summaryrefslogtreecommitdiffstats
path: root/macosx
diff options
context:
space:
mode:
authorculler <culler>2019-01-05 17:00:15 (GMT)
committerculler <culler>2019-01-05 17:00:15 (GMT)
commit0ff9be54ab18ebef3aecc29024da14d34940d45a (patch)
tree33013dabf38933ec1bfb03825024fa2610ad7b65 /macosx
parentcdcd80aec2e8f345a9a491e82129ab8ae0f864ea (diff)
downloadtk-0ff9be54ab18ebef3aecc29024da14d34940d45a.zip
tk-0ff9be54ab18ebef3aecc29024da14d34940d45a.tar.gz
tk-0ff9be54ab18ebef3aecc29024da14d34940d45a.tar.bz2
Implement local grabs for Aqua.
Diffstat (limited to 'macosx')
-rw-r--r--macosx/tkMacOSXKeyEvent.c23
-rw-r--r--macosx/tkMacOSXMouseEvent.c27
2 files changed, 34 insertions, 16 deletions
diff --git a/macosx/tkMacOSXKeyEvent.c b/macosx/tkMacOSXKeyEvent.c
index a153797..3327f0a 100644
--- a/macosx/tkMacOSXKeyEvent.c
+++ b/macosx/tkMacOSXKeyEvent.c
@@ -139,18 +139,26 @@ unsigned short releaseCode;
}
/*
- * The focus must be in the FrontWindow on the Macintosh. We then query Tk
- * to determine the exact Tk window that owns the focus.
+ * Events are only received for the front Window on the Macintosh.
+ * So to build an XEvent we look up the Tk window associated to the
+ * Front window. If a different window has a local grab we ignore
+ * the event.
*/
TkWindow *winPtr = TkMacOSXGetTkWindow(w);
Tk_Window tkwin = (Tk_Window) winPtr;
- if (!tkwin) {
- TkMacOSXDbgMsg("tkwin == NULL");
- return theEvent;
- }
- tkwin = (Tk_Window) winPtr->dispPtr->focusPtr;
+ if (tkwin) {
+ TkWindow *grabWinPtr = winPtr->dispPtr->grabWinPtr;
+ if (grabWinPtr &&
+ grabWinPtr != winPtr &&
+ !winPtr->dispPtr->grabFlags && /* this means the grab is local. */
+ grabWinPtr->mainPtr == winPtr->mainPtr) {
+ return theEvent;
+ }
+ } else {
+ tkwin = (Tk_Window) winPtr->dispPtr->focusPtr;
+ }
if (!tkwin) {
TkMacOSXDbgMsg("tkwin == NULL");
return theEvent; /* Give up. No window for this event. */
@@ -160,6 +168,7 @@ unsigned short releaseCode;
* If it's a function key, or we have modifiers other than Shift or Alt,
* pass it straight to Tk. Otherwise we'll send for input processing.
*/
+
int code = (len == 0) ?
0 : [charactersIgnoringModifiers characterAtIndex: 0];
if (type != NSKeyDown || isFunctionKey(code)
diff --git a/macosx/tkMacOSXMouseEvent.c b/macosx/tkMacOSXMouseEvent.c
index 828d874..f02df1d 100644
--- a/macosx/tkMacOSXMouseEvent.c
+++ b/macosx/tkMacOSXMouseEvent.c
@@ -106,23 +106,32 @@ enum {
}
}
- Window window = TkMacOSXGetXWindow(eventWindow);
- Tk_Window tkwin = window ? Tk_IdToWindow(TkGetDisplayList()->display,
- window) : NULL;
- if (!tkwin) {
+ TkWindow *winPtr = TkMacOSXGetTkWindow(eventWindow);
+ Tk_Window tkwin = (Tk_Window) winPtr;
+
+ if (tkwin) {
+ TkWindow *grabWinPtr = winPtr->dispPtr->grabWinPtr;
+ if (grabWinPtr &&
+ grabWinPtr != winPtr &&
+ !winPtr->dispPtr->grabFlags && /* this means the grab is local. */
+ grabWinPtr->mainPtr == winPtr->mainPtr) {
+ return theEvent;
+ }
+ } else {
tkwin = TkMacOSXGetCapture();
}
if (!tkwin) {
+ TkMacOSXDbgMsg("tkwin == NULL");
return theEvent; /* Give up. No window for this event. */
- }
-
- TkWindow *winPtr = (TkWindow *) tkwin;
+ } else {
+ winPtr = (TkWindow *)tkwin;
+ }
+
local.x -= winPtr->wmInfoPtr->xInParent;
local.y -= winPtr->wmInfoPtr->yInParent;
int win_x, win_y;
- tkwin = Tk_TopCoordsToWindow(tkwin, local.x, local.y,
- &win_x, &win_y);
+ tkwin = Tk_TopCoordsToWindow(tkwin, local.x, local.y, &win_x, &win_y);
unsigned int state = 0;
NSInteger button = [theEvent buttonNumber];