View Issue Details

IDProjectCategoryView StatusLast Update
0015494LazarusIDEpublic2011-12-01 11:23
ReporterAndrzej BoruckiAssigned ToPaul Ishenin 
PrioritynormalSeverityminorReproducibilityhave not tried
Status closedResolutionfixed 
Product Version0.9.29 (SVN)Product Build23301 
Target VersionFixed in Version0.9.29 (SVN) 
Summary0015494: Trouble with focus
DescriptionI turn on the compile dialog: Environment->Options->Environment->Show compile dialog. I compile with Control+F9. This dialog is not modal but always on top, sometimes visible above another application when I use Alt+Tab. This dialog has not focus, Enter not closes it, I must click with mouse on button Close. Sometimes (has no reproducibility) when I press Enter, I edit code.
I not compile dialog exists another problems with focus:
If I press F9 - compiles and runs program. If I close program, source editor nor Lazarus menu not have focus. F9 not works, I must click on source editor to use F9.
If I press Control+F9 focus receives Messages window and I can't edit source until click on Source Editor.
TagsNo tags attached.
Fixed in Revision23911
LazTarget-
WidgetsetWin32/Win64
Attached Files
  • win32focus.patch (1,614 bytes)
    Index: win32callback.inc
    ===================================================================
    --- win32callback.inc	(revision 23543)
    +++ win32callback.inc	(working copy)
    @@ -2249,6 +2249,17 @@
     {$ifdef DEBUG_CARET}
           DebugLn('WM_SETFOCUS received for window ', IntToHex(Window, 8));
     {$endif}
    +      // preventing App window from aquiring the focus
    +      if (Window=TWin32WidgetSet(WidgetSet).AppHandle) then
    +      begin
    +        if (WindowLastFocused<>0) and IsWindow(WindowLastFocused) then 
    +        begin
    +          SetFocus(WindowLastFocused);
    +          Result:=0;
    +          WinProcess:=False;             
    +          Exit;
    +        end;
    +      end;
           // handle feature mouse-click, setfocus, mouse-click -> double-click
           if (Window <> MouseDownWindow) and (MouseDownFocusStatus <> mfNone) then
           begin
    @@ -2256,6 +2267,8 @@
             MouseDownFocusWindow := Window;
           end;
           LMessage.Msg := LM_SETFOCUS;
    +      if Window <> TWin32WidgetSet(WidgetSet).AppHandle then
    +        WindowLastFocused := Window;
         end;
         WM_SHOWWINDOW:
         begin
    Index: win32int.pp
    ===================================================================
    --- win32int.pp	(revision 23543)
    +++ win32int.pp	(working copy)
    @@ -269,6 +269,7 @@
       MouseDownWindow: HWND = 0;
       MouseDownFocusWindow: HWND;
       MouseDownFocusStatus: TMouseDownFocusStatus = mfNone;
    +  WindowLastFocused: HWND = 0;
       ComboBoxHandleSizeWindow: HWND = 0;
       IgnoreNextCharWindow: HWND = 0;  // ignore next WM_(SYS)CHAR message
       // set to true, if we are redirecting a WM_MOUSEWHEEL message, to prevent recursion
    
    win32focus.patch (1,614 bytes)

Relationships

related to 0015279 closedJuha Manninen Lazarus The focus does not return to the IDE after closing the running program 
related to 0012020 closedMattias Gaertner Patches If "Show compile dialog" is active, the focus is put to the messages window when the compilation done 
related to 0014294 closedMartin Friebe Lazarus Stop debug with ctrl-F2, moves focus away from Editor 
related to 0014789 resolvedPaul Ishenin Lazarus Patch: Focus lost when execution stops 

Activities

samuel herzog

2010-01-12 20:46

developer   ~0033591

Last edited: 2010-01-12 20:46

Look's like it is related to already reported problem 0015279.

samuel herzog

2010-01-23 08:49

developer   ~0033804

And it's also related to already problem 0012020.

Dmitry Boyarintsev

2010-01-23 11:34

developer   ~0033809

Last edited: 2010-01-23 11:47

Andrzej, please apply win32focus.patch rebuild both LCL and IDE to test it helps.

2010-01-24 13:37

 

win32focus.patch (1,614 bytes)
Index: win32callback.inc
===================================================================
--- win32callback.inc	(revision 23543)
+++ win32callback.inc	(working copy)
@@ -2249,6 +2249,17 @@
 {$ifdef DEBUG_CARET}
       DebugLn('WM_SETFOCUS received for window ', IntToHex(Window, 8));
 {$endif}
+      // preventing App window from aquiring the focus
+      if (Window=TWin32WidgetSet(WidgetSet).AppHandle) then
+      begin
+        if (WindowLastFocused<>0) and IsWindow(WindowLastFocused) then 
+        begin
+          SetFocus(WindowLastFocused);
+          Result:=0;
+          WinProcess:=False;             
+          Exit;
+        end;
+      end;
       // handle feature mouse-click, setfocus, mouse-click -> double-click
       if (Window <> MouseDownWindow) and (MouseDownFocusStatus <> mfNone) then
       begin
@@ -2256,6 +2267,8 @@
         MouseDownFocusWindow := Window;
       end;
       LMessage.Msg := LM_SETFOCUS;
+      if Window <> TWin32WidgetSet(WidgetSet).AppHandle then
+        WindowLastFocused := Window;
     end;
     WM_SHOWWINDOW:
     begin
Index: win32int.pp
===================================================================
--- win32int.pp	(revision 23543)
+++ win32int.pp	(working copy)
@@ -269,6 +269,7 @@
   MouseDownWindow: HWND = 0;
   MouseDownFocusWindow: HWND;
   MouseDownFocusStatus: TMouseDownFocusStatus = mfNone;
+  WindowLastFocused: HWND = 0;
   ComboBoxHandleSizeWindow: HWND = 0;
   IgnoreNextCharWindow: HWND = 0;  // ignore next WM_(SYS)CHAR message
   // set to true, if we are redirecting a WM_MOUSEWHEEL message, to prevent recursion
win32focus.patch (1,614 bytes)

Paul Ishenin

2010-03-10 09:24

manager   ~0035128

Applied with big modifications. Please review, test and close if ok.

Issue History

Date Modified Username Field Change
2010-01-11 22:26 Andrzej Borucki New Issue
2010-01-11 22:26 Andrzej Borucki Widgetset => Win32/Win64
2010-01-12 20:46 samuel herzog Note Added: 0033591
2010-01-12 20:46 samuel herzog Note Edited: 0033591
2010-01-23 08:49 samuel herzog Note Added: 0033804
2010-01-23 10:42 Dmitry Boyarintsev Relationship added related to 0015279
2010-01-23 10:42 Dmitry Boyarintsev Relationship added related to 0012020
2010-01-23 10:43 Dmitry Boyarintsev Relationship added related to 0014294
2010-01-23 10:51 Dmitry Boyarintsev Relationship added related to 0014789
2010-01-23 11:34 Dmitry Boyarintsev File Added: win32focus.patch
2010-01-23 11:34 Dmitry Boyarintsev LazTarget => -
2010-01-23 11:34 Dmitry Boyarintsev Note Added: 0033809
2010-01-23 11:34 Dmitry Boyarintsev Status new => feedback
2010-01-23 11:39 Dmitry Boyarintsev File Deleted: win32focus.patch
2010-01-23 11:39 Dmitry Boyarintsev File Added: win32focus.patch
2010-01-23 11:47 Dmitry Boyarintsev Note Edited: 0033809
2010-01-23 11:47 Dmitry Boyarintsev Note Edited: 0033809
2010-01-24 13:36 Dmitry Boyarintsev File Deleted: win32focus.patch
2010-01-24 13:37 Dmitry Boyarintsev File Added: win32focus.patch
2010-02-05 00:23 Dmitry Boyarintsev Relationship added related to 0013749
2010-02-05 10:49 Dmitry Boyarintsev Relationship deleted related to 0013749
2010-03-10 09:24 Paul Ishenin Fixed in Revision => 23911
2010-03-10 09:24 Paul Ishenin Status feedback => resolved
2010-03-10 09:24 Paul Ishenin Fixed in Version => 0.9.29 (SVN)
2010-03-10 09:24 Paul Ishenin Resolution open => fixed
2010-03-10 09:24 Paul Ishenin Assigned To => Paul Ishenin
2010-03-10 09:24 Paul Ishenin Note Added: 0035128
2011-12-01 11:23 Marc Weustink Status resolved => closed