View Issue Details

IDProjectCategoryView StatusLast Update
0015648LazarusLCLpublic2010-03-09 09:45
Reportercobines Assigned ToPaul Ishenin  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version0.9.29 (SVN) 
Fixed in Version0.9.29 (SVN) 
Summary0015648: Application is not properly deactivated
DescriptionThe 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.
TagsNo tags attached.
Fixed in Revision23884
LazTarget-
WidgetsetWin32/Win64, QT
Attached Files

Relationships

related to 0015331 closedMattias Gaertner IDE should reload a (text, XML...) file if it has changed on disk 
related to 0015340 closedJuha Manninen QT version of Lazarus does not reload a changed file in editor automatically 

Activities

Zeljan Rikalo

2010-02-02 08:06

developer   ~0034150

My patch is already here http://bugs.freepascal.org/view.php?id=15331 and wait to be commited.Please test with that patch and give some feedback.

cobines

2010-02-02 23:50

reporter   ~0034170

Yes, your patch is exactly what I meant. I have tested on Win32, Linux/GTK2, and Linux/QT and application activation/deactivation is working. Focus is properly restored too.

The difference between the widgetsets is that Win32 and QT send on deactivate:
- Deactivate app
- Kill focus

But GTK2 sends:
- Kill focus
- Deactivate app

So it is always working on GTK2, and never on Win32 and QT.

If the patch gets committed I think this issue can be resolved.

Zeljan Rikalo

2010-02-03 08:05

developer   ~0034182

Yes, win32 & qt works as expected, don't know for gtk2, but if something's wrong with gtk2 that's because that it's still common gtk1 code.
Again: if ws sends app deactivate then app is deactivated.Everything else is wrong (like it is now in LCL).

Flávio Etrusco

2010-02-28 05:47

developer   ~0034843

Was the patch applied? I still see the buggy behavior in Win32.
I have an issue registered regarding Gtk2 behavior; it triggers Deactivate on every form switch.

Zeljan Rikalo

2010-02-28 09:17

developer   ~0034844

No it's not applied yet.

Paul Ishenin

2010-03-09 09:14

manager   ~0035061

Please test and close if ok.

Zeljan Rikalo

2010-03-09 09:45

developer   ~0035062

It's ok now. Thanks.

Issue History

Date Modified Username Field Change
2010-02-02 03:21 cobines New Issue
2010-02-02 03:21 cobines Widgetset => Win32/Win64, QT
2010-02-02 08:05 Zeljan Rikalo Relationship added related to 0015331
2010-02-02 08:06 Zeljan Rikalo LazTarget => -
2010-02-02 08:06 Zeljan Rikalo Note Added: 0034150
2010-02-02 08:06 Zeljan Rikalo Status new => feedback
2010-02-02 08:07 Zeljan Rikalo Relationship added related to 0015340
2010-02-02 23:50 cobines Note Added: 0034170
2010-02-03 08:05 Zeljan Rikalo Note Added: 0034182
2010-02-28 05:47 Flávio Etrusco Note Added: 0034843
2010-02-28 09:17 Zeljan Rikalo Note Added: 0034844
2010-03-09 09:14 Paul Ishenin Fixed in Revision => 23884
2010-03-09 09:14 Paul Ishenin Status feedback => resolved
2010-03-09 09:14 Paul Ishenin Fixed in Version => 0.9.29 (SVN)
2010-03-09 09:14 Paul Ishenin Resolution open => fixed
2010-03-09 09:14 Paul Ishenin Assigned To => Paul Ishenin
2010-03-09 09:14 Paul Ishenin Note Added: 0035061
2010-03-09 09:45 Zeljan Rikalo Status resolved => closed
2010-03-09 09:45 Zeljan Rikalo Note Added: 0035062