Revision: 30651
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=30651
Author: merwin
Date: 2010-07-23 12:03:22 +0200 (Fri, 23 Jul 2010)
Log Message:
-----------
mostly formatting: put SystemCocoa on a diet of a thousand tabs, also spotted
and fixed a leaky switch-case (trackpad gesture for 'rotate')
Modified Paths:
--------------
branches/soc-2010-merwin/intern/ghost/intern/GHOST_SystemCocoa.mm
Modified: branches/soc-2010-merwin/intern/ghost/intern/GHOST_SystemCocoa.mm
===================================================================
--- branches/soc-2010-merwin/intern/ghost/intern/GHOST_SystemCocoa.mm
2010-07-23 09:33:58 UTC (rev 30650)
+++ branches/soc-2010-merwin/intern/ghost/intern/GHOST_SystemCocoa.mm
2010-07-23 10:03:22 UTC (rev 30651)
@@ -235,8 +235,8 @@
* @return Ghost key code
*/
static GHOST_TKey convertKey(int rawCode, unichar recvChar, UInt16 keyAction)
-{
-
+{
+
//printf("\nrecvchar %c 0x%x",recvChar,recvChar);
switch (rawCode) {
/*Physical keycodes not used due to map changes in int'l
keyboards
@@ -266,7 +266,7 @@
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;
@@ -279,7 +279,7 @@
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;
@@ -318,24 +318,24 @@
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;
@@ -347,12 +347,12 @@
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:
/* alphanumerical or punctuation key that is remappable
in int'l keyboards */
if ((recvChar >= 'A') && (recvChar <= 'Z')) {
@@ -363,42 +363,38 @@
#if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4
KeyboardLayoutRef keyLayout;
UCKeyboardLayout *uchrData;
-
+
KLGetCurrentKeyboardLayout(&keyLayout);
KLGetKeyboardLayoutProperty(keyLayout,
kKLuchrData, (const void **)
&uchrData);
/*get actual character value of the
"remappable" keys in int'l keyboards,
if keyboard layout is not correctly reported
(e.g. some non Apple keyboards in Tiger),
then fallback on using the received
charactersIgnoringModifiers */
- if (uchrData)
- {
+ if (uchrData) {
UInt32 deadKeyState=0;
UniCharCount actualStrLength=0;
-
+
UCKeyTranslate(uchrData, rawCode,
keyAction, 0,
-
LMGetKbdType(), kUCKeyTranslateNoDeadKeysBit, &deadKeyState, 1,
&actualStrLength, &recvChar);
-
- }
+ LMGetKbdType(),
kUCKeyTranslateNoDeadKeysBit, &deadKeyState, 1, &actualStrLength, &recvChar);
+ }
#else
/* Leopard and Snow Leopard 64bit compatible
API*/
CFDataRef uchrHandle; /*the keyboard layout*/
TISInputSourceRef kbdTISHandle;
-
+
kbdTISHandle =
TISCopyCurrentKeyboardLayoutInputSource();
uchrHandle =
(CFDataRef)TISGetInputSourceProperty(kbdTISHandle,kTISPropertyUnicodeKeyLayoutData);
CFRelease(kbdTISHandle);
-
+
/*get actual character value of the
"remappable" keys in int'l keyboards,
if keyboard layout is not correctly reported
(e.g. some non Apple keyboards in Tiger),
then fallback on using the received
charactersIgnoringModifiers */
- if (uchrHandle)
- {
+ if (uchrHandle) {
UInt32 deadKeyState=0;
UniCharCount actualStrLength=0;
-
+
UCKeyTranslate((UCKeyboardLayout*)CFDataGetBytePtr(uchrHandle), rawCode,
keyAction, 0,
LMGetKbdType(), kUCKeyTranslateNoDeadKeysBit, &deadKeyState, 1,
&actualStrLength, &recvChar);
-
}
#endif
switch (recvChar) {
@@ -476,9 +472,9 @@
{
int result;
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-
+
result = fromcocoa_request_qtcodec_settings(C, op);
-
+
[pool drain];
return result;
}
@@ -549,7 +545,7 @@
struct timeval boottime;
size_t len;
char *rstring = NULL;
-
+
m_modifierMask =0;
m_pressedMouseButtons =0;
m_isGestureInProgress = false;
@@ -568,27 +564,27 @@
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;
sysctl( mib, 2, NULL, &len, NULL, 0 );
rstring = (char*)malloc( len );
sysctl( mib, 2, rstring, &len, NULL, 0 );
-
+
//Hack on MacBook revision, as multitouch avail. function missing
m_hasMultiTouchTrackpad =
(strstr(rstring,"MacBookAir") ||
(strstr(rstring,"MacBook") && (rstring[strlen(rstring)-3]>='5')
&& (rstring[strlen(rstring)-3]<='9')));
-
+
free( rstring );
rstring = NULL;
-
+
m_ignoreWindowSizedMessages = false;
-
+
m_input_fidelity_hint = HI_FI; // just for testing...
}
@@ -599,63 +595,63 @@
GHOST_TSuccess GHOST_SystemCocoa::init()
{
- GHOST_TSuccess success = GHOST_System::init();
- if (success) {
+ GHOST_TSuccess success = GHOST_System::init();
+ if (success) {
m_ndofManager = new GHOST_NDOFManagerCocoa(*this);
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];
@@ -666,12 +662,12 @@
[appDelegate setSystemCocoa:this];
[NSApp setDelegate:appDelegate];
}
-
+
[NSApp finishLaunching];
-
+
[pool drain];
- }
- return success;
+ }
+ return success;
}
@@ -681,11 +677,10 @@
{
//Cocoa equivalent exists in 10.6 ([[NSProcessInfo processInfo]
systemUptime])
struct timeval currentTime;
-
+
gettimeofday(¤tTime, NULL);
-
+
//Return timestamp of system uptime
-
return
((currentTime.tv_sec*1000)+(currentTime.tv_usec/1000)-m_start_time);
}
@@ -708,11 +703,11 @@
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;
@@ -721,7 +716,7 @@
GHOST_IWindow* GHOST_SystemCocoa::createWindow(
- const STR_String& title,
+ const STR_String& title,
GHOST_TInt32 left,
GHOST_TInt32 top,
GHOST_TUns32 width,
@@ -733,59 +728,58 @@
const GHOST_TEmbedderWindowID parentWindow
)
{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ 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);
- if (window) {
- if (window->getValid()) {
@@ Diff output truncated at 10240 characters. @@
_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs