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
diff options
context:
space:
mode:
authorJoseph Eagar <joeedh@gmail.com>2009-11-08 02:10:18 +0300
committerJoseph Eagar <joeedh@gmail.com>2009-11-08 02:10:18 +0300
commit2ead17843c08c9c4ed211010c0ad4d2a5c31a99c (patch)
tree0fc77499284278cdf8b017eac803910c87b4e07a /intern/ghost
parentcfa4f3222a427eff1991e8fd2c341ce4ca5385bd (diff)
parent4e9699debff6b0ac7e3bfc91d615e071218a67db (diff)
merge with trunk/2.5 at r24378
Diffstat (limited to 'intern/ghost')
-rw-r--r--intern/ghost/SConscript18
-rw-r--r--intern/ghost/intern/GHOST_SystemCocoa.mm160
-rw-r--r--intern/ghost/intern/GHOST_SystemWin32.cpp16
-rw-r--r--intern/ghost/intern/GHOST_SystemWin32.h4
-rw-r--r--intern/ghost/intern/GHOST_WindowCocoa.mm37
5 files changed, 68 insertions, 167 deletions
diff --git a/intern/ghost/SConscript b/intern/ghost/SConscript
index 48009152699..490b45afc1f 100644
--- a/intern/ghost/SConscript
+++ b/intern/ghost/SConscript
@@ -7,6 +7,9 @@ Import ('env')
window_system = env['OURPLATFORM']
sources = env.Glob('intern/*.cpp')
+if window_system == 'darwin':
+ sources += env.Glob('intern/*.mm')
+
pf = ['GHOST_DisplayManager', 'GHOST_System', 'GHOST_Window']
@@ -19,9 +22,17 @@ elif window_system in ('win32-vc', 'win32-mingw', 'cygwin', 'linuxcross', 'win64
sources.remove('intern' + os.sep + f + 'X11.cpp')
sources.remove('intern' + os.sep + f + 'Carbon.cpp')
elif window_system == 'darwin':
- for f in pf:
- sources.remove('intern' + os.sep + f + 'Win32.cpp')
- sources.remove('intern' + os.sep + f + 'X11.cpp')
+ if env['WITH_GHOST_COCOA']:
+ for f in pf:
+ sources.remove('intern' + os.sep + f + 'Win32.cpp')
+ sources.remove('intern' + os.sep + f + 'X11.cpp')
+ sources.remove('intern' + os.sep + f + 'Carbon.cpp')
+ else:
+ for f in pf:
+ sources.remove('intern' + os.sep + f + 'Win32.cpp')
+ sources.remove('intern' + os.sep + f + 'X11.cpp')
+ sources.remove('intern' + os.sep + f + 'Cocoa.mm')
+
else:
print "Unknown window system specified."
Exit()
@@ -30,3 +41,4 @@ incs = '. ../string ' + env['BF_OPENGL_INC']
if window_system in ('win32-vc', 'win32-mingw', 'cygwin', 'linuxcross', 'win64-vc'):
incs = env['BF_WINTAB_INC'] + ' ' + incs
env.BlenderLib ('bf_ghost', sources, Split(incs), defines=['_USE_MATH_DEFINES'], libtype=['intern','player'], priority = [40,15] )
+
diff --git a/intern/ghost/intern/GHOST_SystemCocoa.mm b/intern/ghost/intern/GHOST_SystemCocoa.mm
index b476ee8f0f2..46d8ecf6f94 100644
--- a/intern/ghost/intern/GHOST_SystemCocoa.mm
+++ b/intern/ghost/intern/GHOST_SystemCocoa.mm
@@ -372,133 +372,6 @@ static GHOST_TKey convertKey(int rawCode, unichar recvChar)
return GHOST_kKeyUnknown;
}
-/* MacOSX returns a Roman charset with kEventParamKeyMacCharCodes
- * as defined here: http://developer.apple.com/documentation/mac/Text/Text-516.html
- * I am not sure how international this works...
- * For cross-platform convention, we'll use the Latin ascii set instead.
- * As defined at: http://www.ramsch.org/martin/uni/fmi-hp/iso8859-1.html
- *
- */
-static unsigned char convertRomanToLatin(unsigned char ascii)
-{
-
- if(ascii<128) return ascii;
-
- switch(ascii) {
- case 128: return 142;
- case 129: return 143;
- case 130: return 128;
- case 131: return 201;
- case 132: return 209;
- case 133: return 214;
- case 134: return 220;
- case 135: return 225;
- case 136: return 224;
- case 137: return 226;
- case 138: return 228;
- case 139: return 227;
- case 140: return 229;
- case 141: return 231;
- case 142: return 233;
- case 143: return 232;
- case 144: return 234;
- case 145: return 235;
- case 146: return 237;
- case 147: return 236;
- case 148: return 238;
- case 149: return 239;
- case 150: return 241;
- case 151: return 243;
- case 152: return 242;
- case 153: return 244;
- case 154: return 246;
- case 155: return 245;
- case 156: return 250;
- case 157: return 249;
- case 158: return 251;
- case 159: return 252;
- case 160: return 0;
- case 161: return 176;
- case 162: return 162;
- case 163: return 163;
- case 164: return 167;
- case 165: return 183;
- case 166: return 182;
- case 167: return 223;
- case 168: return 174;
- case 169: return 169;
- case 170: return 174;
- case 171: return 180;
- case 172: return 168;
- case 173: return 0;
- case 174: return 198;
- case 175: return 216;
- case 176: return 0;
- case 177: return 177;
- case 178: return 0;
- case 179: return 0;
- case 180: return 165;
- case 181: return 181;
- case 182: return 0;
- case 183: return 0;
- case 184: return 215;
- case 185: return 0;
- case 186: return 0;
- case 187: return 170;
- case 188: return 186;
- case 189: return 0;
- case 190: return 230;
- case 191: return 248;
- case 192: return 191;
- case 193: return 161;
- case 194: return 172;
- case 195: return 0;
- case 196: return 0;
- case 197: return 0;
- case 198: return 0;
- case 199: return 171;
- case 200: return 187;
- case 201: return 201;
- case 202: return 0;
- case 203: return 192;
- case 204: return 195;
- case 205: return 213;
- case 206: return 0;
- case 207: return 0;
- case 208: return 0;
- case 209: return 0;
- case 210: return 0;
-
- case 214: return 247;
-
- case 229: return 194;
- case 230: return 202;
- case 231: return 193;
- case 232: return 203;
- case 233: return 200;
- case 234: return 205;
- case 235: return 206;
- case 236: return 207;
- case 237: return 204;
- case 238: return 211;
- case 239: return 212;
- case 240: return 0;
- case 241: return 210;
- case 242: return 218;
- case 243: return 219;
- case 244: return 217;
- case 245: return 0;
- case 246: return 0;
- case 247: return 0;
- case 248: return 0;
- case 249: return 0;
- case 250: return 0;
-
-
- default: return 0;
- }
-
-}
#define FIRSTFILEBUFLG 512
static bool g_hasFirstFile = false;
@@ -827,7 +700,7 @@ GHOST_TSuccess GHOST_SystemCocoa::setCursorPosition(GHOST_TInt32 x, GHOST_TInt32
//Quartz Display Services uses the old coordinates (top left origin)
yf = screenRect.size.height -yf;
- CGDisplayMoveCursorToPoint([[[windowScreen deviceDescription] objectForKey:@"NSScreenNumber"] unsignedIntValue], CGPointMake(xf, yf));
+ CGDisplayMoveCursorToPoint((CGDirectDisplayID)[[[windowScreen deviceDescription] objectForKey:@"NSScreenNumber"] unsignedIntValue], CGPointMake(xf, yf));
return GHOST_kSuccess;
}
@@ -913,7 +786,7 @@ bool GHOST_SystemCocoa::processEvents(bool waitForEvent)
case NSFlagsChanged:
handleKeyEvent(event);
- /* Support system-wide keyboard shortcuts, like Exposé, ...) =>included in always NSApp sendEvent */
+ /* Support system-wide keyboard shortcuts, like Exposé, ...) =>included in always NSApp sendEvent */
/* if (([event modifierFlags] & NSCommandKeyMask) || [event type] == NSFlagsChanged) {
[NSApp sendEvent:event];
}*/
@@ -1018,8 +891,8 @@ GHOST_TUns8 GHOST_SystemCocoa::handleQuitRequest()
//Check open windows if some changes are not saved
if (m_windowManager->getAnyModifiedState())
{
- int shouldQuit = NSRunAlertPanel(@"Exit Blender", @"Some changes have not been saved. Do you really want to quit ?",
- @"Cancel", @"Quit anyway", nil);
+ 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) );
@@ -1255,8 +1128,10 @@ GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent(void *eventPtr)
GHOST_IWindow* window = m_windowManager->getActiveWindow();
unsigned int modifiers;
NSString *characters;
+ NSData *convertedCharacters;
GHOST_TKey keyCode;
unsigned char ascii;
+ NSString* charsIgnoringModifiers;
/* Can happen, very rarely - seems to only be when command-H makes
* the window go away and we still get an HKey up.
@@ -1269,16 +1144,25 @@ GHOST_TSuccess GHOST_SystemCocoa::handleKeyEvent(void *eventPtr)
switch ([event type]) {
case NSKeyDown:
case NSKeyUp:
- characters = [event characters];
- if ([characters length]) { //Check for dead keys
+ charsIgnoringModifiers = [event charactersIgnoringModifiers];
+ if ([charsIgnoringModifiers length]>0)
keyCode = convertKey([event keyCode],
- [[event charactersIgnoringModifiers] characterAtIndex:0]);
- ascii= convertRomanToLatin((char)[characters characterAtIndex:0]);
- } else {
+ [charsIgnoringModifiers characterAtIndex:0]);
+ else
keyCode = convertKey([event keyCode],0);
- ascii= 0;
+
+
+ characters = [event characters];
+ if ([characters length]>0) { //Check for dead keys
+ //Convert characters to iso latin 1 encoding
+ convertedCharacters = [characters dataUsingEncoding:NSISOLatin1StringEncoding];
+ if ([convertedCharacters length]>0)
+ 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
diff --git a/intern/ghost/intern/GHOST_SystemWin32.cpp b/intern/ghost/intern/GHOST_SystemWin32.cpp
index 2e89be40bcb..8a17d455695 100644
--- a/intern/ghost/intern/GHOST_SystemWin32.cpp
+++ b/intern/ghost/intern/GHOST_SystemWin32.cpp
@@ -132,8 +132,8 @@
GHOST_SystemWin32::GHOST_SystemWin32()
: m_hasPerformanceCounter(false), m_freq(0), m_start(0),
- m_seperateLeftRight(false),
- m_seperateLeftRightInitialized(false)
+ m_separateLeftRight(false),
+ m_separateLeftRightInitialized(false)
{
m_displayManager = new GHOST_DisplayManagerWin32 ();
GHOST_ASSERT(m_displayManager, "GHOST_SystemWin32::GHOST_SystemWin32(): m_displayManager==0\n");
@@ -274,7 +274,7 @@ GHOST_TSuccess GHOST_SystemWin32::getModifierKeys(GHOST_ModifierKeys& keys) cons
It didn't work all that well on some newer hardware, and worked less
well with the passage of time, so it was fully disabled in ME.
*/
- if (m_seperateLeftRight && m_seperateLeftRightInitialized) {
+ if (m_separateLeftRight && m_separateLeftRightInitialized) {
bool down = HIBYTE(::GetKeyState(VK_LSHIFT)) != 0;
keys.set(GHOST_kModifierKeyLeftShift, down);
down = HIBYTE(::GetKeyState(VK_RSHIFT)) != 0;
@@ -581,29 +581,29 @@ LRESULT WINAPI GHOST_SystemWin32::s_wndProc(HWND hwnd, UINT msg, WPARAM wParam,
case VK_SHIFT:
case VK_CONTROL:
case VK_MENU:
- if (!system->m_seperateLeftRightInitialized) {
+ if (!system->m_separateLeftRightInitialized) {
// Check whether this system supports seperate left and right keys
switch (wParam) {
case VK_SHIFT:
- system->m_seperateLeftRight =
+ system->m_separateLeftRight =
(HIBYTE(::GetKeyState(VK_LSHIFT)) != 0) ||
(HIBYTE(::GetKeyState(VK_RSHIFT)) != 0) ?
true : false;
break;
case VK_CONTROL:
- system->m_seperateLeftRight =
+ system->m_separateLeftRight =
(HIBYTE(::GetKeyState(VK_LCONTROL)) != 0) ||
(HIBYTE(::GetKeyState(VK_RCONTROL)) != 0) ?
true : false;
break;
case VK_MENU:
- system->m_seperateLeftRight =
+ system->m_separateLeftRight =
(HIBYTE(::GetKeyState(VK_LMENU)) != 0) ||
(HIBYTE(::GetKeyState(VK_RMENU)) != 0) ?
true : false;
break;
}
- system->m_seperateLeftRightInitialized = true;
+ system->m_separateLeftRightInitialized = true;
}
system->processModifierKeys(window);
// Bypass call to DefWindowProc
diff --git a/intern/ghost/intern/GHOST_SystemWin32.h b/intern/ghost/intern/GHOST_SystemWin32.h
index 9387b6cad50..6a12975a3dd 100644
--- a/intern/ghost/intern/GHOST_SystemWin32.h
+++ b/intern/ghost/intern/GHOST_SystemWin32.h
@@ -283,9 +283,9 @@ protected:
/** High frequency timer variable. */
__int64 m_start;
/** Stores the capability of this system to distinguish left and right modifier keys. */
- bool m_seperateLeftRight;
+ bool m_separateLeftRight;
/** Stores the initialization state of the member m_leftRightDistinguishable. */
- bool m_seperateLeftRightInitialized;
+ bool m_separateLeftRightInitialized;
};
diff --git a/intern/ghost/intern/GHOST_WindowCocoa.mm b/intern/ghost/intern/GHOST_WindowCocoa.mm
index aac12e80893..9613ee64ef4 100644
--- a/intern/ghost/intern/GHOST_WindowCocoa.mm
+++ b/intern/ghost/intern/GHOST_WindowCocoa.mm
@@ -43,16 +43,6 @@
#include "GHOST_Debug.h"
-// Pixel Format Attributes for the windowed NSOpenGLContext
-static NSOpenGLPixelFormatAttribute pixelFormatAttrsWindow[] =
-{
- NSOpenGLPFADoubleBuffer,
- NSOpenGLPFAAccelerated,
- //NSOpenGLPFAAllowOfflineRenderers, // Removed to allow 10.4 builds, and 2 GPUs rendering is not used anyway
- NSOpenGLPFADepthSize, (NSOpenGLPixelFormatAttribute) 32,
- (NSOpenGLPixelFormatAttribute) 0
-};
-
#pragma mark Cocoa window delegate object
/* live resize ugly patch
extern "C" {
@@ -78,7 +68,7 @@ extern "C" {
- (void)windowWillClose:(NSNotification *)notification;
- (void)windowDidBecomeKey:(NSNotification *)notification;
- (void)windowDidResignKey:(NSNotification *)notification;
-- (void)windowDidUpdate:(NSNotification *)notification;
+- (void)windowDidExpose:(NSNotification *)notification;
- (void)windowDidResize:(NSNotification *)notification;
@end
@@ -101,13 +91,10 @@ extern "C" {
- (void)windowDidResignKey:(NSNotification *)notification
{
- //The window is no more key when its own view becomes fullscreen
- //but ghost doesn't know the view/window difference, so hide this fact
- if (associatedWindow->getState() != GHOST_kWindowStateFullScreen)
systemCocoa->handleWindowEvent(GHOST_kEventWindowDeactivate, associatedWindow);
}
-- (void)windowDidUpdate:(NSNotification *)notification
+- (void)windowDidExpose:(NSNotification *)notification
{
systemCocoa->handleWindowEvent(GHOST_kEventWindowUpdate, associatedWindow);
}
@@ -191,9 +178,12 @@ GHOST_WindowCocoa::GHOST_WindowCocoa(
GHOST_TDrawingContextType type,
const bool stereoVisual
) :
- GHOST_Window(title, left, top, width, height, state, GHOST_kDrawingContextTypeNone),
+ GHOST_Window(title, left, top, width, height, state, GHOST_kDrawingContextTypeNone, stereoVisual),
m_customCursor(0)
{
+ NSOpenGLPixelFormatAttribute pixelFormatAttrsWindow[40];
+ int i;
+
m_systemCocoa = systemCocoa;
m_fullScreen = false;
@@ -225,6 +215,20 @@ GHOST_WindowCocoa::GHOST_WindowCocoa(
setTitle(title);
+ // Pixel Format Attributes for the windowed NSOpenGLContext
+ i=0;
+ pixelFormatAttrsWindow[i++] = NSOpenGLPFADoubleBuffer;
+ pixelFormatAttrsWindow[i++] = NSOpenGLPFAAccelerated;
+ //pixelFormatAttrsWindow[i++] = NSOpenGLPFAAllowOfflineRenderers,; // Removed to allow 10.4 builds, and 2 GPUs rendering is not used anyway
+
+ pixelFormatAttrsWindow[i++] = NSOpenGLPFADepthSize;
+ pixelFormatAttrsWindow[i++] = (NSOpenGLPixelFormatAttribute) 32;
+
+ if (stereoVisual) pixelFormatAttrsWindow[i++] = NSOpenGLPFAStereo;
+
+ pixelFormatAttrsWindow[i] = (NSOpenGLPixelFormatAttribute) 0;
+
+
//Creates the OpenGL View inside the window
NSOpenGLPixelFormat *pixelFormat =
[[NSOpenGLPixelFormat alloc] initWithAttributes:pixelFormatAttrsWindow];
@@ -615,6 +619,7 @@ 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];
+ //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