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:
parent
6d3b323f16
commit
ca4426a962
@ -69,6 +69,7 @@ namespace modules {
|
||||
void set_desktop_urgent(xcb_window_t window);
|
||||
|
||||
bool input(string&& cmd);
|
||||
vector<string> get_desktop_names();
|
||||
|
||||
private:
|
||||
static constexpr const char* DEFAULT_ICON{"icon-default"};
|
||||
|
@ -24,6 +24,7 @@ namespace ewmh_util {
|
||||
vector<position> get_desktop_viewports(int screen = 0);
|
||||
vector<string> get_desktop_names(int screen = 0);
|
||||
unsigned int get_current_desktop(int screen = 0);
|
||||
unsigned int get_number_of_desktops(int screen = 0);
|
||||
xcb_window_t get_active_window(int screen = 0);
|
||||
|
||||
void change_current_desktop(unsigned int desktop);
|
||||
|
@ -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
|
||||
*/
|
||||
|
@ -77,6 +77,13 @@ namespace ewmh_util {
|
||||
return desktop;
|
||||
}
|
||||
|
||||
unsigned int get_number_of_desktops(int screen) {
|
||||
auto conn = initialize().get();
|
||||
unsigned int desktops = XCB_NONE;
|
||||
xcb_ewmh_get_number_of_desktops_reply(conn, xcb_ewmh_get_number_of_desktops(conn, screen), &desktops, nullptr);
|
||||
return desktops;
|
||||
}
|
||||
|
||||
vector<position> get_desktop_viewports(int screen) {
|
||||
auto conn = initialize().get();
|
||||
vector<position> viewports;
|
||||
|
Loading…
Reference in New Issue
Block a user