diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/browser.cpp | 7 | ||||
-rw-r--r-- | src/configuration.cpp | 13 | ||||
-rw-r--r-- | src/ncmpcpp.cpp | 9 | ||||
-rw-r--r-- | src/settings.cpp | 6 | ||||
-rw-r--r-- | src/settings.h | 1 | ||||
-rw-r--r-- | src/status.cpp | 9 |
6 files changed, 34 insertions, 11 deletions
diff --git a/src/browser.cpp b/src/browser.cpp index 02e24803..551bdc02 100644 --- a/src/browser.cpp +++ b/src/browser.cpp @@ -106,12 +106,7 @@ void Browser::resize() void Browser::switchTo() { SwitchTo::execute(this); - - if (w.empty()) - getDirectory(m_current_directory); - else - markSongsInPlaylist(proxySongList()); - + markSongsInPlaylist(proxySongList()); drawHeader(); } diff --git a/src/configuration.cpp b/src/configuration.cpp index d44ba4fa..a34c86ed 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -56,6 +56,7 @@ bool configure(int argc, char **argv) ("config,c", po::value<std::string>(&config_path)->default_value("~/.ncmpcpp/config"), "specify configuration file") ("bindings,b", po::value<std::string>(&bindings_path)->default_value("~/.ncmpcpp/bindings"), "specify bindings file") ("screen,s", po::value<std::string>(), "specify initial screen") + ("slave-screen,S", po::value<std::string>(), "specify initial slave screen") ("help,?", "show help message") ("version,v", "display version information") ; @@ -176,6 +177,18 @@ bool configure(int argc, char **argv) exit(1); } } + + // custom startup slave screen + if (vm.count("slave-screen")) + { + auto screen = vm["slave-screen"].as<std::string>(); + Config.startup_slave_screen_type = stringtoStartupScreenType(screen); + if (Config.startup_slave_screen_type == ScreenType::Unknown) + { + std::cerr << "Unknown slave screen: " << screen << "\n"; + exit(1); + } + } } catch (std::exception &e) { diff --git a/src/ncmpcpp.cpp b/src/ncmpcpp.cpp index 9757be15..ba6bc9d4 100644 --- a/src/ncmpcpp.cpp +++ b/src/ncmpcpp.cpp @@ -130,6 +130,15 @@ int main(int argc, char **argv) // initialize playlist myPlaylist->switchTo(); + + // go to startup screen + if (Config.startup_screen_type != myScreen->type()) + toScreen(Config.startup_screen_type)->switchTo(); + + // lock current screen and go to the slave one + if (Config.startup_slave_screen_type != myScreen->type()) + if (myScreen->lock()) + toScreen(Config.startup_slave_screen_type)->switchTo(); // local variables bool key_pressed = false; diff --git a/src/settings.cpp b/src/settings.cpp index 55415f21..68323d1e 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -517,6 +517,12 @@ bool Configuration::read(const std::string &config_path) throw std::runtime_error("unknown screen: " + v); }, defaults_to(startup_screen_type, ScreenType::Playlist) )); + p.add("startup_slave_screen", option_parser::worker([this](std::string v) { + startup_slave_screen_type = stringtoStartupScreenType(v); + if (startup_slave_screen_type == ScreenType::Unknown) + throw std::runtime_error("unknown slave screen: " + v); + }, defaults_to(startup_slave_screen_type, ScreenType::Playlist) + )); p.add("locked_screen_width_part", assign_default<double>( locked_screen_width_part, 50.0, [](double v) { return v / 100; diff --git a/src/settings.h b/src/settings.h index 8ca8f894..7294841a 100644 --- a/src/settings.h +++ b/src/settings.h @@ -187,6 +187,7 @@ struct Configuration size_t now_playing_suffix_length; ScreenType startup_screen_type; + ScreenType startup_slave_screen_type; std::list<ScreenType> screen_sequence; SortMode browser_sort_mode; diff --git a/src/status.cpp b/src/status.cpp index 2babb084..33217ce4 100644 --- a/src/status.cpp +++ b/src/status.cpp @@ -121,7 +121,11 @@ void initialize_status() { int curr_pos = Status::State::currentSongPosition(); if (curr_pos >= 0) + { myPlaylist->main().highlight(curr_pos); + if (isVisible(myPlaylist)) + myPlaylist->refresh(); + } } // Set TCP_NODELAY on the tcp socket as we are using write-write-read pattern @@ -130,11 +134,6 @@ void initialize_status() int flag = 1; setsockopt(Mpd.GetFD(), IPPROTO_TCP, TCP_NODELAY, &flag, sizeof(flag)); - // go to startup screen - if (Config.startup_screen_type != myScreen->type()) - toScreen(Config.startup_screen_type)->switchTo(); - myScreen->refresh(); - myBrowser->fetchSupportedExtensions(); # ifdef ENABLE_OUTPUTS myOutputs->FetchList(); |