Clean up restacking code
Restacking algorithms now only need to provide the sibling window and stacking mode.
This commit is contained in:
parent
76c7ee3bf6
commit
59acb4150b
@ -25,7 +25,7 @@ namespace bspwm_util {
|
|||||||
};
|
};
|
||||||
|
|
||||||
vector<xcb_window_t> root_windows(connection& conn);
|
vector<xcb_window_t> root_windows(connection& conn);
|
||||||
bool restack_to_root(connection& conn, const monitor_t& mon, const xcb_window_t win);
|
xcb_window_t get_restack_sibling(connection& conn, const monitor_t& mon);
|
||||||
|
|
||||||
string get_socket_path();
|
string get_socket_path();
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ namespace i3_util {
|
|||||||
shared_ptr<workspace_t> focused_workspace(const connection_t&);
|
shared_ptr<workspace_t> focused_workspace(const connection_t&);
|
||||||
|
|
||||||
vector<xcb_window_t> root_windows(connection& conn, const string& output_name = "");
|
vector<xcb_window_t> root_windows(connection& conn, const string& output_name = "");
|
||||||
bool restack_to_root(connection& conn, const xcb_window_t win);
|
xcb_window_t get_restack_sibling(connection& conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -11,9 +11,9 @@
|
|||||||
#include "events/signal_emitter.hpp"
|
#include "events/signal_emitter.hpp"
|
||||||
#include "tags/dispatch.hpp"
|
#include "tags/dispatch.hpp"
|
||||||
#include "utils/bspwm.hpp"
|
#include "utils/bspwm.hpp"
|
||||||
#include "utils/restack.hpp"
|
|
||||||
#include "utils/color.hpp"
|
#include "utils/color.hpp"
|
||||||
#include "utils/math.hpp"
|
#include "utils/math.hpp"
|
||||||
|
#include "utils/restack.hpp"
|
||||||
#include "utils/string.hpp"
|
#include "utils/string.hpp"
|
||||||
#include "utils/units.hpp"
|
#include "utils/units.hpp"
|
||||||
#include "x11/atoms.hpp"
|
#include "x11/atoms.hpp"
|
||||||
@ -492,23 +492,20 @@ void bar::restack_window() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto restacked = false;
|
xcb_window_t restack_sibling = XCB_NONE;
|
||||||
|
xcb_stack_mode_t stack_mode = XCB_STACK_MODE_ABOVE;
|
||||||
|
|
||||||
if (wm_restack == "generic") {
|
if (wm_restack == "generic") {
|
||||||
try {
|
|
||||||
auto children = m_connection.query_tree(m_connection.root()).children();
|
auto children = m_connection.query_tree(m_connection.root()).children();
|
||||||
if (children.begin() != children.end() && *children.begin() != m_opts.x_data.window) {
|
if (children.begin() != children.end() && *children.begin() != m_opts.x_data.window) {
|
||||||
restack_util::restack_relative(m_connection, m_opts.x_data.window, *children.begin(), XCB_STACK_MODE_BELOW);
|
restack_sibling = *children.begin();
|
||||||
}
|
stack_mode = XCB_STACK_MODE_BELOW;
|
||||||
restacked = true;
|
|
||||||
} catch (const exception& err) {
|
|
||||||
m_log.err("Failed to restack bar window (err=%s)", err.what());
|
|
||||||
}
|
}
|
||||||
} else if (wm_restack == "bspwm") {
|
} else if (wm_restack == "bspwm") {
|
||||||
restacked = bspwm_util::restack_to_root(m_connection, m_opts.monitor, m_opts.x_data.window);
|
restack_sibling = bspwm_util::get_restack_sibling(m_connection, m_opts.monitor);
|
||||||
#if ENABLE_I3
|
#if ENABLE_I3
|
||||||
} else if (wm_restack == "i3" && m_opts.override_redirect) {
|
} else if (wm_restack == "i3" && m_opts.override_redirect) {
|
||||||
restacked = i3_util::restack_to_root(m_connection, m_opts.x_data.window);
|
restack_sibling = i3_util::get_restack_sibling(m_connection);
|
||||||
} else if (wm_restack == "i3" && !m_opts.override_redirect) {
|
} else if (wm_restack == "i3" && !m_opts.override_redirect) {
|
||||||
m_log.warn("Ignoring restack of i3 window (not needed when `override-redirect = false`)");
|
m_log.warn("Ignoring restack of i3 window (not needed when `override-redirect = false`)");
|
||||||
wm_restack.clear();
|
wm_restack.clear();
|
||||||
@ -518,8 +515,13 @@ void bar::restack_window() {
|
|||||||
wm_restack.clear();
|
wm_restack.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (restacked) {
|
if (restack_sibling != XCB_NONE) {
|
||||||
|
try {
|
||||||
|
restack_util::restack_relative(m_connection, m_opts.x_data.window, restack_sibling, stack_mode);
|
||||||
m_log.info("Successfully restacked bar window");
|
m_log.info("Successfully restacked bar window");
|
||||||
|
} catch (const exception& err) {
|
||||||
|
m_log.err("Failed to restack bar window (err=%s)", err.what());
|
||||||
|
}
|
||||||
} else if (!wm_restack.empty()) {
|
} else if (!wm_restack.empty()) {
|
||||||
m_log.err("Failed to restack bar window");
|
m_log.err("Failed to restack bar window");
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include "errors.hpp"
|
#include "errors.hpp"
|
||||||
#include "utils/env.hpp"
|
#include "utils/env.hpp"
|
||||||
#include "x11/connection.hpp"
|
#include "x11/connection.hpp"
|
||||||
|
#include "x11/ewmh.hpp"
|
||||||
|
|
||||||
POLYBAR_NS
|
POLYBAR_NS
|
||||||
|
|
||||||
@ -40,7 +41,7 @@ namespace bspwm_util {
|
|||||||
*
|
*
|
||||||
* Fixes the issue with always-on-top window's
|
* Fixes the issue with always-on-top window's
|
||||||
*/
|
*/
|
||||||
bool restack_to_root(connection& conn, const monitor_t& mon, const xcb_window_t win) {
|
xcb_window_t get_restack_sibling(connection& conn, const monitor_t& mon) {
|
||||||
for (auto&& root : root_windows(conn)) {
|
for (auto&& root : root_windows(conn)) {
|
||||||
auto geom = conn.get_geometry(root);
|
auto geom = conn.get_geometry(root);
|
||||||
|
|
||||||
@ -51,16 +52,10 @@ namespace bspwm_util {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const unsigned int value_mask = XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE;
|
return root;
|
||||||
const unsigned int value_list[2]{root, XCB_STACK_MODE_ABOVE};
|
|
||||||
|
|
||||||
conn.configure_window_checked(win, value_mask, value_list);
|
|
||||||
conn.flush();
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return XCB_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -71,14 +71,8 @@ namespace i3_util {
|
|||||||
*
|
*
|
||||||
* Fixes the issue with always-on-top window's
|
* Fixes the issue with always-on-top window's
|
||||||
*/
|
*/
|
||||||
bool restack_to_root(connection& conn, const xcb_window_t win) {
|
xcb_window_t get_restack_sibling(connection& conn) {
|
||||||
const unsigned int value_mask = XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE;
|
return root_window(conn);
|
||||||
const unsigned int value_list[2]{root_window(conn), XCB_STACK_MODE_ABOVE};
|
|
||||||
if (value_list[0] != XCB_NONE) {
|
|
||||||
conn.configure_window_checked(win, value_mask, value_list);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
} // namespace i3_util
|
} // namespace i3_util
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user