GNOME Bugzilla – Bug 695366
gtk_widget_get_screen returns wrong screen
Last modified: 2013-03-09 01:47:04 UTC
gtk_widget_get_screen returns the wrong screen for a GtkWindow when the window in question is created by a process originally started on another screen. eg I have an app which starts a daemon instance and opens multiple windows. The user may start the daemon and initial window on one screen, then change workspaces and run the program again to open another window (via a socket). gtk_widget_get_screen reports windows opened in this way as being on the initial screen rather than their actual screen. eg where win is a GtkWindow: GdkDisplay* display = gtk_widget_get_display( GTK_WIDGET( win ) ); GdkWindow* window = gtk_widget_get_window( GTK_WIDGET( win ) ); GdkScreen* screen = gtk_widget_get_screen( GTK_WIDGET( win ) ); printf("gdk_screen_get_number = %d\n", gdk_screen_get_number( screen ) ); Tested on gtk 2.24 and 3.4
Actually, I see now that even just creating a single gtkwindow on screen number 1 (desktop 2), gtk_widget_get_screen always returns screen number 0. Same for moving the window to another workspace. Testing with plain openbox. This function doesn't seem to be working at all?
are you sure you know what screens are ? workspaces are a different concept.
In some docs I got the impression a gdkscreen was a desktop, but looking at the limited gdk docs this doesn't now appear to be the case - sounds more like it correlates to an X screen. So my results with this function may be correct. Know any functions or code off-hand for getting the current workspace (desktop) of a gtkwindow? Thanks.