From 32eeb46f3c20eda734136ae7419d9b7dc423e9fd Mon Sep 17 00:00:00 2001 From: Jake Petroules Date: Fri, 27 Nov 2015 02:18:23 -0800 Subject: Remove Carbon API usage. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The new API has been available since 10.6 or 10.7 and the debugger indicates it simply calls through to TransformProcessType. Change-Id: Ia8f82d7426cb409aca8fd5feb8e43e1b0e79f8f6 Reviewed-by: Tor Arne Vestbø --- src/plugins/platforms/cocoa/qcocoahelpers.mm | 59 +++++++++++++--------------- 1 file changed, 28 insertions(+), 31 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.mm b/src/plugins/platforms/cocoa/qcocoahelpers.mm index 4b63c7207f..cfb7e911cc 100644 --- a/src/plugins/platforms/cocoa/qcocoahelpers.mm +++ b/src/plugins/platforms/cocoa/qcocoahelpers.mm @@ -443,50 +443,47 @@ Qt::DropActions qt_mac_mapNSDragOperations(NSDragOperation nsActions) // Misc // -// Changes the process type for this process to kProcessTransformToForegroundApplication, +// Sets the activation policy for this process to NSApplicationActivationPolicyRegular, // unless either LSUIElement or LSBackgroundOnly is set in the Info.plist. void qt_mac_transformProccessToForegroundApplication() { - ProcessSerialNumber psn; - if (GetCurrentProcess(&psn) == noErr) { - bool forceTransform = true; - CFTypeRef value = CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle(), - CFSTR("LSUIElement")); + bool forceTransform = true; + CFTypeRef value = CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle(), + CFSTR("LSUIElement")); + if (value) { + CFTypeID valueType = CFGetTypeID(value); + // Officially it's supposed to be a string, a boolean makes sense, so we'll check. + // A number less so, but OK. + if (valueType == CFStringGetTypeID()) + forceTransform = !(QCFString::toQString(static_cast(value)).toInt()); + else if (valueType == CFBooleanGetTypeID()) + forceTransform = !CFBooleanGetValue(static_cast(value)); + else if (valueType == CFNumberGetTypeID()) { + int valueAsInt; + CFNumberGetValue(static_cast(value), kCFNumberIntType, &valueAsInt); + forceTransform = !valueAsInt; + } + } + + if (forceTransform) { + value = CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle(), + CFSTR("LSBackgroundOnly")); if (value) { CFTypeID valueType = CFGetTypeID(value); - // Officially it's supposed to be a string, a boolean makes sense, so we'll check. - // A number less so, but OK. - if (valueType == CFStringGetTypeID()) - forceTransform = !(QCFString::toQString(static_cast(value)).toInt()); - else if (valueType == CFBooleanGetTypeID()) + if (valueType == CFBooleanGetTypeID()) forceTransform = !CFBooleanGetValue(static_cast(value)); + else if (valueType == CFStringGetTypeID()) + forceTransform = !(QCFString::toQString(static_cast(value)).toInt()); else if (valueType == CFNumberGetTypeID()) { int valueAsInt; CFNumberGetValue(static_cast(value), kCFNumberIntType, &valueAsInt); forceTransform = !valueAsInt; } } + } - if (forceTransform) { - value = CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle(), - CFSTR("LSBackgroundOnly")); - if (value) { - CFTypeID valueType = CFGetTypeID(value); - if (valueType == CFBooleanGetTypeID()) - forceTransform = !CFBooleanGetValue(static_cast(value)); - else if (valueType == CFStringGetTypeID()) - forceTransform = !(QCFString::toQString(static_cast(value)).toInt()); - else if (valueType == CFNumberGetTypeID()) { - int valueAsInt; - CFNumberGetValue(static_cast(value), kCFNumberIntType, &valueAsInt); - forceTransform = !valueAsInt; - } - } - } - - if (forceTransform) { - TransformProcessType(&psn, kProcessTransformToForegroundApplication); - } + if (forceTransform) { + [[NSApplication sharedApplication] setActivationPolicy:NSApplicationActivationPolicyRegular]; } } static CGColorSpaceRef m_genericColorSpace = 0; -- cgit v1.2.3