From bfc0b2ea2b598b7074973ffadfef241a99eba770 Mon Sep 17 00:00:00 2001 From: David Rose Date: Wed, 4 Nov 2009 19:52:25 +0000 Subject: [PATCH] BundlePath is always set in 10.4 --- panda/src/osxdisplay/osxGraphicsWindow.mm | 33 ++++++- .../src/tinydisplay/tinyOsxGraphicsWindow.mm | 91 ++++++++++++------- 2 files changed, 85 insertions(+), 39 deletions(-) diff --git a/panda/src/osxdisplay/osxGraphicsWindow.mm b/panda/src/osxdisplay/osxGraphicsWindow.mm index fced577cf2..8d834ac6d2 100644 --- a/panda/src/osxdisplay/osxGraphicsWindow.mm +++ b/panda/src/osxdisplay/osxGraphicsWindow.mm @@ -1059,11 +1059,34 @@ os_open_window(WindowProperties &req_properties) { // Determine if we're running from a bundle. CFDictionaryRef dref = ProcessInformationCopyDictionary(&psn, kProcessDictionaryIncludeAllInformationMask); - // If the dictionary doesn't have "BundlePath", then we're not - // running from a bundle, and we need to call TransformProcessType - // to make the process a "foreground" application, with its own - // icon in the dock and such. - if (!CFDictionaryContainsKey(dref, CFSTR("BundlePath"))) { + // If the dictionary doesn't have "BundlePath" (or the BundlePath + // is the same as the executable path), then we're not running + // from a bundle, and we need to call TransformProcessType to make + // the process a "foreground" application, with its own icon in + // the dock and such. + + bool has_bundle = false; + + CFStringRef bundle_path = (CFStringRef)CFDictionaryGetValue(dref, CFSTR("BundlePath")); + if (bundle_path != NULL) { + // OK, we have a bundle path. We're probably running in a + // bundle . . . + has_bundle = true; + + // . . . unless it turns out it's the same as the executable + // path. + CFStringRef exe_path = (CFStringRef)CFDictionaryGetValue(dref, kCFBundleExecutableKey); + if (exe_path != NULL) { + if (CFStringCompare(bundle_path, exe_path, kCFCompareCaseInsensitive) == kCFCompareEqualTo) { + has_bundle = false; + } + CFRelease(exe_path); + } + + CFRelease(bundle_path); + } + + if (!has_bundle) { TransformProcessType(&psn, kProcessTransformToForegroundApplication); } SetFrontProcess(&psn); diff --git a/panda/src/tinydisplay/tinyOsxGraphicsWindow.mm b/panda/src/tinydisplay/tinyOsxGraphicsWindow.mm index 311af99a7f..ac178ff309 100644 --- a/panda/src/tinydisplay/tinyOsxGraphicsWindow.mm +++ b/panda/src/tinydisplay/tinyOsxGraphicsWindow.mm @@ -854,45 +854,68 @@ bool TinyOsxGraphicsWindow::OSOpenWindow(WindowProperties &req_properties) static bool GlobalInits = false; if (!GlobalInits) - { - // - // one time aplication inits.. to get a window open from a standalone aplication.. + { + // + // one time aplication inits.. to get a window open from a standalone aplication.. - EventHandlerRef application_event_ref_ref1; - EventTypeSpec list1[] = - { - //{ kEventClassCommand, kEventProcessCommand }, - //{ kEventClassCommand, kEventCommandUpdateStatus }, - { kEventClassMouse, kEventMouseDown },// handle trackball functionality globaly because there is only a single user - { kEventClassMouse, kEventMouseUp }, - { kEventClassMouse, kEventMouseMoved }, - { kEventClassMouse, kEventMouseDragged }, - { kEventClassMouse, kEventMouseWheelMoved } , - { kEventClassKeyboard, kEventRawKeyDown }, - { kEventClassKeyboard, kEventRawKeyUp } , - { kEventClassKeyboard, kEventRawKeyRepeat }, - { kEventClassKeyboard, kEventRawKeyModifiersChanged } , - { kEventClassTextInput, kEventTextInputUnicodeForKeyEvent}, - }; + EventHandlerRef application_event_ref_ref1; + EventTypeSpec list1[] = + { + //{ kEventClassCommand, kEventProcessCommand }, + //{ kEventClassCommand, kEventCommandUpdateStatus }, + { kEventClassMouse, kEventMouseDown },// handle trackball functionality globaly because there is only a single user + { kEventClassMouse, kEventMouseUp }, + { kEventClassMouse, kEventMouseMoved }, + { kEventClassMouse, kEventMouseDragged }, + { kEventClassMouse, kEventMouseWheelMoved } , + { kEventClassKeyboard, kEventRawKeyDown }, + { kEventClassKeyboard, kEventRawKeyUp } , + { kEventClassKeyboard, kEventRawKeyRepeat }, + { kEventClassKeyboard, kEventRawKeyModifiersChanged } , + { kEventClassTextInput, kEventTextInputUnicodeForKeyEvent}, + }; - EventHandlerUPP gEvtHandler = NewEventHandlerUPP(appEvtHndlr); - err = InstallApplicationEventHandler (gEvtHandler, GetEventTypeCount (list1) , list1, this, &application_event_ref_ref1 ); - GlobalInits = true; + EventHandlerUPP gEvtHandler = NewEventHandlerUPP(appEvtHndlr); + err = InstallApplicationEventHandler (gEvtHandler, GetEventTypeCount (list1) , list1, this, &application_event_ref_ref1 ); + GlobalInits = true; - ProcessSerialNumber psn = { 0, kCurrentProcess }; + ProcessSerialNumber psn = { 0, kCurrentProcess }; - // Determine if we're running from a bundle. - CFDictionaryRef dref = - ProcessInformationCopyDictionary(&psn, kProcessDictionaryIncludeAllInformationMask); - // If the dictionary doesn't have "BundlePath", then we're not - // running from a bundle, and we need to call TransformProcessType - // to make the process a "foreground" application, with its own - // icon in the dock and such. - if (!CFDictionaryContainsKey(dref, CFSTR("BundlePath"))) { - TransformProcessType(&psn, kProcessTransformToForegroundApplication); + // Determine if we're running from a bundle. + CFDictionaryRef dref = + ProcessInformationCopyDictionary(&psn, kProcessDictionaryIncludeAllInformationMask); + // If the dictionary doesn't have "BundlePath" (or the BundlePath + // is the same as the executable path), then we're not running + // from a bundle, and we need to call TransformProcessType to make + // the process a "foreground" application, with its own icon in + // the dock and such. + + bool has_bundle = false; + + CFStringRef bundle_path = (CFStringRef)CFDictionaryGetValue(dref, CFSTR("BundlePath")); + if (bundle_path != NULL) { + // OK, we have a bundle path. We're probably running in a + // bundle . . . + has_bundle = true; + + // . . . unless it turns out it's the same as the executable + // path. + CFStringRef exe_path = (CFStringRef)CFDictionaryGetValue(dref, kCFBundleExecutableKey); + if (exe_path != NULL) { + if (CFStringCompare(bundle_path, exe_path, kCFCompareCaseInsensitive) == kCFCompareEqualTo) { + has_bundle = false; } - SetFrontProcess(&psn); - } + CFRelease(exe_path); + } + + CFRelease(bundle_path); + } + + if (!has_bundle) { + TransformProcessType(&psn, kProcessTransformToForegroundApplication); + } + SetFrontProcess(&psn); + } if (req_properties.has_fullscreen() && req_properties.get_fullscreen()) {