| Ticket UUID: | 533519 | |||
| Title: | Window placement with multiple screens | |||
| Type: | Bug | Version: | obsolete: 8.5.10 | |
| Submitter: | patthoyts | Created on: | 2002-03-22 09:57:07 | |
| Subsystem: | 68. Win Window Operations | Assigned To: | jan.nijtmans | |
| Priority: | 5 Medium | Severity: | ||
| Status: | Closed | Last Modified: | 2014-03-13 09:08:07 | |
| Resolution: | Fixed | Closed By: | nijtmans | |
| Closed on: | 2012-05-02 11:46:41 | |||
| Description: |
Using multiple screens under MS Windows there are a number of minor issues to do with window placement. Firstly there is no way to find out from Tk the real screen area. Windows arranges multiple monitors as a single large desktop. In my case I have two 1152x864 screens. The primary monitor to the right and the secondary monitor to the left. With this setup my available desktop geometry goes from -1152 to +1152 and 0 to 864. In other words under MS Windows and window may have a negative placement. This is currently handled OK by the wm geometry command. To place a toplevel on the left hand monitor I can do wm geometry . 100x100+-1152+0 and it is placed in the top lefthand corner of the secondary monitor. However, placing . on monitor 2 and creating a second toplevel (.t) places the new window on the primary monitor. Calling tk::PlaceWindow .t widget . places .t at the corrent vertical position but on the wrong monitor. This is because of the bounds checking in the PlaceWindow function. We can fix this by not doing the bounds checking for Windows except that it would be better to do the bounds checking. But we cannot find out the extent of the desktop from Tk. The attached program (multimon.c) shows a Windows way to get the information but I'm not sure where within Tk it should be placed. Possibly the winfo vrootwidth and vrootheight but that doesn't give us the offsets. In my case vrootwidth is going to be 2*1152 but I need to be able to find out that my coordinates go from -1152 to +1152. | |||
| User Comments: |
nijtmans added on 2012-05-02 18:46:41:
allow_comments - 1 Now merged to core-8-4-branch and core-8-5-branch as well. > My understanding is that the bug fix for the > present #533519 did anyway not attempt > to fix #2257424 at the same time. Right! And any fix for #2257424 might be broken again by #533519, so better fix this one first before even looking at the other related issues. Now [winfo . vroot(x|y|width|height)] can be used on Windows to get the size and position of the virtual root window. Previously this gave the size and position of the screen, and that was the fundamental plague which hindered the other multi-screen related issues. Closing fvogelnew1 added on 2012-05-01 18:28:51: Your fix looks perfect to me. What I reported below in my comment dated 2009-10-09 is not fixed but this is because of #2257424. My understanding is that the bug fix for the present #533519 did anyway not attempt to fix #2257424 at the same time. I'm now bouncing this bug back to you Jan since I don't think I can backport this to 8.4 and 8.5. nijtmans added on 2012-04-29 14:50:39: Merged to trunk now. Keeping open for backport to 8.4 and 8.5 Francis, if you have ideas how to improve it, please go on! Leaving the ball to you now. fvogelnew1 added on 2012-04-29 02:57:38: What is currently in branch bug-533519 does not fix what I reported below in my comment dated 2009-10-09. I will try to see why it still fails. However branch bug-533519 makes some tooltips of my app now show up in the correct monitor when in dual monitor mode. Great! dkf added on 2012-04-20 21:36:56: Works with OSX X11 server (though only tk_dialog uses it, not tk_messageBox…) I ran into other problems with the OSX build though. It crashes in the notifier when I start Tk up before I can try out any window placement code. No idea why. (This is occurring before I can run any scripts, so whatever is wrong, it's serious.) nijtmans added on 2012-04-20 21:03:42: Donal, does the bug-533519 still pass all Tk tests on
Mac, in the multi-monitor setup?
Especially bind.test!!! On Windows and UNIX
it works fine.
The problem in the current Tk handling coding, is that
an attempt was made in various places to prevent that
x/y coordinates become negative by substracting
[winfo vrootx/y] to coordinates On the main screen
that should not happen, as the origin of the main
screen is always 0,0. But outsize the main screen we
should never trying to adapt coordinates this way.
instead, the vroot dimensions should only be
used for clipping coordinates, preventing that
windows or menu's become invisible. In branch
bug-533519 that's the main change.
I only can test on Windows and Linux, but
if you could test on the Mac please.....
Thanks!
Jan Nijtmans
nijtmans added on 2012-04-17 15:07:11: > It's going to be a while before I'm back at a dual-monitor setup (and then > I'll only be able to look at OSX and X11 behavior) I would appreciate that! For OSX and X11 not so much changes, because the Tk_GetVRootGeometry is not changed there. But a code review would be fine too ;-) The biggest change is that ::tk::PlaceWindow clips on the vroot limits instead of the screen limits, which is only a safety measure. For Windows the change is bigger, because now the vroot limits can give negative coordinates, and ::tk::PlaceWindow is adapted to handle that correctly. Thanks! dkf added on 2012-04-17 14:48:44: It's going to be a while before I'm back at a dual-monitor setup (and then I'll only be able to look at OSX and X11 behavior) nijtmans added on 2012-04-17 05:28:09: Fix committed to bug-533519 branch (based on core-8-4-branch). It consists of 3 parts: - Change dialog.tcl to use ::tk::PlaceWindow just as other dialogs. - teach ::tk::PlaceWindow how to clip positioning correctly taking the vroot into account (as dialog.tcl already did.) - On Windows, correct Tk_GetVRootGeometry to return the right values for the vroot, not the screen. Tested this on Windows 7 with dual monitor putting the main screen up/down/left/right of the second screen. Feedback welcome! nijtmans added on 2012-04-14 05:12:08: Or - alternative - do we want coordinates always be relative to the current screen? This alternative committed to branch "bug-533519-alt"? Opinions, which of the two is best, welcome? I don't have a dual-monitor setup here to try it. nijtmans added on 2012-04-14 04:21:12: proposed fix committed to branch bug-533519 (derived from trunk) With this change, all mouse coordinates should be >=0, and the offset can be derived from [winfo vrootx] and [winfo vrooty], so I think it fully fixes this bug. Agreed? nijtmans added on 2012-04-13 21:36:19: The problem here is the function Tk_GetVRootGeometry,
which is implemented wrong for Windows: The offsets
it returns is always 0, and the width/height it returns
is the width of the display, not the width of the
virtual root. Currently the implementation does:
*xPtr = 0;
*yPtr = 0;
*widthPtr = DisplayWidth(winPtr->display, winPtr->screenNum);
*heightPtr = DisplayHeight(winPtr->display, winPtr->screenNum);
this should be:
*xPtr = GetSystemMetrics(SM_XVIRTUALSCREEN);
*yPtr = GetSystemMetrics(SM_YVIRTUALSCREEN);
*widthPtr = GetSystemMetrics(SM_CXVIRTUALSCREEN);
*heightPtr = GetSystemMetrics(SM_CYVIRTUALSCREEN);
I think this fully fixes the problem described here, and it
is also fully compatible with what applications expect:
- On a single screen, the offsets are always 0, and the
screen size is equal to the virtual root size.
- On a dual-monitor system where the main screen has
origin 0,0, the offset is still 0,0, only winfo vrootwidth/height
is too small.
- On a dual-monitor system where the main screen does not
have origin 0,0, winfo vrootx/vrooty will report a negative
number after this change. This is the current problematic
situation, in which mouse coordinates can become
negative. But this vrootx/vrooty is used to be substracted
from the system-reported coordinates. So this change
will result in mouse/windows coordinates to be >=0 again.
So, let's fix winfo vrootx/vrooty to report the vroot offset,
as it does on UNIX already.
fvogelnew1 added on 2009-10-09 22:05:29: This missing info is indeed a problem for me too. I have an app that on exit will save the geometry (position and size) of its main window so that the next time the user opens it it will be displayed at the same position and with same size it had during the previous session. When in session 1 there is a dual monitor and the app window is in monitor 2, and when in session 2 there is no monitor 2 anymore (because this is a laptop with an additional monitor and the user moved away from it), then the window may open completely off-screen entirely on the missing monitor 2. The user sees the icon in the task bar, indicating that the app opened, but the window is not visible. He has to have the idea of moving the window through a right-click in the task bar icon (he can't do it with the mouse on the window title bar since he doesn't see it!) toward monitor 1 display area. Most users do not have this idea, and just conclude that the app failed to open properly. dkf added on 2005-01-12 16:36:36: Logged In: YES user_id=79902 Perhaps a [winfo vrootorigin] command? patthoyts added on 2002-03-22 16:58:42: File Added - 19822: multimon.c patthoyts added on 2002-03-22 16:57:07: File Added - 19821: tk.tcl.diff | |||
Attachments:
- multimon.c [download] added by patthoyts on 2002-03-22 16:58:42. [details]
- tk.tcl.diff [download] added by patthoyts on 2002-03-22 16:57:07. [details]
