dwm: Remove id param from update_title_label

Use m_focused_client_id to update the label. It makes more sense to use this
variable instead of passing a client id to the function.
This commit is contained in:
Mihir Lad 2020-07-21 00:42:58 -04:00
parent bc16268d30
commit 5967ac3b0b
2 changed files with 9 additions and 10 deletions

View File

@ -158,12 +158,10 @@ namespace modules {
void update_tag_labels(); void update_tag_labels();
/** /**
* Get the window title of the specified client from dwm and update the * Get the window title of the currently focused client from dwm and update
* title label * the title label
*
* @param client_id The window XID of the client
*/ */
void update_title_label(window_t client_id); void update_title_label();
/** /**
* Translate the tag's tag states to a state_t enum value * Translate the tag's tag states to a state_t enum value

View File

@ -60,6 +60,7 @@ namespace modules {
try { try {
update_monitor_ref(); update_monitor_ref();
m_focused_client_id = m_bar_mon->clients.selected;
// Initialize tags array // Initialize tags array
auto tags = m_ipc->get_tags(); auto tags = m_ipc->get_tags();
@ -90,7 +91,7 @@ namespace modules {
// These events are only necessary to update the focused window title // These events are only necessary to update the focused window title
if (m_title_label) { if (m_title_label) {
update_title_label(m_bar_mon->clients.selected); update_title_label();
m_ipc->on_client_focus_change = [this](const dwmipc::ClientFocusChangeEvent& ev) { m_ipc->on_client_focus_change = [this](const dwmipc::ClientFocusChangeEvent& ev) {
this->on_client_focus_change(ev); this->on_client_focus_change(ev);
}; };
@ -296,11 +297,11 @@ namespace modules {
} }
} }
void dwm_module::update_title_label(window_t client_id) { void dwm_module::update_title_label() {
std::string new_title; std::string new_title;
if (client_id != 0) { if (m_focused_client_id != 0) {
try { try {
new_title = m_ipc->get_client(client_id)->name; new_title = m_ipc->get_client(m_focused_client_id)->name;
} catch (const dwmipc::SocketClosedError& err) { } catch (const dwmipc::SocketClosedError& err) {
m_log.err("%s: Disconnected from socket: %s", name(), err.what()); m_log.err("%s: Disconnected from socket: %s", name(), err.what());
reconnect_dwm(); reconnect_dwm();
@ -363,7 +364,7 @@ namespace modules {
void dwm_module::on_client_focus_change(const dwmipc::ClientFocusChangeEvent& ev) { void dwm_module::on_client_focus_change(const dwmipc::ClientFocusChangeEvent& ev) {
if (ev.monitor_num == m_bar_mon->num) { if (ev.monitor_num == m_bar_mon->num) {
m_focused_client_id = ev.new_win_id; m_focused_client_id = ev.new_win_id;
update_title_label(ev.new_win_id); update_title_label();
} }
} }