~ubuntu-branches/ubuntu/trusty/blender/trusty-proposed

« back to all changes in this revision

Viewing changes to intern/ghost/intern/GHOST_SystemCocoa.mm

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2013-08-14 10:43:49 UTC
  • mfrom: (14.2.19 sid)
  • Revision ID: package-import@ubuntu.com-20130814104349-t1d5mtwkphp12dyj
Tags: 2.68a-3
* Upload to unstable
* debian/: python3.3 Depends simplified
  - debian/control: python3.3 Depends dropped
    for blender-data package
  - 0001-blender_thumbnailer.patch refreshed
* debian/control: libavcodec b-dep versioning dropped

Show diffs side-by-side

added added

removed removed

Lines of Context:
500
500
- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender;
501
501
- (void)applicationWillTerminate:(NSNotification *)aNotification;
502
502
- (void)applicationWillBecomeActive:(NSNotification *)aNotification;
 
503
- (void)toggleFullScreen:(NSNotification *)notification;
503
504
@end
504
505
 
505
506
@implementation CocoaAppDelegate : NSObject
536
537
{
537
538
        systemCocoa->handleApplicationBecomeActiveEvent();
538
539
}
 
540
 
 
541
- (void)toggleFullScreen:(NSNotification *)notification
 
542
{
 
543
}
 
544
 
539
545
@end
540
546
 
541
547
 
542
548
 
 
549
 
543
550
#pragma mark initialization/finalization
544
551
 
 
552
char GHOST_user_locale[128]; // Global current user locale
545
553
 
546
554
GHOST_SystemCocoa::GHOST_SystemCocoa()
547
555
{
580
588
        rstring = NULL;
581
589
        
582
590
        m_ignoreWindowSizedMessages = false;
 
591
        
 
592
        //Get current locale
 
593
        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
 
594
        CFLocaleRef myCFLocale = CFLocaleCopyCurrent();
 
595
        NSLocale * myNSLocale = (NSLocale *) myCFLocale;
 
596
        [myNSLocale autorelease];
 
597
        NSString *nsIdentifier = [myNSLocale localeIdentifier];
 
598
        strncpy(GHOST_user_locale, [nsIdentifier UTF8String], sizeof(GHOST_user_locale) - 1);
 
599
        [pool drain];
583
600
}
584
601
 
585
602
GHOST_SystemCocoa::~GHOST_SystemCocoa()
647
664
                                
648
665
                                [windowMenu addItemWithTitle:@"Zoom" action:@selector(performZoom:) keyEquivalent:@""];
649
666
                                
 
667
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 // make it build with  10.6 deployment target, but as it is not available in 10.6, it will get weaklinked
 
668
                                menuItem = [windowMenu addItemWithTitle:@"Enter Full Screen" action:@selector(toggleFullScreen:) keyEquivalent:@"f" ];
 
669
                                [menuItem setKeyEquivalentModifierMask:NSControlKeyMask | NSCommandKeyMask];
 
670
#endif
 
671
 
650
672
                                menuItem = [windowMenu addItemWithTitle:@"Close" action:@selector(performClose:) keyEquivalent:@"w"];
651
673
                                [menuItem setKeyEquivalentModifierMask:NSCommandKeyMask];
652
674
                                
734
756
        GHOST_TWindowState state,
735
757
        GHOST_TDrawingContextType type,
736
758
        bool stereoVisual,
 
759
        const bool exclusive,
737
760
        const GHOST_TUns16 numOfAASamples,
738
761
        const GHOST_TEmbedderWindowID parentWindow
739
762
)
910
933
                        
911
934
                        anyProcessed = true;
912
935
                        
913
 
                        switch ([event type]) {
914
 
                                case NSKeyDown:
915
 
                                case NSKeyUp:
916
 
                                case NSFlagsChanged:
 
936
                        // Send event to NSApp to ensure Mac wide events are handled,
 
937
                        // this will send events to CocoaWindow which will call back
 
938
                        // to handleKeyEvent, handleMouseEvent and handleTabletEvent
 
939
 
 
940
                        // There is on special exception for ctrl+(shift)+tab. We do not
 
941
                        // get keyDown events delivered to the view because they are
 
942
                        // special hotkeys to switch between views, so override directly
 
943
 
 
944
                        if ([event type] == NSKeyDown &&
 
945
                           [event keyCode] == kVK_Tab &&
 
946
                           ([event modifierFlags] & NSControlKeyMask)) {
 
947
                                handleKeyEvent(event);
 
948
                        }
 
949
                        else {
 
950
                                // For some reason NSApp is swallowing the key up events when command
 
951
                                // key is pressed, even if there seems to be no apparent reason to do
 
952
                                // so, as a workaround we always handle these up events.
 
953
                                if ([event type] == NSKeyUp && ([event modifierFlags] & NSCommandKeyMask))
917
954
                                        handleKeyEvent(event);
918
 
                                        
919
 
                                        /* Support system-wide keyboard shortcuts, like Exposé, ...) =>included in always NSApp sendEvent */
920
 
                                        /*              if (([event modifierFlags] & NSCommandKeyMask) || [event type] == NSFlagsChanged) {
921
 
                                         [NSApp sendEvent:event];
922
 
                                         }*/
923
 
                                        break;
924
 
                                        
925
 
                                case NSLeftMouseDown:
926
 
                                case NSLeftMouseUp:
927
 
                                case NSRightMouseDown:
928
 
                                case NSRightMouseUp:
929
 
                                case NSMouseMoved:
930
 
                                case NSLeftMouseDragged:
931
 
                                case NSRightMouseDragged:
932
 
                                case NSScrollWheel:
933
 
                                case NSOtherMouseDown:
934
 
                                case NSOtherMouseUp:
935
 
                                case NSOtherMouseDragged:
936
 
                                case NSEventTypeMagnify:
937
 
                                case NSEventTypeRotate:
938
 
                                case NSEventTypeBeginGesture:
939
 
                                case NSEventTypeEndGesture:
940
 
                                        handleMouseEvent(event);
941
 
                                        break;
942
 
                                        
943
 
                                case NSTabletPoint:
944
 
                                case NSTabletProximity:
945
 
                                        handleTabletEvent(event,[event type]);
946
 
                                        break;
947
 
                                        
948
 
                                        /* Trackpad features, fired only from OS X 10.5.2
949
 
                                         case NSEventTypeGesture:
950
 
                                         case NSEventTypeSwipe:
951
 
                                         break; */
952
 
                                        
953
 
                                        /*Unused events
954
 
                                         NSMouseEntered       = 8,
955
 
                                         NSMouseExited        = 9,
956
 
                                         NSAppKitDefined      = 13,
957
 
                                         NSSystemDefined      = 14,
958
 
                                         NSApplicationDefined = 15,
959
 
                                         NSPeriodic           = 16,
960
 
                                         NSCursorUpdate       = 17,*/
961
 
                                        
962
 
                                default:
963
 
                                        break;
 
955
 
 
956
                                [NSApp sendEvent:event];
964
957
                        }
965
 
                        //Resend event to NSApp to ensure Mac wide events are handled
966
 
                        [NSApp sendEvent:event];
 
958
 
967
959
                        [pool drain];
968
960
                } while (event != nil);
969
961
#if 0
1395
1387
        
1396
1388
        switch (eventType) {
1397
1389
                case NSTabletPoint:
 
1390
                        // workaround 2 cornercases:
 
1391
                        // 1. if [event isEnteringProximity] was not triggered since program-start
 
1392
                        // 2. device is not sending [event pointingDeviceType], due no eraser
 
1393
                        if (ct.Active == GHOST_kTabletModeNone)
 
1394
                                ct.Active = GHOST_kTabletModeStylus;
 
1395
 
1398
1396
                        ct.Pressure = [event pressure];
1399
1397
                        ct.Xtilt = [event tilt].x;
1400
1398
                        ct.Ytilt = [event tilt].y;
1772
1770
                                //printf("Key down rawCode=0x%x charsIgnoringModifiers=%c keyCode=%u ascii=%i %c utf8=%s\n",[event keyCode],[charsIgnoringModifiers length]>0?[charsIgnoringModifiers characterAtIndex:0]:' ',keyCode,ascii,ascii, utf8_buf);
1773
1771
                        }
1774
1772
                        else {
1775
 
                                pushEvent( new GHOST_EventKey([event timestamp] * 1000, GHOST_kEventKeyUp, window, keyCode, 0, '\0') );
 
1773
                                pushEvent( new GHOST_EventKey([event timestamp] * 1000, GHOST_kEventKeyUp, window, keyCode, 0, NULL) );
1776
1774
                                //printf("Key up rawCode=0x%x charsIgnoringModifiers=%c keyCode=%u ascii=%i %c utf8=%s\n",[event keyCode],[charsIgnoringModifiers length]>0?[charsIgnoringModifiers characterAtIndex:0]:' ',keyCode,ascii,ascii, utf8_buf);
1777
1775
                        }
1778
1776
                        break;