diff --git a/include/utils/i3.hpp b/include/utils/i3.hpp index 8e643a70..ae9f2e9d 100644 --- a/include/utils/i3.hpp +++ b/include/utils/i3.hpp @@ -19,7 +19,7 @@ namespace i3_util { shared_ptr focused_workspace(const connection_t&); vector root_windows(connection& conn, const string& output_name = ""); - bool restack_to_root(connection& conn, const monitor_t& mon, const xcb_window_t win); + bool restack_to_root(connection& conn, const xcb_window_t win); } namespace { diff --git a/src/components/bar.cpp b/src/components/bar.cpp index c887d50f..f6e45e45 100644 --- a/src/components/bar.cpp +++ b/src/components/bar.cpp @@ -369,7 +369,7 @@ void bar::restack_window() { restacked = bspwm_util::restack_to_root(m_connection, m_opts.monitor, m_opts.window); #if ENABLE_I3 } else if (wm_restack == "i3" && m_opts.override_redirect) { - restacked = i3_util::restack_to_root(m_connection, m_opts.monitor, m_opts.window); + restacked = i3_util::restack_to_root(m_connection, m_opts.window); } else if (wm_restack == "i3" && !m_opts.override_redirect) { m_log.warn("Ignoring restack of i3 window (not needed when `override-redirect = false`)"); wm_restack.clear(); @@ -492,6 +492,8 @@ void bar::handle(const evt::enter_notify&) { m_opts.dimmed = false; m_sig.emit(dim_window{1.0}); }); + } else if (m_taskqueue->exist("window-dim")) { + m_taskqueue->purge("window-dim"); } } diff --git a/src/utils/i3.cpp b/src/utils/i3.cpp index d170790b..19993ee1 100644 --- a/src/utils/i3.cpp +++ b/src/utils/i3.cpp @@ -7,6 +7,7 @@ #include "utils/socket.hpp" #include "utils/string.hpp" #include "x11/connection.hpp" +#include "x11/ewmh.hpp" #include "x11/icccm.hpp" POLYBAR_NS @@ -38,20 +39,30 @@ namespace i3_util { } /** - * Get all i3 root windows + * Get main root window */ - vector root_windows(connection& conn, const string& output_name) { - vector roots; + xcb_window_t root_window(connection& conn) { + auto ewmh = ewmh_util::initialize(); auto children = conn.query_tree(conn.screen()->root).children(); + const auto wm_name = [&](xcb_ewmh_connection_t* ewmh, xcb_window_t win) -> string { + string title; + if (!(title = ewmh_util::get_wm_name(ewmh, win)).empty()) { + return title; + } else if (!(title = icccm_util::get_wm_name(ewmh->connection, win)).empty()) { + return title; + } else { + return ""; + } + }; + for (auto it = children.begin(); it != children.end(); it++) { - auto wm_name = icccm_util::get_wm_name(conn, *it); - if (wm_name.compare("[i3 con] output " + output_name) == 0) { - roots.emplace_back(*it); + if (wm_name(&*ewmh, *it) == "i3") { + return *it; } } - return roots; + return XCB_NONE; } /** @@ -60,14 +71,13 @@ namespace i3_util { * * Fixes the issue with always-on-top window's */ - bool restack_to_root(connection& conn, const monitor_t& mon, const xcb_window_t win) { - for (auto&& root : root_windows(conn, mon->name)) { - const uint32_t value_mask = XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE; - const uint32_t value_list[2]{root, XCB_STACK_MODE_BELOW}; + bool restack_to_root(connection& conn, const xcb_window_t win) { + const uint32_t value_mask = XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE; + const uint32_t 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; } }