mirror of
https://github.com/polybar/polybar.git
synced 2026-02-24 09:15:27 +00:00
fix(xworkspace): Fully support _NET_DESKTOP_NAMES spec (#1579)
Ref https://specifications.freedesktop.org/wm-spec/wm-spec-latest.html#idm140200472706208 Fixes #1491 Fixes #248 Closes #904
This commit is contained in:
committed by
Patrick Ziegler
parent
6d3b323f16
commit
ca4426a962
@ -81,7 +81,7 @@ namespace modules {
|
||||
m_monitors = randr_util::get_monitors(m_connection, m_connection.root(), false);
|
||||
|
||||
// Get desktop details
|
||||
m_desktop_names = ewmh_util::get_desktop_names();
|
||||
m_desktop_names = get_desktop_names();
|
||||
m_current_desktop = ewmh_util::get_current_desktop();
|
||||
|
||||
rebuild_desktops();
|
||||
@ -97,8 +97,8 @@ namespace modules {
|
||||
void xworkspaces_module::handle(const evt::property_notify& evt) {
|
||||
if (evt->atom == m_ewmh->_NET_CLIENT_LIST) {
|
||||
rebuild_clientlist();
|
||||
} else if (evt->atom == m_ewmh->_NET_DESKTOP_NAMES) {
|
||||
m_desktop_names = ewmh_util::get_desktop_names();
|
||||
} else if (evt->atom == m_ewmh->_NET_DESKTOP_NAMES || evt->atom == m_ewmh->_NET_NUMBER_OF_DESKTOPS) {
|
||||
m_desktop_names = get_desktop_names();
|
||||
rebuild_desktops();
|
||||
rebuild_desktop_states();
|
||||
} else if (evt->atom == m_ewmh->_NET_CURRENT_DESKTOP) {
|
||||
@ -224,6 +224,22 @@ namespace modules {
|
||||
}
|
||||
}
|
||||
|
||||
vector<string> xworkspaces_module::get_desktop_names(){
|
||||
vector<string> names = ewmh_util::get_desktop_names();
|
||||
unsigned int desktops_number = ewmh_util::get_number_of_desktops();
|
||||
if(desktops_number == names.size()) {
|
||||
return names;
|
||||
}
|
||||
else if(desktops_number < names.size()) {
|
||||
names.erase(names.begin()+desktops_number, names.end());
|
||||
return names;
|
||||
}
|
||||
for (unsigned int i = names.size(); i < desktops_number + 1; i++) {
|
||||
names.insert(names.end(), to_string(i));
|
||||
}
|
||||
return names;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find window and set corresponding desktop to urgent
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user