From 8ba154154bdb9c4923685db7baff72c1c7a085c5 Mon Sep 17 00:00:00 2001 From: culler Date: Mon, 17 Dec 2018 14:11:38 +0000 Subject: Restore the old behavior with unix title bars and borders, but document and test it. --- doc/winfo.n | 3 +++ tests/unixWm.test | 23 +++++++++++++---------- unix/tkUnixWm.c | 36 +++--------------------------------- 3 files changed, 19 insertions(+), 43 deletions(-) diff --git a/doc/winfo.n b/doc/winfo.n index 5008448..a833e31 100644 --- a/doc/winfo.n +++ b/doc/winfo.n @@ -73,6 +73,9 @@ to the screen containing \fIwindow\fR; otherwise they refer to the screen of the application's main window. If no window in this application contains the point then an empty string is returned. +An empty string is also returned if the point lies in the title bar +or border of its highest containing toplevel in this application. +(Note that with some window managers the borders may be invisible.) In selecting the containing window, children are given higher priority than parents and among siblings the highest one in the stacking order is chosen. diff --git a/tests/unixWm.test b/tests/unixWm.test index 9029fc9..6759f38 100644 --- a/tests/unixWm.test +++ b/tests/unixWm.test @@ -1779,14 +1779,15 @@ test unixWm-49.2 {Tk_GetRootCoords procedure, menubars} {unix testmenubar} { } {52 7 12 62} deleteWindows -# The root window must not overlap the test windows during these -# tests. Previously this was arranged by iconifying the root. But -# this does not work on Ubuntu Unity, possibly because of -# https://bugs.launchpad.net/ubuntu/+source/unity/+bug/1502370 -# A workaround is to just move it far away. -wm geometry . +1000+1000 -#wm iconify . -test unixWm-50.1 {Tk_CoordsToWindow procedure, finding a toplevel, x-coords} unix { +wm withdraw . +if {[tk windowingsystem] == "aqua"} { + # Modern mac windows have no border. + set result_50_1 {{} {} .t .t .t2 {} .t2 .t .t} +} else { + # Windows are assumed to have a border (invisible in Gnome 3). + set result_50_1 {{} {} .t {} .t2 {} .t2 {} .t} +} +test unixWm-50.1 {Tk_CoordsToWindow procedure, finding a toplevel, x-coords, title bar} unix { update toplevel .t -width 300 -height 400 -bg green wm geom .t +100+100 @@ -1803,10 +1804,11 @@ test unixWm-50.1 {Tk_CoordsToWindow procedure, finding a toplevel, x-coords} uni [winfo containing $x [expr $y + 250]] \ [winfo containing [expr $x + 99] [expr $y + 250]] \ [winfo containing [expr $x + 100] [expr $y + 250]] \ + [winfo containing [expr $x + 150] [expr $y + 90]] \ [winfo containing [expr $x + 199] [expr $y + 250]] \ [winfo containing [expr $x + 200] [expr $y + 250]] \ - [winfo containing [expr $x + 220] [expr $y + 250]] -} {{} {} .t .t .t2 .t2 .t .t} + [winfo containing [expr $x + 220] [expr $y + 250]] \ +} $result_50_1 test unixWm-50.2 {Tk_CoordsToWindow procedure, finding a toplevel, y-coords and overrideredirect} unix { deleteWindows toplevel .t -width 400 -height 300 -bg yellow @@ -1962,6 +1964,7 @@ test unixWm-50.9 {Tk_CoordsToWindow procedure, unmapped windows} unix { tkwait visibility .t2 set result [list [winfo containing 100 100]] wm iconify .t2 + animationDelay lappend result [winfo containing 100 100] } {.t2 .t} test unixWm-50.10 {Tk_CoordsToWindow procedure, unmapped windows} unix { diff --git a/unix/tkUnixWm.c b/unix/tkUnixWm.c index 5bee6ba..fa54f56 100644 --- a/unix/tkUnixWm.c +++ b/unix/tkUnixWm.c @@ -5875,41 +5875,11 @@ Tk_CoordsToWindow( goto gotToplevel; } else { - /* Ouch! The point is not in the reparented window! - * - * This can happen with Gnome3-based window managers. - * They provide an invisible border around a window to - * help grab the edge for resizing. When the point is - * inside the invisible border of some window, - * XTranslateCoordinates will set the child to be a - * reparent of that window. But we don't want that - * window. What we have to do in this case is to search - * through all of the toplevels below this one and find - * the highest one which actually contains the point. + /* + * Return NULL if the point is in the title bar or border. */ - TkWindow **windows, **window_ptr; - windows = TkWmStackorderToplevel( - ((TkWindow *) tkwin)->mainPtr->winPtr); - if (windows == NULL) { - return NULL; - } - winPtr = NULL; - for (window_ptr = windows; *window_ptr ; window_ptr++) { - wmPtr = (*window_ptr)->wmInfoPtr; - if (wmPtr == NULL) { - continue; - } - if (PointInWindow(x, y, wmPtr)) { - winPtr = *window_ptr; - break; - } - } - ckfree(windows); - if (winPtr == NULL) { - return NULL; - } - goto gotToplevel; + return NULL; } } if (wmPtr->wrapperPtr != NULL) { -- cgit v0.12