diff --git a/doc/config b/doc/config index 43ba779c..edcd02a2 100644 --- a/doc/config +++ b/doc/config @@ -411,6 +411,8 @@ ## #startup_slave_screen = "" # +#startup_slave_screen_focus = no +# ## ## Default width of locked screen (in %). ## Acceptable values are from 20 to 80. diff --git a/doc/ncmpcpp.1 b/doc/ncmpcpp.1 index 3672b172..1ddec35c 100644 --- a/doc/ncmpcpp.1 +++ b/doc/ncmpcpp.1 @@ -263,6 +263,9 @@ Screen that has to be displayed at start (playlist by default). .B startup_slave_screen = SCREEN_NAME Slave screen that has to be displayed at start (nothing by default). .TP +.B startup_slave_screen_focus = yes/no +If set to yes, slave screen will be the active one after startup. Otherwise master screen will be. +.TP .B locked_screen_width_part = 20-80 If you want to lock a screen, ncmpcpp asks for % of locked screen's width to be reserved before that and provides a default value, which is the one you can set here. .TP diff --git a/src/ncmpcpp.cpp b/src/ncmpcpp.cpp index 23c8dde2..5c72d504 100644 --- a/src/ncmpcpp.cpp +++ b/src/ncmpcpp.cpp @@ -144,10 +144,16 @@ int main(int argc, char **argv) // lock current screen and go to the slave one if applicable if (Config.startup_slave_screen_type) { - auto slave_screen = *Config.startup_slave_screen_type; + auto slave_screen_type = *Config.startup_slave_screen_type; bool screen_locked = myScreen->lock(); - if (screen_locked && slave_screen != myScreen->type()) - toScreen(slave_screen)->switchTo(); + if (screen_locked && slave_screen_type != myScreen->type()) + { + auto slave_screen = toScreen(slave_screen_type); + assert(slave_screen != nullptr); + slave_screen->switchTo(); + if (!Config.startup_slave_screen_focus) + Actions::get(Actions::Type::MasterScreen).execute(); + } } // local variables diff --git a/src/settings.cpp b/src/settings.cpp index 34f89c46..74484cc0 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -546,6 +546,9 @@ bool Configuration::read(const std::vector &config_paths, bool igno } }, defaults_to(startup_slave_screen_type, boost::none) )); + p.add("startup_slave_screen_focus", yes_no( + startup_slave_screen_focus, false + )); p.add("locked_screen_width_part", assign_default( locked_screen_width_part, 50.0, [](double v) { return v / 100; diff --git a/src/settings.h b/src/settings.h index 2c0f53a7..ef53f880 100644 --- a/src/settings.h +++ b/src/settings.h @@ -165,6 +165,7 @@ struct Configuration bool ask_for_locked_screen_width_part; bool allow_for_physical_item_deletion; bool progressbar_boldness; + bool startup_slave_screen_focus; unsigned mpd_connection_timeout; unsigned crossfade_time;