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

« back to all changes in this revision

Viewing changes to intern/ghost/intern/GHOST_WindowCocoa.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:
44
44
#include "GHOST_SystemCocoa.h"
45
45
#include "GHOST_Debug.h"
46
46
 
 
47
#if MAC_OS_X_VERSION_MAX_ALLOWED < 1070
 
48
/* Lion style fullscreen support when building with the 10.6 SDK */
 
49
enum {
 
50
        NSWindowCollectionBehaviorFullScreenPrimary = 1 << 7,
 
51
        NSFullScreenWindowMask = 1 << 14
 
52
};
 
53
#endif
47
54
 
48
55
#pragma mark Cocoa window delegate object
49
 
/* live resize ugly patch
50
 
extern "C" {
51
 
        struct bContext;
52
 
        typedef struct bContext bContext;
53
 
        bContext* ghostC;
54
 
        extern int wm_window_timer(const bContext *C);
55
 
        extern void wm_window_process_events(const bContext *C);
56
 
        extern void wm_event_do_handlers(bContext *C);
57
 
        extern void wm_event_do_notifiers(bContext *C);
58
 
        extern void wm_draw_update(bContext *C);
59
 
};*/
 
56
 
60
57
@interface CocoaWindowDelegate : NSObject
61
58
<NSWindowDelegate>
62
59
{
118
115
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
119
116
        //}
120
117
#endif
121
 
        /* Live resize ugly patch. Needed because live resize runs in a modal loop, not letting main loop run
 
118
        /* Live resize, send event, gets handled in wm_window.c. Needed because live resize runs in a modal loop, not letting main loop run */
122
119
         if ([[notification object] inLiveResize]) {
123
120
                systemCocoa->dispatchEvents();
124
 
                wm_window_timer(ghostC);
125
 
                wm_event_do_handlers(ghostC);
126
 
                wm_event_do_notifiers(ghostC);
127
 
                wm_draw_update(ghostC);
128
 
        }*/
 
121
        }
129
122
}
130
123
 
131
124
- (void)windowDidChangeBackingProperties:(NSNotification *)notification
276
269
// The trick to prevent Cocoa from complaining (beeping)
277
270
- (void)keyDown:(NSEvent *)event
278
271
{
 
272
        systemCocoa->handleKeyEvent(event);
 
273
 
279
274
        /* Start or continue composing? */
280
275
        if ([[event characters] length] == 0  ||
281
276
            [[event charactersIgnoringModifiers] length] == 0 ||
290
285
                [self interpretKeyEvents:events]; // calls insertText
291
286
                [events removeObject:event];
292
287
                [events release];
293
 
 
294
288
                return;
295
289
        }
296
290
}
297
291
 
298
 
#if MAC_OS_X_VERSION_MIN_REQUIRED <= 1040
299
 
//Cmd+key are handled differently before 10.5
300
 
- (BOOL)performKeyEquivalent:(NSEvent *)theEvent
301
 
{
302
 
        NSString *chars = [theEvent charactersIgnoringModifiers];
303
 
        
304
 
        if ([chars length] <1) 
305
 
                return NO;
306
 
        
307
 
        //Let cocoa handle menu shortcuts
308
 
        switch ([chars characterAtIndex:0]) {
309
 
                case 'q':
310
 
                case 'w':
311
 
                case 'h':
312
 
                case 'm':
313
 
                case '<':
314
 
                case '>':
315
 
                case '~':
316
 
                case '`':
317
 
                        return NO;
318
 
                default:
319
 
                        return YES;
320
 
        }
321
 
}
322
 
#endif
 
292
- (void)keyUp:(NSEvent *)event
 
293
{
 
294
        systemCocoa->handleKeyEvent(event);
 
295
}
 
296
 
 
297
- (void)flagsChanged:(NSEvent *)event
 
298
{
 
299
        systemCocoa->handleKeyEvent(event);
 
300
}
 
301
 
 
302
- (void)mouseDown:(NSEvent *)event
 
303
{
 
304
        systemCocoa->handleMouseEvent(event);
 
305
}
 
306
 
 
307
- (void)mouseUp:(NSEvent *)event
 
308
{
 
309
        systemCocoa->handleMouseEvent(event);
 
310
}
 
311
 
 
312
- (void)rightMouseDown:(NSEvent *)event
 
313
{
 
314
        systemCocoa->handleMouseEvent(event);
 
315
}
 
316
 
 
317
- (void)rightMouseUp:(NSEvent *)event
 
318
{
 
319
        systemCocoa->handleMouseEvent(event);
 
320
}
 
321
 
 
322
- (void)mouseMoved:(NSEvent *)event
 
323
{
 
324
        systemCocoa->handleMouseEvent(event);
 
325
}
 
326
 
 
327
- (void)mouseDragged:(NSEvent *)event
 
328
{
 
329
        systemCocoa->handleMouseEvent(event);
 
330
}
 
331
 
 
332
- (void)rightMouseDragged:(NSEvent *)event
 
333
{
 
334
        systemCocoa->handleMouseEvent(event);
 
335
}
 
336
 
 
337
- (void)scrollWheel:(NSEvent *)event
 
338
{
 
339
        systemCocoa->handleMouseEvent(event);
 
340
}
 
341
 
 
342
- (void)otherMouseDown:(NSEvent *)event
 
343
{
 
344
        systemCocoa->handleMouseEvent(event);
 
345
}
 
346
 
 
347
- (void)otherMouseUp:(NSEvent *)event
 
348
{
 
349
        systemCocoa->handleMouseEvent(event);
 
350
}
 
351
 
 
352
- (void)otherMouseDragged:(NSEvent *)event
 
353
{
 
354
        systemCocoa->handleMouseEvent(event);
 
355
}
 
356
 
 
357
- (void)magnifyWithEvent:(NSEvent *)event
 
358
{
 
359
        systemCocoa->handleMouseEvent(event);
 
360
}
 
361
 
 
362
- (void)rotateWithEvent:(NSEvent *)event
 
363
{
 
364
        systemCocoa->handleMouseEvent(event);
 
365
}
 
366
 
 
367
- (void)beginGestureWithEvent:(NSEvent *)event
 
368
{
 
369
        systemCocoa->handleMouseEvent(event);
 
370
}
 
371
 
 
372
- (void)endGestureWithEvent:(NSEvent *)event
 
373
{
 
374
        systemCocoa->handleMouseEvent(event);
 
375
}
 
376
 
 
377
- (void)tabletPoint:(NSEvent *)event
 
378
{
 
379
        systemCocoa->handleTabletEvent(event,[event type]);
 
380
}
 
381
 
 
382
- (void)tabletProximity:(NSEvent *)event
 
383
{
 
384
        systemCocoa->handleTabletEvent(event,[event type]);
 
385
}
323
386
 
324
387
- (BOOL)isOpaque
325
388
{
454
517
        GHOST_TDrawingContextType type,
455
518
        const bool stereoVisual, const GHOST_TUns16 numOfAASamples
456
519
) :
457
 
        GHOST_Window(width, height, state, GHOST_kDrawingContextTypeNone, stereoVisual, numOfAASamples),
 
520
        GHOST_Window(width, height, state, GHOST_kDrawingContextTypeNone, stereoVisual, false, numOfAASamples),
458
521
        m_customCursor(0)
459
522
{
460
523
        NSOpenGLPixelFormatAttribute pixelFormatAttrsWindow[40];
622
685
        
623
686
        [m_window registerForDraggedTypes:[NSArray arrayWithObjects:NSFilenamesPboardType,
624
687
                                                                                  NSStringPboardType, NSTIFFPboardType, nil]];
625
 
                                                                                  
 
688
        
 
689
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
 
690
        if (state != GHOST_kWindowStateFullScreen) {
 
691
                [m_window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
 
692
        }
 
693
#endif
 
694
        
626
695
        if (state == GHOST_kWindowStateFullScreen)
627
696
                setState(GHOST_kWindowStateFullScreen);
628
697
                
845
914
        GHOST_ASSERT(getValid(), "GHOST_WindowCocoa::getState(): window invalid");
846
915
        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
847
916
        GHOST_TWindowState state;
 
917
 
 
918
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
 
919
        NSUInteger masks = [m_window styleMask];
 
920
 
 
921
        if (masks & NSFullScreenWindowMask) {
 
922
                // Lion style fullscreen
 
923
                state = GHOST_kWindowStateFullScreen;
 
924
        }
 
925
        else
 
926
#endif
848
927
        if (m_fullScreen) {
849
928
                state = GHOST_kWindowStateFullScreen;
850
929
        } 
953
1032
                        [m_window zoom:nil];
954
1033
                        break;
955
1034
                
956
 
                case GHOST_kWindowStateFullScreen:
 
1035
                case GHOST_kWindowStateFullScreen: {
 
1036
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
 
1037
                        NSUInteger masks = [m_window styleMask];
 
1038
 
 
1039
                        if (!m_fullScreen && !(masks & NSFullScreenWindowMask)) {
 
1040
#else
957
1041
                        if (!m_fullScreen) {
 
1042
#endif
958
1043
                                NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
959
1044
                        
960
1045
                                /* This status change needs to be done before Cocoa call to enter fullscreen mode
963
1048
                                m_fullScreen = true;
964
1049
 
965
1050
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
 
1051
                                /* Disable toggle for Lion style fullscreen */
 
1052
                                [m_window setCollectionBehavior:NSWindowCollectionBehaviorDefault];
 
1053
#endif
 
1054
 
 
1055
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
966
1056
                                //10.6 provides Cocoa functions to autoshow menu bar, and to change a window style
967
 
                                //Hide menu & dock if needed
 
1057
                                //Hide menu & dock if on primary screen. else only menu
968
1058
                                if ([[m_window screen] isEqual:[[NSScreen screens] objectAtIndex:0]]) {
969
 
                                        [NSApp setPresentationOptions:(NSApplicationPresentationHideDock | NSApplicationPresentationAutoHideMenuBar)];
 
1059
                                        [NSApp setPresentationOptions:(NSApplicationPresentationAutoHideDock | NSApplicationPresentationAutoHideMenuBar)];
970
1060
                                }
971
1061
                                //Make window borderless and enlarge it
972
1062
                                [m_window setStyleMask:NSBorderlessWindowMask];
1011
1101
                                [pool drain];
1012
1102
                                }
1013
1103
                        break;
 
1104
                }
1014
1105
                case GHOST_kWindowStateNormal:
1015
1106
                default:
1016
1107
                        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
 
1108
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
 
1109
                        NSUInteger masks = [m_window styleMask];
 
1110
 
 
1111
                        if (masks & NSFullScreenWindowMask) {
 
1112
                                // Lion style fullscreen
 
1113
                                [m_window toggleFullScreen:nil];
 
1114
                        }
 
1115
                        else
 
1116
#endif
1017
1117
                        if (m_fullScreen) {
1018
1118
                                m_fullScreen = false;
1019
1119
 
 
1120
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
 
1121
                                /* Enable toggle for into Lion style fullscreen */
 
1122
                                [m_window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
 
1123
#endif
 
1124
 
1020
1125
                                //Exit fullscreen
1021
1126
#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
1022
1127
                                //Show again menu & dock if needed