Changeset View
Changeset View
Standalone View
Standalone View
intern/ghost/intern/GHOST_SystemCocoa.mm
| Show All 21 Lines | |||||
| * | * | ||||
| * Contributors: Maarten Gribnau 05/2001 | * Contributors: Maarten Gribnau 05/2001 | ||||
| * Damien Plisson 09/2009 | * Damien Plisson 09/2009 | ||||
| * Jens Verwiebe 10/2014 | * Jens Verwiebe 10/2014 | ||||
| * | * | ||||
| * ***** END GPL LICENSE BLOCK ***** | * ***** END GPL LICENSE BLOCK ***** | ||||
| */ | */ | ||||
| #import <Cocoa/Cocoa.h> | |||||
| /*For the currently not ported to Cocoa keyboard layout functions (64bit & 10.6 compatible)*/ | |||||
| #include <Carbon/Carbon.h> | |||||
| #include <sys/time.h> | |||||
| #include <sys/types.h> | |||||
| #include <sys/sysctl.h> | |||||
| #include "GHOST_SystemCocoa.h" | #include "GHOST_SystemCocoa.h" | ||||
| #include "GHOST_DisplayManagerCocoa.h" | #include "GHOST_DisplayManagerCocoa.h" | ||||
| #include "GHOST_EventKey.h" | #include "GHOST_EventKey.h" | ||||
| #include "GHOST_EventButton.h" | #include "GHOST_EventButton.h" | ||||
| #include "GHOST_EventCursor.h" | #include "GHOST_EventCursor.h" | ||||
| #include "GHOST_EventWheel.h" | #include "GHOST_EventWheel.h" | ||||
| #include "GHOST_EventTrackpad.h" | #include "GHOST_EventTrackpad.h" | ||||
| #include "GHOST_EventDragnDrop.h" | #include "GHOST_EventDragnDrop.h" | ||||
| #include "GHOST_EventString.h" | #include "GHOST_EventString.h" | ||||
| #include "GHOST_TimerManager.h" | #include "GHOST_TimerManager.h" | ||||
| #include "GHOST_TimerTask.h" | #include "GHOST_TimerTask.h" | ||||
| #include "GHOST_WindowManager.h" | #include "GHOST_WindowManager.h" | ||||
| #include "GHOST_WindowCocoa.h" | #include "GHOST_WindowCocoa.h" | ||||
| #if defined(WITH_GL_EGL) | |||||
| # include "GHOST_ContextEGL.h" | |||||
| #else | |||||
| # include "GHOST_ContextCGL.h" | |||||
| #endif | |||||
| #ifdef WITH_INPUT_NDOF | #ifdef WITH_INPUT_NDOF | ||||
| #include "GHOST_NDOFManagerCocoa.h" | #include "GHOST_NDOFManagerCocoa.h" | ||||
| #endif | #endif | ||||
| #include "AssertMacros.h" | #include "AssertMacros.h" | ||||
| #import <Cocoa/Cocoa.h> | |||||
| /* For the currently not ported to Cocoa keyboard layout functions (64bit & 10.6 compatible) */ | |||||
| #include <Carbon/Carbon.h> | |||||
| #include <sys/time.h> | |||||
| #include <sys/types.h> | |||||
| #include <sys/sysctl.h> | |||||
| #pragma mark KeyMap, mouse converters | #pragma mark KeyMap, mouse converters | ||||
| static GHOST_TButtonMask convertButton(int button) | static GHOST_TButtonMask convertButton(int button) | ||||
| { | { | ||||
| switch (button) { | switch (button) { | ||||
| case 0: | case 0: | ||||
| return GHOST_kButtonMaskLeft; | return GHOST_kButtonMaskLeft; | ||||
| ▲ Show 20 Lines • Show All 508 Lines • ▼ Show 20 Lines | else { | ||||
| window = NULL; | window = NULL; | ||||
| } | } | ||||
| [pool drain]; | [pool drain]; | ||||
| return window; | return window; | ||||
| } | } | ||||
| /** | /** | ||||
| * Create a new offscreen context. | |||||
| * Never explicitly delete the context, use disposeContext() instead. | |||||
| * \return The new context (or 0 if creation failed). | |||||
| */ | |||||
| GHOST_IContext * | |||||
| GHOST_SystemCocoa:: | |||||
| createOffscreenContext() | |||||
| { | |||||
| GHOST_Context *context = new GHOST_ContextCGL( | |||||
| false, | |||||
| 0, | |||||
| NULL, | |||||
| NULL, | |||||
| #if defined(WITH_GL_PROFILE_CORE) | |||||
| GL_CONTEXT_CORE_PROFILE_BIT, | |||||
| 3, 2, | |||||
| #else | |||||
| 0, // no profile bit | |||||
| 2, 1, | |||||
| #endif | |||||
| GHOST_OPENGL_CGL_CONTEXT_FLAGS, | |||||
| GHOST_OPENGL_CGL_RESET_NOTIFICATION_STRATEGY); | |||||
| if (context->initializeDrawingContext()) | |||||
| return context; | |||||
| else | |||||
| delete context; | |||||
| return NULL; | |||||
| } | |||||
| /** | |||||
| * Dispose of a context. | |||||
| * \param context Pointer to the context to be disposed. | |||||
| * \return Indication of success. | |||||
| */ | |||||
| GHOST_TSuccess | |||||
| GHOST_SystemCocoa:: | |||||
| disposeContext(GHOST_IContext *context) | |||||
| { | |||||
| delete context; | |||||
| return GHOST_kSuccess; | |||||
| } | |||||
| /** | |||||
| * \note : returns coordinates in Cocoa screen coordinates | * \note : returns coordinates in Cocoa screen coordinates | ||||
| */ | */ | ||||
| GHOST_TSuccess GHOST_SystemCocoa::getCursorPosition(GHOST_TInt32& x, GHOST_TInt32& y) const | GHOST_TSuccess GHOST_SystemCocoa::getCursorPosition(GHOST_TInt32& x, GHOST_TInt32& y) const | ||||
| { | { | ||||
| NSPoint mouseLoc = [NSEvent mouseLocation]; | NSPoint mouseLoc = [NSEvent mouseLocation]; | ||||
| // Returns the mouse location in screen coordinates | // Returns the mouse location in screen coordinates | ||||
| x = (GHOST_TInt32)mouseLoc.x; | x = (GHOST_TInt32)mouseLoc.x; | ||||
| ▲ Show 20 Lines • Show All 1,069 Lines • Show Last 20 Lines | |||||