feat(xworkspaces): Persistent urgent hint (#2340)
* add urgent hint * feat(xworkspaces): Fully implement urgency hint Co-authored-by: Jérôme BOULMIER <jerome.boulmier@outlook.fr>
This commit is contained in:
parent
80a50874fd
commit
412f4c723f
@ -62,6 +62,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- IPC commands to change visibility of modules
|
- IPC commands to change visibility of modules
|
||||||
(`hide.<name>`, `show.<name>`, and `toggle.<name>`)
|
(`hide.<name>`, `show.<name>`, and `toggle.<name>`)
|
||||||
([`#2108`](https://github.com/polybar/polybar/issues/2108))
|
([`#2108`](https://github.com/polybar/polybar/issues/2108))
|
||||||
|
- `internal/xworkspaces`: Make the urgent hint persistent
|
||||||
|
([`#1081`](https://github.com/polybar/polybar/issues/1081))
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Slight changes to the value ranges the different ramp levels are responsible
|
- Slight changes to the value ranges the different ramp levels are responsible
|
||||||
|
@ -68,9 +68,9 @@ namespace modules {
|
|||||||
void handle(const evt::property_notify& evt);
|
void handle(const evt::property_notify& evt);
|
||||||
|
|
||||||
void rebuild_clientlist();
|
void rebuild_clientlist();
|
||||||
|
void rebuild_urgent_hints();
|
||||||
void rebuild_desktops();
|
void rebuild_desktops();
|
||||||
void rebuild_desktop_states();
|
void rebuild_desktop_states();
|
||||||
void set_desktop_urgent(xcb_window_t window);
|
|
||||||
|
|
||||||
bool input(const string& action, const string& data);
|
bool input(const string& action, const string& data);
|
||||||
|
|
||||||
@ -91,6 +91,7 @@ namespace modules {
|
|||||||
bool m_monitorsupport{true};
|
bool m_monitorsupport{true};
|
||||||
|
|
||||||
vector<string> m_desktop_names;
|
vector<string> m_desktop_names;
|
||||||
|
vector<bool> m_urgent_desktops;
|
||||||
unsigned int m_current_desktop;
|
unsigned int m_current_desktop;
|
||||||
string m_current_desktop_name;
|
string m_current_desktop_name;
|
||||||
|
|
||||||
|
@ -119,9 +119,8 @@ namespace modules {
|
|||||||
m_current_desktop_name = m_desktop_names[m_current_desktop];
|
m_current_desktop_name = m_desktop_names[m_current_desktop];
|
||||||
rebuild_desktop_states();
|
rebuild_desktop_states();
|
||||||
} else if (evt->atom == WM_HINTS) {
|
} else if (evt->atom == WM_HINTS) {
|
||||||
if (icccm_util::get_wm_urgency(m_connection, evt->window)) {
|
rebuild_urgent_hints();
|
||||||
set_desktop_urgent(evt->window);
|
rebuild_desktop_states();
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -146,7 +145,21 @@ namespace modules {
|
|||||||
// rebuild entire mapping of clients to desktops
|
// rebuild entire mapping of clients to desktops
|
||||||
m_clients.clear();
|
m_clients.clear();
|
||||||
for (auto&& client : newclients) {
|
for (auto&& client : newclients) {
|
||||||
m_clients[client] = ewmh_util::get_desktop_from_window(client);
|
auto desk = ewmh_util::get_desktop_from_window(client);
|
||||||
|
m_clients[client] = desk;
|
||||||
|
}
|
||||||
|
|
||||||
|
rebuild_urgent_hints();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Goes through all clients and updates the urgent hints on the desktop they are on.
|
||||||
|
*/
|
||||||
|
void xworkspaces_module::rebuild_urgent_hints() {
|
||||||
|
m_urgent_desktops.assign(m_desktop_names.size(), false);
|
||||||
|
for (auto&& client : ewmh_util::get_client_list()) {
|
||||||
|
auto desk = ewmh_util::get_desktop_from_window(client);
|
||||||
|
m_urgent_desktops[desk] = m_urgent_desktops[desk] || icccm_util::get_wm_urgency(m_connection, client);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,7 +256,9 @@ namespace modules {
|
|||||||
|
|
||||||
for (auto&& v : m_viewports) {
|
for (auto&& v : m_viewports) {
|
||||||
for (auto&& d : v->desktops) {
|
for (auto&& d : v->desktops) {
|
||||||
if (d->index == m_current_desktop) {
|
if (m_urgent_desktops[d->index]) {
|
||||||
|
d->state = desktop_state::URGENT;
|
||||||
|
} else if (d->index == m_current_desktop) {
|
||||||
d->state = desktop_state::ACTIVE;
|
d->state = desktop_state::ACTIVE;
|
||||||
} else if (occupied_desks.count(d->index) > 0) {
|
} else if (occupied_desks.count(d->index) > 0) {
|
||||||
d->state = desktop_state::OCCUPIED;
|
d->state = desktop_state::OCCUPIED;
|
||||||
@ -275,30 +290,6 @@ namespace modules {
|
|||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Find window and set corresponding desktop to urgent
|
|
||||||
*/
|
|
||||||
void xworkspaces_module::set_desktop_urgent(xcb_window_t window) {
|
|
||||||
auto desk = ewmh_util::get_desktop_from_window(window);
|
|
||||||
if (desk == m_current_desktop)
|
|
||||||
// ignore if current desktop is urgent
|
|
||||||
return;
|
|
||||||
for (auto&& v : m_viewports) {
|
|
||||||
for (auto&& d : v->desktops) {
|
|
||||||
if (d->index == desk && d->state != desktop_state::URGENT) {
|
|
||||||
d->state = desktop_state::URGENT;
|
|
||||||
|
|
||||||
d->label = m_labels.at(d->state)->clone();
|
|
||||||
d->label->reset_tokens();
|
|
||||||
d->label->replace_token("%index%", to_string(d->index + 1));
|
|
||||||
d->label->replace_token("%name%", m_desktop_names[d->index]);
|
|
||||||
d->label->replace_token("%icon%", m_icons->get(m_desktop_names[d->index], DEFAULT_ICON)->get());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch and parse data
|
* Fetch and parse data
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user