View Issue Details

IDProjectCategoryView StatusLast Update
0017562LazarusWidgetsetpublic2019-04-22 19:30
ReporterMartin Friebe Assigned ToMartin Friebe  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version0.9.29 (SVN) 
Summary0017562: GTK2: SetFocus is ignored in certain cases
DescriptionTested with attached app.

If the checkbox is checked, then closing Form3 should Focus Form2.Edit1
- Checkbox must be checked always
- Form3 can be shown via button1
- Form3 can be closed by click on Form3 (Form3.OnClick)
- Form3 can be closed by click on one of the other forms (Form3.Deactivate

** On Ubunto9 / Gnome
- With single-task-bar-button or with multi-task-bar-button
 Close form3 via click on Form2 or Form3 => works: edit has focus
   (If LCL compiled with -dVerboseFocus,
    you can see additional focus msgs after the focus was set)
 Close Form3 via click on Form1 => fails Form1 will be focused (BUG)

** On Fedora 13 / XFCE Desktop
- With single-task-bar-button or with multi-task-bar-button
 Close form3 via click on Form1 or Form2 => works: edit has focus
 Close Form3 via click on Form3 => fails Form1 will be focused (BUG)
   (If LCL compiled with -dVerboseFocus,
    you can see additional focus msgs after the focus was set)


TagsNo tags attached.
Fixed in Revision
LazTarget-
WidgetsetGTK 2
Attached Files

Relationships

related to 0017533 closedZeljan Rikalo Editor does not get focused after closing autocompletion popup 
related to 0017253 closedMartin Friebe GTK2 focus is report wrong 
related to 0017558 closedPaul Ishenin SetFocus fails, if form is docked (regression) 

Activities

2010-10-06 21:08

 

focus_bug.rar (3,432 bytes)

Zeljan Rikalo

2010-10-07 08:38

developer   ~0041570

@Martin, just checked this and it seem to be ok. Maybe my latest patch about form focusing fixed this one also (tested under Fedora 3 with gtk2-2.12, later I'll try under FC13 + xfce + gtk-2.20).

Martin Friebe

2010-10-07 14:38

manager   ~0041581

Just tested, issue still exists

Zeljan Rikalo

2010-10-07 19:43

developer   ~0041588

Yes it's true that this issue exists under xfce wm (Fedora 13), but guess what. Just tested under KDE Fedora 13 and seem that it works ok.This issue is somehow connected to window manager. Qt shows this bug all the time: it says in console that edit is focused , but visually form 1 is active.

Zeljan Rikalo

2010-10-07 20:25

developer   ~0041591

ok (talking about qt), this could be because of missing part in TQtWidgetSet.SetFocus(). MSDN says that when an control is focused via setFocus it's window (form) should be activated first if it's not active window. THat's exactly what happens here. Try to add Form2.BringToFront before Form2.Edit1.SetFocus and you'll see that everything works ok (probably same applies to gtk2), since BringToFront isn't needed on all window managers / versions of X server.

Martin Friebe

2010-10-07 23:02

manager   ~0041597

see also note 0041594 on 0017533

At least the XFCE (Fedora 13) has such a focus change after the OnClick finishes:

//// First the SetFocus as called in OnClick

[TWinControl.SetFocus] Edit1:TEdit Visible=True HandleAllocated=True
TCustomForm.SetFocus Form2:TForm2 ActiveControl=Edit1:TEdit
TCustomForm.SetWindowFocus Form2:TForm2 NewFocusControl=Edit1:TEdit HndAlloc=True

///// in the gtk2 widgetset

[TGtk2WidgetSet.SetFocus] A hWnd=0931D808=GtkEntry [RMVDFStPrDb] LCLObject=006505B0=Edit1:TEdit<Is MainWidget><Is FixedWidget><Is CoreWidget>
[TGtk2WidgetSet.SetFocus] B
   TopLevel=0928B2C0 OldFocus=0927B328=GtkEventBox [RMVDStPrDb] LCLObject=0064F420=Button1:TButton<Is MainWidget><Is FixedWidget>
  C TopLevel is a gtkwindow focus_widget=0931D808 LCLParent=Edit1:TEdit
  E taking ImplementationWidget
  G NewFocusWidget=0931D808 Edit1:TEdit WidVisible=TRUE WidRealized=TRUE WidMapped=TRUE WidCanfocus=TRUE TopLvlVisible=TRUE
  J Grabbing focus 0931D808=GtkEntry [RMVDFStPrDb] LCLObject=006505B0=Edit1:TEdit<Is MainWidget><Is FixedWidget><Is CoreWidget>

///// There also is a call to set the window
///// Note that the Edit already was the focused/active control for the form => so all that is done is setting the window.

TGtk2WidgetSet.SetForegroundWindow hWnd=153662144 LCLObject=Form2:TForm2
[TGtk2WidgetSet.SetFocus] END hWnd=154261512 NewFocus=0927B328 NewLCLParent=Button1:TButton
======== Done Focus edit1 in form2 ============
**********************************************

///// Now the On click is finished:

GTKFocusCBAfter Widget=0928B210 Event^.theIn=1 LCLObject=Form1:TForm1
     GetFocus=0927B328 ParentLCLFocus=Button1:TButton


//// And I have no idea who sends the above
//// trouble is: even if you do Application.ProcessMessages *after* calling Form3.Hide => it is only done when the OnClick finishes.
So what, I am asking myself: if the window manager schedules it at the time of closing form3, why doesn't ProcessMessages pick it up?

[TCustomForm.WndProc] Form1:TForm1 FActiveControl=Button1:TButton

[TGtk2WidgetSet.SetFocus] A hWnd=0927B328=GtkEventBox [RMVDStPrDb] LCLObject=0064F420=Button1:TButton<Is MainWidget><Is FixedWidget>
[TGtk2WidgetSet.SetFocus] B

Zeljan Rikalo

2010-10-08 17:58

developer   ~0041616

Yes, got same thing under gtk2-2.20 and Fedora 13, there's an alien GTKFocusCBAfter ...

Zeljan Rikalo

2010-10-10 20:47

developer   ~0041706

Tested again under FC13: XFCE, Gnome, KDE, BlackBox and CANNOT reproduce it anymore. Can you please recheck once again (haven't included any logs but used example and it works ok and focus is always where it should be - in edit field).
NOTE: I've enabled focus stealing prevention in XFCE also, so don't know what happens without it.

Martin Friebe

2010-10-10 22:54

manager   ~0041711

Ubuntu9 Gnome

clicking on Form1 will activate Form1, despite Form2.Edit1.SetFocus

Zeljan Rikalo

2010-10-11 08:03

developer   ~0041715

What's gtk2 version on Ubuntu 9 , and can you test under KDE ubuntu 9 (if you installed it there) ?

Martin Friebe

2010-10-11 12:15

manager   ~0041720

Ubuntu: gtk2.16.1 (not exactly sure...)
Don't have kde on Ubuntu.

Also tested on Fedora FC13 with gnome. Same effect: click form1, and form1.button1 is focused instead of Form2.edit1

FC13 gtk2 2.20.1-1.fc13

Zeljan Rikalo

2011-12-07 14:46

developer   ~0054786

Last edited: 2011-12-07 14:51

hm... works fine with kwin window manager, also works fine with XFCE 4.8 (Fedora 16), but does not work ok with Gnome-3.2 on Fedora 16 ...
UPDATE: Wrong test was with Gnome-3.2 , I forgot to enable checkbox.
So this is final tests maded on Fedora 14 (KDE-4.6.5 kwin, XFCE 4.6, Gnome-2.32) and Fedora 16 (KDE-4.7.3 kwin, XFCE 4.8 and Gnome 3.2) IN ALL CASES IT WORKS FINE - paralel test with qt version shows totally same behaviour.

Zeljan Rikalo

2011-12-07 14:51

developer   ~0054787

@Martin can you retest please ? I cannot reproduce (explanation in my previous note).

Martin Friebe

2011-12-07 16:36

manager   ~0054795

no longer able to reproduce

Issue History

Date Modified Username Field Change
2010-10-06 21:08 Martin Friebe New Issue
2010-10-06 21:08 Martin Friebe File Added: focus_bug.rar
2010-10-06 21:08 Martin Friebe LazTarget => -
2010-10-06 21:08 Martin Friebe Widgetset => GTK 2
2010-10-06 21:09 Martin Friebe Relationship added related to 0017533
2010-10-06 21:13 Martin Friebe Relationship added related to 0017558
2010-10-07 08:38 Zeljan Rikalo Note Added: 0041570
2010-10-07 08:38 Zeljan Rikalo Status new => feedback
2010-10-07 14:38 Martin Friebe Note Added: 0041581
2010-10-07 19:43 Zeljan Rikalo Note Added: 0041588
2010-10-07 20:25 Zeljan Rikalo Note Added: 0041591
2010-10-07 23:02 Martin Friebe Note Added: 0041597
2010-10-08 17:58 Zeljan Rikalo Note Added: 0041616
2010-10-10 20:47 Zeljan Rikalo Note Added: 0041706
2010-10-10 22:54 Martin Friebe Note Added: 0041711
2010-10-11 08:03 Zeljan Rikalo Note Added: 0041715
2010-10-11 12:15 Martin Friebe Note Added: 0041720
2010-11-06 12:47 Zeljan Rikalo Relationship added related to 0017253
2010-12-05 20:20 Vincent Snijders Status feedback => acknowledged
2011-12-07 14:46 Zeljan Rikalo Note Added: 0054786
2011-12-07 14:51 Zeljan Rikalo Note Edited: 0054786
2011-12-07 14:51 Zeljan Rikalo Note Added: 0054787
2011-12-07 14:51 Zeljan Rikalo Status acknowledged => feedback
2011-12-07 16:36 Martin Friebe Status feedback => resolved
2011-12-07 16:36 Martin Friebe Resolution open => fixed
2011-12-07 16:36 Martin Friebe Assigned To => Martin Friebe
2011-12-07 16:36 Martin Friebe Note Added: 0054795
2019-04-22 19:30 Martin Friebe Status resolved => closed