diff options
author | culler <culler> | 2019-01-04 01:01:01 (GMT) |
---|---|---|
committer | culler <culler> | 2019-01-04 01:01:01 (GMT) |
commit | 25dc6318ede3ac345dd0c7266edb3915db9687de (patch) | |
tree | 016467929973584a461a304fb5fad0f3b7228277 /unix/tkUnixWm.c | |
parent | b30dbf0b32451060c56d0c58f2d5c908c55f402f (diff) | |
parent | fd6508a2a0aa568a36f853f326794536601769f0 (diff) | |
download | tk-25dc6318ede3ac345dd0c7266edb3915db9687de.zip tk-25dc6318ede3ac345dd0c7266edb3915db9687de.tar.gz tk-25dc6318ede3ac345dd0c7266edb3915db9687de.tar.bz2 |
Resolve bug [18a4ba19bd]. Make winfo containing behave consistently across
platforms and fix a bug with embedded toplevels.
Diffstat (limited to 'unix/tkUnixWm.c')
-rw-r--r-- | unix/tkUnixWm.c | 67 |
1 files changed, 52 insertions, 15 deletions
diff --git a/unix/tkUnixWm.c b/unix/tkUnixWm.c index 1c55f40..cb821d9 100644 --- a/unix/tkUnixWm.c +++ b/unix/tkUnixWm.c @@ -5781,6 +5781,18 @@ Tk_GetRootCoords( *---------------------------------------------------------------------- */ +static int PointInWindow( + int x, + int y, + WmInfo *wmPtr) +{ + XWindowChanges changes = wmPtr->winPtr->changes; + return (x >= changes.x && + x < changes.x + changes.width && + y >= changes.y - wmPtr->menuHeight && + y < changes.y + changes.height); +} + Tk_Window Tk_CoordsToWindow( int rootX, int rootY, /* Coordinates of point in root window. If a @@ -5851,13 +5863,38 @@ Tk_CoordsToWindow( } for (wmPtr = (WmInfo *) dispPtr->firstWmPtr; wmPtr != NULL; wmPtr = wmPtr->nextPtr) { - if (wmPtr->reparent == child) { - goto gotToplevel; + if (wmPtr->winPtr->mainPtr == NULL) { + continue; + } + if (child == wmPtr->reparent) { + if (PointInWindow(x, y, wmPtr)) { + goto gotToplevel; + } else { + + /* + * Return NULL if the point is in the title bar or border. + */ + + return NULL; + } } if (wmPtr->wrapperPtr != NULL) { if (child == wmPtr->wrapperPtr->window) { goto gotToplevel; - } + } else if (wmPtr->winPtr->flags & TK_EMBEDDED && + TkpGetOtherWindow(wmPtr->winPtr) == NULL) { + + /* + * This toplevel is embedded in a window belonging to + * a different application. + */ + + int rx, ry; + Tk_GetRootCoords((Tk_Window) wmPtr->winPtr, &rx, &ry); + childX -= rx; + childY -= ry; + goto gotToplevel; + } } else if (child == wmPtr->winPtr->window) { goto gotToplevel; } @@ -5879,9 +5916,6 @@ Tk_CoordsToWindow( handler = NULL; } winPtr = wmPtr->winPtr; - if (winPtr->mainPtr != ((TkWindow *) tkwin)->mainPtr) { - return NULL; - } /* * Step 3: at this point winPtr and wmPtr refer to the toplevel that @@ -5938,27 +5972,30 @@ Tk_CoordsToWindow( if (nextPtr == NULL) { break; } - winPtr = nextPtr; - x -= winPtr->changes.x; - y -= winPtr->changes.y; - if ((winPtr->flags & TK_CONTAINER) - && (winPtr->flags & TK_BOTH_HALVES)) { + x -= nextPtr->changes.x; + y -= nextPtr->changes.y; + if ((nextPtr->flags & TK_CONTAINER) + && (nextPtr->flags & TK_BOTH_HALVES)) { /* * The window containing the point is a container, and the * embedded application is in this same process. Switch over to * the toplevel for the embedded application and start processing * that toplevel from scratch. */ - - winPtr = TkpGetOtherWindow(winPtr); + winPtr = TkpGetOtherWindow(nextPtr); if (winPtr == NULL) { - return NULL; + return (Tk_Window) nextPtr; } wmPtr = winPtr->wmInfoPtr; childX = x; childY = y; goto gotToplevel; - } + } else { + winPtr = nextPtr; + } + } + if (winPtr->mainPtr != ((TkWindow *) tkwin)->mainPtr) { + return NULL; } return (Tk_Window) winPtr; } |