summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generic/tkGrab.c7
-rw-r--r--macosx/tkMacOSXKeyEvent.c23
-rw-r--r--macosx/tkMacOSXMouseEvent.c27
3 files changed, 35 insertions, 22 deletions
diff --git a/generic/tkGrab.c b/generic/tkGrab.c
index 00d4511..5ea2906 100644
--- a/generic/tkGrab.c
+++ b/generic/tkGrab.c
@@ -426,12 +426,7 @@ Tk_Grab(
}
Tk_MakeWindowExist(tkwin);
-#ifndef MAC_OSX_TK
- if (!grabGlobal)
-#else
- if (0)
-#endif /* MAC_OSX_TK */
- {
+ if (!grabGlobal) {
Window dummy1, dummy2;
int dummy3, dummy4, dummy5, dummy6;
unsigned int state;
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];