~siretart/ubuntu/utopic/blender/libav10

« back to all changes in this revision

Viewing changes to intern/ghost/intern/GHOST_SystemCarbon.cpp

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2012-07-23 08:54:18 UTC
  • mfrom: (14.2.16 sid)
  • mto: (14.2.19 sid)
  • mto: This revision was merged to the branch mainline in revision 42.
  • Revision ID: package-import@ubuntu.com-20120723085418-9foz30v6afaf5ffs
Tags: 2.63a-2
* debian/: Cycles support added (Closes: #658075)
  For now, this top feature has been enabled only
  on [any-amd64 any-i386] architectures because
  of OpenImageIO failing on all others
* debian/: scripts installation path changed
  from /usr/lib to /usr/share:
  + debian/patches/: patchset re-worked for path changing
  + debian/control: "Breaks" field added on yafaray-exporter

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**
2
 
 * $Id: GHOST_SystemCarbon.cpp 30004 2010-07-05 19:59:37Z damien78 $
 
1
/*
3
2
 * ***** BEGIN GPL LICENSE BLOCK *****
4
3
 *
5
4
 * This program is free software; you can redistribute it and/or
26
25
 * ***** END GPL LICENSE BLOCK *****
27
26
 */
28
27
 
 
28
/** \file ghost/intern/GHOST_SystemCarbon.cpp
 
29
 *  \ingroup GHOST
 
30
 */
 
31
 
 
32
 
29
33
/**
30
34
 
31
 
 * $Id: GHOST_SystemCarbon.cpp 30004 2010-07-05 19:59:37Z damien78 $
32
35
 * Copyright (C) 2001 NaN Technologies B.V.
33
36
 * @author      Maarten Gribnau
34
37
 * @date        May 7, 2001
43
46
#include "GHOST_EventButton.h"
44
47
#include "GHOST_EventCursor.h"
45
48
#include "GHOST_EventWheel.h"
 
49
#ifdef WITH_INPUT_NDOF
46
50
#include "GHOST_EventNDOF.h"
 
51
#endif
47
52
 
48
53
#include "GHOST_TimerManager.h"
49
54
#include "GHOST_TimerTask.h"
387
392
void GHOST_SystemCarbon::getMainDisplayDimensions(GHOST_TUns32& width, GHOST_TUns32& height) const
388
393
{
389
394
        BitMap screenBits;
390
 
    Rect bnds = GetQDGlobalsScreenBits(&screenBits)->bounds;
 
395
        Rect bnds = GetQDGlobalsScreenBits(&screenBits)->bounds;
391
396
        width = bnds.right - bnds.left;
392
397
        height = bnds.bottom - bnds.top;
393
398
}
406
411
        const GHOST_TEmbedderWindowID parentWindow
407
412
)
408
413
{
409
 
    GHOST_IWindow* window = 0;
 
414
        GHOST_IWindow* window = 0;
410
415
 
411
416
        window = new GHOST_WindowCarbon (title, left, top, width, height, state, type);
412
417
 
413
 
    if (window) {
414
 
        if (window->getValid()) {
415
 
            // Store the pointer to the window 
416
 
            GHOST_ASSERT(m_windowManager, "m_windowManager not initialized");
417
 
            m_windowManager->addWindow(window);
418
 
            m_windowManager->setActiveWindow(window);
419
 
            pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowSize, window));
420
 
        }
421
 
        else {
 
418
        if (window) {
 
419
                if (window->getValid()) {
 
420
                        // Store the pointer to the window
 
421
                        GHOST_ASSERT(m_windowManager, "m_windowManager not initialized");
 
422
                        m_windowManager->addWindow(window);
 
423
                        m_windowManager->setActiveWindow(window);
 
424
                        pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowSize, window));
 
425
                }
 
426
                else {
422
427
                        GHOST_PRINT("GHOST_SystemCarbon::createWindow(): window invalid\n");
423
 
            delete window;
424
 
            window = 0;
425
 
        }
426
 
    }
 
428
                        delete window;
 
429
                        window = 0;
 
430
                }
 
431
        }
427
432
        else {
428
433
                GHOST_PRINT("GHOST_SystemCarbon::createWindow(): could not create window\n");
429
434
        }
430
 
    return window;
 
435
        return window;
431
436
}
432
437
 
433
438
GHOST_TSuccess GHOST_SystemCarbon::beginFullScreen(const GHOST_DisplaySetting& setting, GHOST_IWindow** window, const bool stereoVisual)
515
520
                }
516
521
        } while (waitForEvent && !anyProcessed);
517
522
        
518
 
    return anyProcessed;
 
523
        return anyProcessed;
519
524
}
520
525
        
521
526
 
522
527
GHOST_TSuccess GHOST_SystemCarbon::getCursorPosition(GHOST_TInt32& x, GHOST_TInt32& y) const
523
528
{
524
 
    Point mouseLoc;
525
 
    // Get the position of the mouse in the active port
526
 
    ::GetGlobalMouse(&mouseLoc);
527
 
    // Convert the coordinates to screen coordinates
528
 
    x = (GHOST_TInt32)mouseLoc.h;
529
 
    y = (GHOST_TInt32)mouseLoc.v;
530
 
    return GHOST_kSuccess;
 
529
        Point mouseLoc;
 
530
        // Get the position of the mouse in the active port
 
531
        ::GetGlobalMouse(&mouseLoc);
 
532
        // Convert the coordinates to screen coordinates
 
533
        x = (GHOST_TInt32)mouseLoc.h;
 
534
        y = (GHOST_TInt32)mouseLoc.v;
 
535
        return GHOST_kSuccess;
531
536
}
532
537
 
533
538
 
545
550
        // this call below sends event, but empties other events (like shift)
546
551
        // CGPostMouseEvent(CGPointMake(xf, yf), TRUE, 1, FALSE, 0);
547
552
 
548
 
    return GHOST_kSuccess;
 
553
        return GHOST_kSuccess;
549
554
}
550
555
 
551
556
 
552
557
GHOST_TSuccess GHOST_SystemCarbon::getModifierKeys(GHOST_ModifierKeys& keys) const
553
558
{
554
 
    UInt32 modifiers = ::GetCurrentKeyModifiers();
 
559
        UInt32 modifiers = ::GetCurrentKeyModifiers();
555
560
 
556
 
    keys.set(GHOST_kModifierKeyCommand, (modifiers & cmdKey) ? true : false);
557
 
    keys.set(GHOST_kModifierKeyLeftAlt, (modifiers & optionKey) ? true : false);
558
 
    keys.set(GHOST_kModifierKeyLeftShift, (modifiers & shiftKey) ? true : false);
559
 
    keys.set(GHOST_kModifierKeyLeftControl, (modifiers & controlKey) ? true : false);
 
561
        keys.set(GHOST_kModifierKeyOS, (modifiers & cmdKey) ? true : false);
 
562
        keys.set(GHOST_kModifierKeyLeftAlt, (modifiers & optionKey) ? true : false);
 
563
        keys.set(GHOST_kModifierKeyLeftShift, (modifiers & shiftKey) ? true : false);
 
564
        keys.set(GHOST_kModifierKeyLeftControl, (modifiers & controlKey) ? true : false);
560
565
        
561
 
    return GHOST_kSuccess;
 
566
        return GHOST_kSuccess;
562
567
}
563
568
 
564
 
        /* XXX, incorrect for multibutton mice */
 
569
/* XXX, incorrect for multibutton mice */
565
570
GHOST_TSuccess GHOST_SystemCarbon::getButtons(GHOST_Buttons& buttons) const
566
571
{
567
 
    Boolean theOnlyButtonIsDown = ::Button();
568
 
    buttons.clear();
569
 
    buttons.set(GHOST_kButtonMaskLeft, theOnlyButtonIsDown);
570
 
    return GHOST_kSuccess;
 
572
        Boolean theOnlyButtonIsDown = ::Button();
 
573
        buttons.clear();
 
574
        buttons.set(GHOST_kButtonMaskLeft, theOnlyButtonIsDown);
 
575
        return GHOST_kSuccess;
571
576
}
572
577
 
573
578
#define FIRSTFILEBUFLG 512
574
579
static bool g_hasFirstFile = false;
575
580
static char g_firstFileBuf[512];
576
581
 
577
 
extern "C" int GHOST_HACK_getFirstFile(char buf[FIRSTFILEBUFLG]) { 
 
582
extern "C" int GHOST_HACK_getFirstFile(char buf[FIRSTFILEBUFLG])
 
583
{
578
584
        if (g_hasFirstFile) {
579
585
                strncpy(buf, g_firstFileBuf, FIRSTFILEBUFLG - 1);
580
586
                buf[FIRSTFILEBUFLG - 1] = '\0';
652
658
 
653
659
GHOST_TSuccess GHOST_SystemCarbon::init()
654
660
{
655
 
 
656
 
    GHOST_TSuccess success = GHOST_System::init();
657
 
    if (success) {
 
661
 
 
662
        GHOST_TSuccess success = GHOST_System::init();
 
663
        if (success) {
658
664
                /*
659
 
         * Initialize the cursor to the standard arrow shape (so that we can change it later on).
660
 
         * This initializes the cursor's visibility counter to 0.
661
 
         */
662
 
        ::InitCursor();
 
665
                 * Initialize the cursor to the standard arrow shape (so that we can change it later on).
 
666
                 * This initializes the cursor's visibility counter to 0.
 
667
                 */
 
668
                ::InitCursor();
663
669
 
664
670
                MenuRef windMenu;
665
671
                ::CreateStandardWindowMenu(0, &windMenu);
666
672
                ::InsertMenu(windMenu, 0);
667
673
                ::DrawMenuBar();
668
674
 
669
 
        ::InstallApplicationEventHandler(sEventHandlerProc, GetEventTypeCount(kEvents), kEvents, this, &m_handler);
 
675
                ::InstallApplicationEventHandler(sEventHandlerProc, GetEventTypeCount(kEvents), kEvents, this, &m_handler);
670
676
                
671
677
                ::AEInstallEventHandler(kCoreEventClass, kAEOpenApplication, sAEHandlerLaunch, (SInt32) this, false);
672
678
                ::AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments, sAEHandlerOpenDocs, (SInt32) this, false);
673
679
                ::AEInstallEventHandler(kCoreEventClass, kAEPrintDocuments, sAEHandlerPrintDocs, (SInt32) this, false);
674
680
                ::AEInstallEventHandler(kCoreEventClass, kAEQuitApplication, sAEHandlerQuit, (SInt32) this, false);
675
681
                
676
 
    }
677
 
    return success;
 
682
        }
 
683
        return success;
678
684
}
679
685
 
680
686
 
681
687
GHOST_TSuccess GHOST_SystemCarbon::exit()
682
688
{
683
 
    return GHOST_System::exit();
 
689
        return GHOST_System::exit();
684
690
}
685
691
 
686
692
 
840
846
                                        err = noErr;
841
847
                                }
842
848
                        }
843
 
            break;
 
849
                        break;
844
850
                        
845
851
                case kEventMouseMoved:
846
852
                case kEventMouseDragged: {
847
 
                        Point mousePos;
 
853
                        Point mousePos;
848
854
 
849
855
                        if (window) {
850
856
                                //handle any tablet events that may have come with the mouse event (optional)
853
859
                                ::GetEventParameter(event, kEventParamMouseLocation, typeQDPoint, NULL, sizeof(Point), NULL, &mousePos);
854
860
                                pushEvent(new GHOST_EventCursor(getMilliSeconds(), GHOST_kEventCursorMove, window, mousePos.h, mousePos.v));
855
861
                                err = noErr;
856
 
                        }
 
862
                        }
857
863
                        break;
858
864
                }
859
865
                case kEventMouseWheelMoved:
924
930
                                } else {
925
931
                                        type = GHOST_kEventKeyUp;
926
932
                                }
927
 
                                pushEvent( new GHOST_EventKey( getMilliSeconds(), type, window, key, ascii) );
 
933
                                pushEvent( new GHOST_EventKey( getMilliSeconds(), type, window, key, ascii, NULL) );
928
934
//                      }
929
935
                        break;
930
936
        
941
947
                                pushEvent( new GHOST_EventKey(getMilliSeconds(), (modifiers & optionKey)?GHOST_kEventKeyDown:GHOST_kEventKeyUp, window, GHOST_kKeyLeftAlt) );
942
948
                        }
943
949
                        if ((modifiers & cmdKey) != (m_modifierMask & cmdKey)) {
944
 
                                pushEvent( new GHOST_EventKey(getMilliSeconds(), (modifiers & cmdKey)?GHOST_kEventKeyDown:GHOST_kEventKeyUp, window, GHOST_kKeyCommand) );
 
950
                                pushEvent( new GHOST_EventKey(getMilliSeconds(), (modifiers & cmdKey)?GHOST_kEventKeyDown:GHOST_kEventKeyUp, window, GHOST_kKeyOS) );
945
951
                        }
946
952
                        
947
953
                        m_modifierMask = modifiers;
1087
1093
        }
1088
1094
 
1089
1095
        ::HiliteMenu(0);
1090
 
    return handled;
 
1096
        return handled;
1091
1097
}
1092
1098
 
1093
1099
 
1094
1100
OSStatus GHOST_SystemCarbon::sEventHandlerProc(EventHandlerCallRef handler, EventRef event, void* userData)
1095
1101
{
1096
1102
        GHOST_SystemCarbon* sys = (GHOST_SystemCarbon*) userData;
1097
 
    OSStatus err = eventNotHandledErr;
 
1103
        OSStatus err = eventNotHandledErr;
1098
1104
        GHOST_IWindow* window;
 
1105
#ifdef WITH_INPUT_NDOF
1099
1106
        GHOST_TEventNDOFData data;
 
1107
#endif
1100
1108
        UInt32 kind;
1101
1109
        
1102
 
    switch (::GetEventClass(event))
1103
 
    {
 
1110
        switch (::GetEventClass(event))
 
1111
        {
1104
1112
                case kEventClassAppleEvent:
1105
1113
                        EventRecord eventrec;
1106
1114
                        if (ConvertEventRefToEventRecord(event, &eventrec)) {
1107
1115
                                err = AEProcessAppleEvent(&eventrec);
1108
1116
                        }
1109
1117
                        break;
1110
 
        case kEventClassMouse:
1111
 
            err = sys->handleMouseEvent(event);
1112
 
            break;
 
1118
                case kEventClassMouse:
 
1119
                        err = sys->handleMouseEvent(event);
 
1120
                        break;
1113
1121
                case kEventClassWindow:
1114
1122
                        err = sys->handleWindowEvent(event);
1115
1123
                        break;
1116
1124
                case kEventClassKeyboard:
1117
1125
                        err = sys->handleKeyEvent(event);
1118
1126
                        break;
1119
 
                case kEventClassBlender :
 
1127
                case kEventClassBlender :
 
1128
#ifdef WITH_INPUT_NDOF
1120
1129
                        window = sys->m_windowManager->getActiveWindow();
1121
1130
                        sys->m_ndofManager->GHOST_NDOFGetDatas(data);
1122
1131
                        kind = ::GetEventKind(event);
1132
1141
//                                      printf("button\n");
1133
1142
                                        break;
1134
1143
                        }
 
1144
#endif
1135
1145
                        err = noErr;
1136
1146
                        break;
1137
1147
                default : 
1138
 
                        ;
 
1148
                        ;
1139
1149
                        break;
1140
 
   }
 
1150
        }
1141
1151
 
1142
 
    return err;
 
1152
        return err;
1143
1153
}
1144
1154
 
1145
1155
GHOST_TUns8* GHOST_SystemCarbon::getClipboard(bool selection) const
1214
1224
                CFRelease(textData);
1215
1225
        }
1216
1226
}
1217
 
 
1218
 
 
1219
 
const GHOST_TUns8* GHOST_SystemCarbon::getSystemDir() const
1220
 
{
1221
 
        return (GHOST_TUns8*)"/Library/Application Support";
1222
 
}
1223
 
 
1224
 
const GHOST_TUns8* GHOST_SystemCarbon::getUserDir() const
1225
 
{
1226
 
        static char usrPath[256] = "";
1227
 
        char* env = getenv("HOME");
1228
 
        
1229
 
        if (env) {
1230
 
                strncpy(usrPath, env, 245);
1231
 
                usrPath[245]=0;
1232
 
                strcat(usrPath, "/Library/Application Support");
1233
 
                return (GHOST_TUns8*) usrPath;
1234
 
        }
1235
 
        else
1236
 
                return NULL;
1237
 
}
1238
 
 
1239
 
const GHOST_TUns8* GHOST_SystemCarbon::getBinaryDir() const
1240
 
{
1241
 
        CFURLRef bundleURL;
1242
 
        CFStringRef pathStr;
1243
 
        static char path[256];
1244
 
        CFBundleRef mainBundle = CFBundleGetMainBundle();
1245
 
        
1246
 
        bundleURL = CFBundleCopyBundleURL(mainBundle);
1247
 
        pathStr = CFURLCopyFileSystemPath(bundleURL, kCFURLPOSIXPathStyle);
1248
 
        CFStringGetCString(pathStr, path, 255, kCFStringEncodingASCII);
1249
 
        CFRelease(pathStr);
1250
 
        CFRelease(bundleURL);
1251
 
        return (GHOST_TUns8*)path;
1252
 
}