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
path: root/intern
diff options
context:
space:
mode:
authorTom Musgrove <LetterRip@gmail.com>2010-07-22 08:06:13 +0400
committerTom Musgrove <LetterRip@gmail.com>2010-07-22 08:06:13 +0400
commit35a45a7de82d433aaea70d3bc1021bdb6a3366f8 (patch)
treef3d84e068adf9b5f620554650580b002a96b9fb8 /intern
parentd057f700fe95c8c3e6a3df518b2a12e5227c8c37 (diff)
some things missed from head merging
Diffstat (limited to 'intern')
-rw-r--r--intern/ghost/intern/GHOST_DisplayManagerCocoa.h2
-rw-r--r--intern/ghost/intern/GHOST_DisplayManagerCocoa.mm330
-rw-r--r--intern/ghost/intern/GHOST_EventDragnDrop.h2
-rw-r--r--intern/ghost/intern/GHOST_SystemCocoa.h6
-rw-r--r--intern/ghost/intern/GHOST_SystemCocoa.mm1790
-rw-r--r--intern/ghost/intern/GHOST_SystemWin32.h2
-rw-r--r--intern/ghost/intern/GHOST_SystemX11.cpp6
-rw-r--r--intern/ghost/intern/GHOST_WindowCocoa.h2
-rw-r--r--intern/ghost/intern/GHOST_WindowCocoa.mm1378
9 files changed, 1280 insertions, 2238 deletions
diff --git a/intern/ghost/intern/GHOST_DisplayManagerCocoa.h b/intern/ghost/intern/GHOST_DisplayManagerCocoa.h
index 93782bbcf7b..7261ac3b8e5 100644
--- a/intern/ghost/intern/GHOST_DisplayManagerCocoa.h
+++ b/intern/ghost/intern/GHOST_DisplayManagerCocoa.h
@@ -1,5 +1,5 @@
/**
- * $Id: GHOST_DisplayManagerCocoa.h 23603 2009-10-02 07:20:33Z damien78 $
+ * $Id: GHOST_DisplayManagerCocoa.h 26841 2010-02-12 13:34:04Z campbellbarton $
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
diff --git a/intern/ghost/intern/GHOST_DisplayManagerCocoa.mm b/intern/ghost/intern/GHOST_DisplayManagerCocoa.mm
index 991188524df..0b2fee7f156 100644
--- a/intern/ghost/intern/GHOST_DisplayManagerCocoa.mm
+++ b/intern/ghost/intern/GHOST_DisplayManagerCocoa.mm
@@ -1,168 +1,168 @@
-/**
- * $Id: GHOST_DisplayManagerCocoa.mm 23603 2009-10-02 07:20:33Z damien78 $
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
+/**
+ * $Id: GHOST_DisplayManagerCocoa.mm 26841 2010-02-12 13:34:04Z campbellbarton $
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): Maarten Gribnau 09/2001
- Damien Plisson 10/2009
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#include <Cocoa/Cocoa.h>
-
-#include "GHOST_DisplayManagerCocoa.h"
-#include "GHOST_Debug.h"
-
-// We do not support multiple monitors at the moment
-
-
-GHOST_DisplayManagerCocoa::GHOST_DisplayManagerCocoa(void)
-{
-}
-
-
-GHOST_TSuccess GHOST_DisplayManagerCocoa::getNumDisplays(GHOST_TUns8& numDisplays) const
-{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
- numDisplays = (GHOST_TUns8) [[NSScreen screens] count];
-
- [pool drain];
- return GHOST_kSuccess;
-}
-
-
-GHOST_TSuccess GHOST_DisplayManagerCocoa::getNumDisplaySettings(GHOST_TUns8 display, GHOST_TInt32& numSettings) const
-{
- GHOST_ASSERT((display==kMainDisplay), "GHOST_DisplayManagerCocoa::getNumDisplaySettings(): only main display is supported");
-
- numSettings = (GHOST_TInt32)3; //Width, Height, BitsPerPixel
-
- return GHOST_kSuccess;
-}
-
-
-GHOST_TSuccess GHOST_DisplayManagerCocoa::getDisplaySetting(GHOST_TUns8 display, GHOST_TInt32 index, GHOST_DisplaySetting& setting) const
-{
- //Note that only current display setting is available
- NSScreen *askedDisplay;
-
- GHOST_ASSERT((display==kMainDisplay), "GHOST_DisplayManagerCocoa::getDisplaySetting(): only main display is supported");
-
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
- if (display == kMainDisplay) //Screen #0 may not be the main one
- askedDisplay = [NSScreen mainScreen];
- else
- askedDisplay = [[NSScreen screens] objectAtIndex:display];
-
- if(askedDisplay == nil) {
- [pool drain];
- return GHOST_kFailure;
- }
-
- NSRect frame = [askedDisplay visibleFrame];
- setting.xPixels = frame.size.width;
- setting.yPixels = frame.size.height;
-
- setting.bpp = NSBitsPerPixelFromDepth([askedDisplay depth]);
-
- setting.frequency = 0; //No more CRT display...
-
-#ifdef GHOST_DEBUG
- printf("display mode: width=%d, height=%d, bpp=%d, frequency=%d\n", setting.xPixels, setting.yPixels, setting.bpp, setting.frequency);
-#endif // GHOST_DEBUG
-
- [pool drain];
- return GHOST_kSuccess;
-}
-
-
-GHOST_TSuccess GHOST_DisplayManagerCocoa::getCurrentDisplaySetting(GHOST_TUns8 display, GHOST_DisplaySetting& setting) const
-{
- NSScreen *askedDisplay;
-
- GHOST_ASSERT((display==kMainDisplay), "GHOST_DisplayManagerCocoa::getCurrentDisplaySetting(): only main display is supported");
-
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
- if (display == kMainDisplay) //Screen #0 may not be the main one
- askedDisplay = [NSScreen mainScreen];
- else
- askedDisplay = [[NSScreen screens] objectAtIndex:display];
-
- if(askedDisplay == nil) {
- [pool drain];
- return GHOST_kFailure;
- }
-
- NSRect frame = [askedDisplay visibleFrame];
- setting.xPixels = frame.size.width;
- setting.yPixels = frame.size.height;
-
- setting.bpp = NSBitsPerPixelFromDepth([askedDisplay depth]);
-
- setting.frequency = 0; //No more CRT display...
-
-#ifdef GHOST_DEBUG
- printf("current display mode: width=%d, height=%d, bpp=%d, frequency=%d\n", setting.xPixels, setting.yPixels, setting.bpp, setting.frequency);
-#endif // GHOST_DEBUG
-
- [pool drain];
- return GHOST_kSuccess;
-}
-
-
-GHOST_TSuccess GHOST_DisplayManagerCocoa::setCurrentDisplaySetting(GHOST_TUns8 display, const GHOST_DisplaySetting& setting)
-{
- GHOST_ASSERT((display==kMainDisplay), "GHOST_DisplayManagerCocoa::setCurrentDisplaySetting(): only main display is supported");
-
-#ifdef GHOST_DEBUG
- printf("GHOST_DisplayManagerCocoa::setCurrentDisplaySetting(): requested settings:\n");
- printf(" setting.xPixels=%d\n", setting.xPixels);
- printf(" setting.yPixels=%d\n", setting.yPixels);
- printf(" setting.bpp=%d\n", setting.bpp);
- printf(" setting.frequency=%d\n", setting.frequency);
-#endif // GHOST_DEBUG
-
- //Display configuration is no more available in 10.6
-
-/* CFDictionaryRef displayModeValues = ::CGDisplayBestModeForParametersAndRefreshRate(
- m_displayIDs[display],
- (size_t)setting.bpp,
- (size_t)setting.xPixels,
- (size_t)setting.yPixels,
- (CGRefreshRate)setting.frequency,
- NULL);*/
-
-#ifdef GHOST_DEBUG
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Maarten Gribnau 09/2001
+ Damien Plisson 10/2009
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include <Cocoa/Cocoa.h>
+
+#include "GHOST_DisplayManagerCocoa.h"
+#include "GHOST_Debug.h"
+
+// We do not support multiple monitors at the moment
+
+
+GHOST_DisplayManagerCocoa::GHOST_DisplayManagerCocoa(void)
+{
+}
+
+
+GHOST_TSuccess GHOST_DisplayManagerCocoa::getNumDisplays(GHOST_TUns8& numDisplays) const
+{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+ numDisplays = (GHOST_TUns8) [[NSScreen screens] count];
+
+ [pool drain];
+ return GHOST_kSuccess;
+}
+
+
+GHOST_TSuccess GHOST_DisplayManagerCocoa::getNumDisplaySettings(GHOST_TUns8 display, GHOST_TInt32& numSettings) const
+{
+ GHOST_ASSERT((display==kMainDisplay), "GHOST_DisplayManagerCocoa::getNumDisplaySettings(): only main display is supported");
+
+ numSettings = (GHOST_TInt32)3; //Width, Height, BitsPerPixel
+
+ return GHOST_kSuccess;
+}
+
+
+GHOST_TSuccess GHOST_DisplayManagerCocoa::getDisplaySetting(GHOST_TUns8 display, GHOST_TInt32 index, GHOST_DisplaySetting& setting) const
+{
+ //Note that only current display setting is available
+ NSScreen *askedDisplay;
+
+ GHOST_ASSERT((display==kMainDisplay), "GHOST_DisplayManagerCocoa::getDisplaySetting(): only main display is supported");
+
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+ if (display == kMainDisplay) //Screen #0 may not be the main one
+ askedDisplay = [NSScreen mainScreen];
+ else
+ askedDisplay = [[NSScreen screens] objectAtIndex:display];
+
+ if(askedDisplay == nil) {
+ [pool drain];
+ return GHOST_kFailure;
+ }
+
+ NSRect frame = [askedDisplay visibleFrame];
+ setting.xPixels = frame.size.width;
+ setting.yPixels = frame.size.height;
+
+ setting.bpp = NSBitsPerPixelFromDepth([askedDisplay depth]);
+
+ setting.frequency = 0; //No more CRT display...
+
+#ifdef GHOST_DEBUG
+ printf("display mode: width=%d, height=%d, bpp=%d, frequency=%d\n", setting.xPixels, setting.yPixels, setting.bpp, setting.frequency);
+#endif // GHOST_DEBUG
+
+ [pool drain];
+ return GHOST_kSuccess;
+}
+
+
+GHOST_TSuccess GHOST_DisplayManagerCocoa::getCurrentDisplaySetting(GHOST_TUns8 display, GHOST_DisplaySetting& setting) const
+{
+ NSScreen *askedDisplay;
+
+ GHOST_ASSERT((display==kMainDisplay), "GHOST_DisplayManagerCocoa::getCurrentDisplaySetting(): only main display is supported");
+
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+ if (display == kMainDisplay) //Screen #0 may not be the main one
+ askedDisplay = [NSScreen mainScreen];
+ else
+ askedDisplay = [[NSScreen screens] objectAtIndex:display];
+
+ if(askedDisplay == nil) {
+ [pool drain];
+ return GHOST_kFailure;
+ }
+
+ NSRect frame = [askedDisplay visibleFrame];
+ setting.xPixels = frame.size.width;
+ setting.yPixels = frame.size.height;
+
+ setting.bpp = NSBitsPerPixelFromDepth([askedDisplay depth]);
+
+ setting.frequency = 0; //No more CRT display...
+
+#ifdef GHOST_DEBUG
+ printf("current display mode: width=%d, height=%d, bpp=%d, frequency=%d\n", setting.xPixels, setting.yPixels, setting.bpp, setting.frequency);
+#endif // GHOST_DEBUG
+
+ [pool drain];
+ return GHOST_kSuccess;
+}
+
+
+GHOST_TSuccess GHOST_DisplayManagerCocoa::setCurrentDisplaySetting(GHOST_TUns8 display, const GHOST_DisplaySetting& setting)
+{
+ GHOST_ASSERT((display==kMainDisplay), "GHOST_DisplayManagerCocoa::setCurrentDisplaySetting(): only main display is supported");
+
+#ifdef GHOST_DEBUG
+ printf("GHOST_DisplayManagerCocoa::setCurrentDisplaySetting(): requested settings:\n");
+ printf(" setting.xPixels=%d\n", setting.xPixels);
+ printf(" setting.yPixels=%d\n", setting.yPixels);
+ printf(" setting.bpp=%d\n", setting.bpp);
+ printf(" setting.frequency=%d\n", setting.frequency);
+#endif // GHOST_DEBUG
+
+ //Display configuration is no more available in 10.6
+
+/* CFDictionaryRef displayModeValues = ::CGDisplayBestModeForParametersAndRefreshRate(
+ m_displayIDs[display],
+ (size_t)setting.bpp,
+ (size_t)setting.xPixels,
+ (size_t)setting.yPixels,
+ (CGRefreshRate)setting.frequency,
+ NULL);*/
+
+#ifdef GHOST_DEBUG
/* printf("GHOST_DisplayManagerCocoa::setCurrentDisplaySetting(): switching to:\n");
- printf(" setting.xPixels=%d\n", getValue(displayModeValues, kCGDisplayWidth));
- printf(" setting.yPixels=%d\n", getValue(displayModeValues, kCGDisplayHeight));
- printf(" setting.bpp=%d\n", getValue(displayModeValues, kCGDisplayBitsPerPixel));
+ printf(" setting.xPixels=%d\n", getValue(displayModeValues, kCGDisplayWidth));
+ printf(" setting.yPixels=%d\n", getValue(displayModeValues, kCGDisplayHeight));
+ printf(" setting.bpp=%d\n", getValue(displayModeValues, kCGDisplayBitsPerPixel));
printf(" setting.frequency=%d\n", getValue(displayModeValues, kCGDisplayRefreshRate)); */
-#endif // GHOST_DEBUG
-
- //CGDisplayErr err = ::CGDisplaySwitchToMode(m_displayIDs[display], displayModeValues);
-
- return /*err == CGDisplayNoErr ? GHOST_kSuccess :*/ GHOST_kFailure;
-}
+#endif // GHOST_DEBUG
+
+ //CGDisplayErr err = ::CGDisplaySwitchToMode(m_displayIDs[display], displayModeValues);
+
+ return /*err == CGDisplayNoErr ? GHOST_kSuccess :*/ GHOST_kFailure;
+}
diff --git a/intern/ghost/intern/GHOST_EventDragnDrop.h b/intern/ghost/intern/GHOST_EventDragnDrop.h
index ea13a33f889..1fcfddf5349 100644
--- a/intern/ghost/intern/GHOST_EventDragnDrop.h
+++ b/intern/ghost/intern/GHOST_EventDragnDrop.h
@@ -69,7 +69,7 @@ public:
* @param time The time this event was generated.
* @param type The type of this event.
* @param dataType The type of the drop candidate object
- * @param window The window where the event occured
+ * @param window The window where the event occurred
* @param x The x-coordinate of the location the cursor was at at the time of the event.
* @param y The y-coordinate of the location the cursor was at at the time of the event.
* @param data The "content" dropped in the window
diff --git a/intern/ghost/intern/GHOST_SystemCocoa.h b/intern/ghost/intern/GHOST_SystemCocoa.h
index 56b4ceeedf7..6f9c90c7ed7 100644
--- a/intern/ghost/intern/GHOST_SystemCocoa.h
+++ b/intern/ghost/intern/GHOST_SystemCocoa.h
@@ -1,5 +1,5 @@
/**
- * $Id: GHOST_SystemCocoa.h 23737 2009-10-09 12:48:28Z damien78 $
+ * $Id: GHOST_SystemCocoa.h 30526 2010-07-20 10:41:08Z campbellbarton $
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
@@ -155,7 +155,7 @@ public:
* @param draggedObjectType The type object concerned (currently array of file names, string, TIFF image)
* @param mouseX x mouse coordinate (in cocoa base window coordinates)
* @param mouseY y mouse coordinate
- * @param window The window on which the event occured
+ * @param window The window on which the event occurred
* @return Indication whether the event was handled.
*/
GHOST_TSuccess handleDraggingEvent(GHOST_TEventType eventType, GHOST_TDragnDropTypes draggedObjectType,
@@ -236,7 +236,7 @@ public:
/**
* Handles a window event. Called by GHOST_WindowCocoa window delegate
* @param eventType The type of window event
- * @param window The window on which the event occured
+ * @param window The window on which the event occurred
* @return Indication whether the event was handled.
*/
GHOST_TSuccess handleWindowEvent(GHOST_TEventType eventType, GHOST_WindowCocoa* window);
diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm
index a3089a76ece..a763309a09a 100644
--- a/intern/ghost/intern/GHOST_SystemCocoa.mm
+++ b/intern/ghost/intern/GHOST_SystemCocoa.mm
@@ -1,48 +1,20 @@
-/**
- * $Id: GHOST_SystemCocoa.mm 23854 2009-10-15 08:27:31Z damien78 $
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
+/**
+ * $Id: GHOST_SystemCocoa.mm 30526 2010-07-20 10:41:08Z campbellbarton $
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-<<<<<<< .working
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): Maarten Gribnau 05/2001
- * Damien Plisson 09/2009
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#import <Cocoa/Cocoa.h>
-
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/sysctl.h>
-
-#include "GHOST_SystemCocoa.h"
-
-#include "GHOST_DisplayManagerCocoa.h"
-#include "GHOST_EventKey.h"
-#include "GHOST_EventButton.h"
-#include "GHOST_EventCursor.h"
-#include "GHOST_EventWheel.h"
-#include "GHOST_EventNDOF.h"
-=======
*
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
* All rights reserved.
@@ -72,344 +44,9 @@
#include "GHOST_EventCursor.h"
#include "GHOST_EventWheel.h"
#include "GHOST_EventNDOF.h"
->>>>>>> .merge-right.r30358
#include "GHOST_EventTrackpad.h"
#include "GHOST_EventDragnDrop.h"
#include "GHOST_EventString.h"
-<<<<<<< .working
-
-#include "GHOST_TimerManager.h"
-#include "GHOST_TimerTask.h"
-#include "GHOST_WindowManager.h"
-#include "GHOST_WindowCocoa.h"
-#include "GHOST_NDOFManager.h"
-#include "AssertMacros.h"
-
-#pragma mark KeyMap, mouse converters
-
-
-/* Keycodes from Carbon include file */
-/*
- * Summary:
- * Virtual keycodes
- *
- * Discussion:
- * These constants are the virtual keycodes defined originally in
- * Inside Mac Volume V, pg. V-191. They identify physical keys on a
- * keyboard. Those constants with "ANSI" in the name are labeled
- * according to the key position on an ANSI-standard US keyboard.
- * For example, kVK_ANSI_A indicates the virtual keycode for the key
- * with the letter 'A' in the US keyboard layout. Other keyboard
- * layouts may have the 'A' key label on a different physical key;
- * in this case, pressing 'A' will generate a different virtual
- * keycode.
- */
-enum {
- kVK_ANSI_A = 0x00,
- kVK_ANSI_S = 0x01,
- kVK_ANSI_D = 0x02,
- kVK_ANSI_F = 0x03,
- kVK_ANSI_H = 0x04,
- kVK_ANSI_G = 0x05,
- kVK_ANSI_Z = 0x06,
- kVK_ANSI_X = 0x07,
- kVK_ANSI_C = 0x08,
- kVK_ANSI_V = 0x09,
- kVK_ANSI_B = 0x0B,
- kVK_ANSI_Q = 0x0C,
- kVK_ANSI_W = 0x0D,
- kVK_ANSI_E = 0x0E,
- kVK_ANSI_R = 0x0F,
- kVK_ANSI_Y = 0x10,
- kVK_ANSI_T = 0x11,
- kVK_ANSI_1 = 0x12,
- kVK_ANSI_2 = 0x13,
- kVK_ANSI_3 = 0x14,
- kVK_ANSI_4 = 0x15,
- kVK_ANSI_6 = 0x16,
- kVK_ANSI_5 = 0x17,
- kVK_ANSI_Equal = 0x18,
- kVK_ANSI_9 = 0x19,
- kVK_ANSI_7 = 0x1A,
- kVK_ANSI_Minus = 0x1B,
- kVK_ANSI_8 = 0x1C,
- kVK_ANSI_0 = 0x1D,
- kVK_ANSI_RightBracket = 0x1E,
- kVK_ANSI_O = 0x1F,
- kVK_ANSI_U = 0x20,
- kVK_ANSI_LeftBracket = 0x21,
- kVK_ANSI_I = 0x22,
- kVK_ANSI_P = 0x23,
- kVK_ANSI_L = 0x25,
- kVK_ANSI_J = 0x26,
- kVK_ANSI_Quote = 0x27,
- kVK_ANSI_K = 0x28,
- kVK_ANSI_Semicolon = 0x29,
- kVK_ANSI_Backslash = 0x2A,
- kVK_ANSI_Comma = 0x2B,
- kVK_ANSI_Slash = 0x2C,
- kVK_ANSI_N = 0x2D,
- kVK_ANSI_M = 0x2E,
- kVK_ANSI_Period = 0x2F,
- kVK_ANSI_Grave = 0x32,
- kVK_ANSI_KeypadDecimal = 0x41,
- kVK_ANSI_KeypadMultiply = 0x43,
- kVK_ANSI_KeypadPlus = 0x45,
- kVK_ANSI_KeypadClear = 0x47,
- kVK_ANSI_KeypadDivide = 0x4B,
- kVK_ANSI_KeypadEnter = 0x4C,
- kVK_ANSI_KeypadMinus = 0x4E,
- kVK_ANSI_KeypadEquals = 0x51,
- kVK_ANSI_Keypad0 = 0x52,
- kVK_ANSI_Keypad1 = 0x53,
- kVK_ANSI_Keypad2 = 0x54,
- kVK_ANSI_Keypad3 = 0x55,
- kVK_ANSI_Keypad4 = 0x56,
- kVK_ANSI_Keypad5 = 0x57,
- kVK_ANSI_Keypad6 = 0x58,
- kVK_ANSI_Keypad7 = 0x59,
- kVK_ANSI_Keypad8 = 0x5B,
- kVK_ANSI_Keypad9 = 0x5C
-};
-
-/* keycodes for keys that are independent of keyboard layout*/
-enum {
- kVK_Return = 0x24,
- kVK_Tab = 0x30,
- kVK_Space = 0x31,
- kVK_Delete = 0x33,
- kVK_Escape = 0x35,
- kVK_Command = 0x37,
- kVK_Shift = 0x38,
- kVK_CapsLock = 0x39,
- kVK_Option = 0x3A,
- kVK_Control = 0x3B,
- kVK_RightShift = 0x3C,
- kVK_RightOption = 0x3D,
- kVK_RightControl = 0x3E,
- kVK_Function = 0x3F,
- kVK_F17 = 0x40,
- kVK_VolumeUp = 0x48,
- kVK_VolumeDown = 0x49,
- kVK_Mute = 0x4A,
- kVK_F18 = 0x4F,
- kVK_F19 = 0x50,
- kVK_F20 = 0x5A,
- kVK_F5 = 0x60,
- kVK_F6 = 0x61,
- kVK_F7 = 0x62,
- kVK_F3 = 0x63,
- kVK_F8 = 0x64,
- kVK_F9 = 0x65,
- kVK_F11 = 0x67,
- kVK_F13 = 0x69,
- kVK_F16 = 0x6A,
- kVK_F14 = 0x6B,
- kVK_F10 = 0x6D,
- kVK_F12 = 0x6F,
- kVK_F15 = 0x71,
- kVK_Help = 0x72,
- kVK_Home = 0x73,
- kVK_PageUp = 0x74,
- kVK_ForwardDelete = 0x75,
- kVK_F4 = 0x76,
- kVK_End = 0x77,
- kVK_F2 = 0x78,
- kVK_PageDown = 0x79,
- kVK_F1 = 0x7A,
- kVK_LeftArrow = 0x7B,
- kVK_RightArrow = 0x7C,
- kVK_DownArrow = 0x7D,
- kVK_UpArrow = 0x7E
-};
-
-/* ISO keyboards only*/
-enum {
- kVK_ISO_Section = 0x0A
-};
-
-/* JIS keyboards only*/
-enum {
- kVK_JIS_Yen = 0x5D,
- kVK_JIS_Underscore = 0x5E,
- kVK_JIS_KeypadComma = 0x5F,
- kVK_JIS_Eisu = 0x66,
- kVK_JIS_Kana = 0x68
-};
-
-
-static GHOST_TButtonMask convertButton(int button)
-{
- switch (button) {
- case 0:
- return GHOST_kButtonMaskLeft;
- case 1:
- return GHOST_kButtonMaskRight;
- case 2:
- return GHOST_kButtonMaskMiddle;
- case 3:
- return GHOST_kButtonMaskButton4;
- case 4:
- return GHOST_kButtonMaskButton5;
- default:
- return GHOST_kButtonMaskLeft;
- }
-}
-
-/**
- * Converts Mac rawkey codes (same for Cocoa & Carbon)
- * into GHOST key codes
- * @param rawCode The raw physical key code
- * @param recvChar the character ignoring modifiers (except for shift)
- * @return Ghost key code
- */
-static GHOST_TKey convertKey(int rawCode, unichar recvChar)
-{
-
- //printf("\nrecvchar %c 0x%x",recvChar,recvChar);
- switch (rawCode) {
- /*Physical keycodes not used due to map changes in int'l keyboards
- case kVK_ANSI_A: return GHOST_kKeyA;
- case kVK_ANSI_B: return GHOST_kKeyB;
- case kVK_ANSI_C: return GHOST_kKeyC;
- case kVK_ANSI_D: return GHOST_kKeyD;
- case kVK_ANSI_E: return GHOST_kKeyE;
- case kVK_ANSI_F: return GHOST_kKeyF;
- case kVK_ANSI_G: return GHOST_kKeyG;
- case kVK_ANSI_H: return GHOST_kKeyH;
- case kVK_ANSI_I: return GHOST_kKeyI;
- case kVK_ANSI_J: return GHOST_kKeyJ;
- case kVK_ANSI_K: return GHOST_kKeyK;
- case kVK_ANSI_L: return GHOST_kKeyL;
- case kVK_ANSI_M: return GHOST_kKeyM;
- case kVK_ANSI_N: return GHOST_kKeyN;
- case kVK_ANSI_O: return GHOST_kKeyO;
- case kVK_ANSI_P: return GHOST_kKeyP;
- case kVK_ANSI_Q: return GHOST_kKeyQ;
- case kVK_ANSI_R: return GHOST_kKeyR;
- case kVK_ANSI_S: return GHOST_kKeyS;
- case kVK_ANSI_T: return GHOST_kKeyT;
- case kVK_ANSI_U: return GHOST_kKeyU;
- case kVK_ANSI_V: return GHOST_kKeyV;
- case kVK_ANSI_W: return GHOST_kKeyW;
- case kVK_ANSI_X: return GHOST_kKeyX;
- case kVK_ANSI_Y: return GHOST_kKeyY;
- case kVK_ANSI_Z: return GHOST_kKeyZ;*/
-
- /* Numbers keys mapped to handle some int'l keyboard (e.g. French)*/
- case kVK_ISO_Section: return GHOST_kKeyUnknown;
- case kVK_ANSI_1: return GHOST_kKey1;
- case kVK_ANSI_2: return GHOST_kKey2;
- case kVK_ANSI_3: return GHOST_kKey3;
- case kVK_ANSI_4: return GHOST_kKey4;
- case kVK_ANSI_5: return GHOST_kKey5;
- case kVK_ANSI_6: return GHOST_kKey6;
- case kVK_ANSI_7: return GHOST_kKey7;
- case kVK_ANSI_8: return GHOST_kKey8;
- case kVK_ANSI_9: return GHOST_kKey9;
- case kVK_ANSI_0: return GHOST_kKey0;
-
- case kVK_ANSI_Keypad0: return GHOST_kKeyNumpad0;
- case kVK_ANSI_Keypad1: return GHOST_kKeyNumpad1;
- case kVK_ANSI_Keypad2: return GHOST_kKeyNumpad2;
- case kVK_ANSI_Keypad3: return GHOST_kKeyNumpad3;
- case kVK_ANSI_Keypad4: return GHOST_kKeyNumpad4;
- case kVK_ANSI_Keypad5: return GHOST_kKeyNumpad5;
- case kVK_ANSI_Keypad6: return GHOST_kKeyNumpad6;
- case kVK_ANSI_Keypad7: return GHOST_kKeyNumpad7;
- case kVK_ANSI_Keypad8: return GHOST_kKeyNumpad8;
- case kVK_ANSI_Keypad9: return GHOST_kKeyNumpad9;
- case kVK_ANSI_KeypadDecimal: return GHOST_kKeyNumpadPeriod;
- case kVK_ANSI_KeypadEnter: return GHOST_kKeyNumpadEnter;
- case kVK_ANSI_KeypadPlus: return GHOST_kKeyNumpadPlus;
- case kVK_ANSI_KeypadMinus: return GHOST_kKeyNumpadMinus;
- case kVK_ANSI_KeypadMultiply: return GHOST_kKeyNumpadAsterisk;
- case kVK_ANSI_KeypadDivide: return GHOST_kKeyNumpadSlash;
- case kVK_ANSI_KeypadClear: return GHOST_kKeyUnknown;
-
- case kVK_F1: return GHOST_kKeyF1;
- case kVK_F2: return GHOST_kKeyF2;
- case kVK_F3: return GHOST_kKeyF3;
- case kVK_F4: return GHOST_kKeyF4;
- case kVK_F5: return GHOST_kKeyF5;
- case kVK_F6: return GHOST_kKeyF6;
- case kVK_F7: return GHOST_kKeyF7;
- case kVK_F8: return GHOST_kKeyF8;
- case kVK_F9: return GHOST_kKeyF9;
- case kVK_F10: return GHOST_kKeyF10;
- case kVK_F11: return GHOST_kKeyF11;
- case kVK_F12: return GHOST_kKeyF12;
- case kVK_F13: return GHOST_kKeyF13;
- case kVK_F14: return GHOST_kKeyF14;
- case kVK_F15: return GHOST_kKeyF15;
- case kVK_F16: return GHOST_kKeyF16;
- case kVK_F17: return GHOST_kKeyF17;
- case kVK_F18: return GHOST_kKeyF18;
- case kVK_F19: return GHOST_kKeyF19;
- case kVK_F20: return GHOST_kKeyF20;
-
- case kVK_UpArrow: return GHOST_kKeyUpArrow;
- case kVK_DownArrow: return GHOST_kKeyDownArrow;
- case kVK_LeftArrow: return GHOST_kKeyLeftArrow;
- case kVK_RightArrow: return GHOST_kKeyRightArrow;
-
- case kVK_Return: return GHOST_kKeyEnter;
- case kVK_Delete: return GHOST_kKeyBackSpace;
- case kVK_ForwardDelete: return GHOST_kKeyDelete;
- case kVK_Escape: return GHOST_kKeyEsc;
- case kVK_Tab: return GHOST_kKeyTab;
- case kVK_Space: return GHOST_kKeySpace;
-
- case kVK_Home: return GHOST_kKeyHome;
- case kVK_End: return GHOST_kKeyEnd;
- case kVK_PageUp: return GHOST_kKeyUpPage;
- case kVK_PageDown: return GHOST_kKeyDownPage;
-
- /*case kVK_ANSI_Minus: return GHOST_kKeyMinus;
- case kVK_ANSI_Equal: return GHOST_kKeyEqual;
- case kVK_ANSI_Comma: return GHOST_kKeyComma;
- case kVK_ANSI_Period: return GHOST_kKeyPeriod;
- case kVK_ANSI_Slash: return GHOST_kKeySlash;
- case kVK_ANSI_Semicolon: return GHOST_kKeySemicolon;
- case kVK_ANSI_Quote: return GHOST_kKeyQuote;
- case kVK_ANSI_Backslash: return GHOST_kKeyBackslash;
- case kVK_ANSI_LeftBracket: return GHOST_kKeyLeftBracket;
- case kVK_ANSI_RightBracket: return GHOST_kKeyRightBracket;
- case kVK_ANSI_Grave: return GHOST_kKeyAccentGrave;*/
-
- case kVK_VolumeUp:
- case kVK_VolumeDown:
- case kVK_Mute:
- return GHOST_kKeyUnknown;
-
- default:
- /*Then detect on character value for "remappable" keys in int'l keyboards*/
- if ((recvChar >= 'A') && (recvChar <= 'Z')) {
- return (GHOST_TKey) (recvChar - 'A' + GHOST_kKeyA);
- } else if ((recvChar >= 'a') && (recvChar <= 'z')) {
- return (GHOST_TKey) (recvChar - 'a' + GHOST_kKeyA);
- } else
- switch (recvChar) {
- case '-': return GHOST_kKeyMinus;
- case '=': return GHOST_kKeyEqual;
- case ',': return GHOST_kKeyComma;
- case '.': return GHOST_kKeyPeriod;
- case '/': return GHOST_kKeySlash;
- case ';': return GHOST_kKeySemicolon;
- case '\'': return GHOST_kKeyQuote;
- case '\\': return GHOST_kKeyBackslash;
- case '[': return GHOST_kKeyLeftBracket;
- case ']': return GHOST_kKeyRightBracket;
- case '`': return GHOST_kKeyAccentGrave;
- default:
- return GHOST_kKeyUnknown;
- }
- }
- return GHOST_kKeyUnknown;
-}
-
-
-=======
#include "GHOST_TimerManager.h"
#include "GHOST_TimerTask.h"
@@ -783,7 +420,6 @@ static GHOST_TKey convertKey(int rawCode, unichar recvChar, UInt16 keyAction)
}
->>>>>>> .merge-right.r30358
#pragma mark defines for 10.6 api not documented in 10.5
#ifndef MAC_OS_X_VERSION_10_6
enum {
@@ -810,21 +446,21 @@ enum {
#pragma mark Utility functions
-#define FIRSTFILEBUFLG 512
-static bool g_hasFirstFile = false;
-static char g_firstFileBuf[512];
-
-//TODO:Need to investigate this. Function called too early in creator.c to have g_hasFirstFile == true
-extern "C" int GHOST_HACK_getFirstFile(char buf[FIRSTFILEBUFLG]) {
- if (g_hasFirstFile) {
- strncpy(buf, g_firstFileBuf, FIRSTFILEBUFLG - 1);
- buf[FIRSTFILEBUFLG - 1] = '\0';
- return 1;
- } else {
- return 0;
- }
-}
-
+#define FIRSTFILEBUFLG 512
+static bool g_hasFirstFile = false;
+static char g_firstFileBuf[512];
+
+//TODO:Need to investigate this. Function called too early in creator.c to have g_hasFirstFile == true
+extern "C" int GHOST_HACK_getFirstFile(char buf[FIRSTFILEBUFLG]) {
+ if (g_hasFirstFile) {
+ strncpy(buf, g_firstFileBuf, FIRSTFILEBUFLG - 1);
+ buf[FIRSTFILEBUFLG - 1] = '\0';
+ return 1;
+ } else {
+ return 0;
+ }
+}
+
#if defined(WITH_QUICKTIME) && !defined(USE_QTKIT)
//Need to place this quicktime function in an ObjC file
//It is used to avoid memory leak when raising the quicktime "compression settings" standard dialog
@@ -832,7 +468,7 @@ extern "C" {
struct bContext;
struct wmOperator;
extern int fromcocoa_request_qtcodec_settings(bContext *C, wmOperator *op);
-
+
int cocoa_request_qtcodec_settings(bContext *C, wmOperator *op)
{
@@ -848,89 +484,89 @@ int cocoa_request_qtcodec_settings(bContext *C, wmOperator *op)
#endif
-#pragma mark Cocoa objects
-
-/**
- * CocoaAppDelegate
- * ObjC object to capture applicationShouldTerminate, and send quit event
- **/
-@interface CocoaAppDelegate : NSObject {
- GHOST_SystemCocoa *systemCocoa;
-}
+#pragma mark Cocoa objects
+
+/**
+ * CocoaAppDelegate
+ * ObjC object to capture applicationShouldTerminate, and send quit event
+ **/
+@interface CocoaAppDelegate : NSObject {
+ GHOST_SystemCocoa *systemCocoa;
+}
- (void)setSystemCocoa:(GHOST_SystemCocoa *)sysCocoa;
- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename;
-- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender;
-- (void)applicationWillTerminate:(NSNotification *)aNotification;
+- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender;
+- (void)applicationWillTerminate:(NSNotification *)aNotification;
- (void)applicationWillBecomeActive:(NSNotification *)aNotification;
-@end
-
-@implementation CocoaAppDelegate : NSObject
--(void)setSystemCocoa:(GHOST_SystemCocoa *)sysCocoa
-{
- systemCocoa = sysCocoa;
-}
-
+@end
+
+@implementation CocoaAppDelegate : NSObject
+-(void)setSystemCocoa:(GHOST_SystemCocoa *)sysCocoa
+{
+ systemCocoa = sysCocoa;
+}
+
- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename
{
return systemCocoa->handleOpenDocumentRequest(filename);
}
-- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
-{
- //TODO: implement graceful termination through Cocoa mechanism to avoid session log off to be cancelled
- //Note that Cmd+Q is already handled by keyhandler
- if (systemCocoa->handleQuitRequest() == GHOST_kExitNow)
- return NSTerminateCancel;//NSTerminateNow;
- else
- return NSTerminateCancel;
-}
-
-// To avoid cancelling a log off process, we must use Cocoa termination process
-// And this function is the only chance to perform clean up
-// So WM_exit needs to be called directly, as the event loop will never run before termination
-- (void)applicationWillTerminate:(NSNotification *)aNotification
-{
- /*G.afbreek = 0; //Let Cocoa perform the termination at the end
- WM_exit(C);*/
-}
+- (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender
+{
+ //TODO: implement graceful termination through Cocoa mechanism to avoid session log off to be cancelled
+ //Note that Cmd+Q is already handled by keyhandler
+ if (systemCocoa->handleQuitRequest() == GHOST_kExitNow)
+ return NSTerminateCancel;//NSTerminateNow;
+ else
+ return NSTerminateCancel;
+}
+
+// To avoid cancelling a log off process, we must use Cocoa termination process
+// And this function is the only chance to perform clean up
+// So WM_exit needs to be called directly, as the event loop will never run before termination
+- (void)applicationWillTerminate:(NSNotification *)aNotification
+{
+ /*G.afbreek = 0; //Let Cocoa perform the termination at the end
+ WM_exit(C);*/
+}
- (void)applicationWillBecomeActive:(NSNotification *)aNotification
{
systemCocoa->handleApplicationBecomeActiveEvent();
}
-@end
-
-
-
-#pragma mark initialization/finalization
-
-
-GHOST_SystemCocoa::GHOST_SystemCocoa()
-{
+@end
+
+
+
+#pragma mark initialization/finalization
+
+
+GHOST_SystemCocoa::GHOST_SystemCocoa()
+{
int mib[2];
struct timeval boottime;
size_t len;
char *rstring = NULL;
- m_modifierMask =0;
- m_pressedMouseButtons =0;
+ m_modifierMask =0;
+ m_pressedMouseButtons =0;
m_isGestureInProgress = false;
m_cursorDelta_x=0;
m_cursorDelta_y=0;
m_outsideLoopEventProcessed = false;
m_needDelayedApplicationBecomeActiveEventProcessing = false;
- m_displayManager = new GHOST_DisplayManagerCocoa ();
- GHOST_ASSERT(m_displayManager, "GHOST_SystemCocoa::GHOST_SystemCocoa(): m_displayManager==0\n");
- m_displayManager->initialize();
-
- //NSEvent timeStamp is given in system uptime, state start date is boot time
- mib[0] = CTL_KERN;
- mib[1] = KERN_BOOTTIME;
- len = sizeof(struct timeval);
-
- sysctl(mib, 2, &boottime, &len, NULL, 0);
- m_start_time = ((boottime.tv_sec*1000)+(boottime.tv_usec/1000));
-
+ m_displayManager = new GHOST_DisplayManagerCocoa ();
+ GHOST_ASSERT(m_displayManager, "GHOST_SystemCocoa::GHOST_SystemCocoa(): m_displayManager==0\n");
+ m_displayManager->initialize();
+
+ //NSEvent timeStamp is given in system uptime, state start date is boot time
+ mib[0] = CTL_KERN;
+ mib[1] = KERN_BOOTTIME;
+ len = sizeof(struct timeval);
+
+ sysctl(mib, 2, &boottime, &len, NULL, 0);
+ m_start_time = ((boottime.tv_sec*1000)+(boottime.tv_usec/1000));
+
//Detect multitouch trackpad
mib[0] = CTL_HW;
mib[1] = HW_MODEL;
@@ -947,214 +583,169 @@ GHOST_SystemCocoa::GHOST_SystemCocoa()
free( rstring );
rstring = NULL;
- m_ignoreWindowSizedMessages = false;
-}
-
-GHOST_SystemCocoa::~GHOST_SystemCocoa()
-{
-}
-
-
-GHOST_TSuccess GHOST_SystemCocoa::init()
-{
-
- GHOST_TSuccess success = GHOST_System::init();
- if (success) {
- //ProcessSerialNumber psn;
-
- //Carbon stuff to move window & menu to foreground
- /*if (!GetCurrentProcess(&psn)) {
- TransformProcessType(&psn, kProcessTransformToForegroundApplication);
- SetFrontProcess(&psn);
- }*/
-
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- if (NSApp == nil) {
- [NSApplication sharedApplication];
-
- if ([NSApp mainMenu] == nil) {
- NSMenu *mainMenubar = [[NSMenu alloc] init];
- NSMenuItem *menuItem;
- NSMenu *windowMenu;
- NSMenu *appMenu;
-
- //Create the application menu
- appMenu = [[NSMenu alloc] initWithTitle:@"Blender"];
-
- [appMenu addItemWithTitle:@"About Blender" action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""];
- [appMenu addItem:[NSMenuItem separatorItem]];
-
- menuItem = [appMenu addItemWithTitle:@"Hide Blender" action:@selector(hide:) keyEquivalent:@"h"];
- [menuItem setKeyEquivalentModifierMask:NSCommandKeyMask];
-
- menuItem = [appMenu addItemWithTitle:@"Hide others" action:@selector(hideOtherApplications:) keyEquivalent:@"h"];
- [menuItem setKeyEquivalentModifierMask:(NSAlternateKeyMask | NSCommandKeyMask)];
-
- [appMenu addItemWithTitle:@"Show All" action:@selector(unhideAllApplications:) keyEquivalent:@""];
-
- menuItem = [appMenu addItemWithTitle:@"Quit Blender" action:@selector(terminate:) keyEquivalent:@"q"];
- [menuItem setKeyEquivalentModifierMask:NSCommandKeyMask];
-
- menuItem = [[NSMenuItem alloc] init];
- [menuItem setSubmenu:appMenu];
-
- [mainMenubar addItem:menuItem];
- [menuItem release];
- [NSApp performSelector:@selector(setAppleMenu:) withObject:appMenu]; //Needed for 10.5
- [appMenu release];
-
- //Create the window menu
- windowMenu = [[NSMenu alloc] initWithTitle:@"Window"];
-
- menuItem = [windowMenu addItemWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@"m"];
- [menuItem setKeyEquivalentModifierMask:NSCommandKeyMask];
-
- [windowMenu addItemWithTitle:@"Zoom" action:@selector(performZoom:) keyEquivalent:@""];
-
+ m_ignoreWindowSizedMessages = false;
+}
+
+GHOST_SystemCocoa::~GHOST_SystemCocoa()
+{
+}
+
+
+GHOST_TSuccess GHOST_SystemCocoa::init()
+{
+
+ GHOST_TSuccess success = GHOST_System::init();
+ if (success) {
+ //ProcessSerialNumber psn;
+
+ //Carbon stuff to move window & menu to foreground
+ /*if (!GetCurrentProcess(&psn)) {
+ TransformProcessType(&psn, kProcessTransformToForegroundApplication);
+ SetFrontProcess(&psn);
+ }*/
+
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ if (NSApp == nil) {
+ [NSApplication sharedApplication];
+
+ if ([NSApp mainMenu] == nil) {
+ NSMenu *mainMenubar = [[NSMenu alloc] init];
+ NSMenuItem *menuItem;
+ NSMenu *windowMenu;
+ NSMenu *appMenu;
+
+ //Create the application menu
+ appMenu = [[NSMenu alloc] initWithTitle:@"Blender"];
+
+ [appMenu addItemWithTitle:@"About Blender" action:@selector(orderFrontStandardAboutPanel:) keyEquivalent:@""];
+ [appMenu addItem:[NSMenuItem separatorItem]];
+
+ menuItem = [appMenu addItemWithTitle:@"Hide Blender" action:@selector(hide:) keyEquivalent:@"h"];
+ [menuItem setKeyEquivalentModifierMask:NSCommandKeyMask];
+
+ menuItem = [appMenu addItemWithTitle:@"Hide others" action:@selector(hideOtherApplications:) keyEquivalent:@"h"];
+ [menuItem setKeyEquivalentModifierMask:(NSAlternateKeyMask | NSCommandKeyMask)];
+
+ [appMenu addItemWithTitle:@"Show All" action:@selector(unhideAllApplications:) keyEquivalent:@""];
+
+ menuItem = [appMenu addItemWithTitle:@"Quit Blender" action:@selector(terminate:) keyEquivalent:@"q"];
+ [menuItem setKeyEquivalentModifierMask:NSCommandKeyMask];
+
+ menuItem = [[NSMenuItem alloc] init];
+ [menuItem setSubmenu:appMenu];
+
+ [mainMenubar addItem:menuItem];
+ [menuItem release];
+ [NSApp performSelector:@selector(setAppleMenu:) withObject:appMenu]; //Needed for 10.5
+ [appMenu release];
+
+ //Create the window menu
+ windowMenu = [[NSMenu alloc] initWithTitle:@"Window"];
+
+ menuItem = [windowMenu addItemWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@"m"];
+ [menuItem setKeyEquivalentModifierMask:NSCommandKeyMask];
+
+ [windowMenu addItemWithTitle:@"Zoom" action:@selector(performZoom:) keyEquivalent:@""];
+
menuItem = [windowMenu addItemWithTitle:@"Close" action:@selector(performClose:) keyEquivalent:@"w"];
[menuItem setKeyEquivalentModifierMask:NSCommandKeyMask];
- menuItem = [[NSMenuItem alloc] init];
- [menuItem setSubmenu:windowMenu];
-
- [mainMenubar addItem:menuItem];
- [menuItem release];
-
- [NSApp setMainMenu:mainMenubar];
- [NSApp setWindowsMenu:windowMenu];
- [windowMenu release];
- }
- }
- if ([NSApp delegate] == nil) {
- CocoaAppDelegate *appDelegate = [[CocoaAppDelegate alloc] init];
- [appDelegate setSystemCocoa:this];
- [NSApp setDelegate:appDelegate];
- }
+ menuItem = [[NSMenuItem alloc] init];
+ [menuItem setSubmenu:windowMenu];
+
+ [mainMenubar addItem:menuItem];
+ [menuItem release];
+
+ [NSApp setMainMenu:mainMenubar];
+ [NSApp setWindowsMenu:windowMenu];
+ [windowMenu release];
+ }
+ }
+ if ([NSApp delegate] == nil) {
+ CocoaAppDelegate *appDelegate = [[CocoaAppDelegate alloc] init];
+ [appDelegate setSystemCocoa:this];
+ [NSApp setDelegate:appDelegate];
+ }
[NSApp finishLaunching];
- [pool drain];
- }
- return success;
-}
-
-
-#pragma mark window management
-
-GHOST_TUns64 GHOST_SystemCocoa::getMilliSeconds() const
-{
- //Cocoa equivalent exists in 10.6 ([[NSProcessInfo processInfo] systemUptime])
+ [pool drain];
+ }
+ return success;
+}
+
+
+#pragma mark window management
+
+GHOST_TUns64 GHOST_SystemCocoa::getMilliSeconds() const
+{
+ //Cocoa equivalent exists in 10.6 ([[NSProcessInfo processInfo] systemUptime])
struct timeval currentTime;
-
+
gettimeofday(&currentTime, NULL);
-
+
//Return timestamp of system uptime
return ((currentTime.tv_sec*1000)+(currentTime.tv_usec/1000)-m_start_time);
-}
-
-
-GHOST_TUns8 GHOST_SystemCocoa::getNumDisplays() const
-{
- //Note that OS X supports monitor hot plug
- // We do not support multiple monitors at the moment
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
- GHOST_TUns8 count = [[NSScreen screens] count];
-
- [pool drain];
- return count;
-}
-
-
-void GHOST_SystemCocoa::getMainDisplayDimensions(GHOST_TUns32& width, GHOST_TUns32& height) const
-{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- //Get visible frame, that is frame excluding dock and top menu bar
- NSRect frame = [[NSScreen mainScreen] visibleFrame];
-
- //Returns max window contents (excluding title bar...)
- NSRect contentRect = [NSWindow contentRectForFrameRect:frame
- styleMask:(NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask)];
-
- width = contentRect.size.width;
- height = contentRect.size.height;
-
- [pool drain];
-}
-
-
-GHOST_IWindow* GHOST_SystemCocoa::createWindow(
- const STR_String& title,
- GHOST_TInt32 left,
- GHOST_TInt32 top,
- GHOST_TUns32 width,
- GHOST_TUns32 height,
- GHOST_TWindowState state,
- GHOST_TDrawingContextType type,
- bool stereoVisual,
+}
+
+
+GHOST_TUns8 GHOST_SystemCocoa::getNumDisplays() const
+{
+ //Note that OS X supports monitor hot plug
+ // We do not support multiple monitors at the moment
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+ GHOST_TUns8 count = [[NSScreen screens] count];
+
+ [pool drain];
+ return count;
+}
+
+
+void GHOST_SystemCocoa::getMainDisplayDimensions(GHOST_TUns32& width, GHOST_TUns32& height) const
+{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ //Get visible frame, that is frame excluding dock and top menu bar
+ NSRect frame = [[NSScreen mainScreen] visibleFrame];
+
+ //Returns max window contents (excluding title bar...)
+ NSRect contentRect = [NSWindow contentRectForFrameRect:frame
+ styleMask:(NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask)];
+
+ width = contentRect.size.width;
+ height = contentRect.size.height;
+
+ [pool drain];
+}
+
+
+GHOST_IWindow* GHOST_SystemCocoa::createWindow(
+ const STR_String& title,
+ GHOST_TInt32 left,
+ GHOST_TInt32 top,
+ GHOST_TUns32 width,
+ GHOST_TUns32 height,
+ GHOST_TWindowState state,
+ GHOST_TDrawingContextType type,
+ bool stereoVisual,
const GHOST_TUns16 numOfAASamples,
- const GHOST_TEmbedderWindowID parentWindow
-)
-{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- GHOST_IWindow* window = 0;
-
- //Get the available rect for including window contents
- NSRect frame = [[NSScreen mainScreen] visibleFrame];
- NSRect contentRect = [NSWindow contentRectForFrameRect:frame
- styleMask:(NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask)];
-
- //Ensures window top left is inside this available rect
- left = left > contentRect.origin.x ? left : contentRect.origin.x;
- top = top > contentRect.origin.y ? top : contentRect.origin.y;
-
+ const GHOST_TEmbedderWindowID parentWindow
+)
+{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ GHOST_IWindow* window = 0;
+
+ //Get the available rect for including window contents
+ NSRect frame = [[NSScreen mainScreen] visibleFrame];
+ NSRect contentRect = [NSWindow contentRectForFrameRect:frame
+ styleMask:(NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask)];
+
+ //Ensures window top left is inside this available rect
+ left = left > contentRect.origin.x ? left : contentRect.origin.x;
+ top = top > contentRect.origin.y ? top : contentRect.origin.y;
+
window = new GHOST_WindowCocoa (this, title, left, top, width, height, state, type, stereoVisual, numOfAASamples);
-<<<<<<< .working
-
- if (window) {
- if (window->getValid()) {
- // Store the pointer to the window
- GHOST_ASSERT(m_windowManager, "m_windowManager not initialized");
- m_windowManager->addWindow(window);
- m_windowManager->setActiveWindow(window);
- //Need to tell window manager the new window is the active one (Cocoa does not send the event activate upon window creation)
- pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowActivate, window));
- pushEvent(new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowSize, window));
-
- }
- else {
- GHOST_PRINT("GHOST_SystemCocoa::createWindow(): window invalid\n");
- delete window;
- window = 0;
- }
- }
- else {
- GHOST_PRINT("GHOST_SystemCocoa::createWindow(): could not create window\n");
- }
- [pool drain];
- return window;
-}
-
-GHOST_TSuccess GHOST_SystemCocoa::beginFullScreen(const GHOST_DisplaySetting& setting, GHOST_IWindow** window, const bool stereoVisual)
-{
- GHOST_IWindow* currentWindow = m_windowManager->getActiveWindow();
-
- *window = currentWindow;
-
- return currentWindow->setState(GHOST_kWindowStateFullScreen);
-}
-
-GHOST_TSuccess GHOST_SystemCocoa::endFullScreen(void)
-{
- GHOST_IWindow* currentWindow = m_windowManager->getActiveWindow();
-
- return currentWindow->setState(GHOST_kWindowStateNormal);
-}
-
-
-
-=======
if (window) {
if (window->getValid()) {
@@ -1200,28 +791,22 @@ GHOST_TSuccess GHOST_SystemCocoa::endFullScreen(void)
->>>>>>> .merge-right.r30358
/**
* @note : returns coordinates in Cocoa screen coordinates
*/
-GHOST_TSuccess GHOST_SystemCocoa::getCursorPosition(GHOST_TInt32& x, GHOST_TInt32& y) const
-{
- NSPoint mouseLoc = [NSEvent mouseLocation];
-
- // Returns the mouse location in screen coordinates
- x = (GHOST_TInt32)mouseLoc.x;
- y = (GHOST_TInt32)mouseLoc.y;
- return GHOST_kSuccess;
-}
-
+GHOST_TSuccess GHOST_SystemCocoa::getCursorPosition(GHOST_TInt32& x, GHOST_TInt32& y) const
+{
+ NSPoint mouseLoc = [NSEvent mouseLocation];
+
+ // Returns the mouse location in screen coordinates
+ x = (GHOST_TInt32)mouseLoc.x;
+ y = (GHOST_TInt32)mouseLoc.y;
+ return GHOST_kSuccess;
+}
+
/**
* @note : expect Cocoa screen coordinates
*/
-<<<<<<< .working
-GHOST_TSuccess GHOST_SystemCocoa::setCursorPosition(GHOST_TInt32 x, GHOST_TInt32 y) const
-{
- float xf=(float)x, yf=(float)y;
-=======
GHOST_TSuccess GHOST_SystemCocoa::setCursorPosition(GHOST_TInt32 x, GHOST_TInt32 y)
{
GHOST_TInt32 wx,wy;
@@ -1245,31 +830,22 @@ GHOST_TSuccess GHOST_SystemCocoa::setCursorPosition(GHOST_TInt32 x, GHOST_TInt32
GHOST_TSuccess GHOST_SystemCocoa::setMouseCursorPosition(GHOST_TInt32 x, GHOST_TInt32 y)
{
float xf=(float)x, yf=(float)y;
->>>>>>> .merge-right.r30358
GHOST_WindowCocoa* window = (GHOST_WindowCocoa*)m_windowManager->getActiveWindow();
if (!window) return GHOST_kFailure;
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSScreen *windowScreen = window->getScreen();
NSRect screenRect = [windowScreen frame];
-
+
//Set position relative to current screen
xf -= screenRect.origin.x;
yf -= screenRect.origin.y;
- //Quartz Display Services uses the old coordinates (top left origin)
+ //Quartz Display Services uses the old coordinates (top left origin)
yf = screenRect.size.height -yf;
-
+
CGDisplayMoveCursorToPoint((CGDirectDisplayID)[[[windowScreen deviceDescription] objectForKey:@"NSScreenNumber"] unsignedIntValue], CGPointMake(xf, yf));
-<<<<<<< .working
- return GHOST_kSuccess;
-}
-
-
-GHOST_TSuccess GHOST_SystemCocoa::getModifierKeys(GHOST_ModifierKeys& keys) const
-{
-=======
[pool drain];
return GHOST_kSuccess;
}
@@ -1277,141 +853,140 @@ GHOST_TSuccess GHOST_SystemCocoa::getModifierKeys(GHOST_ModifierKeys& keys) cons
GHOST_TSuccess GHOST_SystemCocoa::getModifierKeys(GHOST_ModifierKeys& keys) const
{
->>>>>>> .merge-right.r30358
keys.set(GHOST_kModifierKeyCommand, (m_modifierMask & NSCommandKeyMask) ? true : false);
keys.set(GHOST_kModifierKeyLeftAlt, (m_modifierMask & NSAlternateKeyMask) ? true : false);
keys.set(GHOST_kModifierKeyLeftShift, (m_modifierMask & NSShiftKeyMask) ? true : false);
keys.set(GHOST_kModifierKeyLeftControl, (m_modifierMask & NSControlKeyMask) ? true : false);
-
- return GHOST_kSuccess;
-}
-
-GHOST_TSuccess GHOST_SystemCocoa::getButtons(GHOST_Buttons& buttons) const
-{
- buttons.clear();
- buttons.set(GHOST_kButtonMaskLeft, m_pressedMouseButtons & GHOST_kButtonMaskLeft);
- buttons.set(GHOST_kButtonMaskRight, m_pressedMouseButtons & GHOST_kButtonMaskRight);
- buttons.set(GHOST_kButtonMaskMiddle, m_pressedMouseButtons & GHOST_kButtonMaskMiddle);
- buttons.set(GHOST_kButtonMaskButton4, m_pressedMouseButtons & GHOST_kButtonMaskButton4);
- buttons.set(GHOST_kButtonMaskButton5, m_pressedMouseButtons & GHOST_kButtonMaskButton5);
- return GHOST_kSuccess;
-}
-
-
-
-#pragma mark Event handlers
-
-/**
- * The event queue polling function
- */
-bool GHOST_SystemCocoa::processEvents(bool waitForEvent)
-{
- bool anyProcessed = false;
- NSEvent *event;
-
- // SetMouseCoalescingEnabled(false, NULL);
- //TODO : implement timer ??
-
- /*do {
- GHOST_TimerManager* timerMgr = getTimerManager();
-
- if (waitForEvent) {
- GHOST_TUns64 next = timerMgr->nextFireTime();
- double timeOut;
-
- if (next == GHOST_kFireTimeNever) {
- timeOut = kEventDurationForever;
- } else {
- timeOut = (double)(next - getMilliSeconds())/1000.0;
- if (timeOut < 0.0)
- timeOut = 0.0;
- }
-
- ::ReceiveNextEvent(0, NULL, timeOut, false, &event);
- }
-
- if (timerMgr->fireTimers(getMilliSeconds())) {
- anyProcessed = true;
- }*/
-
- do {
- NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
- event = [NSApp nextEventMatchingMask:NSAnyEventMask
- untilDate:[NSDate distantPast]
- inMode:NSDefaultRunLoopMode
- dequeue:YES];
- if (event==nil) {
- [pool drain];
- break;
- }
-
- anyProcessed = true;
-
- switch ([event type]) {
- case NSKeyDown:
- case NSKeyUp:
- case NSFlagsChanged:
- handleKeyEvent(event);
-
+
+ return GHOST_kSuccess;
+}
+
+GHOST_TSuccess GHOST_SystemCocoa::getButtons(GHOST_Buttons& buttons) const
+{
+ buttons.clear();
+ buttons.set(GHOST_kButtonMaskLeft, m_pressedMouseButtons & GHOST_kButtonMaskLeft);
+ buttons.set(GHOST_kButtonMaskRight, m_pressedMouseButtons & GHOST_kButtonMaskRight);
+ buttons.set(GHOST_kButtonMaskMiddle, m_pressedMouseButtons & GHOST_kButtonMaskMiddle);
+ buttons.set(GHOST_kButtonMaskButton4, m_pressedMouseButtons & GHOST_kButtonMaskButton4);
+ buttons.set(GHOST_kButtonMaskButton5, m_pressedMouseButtons & GHOST_kButtonMaskButton5);
+ return GHOST_kSuccess;
+}
+
+
+
+#pragma mark Event handlers
+
+/**
+ * The event queue polling function
+ */
+bool GHOST_SystemCocoa::processEvents(bool waitForEvent)
+{
+ bool anyProcessed = false;
+ NSEvent *event;
+
+ // SetMouseCoalescingEnabled(false, NULL);
+ //TODO : implement timer ??
+
+ /*do {
+ GHOST_TimerManager* timerMgr = getTimerManager();
+
+ if (waitForEvent) {
+ GHOST_TUns64 next = timerMgr->nextFireTime();
+ double timeOut;
+
+ if (next == GHOST_kFireTimeNever) {
+ timeOut = kEventDurationForever;
+ } else {
+ timeOut = (double)(next - getMilliSeconds())/1000.0;
+ if (timeOut < 0.0)
+ timeOut = 0.0;
+ }
+
+ ::ReceiveNextEvent(0, NULL, timeOut, false, &event);
+ }
+
+ if (timerMgr->fireTimers(getMilliSeconds())) {
+ anyProcessed = true;
+ }*/
+
+ do {
+ NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
+ event = [NSApp nextEventMatchingMask:NSAnyEventMask
+ untilDate:[NSDate distantPast]
+ inMode:NSDefaultRunLoopMode
+ dequeue:YES];
+ if (event==nil) {
+ [pool drain];
+ break;
+ }
+
+ 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:
+ /* 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;
-
+ 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
- [NSApp sendEvent:event];
- [pool drain];
- } while (event!= nil);
- //} while (waitForEvent && !anyProcessed); Needed only for timer implementation
-
+ 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
+ [NSApp sendEvent:event];
+ [pool drain];
+ } while (event!= nil);
+ //} while (waitForEvent && !anyProcessed); Needed only for timer implementation
+
if (m_needDelayedApplicationBecomeActiveEventProcessing) handleApplicationBecomeActiveEvent();
if (m_outsideLoopEventProcessed) {
m_outsideLoopEventProcessed = false;
return true;
}
-
+
return anyProcessed;
}
@@ -1430,7 +1005,7 @@ GHOST_TSuccess GHOST_SystemCocoa::handleApplicationBecomeActiveEvent()
else m_needDelayedApplicationBecomeActiveEventProcessing = false;
modifiers = [[[NSApplication sharedApplication] currentEvent] modifierFlags];
-
+
if ((modifiers & NSShiftKeyMask) != (m_modifierMask & NSShiftKeyMask)) {
pushEvent( new GHOST_EventKey(getMilliSeconds(), (modifiers & NSShiftKeyMask)?GHOST_kEventKeyDown:GHOST_kEventKeyUp, window, GHOST_kKeyLeftShift) );
}
@@ -1448,50 +1023,50 @@ GHOST_TSuccess GHOST_SystemCocoa::handleApplicationBecomeActiveEvent()
m_outsideLoopEventProcessed = true;
return GHOST_kSuccess;
-}
-
-//Note: called from NSWindow delegate
-GHOST_TSuccess GHOST_SystemCocoa::handleWindowEvent(GHOST_TEventType eventType, GHOST_WindowCocoa* window)
-{
- if (!validWindow(window)) {
- return GHOST_kFailure;
- }
- switch(eventType)
- {
- case GHOST_kEventWindowClose:
- pushEvent( new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowClose, window) );
- break;
- case GHOST_kEventWindowActivate:
- m_windowManager->setActiveWindow(window);
- window->loadCursor(window->getCursorVisibility(), window->getCursorShape());
- pushEvent( new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowActivate, window) );
- break;
- case GHOST_kEventWindowDeactivate:
- m_windowManager->setWindowInactive(window);
- pushEvent( new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowDeactivate, window) );
- break;
- case GHOST_kEventWindowUpdate:
- pushEvent( new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowUpdate, window) );
- break;
+}
+
+//Note: called from NSWindow delegate
+GHOST_TSuccess GHOST_SystemCocoa::handleWindowEvent(GHOST_TEventType eventType, GHOST_WindowCocoa* window)
+{
+ if (!validWindow(window)) {
+ return GHOST_kFailure;
+ }
+ switch(eventType)
+ {
+ case GHOST_kEventWindowClose:
+ pushEvent( new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowClose, window) );
+ break;
+ case GHOST_kEventWindowActivate:
+ m_windowManager->setActiveWindow(window);
+ window->loadCursor(window->getCursorVisibility(), window->getCursorShape());
+ pushEvent( new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowActivate, window) );
+ break;
+ case GHOST_kEventWindowDeactivate:
+ m_windowManager->setWindowInactive(window);
+ pushEvent( new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowDeactivate, window) );
+ break;
+ case GHOST_kEventWindowUpdate:
+ pushEvent( new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowUpdate, window) );
+ break;
case GHOST_kEventWindowMove:
pushEvent( new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowMove, window) );
break;
- case GHOST_kEventWindowSize:
- if (!m_ignoreWindowSizedMessages)
- {
- window->updateDrawingContext();
- pushEvent( new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowSize, window) );
- }
- break;
- default:
- return GHOST_kFailure;
- break;
- }
+ case GHOST_kEventWindowSize:
+ if (!m_ignoreWindowSizedMessages)
+ {
+ window->updateDrawingContext();
+ pushEvent( new GHOST_Event(getMilliSeconds(), GHOST_kEventWindowSize, window) );
+ }
+ break;
+ default:
+ return GHOST_kFailure;
+ break;
+ }
m_outsideLoopEventProcessed = true;
- return GHOST_kSuccess;
-}
-
+ return GHOST_kSuccess;
+}
+
//Note: called from NSWindow subclass
GHOST_TSuccess GHOST_SystemCocoa::handleDraggingEvent(GHOST_TEventType eventType, GHOST_TDragnDropTypes draggedObjectType,
GHOST_WindowCocoa* window, int mouseX, int mouseY, void* data)
@@ -1702,41 +1277,41 @@ GHOST_TSuccess GHOST_SystemCocoa::handleDraggingEvent(GHOST_TEventType eventType
}
-GHOST_TUns8 GHOST_SystemCocoa::handleQuitRequest()
-{
+GHOST_TUns8 GHOST_SystemCocoa::handleQuitRequest()
+{
GHOST_Window* window = (GHOST_Window*)m_windowManager->getActiveWindow();
//Discard quit event if we are in cursor grab sequence
if (window && (window->getCursorGrabMode() != GHOST_kGrabDisable) && (window->getCursorGrabMode() != GHOST_kGrabNormal))
return GHOST_kExitCancel;
- //Check open windows if some changes are not saved
- if (m_windowManager->getAnyModifiedState())
- {
+ //Check open windows if some changes are not saved
+ if (m_windowManager->getAnyModifiedState())
+ {
int shouldQuit = NSRunAlertPanel(@"Exit Blender", @"Some changes have not been saved.\nDo you really want to quit ?",
@"Cancel", @"Quit Anyway", nil);
- if (shouldQuit == NSAlertAlternateReturn)
- {
- pushEvent( new GHOST_Event(getMilliSeconds(), GHOST_kEventQuit, NULL) );
- return GHOST_kExitNow;
+ if (shouldQuit == NSAlertAlternateReturn)
+ {
+ pushEvent( new GHOST_Event(getMilliSeconds(), GHOST_kEventQuit, NULL) );
+ return GHOST_kExitNow;
} else {
//Give back focus to the blender window if user selected cancel quit
NSArray *windowsList = [NSApp orderedWindows];
if ([windowsList count]) {
[[windowsList objectAtIndex:0] makeKeyAndOrderFront:nil];
}
- }
+ }
- }
- else {
- pushEvent( new GHOST_Event(getMilliSeconds(), GHOST_kEventQuit, NULL) );
+ }
+ else {
+ pushEvent( new GHOST_Event(getMilliSeconds(), GHOST_kEventQuit, NULL) );
m_outsideLoopEventProcessed = true;
- return GHOST_kExitNow;
- }
-
- return GHOST_kExitCancel;
-}
-
+ return GHOST_kExitNow;
+ }
+
+ return GHOST_kExitCancel;
+}
+
bool GHOST_SystemCocoa::handleOpenDocumentRequest(void *filepathStr)
{
NSString *filepath = (NSString*)filepathStr;
@@ -1761,7 +1336,7 @@ bool GHOST_SystemCocoa::handleOpenDocumentRequest(void *filepathStr)
@"Current document has not been saved.\nDo you really want to proceed?",
@"Cancel", @"Open", nil);
}
-
+
//Give back focus to the blender window
windowsList = [NSApp orderedWindows];
if ([windowsList count]) {
@@ -1789,9 +1364,9 @@ bool GHOST_SystemCocoa::handleOpenDocumentRequest(void *filepathStr)
else return NO;
}
-GHOST_TSuccess GHOST_SystemCocoa::handleTabletEvent(void *eventPtr, short eventType)
-{
- NSEvent *event = (NSEvent *)eventPtr;
+GHOST_TSuccess GHOST_SystemCocoa::handleTabletEvent(void *eventPtr, short eventType)
+{
+ NSEvent *event = (NSEvent *)eventPtr;
GHOST_IWindow* window;
window = m_windowManager->getWindowAssociatedWithOSWindow((void*)[event window]);
@@ -1800,116 +1375,116 @@ GHOST_TSuccess GHOST_SystemCocoa::handleTabletEvent(void *eventPtr, short eventT
return GHOST_kFailure;
}
- GHOST_TabletData& ct=((GHOST_WindowCocoa*)window)->GetCocoaTabletData();
-
- switch (eventType) {
- case NSTabletPoint:
+ GHOST_TabletData& ct=((GHOST_WindowCocoa*)window)->GetCocoaTabletData();
+
+ switch (eventType) {
+ case NSTabletPoint:
ct.Pressure = [event pressure];
- ct.Xtilt = [event tilt].x;
- ct.Ytilt = [event tilt].y;
- break;
-
- case NSTabletProximity:
- ct.Pressure = 0;
- ct.Xtilt = 0;
- ct.Ytilt = 0;
- if ([event isEnteringProximity])
- {
- //pointer is entering tablet area proximity
- switch ([event pointingDeviceType]) {
- case NSPenPointingDevice:
- ct.Active = GHOST_kTabletModeStylus;
- break;
- case NSEraserPointingDevice:
- ct.Active = GHOST_kTabletModeEraser;
- break;
- case NSCursorPointingDevice:
- case NSUnknownPointingDevice:
- default:
- ct.Active = GHOST_kTabletModeNone;
- break;
- }
- } else {
- // pointer is leaving - return to mouse
- ct.Active = GHOST_kTabletModeNone;
- }
- break;
-
- default:
- GHOST_ASSERT(FALSE,"GHOST_SystemCocoa::handleTabletEvent : unknown event received");
- return GHOST_kFailure;
- break;
- }
- return GHOST_kSuccess;
-}
-
-
-GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
-{
- NSEvent *event = (NSEvent *)eventPtr;
+ ct.Xtilt = [event tilt].x;
+ ct.Ytilt = [event tilt].y;
+ break;
+
+ case NSTabletProximity:
+ ct.Pressure = 0;
+ ct.Xtilt = 0;
+ ct.Ytilt = 0;
+ if ([event isEnteringProximity])
+ {
+ //pointer is entering tablet area proximity
+ switch ([event pointingDeviceType]) {
+ case NSPenPointingDevice:
+ ct.Active = GHOST_kTabletModeStylus;
+ break;
+ case NSEraserPointingDevice:
+ ct.Active = GHOST_kTabletModeEraser;
+ break;
+ case NSCursorPointingDevice:
+ case NSUnknownPointingDevice:
+ default:
+ ct.Active = GHOST_kTabletModeNone;
+ break;
+ }
+ } else {
+ // pointer is leaving - return to mouse
+ ct.Active = GHOST_kTabletModeNone;
+ }
+ break;
+
+ default:
+ GHOST_ASSERT(FALSE,"GHOST_SystemCocoa::handleTabletEvent : unknown event received");
+ return GHOST_kFailure;
+ break;
+ }
+ return GHOST_kSuccess;
+}
+
+
+GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
+{
+ NSEvent *event = (NSEvent *)eventPtr;
GHOST_Window* window;
-
+
window = (GHOST_Window*)m_windowManager->getWindowAssociatedWithOSWindow((void*)[event window]);
- if (!window) {
+ if (!window) {
//printf("\nW failure for event 0x%x",[event type]);
- return GHOST_kFailure;
- }
-
- switch ([event type])
- {
- case NSLeftMouseDown:
- case NSRightMouseDown:
- case NSOtherMouseDown:
+ return GHOST_kFailure;
+ }
+
+ switch ([event type])
+ {
+ case NSLeftMouseDown:
+ case NSRightMouseDown:
+ case NSOtherMouseDown:
pushEvent(new GHOST_EventButton([event timestamp]*1000, GHOST_kEventButtonDown, window, convertButton([event buttonNumber])));
- //Handle tablet events combined with mouse events
- switch ([event subtype]) {
- case NX_SUBTYPE_TABLET_POINT:
- handleTabletEvent(eventPtr, NSTabletPoint);
- break;
- case NX_SUBTYPE_TABLET_PROXIMITY:
- handleTabletEvent(eventPtr, NSTabletProximity);
- break;
- default:
- //No tablet event included : do nothing
- break;
- }
- break;
-
- case NSLeftMouseUp:
- case NSRightMouseUp:
- case NSOtherMouseUp:
+ //Handle tablet events combined with mouse events
+ switch ([event subtype]) {
+ case NX_SUBTYPE_TABLET_POINT:
+ handleTabletEvent(eventPtr, NSTabletPoint);
+ break;
+ case NX_SUBTYPE_TABLET_PROXIMITY:
+ handleTabletEvent(eventPtr, NSTabletProximity);
+ break;
+ default:
+ //No tablet event included : do nothing
+ break;
+ }
+ break;
+
+ case NSLeftMouseUp:
+ case NSRightMouseUp:
+ case NSOtherMouseUp:
pushEvent(new GHOST_EventButton([event timestamp]*1000, GHOST_kEventButtonUp, window, convertButton([event buttonNumber])));
- //Handle tablet events combined with mouse events
- switch ([event subtype]) {
- case NX_SUBTYPE_TABLET_POINT:
- handleTabletEvent(eventPtr, NSTabletPoint);
- break;
- case NX_SUBTYPE_TABLET_PROXIMITY:
- handleTabletEvent(eventPtr, NSTabletProximity);
- break;
- default:
- //No tablet event included : do nothing
- break;
- }
- break;
-
- case NSLeftMouseDragged:
- case NSRightMouseDragged:
- case NSOtherMouseDragged:
- //Handle tablet events combined with mouse events
- switch ([event subtype]) {
- case NX_SUBTYPE_TABLET_POINT:
- handleTabletEvent(eventPtr, NSTabletPoint);
- break;
- case NX_SUBTYPE_TABLET_PROXIMITY:
- handleTabletEvent(eventPtr, NSTabletProximity);
- break;
- default:
- //No tablet event included : do nothing
- break;
- }
+ //Handle tablet events combined with mouse events
+ switch ([event subtype]) {
+ case NX_SUBTYPE_TABLET_POINT:
+ handleTabletEvent(eventPtr, NSTabletPoint);
+ break;
+ case NX_SUBTYPE_TABLET_PROXIMITY:
+ handleTabletEvent(eventPtr, NSTabletProximity);
+ break;
+ default:
+ //No tablet event included : do nothing
+ break;
+ }
+ break;
+
+ case NSLeftMouseDragged:
+ case NSRightMouseDragged:
+ case NSOtherMouseDragged:
+ //Handle tablet events combined with mouse events
+ switch ([event subtype]) {
+ case NX_SUBTYPE_TABLET_POINT:
+ handleTabletEvent(eventPtr, NSTabletPoint);
+ break;
+ case NX_SUBTYPE_TABLET_PROXIMITY:
+ handleTabletEvent(eventPtr, NSTabletProximity);
+ break;
+ default:
+ //No tablet event included : do nothing
+ break;
+ }
- case NSMouseMoved:
+ case NSMouseMoved:
switch (window->getCursorGrabMode()) {
case GHOST_kGrabHide: //Cursor hidden grab operation : no cursor move
{
@@ -1975,14 +1550,14 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
NSPoint mousePos = [event locationInWindow];
pushEvent(new GHOST_EventCursor([event timestamp]*1000, GHOST_kEventCursorMove, window, mousePos.x, mousePos.y));
m_cursorDelta_x=0;
- m_cursorDelta_y=0; //Mouse motion occured between two cursor warps, so we can reset the delta counter
+ m_cursorDelta_y=0; //Mouse motion occurred between two cursor warps, so we can reset the delta counter
}
break;
- }
- break;
-
- case NSScrollWheel:
- {
+ }
+ break;
+
+ case NSScrollWheel:
+ {
/* Send trackpad event if inside a trackpad gesture, send wheel event otherwise */
if (!m_hasMultiTouchTrackpad || !m_isGestureInProgress) {
GHOST_TInt32 delta;
@@ -2013,9 +1588,9 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
pushEvent(new GHOST_EventTrackpad([event timestamp]*1000, window, GHOST_kTrackpadEventScroll, mousePos.x, mousePos.y, dx, dy));
}
- }
- break;
-
+ }
+ break;
+
case NSEventTypeMagnify:
{
NSPoint mousePos = [event locationInWindow];
@@ -2036,47 +1611,43 @@ GHOST_TSuccess GHOST_SystemCocoa::handleMouseEvent(void *eventPtr)
case NSEventTypeEndGesture:
m_isGestureInProgress = false;
break;
- default:
- return GHOST_kFailure;
- break;
- }
-
- return GHOST_kSuccess;
-}
-
-
-GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent(void *eventPtr)
-{
- NSEvent *event = (NSEvent *)eventPtr;
+ default:
+ return GHOST_kFailure;
+ break;
+ }
+
+ return GHOST_kSuccess;
+}
+
+
+GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent(void *eventPtr)
+{
+ NSEvent *event = (NSEvent *)eventPtr;
GHOST_IWindow* window;
- unsigned int modifiers;
- NSString *characters;
+ unsigned int modifiers;
+ NSString *characters;
NSData *convertedCharacters;
- GHOST_TKey keyCode;
- unsigned char ascii;
+ GHOST_TKey keyCode;
+ unsigned char ascii;
NSString* charsIgnoringModifiers;
-
+
window = m_windowManager->getWindowAssociatedWithOSWindow((void*)[event window]);
- if (!window) {
+ if (!window) {
//printf("\nW failure for event 0x%x",[event type]);
- return GHOST_kFailure;
- }
-
- switch ([event type]) {
- case NSKeyDown:
- case NSKeyUp:
+ return GHOST_kFailure;
+ }
+
+ switch ([event type]) {
+ case NSKeyDown:
+ case NSKeyUp:
charsIgnoringModifiers = [event charactersIgnoringModifiers];
if ([charsIgnoringModifiers length]>0)
- keyCode = convertKey([event keyCode],
+ keyCode = convertKey([event keyCode],
[charsIgnoringModifiers characterAtIndex:0],
[event type] == NSKeyDown?kUCKeyActionDown:kUCKeyActionUp);
else
-<<<<<<< .working
- keyCode = convertKey([event keyCode],0);
-=======
keyCode = convertKey([event keyCode],0,
[event type] == NSKeyDown?kUCKeyActionDown:kUCKeyActionUp);
->>>>>>> .merge-right.r30358
characters = [event characters];
@@ -2087,145 +1658,132 @@ GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent(void *eventPtr)
ascii =((char*)[convertedCharacters bytes])[0];
else
ascii = 0; //Character not available in iso latin 1 encoding
- }
+ }
else
ascii= 0;
-
- if ((keyCode == GHOST_kKeyQ) && (m_modifierMask & NSCommandKeyMask))
- break; //Cmd-Q is directly handled by Cocoa
-
- if ([event type] == NSKeyDown) {
+
+ if ((keyCode == GHOST_kKeyQ) && (m_modifierMask & NSCommandKeyMask))
+ break; //Cmd-Q is directly handled by Cocoa
+
+ if ([event type] == NSKeyDown) {
pushEvent( new GHOST_EventKey([event timestamp]*1000, GHOST_kEventKeyDown, window, keyCode, ascii) );
-<<<<<<< .working
- //printf("\nKey pressed keyCode=%u ascii=%i %c",keyCode,ascii,ascii);
- } else {
-=======
//printf("\nKey down rawCode=0x%x charsIgnoringModifiers=%c keyCode=%u ascii=%i %c",[event keyCode],[charsIgnoringModifiers length]>0?[charsIgnoringModifiers characterAtIndex:0]:' ',keyCode,ascii,ascii);
} else {
->>>>>>> .merge-right.r30358
pushEvent( new GHOST_EventKey([event timestamp]*1000, GHOST_kEventKeyUp, window, keyCode, ascii) );
-<<<<<<< .working
- }
- break;
-
- case NSFlagsChanged:
- modifiers = [event modifierFlags];
-=======
//printf("\nKey up rawCode=0x%x charsIgnoringModifiers=%c keyCode=%u ascii=%i %c",[event keyCode],[charsIgnoringModifiers length]>0?[charsIgnoringModifiers characterAtIndex:0]:' ',keyCode,ascii,ascii);
}
break;
case NSFlagsChanged:
modifiers = [event modifierFlags];
->>>>>>> .merge-right.r30358
- if ((modifiers & NSShiftKeyMask) != (m_modifierMask & NSShiftKeyMask)) {
+ if ((modifiers & NSShiftKeyMask) != (m_modifierMask & NSShiftKeyMask)) {
pushEvent( new GHOST_EventKey([event timestamp]*1000, (modifiers & NSShiftKeyMask)?GHOST_kEventKeyDown:GHOST_kEventKeyUp, window, GHOST_kKeyLeftShift) );
- }
- if ((modifiers & NSControlKeyMask) != (m_modifierMask & NSControlKeyMask)) {
+ }
+ if ((modifiers & NSControlKeyMask) != (m_modifierMask & NSControlKeyMask)) {
pushEvent( new GHOST_EventKey([event timestamp]*1000, (modifiers & NSControlKeyMask)?GHOST_kEventKeyDown:GHOST_kEventKeyUp, window, GHOST_kKeyLeftControl) );
- }
- if ((modifiers & NSAlternateKeyMask) != (m_modifierMask & NSAlternateKeyMask)) {
+ }
+ if ((modifiers & NSAlternateKeyMask) != (m_modifierMask & NSAlternateKeyMask)) {
pushEvent( new GHOST_EventKey([event timestamp]*1000, (modifiers & NSAlternateKeyMask)?GHOST_kEventKeyDown:GHOST_kEventKeyUp, window, GHOST_kKeyLeftAlt) );
- }
- if ((modifiers & NSCommandKeyMask) != (m_modifierMask & NSCommandKeyMask)) {
+ }
+ if ((modifiers & NSCommandKeyMask) != (m_modifierMask & NSCommandKeyMask)) {
pushEvent( new GHOST_EventKey([event timestamp]*1000, (modifiers & NSCommandKeyMask)?GHOST_kEventKeyDown:GHOST_kEventKeyUp, window, GHOST_kKeyCommand) );
- }
-
- m_modifierMask = modifiers;
- break;
-
- default:
- return GHOST_kFailure;
- break;
- }
-
- return GHOST_kSuccess;
-}
-
-
-
-#pragma mark Clipboard get/set
-
-GHOST_TUns8* GHOST_SystemCocoa::getClipboard(bool selection) const
-{
- GHOST_TUns8 * temp_buff;
- size_t pastedTextSize;
-
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
- NSPasteboard *pasteBoard = [NSPasteboard generalPasteboard];
-
- if (pasteBoard == nil) {
- [pool drain];
- return NULL;
- }
-
- NSArray *supportedTypes =
+ }
+
+ m_modifierMask = modifiers;
+ break;
+
+ default:
+ return GHOST_kFailure;
+ break;
+ }
+
+ return GHOST_kSuccess;
+}
+
+
+
+#pragma mark Clipboard get/set
+
+GHOST_TUns8* GHOST_SystemCocoa::getClipboard(bool selection) const
+{
+ GHOST_TUns8 * temp_buff;
+ size_t pastedTextSize;
+
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+ NSPasteboard *pasteBoard = [NSPasteboard generalPasteboard];
+
+ if (pasteBoard == nil) {
+ [pool drain];
+ return NULL;
+ }
+
+ NSArray *supportedTypes =
[NSArray arrayWithObjects: NSStringPboardType, nil];
-
- NSString *bestType = [[NSPasteboard generalPasteboard]
- availableTypeFromArray:supportedTypes];
-
- if (bestType == nil) {
- [pool drain];
- return NULL;
- }
-
+
+ NSString *bestType = [[NSPasteboard generalPasteboard]
+ availableTypeFromArray:supportedTypes];
+
+ if (bestType == nil) {
+ [pool drain];
+ return NULL;
+ }
+
NSString * textPasted = [pasteBoard stringForType:NSStringPboardType];
-
- if (textPasted == nil) {
- [pool drain];
- return NULL;
- }
-
+
+ if (textPasted == nil) {
+ [pool drain];
+ return NULL;
+ }
+
pastedTextSize = [textPasted lengthOfBytesUsingEncoding:NSISOLatin1StringEncoding];
-
- temp_buff = (GHOST_TUns8*) malloc(pastedTextSize+1);
-
- if (temp_buff == NULL) {
- [pool drain];
- return NULL;
- }
-
+
+ temp_buff = (GHOST_TUns8*) malloc(pastedTextSize+1);
+
+ if (temp_buff == NULL) {
+ [pool drain];
+ return NULL;
+ }
+
strncpy((char*)temp_buff, [textPasted cStringUsingEncoding:NSISOLatin1StringEncoding], pastedTextSize);
-
- temp_buff[pastedTextSize] = '\0';
-
- [pool drain];
-
- if(temp_buff) {
- return temp_buff;
- } else {
- return NULL;
- }
-}
-
-void GHOST_SystemCocoa::putClipboard(GHOST_TInt8 *buffer, bool selection) const
-{
- NSString *textToCopy;
-
- if(selection) {return;} // for copying the selection, used on X11
-
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
- NSPasteboard *pasteBoard = [NSPasteboard generalPasteboard];
-
- if (pasteBoard == nil) {
- [pool drain];
- return;
- }
-
+
+ temp_buff[pastedTextSize] = '\0';
+
+ [pool drain];
+
+ if(temp_buff) {
+ return temp_buff;
+ } else {
+ return NULL;
+ }
+}
+
+void GHOST_SystemCocoa::putClipboard(GHOST_TInt8 *buffer, bool selection) const
+{
+ NSString *textToCopy;
+
+ if(selection) {return;} // for copying the selection, used on X11
+
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+ NSPasteboard *pasteBoard = [NSPasteboard generalPasteboard];
+
+ if (pasteBoard == nil) {
+ [pool drain];
+ return;
+ }
+
NSArray *supportedTypes = [NSArray arrayWithObject:NSStringPboardType];
-
- [pasteBoard declareTypes:supportedTypes owner:nil];
-
+
+ [pasteBoard declareTypes:supportedTypes owner:nil];
+
textToCopy = [NSString stringWithCString:buffer encoding:NSISOLatin1StringEncoding];
-
+
[pasteBoard setString:textToCopy forType:NSStringPboardType];
-
- [pool drain];
-}
+
+ [pool drain];
+}
#pragma mark Base directories retrieval
diff --git a/intern/ghost/intern/GHOST_SystemWin32.h b/intern/ghost/intern/GHOST_SystemWin32.h
index 888d9c0ab3e..35b8debf6b4 100644
--- a/intern/ghost/intern/GHOST_SystemWin32.h
+++ b/intern/ghost/intern/GHOST_SystemWin32.h
@@ -214,7 +214,7 @@ public:
* @param draggedObjectType The type object concerned (currently array of file names, string, ?bitmap)
* @param mouseX x mouse coordinate (in window coordinates)
* @param mouseY y mouse coordinate
- * @param window The window on which the event occured
+ * @param window The window on which the event occurred
* @return Indication whether the event was handled.
*/
static GHOST_TSuccess pushDragDropEvent(GHOST_TEventType eventType, GHOST_TDragnDropTypes draggedObjectType,GHOST_IWindow* window, int mouseX, int mouseY, void* data);
diff --git a/intern/ghost/intern/GHOST_SystemX11.cpp b/intern/ghost/intern/GHOST_SystemX11.cpp
index c9228e68e54..961a637e616 100644
--- a/intern/ghost/intern/GHOST_SystemX11.cpp
+++ b/intern/ghost/intern/GHOST_SystemX11.cpp
@@ -67,6 +67,10 @@
#include <stdio.h> // for fprintf only
#include <cstdlib> // for exit
+#ifndef PREFIX
+# define PREFIX "/usr/local"
+#endif
+
typedef struct NDOFPlatformInfo {
Display *display;
Window window;
@@ -1461,7 +1465,7 @@ void GHOST_SystemX11::putClipboard(GHOST_TInt8 *buffer, bool selection) const
const GHOST_TUns8* GHOST_SystemX11::getSystemDir() const
{
- return (GHOST_TUns8*)"/usr/share";
+ return (GHOST_TUns8*) PREFIX "/share";
}
const GHOST_TUns8* GHOST_SystemX11::getUserDir() const
diff --git a/intern/ghost/intern/GHOST_WindowCocoa.h b/intern/ghost/intern/GHOST_WindowCocoa.h
index 4b492a6b0b5..410febe11eb 100644
--- a/intern/ghost/intern/GHOST_WindowCocoa.h
+++ b/intern/ghost/intern/GHOST_WindowCocoa.h
@@ -1,5 +1,5 @@
/**
- * $Id: GHOST_WindowCocoa.h 23789 2009-10-12 16:51:36Z damien78 $
+ * $Id: GHOST_WindowCocoa.h 29143 2010-06-01 20:21:40Z damien78 $
* ***** BEGIN GPL LICENSE BLOCK *****
*
* This program is free software; you can redistribute it and/or
diff --git a/intern/ghost/intern/GHOST_WindowCocoa.mm b/intern/ghost/intern/GHOST_WindowCocoa.mm
index 233edfc9d65..bc28ffb7223 100644
--- a/intern/ghost/intern/GHOST_WindowCocoa.mm
+++ b/intern/ghost/intern/GHOST_WindowCocoa.mm
@@ -1,51 +1,51 @@
-/**
- * $Id: GHOST_WindowCocoa.mm 23873 2009-10-15 20:09:50Z damien78 $
- * ***** BEGIN GPL LICENSE BLOCK *****
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software Foundation,
+/**
+ * $Id: GHOST_WindowCocoa.mm 30325 2010-07-14 14:11:03Z jwilkins $
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
- * All rights reserved.
- *
- * The Original Code is: all of this file.
- *
- * Contributor(s): Maarten Gribnau 05/2001
- Damien Plisson 10/2009
- *
- * ***** END GPL LICENSE BLOCK *****
- */
-
-#include <Cocoa/Cocoa.h>
-
-#ifndef MAC_OS_X_VERSION_10_6
-//Use of the SetSystemUIMode function (64bit compatible)
-#include <Carbon/Carbon.h>
-#endif
-
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): Maarten Gribnau 05/2001
+ Damien Plisson 10/2009
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+#include <Cocoa/Cocoa.h>
+
+#ifndef MAC_OS_X_VERSION_10_6
+//Use of the SetSystemUIMode function (64bit compatible)
+#include <Carbon/Carbon.h>
+#endif
+
#include <OpenGL/gl.h>
/***** Multithreaded opengl code : uncomment for enabling
#include <OpenGL/OpenGL.h>
*/
-#include "GHOST_WindowCocoa.h"
-#include "GHOST_SystemCocoa.h"
-#include "GHOST_Debug.h"
-
-
-#pragma mark Cocoa window delegate object
+#include "GHOST_WindowCocoa.h"
+#include "GHOST_SystemCocoa.h"
+#include "GHOST_Debug.h"
+
+
+#pragma mark Cocoa window delegate object
/* live resize ugly patch
extern "C" {
struct bContext;
@@ -57,52 +57,52 @@ extern "C" {
extern void wm_event_do_notifiers(bContext *C);
extern void wm_draw_update(bContext *C);
};*/
-@interface CocoaWindowDelegate : NSObject
+@interface CocoaWindowDelegate : NSObject
#ifdef MAC_OS_X_VERSION_10_6
<NSWindowDelegate>
#endif
-{
- GHOST_SystemCocoa *systemCocoa;
- GHOST_WindowCocoa *associatedWindow;
-}
-
+{
+ GHOST_SystemCocoa *systemCocoa;
+ GHOST_WindowCocoa *associatedWindow;
+}
+
- (void)setSystemAndWindowCocoa:(GHOST_SystemCocoa *)sysCocoa windowCocoa:(GHOST_WindowCocoa *)winCocoa;
-- (void)windowWillClose:(NSNotification *)notification;
-- (void)windowDidBecomeKey:(NSNotification *)notification;
-- (void)windowDidResignKey:(NSNotification *)notification;
+- (void)windowWillClose:(NSNotification *)notification;
+- (void)windowDidBecomeKey:(NSNotification *)notification;
+- (void)windowDidResignKey:(NSNotification *)notification;
- (void)windowDidExpose:(NSNotification *)notification;
-- (void)windowDidResize:(NSNotification *)notification;
+- (void)windowDidResize:(NSNotification *)notification;
- (void)windowDidMove:(NSNotification *)notification;
- (void)windowWillMove:(NSNotification *)notification;
-@end
-
-@implementation CocoaWindowDelegate : NSObject
-- (void)setSystemAndWindowCocoa:(GHOST_SystemCocoa *)sysCocoa windowCocoa:(GHOST_WindowCocoa *)winCocoa
-{
- systemCocoa = sysCocoa;
- associatedWindow = winCocoa;
-}
-
-- (void)windowWillClose:(NSNotification *)notification
-{
- systemCocoa->handleWindowEvent(GHOST_kEventWindowClose, associatedWindow);
-}
-
-- (void)windowDidBecomeKey:(NSNotification *)notification
-{
- systemCocoa->handleWindowEvent(GHOST_kEventWindowActivate, associatedWindow);
-}
-
-- (void)windowDidResignKey:(NSNotification *)notification
-{
- systemCocoa->handleWindowEvent(GHOST_kEventWindowDeactivate, associatedWindow);
-}
-
+@end
+
+@implementation CocoaWindowDelegate : NSObject
+- (void)setSystemAndWindowCocoa:(GHOST_SystemCocoa *)sysCocoa windowCocoa:(GHOST_WindowCocoa *)winCocoa
+{
+ systemCocoa = sysCocoa;
+ associatedWindow = winCocoa;
+}
+
+- (void)windowWillClose:(NSNotification *)notification
+{
+ systemCocoa->handleWindowEvent(GHOST_kEventWindowClose, associatedWindow);
+}
+
+- (void)windowDidBecomeKey:(NSNotification *)notification
+{
+ systemCocoa->handleWindowEvent(GHOST_kEventWindowActivate, associatedWindow);
+}
+
+- (void)windowDidResignKey:(NSNotification *)notification
+{
+ systemCocoa->handleWindowEvent(GHOST_kEventWindowDeactivate, associatedWindow);
+}
+
- (void)windowDidExpose:(NSNotification *)notification
-{
- systemCocoa->handleWindowEvent(GHOST_kEventWindowUpdate, associatedWindow);
-}
-
+{
+ systemCocoa->handleWindowEvent(GHOST_kEventWindowUpdate, associatedWindow);
+}
+
- (void)windowDidMove:(NSNotification *)notification
{
systemCocoa->handleWindowEvent(GHOST_kEventWindowMove, associatedWindow);
@@ -113,8 +113,8 @@ extern "C" {
systemCocoa->handleWindowEvent(GHOST_kEventWindowMove, associatedWindow);
}
-- (void)windowDidResize:(NSNotification *)notification
-{
+- (void)windowDidResize:(NSNotification *)notification
+{
#ifdef MAC_OS_X_VERSION_10_6
//if (![[notification object] inLiveResize]) {
//Send event only once, at end of resize operation (when user has released mouse button)
@@ -131,31 +131,31 @@ extern "C" {
wm_event_do_notifiers(ghostC);
wm_draw_update(ghostC);
}*/
-}
-@end
-
-#pragma mark NSWindow subclass
-//We need to subclass it to tell that even borderless (fullscreen), it can become key (receive user events)
-@interface CocoaWindow: NSWindow
-{
+}
+@end
+
+#pragma mark NSWindow subclass
+//We need to subclass it to tell that even borderless (fullscreen), it can become key (receive user events)
+@interface CocoaWindow: NSWindow
+{
GHOST_SystemCocoa *systemCocoa;
GHOST_WindowCocoa *associatedWindow;
GHOST_TDragnDropTypes m_draggedObjectType;
-}
+}
- (void)setSystemAndWindowCocoa:(GHOST_SystemCocoa *)sysCocoa windowCocoa:(GHOST_WindowCocoa *)winCocoa;
-@end
-@implementation CocoaWindow
+@end
+@implementation CocoaWindow
- (void)setSystemAndWindowCocoa:(GHOST_SystemCocoa *)sysCocoa windowCocoa:(GHOST_WindowCocoa *)winCocoa
{
systemCocoa = sysCocoa;
associatedWindow = winCocoa;
}
-
--(BOOL)canBecomeKeyWindow
-{
- return YES;
-}
-
+
+-(BOOL)canBecomeKeyWindow
+{
+ return YES;
+}
+
//The drag'n'drop dragging destination methods
- (NSDragOperation)draggingEntered:(id < NSDraggingInfo >)sender
{
@@ -228,27 +228,27 @@ extern "C" {
return YES;
}
-@end
-
-
-
-#pragma mark NSOpenGLView subclass
-//We need to subclass it in order to give Cocoa the feeling key events are trapped
-@interface CocoaOpenGLView : NSOpenGLView
-{
-}
-@end
-@implementation CocoaOpenGLView
-
-- (BOOL)acceptsFirstResponder
-{
- return YES;
-}
-
-//The trick to prevent Cocoa from complaining (beeping)
-- (void)keyDown:(NSEvent *)theEvent
-{}
-
+@end
+
+
+
+#pragma mark NSOpenGLView subclass
+//We need to subclass it in order to give Cocoa the feeling key events are trapped
+@interface CocoaOpenGLView : NSOpenGLView
+{
+}
+@end
+@implementation CocoaOpenGLView
+
+- (BOOL)acceptsFirstResponder
+{
+ return YES;
+}
+
+//The trick to prevent Cocoa from complaining (beeping)
+- (void)keyDown:(NSEvent *)theEvent
+{}
+
#if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4
//Cmd+key are handled differently before 10.5
- (BOOL)performKeyEquivalent:(NSEvent *)theEvent
@@ -275,59 +275,59 @@ extern "C" {
}
#endif
-- (BOOL)isOpaque
-{
- return YES;
-}
-
-@end
-
-
-#pragma mark initialization / finalization
-
-NSOpenGLContext* GHOST_WindowCocoa::s_firstOpenGLcontext = nil;
-
-GHOST_WindowCocoa::GHOST_WindowCocoa(
- GHOST_SystemCocoa *systemCocoa,
- const STR_String& title,
- GHOST_TInt32 left,
- GHOST_TInt32 top,
- GHOST_TUns32 width,
- GHOST_TUns32 height,
- GHOST_TWindowState state,
- GHOST_TDrawingContextType type,
+- (BOOL)isOpaque
+{
+ return YES;
+}
+
+@end
+
+
+#pragma mark initialization / finalization
+
+NSOpenGLContext* GHOST_WindowCocoa::s_firstOpenGLcontext = nil;
+
+GHOST_WindowCocoa::GHOST_WindowCocoa(
+ GHOST_SystemCocoa *systemCocoa,
+ const STR_String& title,
+ GHOST_TInt32 left,
+ GHOST_TInt32 top,
+ GHOST_TUns32 width,
+ GHOST_TUns32 height,
+ GHOST_TWindowState state,
+ GHOST_TDrawingContextType type,
const bool stereoVisual, const GHOST_TUns16 numOfAASamples
-) :
+) :
GHOST_Window(title, left, top, width, height, state, GHOST_kDrawingContextTypeNone, stereoVisual, numOfAASamples),
- m_customCursor(0)
-{
+ m_customCursor(0)
+{
NSOpenGLPixelFormatAttribute pixelFormatAttrsWindow[40];
NSOpenGLPixelFormat *pixelFormat = nil;
int i;
- m_systemCocoa = systemCocoa;
- m_fullScreen = false;
-
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
-
- //Creates the window
- NSRect rect;
+ m_systemCocoa = systemCocoa;
+ m_fullScreen = false;
+
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+
+ //Creates the window
+ NSRect rect;
NSSize minSize;
-
- rect.origin.x = left;
- rect.origin.y = top;
- rect.size.width = width;
- rect.size.height = height;
-
- m_window = [[CocoaWindow alloc] initWithContentRect:rect
- styleMask:NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask | NSMiniaturizableWindowMask
- backing:NSBackingStoreBuffered defer:NO];
- if (m_window == nil) {
- [pool drain];
- return;
- }
-
+
+ rect.origin.x = left;
+ rect.origin.y = top;
+ rect.size.width = width;
+ rect.size.height = height;
+
+ m_window = [[CocoaWindow alloc] initWithContentRect:rect
+ styleMask:NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask | NSMiniaturizableWindowMask
+ backing:NSBackingStoreBuffered defer:NO];
+ if (m_window == nil) {
+ [pool drain];
+ return;
+ }
+
[m_window setSystemAndWindowCocoa:systemCocoa windowCocoa:this];
//Forbid to resize the window below the blender defined minimum one
@@ -335,9 +335,9 @@ GHOST_WindowCocoa::GHOST_WindowCocoa(
minSize.height = 240;
[m_window setContentMinSize:minSize];
- setTitle(title);
-
-
+ setTitle(title);
+
+
// Pixel Format Attributes for the windowed NSOpenGLContext
i=0;
pixelFormatAttrsWindow[i++] = NSOpenGLPFADoubleBuffer;
@@ -405,296 +405,77 @@ GHOST_WindowCocoa::GHOST_WindowCocoa(
}
}
- //Creates the OpenGL View inside the window
- m_openGLView = [[CocoaOpenGLView alloc] initWithFrame:rect
- pixelFormat:pixelFormat];
-
- [pixelFormat release];
-
- m_openGLContext = [m_openGLView openGLContext]; //This context will be replaced by the proper one just after
-
- [m_window setContentView:m_openGLView];
- [m_window setInitialFirstResponder:m_openGLView];
-
- [m_window setReleasedWhenClosed:NO]; //To avoid bad pointer exception in case of user closing the window
-
- [m_window makeKeyAndOrderFront:nil];
-
- setDrawingContextType(type);
- updateDrawingContext();
- activateDrawingContext();
-
- m_tablet.Active = GHOST_kTabletModeNone;
-
- CocoaWindowDelegate *windowDelegate = [[CocoaWindowDelegate alloc] init];
- [windowDelegate setSystemAndWindowCocoa:systemCocoa windowCocoa:this];
- [m_window setDelegate:windowDelegate];
-
- [m_window setAcceptsMouseMovedEvents:YES];
-
+ //Creates the OpenGL View inside the window
+ m_openGLView = [[CocoaOpenGLView alloc] initWithFrame:rect
+ pixelFormat:pixelFormat];
+
+ [pixelFormat release];
+
+ m_openGLContext = [m_openGLView openGLContext]; //This context will be replaced by the proper one just after
+
+ [m_window setContentView:m_openGLView];
+ [m_window setInitialFirstResponder:m_openGLView];
+
+ [m_window setReleasedWhenClosed:NO]; //To avoid bad pointer exception in case of user closing the window
+
+ [m_window makeKeyAndOrderFront:nil];
+
+ setDrawingContextType(type);
+ updateDrawingContext();
+ activateDrawingContext();
+
+ m_tablet.Active = GHOST_kTabletModeNone;
+
+ CocoaWindowDelegate *windowDelegate = [[CocoaWindowDelegate alloc] init];
+ [windowDelegate setSystemAndWindowCocoa:systemCocoa windowCocoa:this];
+ [m_window setDelegate:windowDelegate];
+
+ [m_window setAcceptsMouseMovedEvents:YES];
+
[m_window registerForDraggedTypes:[NSArray arrayWithObjects:NSFilenamesPboardType,
NSStringPboardType, NSTIFFPboardType, nil]];
- if (state == GHOST_kWindowStateFullScreen)
- setState(GHOST_kWindowStateFullScreen);
-
- [pool drain];
-}
-
-
-GHOST_WindowCocoa::~GHOST_WindowCocoa()
-{
- if (m_customCursor) delete m_customCursor;
-
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- [m_openGLView release];
-
- if (m_window) {
- [m_window close];
- [[m_window delegate] release];
- [m_window release];
- m_window = nil;
- }
-
- //Check for other blender opened windows and make the frontmost key
- NSArray *windowsList = [NSApp orderedWindows];
- if ([windowsList count]) {
- [[windowsList objectAtIndex:0] makeKeyAndOrderFront:nil];
- }
- [pool drain];
-}
-
-#pragma mark accessors
-
-bool GHOST_WindowCocoa::getValid() const
-{
+ if (state == GHOST_kWindowStateFullScreen)
+ setState(GHOST_kWindowStateFullScreen);
+
+ [pool drain];
+}
+
+
+GHOST_WindowCocoa::~GHOST_WindowCocoa()
+{
+ if (m_customCursor) delete m_customCursor;
+
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ [m_openGLView release];
+
+ if (m_window) {
+ [m_window close];
+ [[m_window delegate] release];
+ [m_window release];
+ m_window = nil;
+ }
+
+ //Check for other blender opened windows and make the frontmost key
+ NSArray *windowsList = [NSApp orderedWindows];
+ if ([windowsList count]) {
+ [[windowsList objectAtIndex:0] makeKeyAndOrderFront:nil];
+ }
+ [pool drain];
+}
+
+#pragma mark accessors
+
+bool GHOST_WindowCocoa::getValid() const
+{
return (m_window != 0);
-}
-
+}
+
void* GHOST_WindowCocoa::getOSWindow() const
{
return (void*)m_window;
}
-
-void GHOST_WindowCocoa::setTitle(const STR_String& title)
-{
- GHOST_ASSERT(getValid(), "GHOST_WindowCocoa::setTitle(): window invalid")
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
- NSString *windowTitle = [[NSString alloc] initWithUTF8String:title];
-
- //Set associated file if applicable
- if ([windowTitle hasPrefix:@"Blender"])
- {
- NSRange fileStrRange;
- NSString *associatedFileName;
- int len;
-
- fileStrRange.location = [windowTitle rangeOfString:@"["].location+1;
- len = [windowTitle rangeOfString:@"]"].location - fileStrRange.location;
-
- if (len >0)
- {
- fileStrRange.length = len;
- associatedFileName = [windowTitle substringWithRange:fileStrRange];
- @try {
- [m_window setRepresentedFilename:associatedFileName];
- }
- @catch (NSException * e) {
- printf("\nInvalid file path given in window title");
- }
- [m_window setTitle:[associatedFileName lastPathComponent]];
- }
- else {
- [m_window setTitle:windowTitle];
- [m_window setRepresentedFilename:@""];
- }
-
- } else {
- [m_window setTitle:windowTitle];
- [m_window setRepresentedFilename:@""];
- }
-
-
- [windowTitle release];
- [pool drain];
-}
-
-
-void GHOST_WindowCocoa::getTitle(STR_String& title) const
-{
- GHOST_ASSERT(getValid(), "GHOST_WindowCocoa::getTitle(): window invalid")
-
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
- NSString *windowTitle = [m_window title];
-
- if (windowTitle != nil) {
- title = [windowTitle UTF8String];
- }
-
- [pool drain];
-}
-
-
-void GHOST_WindowCocoa::getWindowBounds(GHOST_Rect& bounds) const
-{
- NSRect rect;
- GHOST_ASSERT(getValid(), "GHOST_WindowCocoa::getWindowBounds(): window invalid")
-
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
- NSRect screenSize = [[m_window screen] visibleFrame];
-
- rect = [m_window frame];
-
- bounds.m_b = screenSize.size.height - (rect.origin.y -screenSize.origin.y);
- bounds.m_l = rect.origin.x -screenSize.origin.x;
- bounds.m_r = rect.origin.x-screenSize.origin.x + rect.size.width;
- bounds.m_t = screenSize.size.height - (rect.origin.y + rect.size.height -screenSize.origin.y);
-
- [pool drain];
-}
-
-
-void GHOST_WindowCocoa::getClientBounds(GHOST_Rect& bounds) const
-{
- NSRect rect;
- GHOST_ASSERT(getValid(), "GHOST_WindowCocoa::getClientBounds(): window invalid")
-
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
- if (!m_fullScreen)
- {
- NSRect screenSize = [[m_window screen] visibleFrame];
-
- //Max window contents as screen size (excluding title bar...)
- NSRect contentRect = [CocoaWindow contentRectForFrameRect:screenSize
- styleMask:(NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask)];
-
- rect = [m_window contentRectForFrameRect:[m_window frame]];
-
- bounds.m_b = contentRect.size.height - (rect.origin.y -contentRect.origin.y);
- bounds.m_l = rect.origin.x -contentRect.origin.x;
- bounds.m_r = rect.origin.x-contentRect.origin.x + rect.size.width;
- bounds.m_t = contentRect.size.height - (rect.origin.y + rect.size.height -contentRect.origin.y);
- }
- else {
- NSRect screenSize = [[m_window screen] frame];
-
- bounds.m_b = screenSize.origin.y + screenSize.size.height;
- bounds.m_l = screenSize.origin.x;
- bounds.m_r = screenSize.origin.x + screenSize.size.width;
- bounds.m_t = screenSize.origin.y;
- }
- [pool drain];
-}
-
-
-GHOST_TSuccess GHOST_WindowCocoa::setClientWidth(GHOST_TUns32 width)
-{
- GHOST_ASSERT(getValid(), "GHOST_WindowCocoa::setClientWidth(): window invalid")
- GHOST_Rect cBnds, wBnds;
- getClientBounds(cBnds);
- if (((GHOST_TUns32)cBnds.getWidth()) != width) {
- NSSize size;
- size.width=width;
- size.height=cBnds.getHeight();
- [m_window setContentSize:size];
- }
- return GHOST_kSuccess;
-}
-
-
-GHOST_TSuccess GHOST_WindowCocoa::setClientHeight(GHOST_TUns32 height)
-{
- GHOST_ASSERT(getValid(), "GHOST_WindowCocoa::setClientHeight(): window invalid")
- GHOST_Rect cBnds, wBnds;
- getClientBounds(cBnds);
- if (((GHOST_TUns32)cBnds.getHeight()) != height) {
- NSSize size;
- size.width=cBnds.getWidth();
- size.height=height;
- [m_window setContentSize:size];
- }
- return GHOST_kSuccess;
-}
-
-
-GHOST_TSuccess GHOST_WindowCocoa::setClientSize(GHOST_TUns32 width, GHOST_TUns32 height)
-{
- GHOST_ASSERT(getValid(), "GHOST_WindowCocoa::setClientSize(): window invalid")
- GHOST_Rect cBnds, wBnds;
- getClientBounds(cBnds);
- if ((((GHOST_TUns32)cBnds.getWidth()) != width) ||
- (((GHOST_TUns32)cBnds.getHeight()) != height)) {
- NSSize size;
- size.width=width;
- size.height=height;
- [m_window setContentSize:size];
- }
- return GHOST_kSuccess;
-}
-
-
-GHOST_TWindowState GHOST_WindowCocoa::getState() const
-{
- GHOST_ASSERT(getValid(), "GHOST_WindowCocoa::getState(): window invalid")
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- GHOST_TWindowState state;
- if (m_fullScreen) {
- state = GHOST_kWindowStateFullScreen;
- }
- else if ([m_window isMiniaturized]) {
- state = GHOST_kWindowStateMinimized;
- }
- else if ([m_window isZoomed]) {
- state = GHOST_kWindowStateMaximized;
- }
- else {
- state = GHOST_kWindowStateNormal;
- }
- [pool drain];
- return state;
-}
-
-
-void GHOST_WindowCocoa::screenToClient(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY) const
-{
- GHOST_ASSERT(getValid(), "GHOST_WindowCocoa::screenToClient(): window invalid")
-
- NSPoint screenCoord;
- NSPoint baseCoord;
-
- screenCoord.x = inX;
- screenCoord.y = inY;
-
- baseCoord = [m_window convertScreenToBase:screenCoord];
-
- outX = baseCoord.x;
- outY = baseCoord.y;
-}
-
-
-void GHOST_WindowCocoa::clientToScreen(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST_TInt32& outX, GHOST_TInt32& outY) const
-{
- GHOST_ASSERT(getValid(), "GHOST_WindowCocoa::clientToScreen(): window invalid")
-
- NSPoint screenCoord;
- NSPoint baseCoord;
-
- baseCoord.x = inX;
- baseCoord.y = inY;
-
- screenCoord = [m_window convertBaseToScreen:baseCoord];
-
- outX = screenCoord.x;
- outY = screenCoord.y;
-}
-
-
-<<<<<<< .working
-=======
+
void GHOST_WindowCocoa::setTitle(const STR_String& title)
{
GHOST_ASSERT(getValid(), "GHOST_WindowCocoa::setTitle(): window invalid")
@@ -918,50 +699,12 @@ void GHOST_WindowCocoa::clientToScreen(GHOST_TInt32 inX, GHOST_TInt32 inY, GHOST
}
->>>>>>> .merge-right.r30358
NSScreen* GHOST_WindowCocoa::getScreen()
{
return [m_window screen];
}
-<<<<<<< .working
-/**
- * @note Fullscreen switch is not actual fullscreen with display capture. As this capture removes all OS X window manager features.
- * Instead, the menu bar and the dock are hidden, and the window is made borderless and enlarged.
- * Thus, process switch, exposé, spaces, ... still work in fullscreen mode
- */
-GHOST_TSuccess GHOST_WindowCocoa::setState(GHOST_TWindowState state)
-{
- GHOST_ASSERT(getValid(), "GHOST_WindowCocoa::setState(): window invalid")
- switch (state) {
- case GHOST_kWindowStateMinimized:
- [m_window miniaturize:nil];
- break;
- case GHOST_kWindowStateMaximized:
- [m_window zoom:nil];
- break;
-
- case GHOST_kWindowStateFullScreen:
- if (!m_fullScreen)
- {
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
- //This status change needs to be done before Cocoa call to enter fullscreen mode
- //to give window delegate hint not to forward its deactivation to ghost wm that doesn't know view/window difference
- m_fullScreen = true;
-
-#ifdef MAC_OS_X_VERSION_10_6
- //10.6 provides Cocoa functions to autoshow menu bar, and to change a window style
- //Hide menu & dock if needed
- if ([[m_window screen] isEqual:[NSScreen mainScreen]])
- {
- [NSApp setPresentationOptions:(NSApplicationPresentationHideDock | NSApplicationPresentationAutoHideMenuBar)];
- }
- //Make window borderless and enlarge it
- [m_window setStyleMask:NSBorderlessWindowMask];
- [m_window setFrame:[[m_window screen] frame] display:YES];
-=======
/**
* @note Fullscreen switch is not actual fullscreen with display capture. As this capture removes all OS X window manager features.
* Instead, the menu bar and the dock are hidden, and the window is made borderless and enlarged.
@@ -997,67 +740,7 @@ GHOST_TSuccess GHOST_WindowCocoa::setState(GHOST_TWindowState state)
//Make window borderless and enlarge it
[m_window setStyleMask:NSBorderlessWindowMask];
[m_window setFrame:[[m_window screen] frame] display:YES];
->>>>>>> .merge-right.r30358
[m_window makeFirstResponder:m_openGLView];
-<<<<<<< .working
-#else
- //With 10.5, we need to create a new window to change its style to borderless
- //Hide menu & dock if needed
- if ([[m_window screen] isEqual:[NSScreen mainScreen]])
- {
- //Cocoa function in 10.5 does not allow to set the menu bar in auto-show mode [NSMenu setMenuBarVisible:NO];
- //One of the very few 64bit compatible Carbon function
- SetSystemUIMode(kUIModeAllHidden,kUIOptionAutoShowMenuBar);
- }
- //Create a fullscreen borderless window
- CocoaWindow *tmpWindow = [[CocoaWindow alloc]
- initWithContentRect:[[m_window screen] frame]
- styleMask:NSBorderlessWindowMask
- backing:NSBackingStoreBuffered
- defer:YES];
- //Copy current window parameters
- [tmpWindow setTitle:[m_window title]];
- [tmpWindow setRepresentedFilename:[m_window representedFilename]];
- [tmpWindow setReleasedWhenClosed:NO];
- [tmpWindow setAcceptsMouseMovedEvents:YES];
- [tmpWindow setDelegate:[m_window delegate]];
-
- //Assign the openGL view to the new window
- [tmpWindow setContentView:m_openGLView];
-
- //Show the new window
- [tmpWindow makeKeyAndOrderFront:nil];
- //Close and release old window
- [m_window setDelegate:nil]; // To avoid the notification of "window closed" event
- [m_window close];
- [m_window release];
- m_window = tmpWindow;
-#endif
-
- //Tell WM of view new size
- m_systemCocoa->handleWindowEvent(GHOST_kEventWindowSize, this);
-
- [pool drain];
- }
- break;
- case GHOST_kWindowStateNormal:
- default:
- if (m_fullScreen)
- {
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- m_fullScreen = false;
-
- //Exit fullscreen
-#ifdef MAC_OS_X_VERSION_10_6
- //Show again menu & dock if needed
- if ([[m_window screen] isEqual:[NSScreen mainScreen]])
- {
- [NSApp setPresentationOptions:NSApplicationPresentationDefault];
- }
- //Make window normal and resize it
- [m_window setStyleMask:(NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask)];
- [m_window setFrame:[[m_window screen] visibleFrame] display:YES];
-=======
#else
//With 10.5, we need to create a new window to change its style to borderless
//Hide menu & dock if needed
@@ -1115,164 +798,163 @@ GHOST_TSuccess GHOST_WindowCocoa::setState(GHOST_TWindowState state)
//Make window normal and resize it
[m_window setStyleMask:(NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask)];
[m_window setFrame:[[m_window screen] visibleFrame] display:YES];
->>>>>>> .merge-right.r30358
//TODO for 10.6 only : window title is forgotten after the style change
[m_window makeFirstResponder:m_openGLView];
-#else
- //With 10.5, we need to create a new window to change its style to borderless
- //Show menu & dock if needed
- if ([[m_window screen] isEqual:[NSScreen mainScreen]])
- {
- //Cocoa function in 10.5 does not allow to set the menu bar in auto-show mode [NSMenu setMenuBarVisible:YES];
- SetSystemUIMode(kUIModeNormal, 0); //One of the very few 64bit compatible Carbon function
- }
- //Create a fullscreen borderless window
- CocoaWindow *tmpWindow = [[CocoaWindow alloc]
- initWithContentRect:[[m_window screen] frame]
- styleMask:(NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask)
- backing:NSBackingStoreBuffered
- defer:YES];
- //Copy current window parameters
- [tmpWindow setTitle:[m_window title]];
- [tmpWindow setRepresentedFilename:[m_window representedFilename]];
- [tmpWindow setReleasedWhenClosed:NO];
- [tmpWindow setAcceptsMouseMovedEvents:YES];
- [tmpWindow setDelegate:[m_window delegate]];
-
- //Assign the openGL view to the new window
- [tmpWindow setContentView:m_openGLView];
-
- //Show the new window
- [tmpWindow makeKeyAndOrderFront:nil];
- //Close and release old window
- [m_window setDelegate:nil]; // To avoid the notification of "window closed" event
- [m_window close];
- [m_window release];
- m_window = tmpWindow;
-#endif
-
- //Tell WM of view new size
- m_systemCocoa->handleWindowEvent(GHOST_kEventWindowSize, this);
-
- [pool drain];
- }
- else if ([m_window isMiniaturized])
- [m_window deminiaturize:nil];
- else if ([m_window isZoomed])
- [m_window zoom:nil];
- break;
- }
- return GHOST_kSuccess;
-}
-
-GHOST_TSuccess GHOST_WindowCocoa::setModifiedState(bool isUnsavedChanges)
-{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
- [m_window setDocumentEdited:isUnsavedChanges];
-
- [pool drain];
- return GHOST_Window::setModifiedState(isUnsavedChanges);
-}
-
-
-
-GHOST_TSuccess GHOST_WindowCocoa::setOrder(GHOST_TWindowOrder order)
-{
+#else
+ //With 10.5, we need to create a new window to change its style to borderless
+ //Show menu & dock if needed
+ if ([[m_window screen] isEqual:[NSScreen mainScreen]])
+ {
+ //Cocoa function in 10.5 does not allow to set the menu bar in auto-show mode [NSMenu setMenuBarVisible:YES];
+ SetSystemUIMode(kUIModeNormal, 0); //One of the very few 64bit compatible Carbon function
+ }
+ //Create a fullscreen borderless window
+ CocoaWindow *tmpWindow = [[CocoaWindow alloc]
+ initWithContentRect:[[m_window screen] frame]
+ styleMask:(NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSResizableWindowMask)
+ backing:NSBackingStoreBuffered
+ defer:YES];
+ //Copy current window parameters
+ [tmpWindow setTitle:[m_window title]];
+ [tmpWindow setRepresentedFilename:[m_window representedFilename]];
+ [tmpWindow setReleasedWhenClosed:NO];
+ [tmpWindow setAcceptsMouseMovedEvents:YES];
+ [tmpWindow setDelegate:[m_window delegate]];
+
+ //Assign the openGL view to the new window
+ [tmpWindow setContentView:m_openGLView];
+
+ //Show the new window
+ [tmpWindow makeKeyAndOrderFront:nil];
+ //Close and release old window
+ [m_window setDelegate:nil]; // To avoid the notification of "window closed" event
+ [m_window close];
+ [m_window release];
+ m_window = tmpWindow;
+#endif
+
+ //Tell WM of view new size
+ m_systemCocoa->handleWindowEvent(GHOST_kEventWindowSize, this);
+
+ [pool drain];
+ }
+ else if ([m_window isMiniaturized])
+ [m_window deminiaturize:nil];
+ else if ([m_window isZoomed])
+ [m_window zoom:nil];
+ break;
+ }
+ return GHOST_kSuccess;
+}
+
+GHOST_TSuccess GHOST_WindowCocoa::setModifiedState(bool isUnsavedChanges)
+{
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- GHOST_ASSERT(getValid(), "GHOST_WindowCocoa::setOrder(): window invalid")
- if (order == GHOST_kWindowOrderTop) {
+ [m_window setDocumentEdited:isUnsavedChanges];
+
+ [pool drain];
+ return GHOST_Window::setModifiedState(isUnsavedChanges);
+}
+
+
+
+GHOST_TSuccess GHOST_WindowCocoa::setOrder(GHOST_TWindowOrder order)
+{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+ GHOST_ASSERT(getValid(), "GHOST_WindowCocoa::setOrder(): window invalid")
+ if (order == GHOST_kWindowOrderTop) {
[m_window makeKeyAndOrderFront:nil];
- }
- else {
+ }
+ else {
NSArray *windowsList;
- [m_window orderBack:nil];
+ [m_window orderBack:nil];
//Check for other blender opened windows and make the frontmost key
windowsList = [NSApp orderedWindows];
if ([windowsList count]) {
[[windowsList objectAtIndex:0] makeKeyAndOrderFront:nil];
}
- }
+ }
[pool drain];
- return GHOST_kSuccess;
-}
-
-#pragma mark Drawing context
-
-/*#define WAIT_FOR_VSYNC 1*/
-
-GHOST_TSuccess GHOST_WindowCocoa::swapBuffers()
-{
- if (m_drawingContextType == GHOST_kDrawingContextTypeOpenGL) {
- if (m_openGLContext != nil) {
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- [m_openGLContext flushBuffer];
- [pool drain];
- return GHOST_kSuccess;
- }
- }
- return GHOST_kFailure;
-}
-
-GHOST_TSuccess GHOST_WindowCocoa::updateDrawingContext()
-{
- if (m_drawingContextType == GHOST_kDrawingContextTypeOpenGL) {
- if (m_openGLContext != nil) {
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- [m_openGLContext update];
- [pool drain];
- return GHOST_kSuccess;
- }
- }
- return GHOST_kFailure;
-}
-
-GHOST_TSuccess GHOST_WindowCocoa::activateDrawingContext()
-{
- if (m_drawingContextType == GHOST_kDrawingContextTypeOpenGL) {
- if (m_openGLContext != nil) {
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- [m_openGLContext makeCurrentContext];
+ return GHOST_kSuccess;
+}
+
+#pragma mark Drawing context
+
+/*#define WAIT_FOR_VSYNC 1*/
+
+GHOST_TSuccess GHOST_WindowCocoa::swapBuffers()
+{
+ if (m_drawingContextType == GHOST_kDrawingContextTypeOpenGL) {
+ if (m_openGLContext != nil) {
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ [m_openGLContext flushBuffer];
+ [pool drain];
+ return GHOST_kSuccess;
+ }
+ }
+ return GHOST_kFailure;
+}
+
+GHOST_TSuccess GHOST_WindowCocoa::updateDrawingContext()
+{
+ if (m_drawingContextType == GHOST_kDrawingContextTypeOpenGL) {
+ if (m_openGLContext != nil) {
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ [m_openGLContext update];
+ [pool drain];
+ return GHOST_kSuccess;
+ }
+ }
+ return GHOST_kFailure;
+}
+
+GHOST_TSuccess GHOST_WindowCocoa::activateDrawingContext()
+{
+ if (m_drawingContextType == GHOST_kDrawingContextTypeOpenGL) {
+ if (m_openGLContext != nil) {
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ [m_openGLContext makeCurrentContext];
// Disable AA by default
if (m_numOfAASamples > 0) glDisable(GL_MULTISAMPLE_ARB);
- [pool drain];
- return GHOST_kSuccess;
- }
- }
- return GHOST_kFailure;
-}
-
-
-GHOST_TSuccess GHOST_WindowCocoa::installDrawingContext(GHOST_TDrawingContextType type)
-{
- GHOST_TSuccess success = GHOST_kFailure;
-
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
- NSOpenGLPixelFormat *pixelFormat;
- NSOpenGLContext *tmpOpenGLContext;
-
+ [pool drain];
+ return GHOST_kSuccess;
+ }
+ }
+ return GHOST_kFailure;
+}
+
+
+GHOST_TSuccess GHOST_WindowCocoa::installDrawingContext(GHOST_TDrawingContextType type)
+{
+ GHOST_TSuccess success = GHOST_kFailure;
+
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+
+ NSOpenGLPixelFormat *pixelFormat;
+ NSOpenGLContext *tmpOpenGLContext;
+
/***** Multithreaded opengl code : uncomment for enabling
CGLContextObj cglCtx;
*/
- switch (type) {
- case GHOST_kDrawingContextTypeOpenGL:
- if (!getValid()) break;
-
- pixelFormat = [m_openGLView pixelFormat];
- tmpOpenGLContext = [[NSOpenGLContext alloc] initWithFormat:pixelFormat
- shareContext:s_firstOpenGLcontext];
- if (tmpOpenGLContext == nil) {
- success = GHOST_kFailure;
- break;
- }
-
+ switch (type) {
+ case GHOST_kDrawingContextTypeOpenGL:
+ if (!getValid()) break;
+
+ pixelFormat = [m_openGLView pixelFormat];
+ tmpOpenGLContext = [[NSOpenGLContext alloc] initWithFormat:pixelFormat
+ shareContext:s_firstOpenGLcontext];
+ if (tmpOpenGLContext == nil) {
+ success = GHOST_kFailure;
+ break;
+ }
+
//Switch openGL to multhreaded mode
/******* Multithreaded opengl code : uncomment for enabling
cglCtx = (CGLContextObj)[tmpOpenGLContext CGLContextObj];
@@ -1280,130 +962,20 @@ GHOST_TSuccess GHOST_WindowCocoa::installDrawingContext(GHOST_TDrawingContextTyp
printf("\nSwitched openGL to multithreaded mode");
*/
- if (!s_firstOpenGLcontext) s_firstOpenGLcontext = tmpOpenGLContext;
-#ifdef WAIT_FOR_VSYNC
+ if (!s_firstOpenGLcontext) s_firstOpenGLcontext = tmpOpenGLContext;
+#ifdef WAIT_FOR_VSYNC
{
GLint swapInt = 1;
- /* wait for vsync, to avoid tearing artifacts */
+ /* wait for vsync, to avoid tearing artifacts */
[tmpOpenGLContext setValues:&swapInt forParameter:NSOpenGLCPSwapInterval];
}
-#endif
+#endif
[m_openGLView setOpenGLContext:tmpOpenGLContext];
[tmpOpenGLContext setView:m_openGLView];
m_openGLContext = tmpOpenGLContext;
- break;
-
-<<<<<<< .working
- case GHOST_kDrawingContextTypeNone:
- success = GHOST_kSuccess;
- break;
-
- default:
- break;
- }
- [pool drain];
- return success;
-}
-
-
-GHOST_TSuccess GHOST_WindowCocoa::removeDrawingContext()
-{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- switch (m_drawingContextType) {
- case GHOST_kDrawingContextTypeOpenGL:
- if (m_openGLContext)
- {
- [m_openGLView clearGLContext];
- if (s_firstOpenGLcontext == m_openGLContext) s_firstOpenGLcontext = nil;
- m_openGLContext = nil;
- }
- [pool drain];
- return GHOST_kSuccess;
- case GHOST_kDrawingContextTypeNone:
- [pool drain];
- return GHOST_kSuccess;
- break;
- default:
- [pool drain];
- return GHOST_kFailure;
- }
-}
-
-
-GHOST_TSuccess GHOST_WindowCocoa::invalidate()
-{
- GHOST_ASSERT(getValid(), "GHOST_WindowCocoa::invalidate(): window invalid")
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- [m_openGLView setNeedsDisplay:YES];
- [pool drain];
- return GHOST_kSuccess;
-}
-
-#pragma mark Cursor handling
-
-void GHOST_WindowCocoa::loadCursor(bool visible, GHOST_TStandardCursor cursor) const
-{
- static bool systemCursorVisible = true;
-
- NSAutoreleasePool *pool =[[NSAutoreleasePool alloc] init];
-
- NSCursor *tmpCursor =nil;
-
- if (visible != systemCursorVisible) {
- if (visible) {
- [NSCursor unhide];
- systemCursorVisible = true;
- }
- else {
- [NSCursor hide];
- systemCursorVisible = false;
- }
- }
-
- if (cursor == GHOST_kStandardCursorCustom && m_customCursor) {
- tmpCursor = m_customCursor;
- } else {
- switch (cursor) {
- case GHOST_kStandardCursorDestroy:
- tmpCursor = [NSCursor disappearingItemCursor];
- break;
- case GHOST_kStandardCursorText:
- tmpCursor = [NSCursor IBeamCursor];
- break;
- case GHOST_kStandardCursorCrosshair:
- tmpCursor = [NSCursor crosshairCursor];
- break;
- case GHOST_kStandardCursorUpDown:
- tmpCursor = [NSCursor resizeUpDownCursor];
- break;
- case GHOST_kStandardCursorLeftRight:
- tmpCursor = [NSCursor resizeLeftRightCursor];
- break;
- case GHOST_kStandardCursorTopSide:
- tmpCursor = [NSCursor resizeUpCursor];
- break;
- case GHOST_kStandardCursorBottomSide:
- tmpCursor = [NSCursor resizeDownCursor];
- break;
- case GHOST_kStandardCursorLeftSide:
- tmpCursor = [NSCursor resizeLeftCursor];
- break;
- case GHOST_kStandardCursorRightSide:
- tmpCursor = [NSCursor resizeRightCursor];
- break;
- case GHOST_kStandardCursorRightArrow:
- case GHOST_kStandardCursorInfo:
- case GHOST_kStandardCursorLeftArrow:
- case GHOST_kStandardCursorHelp:
- case GHOST_kStandardCursorCycle:
- case GHOST_kStandardCursorSpray:
- case GHOST_kStandardCursorWait:
- case GHOST_kStandardCursorTopLeftCorner:
- case GHOST_kStandardCursorTopRightCorner:
- case GHOST_kStandardCursorBottomRightCorner:
- case GHOST_kStandardCursorBottomLeftCorner:
-=======
+ break;
+
case GHOST_kDrawingContextTypeNone:
success = GHOST_kSuccess;
break;
@@ -1570,32 +1142,7 @@ void GHOST_WindowCocoa::loadCursor(bool visible, GHOST_TStandardCursor cursor) c
case GHOST_kStandardCursorTopRightCorner:
case GHOST_kStandardCursorBottomRightCorner:
case GHOST_kStandardCursorBottomLeftCorner:
->>>>>>> .merge-right.r30358
case GHOST_kStandardCursorCopy:
-<<<<<<< .working
- case GHOST_kStandardCursorDefault:
- default:
- tmpCursor = [NSCursor arrowCursor];
- break;
- };
- }
- [tmpCursor set];
- [pool drain];
-}
-
-
-
-GHOST_TSuccess GHOST_WindowCocoa::setWindowCursorVisibility(bool visible)
-{
- if ([m_window isVisible]) {
- loadCursor(visible, getCursorShape());
- }
-
- return GHOST_kSuccess;
-}
-
-
-=======
case GHOST_kStandardCursorDefault:
default:
tmpCursor = [NSCursor arrowCursor];
@@ -1620,21 +1167,20 @@ GHOST_TSuccess GHOST_WindowCocoa::setWindowCursorVisibility(bool visible)
}
->>>>>>> .merge-right.r30358
GHOST_TSuccess GHOST_WindowCocoa::setWindowCursorGrab(GHOST_TGrabCursorMode mode)
-{
+{
GHOST_TSuccess err = GHOST_kSuccess;
-
+
if (mode != GHOST_kGrabDisable)
- {
- //No need to perform grab without warp as it is always on in OS X
+ {
+ //No need to perform grab without warp as it is always on in OS X
if(mode != GHOST_kGrabNormal) {
- GHOST_TInt32 x_old,y_old;
+ GHOST_TInt32 x_old,y_old;
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
- m_systemCocoa->getCursorPosition(x_old,y_old);
+
+ m_systemCocoa->getCursorPosition(x_old,y_old);
screenToClient(x_old, y_old, m_cursorGrabInitPos[0], m_cursorGrabInitPos[1]);
- //Warp position is stored in client (window base) coordinates
+ //Warp position is stored in client (window base) coordinates
setCursorGrabAccum(0, 0);
if(mode == GHOST_kGrabHide) {
@@ -1648,86 +1194,21 @@ GHOST_TSuccess GHOST_WindowCocoa::setWindowCursorGrab(GHOST_TGrabCursorMode mode
err = CGAssociateMouseAndMouseCursorPosition(false) == kCGErrorSuccess ? GHOST_kSuccess : GHOST_kFailure;
[pool drain];
- }
- }
- else {
+ }
+ }
+ else {
if(m_cursorGrab==GHOST_kGrabHide)
{
//No need to set again cursor position, as it has not changed for Cocoa
- setWindowCursorVisibility(true);
- }
+ setWindowCursorVisibility(true);
+ }
err = CGAssociateMouseAndMouseCursorPosition(true) == kCGErrorSuccess ? GHOST_kSuccess : GHOST_kFailure;
/* Almost works without but important otherwise the mouse GHOST location can be incorrect on exit */
setCursorGrabAccum(0, 0);
m_cursorGrabBounds.m_l= m_cursorGrabBounds.m_r= -1; /* disable */
- }
+ }
return err;
-<<<<<<< .working
-}
-
-GHOST_TSuccess GHOST_WindowCocoa::setWindowCursorShape(GHOST_TStandardCursor shape)
-{
- if (m_customCursor) {
- [m_customCursor release];
- m_customCursor = nil;
- }
-
- if ([m_window isVisible]) {
- loadCursor(getCursorVisibility(), shape);
- }
-
- return GHOST_kSuccess;
-}
-
-/** Reverse the bits in a GHOST_TUns8
-static GHOST_TUns8 uns8ReverseBits(GHOST_TUns8 ch)
-{
- ch= ((ch>>1)&0x55) | ((ch<<1)&0xAA);
- ch= ((ch>>2)&0x33) | ((ch<<2)&0xCC);
- ch= ((ch>>4)&0x0F) | ((ch<<4)&0xF0);
- return ch;
-}
-*/
-
-
-/** Reverse the bits in a GHOST_TUns16 */
-static GHOST_TUns16 uns16ReverseBits(GHOST_TUns16 shrt)
-{
- shrt= ((shrt>>1)&0x5555) | ((shrt<<1)&0xAAAA);
- shrt= ((shrt>>2)&0x3333) | ((shrt<<2)&0xCCCC);
- shrt= ((shrt>>4)&0x0F0F) | ((shrt<<4)&0xF0F0);
- shrt= ((shrt>>8)&0x00FF) | ((shrt<<8)&0xFF00);
- return shrt;
-}
-
-GHOST_TSuccess GHOST_WindowCocoa::setWindowCustomCursorShape(GHOST_TUns8 *bitmap, GHOST_TUns8 *mask,
- int sizex, int sizey, int hotX, int hotY, int fg_color, int bg_color)
-{
- int y,nbUns16;
- NSPoint hotSpotPoint;
- NSBitmapImageRep *cursorImageRep;
- NSImage *cursorImage;
- NSSize imSize;
- GHOST_TUns16 *cursorBitmap;
-
-
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
- if (m_customCursor) {
- [m_customCursor release];
- m_customCursor = nil;
- }
-
-
- cursorImageRep = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:nil
- pixelsWide:sizex
- pixelsHigh:sizey
- bitsPerSample:1
- samplesPerPixel:2
- hasAlpha:YES
- isPlanar:YES
-=======
}
GHOST_TSuccess GHOST_WindowCocoa::setWindowCursorShape(GHOST_TStandardCursor shape)
@@ -1794,51 +1275,50 @@ GHOST_TSuccess GHOST_WindowCocoa::setWindowCustomCursorShape(GHOST_TUns8 *bitmap
samplesPerPixel:2
hasAlpha:YES
isPlanar:YES
->>>>>>> .merge-right.r30358
colorSpaceName:NSDeviceWhiteColorSpace
- bytesPerRow:(sizex/8 + (sizex%8 >0 ?1:0))
- bitsPerPixel:1];
-
-
- cursorBitmap = (GHOST_TUns16*)[cursorImageRep bitmapData];
- nbUns16 = [cursorImageRep bytesPerPlane]/2;
-
- for (y=0; y<nbUns16; y++) {
-#if !defined(__LITTLE_ENDIAN__)
+ bytesPerRow:(sizex/8 + (sizex%8 >0 ?1:0))
+ bitsPerPixel:1];
+
+
+ cursorBitmap = (GHOST_TUns16*)[cursorImageRep bitmapData];
+ nbUns16 = [cursorImageRep bytesPerPlane]/2;
+
+ for (y=0; y<nbUns16; y++) {
+#if !defined(__LITTLE_ENDIAN__)
cursorBitmap[y] = ~uns16ReverseBits((bitmap[2*y]<<0) | (bitmap[2*y+1]<<8));
- cursorBitmap[nbUns16+y] = uns16ReverseBits((mask[2*y]<<0) | (mask[2*y+1]<<8));
-#else
+ cursorBitmap[nbUns16+y] = uns16ReverseBits((mask[2*y]<<0) | (mask[2*y+1]<<8));
+#else
cursorBitmap[y] = ~uns16ReverseBits((bitmap[2*y+1]<<0) | (bitmap[2*y]<<8));
- cursorBitmap[nbUns16+y] = uns16ReverseBits((mask[2*y+1]<<0) | (mask[2*y]<<8));
-#endif
-
- }
-
-
- imSize.width = sizex;
- imSize.height= sizey;
- cursorImage = [[NSImage alloc] initWithSize:imSize];
- [cursorImage addRepresentation:cursorImageRep];
-
- hotSpotPoint.x = hotX;
- hotSpotPoint.y = hotY;
-
- //foreground and background color parameter is not handled for now (10.6)
- m_customCursor = [[NSCursor alloc] initWithImage:cursorImage
- hotSpot:hotSpotPoint];
-
- [cursorImageRep release];
- [cursorImage release];
-
- if ([m_window isVisible]) {
- loadCursor(getCursorVisibility(), GHOST_kStandardCursorCustom);
- }
- [pool drain];
- return GHOST_kSuccess;
-}
-
-GHOST_TSuccess GHOST_WindowCocoa::setWindowCustomCursorShape(GHOST_TUns8 bitmap[16][2],
- GHOST_TUns8 mask[16][2], int hotX, int hotY)
-{
- return setWindowCustomCursorShape((GHOST_TUns8*)bitmap, (GHOST_TUns8*) mask, 16, 16, hotX, hotY, 0, 1);
-}
+ cursorBitmap[nbUns16+y] = uns16ReverseBits((mask[2*y+1]<<0) | (mask[2*y]<<8));
+#endif
+
+ }
+
+
+ imSize.width = sizex;
+ imSize.height= sizey;
+ cursorImage = [[NSImage alloc] initWithSize:imSize];
+ [cursorImage addRepresentation:cursorImageRep];
+
+ hotSpotPoint.x = hotX;
+ hotSpotPoint.y = hotY;
+
+ //foreground and background color parameter is not handled for now (10.6)
+ m_customCursor = [[NSCursor alloc] initWithImage:cursorImage
+ hotSpot:hotSpotPoint];
+
+ [cursorImageRep release];
+ [cursorImage release];
+
+ if ([m_window isVisible]) {
+ loadCursor(getCursorVisibility(), GHOST_kStandardCursorCustom);
+ }
+ [pool drain];
+ return GHOST_kSuccess;
+}
+
+GHOST_TSuccess GHOST_WindowCocoa::setWindowCustomCursorShape(GHOST_TUns8 bitmap[16][2],
+ GHOST_TUns8 mask[16][2], int hotX, int hotY)
+{
+ return setWindowCustomCursorShape((GHOST_TUns8*)bitmap, (GHOST_TUns8*) mask, 16, 16, hotX, hotY, 0, 1);
+}