mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-05 07:08:23 +02:00
Qt5: removed old qt4 workaround for buggy application activate/deactivate.
This commit is contained in:
parent
058b949f47
commit
6c47517822
@ -846,84 +846,27 @@ 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
|
||||
if not FAppActive then
|
||||
begin
|
||||
FAppActive := True;
|
||||
{$IF DEFINED(QTDEBUGAPPACTIVATE) OR DEFINED(VerboseQtEvents)}
|
||||
DebugLn('TQtWidgetSet.EventFilter: Application is activated: ',dbgs(GetTickCount));
|
||||
{$ENDIF}
|
||||
QEvent_accept(Event);
|
||||
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);
|
||||
if FAppActive then
|
||||
begin
|
||||
FAppActive := False;
|
||||
QEvent_accept(Event);
|
||||
Application.IntfAppDeactivate;
|
||||
end;
|
||||
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;
|
||||
Application.IntfAppDeactivate;
|
||||
Result := True;
|
||||
end;
|
||||
QEventApplicationPaletteChange:
|
||||
begin
|
||||
if Sender = App then
|
||||
|
Loading…
Reference in New Issue
Block a user