Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2013-05-11 14:15:27 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2013-05-11 14:15:27 +0400
commita919b0e4c3968dac3f357b2d65d1f2c9b285168b (patch)
tree9e76e1aaf7a2c7c5249784f9ebc59f045d830242 /intern/ghost
parent561cf26c2f92a11c8f2fa2da79bcaebf2647fc76 (diff)
Fix #35265: on OS X, pressing system shortcuts such as cmd+M or cmd+` would both
insert text in the text editor and do the associated operation like minimizing the window or switching windows. The code was always doing both without trying to ensure only one is done. Now we integrate a bit better with the event handling and pass the event to NSApp, which then decides to handle the event itself or pass it on to the window, from where we then send it back to be handled.
Diffstat (limited to 'intern/ghost')
-rw-r--r--intern/ghost/intern/GHOST_SystemCocoa.h17
-rw-r--r--intern/ghost/intern/GHOST_SystemCocoa.mm56
-rw-r--r--intern/ghost/intern/GHOST_WindowCocoa.mm119
3 files changed, 105 insertions, 87 deletions
diff --git a/intern/ghost/intern/GHOST_SystemCocoa.h b/intern/ghost/intern/GHOST_SystemCocoa.h
index cbb61f6e6ea..7d58c58b90e 100644
--- a/intern/ghost/intern/GHOST_SystemCocoa.h
+++ b/intern/ghost/intern/GHOST_SystemCocoa.h
@@ -237,15 +237,6 @@ public:
return 0;
}
-
-protected:
- /**
- * Initializes the system.
- * For now, it justs registers the window class (WNDCLASS).
- * \return A success value.
- */
- virtual GHOST_TSuccess init();
-
/**
* Handles a tablet event.
* \param eventPtr An NSEvent pointer (casted to void* to enable compilation in standard C++)
@@ -270,6 +261,14 @@ protected:
* \return Indication whether the event was handled.
*/
GHOST_TSuccess handleKeyEvent(void *eventPtr);
+
+protected:
+ /**
+ * Initializes the system.
+ * For now, it justs registers the window class (WNDCLASS).
+ * \return A success value.
+ */
+ virtual GHOST_TSuccess init();
/**
* Performs the actual cursor position update (location in screen coordinates).
diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm
index 1f6da80069e..114a5619fb4 100644
--- a/intern/ghost/intern/GHOST_SystemCocoa.mm
+++ b/intern/ghost/intern/GHOST_SystemCocoa.mm
@@ -931,59 +931,9 @@ bool GHOST_SystemCocoa::processEvents(bool waitForEvent)
anyProcessed = true;
- switch ([event type]) {
- case NSKeyDown:
- case NSKeyUp:
- case NSFlagsChanged:
- handleKeyEvent(event);
-
- /* Support system-wide keyboard shortcuts, like Exposé, ...) =>included in always NSApp sendEvent */
- /* if (([event modifierFlags] & NSCommandKeyMask) || [event type] == NSFlagsChanged) {
- [NSApp sendEvent:event];
- }*/
- break;
-
- case NSLeftMouseDown:
- case NSLeftMouseUp:
- case NSRightMouseDown:
- case NSRightMouseUp:
- case NSMouseMoved:
- case NSLeftMouseDragged:
- case NSRightMouseDragged:
- case NSScrollWheel:
- case NSOtherMouseDown:
- case NSOtherMouseUp:
- case NSOtherMouseDragged:
- case NSEventTypeMagnify:
- case NSEventTypeRotate:
- case NSEventTypeBeginGesture:
- case NSEventTypeEndGesture:
- handleMouseEvent(event);
- break;
-
- case NSTabletPoint:
- case NSTabletProximity:
- handleTabletEvent(event,[event type]);
- break;
-
- /* Trackpad features, fired only from OS X 10.5.2
- case NSEventTypeGesture:
- case NSEventTypeSwipe:
- break; */
-
- /*Unused events
- NSMouseEntered = 8,
- NSMouseExited = 9,
- NSAppKitDefined = 13,
- NSSystemDefined = 14,
- NSApplicationDefined = 15,
- NSPeriodic = 16,
- NSCursorUpdate = 17,*/
-
- default:
- break;
- }
- //Resend event to NSApp to ensure Mac wide events are handled
+ // Send event to NSApp to ensure Mac wide events are handled,
+ // this will send events to CocoaWindow which will call back
+ // to handleKeyEvent, handleMouseEvent and handleTabletEvent
[NSApp sendEvent:event];
[pool drain];
} while (event != nil);
diff --git a/intern/ghost/intern/GHOST_WindowCocoa.mm b/intern/ghost/intern/GHOST_WindowCocoa.mm
index 5e73001ccfe..9e01fdbf332 100644
--- a/intern/ghost/intern/GHOST_WindowCocoa.mm
+++ b/intern/ghost/intern/GHOST_WindowCocoa.mm
@@ -297,36 +297,105 @@ extern "C" {
[self interpretKeyEvents:events]; // calls insertText
[events removeObject:event];
[events release];
-
- return;
}
+
+ systemCocoa->handleKeyEvent(event);
}
-#if MAC_OS_X_VERSION_MIN_REQUIRED <= 1040
-//Cmd+key are handled differently before 10.5
-- (BOOL)performKeyEquivalent:(NSEvent *)theEvent
+- (void)keyUp:(NSEvent *)event
{
- NSString *chars = [theEvent charactersIgnoringModifiers];
-
- if ([chars length] <1)
- return NO;
-
- //Let cocoa handle menu shortcuts
- switch ([chars characterAtIndex:0]) {
- case 'q':
- case 'w':
- case 'h':
- case 'm':
- case '<':
- case '>':
- case '~':
- case '`':
- return NO;
- default:
- return YES;
- }
+ systemCocoa->handleKeyEvent(event);
+}
+
+- (void)flagsChanged:(NSEvent *)event
+{
+ systemCocoa->handleKeyEvent(event);
+}
+
+- (void)mouseDown:(NSEvent *)event
+{
+ systemCocoa->handleMouseEvent(event);
+}
+
+- (void)mouseUp:(NSEvent *)event
+{
+ systemCocoa->handleMouseEvent(event);
+}
+
+- (void)rightMouseDown:(NSEvent *)event
+{
+ systemCocoa->handleMouseEvent(event);
+}
+
+- (void)rightMouseUp:(NSEvent *)event
+{
+ systemCocoa->handleMouseEvent(event);
+}
+
+- (void)mouseMoved:(NSEvent *)event
+{
+ systemCocoa->handleMouseEvent(event);
+}
+
+- (void)mouseDragged:(NSEvent *)event
+{
+ systemCocoa->handleMouseEvent(event);
+}
+
+- (void)rightMouseDragged:(NSEvent *)event
+{
+ systemCocoa->handleMouseEvent(event);
+}
+
+- (void)scrollWheel:(NSEvent *)event
+{
+ systemCocoa->handleMouseEvent(event);
+}
+
+- (void)otherMouseDown:(NSEvent *)event
+{
+ systemCocoa->handleMouseEvent(event);
+}
+
+- (void)otherMouseUp:(NSEvent *)event
+{
+ systemCocoa->handleMouseEvent(event);
+}
+
+- (void)otherMouseDragged:(NSEvent *)event
+{
+ systemCocoa->handleMouseEvent(event);
+}
+
+- (void)magnifyWithEvent:(NSEvent *)event
+{
+ systemCocoa->handleMouseEvent(event);
+}
+
+- (void)rotateWithEvent:(NSEvent *)event
+{
+ systemCocoa->handleMouseEvent(event);
+}
+
+- (void)beginGestureWithEvent:(NSEvent *)event
+{
+ systemCocoa->handleMouseEvent(event);
+}
+
+- (void)endGestureWithEvent:(NSEvent *)event
+{
+ systemCocoa->handleMouseEvent(event);
+}
+
+- (void)tabletPoint:(NSEvent *)event
+{
+ systemCocoa->handleTabletEvent(event,[event type]);
+}
+
+- (void)tabletProximity:(NSEvent *)event
+{
+ systemCocoa->handleTabletEvent(event,[event type]);
}
-#endif
- (BOOL)isOpaque
{