Vince wrote: What is the right (x-platform) way to find the size/position of a toplevel window, including all window-manager decorations (so that I can position two windows without their wm borders overlapping)?
Testing on Windows shows that
wm geometry . returns contentswidthxcontentsheight+decorationTop+decorationLeftEdge.
and
winfo rooty . returns contentsTop
winfo rootx . returns contentsLeftEdge
So, we have the (x,y) of the wm decoration from wm geometry, and we can get the titlebar/border height with contentsTop - decorationTop, and the left decoration thickness with contentsLeftEdge - decorationLeftEdge. But how do I get the thickness of the right-edge and bottom-edge decoration? I can assume it's the same as the left edge decoration, I suppose.
Is the above true cross-platform? Is there a better way of doing this? Does it work if the toplevel now has . configure -menu applied?
Peter Newman 22 April 2004: In Centering a window, Martin Lemburg asked a similar question (and got no answer). winfo provides lots of useful information. But it doesn't provide that. But whether that's because 1) it's impossible to provide that info. in a cross-platform way, 2) it's un-necessary, because your assumption that it's alway left = right = bottom is always correct, or 3) winfos authors never though of it, who knows? On my Windows 95, I've never seen an app that doesn't do this. Nor on any Windows or Linux screen dump I've seen on the Net. Maybe there's some Linux and Mac users out there can tell us if that's true for them. I think you have to assume that it is. And I've never experienced . configure -menu changing this.
Vince adds then, that this proc works for windows:
proc 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] }
But can anyone test it on other platforms, please?
22 apr 2004 dk -- it appears to work under OS X (mac)
Peter Newman 23 April 2004: Just had a look on MSDN. And it appears to me that though the Windows API, right from Windows 95, would allow an app. to create a window where 'left border' = 'right border' = 'bottom border' is no longer true, Tk doesn't take advantage of this. Tk appears to restrict itself to rectangular grey unskinned/unthemed windows, where 'left border' = 'right border' = 'bottom border'.
So if Tk is a cross-platform app., and it applies that restriction to Windows, then surely it must (or at least should,) apply it to other platforms as well.
However if your a Linux or Mac user, don't let that stop you from checking out Vince's proc on your machine as well.
Peter Newman 23 April 2004: Another related issue that I remember some Tcl'er pointing out, was that Tk, on Windows (not sure the others), didn't know anything about the taskbar (at the bottom of the screen). So an app. that assumed it had the full screen_height to work with,