From 568837d06a8f697d65ba747a7c913503d7b2c65a Mon Sep 17 00:00:00 2001 From: Michael Carlberg Date: Wed, 11 Jan 2017 05:00:23 +0100 Subject: [PATCH] fix(x11): Preload the _NET_WM_WINDOW_OPACITY atom --- include/x11/atoms.hpp | 3 ++- src/components/bar.cpp | 2 +- src/x11/atoms.cpp | 4 +++- src/x11/wm.cpp | 7 +------ 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/include/x11/atoms.hpp b/include/x11/atoms.hpp index 42c229f4..169dd12a 100644 --- a/include/x11/atoms.hpp +++ b/include/x11/atoms.hpp @@ -8,7 +8,7 @@ struct cached_atom { xcb_atom_t* atom; }; -extern cached_atom ATOMS[34]; +extern cached_atom ATOMS[35]; extern xcb_atom_t _NET_SUPPORTED; extern xcb_atom_t _NET_CURRENT_DESKTOP; @@ -44,3 +44,4 @@ extern xcb_atom_t _XROOTMAP_ID; extern xcb_atom_t _XSETROOT_ID; extern xcb_atom_t ESETROOT_PMAP_ID; extern xcb_atom_t _COMPTON_SHADOW; +extern xcb_atom_t _NET_WM_WINDOW_OPACITY; diff --git a/src/components/bar.cpp b/src/components/bar.cpp index e0ed44d3..f8bd72f1 100644 --- a/src/components/bar.cpp +++ b/src/components/bar.cpp @@ -426,7 +426,7 @@ void bar::reconfigure_wm_hints() { xcb_icccm_set_wm_name(m_connection, m_opts.window, XCB_ATOM_STRING, 8, m_opts.wmname.size(), m_opts.wmname.c_str()); xcb_icccm_set_wm_class(m_connection, m_opts.window, 15, "polybar\0Polybar"); - m_log.trace("bar: Set window _NET_Wm_opts.window_TYPE"); + m_log.trace("bar: Set window _NET_WM_WINDOW_TYPE"); set_wm_window_type(m_connection, m_opts.window, {_NET_WM_WINDOW_TYPE_DOCK}); m_log.trace("bar: Set window _NET_WM_STATE"); diff --git a/src/x11/atoms.cpp b/src/x11/atoms.cpp index de8ede28..5fd98560 100644 --- a/src/x11/atoms.cpp +++ b/src/x11/atoms.cpp @@ -37,9 +37,10 @@ xcb_atom_t _XROOTMAP_ID; xcb_atom_t _XSETROOT_ID; xcb_atom_t ESETROOT_PMAP_ID; xcb_atom_t _COMPTON_SHADOW; +xcb_atom_t _NET_WM_WINDOW_OPACITY; // clang-format off -cached_atom ATOMS[34] = { +cached_atom ATOMS[35] = { {"_NET_SUPPORTED", sizeof("_NET_SUPPORTED") - 1, &_NET_SUPPORTED}, {"_NET_CURRENT_DESKTOP", sizeof("_NET_CURRENT_DESKTOP") - 1, &_NET_CURRENT_DESKTOP}, {"_NET_ACTIVE_WINDOW", sizeof("_NET_ACTIVE_WINDOW") - 1, &_NET_ACTIVE_WINDOW}, @@ -74,5 +75,6 @@ cached_atom ATOMS[34] = { {"_XSETROOT_ID", sizeof("_XSETROOT_ID") - 1, &_XSETROOT_ID}, {"ESETROOT_PMAP_ID", sizeof("ESETROOT_PMAP_ID") - 1, &ESETROOT_PMAP_ID}, {"_COMPTON_SHADOW", sizeof("_COMPTON_SHADOW") - 1, &_COMPTON_SHADOW}, + {"_NET_WM_WINDOW_OPACITY", sizeof("_NET_WM_WINDOW_OPACITY") - 1, &_NET_WM_WINDOW_OPACITY}, }; // clang-format on diff --git a/src/x11/wm.cpp b/src/x11/wm.cpp index 4142f159..1aabdba2 100644 --- a/src/x11/wm.cpp +++ b/src/x11/wm.cpp @@ -38,12 +38,7 @@ namespace wm_util { } void set_wm_window_opacity(xcb_connection_t* conn, xcb_window_t win, uint64_t values) { - xcb_intern_atom_reply_t* reply{ - xcb_intern_atom_reply(conn, xcb_intern_atom(conn, false, 22, "_NET_WM_WINDOW_OPACITY"), nullptr)}; - if (reply) { - xcb_change_property(conn, XCB_PROP_MODE_REPLACE, win, reply->atom, XCB_ATOM_CARDINAL, 32, 1, &values); - free(reply); - } + xcb_change_property(conn, XCB_PROP_MODE_REPLACE, win, _NET_WM_WINDOW_OPACITY, XCB_ATOM_CARDINAL, 32, 1, &values); } }