fix(bar): Only initialize config values when using --print-wmname

This commit is contained in:
Michael Carlberg 2016-12-27 04:15:01 +01:00
parent db7aa7c490
commit f101a303bd
3 changed files with 11 additions and 6 deletions

View File

@ -36,10 +36,10 @@ class bar : public xpp::event::sink<evt::button_press, evt::expose, evt::propert
public signal_receiver<SIGN_PRIORITY_BAR, sig_ui::tick, sig_ui::shade_window, sig_ui::unshade_window, sig_ui::dim_window> { public signal_receiver<SIGN_PRIORITY_BAR, sig_ui::tick, sig_ui::shade_window, sig_ui::unshade_window, sig_ui::dim_window> {
public: public:
using make_type = unique_ptr<bar>; using make_type = unique_ptr<bar>;
static make_type make(); static make_type make(bool only_initialize_values = false);
explicit bar(connection&, signal_emitter&, const config&, const logger&, unique_ptr<screen>&&, explicit bar(connection&, signal_emitter&, const config&, const logger&, unique_ptr<screen>&&,
unique_ptr<tray_manager>&&, unique_ptr<parser>&&, unique_ptr<taskqueue>&&); unique_ptr<tray_manager>&&, unique_ptr<parser>&&, unique_ptr<taskqueue>&&, bool only_initialize_values);
~bar(); ~bar();
void parse(string&& data) const; void parse(string&& data) const;

View File

@ -35,7 +35,7 @@ using namespace wm_util;
/** /**
* Create instance * Create instance
*/ */
bar::make_type bar::make() { bar::make_type bar::make(bool only_initialize_values) {
// clang-format off // clang-format off
return factory_util::unique<bar>( return factory_util::unique<bar>(
connection::make(), connection::make(),
@ -45,7 +45,8 @@ bar::make_type bar::make() {
screen::make(), screen::make(),
tray_manager::make(), tray_manager::make(),
parser::make(), parser::make(),
taskqueue::make()); taskqueue::make(),
only_initialize_values);
// clang-format on // clang-format on
} }
@ -56,7 +57,7 @@ bar::make_type bar::make() {
*/ */
bar::bar(connection& conn, signal_emitter& emitter, const config& config, const logger& logger, bar::bar(connection& conn, signal_emitter& emitter, const config& config, const logger& logger,
unique_ptr<screen>&& screen, unique_ptr<tray_manager>&& tray_manager, unique_ptr<parser>&& parser, unique_ptr<screen>&& screen, unique_ptr<tray_manager>&& tray_manager, unique_ptr<parser>&& parser,
unique_ptr<taskqueue>&& taskqueue) unique_ptr<taskqueue>&& taskqueue, bool only_initialize_values)
: m_connection(conn) : m_connection(conn)
, m_sig(emitter) , m_sig(emitter)
, m_conf(config) , m_conf(config)
@ -144,6 +145,10 @@ bar::bar(connection& conn, signal_emitter& emitter, const config& config, const
m_opts.separator = string_util::trim(m_conf.get<string>(bs, "separator", ""), '"'); m_opts.separator = string_util::trim(m_conf.get<string>(bs, "separator", ""), '"');
m_opts.locale = m_conf.get<string>(bs, "locale", ""); m_opts.locale = m_conf.get<string>(bs, "locale", "");
if (only_initialize_values) {
return;
}
// Load values used to adjust the struts atom // Load values used to adjust the struts atom
m_opts.strut.top = m_conf.get<int>("global/wm", "margin-top", 0); m_opts.strut.top = m_conf.get<int>("global/wm", "margin-top", 0);
m_opts.strut.bottom = m_conf.get<int>("global/wm", "margin-bottom", 0); m_opts.strut.bottom = m_conf.get<int>("global/wm", "margin-bottom", 0);

View File

@ -110,7 +110,7 @@ int main(int argc, char** argv) {
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
if (cli->has("print-wmname")) { if (cli->has("print-wmname")) {
std::cout << bar::make()->settings().wmname << std::endl; std::cout << bar::make(true)->settings().wmname << std::endl;
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }