mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-28 22:40:56 +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);
|
LCLQt_PopupMenuTriggered = QEventType(Ord(QEventUser) + $1003);
|
||||||
// QEventType(Ord(QEventUser) + $1004 is reserved by
|
// QEventType(Ord(QEventUser) + $1004 is reserved by
|
||||||
// LCLQt_ClipboardPrimarySelection (qtobjects) to reduce includes !
|
// 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)
|
// needed by itemviews (TQtListWidget, TQtTreeWidget)
|
||||||
LCLQt_ItemViewAfterMouseRelease = QEventType(Ord(QEventUser) + $1008);
|
LCLQt_ItemViewAfterMouseRelease = QEventType(Ord(QEventUser) + $1008);
|
||||||
|
@ -673,6 +673,13 @@ var
|
|||||||
R: TRect;
|
R: TRect;
|
||||||
AQtPoint: TQtPoint;
|
AQtPoint: TQtPoint;
|
||||||
|
|
||||||
|
function IsAnyWindowActive: Boolean;
|
||||||
|
begin
|
||||||
|
Result := (QApplication_activeWindow() <> nil) or
|
||||||
|
(QApplication_activeModalWidget() <> nil) or
|
||||||
|
(QApplication_activePopupWidget() <> nil);
|
||||||
|
end;
|
||||||
|
|
||||||
function IsSystemTrayWidget: boolean;
|
function IsSystemTrayWidget: boolean;
|
||||||
var
|
var
|
||||||
AName: WideString;
|
AName: WideString;
|
||||||
@ -831,30 +838,84 @@ begin
|
|||||||
|
|
||||||
QEventApplicationActivate:
|
QEventApplicationActivate:
|
||||||
begin
|
begin
|
||||||
if Assigned(Application) and not FAppActive then
|
LCLEvent := QLCLMessageEvent_create(LCLQt_ApplicationActivate);
|
||||||
begin
|
// activate it imediatelly (high priority)
|
||||||
FAppActive := True;
|
QCoreApplication_postEvent(Sender, LCLEvent, 1 {high priority});
|
||||||
{$IF DEFINED(QTDEBUGAPPACTIVATE) OR DEFINED(VerboseQtEvents)}
|
end;
|
||||||
DebugLn('TQtWidgetSet.EventFilter: Application is activated: ',dbgs(GetTickCount));
|
LCLQt_ApplicationActivate:
|
||||||
{$ENDIF}
|
begin
|
||||||
Application.IntfAppActivate;
|
if Assigned(Application) and not FAppActive then
|
||||||
Result := True;
|
begin
|
||||||
end;
|
FAppActive := True;
|
||||||
|
{$IF DEFINED(QTDEBUGAPPACTIVATE) OR DEFINED(VerboseQtEvents)}
|
||||||
|
DebugLn('TQtWidgetSet.EventFilter: Application is activated: ',dbgs(GetTickCount));
|
||||||
|
{$ENDIF}
|
||||||
|
Application.IntfAppActivate;
|
||||||
|
Result := True;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
QEventApplicationDeactivate:
|
QEventApplicationDeactivate:
|
||||||
begin
|
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
|
if Assigned(Application) and FAppActive then
|
||||||
begin
|
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)}
|
{$IF DEFINED(QTDEBUGAPPACTIVATE) OR DEFINED(VerboseQtEvents)}
|
||||||
DebugLn('TQtWidgetSet.EventFilter: Application is deactivated: ',dbgs(GetTickCount));
|
DebugLn('TQtWidgetSet.EventFilter: Application is deactivated: ',dbgs(GetTickCount));
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
FAppActive := False;
|
FAppActive := False;
|
||||||
ReleaseCapture;
|
|
||||||
Application.IntfAppDeactivate;
|
Application.IntfAppDeactivate;
|
||||||
Result := True;
|
Result := True;
|
||||||
end;
|
end;
|
||||||
end;
|
|
||||||
|
|
||||||
QEventApplicationPaletteChange:
|
QEventApplicationPaletteChange:
|
||||||
begin
|
begin
|
||||||
|
@ -307,6 +307,12 @@ const
|
|||||||
LCLQt_PopupMenuTriggered = QEventType(Ord(QEventUser) + $1003);
|
LCLQt_PopupMenuTriggered = QEventType(Ord(QEventUser) + $1003);
|
||||||
// QEventType(Ord(QEventUser) + $1004 is reserved by
|
// QEventType(Ord(QEventUser) + $1004 is reserved by
|
||||||
// LCLQt_ClipboardPrimarySelection (qtobjects) to reduce includes !
|
// 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)
|
// needed by itemviews (TQtListWidget, TQtTreeWidget)
|
||||||
LCLQt_ItemViewAfterMouseRelease = QEventType(Ord(QEventUser) + $1008);
|
LCLQt_ItemViewAfterMouseRelease = QEventType(Ord(QEventUser) + $1008);
|
||||||
|
@ -646,6 +646,13 @@ var
|
|||||||
R: TRect;
|
R: TRect;
|
||||||
AQtPoint: TQtPoint;
|
AQtPoint: TQtPoint;
|
||||||
|
|
||||||
|
function IsAnyWindowActive: Boolean;
|
||||||
|
begin
|
||||||
|
Result := (QApplication_activeWindow() <> nil) or
|
||||||
|
(QApplication_activeModalWidget() <> nil) or
|
||||||
|
(QApplication_activePopupWidget() <> nil);
|
||||||
|
end;
|
||||||
|
|
||||||
function IsSystemTrayWidget: boolean;
|
function IsSystemTrayWidget: boolean;
|
||||||
var
|
var
|
||||||
AName: WideString;
|
AName: WideString;
|
||||||
@ -796,7 +803,6 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
QEventApplicationFontChange: SetDefaultAppFontName;
|
QEventApplicationFontChange: SetDefaultAppFontName;
|
||||||
|
|
||||||
QEventStyleChange:
|
QEventStyleChange:
|
||||||
begin
|
begin
|
||||||
if (Sender = QCoreApplication_instance()) then
|
if (Sender = QCoreApplication_instance()) then
|
||||||
@ -805,9 +811,13 @@ begin
|
|||||||
ThemeServices.IntfDoOnThemeChange;
|
ThemeServices.IntfDoOnThemeChange;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
QEventApplicationActivate:
|
QEventApplicationActivate:
|
||||||
begin
|
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
|
if Assigned(Application) and not FAppActive then
|
||||||
begin
|
begin
|
||||||
FAppActive := True;
|
FAppActive := True;
|
||||||
@ -817,22 +827,68 @@ begin
|
|||||||
Application.IntfAppActivate;
|
Application.IntfAppActivate;
|
||||||
Result := True;
|
Result := True;
|
||||||
end;
|
end;
|
||||||
end;
|
|
||||||
|
|
||||||
QEventApplicationDeactivate:
|
QEventApplicationDeactivate:
|
||||||
begin
|
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
|
if Assigned(Application) and FAppActive then
|
||||||
begin
|
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)}
|
{$IF DEFINED(QTDEBUGAPPACTIVATE) OR DEFINED(VerboseQtEvents)}
|
||||||
DebugLn('TQtWidgetSet.EventFilter: Application is deactivated: ',dbgs(GetTickCount));
|
DebugLn('TQtWidgetSet.EventFilter: Application is deactivated: ',dbgs(GetTickCount));
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
ReleaseCapture;
|
FAppActive := False;
|
||||||
Application.IntfAppDeactivate;
|
Application.IntfAppDeactivate;
|
||||||
Result := True;
|
Result := True;
|
||||||
end;
|
end;
|
||||||
end;
|
|
||||||
|
|
||||||
QEventApplicationPaletteChange:
|
QEventApplicationPaletteChange:
|
||||||
begin
|
begin
|
||||||
if Sender = App then
|
if Sender = App then
|
||||||
|
Loading…
Reference in New Issue
Block a user