Menu

#1700 wm geometry contradictions (and inadequately documented

obsolete: 8.5a2
open
5
2004-06-15
2004-04-22
No

The documentation of "wm geometry $win" doesn't make
clear whether the quantities referred to are relative
to the toplevel window's border or the window manager
decoration (titlebar, menubar with configure -menu, etc).

In fact on windows, the returned value is:

contentsWidth x contentsHeight
+ decorationLeft + decorationTop

which is rather surprising. This means to find the
total number of vertical pixels covered by the
toplevel, including any menubar/titlebar/border, we
must perform a complex calculation (and must actually
assume the bottom edge and right edge decoration are
the same thickness as the left edge decoration). So,
here's a function to determine, as best possible, the
total geometry covered by a window:

proc default::totalGeometry {{w .}} {
set geom [wm geometry $w]
regexp -- {([0-9]+)x([0-9]+)\+([0-9]+)\+([0-9]+)}
$geom -> \
width height decorationLeft decorationTop
set contentsTop [winfo rooty $w]
set contentsLeft [winfo rootx $w]

# Measure left edge, and assume all edges except
top are the
# same thickness
set decorationThickness [expr {$contentsLeft -
$decorationLeft}]

# Find titlebar and menubar thickness
set menubarThickness [expr {$contentsTop -
$decorationTop}]

incr width [expr {2 * $decorationThickness}]
incr height $decorationThickness
incr height $menubarThickness

return [list $width $height $decorationLeft
$decorationTop]
}

Nowhere in the documentation are these issues/terms
made clear. So, while I know the above works on
Windows, I really cannot be sure it works on other
platforms. The documentation should be fixed (and this
proc could be used as an example, perhaps).

Discussion

  • Vince Darley

    Vince Darley - 2004-05-20
    • assigned_to: chengyemao --> hobbs
    • summary: wm geometry inadequately documented --> wm geometry contradictions (and inadequately documented
     
  • Vince Darley

    Vince Darley - 2004-05-20

    Logged In: YES
    user_id=32170

    Furthermore, on X11, the behaviour is totally different! On
    X11 it is impossible to get the decoration sizes, and in
    fact 'wm geometry' operates only on the window contents.

    This means, for example, that 'wm geometry +0+0' performs
    totally differently on Windows vs X11.

     
  • Vince Darley

    Vince Darley - 2004-05-21

    Logged In: YES
    user_id=32170

    According to http://mini.net/tcl/11502,

    This depends on the window manager. Under metacity (Gnome's
    WM), twm, and others, wm geometry . +$x+$y places the
    upper-left corner of the window decoration at $x,$y; under
    MWM and 4DWM, it places the upper-left corner of the window
    contents there. I'm pretty sure this is because tkUnixWm.c
    isn't doing the right thing according to the ICCCM -- it
    looks like it's trying to implement the first behaviour
    (place window decorations), but it does so by attempting to
    second-guess what the WM is going to do. Under many WMs, it
    guesses wrong.

    This means even between different X11 wm's the behaviour is
    inconsistent for something as simple as 'wm geometry . +0+0'

     
  • Joe English

    Joe English - 2004-06-15
    • assigned_to: hobbs --> jenglish
     
  • Joe English

    Joe English - 2004-06-15

    Logged In: YES
    user_id=68433

    Reassigning to me; see also #220791.

     
MongoDB Logo MongoDB