forked from qt-creator/qt-creator
Remove the last usage of deprecated Carbon APIs from Qt Creator
Change-Id: I05c8345e5f1618e7ecbb8a9c27feb5b9a321dc11 Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@qt.io> Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: Vikas Pachdha <vikas.pachdha@qt.io> Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -68,4 +68,11 @@ bool ProcessHandle::equals(const ProcessHandle &rhs) const
|
|||||||
return m_pid == rhs.m_pid;
|
return m_pid == rhs.m_pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef Q_OS_MACOS
|
||||||
|
bool ProcessHandle::activate()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
} // Utils
|
} // Utils
|
||||||
|
|||||||
@@ -43,6 +43,8 @@ public:
|
|||||||
|
|
||||||
bool equals(const ProcessHandle &) const;
|
bool equals(const ProcessHandle &) const;
|
||||||
|
|
||||||
|
bool activate();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
qint64 m_pid;
|
qint64 m_pid;
|
||||||
};
|
};
|
||||||
|
|||||||
39
src/libs/utils/processhandle_mac.mm
Normal file
39
src/libs/utils/processhandle_mac.mm
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2017 The Qt Company Ltd.
|
||||||
|
** Contact: https://www.qt.io/licensing/
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms
|
||||||
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
||||||
|
** information use the contact form at https://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU
|
||||||
|
** General Public License version 3 as published by the Free Software
|
||||||
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
||||||
|
** included in the packaging of this file. Please review the following
|
||||||
|
** information to ensure the GNU General Public License requirements will
|
||||||
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "processhandle.h"
|
||||||
|
#import <AppKit/AppKit.h>
|
||||||
|
|
||||||
|
namespace Utils {
|
||||||
|
|
||||||
|
bool ProcessHandle::activate()
|
||||||
|
{
|
||||||
|
NSRunningApplication *app = [NSRunningApplication
|
||||||
|
runningApplicationWithProcessIdentifier:pid()];
|
||||||
|
return app && [app activateWithOptions:static_cast<NSApplicationActivationOptions>(
|
||||||
|
NSApplicationActivateIgnoringOtherApps)];
|
||||||
|
}
|
||||||
|
|
||||||
|
} // Utils
|
||||||
@@ -252,8 +252,9 @@ osx {
|
|||||||
HEADERS += \
|
HEADERS += \
|
||||||
$$PWD/fileutils_mac.h
|
$$PWD/fileutils_mac.h
|
||||||
OBJECTIVE_SOURCES += \
|
OBJECTIVE_SOURCES += \
|
||||||
$$PWD/fileutils_mac.mm
|
$$PWD/fileutils_mac.mm \
|
||||||
LIBS += -framework Foundation
|
$$PWD/processhandle_mac.mm
|
||||||
|
LIBS += -framework Foundation -framework AppKit
|
||||||
}
|
}
|
||||||
|
|
||||||
include(mimetypes/mimetypes.pri)
|
include(mimetypes/mimetypes.pri)
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ Project {
|
|||||||
|
|
||||||
Properties {
|
Properties {
|
||||||
condition: qbs.targetOS.contains("macos")
|
condition: qbs.targetOS.contains("macos")
|
||||||
cpp.frameworks: ["Foundation"]
|
cpp.frameworks: ["Foundation", "AppKit"]
|
||||||
}
|
}
|
||||||
|
|
||||||
Depends { name: "Qt"; submodules: ["concurrent", "network", "qml", "widgets"] }
|
Depends { name: "Qt"; submodules: ["concurrent", "network", "qml", "widgets"] }
|
||||||
@@ -297,6 +297,14 @@ Project {
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Group {
|
||||||
|
name: "ProcessHandle_macos"
|
||||||
|
condition: qbs.targetOS.contains("macos")
|
||||||
|
files: [
|
||||||
|
"processhandle_mac.mm",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
Group {
|
Group {
|
||||||
name: "MimeTypes"
|
name: "MimeTypes"
|
||||||
prefix: "mimetypes/"
|
prefix: "mimetypes/"
|
||||||
|
|||||||
@@ -330,8 +330,6 @@ journald {
|
|||||||
LIBS += -lsystemd
|
LIBS += -lsystemd
|
||||||
}
|
}
|
||||||
|
|
||||||
macx:LIBS += -framework Carbon
|
|
||||||
|
|
||||||
RESOURCES += projectexplorer.qrc
|
RESOURCES += projectexplorer.qrc
|
||||||
|
|
||||||
# Some way to override the architecture used in Abi:
|
# Some way to override the architecture used in Abi:
|
||||||
|
|||||||
@@ -15,10 +15,6 @@ Project {
|
|||||||
Depends { name: "TextEditor" }
|
Depends { name: "TextEditor" }
|
||||||
|
|
||||||
cpp.defines: base.concat("QTC_CPU=X86Architecture")
|
cpp.defines: base.concat("QTC_CPU=X86Architecture")
|
||||||
Properties {
|
|
||||||
condition: qbs.targetOS.contains("macos")
|
|
||||||
cpp.frameworks: base.concat(["Carbon"])
|
|
||||||
}
|
|
||||||
|
|
||||||
Group {
|
Group {
|
||||||
name: "General"
|
name: "General"
|
||||||
|
|||||||
@@ -704,11 +704,6 @@ public:
|
|||||||
RunControlState state = RunControlState::Initialized;
|
RunControlState state = RunControlState::Initialized;
|
||||||
|
|
||||||
QList<QPointer<RunWorker>> m_workers;
|
QList<QPointer<RunWorker>> m_workers;
|
||||||
|
|
||||||
#ifdef Q_OS_OSX
|
|
||||||
// This is used to bring apps in the foreground on Mac
|
|
||||||
int foregroundCount;
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // Internal
|
} // Internal
|
||||||
@@ -1242,25 +1237,7 @@ void RunControlPrivate::debugMessage(const QString &msg)
|
|||||||
*/
|
*/
|
||||||
void RunControl::bringApplicationToForeground()
|
void RunControl::bringApplicationToForeground()
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_OSX
|
d->applicationProcessHandle.activate();
|
||||||
d->foregroundCount = 0;
|
|
||||||
bringApplicationToForegroundInternal();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void RunControl::bringApplicationToForegroundInternal()
|
|
||||||
{
|
|
||||||
#ifdef Q_OS_OSX
|
|
||||||
ProcessSerialNumber psn;
|
|
||||||
GetProcessForPID(d->applicationProcessHandle.pid(), &psn);
|
|
||||||
if (SetFrontProcess(&psn) == procNotFound && d->foregroundCount < 15) {
|
|
||||||
// somehow the mac/carbon api says
|
|
||||||
// "-600 no eligible process with specified process id"
|
|
||||||
// if we call SetFrontProcess too early
|
|
||||||
++d->foregroundCount;
|
|
||||||
QTimer::singleShot(200, this, &RunControl::bringApplicationToForegroundInternal);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RunControl::appendMessage(const QString &msg, Utils::OutputFormat format)
|
void RunControl::appendMessage(const QString &msg, Utils::OutputFormat format)
|
||||||
|
|||||||
@@ -488,7 +488,6 @@ private:
|
|||||||
friend class Internal::RunWorkerPrivate;
|
friend class Internal::RunWorkerPrivate;
|
||||||
|
|
||||||
static void addWorkerFactory(const WorkerFactory &workerFactory);
|
static void addWorkerFactory(const WorkerFactory &workerFactory);
|
||||||
void bringApplicationToForegroundInternal();
|
|
||||||
Internal::RunControlPrivate *d;
|
Internal::RunControlPrivate *d;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user