summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrzej Rybczak <electricityispower@gmail.com>2014-11-07 23:46:20 +0100
committerAndrzej Rybczak <electricityispower@gmail.com>2014-11-07 23:46:20 +0100
commit7acc64979e3c4f46856ea8c9e34a6b474af4c820 (patch)
treebb2ad20a4d1f85016c169b7232ef30bd155d88de
parent543dadf3c6a8c3fb823b2a76b22dfe4414509ae5 (diff)
settings: make slave screen optional and unset by default
-rw-r--r--doc/config5
-rw-r--r--doc/ncmpcpp.12
-rw-r--r--src/ncmpcpp.cpp12
-rw-r--r--src/settings.cpp11
-rw-r--r--src/settings.h3
-rw-r--r--src/status.cpp3
6 files changed, 22 insertions, 14 deletions
diff --git a/doc/config b/doc/config
index 132d019b..a9091af6 100644
--- a/doc/config
+++ b/doc/config
@@ -407,9 +407,10 @@
#
##
## Note: You can define startup slave screen
-## by choosing screen from the list above.
+## by choosing screen from the list above or
+## an empty value for no slave screen.
##
-#startup_slave_screen = playlist
+#startup_slave_screen = ""
#
##
## Default width of locked screen (in %).
diff --git a/doc/ncmpcpp.1 b/doc/ncmpcpp.1
index 00b7cf84..bf93aad6 100644
--- a/doc/ncmpcpp.1
+++ b/doc/ncmpcpp.1
@@ -272,7 +272,7 @@ If set to "previous", key_screen_switcher will switch between current and last u
Screen that has to be displayed at start (playlist by default).
.TP
.B startup_slave_screen = SCREEN_NAME
-Slave screen that has to be displayed at start (playlist by default).
+Slave screen that has to be displayed at start (nothing by default).
.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.
diff --git a/src/ncmpcpp.cpp b/src/ncmpcpp.cpp
index ba6bc9d4..b9dd3b24 100644
--- a/src/ncmpcpp.cpp
+++ b/src/ncmpcpp.cpp
@@ -135,10 +135,14 @@ int main(int argc, char **argv)
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();
+ // 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;
+ bool screen_locked = myScreen->lock();
+ if (screen_locked && slave_screen != myScreen->type())
+ toScreen(slave_screen)->switchTo();
+ }
// local variables
bool key_pressed = false;
diff --git a/src/settings.cpp b/src/settings.cpp
index 68323d1e..646c141b 100644
--- a/src/settings.cpp
+++ b/src/settings.cpp
@@ -518,10 +518,13 @@ bool Configuration::read(const std::string &config_path)
}, 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)
+ if (!v.empty())
+ {
+ 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, boost::none)
));
p.add("locked_screen_width_part", assign_default<double>(
locked_screen_width_part, 50.0, [](double v) {
diff --git a/src/settings.h b/src/settings.h
index 7294841a..a9b1fad2 100644
--- a/src/settings.h
+++ b/src/settings.h
@@ -22,6 +22,7 @@
#define NCMPCPP_SETTINGS_H
#include <boost/date_time/posix_time/posix_time_types.hpp>
+#include <boost/optional.hpp>
#include <boost/regex.hpp>
#include <cassert>
#include <vector>
@@ -187,7 +188,7 @@ struct Configuration
size_t now_playing_suffix_length;
ScreenType startup_screen_type;
- ScreenType startup_slave_screen_type;
+ boost::optional<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 3e7c17a7..befc26ea 100644
--- a/src/status.cpp
+++ b/src/status.cpp
@@ -140,8 +140,7 @@ void initialize_status()
# endif // ENABLE_OUTPUTS
# ifdef ENABLE_VISUALIZER
myVisualizer->ResetFD();
- if (myScreen == myVisualizer)
- myVisualizer->SetFD();
+ myVisualizer->SetFD();
myVisualizer->FindOutputID();
# endif // ENABLE_VISUALIZER