Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions sources/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ set(HEADERS
xdtsio.h
pathutils.h
commandmanager.h
macdockicon.h
${MOC_HEADERS}
)

Expand Down Expand Up @@ -56,6 +57,18 @@ else()
message(ERROR "Unsupported build environment, only MSVC and APPLE are supported")
endif()

# macdockicon.mm is Objective-C++ (hides the mothership process's Dock icon
# on macOS); only compiled for the Apple build, MSVC cannot build .mm files.
# macdockicon.mm縺ッObjective-C++��acOS縺ァ豈崎襖繝励Ο繧サ繧ケ縺ョDock繧「繧、繧ウ繝ウ繧帝國縺
# 縺溘a縺ョ繧ゅ��峨�pple繝薙Ν繝峨〒縺ョ縺ソ繧ウ繝ウ繝代う繝ォ縺吶k縲�SVC縺ッ.mm繝輔ぃ繧、繝ォ繧
# 繝薙Ν繝峨〒縺阪↑縺�
if(BUILD_ENV_APPLE)
set(SOURCES
${SOURCES}
macdockicon.mm
)
endif()

#-----------------------------------------------------------------------------
# Build Options
option(WITH_TRANSLATION "Generate translation projects as well" ON)
Expand Down Expand Up @@ -166,6 +179,9 @@ if(BUILD_ENV_MSVC)
target_link_libraries(${PROJECT_NAME} Qt5::Widgets Qt5::Network ${PSD_SDK_LIB} )
else()
target_link_libraries(${PROJECT_NAME} Qt5::Widgets Qt5::Network)
# AppKit is needed by macdockicon.mm (NSApplicationActivationPolicy).
# AppKit縺ッmacdockicon.mm��SApplicationActivationPolicy�峨↓蠢�ヲ√
target_link_libraries(${PROJECT_NAME} "-framework AppKit")
endif()

add_definitions(
Expand Down
12 changes: 12 additions & 0 deletions sources/instancemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "pathutils.h"
#include "xdtsio.h"
#include "dialogs.h"
#include "macdockicon.h"

#include <QApplication>
#include <QCoreApplication>
Expand Down Expand Up @@ -171,6 +172,17 @@ void InstanceManager::startMothership(const QString& initialPath) {
// 明示的に制御する。
qApp->setQuitOnLastWindowClosed(false);

// The mothership has no window, but on macOS every process that starts a
// Cocoa event loop still gets a Dock icon by default; hide it so the app
// doesn't show two Dock icons (one for this process, one for the worker
// window it spawns).
// 母艦はウィンドウを持たないが、macOSではCocoaのイベントループを開始した
// 各プロセスは既定でDockアイコンを持つ。起動するワーカーウィンドウの
// アイコンと並んで2つ表示されないよう、ここで隠す。
#ifdef __MACOS__
hideDockIcon();
#endif

// Treat our own launch argument the same way as a request coming from
// another process (always spawns a worker, since nothing is registered
// yet at this point).
Expand Down
25 changes: 25 additions & 0 deletions sources/macdockicon.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
�ソ#pragma once
#ifndef MACDOCKICON_H
#define MACDOCKICON_H

#ifdef __MACOS__
// Hides this process's Dock icon and Cmd+Tab entry
// (NSApplicationActivationPolicyAccessory). The invisible mothership
// process has no window of its own, but every process that starts a Cocoa
// event loop gets a Dock icon by default -- without this, launching XDTS
// Viewer shows two Dock icons (one for the mothership, one for the
// per-file worker window) instead of one. Safe to call at any time after
// QApplication is constructed; it does not prevent this process from
// later showing dialogs (e.g. the CSP sync picker) in the foreground.
// 縺薙�繝励Ο繧サ繧ケ縺ョDock繧「繧、繧ウ繝ウ縺ィCmd+Tab縺ク縺ョ陦ィ遉コ繧帝國縺
// ��SApplicationActivationPolicyAccessory�峨よッ崎襖繝励Ο繧サ繧ケ縺ッ閾ェ霄ォ縺ョ
// 繧ヲ繧」繝ウ繝峨え繧呈戟縺溘↑縺�′縲,ocoa縺ョ繧、繝吶Φ繝医Ν繝シ繝励r髢句ァ九@縺溷推繝励Ο繧サ繧ケ縺ッ
// 譌「螳壹〒Dock繧「繧、繧ウ繝ウ繧1縺、謖√▽縺溘a縲√%繧後r陦後o縺ェ縺�→XDTS Viewer襍キ蜍墓凾縺ォ
// Dock繧「繧、繧ウ繝ウ縺2縺、�域ッ崎襖逕ィ縺ィ繝輔ぃ繧、繝ォ縺斐→縺ョ繝ッ繝シ繧ォ繝シ繧ヲ繧」繝ウ繝峨え逕ィ�芽。ィ遉コ
// 縺輔l縺ヲ縺励∪縺�2Application讒狗ッ牙セ後〒縺ゅl縺ー縺�▽蜻シ繧薙〒繧り憶縺上√%繧後r
// 蜻シ繧薙□蠕後b縺薙�繝励Ο繧サ繧ケ縺靴SP蜷梧悄繝斐ャ繧ォ繝シ縺ェ縺ゥ縺ョ繝繧、繧「繝ュ繧ー繧貞燕髱「縺ォ陦ィ遉コ
// 縺吶k縺薙→縺ッ螯ィ縺偵i繧後↑縺�
void hideDockIcon();
#endif

#endif
9 changes: 9 additions & 0 deletions sources/macdockicon.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "macdockicon.h"

#ifdef __MACOS__
#import <AppKit/AppKit.h>

void hideDockIcon() {
[NSApp setActivationPolicy:NSApplicationActivationPolicyAccessory];
}
#endif
Loading