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 695366 - gtk_widget_get_screen returns wrong screen
gtk_widget_get_screen returns wrong screen
Status: RESOLVED INVALID
Product: gtk+
Classification: Platform
Component: Widget: Other
3.4.x
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2013-03-07 15:44 UTC by IgnorantGuru
Modified: 2013-03-09 01:47 UTC
See Also:
GNOME target: ---
GNOME version: 3.3/3.4



Description IgnorantGuru 2013-03-07 15:44:38 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
Comment 1 IgnorantGuru 2013-03-07 16:09:33 UTC
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?
Comment 2 Matthias Clasen 2013-03-09 01:17:38 UTC
are you sure you know what screens are ? workspaces are a different concept.
Comment 3 IgnorantGuru 2013-03-09 01:47:04 UTC
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.