After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 688830 - gtk_window_present uses an invalid time value, and does not always work
gtk_window_present uses an invalid time value, and does not always work
Status: RESOLVED OBSOLETE
Product: gtk+
Classification: Platform
Component: Widget: Other
3.6.x
Other Linux
: Normal major
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks: 738767
 
 
Reported: 2012-11-21 18:48 UTC by Marco Trevisan (Treviño)
Modified: 2017-09-06 21:04 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Example window showing the present issue (1.39 KB, text/x-vala)
2012-11-21 18:48 UTC, Marco Trevisan (Treviño)
Details
Gtk.Application which does not present its window on second run (805 bytes, text/x-python)
2014-03-29 22:06 UTC, Alex Băluț
Details

Description Marco Trevisan (Treviño) 2012-11-21 18:48:25 UTC
Created attachment 229589 [details]
Example window showing the present issue

Calling gtk_window_present() does not always do what it is supposed to do, in fact even if the proper atoms are correctly set on window, the Window Manager (tested both compiz, metacity and gnome-shell) refuses to put the given window in focus.

This seems really caused by an old timestamp value used when calling gdk_window_focus.
Actually, using this hack to use current X11 server time fixes the issue.

    GdkWindow *gwindow = gtk_widget_get_window (GTK_WIDGET (window));
    guint32 server_time = gdk_x11_get_server_time (gwindow);
    gtk_window_present_with_time (GTK_WINDOW (window), server_time);

Bug 674816 is also a side effect of this problem.

I've attached here a simple example that underlines this issue.
Comment 1 Alex Băluț 2014-03-29 22:06:51 UTC
Created attachment 273254 [details]
Gtk.Application which does not present its window on second run

I also see this bug when:
1. window1 is created and shown;
2. window2 is created, set_transient_for(window1), shown;
3. window2 is closed with the X button;
4. window1 is presented, notice the operation fails, window1 remains in the back.

The attached file shows a Gtk.Application which shows two windows. Close the second window, bring some other window in front of it, then run the app again - notice the remaining window is not presented.

Thanks Marko for the workaround! In Python this would be:

            from gi.repository import GdkX11
            x11_server_time = GdkX11.x11_get_server_time(window1.get_window())
            window1.present_with_time(x11_server_time)
Comment 2 Daniel Boles 2017-09-06 21:04:36 UTC
(In reply to Alex Băluț from comment #1)
> The attached file shows a Gtk.Application which shows two windows. Close the
> second window, bring some other window in front of it, then run the app
> again - notice the remaining window is not presented.

It is for me (and I numbered the window titles to be sure). I guess this is obsolete now. If not, please reopen with more info on your system, or even just explain what I did wrong. :P