GNOME Bugzilla – Bug 99496
Gtk+ does not handle multiple screens well under Windows
Last modified: 2011-02-04 16:12:02 UTC
In particular, when you have a Gtk+ window in a second screen, the menu items are opened and displayed always in the first screen. A (unverified) guess may be that there are some checks against invalid coordinates done by the Win32 back end that are invalid for multiple screens. Does this make sense ? If so, where would be the places to look at to investigate and fix this issue ? If not, are there other possible likely candidates ? Arno
I forgot to mention also that the mouse wheel only works in the main display. Arno
I wonder if there exists a "virtual multiple monitor" driver for Win2k? I.e. a piece of software that would make Windows think that there are several physical monitors attached, even if there is only one. Such a driver would make it easier to test software for multiple-monitor correctness without actually having multiple physical monitors. With such a driver, Windows would propagate the fake multiple-monitorness appearance to applications, i.e. windows located on a "virtual monitor" to the left of the "virtual main monitor" should have negative coordinates. I don't think the common "virtual desktop" managers for Win32 work like this, they don't make Windows think there are several monitors.
Created attachment 13581 [details] [review] Fix handling of negative coordinates
It appears that the mouse wheel not working, and the menu items opened in the main display are two separate issues. The mouse wheel is caused by the Win32 GDK back end using LO/HIWORD instead of GET_X/Y_LPARAM, and therefore handling incorrectly negative values. The patch I've just sent fixes this issue (and possibly other similar bugs). The handling of menus is actually a gtk rather than gdk/win32 issue: gtkmenuitem.c explicitely assume that coordinates can't get values below 0. I will also include a patch that addresses this issue, although this patch is not completely satisfactory, but will give you the idea. Arno
Created attachment 13582 [details] [review] possible way to handle negative coordinates for menu positioning
*** Bug 104972 has been marked as a duplicate of this bug. ***
From: "Alan <alan.davies@oracle.com>" <alan.davies@oracle.com> To: gimpwin-dev@yahoogroups.com Subject: [gimpwin-dev] Fix for GTK+ on multiple monitors Date: Wed, 12 Feb 2003 20:18:16 -0000 I think it's been noted before that GTK+ always pops up new windows on the primary monitor with multiple-monitor systems. I haven't compiled GTK+ on my system, but downloaded the 1.3.0 sources on Tor's website, as this is a common problem that I've seen before, typically with a simple fix. I noticed that in gdk_input_init(), the following calls are made: gdk_input_root_width = GetSystemMetrics (SM_CXSCREEN); gdk_input_root_height = GetSystemMetrics (SM_CYSCREEN); According to MSDN, SM_CXSCREEN and SM_CYSCREEN will give the "Width and height, in pixels, of the screen of the primary display monitor." This causes problems with multiple screens, because GTK+ assumes that the second monitor part of the screen doesn't exist. On Win98/2000 or later, the following values can be passed to GetSystemMetrics: SM_CXVIRTUALSCREEN and SM_CYVIRTUALSCREEN, which should give "the width and height of the virtual screen." The same changes should probably be made to other calls to GetSystemMetrics() within GTK+. Hope this helps, --Alan
I also considered using SM_CXSCREEN but I am not sure it would actually improve the situation or make more reliable. Anyway, any news on integrating my two suggested patches ? Is there anything I can do to speed up the process ? Arno
The first patch, to gdkevents-win32.c, applied to HEAD and gtk-2-2. I would like to get input from Owen about the second patch, to gtkmenuitem.c. Is this a good patch? Is this really the only place in GTK where GTK assumes coordinates are non-negative? I would also like to have confirmation that it indeed is proper for GDK to generate events with negative coordinates. (If not, I guess gdk/win32 will have to recognize multiple monitors and offset all coordinates if necessary so that they are presented to upper layers as non-negative.)
Move remaining bugs off 2.2.2 target milestone.
*** Bug 118626 has been marked as a duplicate of this bug. ***
Multiple monitor support added to HEAD and gtk-2-2. Please reopen if there still are problems. 2003-08-07 Tor Lillqvist <tml@iki.fi> [Win32] Add support for multiple monitors. * gdk/win32/gdkprivate-win32.h * gdk/win32/gdkglobals-win32.c: New global variables for multiple-monitor info: _gdk_num_monitors, _gdk_monitors, and _gdk_offset_x and _gdk_offset_y. * gdk/win32/gdkdisplay-win32.c (count_monitor, enum_monitor): New functions, enumeration functions passed to EnumDisplayMonitors(). (gdk_display_open): If the EnumDisplayMonitors() and GetMonitorInfo() API is present (on Win98, Win2000 and newer), use if to find out monitor info. Calculate the offset between Win32 coordinates (relative to the primary monitor's origin (and thus negative on monitors to the left of or above it), and GDK's (visible coordinates should be non-negative). * gdk/win32/gdkscreen-win32 (gdk_screen_get_n_monitors, gdk_screen_get_monitor_geometry): Use information collected above. (gdk_window_move, gdk_window_move_resize_window_get_geometry): Subtract _gdk_offset_{x,y} from GDK root window coordinates. (gdk_window_get_geometry, gdk_window_get_origin, gdk_window_get_frame_extents): For top-level windows, add _gdk_offset_{x,y} to GDK root window coordinates Still need to handle multiple monitors in gdk_window_fullscreen(). Probably should make the window fullscreen on the monitor where the cursor is? * gdk/win32/gdkevents-win32.c: Add _gdk_offset_{x,y} to all GDK root window coordinates in GdkEvents.