mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-27 13:00:17 +02:00
Qt,Qt5: restored the way how we send application activate/deactivate to LCL, removed calling of RestoreStayOnTop windows which cause confusion.
(cherry picked from commit 5081a5269f
)
This commit is contained in:
parent
22fa14ce16
commit
98742e6185
@ -311,6 +311,12 @@ const
|
||||
LCLQt_PopupMenuTriggered = QEventType(Ord(QEventUser) + $1003);
|
||||
// QEventType(Ord(QEventUser) + $1004 is reserved by
|
||||
// LCLQt_ClipboardPrimarySelection (qtobjects) to reduce includes !
|
||||
LCLQt_ApplicationActivate = QEventType(Ord(QEventUser) + $1005);
|
||||
// deactivate sent from qt
|
||||
LCLQt_ApplicationDeactivate = QEventType(Ord(QEventUser) + $1006);
|
||||
// deactivate sent from LCLQt_ApplicationDeactivate to check it twice
|
||||
// instead of using timer.
|
||||
LCLQt_ApplicationDeactivate_Check = QEventType(Ord(QEventUser) + $1007);
|
||||
|
||||
// needed by itemviews (TQtListWidget, TQtTreeWidget)
|
||||
LCLQt_ItemViewAfterMouseRelease = QEventType(Ord(QEventUser) + $1008);
|
||||
|
@ -673,6 +673,13 @@ var
|
||||
R: TRect;
|
||||
AQtPoint: TQtPoint;
|
||||
|
||||
function IsAnyWindowActive: Boolean;
|
||||
begin
|
||||
Result := (QApplication_activeWindow() <> nil) or
|
||||
(QApplication_activeModalWidget() <> nil) or
|
||||
(QApplication_activePopupWidget() <> nil);
|
||||
end;
|
||||
|
||||
function IsSystemTrayWidget: boolean;
|
||||
var
|
||||
AName: WideString;
|
||||
@ -831,30 +838,84 @@ begin
|
||||
|
||||
QEventApplicationActivate:
|
||||
begin
|
||||
if Assigned(Application) and not FAppActive then
|
||||
begin
|
||||
FAppActive := True;
|
||||
{$IF DEFINED(QTDEBUGAPPACTIVATE) OR DEFINED(VerboseQtEvents)}
|
||||
DebugLn('TQtWidgetSet.EventFilter: Application is activated: ',dbgs(GetTickCount));
|
||||
{$ENDIF}
|
||||
Application.IntfAppActivate;
|
||||
Result := True;
|
||||
end;
|
||||
LCLEvent := QLCLMessageEvent_create(LCLQt_ApplicationActivate);
|
||||
// activate it imediatelly (high priority)
|
||||
QCoreApplication_postEvent(Sender, LCLEvent, 1 {high priority});
|
||||
end;
|
||||
LCLQt_ApplicationActivate:
|
||||
begin
|
||||
if Assigned(Application) and not FAppActive then
|
||||
begin
|
||||
FAppActive := True;
|
||||
{$IF DEFINED(QTDEBUGAPPACTIVATE) OR DEFINED(VerboseQtEvents)}
|
||||
DebugLn('TQtWidgetSet.EventFilter: Application is activated: ',dbgs(GetTickCount));
|
||||
{$ENDIF}
|
||||
Application.IntfAppActivate;
|
||||
Result := True;
|
||||
end;
|
||||
end;
|
||||
|
||||
QEventApplicationDeactivate:
|
||||
begin
|
||||
// we must check if we are ready for deactivation (low priority)
|
||||
// this is 2way check. LCLQt_ApplicationDeActivate sends
|
||||
// LCLQt_ApplicationDeActivate_Check to be 100% sure if needed.
|
||||
LCLEvent := QLCLMessageEvent_create(LCLQt_ApplicationDeActivate);
|
||||
QCoreApplication_postEvent(Sender, LCLEvent, -$FF);
|
||||
end;
|
||||
|
||||
LCLQt_ApplicationDeactivate:
|
||||
begin
|
||||
if Assigned(Application) and FAppActive then
|
||||
begin
|
||||
if not IsAnyWindowActive then
|
||||
begin
|
||||
QCoreApplication_sendPostedEvents(nil, QEventWindowActivate);
|
||||
QCoreApplication_processEvents(QEventLoopAllEvents, 10 {msec});
|
||||
end;
|
||||
|
||||
// if there's active window after posting from queue, just exit ...
|
||||
// app is not deactivated.
|
||||
if IsAnyWindowActive then
|
||||
exit(True);
|
||||
|
||||
// to be 100% sure that we are really deactivated, send check
|
||||
// event with pretty low priority. We need
|
||||
// LCLQt_ApplicationDeActivate_Check to avoid infinite loop inside
|
||||
// this event with same code.
|
||||
LCLEvent := QLCLMessageEvent_create(LCLQt_ApplicationDeActivate_Check);
|
||||
QCoreApplication_postEvent(Sender, LCLEvent, -$FFFF);
|
||||
Result := True;
|
||||
end;
|
||||
end;
|
||||
|
||||
LCLQt_ApplicationDeactivate_Check:
|
||||
if Assigned(Application) and FAppActive then
|
||||
begin
|
||||
// 1st send posted events, and process few events from queue
|
||||
if not IsAnyWindowActive then
|
||||
begin
|
||||
QCoreApplication_sendPostedEvents(nil, QEventWindowActivate);
|
||||
QCoreApplication_processEvents(QEventLoopAllEvents, 10 {msec});
|
||||
end;
|
||||
|
||||
// if there's active window after posting from queue, just exit ...
|
||||
// app is not deactivated.
|
||||
if IsAnyWindowActive then
|
||||
begin
|
||||
{$IF DEFINED(QTDEBUGAPPACTIVATE) OR DEFINED(VerboseQtEvents)}
|
||||
DebugLn('NOTICE: TQtWidgetSet.EventFilter: App deactivation called with active windows ... ignoring.');
|
||||
{$ENDIF}
|
||||
QEvent_ignore(Event);
|
||||
exit(True);
|
||||
end;
|
||||
{$IF DEFINED(QTDEBUGAPPACTIVATE) OR DEFINED(VerboseQtEvents)}
|
||||
DebugLn('TQtWidgetSet.EventFilter: Application is deactivated: ',dbgs(GetTickCount));
|
||||
{$ENDIF}
|
||||
FAppActive := False;
|
||||
ReleaseCapture;
|
||||
Application.IntfAppDeactivate;
|
||||
Result := True;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
QEventApplicationPaletteChange:
|
||||
begin
|
||||
|
@ -307,6 +307,12 @@ const
|
||||
LCLQt_PopupMenuTriggered = QEventType(Ord(QEventUser) + $1003);
|
||||
// QEventType(Ord(QEventUser) + $1004 is reserved by
|
||||
// LCLQt_ClipboardPrimarySelection (qtobjects) to reduce includes !
|
||||
LCLQt_ApplicationActivate = QEventType(Ord(QEventUser) + $1005);
|
||||
// deactivate sent from qt
|
||||
LCLQt_ApplicationDeactivate = QEventType(Ord(QEventUser) + $1006);
|
||||
// deactivate sent from LCLQt_ApplicationDeactivate to check it twice
|
||||
// instead of using timer.
|
||||
LCLQt_ApplicationDeactivate_Check = QEventType(Ord(QEventUser) + $1007);
|
||||
|
||||
// needed by itemviews (TQtListWidget, TQtTreeWidget)
|
||||
LCLQt_ItemViewAfterMouseRelease = QEventType(Ord(QEventUser) + $1008);
|
||||
|
@ -646,6 +646,13 @@ var
|
||||
R: TRect;
|
||||
AQtPoint: TQtPoint;
|
||||
|
||||
function IsAnyWindowActive: Boolean;
|
||||
begin
|
||||
Result := (QApplication_activeWindow() <> nil) or
|
||||
(QApplication_activeModalWidget() <> nil) or
|
||||
(QApplication_activePopupWidget() <> nil);
|
||||
end;
|
||||
|
||||
function IsSystemTrayWidget: boolean;
|
||||
var
|
||||
AName: WideString;
|
||||
@ -796,7 +803,6 @@ begin
|
||||
end;
|
||||
|
||||
QEventApplicationFontChange: SetDefaultAppFontName;
|
||||
|
||||
QEventStyleChange:
|
||||
begin
|
||||
if (Sender = QCoreApplication_instance()) then
|
||||
@ -805,9 +811,13 @@ begin
|
||||
ThemeServices.IntfDoOnThemeChange;
|
||||
end;
|
||||
end;
|
||||
|
||||
QEventApplicationActivate:
|
||||
begin
|
||||
LCLEvent := QLCLMessageEvent_create(LCLQt_ApplicationActivate);
|
||||
// activate it imediatelly (high priority)
|
||||
QCoreApplication_postEvent(Sender, LCLEvent, 1 {high priority});
|
||||
end;
|
||||
LCLQt_ApplicationActivate:
|
||||
if Assigned(Application) and not FAppActive then
|
||||
begin
|
||||
FAppActive := True;
|
||||
@ -817,22 +827,68 @@ begin
|
||||
Application.IntfAppActivate;
|
||||
Result := True;
|
||||
end;
|
||||
end;
|
||||
|
||||
QEventApplicationDeactivate:
|
||||
begin
|
||||
// we must check if we are ready for deactivation (low priority)
|
||||
// this is 2way check. LCLQt_ApplicationDeActivate sends
|
||||
// LCLQt_ApplicationDeActivate_Check to be 100% sure if needed.
|
||||
LCLEvent := QLCLMessageEvent_create(LCLQt_ApplicationDeActivate);
|
||||
QCoreApplication_postEvent(Sender, LCLEvent, -$FF);
|
||||
end;
|
||||
|
||||
LCLQt_ApplicationDeactivate:
|
||||
begin
|
||||
if Assigned(Application) and FAppActive then
|
||||
begin
|
||||
if not IsAnyWindowActive then
|
||||
begin
|
||||
QCoreApplication_sendPostedEvents(nil, QEventWindowActivate);
|
||||
QCoreApplication_processEvents(QEventLoopAllEvents, 10 {msec});
|
||||
end;
|
||||
|
||||
// if there's active window after posting from queue, just exit ...
|
||||
// app is not deactivated.
|
||||
if IsAnyWindowActive then
|
||||
exit(True);
|
||||
|
||||
// to be 100% sure that we are really deactivated, send check
|
||||
// event with pretty low priority. We need
|
||||
// LCLQt_ApplicationDeActivate_Check to avoid infinite loop inside
|
||||
// this event with same code.
|
||||
LCLEvent := QLCLMessageEvent_create(LCLQt_ApplicationDeActivate_Check);
|
||||
QCoreApplication_postEvent(Sender, LCLEvent, -$FFFF);
|
||||
Result := True;
|
||||
end;
|
||||
end;
|
||||
|
||||
LCLQt_ApplicationDeactivate_Check:
|
||||
if Assigned(Application) and FAppActive then
|
||||
begin
|
||||
FAppActive := False;
|
||||
// 1st send posted events, and process few events from queue
|
||||
if not IsAnyWindowActive then
|
||||
begin
|
||||
QCoreApplication_sendPostedEvents(nil, QEventWindowActivate);
|
||||
QCoreApplication_processEvents(QEventLoopAllEvents, 10 {msec});
|
||||
end;
|
||||
|
||||
// if there's active window after posting from queue, just exit ...
|
||||
// app is not deactivated.
|
||||
if IsAnyWindowActive then
|
||||
begin
|
||||
{$IF DEFINED(QTDEBUGAPPACTIVATE) OR DEFINED(VerboseQtEvents)}
|
||||
DebugLn('NOTICE: TQtWidgetSet.EventFilter: App deactivation called with active windows ... ignoring.');
|
||||
{$ENDIF}
|
||||
QEvent_ignore(Event);
|
||||
exit(True);
|
||||
end;
|
||||
{$IF DEFINED(QTDEBUGAPPACTIVATE) OR DEFINED(VerboseQtEvents)}
|
||||
DebugLn('TQtWidgetSet.EventFilter: Application is deactivated: ',dbgs(GetTickCount));
|
||||
{$ENDIF}
|
||||
ReleaseCapture;
|
||||
FAppActive := False;
|
||||
Application.IntfAppDeactivate;
|
||||
Result := True;
|
||||
end;
|
||||
end;
|
||||
|
||||
QEventApplicationPaletteChange:
|
||||
begin
|
||||
if Sender = App then
|
||||
|
Loading…
Reference in New Issue
Block a user