fix(bspwm): Restack against topmost root window.
The ewmh strategy has to be dropped because the `_NET_SUPPORTING_WM_CHECK` window may (at least in bspwm) appear anywhere in the window stack. To fix the overlapping monitors issue in #2873, we simply restack against the topmost of these root windows. Fixes #2972 Fixes #2873 (again)
This commit is contained in:
parent
1bfe117c5d
commit
c9752598a5
@ -52,7 +52,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Changed fuzzy match option on i3 and bspwm modules to find longest match instead of the first match ([`#2831`](https://github.com/polybar/polybar/pull/2831), [`#2829`](https://github.com/polybar/polybar/issues/2829)) by [@Ron0Studios](https://github.com/ron0studios/).
|
- Changed fuzzy match option on i3 and bspwm modules to find longest match instead of the first match ([`#2831`](https://github.com/polybar/polybar/pull/2831), [`#2829`](https://github.com/polybar/polybar/issues/2829)) by [@Ron0Studios](https://github.com/ron0studios/).
|
||||||
- `wm-restack`
|
- `wm-restack`
|
||||||
- `generic`: Is now a best effort combination of other restacking strategies. First tries `ewmh` and then the `bottom` strategy ([`#2961`](https://github.com/polybar/polybar/pull/2961))
|
- `generic`: Is now a best effort combination of other restacking strategies. First tries `ewmh` and then the `bottom` strategy ([`#2961`](https://github.com/polybar/polybar/pull/2961))
|
||||||
- `bspwm`: First tries the `ewmh` strategy before falling back to its old behavior ([`#2961`](https://github.com/polybar/polybar/pull/2961))
|
- `bspwm`: Will restack above the topmost bspwm root window instead of the root window associated with the monitor polybar is on ([`#3019`](https://github.com/polybar/polybar/pull/3019))
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Waiting for double click interval on modules that don't have a double click action ([`#2663`](https://github.com/polybar/polybar/issues/2663), [`#2695`](https://github.com/polybar/polybar/pull/2695))
|
- Waiting for double click interval on modules that don't have a double click action ([`#2663`](https://github.com/polybar/polybar/issues/2663), [`#2695`](https://github.com/polybar/polybar/pull/2695))
|
||||||
|
@ -1,38 +1,30 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <xcb/xcb.h>
|
|
||||||
#include <xcb/xcb_icccm.h>
|
|
||||||
|
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
#include "settings.hpp"
|
|
||||||
#include "utils/restack.hpp"
|
#include "utils/restack.hpp"
|
||||||
#include "utils/socket.hpp"
|
#include "utils/socket.hpp"
|
||||||
#include "utils/string.hpp"
|
|
||||||
#include "x11/extensions/randr.hpp"
|
|
||||||
#include "x11/window.hpp"
|
|
||||||
|
|
||||||
POLYBAR_NS
|
POLYBAR_NS
|
||||||
|
|
||||||
class connection;
|
class connection;
|
||||||
|
|
||||||
namespace bspwm_util {
|
namespace bspwm_util {
|
||||||
struct payload;
|
using connection_t = unique_ptr<socket_util::unix_connection>;
|
||||||
using connection_t = unique_ptr<socket_util::unix_connection>;
|
|
||||||
using payload_t = unique_ptr<payload>;
|
|
||||||
|
|
||||||
struct payload {
|
struct payload {
|
||||||
char data[BUFSIZ]{'\0'};
|
char data[BUFSIZ]{'\0'};
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
vector<xcb_window_t> root_windows(connection& conn);
|
using payload_t = unique_ptr<payload>;
|
||||||
restack_util::params get_restack_params(connection& conn, const monitor_t& mon, xcb_window_t bar_window);
|
|
||||||
|
|
||||||
string get_socket_path();
|
restack_util::params get_restack_params(connection& conn);
|
||||||
|
|
||||||
payload_t make_payload(const string& cmd);
|
string get_socket_path();
|
||||||
connection_t make_connection();
|
|
||||||
connection_t make_subscriber();
|
payload_t make_payload(const string& cmd);
|
||||||
}
|
connection_t make_connection();
|
||||||
|
connection_t make_subscriber();
|
||||||
|
} // namespace bspwm_util
|
||||||
|
|
||||||
POLYBAR_NS_END
|
POLYBAR_NS_END
|
||||||
|
@ -506,7 +506,7 @@ void bar::restack_window() {
|
|||||||
} else if (wm_restack == "bottom") {
|
} else if (wm_restack == "bottom") {
|
||||||
restack_params = restack_util::get_bottom_params(m_connection, bar_window);
|
restack_params = restack_util::get_bottom_params(m_connection, bar_window);
|
||||||
} else if (wm_restack == "bspwm") {
|
} else if (wm_restack == "bspwm") {
|
||||||
restack_params = bspwm_util::get_restack_params(m_connection, m_opts.monitor, bar_window);
|
restack_params = bspwm_util::get_restack_params(m_connection);
|
||||||
#if ENABLE_I3
|
#if ENABLE_I3
|
||||||
} else if (wm_restack == "i3" && m_opts.override_redirect) {
|
} else if (wm_restack == "i3" && m_opts.override_redirect) {
|
||||||
restack_params = i3_util::get_restack_params(m_connection);
|
restack_params = i3_util::get_restack_params(m_connection);
|
||||||
|
@ -1,64 +1,41 @@
|
|||||||
#include "utils/bspwm.hpp"
|
#include "utils/bspwm.hpp"
|
||||||
|
|
||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
|
#include <xcb/xcb.h>
|
||||||
|
|
||||||
#include "errors.hpp"
|
#include "errors.hpp"
|
||||||
#include "utils/env.hpp"
|
#include "utils/env.hpp"
|
||||||
|
#include "utils/string.hpp"
|
||||||
#include "x11/connection.hpp"
|
#include "x11/connection.hpp"
|
||||||
#include "x11/ewmh.hpp"
|
#include "x11/icccm.hpp"
|
||||||
|
|
||||||
POLYBAR_NS
|
POLYBAR_NS
|
||||||
|
|
||||||
namespace bspwm_util {
|
namespace bspwm_util {
|
||||||
/**
|
/**
|
||||||
* Get all bspwm root windows
|
* Returns window against which to restack.
|
||||||
|
*
|
||||||
|
* Bspwm creates one root window per monitor with a `WM_CLASS` value of `root\0Bspwm` and the window taking up the
|
||||||
|
* entire monitor.
|
||||||
|
* For overlapping monitors, stacking polybar above the root window for its monitor, but below the root window for an
|
||||||
|
* overlapping monitor, may cause the upper root window to obstruct polybar, at least in terms of receiving mouse
|
||||||
|
* clicks. Because of that, we simply restack polybar above the topmost root window.
|
||||||
*/
|
*/
|
||||||
vector<xcb_window_t> root_windows(connection& conn) {
|
restack_util::params get_restack_params(connection& conn) {
|
||||||
vector<xcb_window_t> roots;
|
|
||||||
auto children = conn.query_tree(conn.root()).children();
|
auto children = conn.query_tree(conn.root()).children();
|
||||||
|
|
||||||
for (auto it = children.begin(); it != children.end(); it++) {
|
xcb_window_t top_root = XCB_NONE;
|
||||||
xcb_icccm_get_wm_class_reply_t reply{};
|
|
||||||
reply.class_name = reply.instance_name = nullptr;
|
|
||||||
|
|
||||||
if (xcb_icccm_get_wm_class_reply(conn, xcb_icccm_get_wm_class(conn, *it), &reply, nullptr)) {
|
// Iteration happens from bottom to top
|
||||||
if (string_util::compare("Bspwm", reply.class_name) && string_util::compare("root", reply.instance_name)) {
|
for (xcb_window_t wid : children) {
|
||||||
roots.emplace_back(*it);
|
auto [instance_name, class_name] = icccm_util::get_wm_class(conn, wid);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (reply.class_name != nullptr || reply.instance_name != nullptr) {
|
if (string_util::compare("root", instance_name) && string_util::compare("Bspwm", class_name)) {
|
||||||
xcb_icccm_get_wm_class_reply_wipe(&reply);
|
top_root = wid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return roots;
|
return {top_root, XCB_STACK_MODE_ABOVE};
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns window against which to restack.
|
|
||||||
*/
|
|
||||||
restack_util::params get_restack_params(connection& conn, const monitor_t& mon, xcb_window_t bar_window) {
|
|
||||||
auto ewmh_params = restack_util::get_ewmh_params(conn);
|
|
||||||
|
|
||||||
if (restack_util::are_siblings(conn, bar_window, ewmh_params.first)) {
|
|
||||||
return ewmh_params;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto&& root : root_windows(conn)) {
|
|
||||||
auto geom = conn.get_geometry(root);
|
|
||||||
|
|
||||||
if (mon->x != geom->x || mon->y != geom->y) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (mon->w != geom->width || mon->h != geom->height) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
return {root, XCB_STACK_MODE_ABOVE};
|
|
||||||
}
|
|
||||||
|
|
||||||
return restack_util::NONE_PARAMS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user