GNOME Bugzilla – Bug 688830
gtk_window_present uses an invalid time value, and does not always work
Last modified: 2017-09-06 21:04:36 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.
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)
(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