#2540 screenwidth incorrect on multiple monitors

obsolete: 8.4.19
closed-invalid
5
2012-05-05
2008-11-10
David Smith
No

The winfo screenwidth . returns 1920 on Windows XP SP2 with dual monitors and the screen spread across both monitors (and the . in the second monitor) whereas winfo geom . returns 200x200+2717+546. The geometry is correct but the screenwidth is not. How do I get the correct screen width in this case. Windows handles this as a single screen (at least it appears to).

Discussion

  • Donal K. Fellows

    • labels: 318687 --> 68. Win Window Operations
     
  • Jan Nijtmans

    Jan Nijtmans - 2012-04-13
    • assigned_to: chengyemao --> nijtmans
     
  • Jan Nijtmans

    Jan Nijtmans - 2012-05-04
    • status: open --> pending-invalid
     
  • Jan Nijtmans

    Jan Nijtmans - 2012-05-04

    With #533519 and #2768586 fixed, the remaining issue
    is: what is a screen under Windows. I would argue
    that where this issue handles a "screen", actually
    the "vroot" is meant. On Windows, the "screen"
    is equal to the main monitor, the vroot is the total
    area occupied by all monitors together.

    This means, the solution is not in Tk, but in the
    application: If you want to know the size of
    the whole area, use [winfo vroot(width|height)]
    The offset can be found by
    [winfo vroot(x|y)].

    I believe that Tk is fixed now, using the
    [winfo vroot...] in stead of [winfo screen..]
    functions where appropriate.

     
  • Francois VOGEL

    Francois VOGEL - 2012-05-05

    I understand your point.

    My use case is related to saving in a preferences file the geometry (position and size) of a toplevel across sessions of the application. Implementation is currently pretty simple: I save [winfo geometry $w] when leaving the app, and feed this value aga

     
  • Francois VOGEL

    Francois VOGEL - 2012-05-05

    Sorry, once more:

    I understand your point.

    My use case is related to saving in a preferences file the geometry (position and size) of a toplevel across sessions of the application. Implementation is currently pretty simple:

    I save [wm geometry $w] in a file when leaving the app
    I feed this value again in wm geometry when creating the toplevel on application launch.

    When a monitor was removed in the meantime the exit and the startup of the app (because this is a laptop that got undocked and now has only its own monitor), and the toplevel was on the now missing monitor at the time the app exited, then on startup the toplevel will be mapped on the missing area, which is outside of the existing monitors area.

    I would have expected wm geometry to clamp somewhat what it gets as an input.
    Since this is not the case I guess I'll have to parse and process [wm geometry ] output for bounds to compare to [winfo vroot... ] values.

     
  • Jan Nijtmans

    Jan Nijtmans - 2012-05-05

    > I would have expected wm geometry to clamp somewhat
    > what it gets as an input. Since this is not the case
    > I guess I'll have to parse and process [wm geometry ]
    > output for bounds to compare to [winfo vroot... ] values.

    Well, I tried it (both on Cygwin and Windows) and the
    [wm geometry] doesn't do any clamping. It would
    be impossible, because windows are allowed to be
    partly invisible, the window manager is not allowed
    to make the window fully visible if that's not what
    is requested.

    Thanks for your use case, it makes the
    situation clear. So, this issue can be closed now.

     
  • Jan Nijtmans

    Jan Nijtmans - 2012-05-05
    • status: pending-invalid --> closed-invalid
     
  • Donal K. Fellows

    The window manager's allowed to completely ignore whatever [wm geometry] requests. You're allowed to ask for the window to be completely off the screen. Net result, you can get yourself in a pickle if you're dumb about saving the geometry, and there's not that much Tk itself can do about it.

    Code to keep a window on the screen after a reload would be a reasonable addition to tklib (if it isn't there already).