diff options
author | patthoyts <patthoyts@noemail.net> | 2011-06-01 10:47:49 (GMT) |
---|---|---|
committer | patthoyts <patthoyts@noemail.net> | 2011-06-01 10:47:49 (GMT) |
commit | 6049f12b1cea5684dec1a3aa8d048a6765d243f7 (patch) | |
tree | be720c0891f1daef8ab6e050e80c1f17a9682492 | |
parent | e6afe7a7f717ba09a99b91d382b26807bff19664 (diff) | |
download | tk-6049f12b1cea5684dec1a3aa8d048a6765d243f7.zip tk-6049f12b1cea5684dec1a3aa8d048a6765d243f7.tar.gz tk-6049f12b1cea5684dec1a3aa8d048a6765d243f7.tar.bz2 |
[Bug # 3306909]: tk_popup placement on Windows Vista can be incorrect.
When posting menus near the bottom of the screen on Windows versions
newer than XP the menu may be placed incorrectly. This is due to code
in PostOverPoint that corrects an error in the XP window manager. This
fix is no longer required for Vista and Windows7.
Reported-by: Harald Oehlmann <oehhar@users.sourceforge.net>
Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
FossilOrigin-Name: 6db4a05c4ecb22120951316412887f21b9d389b9
-rw-r--r-- | library/menu.tcl | 37 |
1 files changed, 24 insertions, 13 deletions
diff --git a/library/menu.tcl b/library/menu.tcl index 31da4fb..f66c498 100644 --- a/library/menu.tcl +++ b/library/menu.tcl @@ -1224,24 +1224,35 @@ proc ::tk::PostOverPoint {menu x y {entry {}}} { } incr x [expr {-[winfo reqwidth $menu]/2}] } - if {$tcl_platform(platform) == "windows"} { + + if {$tcl_platform(platform) eq "windows"} { + # osVersion is not available in safe interps + set ver 5 + if {[info exists tcl_platform(osVersion)]} { + scan $tcl_platform(osVersion) %d ver + } + # We need to fix some problems with menu posting on Windows, # where, if the menu would overlap top or bottom of screen, # Windows puts it in the wrong place for us. We must also # subtract an extra amount for half the height of the current # entry. To be safe we subtract an extra 10. - set yoffset [expr {[winfo screenheight $menu] \ - - $y - [winfo reqheight $menu] - 10}] - if {$yoffset < 0} { - # The bottom of the menu is offscreen, so adjust upwards - incr y $yoffset - if {$y < 0} { set y 0 } - } - # If we're off the top of the screen (either because we were - # originally or because we just adjusted too far upwards), - # then make the menu popup on the top edge. - if {$y < 0} { - set y 0 + # NOTE: this issue appears to have been resolved in the Window + # manager provided with Vista and Windows 7. + if {$ver < 6} { + set yoffset [expr {[winfo screenheight $menu] \ + - $y - [winfo reqheight $menu] - 10}] + if {$yoffset < 0} { + # The bottom of the menu is offscreen, so adjust upwards + incr y $yoffset + if {$y < 0} { set y 0 } + } + # If we're off the top of the screen (either because we were + # originally or because we just adjusted too far upwards), + # then make the menu popup on the top edge. + if {$y < 0} { + set y 0 + } } } $menu post $x $y |