diff options
author | Kevin Walzer <kw@codebykevin.com> | 2015-03-21 01:31:02 (GMT) |
---|---|---|
committer | Kevin Walzer <kw@codebykevin.com> | 2015-03-21 01:31:02 (GMT) |
commit | 6f271af3157483e82be0a839323490597eac5e04 (patch) | |
tree | 4968b67a528b6d9e86370951dc604bfa36b14ec8 /macosx/tkMacOSXKeyEvent.c | |
parent | 50ec1ecb24801b023618048a6704fa12670671d9 (diff) | |
download | tk-6f271af3157483e82be0a839323490597eac5e04.zip tk-6f271af3157483e82be0a839323490597eac5e04.tar.gz tk-6f271af3157483e82be0a839323490597eac5e04.tar.bz2 |
Improvement of memory management, removal of zombie windows from Tk-Cocoa; thanks to Marc Culler for patch
Diffstat (limited to 'macosx/tkMacOSXKeyEvent.c')
-rw-r--r-- | macosx/tkMacOSXKeyEvent.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/macosx/tkMacOSXKeyEvent.c b/macosx/tkMacOSXKeyEvent.c index 09cdf94..7e7e8e4 100644 --- a/macosx/tkMacOSXKeyEvent.c +++ b/macosx/tkMacOSXKeyEvent.c @@ -27,7 +27,9 @@ static Tk_Window grabWinPtr = NULL; /* Current grab window, NULL if no grab. */ static Tk_Window keyboardGrabWinPtr = NULL; /* Current keyboard grab window. */ -static NSModalSession modalSession = NULL; +static NSWindow *keyboardGrabNSWindow = nil; + /* NSWindow for the current keyboard grab window. */ +static NSModalSession modalSession = nil; static BOOL processingCompose = NO; static BOOL finishedCompose = NO; @@ -476,7 +478,9 @@ XGrabKeyboard( if (modalSession) { Tcl_Panic("XGrabKeyboard: already grabbed"); } - modalSession = [NSApp beginModalSessionForWindow:[w retain]]; + keyboardGrabNSWindow = w; + [w retain]; + modalSession = [NSApp beginModalSessionForWindow:w]; } } return GrabSuccess; @@ -504,11 +508,12 @@ XUngrabKeyboard( Time time) { if (modalSession) { - NSWindow *w = keyboardGrabWinPtr ? TkMacOSXDrawableWindow( - ((TkWindow *) keyboardGrabWinPtr)->window) : nil; [NSApp endModalSession:modalSession]; - [w release]; - modalSession = NULL; + modalSession = nil; + } + if (keyboardGrabNSWindow) { + [keyboardGrabNSWindow release]; + keyboardGrabNSWindow = nil; } keyboardGrabWinPtr = NULL; } |