GTK2 focus is report wrong
Original Reporter info from Mantis: Martin @martin_frb
-
Reporter name: Martin Friebe
Original Reporter info from Mantis: Martin @martin_frb
- Reporter name: Martin Friebe
Description:
This bug has been observed in the IDE. see bug #17207 (closed) for the exact observations.
- Debian squeeze 2.6.32-5 / libgtk2 2.20.1-1
- switching focus by tab between: non lazarus windown / main-ide-bar-win / Source-editor
- IDE does not use single-task-bar-button
- It is possible (but not confirmed to be the same issue) that it also happens on Ubuntu 10.04 / GTK 2.20
The short description is, that at some time focus goes from SynEdit (in separate source-editor-window) to ComponentNotebook (in main IDE window, default focused component in main-ide-win)
This focus switch has been observed without WM_KillFocus msg
SynEdit may receive a WM_SetFocus msg afterwards (despite never having been told of loosing it)
(unrelated issue: under gtk2 WMSetFocus seems to be send always twice)
In the end a state as follows is reached:
- SynEdit receives KeyDown/Press/Up events. (indicates it has focus)
- in GTKAPIWidgetClient_DrawCaret (lcl\interfaces\gtk2\gtk2winapiwindow.pp line 511) when triggered for the SynEdit in question, the code in line 602:
HasFocus := gtk_widget_has_focus(Widget);
evaluates to TRUE (indicates it has focus)
- If Synedit calls SynEdit.Focused (which is TWinControl.Focused it receives FALSE.
This directly contradicts the 2 above observations.
Also the user reports of having switched to the Source-editor-window. But analysing TWinControl.Focused shows that "FindOwnerControl(GetFocus)" returns ComponentNotebook.
If the user has switched to the source-editor window a component inside the source-editor window should be focused. If SynEdit receives keydown, then it should be SynEdit.
To all appearance TWinControl.Focused reports wrong
---
It is not necessarily related to the main-ide-bar. This is simple the window used in the test on the original report. It has not been tested if similar behaviour could provoked with other windows
---
The exact detail from the individual functions called by TWinControl.Focused (when called by SynEdit, in the described situation):
FindOwnerControl(GetFocus)=ComponentNotebook
CanTab=True
WidgetSetClass.CanFocus(Self)=True
Additional information:
The information can be derived from the logs kons5 and kons6 on bug #17207 (closed)
Mantis conversion info:
- Mantis ID: 17253
- Version: 0.9.29 (SVN)
- Monitored by: » demerson3 (David Emerson)