refactor(clang-tidy): Apply fixes

This commit is contained in:
Michael Carlberg 2016-12-23 15:54:06 +01:00
parent 7c7e053e1f
commit 97fa7052fe
15 changed files with 60 additions and 73 deletions

View File

@ -82,7 +82,7 @@ class logger {
/** /**
* Convert string * Convert string
*/ */
const char* convert(string arg) const; const char* convert(string arg) const; // NOLINT
/** /**
* Convert thread id * Convert thread id

View File

@ -28,6 +28,7 @@ namespace modules {
public: public:
explicit ipc_module(const bar_settings&, string); explicit ipc_module(const bar_settings&, string);
void update() {}
string get_output(); string get_output();
bool build(builder* builder, const string& tag) const; bool build(builder* builder, const string& tag) const;
void on_message(const ipc_hook& message); void on_message(const ipc_hook& message);

View File

@ -21,6 +21,7 @@ namespace modules {
explicit menu_module(const bar_settings&, string); explicit menu_module(const bar_settings&, string);
bool build(builder* builder, const string& tag) const; bool build(builder* builder, const string& tag) const;
void update() {}
protected: protected:
bool on(const input_event_t& evt); bool on(const input_event_t& evt);

View File

@ -17,13 +17,9 @@ namespace modules {
protected: protected:
void runner() { void runner() {
try { try {
// Warm up module output and // Warm up the module output before entering the loop
// send broadcast before entering CAST_MOD(Impl)->update();
// the update loop CAST_MOD(Impl)->broadcast();
if (this->running()) {
CAST_MOD(Impl)->update();
CAST_MOD(Impl)->broadcast();
}
while (this->running()) { while (this->running()) {
CAST_MOD(Impl)->idle(); CAST_MOD(Impl)->idle();

View File

@ -18,13 +18,9 @@ namespace modules {
protected: protected:
void runner() { void runner() {
try { try {
// Warm up module output and // Warm up module output before entering the loop
// send broadcast before entering CAST_MOD(Impl)->on_event(nullptr);
// the update loop CAST_MOD(Impl)->broadcast();
if (this->running()) {
CAST_MOD(Impl)->on_event(nullptr);
CAST_MOD(Impl)->broadcast();
}
while (this->running()) { while (this->running()) {
CAST_MOD(Impl)->poll_events(); CAST_MOD(Impl)->poll_events();

View File

@ -11,6 +11,7 @@ namespace modules {
using module<Impl>::module; using module<Impl>::module;
void start() { void start() {
CAST_MOD(Impl)->update();
CAST_MOD(Impl)->broadcast(); CAST_MOD(Impl)->broadcast();
} }

View File

@ -30,35 +30,49 @@ namespace modules {
bool on(const input_event_t& evt); bool on(const input_event_t& evt);
private: private:
static constexpr auto FORMAT_ONLINE = "format-online"; static constexpr const char* FORMAT_ONLINE{"format-online"};
static constexpr auto TAG_BAR_PROGRESS = "<bar-progress>"; static constexpr const char* TAG_BAR_PROGRESS{"<bar-progress>"};
static constexpr auto TAG_TOGGLE = "<toggle>"; static constexpr const char* TAG_TOGGLE{"<toggle>"};
static constexpr auto TAG_TOGGLE_STOP = "<toggle-stop>"; static constexpr const char* TAG_TOGGLE_STOP{"<toggle-stop>"};
static constexpr auto TAG_LABEL_SONG = "<label-song>"; static constexpr const char* TAG_LABEL_SONG{"<label-song>"};
static constexpr auto TAG_LABEL_TIME = "<label-time>"; static constexpr const char* TAG_LABEL_TIME{"<label-time>"};
static constexpr auto TAG_ICON_RANDOM = "<icon-random>"; static constexpr const char* TAG_ICON_RANDOM{"<icon-random>"};
static constexpr auto TAG_ICON_REPEAT = "<icon-repeat>"; static constexpr const char* TAG_ICON_REPEAT{"<icon-repeat>"};
static constexpr auto TAG_ICON_REPEAT_ONE = "<icon-repeatone>"; static constexpr const char* TAG_ICON_REPEAT_ONE{"<icon-repeatone>"};
static constexpr auto TAG_ICON_PREV = "<icon-prev>"; static constexpr const char* TAG_ICON_PREV{"<icon-prev>"};
static constexpr auto TAG_ICON_STOP = "<icon-stop>"; static constexpr const char* TAG_ICON_STOP{"<icon-stop>"};
static constexpr auto TAG_ICON_PLAY = "<icon-play>"; static constexpr const char* TAG_ICON_PLAY{"<icon-play>"};
static constexpr auto TAG_ICON_PAUSE = "<icon-pause>"; static constexpr const char* TAG_ICON_PAUSE{"<icon-pause>"};
static constexpr auto TAG_ICON_NEXT = "<icon-next>"; static constexpr const char* TAG_ICON_NEXT{"<icon-next>"};
static constexpr auto TAG_ICON_SEEKB = "<icon-seekb>"; static constexpr const char* TAG_ICON_SEEKB{"<icon-seekb>"};
static constexpr auto TAG_ICON_SEEKF = "<icon-seekf>"; static constexpr const char* TAG_ICON_SEEKF{"<icon-seekf>"};
static constexpr auto FORMAT_OFFLINE = "format-offline"; static constexpr const char* FORMAT_OFFLINE{"format-offline"};
static constexpr auto TAG_LABEL_OFFLINE = "<label-offline>"; static constexpr const char* TAG_LABEL_OFFLINE{"<label-offline>"};
static constexpr auto EVENT_PLAY = "mpdplay"; static constexpr const char* EVENT_PLAY{"mpdplay"};
static constexpr auto EVENT_PAUSE = "mpdpause"; static constexpr const char* EVENT_PAUSE{"mpdpause"};
static constexpr auto EVENT_STOP = "mpdstop"; static constexpr const char* EVENT_STOP{"mpdstop"};
static constexpr auto EVENT_PREV = "mpdprev"; static constexpr const char* EVENT_PREV{"mpdprev"};
static constexpr auto EVENT_NEXT = "mpdnext"; static constexpr const char* EVENT_NEXT{"mpdnext"};
static constexpr auto EVENT_REPEAT = "mpdrepeat"; static constexpr const char* EVENT_REPEAT{"mpdrepeat"};
static constexpr auto EVENT_REPEAT_ONE = "mpdrepeatone"; static constexpr const char* EVENT_REPEAT_ONE{"mpdrepeatone"};
static constexpr auto EVENT_RANDOM = "mpdrandom"; static constexpr const char* EVENT_RANDOM{"mpdrandom"};
static constexpr auto EVENT_SEEK = "mpdseek"; static constexpr const char* EVENT_SEEK{"mpdseek"};
unique_ptr<mpdconnection> m_mpd;
unique_ptr<mpdstatus> m_status;
string m_host{"127.0.0.1"};
string m_pass;
unsigned int m_port{6600U};
chrono::system_clock::time_point m_lastsync{};
float m_synctime{1.0f};
// This flag is used to let thru a broadcast once every time
// the connection state changes
mpd::connection_state m_statebroadcasted{mpd::connection_state::NONE};
progressbar_t m_bar_progress; progressbar_t m_bar_progress;
iconset_t m_icons; iconset_t m_icons;
@ -66,22 +80,8 @@ namespace modules {
label_t m_label_time; label_t m_label_time;
label_t m_label_offline; label_t m_label_offline;
unique_ptr<mpdconnection> m_mpd;
unique_ptr<mpdstatus> m_status;
string m_host = "127.0.0.1";
string m_pass = "";
unsigned int m_port = 6600;
string m_toggle_on_color; string m_toggle_on_color;
string m_toggle_off_color; string m_toggle_off_color;
chrono::system_clock::time_point m_lastsync;
float m_synctime = 1.0f;
// This flag is used to let thru a broadcast once every time
// the connection state changes
mpd::connection_state m_statebroadcasted;
}; };
} }

View File

@ -9,6 +9,7 @@ namespace modules {
public: public:
explicit text_module(const bar_settings&, string); explicit text_module(const bar_settings&, string);
void update() {}
string get_format() const; string get_format() const;
string get_output(); string get_output();
}; };

View File

@ -15,10 +15,10 @@ namespace modules {
template class module<mpd_module>; template class module<mpd_module>;
mpd_module::mpd_module(const bar_settings& bar, string name_) : event_module<mpd_module>(bar, move(name_)) { mpd_module::mpd_module(const bar_settings& bar, string name_) : event_module<mpd_module>(bar, move(name_)) {
m_host = m_conf.get<string>(name(), "host", m_host); m_host = m_conf.get(name(), "host", m_host);
m_port = m_conf.get<unsigned int>(name(), "port", m_port); m_port = m_conf.get(name(), "port", m_port);
m_pass = m_conf.get<string>(name(), "password", m_pass); m_pass = m_conf.get(name(), "password", m_pass);
m_synctime = m_conf.get<float>(name(), "interval", m_synctime); m_synctime = m_conf.get(name(), "interval", m_synctime);
// Add formats and elements {{{ // Add formats and elements {{{

View File

@ -68,9 +68,6 @@ namespace modules {
if (m_formatter->has(TAG_RAMP)) { if (m_formatter->has(TAG_RAMP)) {
m_ramp = load_ramp(m_conf, name(), TAG_RAMP); m_ramp = load_ramp(m_conf, name(), TAG_RAMP);
} }
// Trigger the initial draw event
update();
} }
/** /**

View File

@ -39,8 +39,6 @@ namespace modules {
// Create keyboard object // Create keyboard object
query_keyboard(); query_keyboard();
update();
} }
/** /**

View File

@ -80,9 +80,6 @@ namespace modules {
if (m_formatter->has(TAG_LABEL)) { if (m_formatter->has(TAG_LABEL)) {
m_label = load_optional_label(m_conf, name(), TAG_LABEL, "%title%"); m_label = load_optional_label(m_conf, name(), TAG_LABEL, "%title%");
} }
// Trigger the initial draw event
update();
} }
/** /**

View File

@ -75,8 +75,6 @@ namespace modules {
} }
} }
update();
// Make sure we get notified when root properties change // Make sure we get notified when root properties change
window{m_connection, m_connection.root()}.ensure_event_mask(XCB_EVENT_MASK_PROPERTY_CHANGE); window{m_connection, m_connection.root()}.ensure_event_mask(XCB_EVENT_MASK_PROPERTY_CHANGE);
} }

View File

@ -8,8 +8,9 @@ namespace concurrency_util {
static mutex mtx; static mutex mtx;
static map<thread::id, size_t> ids; static map<thread::id, size_t> ids;
std::lock_guard<mutex> lock(mtx); std::lock_guard<mutex> lock(mtx);
if (ids.find(id) == ids.end()) if (ids.find(id) == ids.end()) {
ids[id] = idx++; ids[id] = idx++;
}
return ids[id]; return ids[id];
} }
} }

View File

@ -72,9 +72,9 @@ bool font_manager::load(const string& name, uint8_t fontindex, int8_t offset_y)
return false; return false;
} else if (fontindex == 0) { } else if (fontindex == 0) {
fontindex = m_fonts.size(); fontindex = m_fonts.size();
m_logger.trace("font_manager: Assign font '%s' to index '%d'", name.c_str(), fontindex); m_logger.trace("font_manager: Assign font '%s' to index '%u'", name, fontindex);
} else { } else {
m_logger.trace("font_manager: Add font '%s' to index '%i'", name, fontindex); m_logger.trace("font_manager: Add font '%s' to index '%u'", name, fontindex);
} }
shared_ptr<font_ref> font{new font_ref{}, font_ref::deleter}; shared_ptr<font_ref> font{new font_ref{}, font_ref::deleter};