! Please note that this is a snapshot of our old Bugzilla server, which is read only since May 29, 2020. Please go to gitlab.xfce.org for our new server !
gtk_window_present inconsistently gives focus.
Status:
RESOLVED: FIXED

Comments

Description Daniel James 2004-10-12 11:58:54 CEST
I'm not sure if this is actually a bug, or if it really is due to xfwm4. When
gtk_window_present is called for a hidden window it doesn't get focus. If it is
called for a window that isn't hidden it does.

I'm not sure if this is the reason, but I've noticed that when running some
applications under xfwm4, some dialogs (such as search dialogs) don't get focus
when they probably should.
Comment 1 Daniel James 2004-11-02 17:33:51 CET
I've looked into the code for gtk_window_present, and it's probably a
bug/feature in GTK, although I'm not 100%. Here's the relevant code:

  if (GTK_WIDGET_VISIBLE (window))
    {
      g_assert (widget->window != NULL);
      
      gdk_window_show (widget->window);

      /* note that gdk_window_focus() will also move the window to
       * the current desktop, for WM spec compliant window managers.
       */
      gdk_window_focus (widget->window,
                        gtk_get_current_event_time ());
    }
  else
    {
      gtk_widget_show (widget);
    }

So I think when the window isn't visible, they're relying on gtk_widget_show to
give the window focus, which is probably wrong. Or maybe they don't think it
should get focus for some reason. So I think I'll take this up with the GTK
people, but any guidance is appreciated, since I really don't know what I'm
talking about here.

In case you're wondering, I assumed that this was a bug with xfwm because it
works as I'd expect with other window managers that I've tried. Sorry.
Comment 2 Olivier Fourdan editbugs 2004-11-02 18:12:32 CET
A quick test doesn't exhibit the problem. 

Could you provide a little piece of code that could show the problem?
Comment 3 Olivier Fourdan editbugs 2004-11-03 08:08:10 CET
Here is why: xfwm4-4.1.90 had that nice 'anti focus stealing" feature activated,
unfortunately GTK doesn't update its "user_time" field reliably.

Since the user_time is not up to date, xfwm4 doesn't give focus (that's
precisely how "anti-focus-stealing" works).

In xfwm4 4.1.91, that feature has been made optional and disabled by default.
Comment 4 Daniel James 2004-11-03 14:34:36 CET
Thanks for looking into that. I do like the anti-focus stealing, so I think that
for now I'll just hack any programs where this causes problems (calling
gtk_window_show before present seems to work). 

Bug #391

Reported by:
Daniel James
Reported on: 2004-10-12
Last modified on: 2009-07-14

People

Assignee:
Olivier Fourdan
CC List:
0 users

Version

Attachments

Additional information