diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-01-13 14:51:58 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2019-01-13 14:51:58 (GMT) |
commit | 40b76dbd4f4479294a9cd461da0400e31734ac2b (patch) | |
tree | 0b9c811cef1183d76e05a6ac238b5652de5bb12d /unix/tkUnixWm.c | |
parent | ad423a347178d6279b112f7031e683c7e15d798a (diff) | |
parent | 75aab96f3ddb340be5aecbb880f1af2a07d9ec25 (diff) | |
download | tk-40b76dbd4f4479294a9cd461da0400e31734ac2b.zip tk-40b76dbd4f4479294a9cd461da0400e31734ac2b.tar.gz tk-40b76dbd4f4479294a9cd461da0400e31734ac2b.tar.bz2 |
Merge 8.7
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 5bfa69e..b84791b 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; } |