summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarc_culler <marc.culler@gmail.com>2020-09-14 15:03:44 (GMT)
committermarc_culler <marc.culler@gmail.com>2020-09-14 15:03:44 (GMT)
commit0e6c603dbde531da22b1b65b987b69e463761b4a (patch)
tree08dcee3a8d07c066790e6118f4f8d7f07859148d
parentad861a0433fe3325ce081e6df2b40ed7fd670fe9 (diff)
downloadtk-0e6c603dbde531da22b1b65b987b69e463761b4a.zip
tk-0e6c603dbde531da22b1b65b987b69e463761b4a.tar.gz
tk-0e6c603dbde531da22b1b65b987b69e463761b4a.tar.bz2
Fix [71e18c5c0a]: Aqua invalid selector crash when switching between normal and full screen mode.
-rw-r--r--macosx/tkMacOSXMouseEvent.c24
-rw-r--r--macosx/tkMacOSXTest.c12
2 files changed, 20 insertions, 16 deletions
diff --git a/macosx/tkMacOSXMouseEvent.c b/macosx/tkMacOSXMouseEvent.c
index 9e57e7d..00477dd 100644
--- a/macosx/tkMacOSXMouseEvent.c
+++ b/macosx/tkMacOSXMouseEvent.c
@@ -54,6 +54,7 @@ enum {
NSWindow *eventWindow = [theEvent window];
NSEventType eventType = [theEvent type];
NSRect viewFrame = [[eventWindow contentView] frame];
+ NSPoint location = [theEvent locationInWindow];
TkWindow *winPtr = NULL, *grabWinPtr;
Tk_Window tkwin = None, capture, target;
NSPoint local, global;
@@ -71,13 +72,12 @@ enum {
* If this event is not for a Tk toplevel, it should just be passed up the
* responder chain. However, there is an exception for synthesized events,
* which are used in testing. Those events are recognized by having their
- * (unused) pressure field set to the impossible value -1.0.
+ * (unused) context pointer set to 1.
*/
- if (![eventWindow isMemberOfClass:[TKWindow class]]) {
- if (eventWindow && [theEvent pressure] != -1.0) {
+ if (eventWindow && ![eventWindow isMemberOfClass:[TKWindow class]]) {
+ if ([theEvent context] != (void *) 1)
return theEvent;
- }
}
/*
@@ -85,8 +85,9 @@ enum {
*/
if (eventWindow) {
- inTitleBar = viewFrame.size.height < [theEvent locationInWindow].y;
+ inTitleBar = viewFrame.size.height < location.y;
}
+
button = [theEvent buttonNumber] + Button1;
switch (eventType) {
case NSRightMouseUp:
@@ -101,13 +102,16 @@ enum {
buttonState |= TkGetButtonMask(button);
break;
case NSMouseEntered:
- if (!inTitleBar) {
+ if ([eventWindow respondsToSelector:@selector(mouseInResizeArea)] &&
+ !inTitleBar) {
[(TKWindow *)eventWindow setMouseInResizeArea:YES];
}
break;
case NSMouseExited:
- [(TKWindow *)eventWindow setMouseInResizeArea:NO];
- break;
+ if ([eventWindow respondsToSelector:@selector(mouseInResizeArea)]) {
+ [(TKWindow *)eventWindow setMouseInResizeArea:NO];
+ break;
+ }
case NSLeftMouseUp:
case NSLeftMouseDown:
case NSMouseMoved:
@@ -129,8 +133,8 @@ enum {
*/
if (eventType == NSLeftMouseDown || eventType == NSLeftMouseDragged) {
- if ([(TKWindow *)eventWindow mouseInResizeArea] &&
- ([eventWindow styleMask] & NSResizableWindowMask)) {
+ if ([eventWindow respondsToSelector:@selector(mouseInResizeArea)] &&
+ [(TKWindow *) eventWindow mouseInResizeArea]) {
/*
* When the left button is pressed in the resize area, we receive
diff --git a/macosx/tkMacOSXTest.c b/macosx/tkMacOSXTest.c
index 52cda8f..16fe37e 100644
--- a/macosx/tkMacOSXTest.c
+++ b/macosx/tkMacOSXTest.c
@@ -178,8 +178,8 @@ TkTestLogDisplay(
* location. It injects NSEvents into the NSApplication event queue, as
* opposed to adding events to the Tcl queue as event generate would do.
* One application is for testing the grab command. These events have
- * pressure = -1.0 as a signal indicating that they should not be ignored
- * by [NSApp tkProcessMouseEvent].
+ * their unused context property set to 1 as a signal indicating that they
+ * should not be ignored by [NSApp tkProcessMouseEvent].
*
* Results:
* A standard Tcl result.
@@ -238,17 +238,17 @@ PressButtonObjCmd(
modifierFlags:0
timestamp:GetCurrentEventTime()
windowNumber:wNum
- context:nil
+ context:(void *) 1
eventNumber:0
clickCount:1
- pressure:-1.0];
+ pressure:0.0];
[NSApp postEvent:motion atStart:NO];
press = [NSEvent mouseEventWithType:NSLeftMouseDown
location:loc
modifierFlags:0
timestamp:GetCurrentEventTime()
windowNumber:wNum
- context:nil
+ context:(void *)1
eventNumber:1
clickCount:1
pressure:-1.0];
@@ -258,7 +258,7 @@ PressButtonObjCmd(
modifierFlags:0
timestamp:GetCurrentEventTime()
windowNumber:wNum
- context:nil
+ context:(void*) 1
eventNumber:2
clickCount:1
pressure:-1.0];