Application is not properly deactivated
Original Reporter info from Mantis: cobines
-
Reporter name:
Original Reporter info from Mantis: cobines
- Reporter name:
Description:
The Application.OnActivate and Application.OnDeactivate events are not called on Win32 and Linux-QT4. Only the first OnActivate (after the application has started) is received. While they are working on Linux-Gtk2 I think this is LCL issue not the widgetsets.
Both on Win32 and QT widgetsets the activate/deactivate messages from OS are detected and TApplication.Activate and TApplication.Deactivate functions are being called. What is stopping the OnActivate, OnDeactive events from working is that the application is never deactivated. In the following code
procedure TApplication.Deactivate(Data: PtrInt);
begin
if (AppDestroying in FFlags) then exit;
if (not (AppActive in FFlags)) then exit;
if (FindControl(GetFocus)<>nil) then begin
// another control of this application has got the focus
exit;
end;
Exclude(FFlags,AppActive);
NotifyDeactivateHandler;
end;
the "if (FindControl(GetFocus)<>nil)" condition stops the message from affecting application state. It so happens that on GTK2 this condition is always false (maybe when the application is deactivated its controls also lose focus) - that's why it works. On Win32 and QT there usually is a control with focus so it doesn't work.
I think the application can be active even if no control has focus. It also can be deactivated when a control has focus. Therefore I think this condition should be removed.
Mantis conversion info:
- Mantis ID: 15648
- Build: 23607
- Version: 0.9.29 (SVN)
- Fixed in version: 0.9.29 (SVN)
- Fixed in revision: 23884 (#b2d37865)
- Monitored by: » etrusco (Flávio Etrusco)