From 97488acf72ed8ab0832e37bd33b7a02d0e9d4fef Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Wed, 4 Apr 2018 18:13:08 +0200 Subject: Try again to disable the dock --- synchronizer/CMakeLists.txt | 3 +++ synchronizer/main.cpp | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/synchronizer/CMakeLists.txt b/synchronizer/CMakeLists.txt index 9c422e6..3ea5521 100644 --- a/synchronizer/CMakeLists.txt +++ b/synchronizer/CMakeLists.txt @@ -15,4 +15,7 @@ target_link_libraries(${PROJECT_NAME} KAsync ${CMAKE_DL_LIBS} ) +if(APPLE) + target_link_libraries(${PROJECT_NAME} "-framework CoreFoundation") +endif() install(TARGETS ${PROJECT_NAME} ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) diff --git a/synchronizer/main.cpp b/synchronizer/main.cpp index 479a0bf..1a79622 100644 --- a/synchronizer/main.cpp +++ b/synchronizer/main.cpp @@ -38,6 +38,9 @@ #include "log.h" #include "test.h" #include "definitions.h" +#ifdef Q_OS_OSX +#include +#endif static Listener *listener = nullptr; @@ -226,6 +229,20 @@ int main(int argc, char *argv[]) qInstallMessageHandler(qtMessageHandler); +#ifdef Q_OS_OSX + if (CFBundleRef mainBundle = CFBundleGetMainBundle()) { + // get the application's Info Dictionary. For app bundles this would live in the bundle's Info.plist, + // for regular executables it is obtained in another way. + CFMutableDictionaryRef infoDict = (CFMutableDictionaryRef) CFBundleGetInfoDictionary(mainBundle); + if (infoDict) { + // Add or set the "LSUIElement" key with/to value "1". This can simply be a CFString. + CFDictionarySetValue(infoDict, CFSTR("LSUIElement"), CFSTR("1")); + // That's it. We're now considered as an "agent" by the window server, and thus will have + // neither menubar nor presence in the Dock or App Switcher. + } + } +#endif + //Necessary to hide this QGuiApplication from the dock and application switcher on mac os. qputenv("QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM", "true"); QGuiApplication::setAttribute(Qt::AA_PluginApplication); -- cgit v1.2.3