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 99496 - Gtk+ does not handle multiple screens well under Windows
Gtk+ does not handle multiple screens well under Windows
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Backend: Win32
2.2.x
Other Windows
: Normal normal
: ---
Assigned To: Tor Lillqvist
gtk-bugs
: 118626 (view as bug list)
Depends on:
Blocks: 99087
 
 
Reported: 2002-11-25 11:42 UTC by Arnaud Charlet
Modified: 2011-02-04 16:12 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Fix handling of negative coordinates (7.75 KB, patch)
2003-01-15 13:13 UTC, Arnaud Charlet
none Details | Review
possible way to handle negative coordinates for menu positioning (1.31 KB, patch)
2003-01-15 13:15 UTC, Arnaud Charlet
none Details | Review

Description Arnaud Charlet 2002-11-25 11:42:47 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
Comment 1 Arnaud Charlet 2002-11-25 11:44:12 UTC
I forgot to mention also that the mouse wheel only works in the
main display.

Arno
Comment 2 Tor Lillqvist 2002-11-25 23:20:59 UTC
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.
Comment 3 Arnaud Charlet 2003-01-15 13:13:13 UTC
Created attachment 13581 [details] [review]
Fix handling of negative coordinates
Comment 4 Arnaud Charlet 2003-01-15 13:14:11 UTC
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
Comment 5 Arnaud Charlet 2003-01-15 13:15:41 UTC
Created attachment 13582 [details] [review]
possible way to handle negative coordinates for menu positioning
Comment 6 Tor Lillqvist 2003-02-01 20:36:20 UTC
*** Bug 104972 has been marked as a duplicate of this bug. ***
Comment 7 Tor Lillqvist 2003-02-13 01:57:26 UTC
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
Comment 8 Arnaud Charlet 2003-02-19 11:56:50 UTC
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
Comment 9 Tor Lillqvist 2003-03-15 00:01:36 UTC
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.)
Comment 10 Matthias Clasen 2003-06-10 09:57:27 UTC
Move remaining bugs off 2.2.2 target milestone.
Comment 11 Tor Lillqvist 2003-07-30 09:32:04 UTC
*** Bug 118626 has been marked as a duplicate of this bug. ***
Comment 12 Tor Lillqvist 2003-08-07 22:41:02 UTC
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.