diff --git a/docs/manual/start.md b/docs/manual/start.md index 3c2267a52..f04b9feee 100644 --- a/docs/manual/start.md +++ b/docs/manual/start.md @@ -88,7 +88,8 @@ JDimはメインプロセス/サブプロセスという関係で動作する。 以下のコマンドを使い分ける事でサブプロセスの起動のしかたをコントロール出来る。 -- 起動するかどうか確認してサブプロセスを起動 +- `-m`を指定しないときはメインプロセスのウインドウを最前面に表示する (v0.11.0-20240330 から変更)
+ デスクトップ環境によって挙動が異なる可能性がある ``` $ jdim ``` diff --git a/src/core.cpp b/src/core.cpp index 9c8840493..60049be14 100644 --- a/src/core.cpp +++ b/src/core.cpp @@ -3197,6 +3197,12 @@ void Core::exec_command() else if( command.command == "quit_jd" ) slot_quit(); + // メインウインドウを最前面に表示する + // NOTE: "最前面に表示" はデスクトップ環境によって挙動が異なる可能性がある + else if( command.command == "present_mainwin" ) { + m_win_main.present( static_cast( g_get_monotonic_time() / 1000 ) ); + } + // 最大化/最大化解除 else if( command.command == "maximize_mainwin" ){ diff --git a/src/iomonitor.cpp b/src/iomonitor.cpp index f7a2b2c7b..b5e25d583 100644 --- a/src/iomonitor.cpp +++ b/src/iomonitor.cpp @@ -184,6 +184,10 @@ bool IOMonitor::slot_ioin( Glib::IOCondition io_condition ) MISC::ERRMSG( "IOMonitor::slot_ioin(): read error." ); } + if( buffer == kURL_WinMain ) { + core_set_command( "present_mainwin" ); + return true; + } // FIFOに書き込まれたURLを開く // "現在のタブ/新しいタブ"など、開き方を選ぶ必要があるかも知れない //core_set_command( "open_article", buffer, "left", "auto" ); diff --git a/src/iomonitor.h b/src/iomonitor.h index 578624867..e08dbb2ab 100644 --- a/src/iomonitor.h +++ b/src/iomonitor.h @@ -11,6 +11,9 @@ namespace CORE { + /// @brief メインウインドウの仮想URL + constexpr const char* kURL_WinMain = "jdwin://main"; + enum { FIFO_OK = 0, diff --git a/src/main.cpp b/src/main.cpp index 5a2968bb9..17377472c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -406,15 +406,13 @@ bool App::setup_fifo( std::string url ) // マルチモードでなく、メインプロセスでもない場合は終了 if( ! multi_mode && ! iomonitor.is_main_process() ) return false; } - // マルチモードでなく、メインプロセスでもない場合は問い合わせる + // マルチモードではなく、メインプロセスでもない場合はメインプロセスのウインドウを最前面に表示して終了する + // NOTE: "最前面に表示" はデスクトップ環境によって挙動が異なる可能性がある else if( ! multi_mode && ! iomonitor.is_main_process() ) { - Gtk::MessageDialog mdiag( "JDimは既に起動しています。起動しますか?\n\n起動中のJDimが存在しない場合\n" - + CACHE::path_lock() + " を削除してください。", - false, Gtk::MESSAGE_QUESTION, Gtk::BUTTONS_YES_NO ); - mdiag.set_title( "ロックファイルが見つかりました" ); - const int ret = mdiag.run(); - if( ret != Gtk::RESPONSE_YES ) return false; + // FIFOに書き込む + iomonitor.send_command( CORE::kURL_WinMain ); + return false; } } // FIFOに問題がある(FATで作成出来ないなど)