refactor: Cleanup
This commit is contained in:
parent
c2acdff7d4
commit
9f4638f42c
@ -59,6 +59,8 @@ class bar : public xpp::event::sink<evt::button_press, evt::expose, evt::propert
|
|||||||
string m_lastinput;
|
string m_lastinput;
|
||||||
|
|
||||||
std::mutex m_mutex;
|
std::mutex m_mutex;
|
||||||
|
|
||||||
|
event_timer m_buttonpress{};
|
||||||
};
|
};
|
||||||
|
|
||||||
di::injector<unique_ptr<bar>> configure_bar();
|
di::injector<unique_ptr<bar>> configure_bar();
|
||||||
|
@ -134,4 +134,18 @@ struct action_block {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct event_timer {
|
||||||
|
xcb_timestamp_t event{0};
|
||||||
|
uint32_t delay_ms{0U};
|
||||||
|
|
||||||
|
bool throttle(xcb_timestamp_t evt) {
|
||||||
|
if (evt > event + delay_ms) {
|
||||||
|
event = evt;
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
POLYBAR_NS_END
|
POLYBAR_NS_END
|
||||||
|
@ -49,7 +49,7 @@ namespace modules {
|
|||||||
connection& m_connection;
|
connection& m_connection;
|
||||||
monitor_t m_output;
|
monitor_t m_output;
|
||||||
xcb_window_t m_proxy;
|
xcb_window_t m_proxy;
|
||||||
xcb_timestamp_t m_timestamp;
|
event_timer m_randrnotify{};
|
||||||
|
|
||||||
ramp_t m_ramp;
|
ramp_t m_ramp;
|
||||||
label_t m_label;
|
label_t m_label;
|
||||||
|
@ -80,9 +80,9 @@ namespace modules {
|
|||||||
bool build(builder* builder, const string& tag) const;
|
bool build(builder* builder, const string& tag) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static constexpr auto TAG_LABEL = "<label>";
|
static constexpr const char* TAG_LABEL{"<label>"};
|
||||||
|
|
||||||
xcb_ewmh_connection_t m_ewmh;
|
ewmh_connection_t m_ewmh;
|
||||||
unique_ptr<active_window> m_active;
|
unique_ptr<active_window> m_active;
|
||||||
label_t m_label;
|
label_t m_label;
|
||||||
};
|
};
|
||||||
|
@ -7,12 +7,13 @@
|
|||||||
#include "config.hpp"
|
#include "config.hpp"
|
||||||
#include "utils/socket.hpp"
|
#include "utils/socket.hpp"
|
||||||
#include "utils/string.hpp"
|
#include "utils/string.hpp"
|
||||||
#include "x11/connection.hpp"
|
|
||||||
#include "x11/randr.hpp"
|
#include "x11/randr.hpp"
|
||||||
#include "x11/window.hpp"
|
#include "x11/window.hpp"
|
||||||
|
|
||||||
POLYBAR_NS
|
POLYBAR_NS
|
||||||
|
|
||||||
|
class connection;
|
||||||
|
|
||||||
namespace bspwm_util {
|
namespace bspwm_util {
|
||||||
struct payload;
|
struct payload;
|
||||||
using connection_t = unique_ptr<socket_util::unix_connection>;
|
using connection_t = unique_ptr<socket_util::unix_connection>;
|
||||||
|
@ -3,11 +3,12 @@
|
|||||||
#include <i3ipc++/ipc.hpp>
|
#include <i3ipc++/ipc.hpp>
|
||||||
|
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
#include "x11/connection.hpp"
|
|
||||||
#include "x11/randr.hpp"
|
#include "x11/randr.hpp"
|
||||||
|
|
||||||
POLYBAR_NS
|
POLYBAR_NS
|
||||||
|
|
||||||
|
class connection;
|
||||||
|
|
||||||
namespace i3_util {
|
namespace i3_util {
|
||||||
using connection_t = i3ipc::connection;
|
using connection_t = i3ipc::connection;
|
||||||
|
|
||||||
|
@ -8,21 +8,17 @@
|
|||||||
#include <xpp/xpp.hpp>
|
#include <xpp/xpp.hpp>
|
||||||
|
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
#include "utils/memory.hpp"
|
|
||||||
#include "utils/string.hpp"
|
|
||||||
#include "x11/atoms.hpp"
|
|
||||||
#include "x11/types.hpp"
|
#include "x11/types.hpp"
|
||||||
#include "x11/xutils.hpp"
|
|
||||||
|
|
||||||
#ifdef ENABLE_DAMAGE_EXT
|
#ifdef ENABLE_DAMAGE_EXT
|
||||||
#include "x11/damage.hpp"
|
#include "x11/damage.hpp"
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_RANDR_EXT
|
|
||||||
#include "x11/randr.hpp"
|
|
||||||
#endif
|
|
||||||
#ifdef ENABLE_RENDER_EXT
|
#ifdef ENABLE_RENDER_EXT
|
||||||
#include "x11/render.hpp"
|
#include "x11/render.hpp"
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef ENABLE_RANDR_EXT
|
||||||
|
#include "x11/randr.hpp"
|
||||||
|
#endif
|
||||||
|
|
||||||
POLYBAR_NS
|
POLYBAR_NS
|
||||||
|
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <xcb/xcb.h>
|
||||||
|
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
#include "x11/connection.hpp"
|
|
||||||
|
|
||||||
POLYBAR_NS
|
POLYBAR_NS
|
||||||
|
|
||||||
|
class connection;
|
||||||
|
|
||||||
namespace draw_util {
|
namespace draw_util {
|
||||||
void fill(connection& conn, xcb_drawable_t d, xcb_gcontext_t g, const xcb_rectangle_t rect);
|
void fill(connection& conn, xcb_drawable_t d, xcb_gcontext_t g, const xcb_rectangle_t rect);
|
||||||
void fill(connection& conn, xcb_drawable_t d, xcb_gcontext_t g, int16_t x, int16_t y, uint16_t w, uint16_t h);
|
void fill(connection& conn, xcb_drawable_t d, xcb_gcontext_t g, int16_t x, int16_t y, uint16_t w, uint16_t h);
|
||||||
|
@ -3,11 +3,10 @@
|
|||||||
#include <xcb/xcb.h>
|
#include <xcb/xcb.h>
|
||||||
|
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
|
#include "x11/connection.hpp"
|
||||||
|
|
||||||
POLYBAR_NS
|
POLYBAR_NS
|
||||||
|
|
||||||
class connection;
|
|
||||||
|
|
||||||
namespace graphics_util {
|
namespace graphics_util {
|
||||||
struct root_pixmap {
|
struct root_pixmap {
|
||||||
uint8_t depth{0};
|
uint8_t depth{0};
|
||||||
|
@ -3,13 +3,23 @@
|
|||||||
#include "config.hpp"
|
#include "config.hpp"
|
||||||
|
|
||||||
// fwd
|
// fwd
|
||||||
#ifdef ENABLE_RANDR_EXT
|
|
||||||
namespace xpp {
|
namespace xpp {
|
||||||
|
#ifdef ENABLE_DAMAGE_EXT
|
||||||
|
namespace damage {
|
||||||
|
class extension;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#ifdef ENABLE_RANDR_EXT
|
||||||
namespace randr {
|
namespace randr {
|
||||||
class extension;
|
class extension;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef ENABLE_RENDER_EXT
|
||||||
|
namespace render {
|
||||||
|
class extension;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#include <xpp/xpp.hpp>
|
#include <xpp/xpp.hpp>
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <xcb/xcb_aux.h>
|
||||||
|
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
#include "x11/connection.hpp"
|
#include "x11/connection.hpp"
|
||||||
#include "x11/randr.hpp"
|
#include "x11/randr.hpp"
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <xcb/xcb_aux.h>
|
||||||
|
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
#include "components/types.hpp"
|
#include "components/types.hpp"
|
||||||
#include "x11/connection.hpp"
|
#include "x11/connection.hpp"
|
||||||
|
|
||||||
POLYBAR_NS
|
POLYBAR_NS
|
||||||
|
|
||||||
using connection_t = connection;
|
|
||||||
|
|
||||||
struct cw_size {
|
struct cw_size {
|
||||||
explicit cw_size(uint16_t w, uint16_t h) : w(w), h(h) {}
|
explicit cw_size(uint16_t w, uint16_t h) : w(w), h(h) {}
|
||||||
explicit cw_size(struct size size) : w(size.w), h(size.h) {}
|
explicit cw_size(struct size size) : w(size.w), h(size.h) {}
|
||||||
|
@ -6,18 +6,16 @@
|
|||||||
|
|
||||||
POLYBAR_NS
|
POLYBAR_NS
|
||||||
|
|
||||||
class connection;
|
|
||||||
|
|
||||||
namespace wm_util {
|
namespace wm_util {
|
||||||
void set_wmname(connection& conn, xcb_window_t win, const string& wm_name, const string& wm_class);
|
void set_wmname(xcb_connection_t* conn, xcb_window_t win, const string& wm_name, const string& wm_class);
|
||||||
void set_wmprotocols(connection& conn, xcb_window_t win, vector<xcb_atom_t> flags);
|
void set_wmprotocols(xcb_connection_t* conn, xcb_window_t win, vector<xcb_atom_t> flags);
|
||||||
void set_windowtype(connection& conn, xcb_window_t win, vector<xcb_atom_t> types);
|
void set_windowtype(xcb_connection_t* conn, xcb_window_t win, vector<xcb_atom_t> types);
|
||||||
void set_wmstate(connection& conn, xcb_window_t win, vector<xcb_atom_t> states);
|
void set_wmstate(xcb_connection_t* conn, xcb_window_t win, vector<xcb_atom_t> states);
|
||||||
void set_wmpid(connection& conn, xcb_window_t win, pid_t pid);
|
void set_wmpid(xcb_connection_t* conn, xcb_window_t win, pid_t pid);
|
||||||
void set_wmdesktop(connection& conn, xcb_window_t win, uint32_t desktop = -1u);
|
void set_wmdesktop(xcb_connection_t* conn, xcb_window_t win, uint32_t desktop = -1u);
|
||||||
|
|
||||||
void set_trayorientation(connection& conn, xcb_window_t win, uint32_t orientation);
|
void set_trayorientation(xcb_connection_t* conn, xcb_window_t win, uint32_t orientation);
|
||||||
void set_trayvisual(connection& conn, xcb_window_t win, xcb_visualid_t visual);
|
void set_trayvisual(xcb_connection_t* conn, xcb_window_t win, xcb_visualid_t visual);
|
||||||
}
|
}
|
||||||
|
|
||||||
POLYBAR_NS_END
|
POLYBAR_NS_END
|
||||||
|
@ -4,14 +4,19 @@
|
|||||||
#include <xcb/xcb_util.h>
|
#include <xcb/xcb_util.h>
|
||||||
|
|
||||||
#include "common.hpp"
|
#include "common.hpp"
|
||||||
|
#include "x11/randr.hpp"
|
||||||
|
|
||||||
POLYBAR_NS
|
POLYBAR_NS
|
||||||
|
|
||||||
class connection;
|
class connection;
|
||||||
|
class config;
|
||||||
|
|
||||||
namespace xutils {
|
namespace xutils {
|
||||||
xcb_connection_t* get_connection();
|
xcb_connection_t* get_connection();
|
||||||
|
|
||||||
|
uint32_t event_timer_ms(const config& conf, const xcb_button_press_event_t&);
|
||||||
|
uint32_t event_timer_ms(const config& conf, const xcb_randr_notify_event_t&);
|
||||||
|
|
||||||
void pack_values(uint32_t mask, const uint32_t* src, uint32_t* dest);
|
void pack_values(uint32_t mask, const uint32_t* src, uint32_t* dest);
|
||||||
void pack_values(uint32_t mask, const xcb_params_cw_t* src, uint32_t* dest);
|
void pack_values(uint32_t mask, const xcb_params_cw_t* src, uint32_t* dest);
|
||||||
void pack_values(uint32_t mask, const xcb_params_gc_t* src, uint32_t* dest);
|
void pack_values(uint32_t mask, const xcb_params_gc_t* src, uint32_t* dest);
|
||||||
|
@ -8,10 +8,14 @@
|
|||||||
#include "utils/color.hpp"
|
#include "utils/color.hpp"
|
||||||
#include "utils/math.hpp"
|
#include "utils/math.hpp"
|
||||||
#include "utils/string.hpp"
|
#include "utils/string.hpp"
|
||||||
|
#include "x11/atoms.hpp"
|
||||||
|
#include "x11/connection.hpp"
|
||||||
|
#include "x11/ewmh.hpp"
|
||||||
#include "x11/fonts.hpp"
|
#include "x11/fonts.hpp"
|
||||||
#include "x11/graphics.hpp"
|
#include "x11/graphics.hpp"
|
||||||
#include "x11/tray.hpp"
|
#include "x11/tray.hpp"
|
||||||
#include "x11/wm.hpp"
|
#include "x11/wm.hpp"
|
||||||
|
#include "x11/xutils.hpp"
|
||||||
|
|
||||||
#if ENABLE_I3
|
#if ENABLE_I3
|
||||||
#include "utils/i3.hpp"
|
#include "utils/i3.hpp"
|
||||||
@ -84,6 +88,8 @@ void bar::bootstrap(bool nodraw) {
|
|||||||
|
|
||||||
m_opts.strut.top = m_conf.get<int>("global/wm", "margin-top", 0);
|
m_opts.strut.top = m_conf.get<int>("global/wm", "margin-top", 0);
|
||||||
m_opts.strut.bottom = m_conf.get<int>("global/wm", "margin-bottom", 0);
|
m_opts.strut.bottom = m_conf.get<int>("global/wm", "margin-bottom", 0);
|
||||||
|
|
||||||
|
m_buttonpress.delay_ms = xutils::event_timer_ms(m_conf, xcb_button_press_event_t{});
|
||||||
}
|
}
|
||||||
|
|
||||||
m_log.trace("bar: Load color values");
|
m_log.trace("bar: Load color values");
|
||||||
@ -554,12 +560,6 @@ void bar::reconfigure_window() {
|
|||||||
xcb_icccm_set_wm_name(m_connection, m_window, XCB_ATOM_STRING, 8, m_opts.wmname.size(), m_opts.wmname.c_str());
|
xcb_icccm_set_wm_name(m_connection, m_window, XCB_ATOM_STRING, 8, m_opts.wmname.size(), m_opts.wmname.c_str());
|
||||||
xcb_icccm_set_wm_class(m_connection, m_window, 15, "polybar\0Polybar");
|
xcb_icccm_set_wm_class(m_connection, m_window, 15, "polybar\0Polybar");
|
||||||
|
|
||||||
m_log.trace("bar: Set window WM_NORMAL_HINTS");
|
|
||||||
xcb_size_hints_t hints;
|
|
||||||
xcb_icccm_size_hints_set_position(&hints, true, m_opts.pos.x, m_opts.pos.y);
|
|
||||||
xcb_icccm_size_hints_set_size(&hints, true, m_opts.size.w, m_opts.size.h);
|
|
||||||
xcb_icccm_set_wm_normal_hints(m_connection, m_window, &hints);
|
|
||||||
|
|
||||||
m_log.trace("bar: Set window _NET_WM_WINDOW_TYPE");
|
m_log.trace("bar: Set window _NET_WM_WINDOW_TYPE");
|
||||||
wm_util::set_windowtype(m_connection, m_window, {_NET_WM_WINDOW_TYPE_DOCK});
|
wm_util::set_windowtype(m_connection, m_window, {_NET_WM_WINDOW_TYPE_DOCK});
|
||||||
|
|
||||||
@ -585,6 +585,10 @@ void bar::handle(const evt::button_press& evt) {
|
|||||||
|
|
||||||
std::lock_guard<std::mutex> guard(m_mutex, std::adopt_lock);
|
std::lock_guard<std::mutex> guard(m_mutex, std::adopt_lock);
|
||||||
|
|
||||||
|
if (m_buttonpress.throttle(evt->time)) {
|
||||||
|
return m_log.trace_x("bar: Ignoring button press (throttled)...");
|
||||||
|
}
|
||||||
|
|
||||||
m_log.trace_x("bar: Received button press: %i at pos(%i, %i)", evt->detail, evt->event_x, evt->event_y);
|
m_log.trace_x("bar: Received button press: %i at pos(%i, %i)", evt->detail, evt->event_x, evt->event_y);
|
||||||
|
|
||||||
const mousebtn button{static_cast<mousebtn>(evt->detail)};
|
const mousebtn button{static_cast<mousebtn>(evt->detail)};
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include "config.hpp"
|
#include "config.hpp"
|
||||||
#include "utils/env.hpp"
|
#include "utils/env.hpp"
|
||||||
#include "utils/inotify.hpp"
|
#include "utils/inotify.hpp"
|
||||||
|
#include "x11/ewmh.hpp"
|
||||||
#include "x11/xutils.hpp"
|
#include "x11/xutils.hpp"
|
||||||
|
|
||||||
using namespace polybar;
|
using namespace polybar;
|
||||||
@ -145,6 +146,7 @@ int main(int argc, char** argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
logger.trace("Close connection to X server");
|
logger.trace("Close connection to X server");
|
||||||
|
ewmh_util::dealloc();
|
||||||
xcb_disconnect(connection);
|
xcb_disconnect(connection);
|
||||||
close(xfd);
|
close(xfd);
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include "utils/math.hpp"
|
#include "utils/math.hpp"
|
||||||
#include "x11/connection.hpp"
|
#include "x11/connection.hpp"
|
||||||
#include "x11/graphics.hpp"
|
#include "x11/graphics.hpp"
|
||||||
|
#include "x11/xutils.hpp"
|
||||||
|
|
||||||
#include "modules/meta/base.inl"
|
#include "modules/meta/base.inl"
|
||||||
#include "modules/meta/static_module.inl"
|
#include "modules/meta/static_module.inl"
|
||||||
@ -59,6 +60,9 @@ namespace modules {
|
|||||||
throw module_error("Failed to create event proxy");
|
throw module_error("Failed to create event proxy");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get the throttle time
|
||||||
|
m_randrnotify.delay_ms = xutils::event_timer_ms(m_conf, xcb_randr_notify_event_t{});
|
||||||
|
|
||||||
// Connect with the event registry and make sure we get
|
// Connect with the event registry and make sure we get
|
||||||
// notified when a RandR output property gets modified
|
// notified when a RandR output property gets modified
|
||||||
m_connection.attach_sink(this, 1);
|
m_connection.attach_sink(this, 1);
|
||||||
@ -102,16 +106,12 @@ namespace modules {
|
|||||||
return;
|
return;
|
||||||
} else if (evt->u.op.atom != m_output->backlight.atom) {
|
} else if (evt->u.op.atom != m_output->backlight.atom) {
|
||||||
return;
|
return;
|
||||||
} else if (evt->u.op.timestamp <= m_timestamp) {
|
} else if (m_randrnotify.throttle(evt->u.op.timestamp)) {
|
||||||
return;
|
return m_log.trace_x("%s: Ignoring randr notify (throttled)...", name());
|
||||||
}
|
} else {
|
||||||
|
|
||||||
// Store the timestamp with a throttle offset (ms)
|
|
||||||
m_timestamp = evt->u.op.timestamp + 50;
|
|
||||||
|
|
||||||
// Fetch the new values
|
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Query the RandR extension for the new values
|
* Query the RandR extension for the new values
|
||||||
|
@ -20,12 +20,12 @@ namespace modules {
|
|||||||
connection& conn{configure_connection().create<decltype(conn)>()};
|
connection& conn{configure_connection().create<decltype(conn)>()};
|
||||||
|
|
||||||
// Initialize ewmh atoms
|
// Initialize ewmh atoms
|
||||||
if (!ewmh_util::setup(conn, &m_ewmh)) {
|
if ((m_ewmh = ewmh_util::initialize()) == nullptr) {
|
||||||
throw module_error("Failed to initialize ewmh atoms");
|
throw module_error("Failed to initialize ewmh atoms");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the WM supports _NET_ACTIVE_WINDOW
|
// Check if the WM supports _NET_ACTIVE_WINDOW
|
||||||
if (!ewmh_util::supports(&m_ewmh, _NET_ACTIVE_WINDOW)) {
|
if (!ewmh_util::supports(m_ewmh.get(), _NET_ACTIVE_WINDOW)) {
|
||||||
throw module_error("The WM does not list _NET_ACTIVE_WINDOW as a supported hint");
|
throw module_error("The WM does not list _NET_ACTIVE_WINDOW as a supported hint");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,14 +81,14 @@ namespace modules {
|
|||||||
* Update the currently active window and query its title
|
* Update the currently active window and query its title
|
||||||
*/
|
*/
|
||||||
void xwindow_module::update() {
|
void xwindow_module::update() {
|
||||||
xcb_window_t win{ewmh_util::get_active_window(&m_ewmh)};
|
xcb_window_t win{ewmh_util::get_active_window(m_ewmh.get())};
|
||||||
string title;
|
string title;
|
||||||
|
|
||||||
if (m_active && m_active->match(win)) {
|
if (m_active && m_active->match(win)) {
|
||||||
title = m_active->title(&m_ewmh);
|
title = m_active->title(m_ewmh.get());
|
||||||
} else if (win != XCB_NONE) {
|
} else if (win != XCB_NONE) {
|
||||||
m_active = make_unique<active_window>(win);
|
m_active = make_unique<active_window>(win);
|
||||||
title = m_active->title(&m_ewmh);
|
title = m_active->title(m_ewmh.get());
|
||||||
} else {
|
} else {
|
||||||
m_active.reset();
|
m_active.reset();
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#include "errors.hpp"
|
#include "errors.hpp"
|
||||||
#include "utils/bspwm.hpp"
|
#include "utils/bspwm.hpp"
|
||||||
#include "utils/env.hpp"
|
#include "utils/env.hpp"
|
||||||
|
#include "x11/connection.hpp"
|
||||||
|
|
||||||
POLYBAR_NS
|
POLYBAR_NS
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
#include "utils/i3.hpp"
|
#include "utils/i3.hpp"
|
||||||
#include "utils/socket.hpp"
|
#include "utils/socket.hpp"
|
||||||
#include "utils/string.hpp"
|
#include "utils/string.hpp"
|
||||||
|
#include "x11/connection.hpp"
|
||||||
|
|
||||||
POLYBAR_NS
|
POLYBAR_NS
|
||||||
|
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
#include "config.hpp"
|
#include "x11/connection.hpp"
|
||||||
|
|
||||||
#include "errors.hpp"
|
#include "errors.hpp"
|
||||||
#include "utils/factory.hpp"
|
#include "utils/factory.hpp"
|
||||||
#include "x11/connection.hpp"
|
#include "utils/memory.hpp"
|
||||||
|
#include "utils/string.hpp"
|
||||||
|
#include "x11/atoms.hpp"
|
||||||
|
#include "x11/xutils.hpp"
|
||||||
|
|
||||||
POLYBAR_NS
|
POLYBAR_NS
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include "utils/string.hpp"
|
#include "utils/string.hpp"
|
||||||
#include "x11/color.hpp"
|
#include "x11/color.hpp"
|
||||||
|
#include "x11/connection.hpp"
|
||||||
#include "x11/draw.hpp"
|
#include "x11/draw.hpp"
|
||||||
|
|
||||||
POLYBAR_NS
|
POLYBAR_NS
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include "x11/connection.hpp"
|
#include "x11/connection.hpp"
|
||||||
#include "x11/fonts.hpp"
|
#include "x11/fonts.hpp"
|
||||||
#include "x11/xlib.hpp"
|
#include "x11/xlib.hpp"
|
||||||
|
#include "x11/xutils.hpp"
|
||||||
|
|
||||||
POLYBAR_NS
|
POLYBAR_NS
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#include "x11/atoms.hpp"
|
#include "x11/atoms.hpp"
|
||||||
#include "x11/connection.hpp"
|
#include "x11/connection.hpp"
|
||||||
#include "x11/graphics.hpp"
|
#include "x11/graphics.hpp"
|
||||||
|
#include "x11/xutils.hpp"
|
||||||
|
|
||||||
POLYBAR_NS
|
POLYBAR_NS
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "utils/string.hpp"
|
#include "utils/string.hpp"
|
||||||
|
#include "x11/atoms.hpp"
|
||||||
#include "x11/connection.hpp"
|
#include "x11/connection.hpp"
|
||||||
#include "x11/randr.hpp"
|
#include "x11/randr.hpp"
|
||||||
|
|
||||||
|
106
src/x11/tray.cpp
106
src/x11/tray.cpp
@ -9,15 +9,18 @@
|
|||||||
#include "utils/factory.hpp"
|
#include "utils/factory.hpp"
|
||||||
#include "utils/memory.hpp"
|
#include "utils/memory.hpp"
|
||||||
#include "utils/process.hpp"
|
#include "utils/process.hpp"
|
||||||
|
#include "x11/atoms.hpp"
|
||||||
#include "x11/color.hpp"
|
#include "x11/color.hpp"
|
||||||
#include "x11/connection.hpp"
|
#include "x11/connection.hpp"
|
||||||
#include "x11/draw.hpp"
|
#include "x11/draw.hpp"
|
||||||
|
#include "x11/ewmh.hpp"
|
||||||
#include "x11/graphics.hpp"
|
#include "x11/graphics.hpp"
|
||||||
#include "x11/tray.hpp"
|
#include "x11/tray.hpp"
|
||||||
#include "x11/window.hpp"
|
#include "x11/window.hpp"
|
||||||
#include "x11/winspec.hpp"
|
#include "x11/winspec.hpp"
|
||||||
#include "x11/wm.hpp"
|
#include "x11/wm.hpp"
|
||||||
#include "x11/xembed.hpp"
|
#include "x11/xembed.hpp"
|
||||||
|
#include "x11/xutils.hpp"
|
||||||
|
|
||||||
POLYBAR_NS
|
POLYBAR_NS
|
||||||
|
|
||||||
@ -550,12 +553,7 @@ void tray_manager::create_bg(bool realloc) { // {{{
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
uint32_t mask = 0;
|
m_connection.change_window_attributes_checked(m_tray, XCB_CW_BACK_PIXMAP, &m_pixmap);
|
||||||
uint32_t values[16];
|
|
||||||
xcb_params_cw_t params;
|
|
||||||
XCB_AUX_ADD_PARAM(&mask, ¶ms, back_pixmap, m_pixmap);
|
|
||||||
xutils::pack_values(mask, ¶ms, values);
|
|
||||||
m_connection.change_window_attributes_checked(m_tray, mask, values);
|
|
||||||
} catch (const exception& err) {
|
} catch (const exception& err) {
|
||||||
m_log.err("Failed to set tray window back pixmap (%s)", err.what());
|
m_log.err("Failed to set tray window back pixmap (%s)", err.what());
|
||||||
}
|
}
|
||||||
@ -596,23 +594,13 @@ void tray_manager::set_wmhints() { // {{{
|
|||||||
xcb_icccm_set_wm_class(m_connection, m_tray, 12, TRAY_WM_CLASS);
|
xcb_icccm_set_wm_class(m_connection, m_tray, 12, TRAY_WM_CLASS);
|
||||||
|
|
||||||
m_log.trace("tray: Set window WM_PROTOCOLS");
|
m_log.trace("tray: Set window WM_PROTOCOLS");
|
||||||
vector<xcb_atom_t> wm_flags;
|
wm_util::set_wmprotocols(m_connection, m_tray, {WM_DELETE_WINDOW, WM_TAKE_FOCUS});
|
||||||
wm_flags.emplace_back(WM_DELETE_WINDOW);
|
|
||||||
wm_flags.emplace_back(WM_TAKE_FOCUS);
|
|
||||||
wm_util::set_wmprotocols(m_connection, m_tray, wm_flags);
|
|
||||||
|
|
||||||
m_log.trace("tray: Set window _NET_WM_WINDOW_TYPE");
|
m_log.trace("tray: Set window _NET_WM_WINDOW_TYPE");
|
||||||
vector<xcb_atom_t> types;
|
wm_util::set_windowtype(m_connection, m_tray, {_NET_WM_WINDOW_TYPE_DOCK, _NET_WM_WINDOW_TYPE_NORMAL});
|
||||||
types.emplace_back(_NET_WM_WINDOW_TYPE_DOCK);
|
|
||||||
types.emplace_back(_NET_WM_WINDOW_TYPE_NORMAL);
|
|
||||||
wm_util::set_wmprotocols(m_connection, m_tray, types);
|
|
||||||
wm_util::set_windowtype(m_connection, m_tray, types);
|
|
||||||
|
|
||||||
m_log.trace("tray: Set window _NET_WM_STATE");
|
m_log.trace("tray: Set window _NET_WM_STATE");
|
||||||
vector<xcb_atom_t> states;
|
wm_util::set_wmstate(m_connection, m_tray, {_NET_WM_STATE_SKIP_TASKBAR});
|
||||||
states.emplace_back(_NET_WM_STATE_SKIP_TASKBAR);
|
|
||||||
m_connection.change_property(
|
|
||||||
XCB_PROP_MODE_REPLACE, m_tray, _NET_WM_STATE, XCB_ATOM_ATOM, 32, states.size(), states.data());
|
|
||||||
|
|
||||||
m_log.trace("tray: Set window _NET_WM_PID");
|
m_log.trace("tray: Set window _NET_WM_PID");
|
||||||
wm_util::set_wmpid(m_connection, m_tray, getpid());
|
wm_util::set_wmpid(m_connection, m_tray, getpid());
|
||||||
@ -691,7 +679,7 @@ void tray_manager::notify_clients_delayed(chrono::duration<double, std::milli> d
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_delaythread = thread([&] {
|
m_delaythread = thread([&] {
|
||||||
std::this_thread::sleep_for(delay);
|
this_thread::sleep_for(delay);
|
||||||
notify_clients();
|
notify_clients();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -702,12 +690,12 @@ void tray_manager::notify_clients_delayed(chrono::duration<double, std::milli> d
|
|||||||
* If it gets destroyed or goes away we can reactivate the tray_manager
|
* If it gets destroyed or goes away we can reactivate the tray_manager
|
||||||
*/
|
*/
|
||||||
void tray_manager::track_selection_owner(xcb_window_t owner) { // {{{
|
void tray_manager::track_selection_owner(xcb_window_t owner) { // {{{
|
||||||
if (!owner) {
|
if (owner) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
m_log.trace("tray: Listen for events on the new selection window");
|
m_log.trace("tray: Listen for events on the new selection window");
|
||||||
const uint32_t value_list[1]{XCB_EVENT_MASK_STRUCTURE_NOTIFY};
|
const uint32_t mask{XCB_CW_EVENT_MASK};
|
||||||
m_connection.change_window_attributes(owner, XCB_CW_EVENT_MASK, value_list);
|
const uint32_t values[]{XCB_EVENT_MASK_STRUCTURE_NOTIFY};
|
||||||
|
m_connection.change_window_attributes(owner, mask, values);
|
||||||
|
}
|
||||||
} // }}}
|
} // }}}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -740,13 +728,11 @@ void tray_manager::process_docking_request(xcb_window_t win) { // {{{
|
|||||||
try {
|
try {
|
||||||
m_log.trace("tray: Update client window");
|
m_log.trace("tray: Update client window");
|
||||||
{
|
{
|
||||||
uint32_t mask = 0;
|
// clang-format off
|
||||||
uint32_t values[16];
|
const uint32_t mask{XCB_CW_BACK_PIXMAP | XCB_CW_EVENT_MASK};
|
||||||
xcb_params_cw_t params;
|
const uint32_t values[]{XCB_BACK_PIXMAP_PARENT_RELATIVE, XCB_EVENT_MASK_PROPERTY_CHANGE | XCB_EVENT_MASK_STRUCTURE_NOTIFY};
|
||||||
XCB_AUX_ADD_PARAM(&mask, ¶ms, event_mask, XCB_EVENT_MASK_PROPERTY_CHANGE | XCB_EVENT_MASK_STRUCTURE_NOTIFY);
|
|
||||||
XCB_AUX_ADD_PARAM(&mask, ¶ms, back_pixmap, XCB_BACK_PIXMAP_PARENT_RELATIVE);
|
|
||||||
xutils::pack_values(mask, ¶ms, values);
|
|
||||||
m_connection.change_window_attributes_checked(client->window(), mask, values);
|
m_connection.change_window_attributes_checked(client->window(), mask, values);
|
||||||
|
// clang-format on
|
||||||
}
|
}
|
||||||
|
|
||||||
m_log.trace("tray: Configure client size");
|
m_log.trace("tray: Configure client size");
|
||||||
@ -802,11 +788,13 @@ void tray_manager::bar_visibility_change(bool state) { // {{{
|
|||||||
*/
|
*/
|
||||||
int16_t tray_manager::calculate_x(uint16_t width) const { // {{{
|
int16_t tray_manager::calculate_x(uint16_t width) const { // {{{
|
||||||
auto x = m_opts.orig_x;
|
auto x = m_opts.orig_x;
|
||||||
|
|
||||||
if (m_opts.align == alignment::RIGHT) {
|
if (m_opts.align == alignment::RIGHT) {
|
||||||
x -= ((m_opts.width + m_opts.spacing) * m_clients.size() + m_opts.spacing);
|
x -= ((m_opts.width + m_opts.spacing) * m_clients.size() + m_opts.spacing);
|
||||||
} else if (m_opts.align == alignment::CENTER) {
|
} else if (m_opts.align == alignment::CENTER) {
|
||||||
x -= (width / 2) - (m_opts.width / 2);
|
x -= (width / 2) - (m_opts.width / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
return x;
|
return x;
|
||||||
} // }}}
|
} // }}}
|
||||||
|
|
||||||
@ -924,34 +912,21 @@ void tray_manager::handle(const evt::client_message& evt) { // {{{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (evt->type == _NET_SYSTEM_TRAY_OPCODE && evt->format == 32) {
|
if (evt->type == WM_PROTOCOLS && evt->data.data32[0] == WM_DELETE_WINDOW) {
|
||||||
m_log.trace("tray: Received client_message");
|
|
||||||
|
|
||||||
switch (evt->data.data32[1]) {
|
|
||||||
case SYSTEM_TRAY_REQUEST_DOCK:
|
|
||||||
try {
|
|
||||||
process_docking_request(evt->data.data32[2]);
|
|
||||||
} catch (const exception& err) {
|
|
||||||
auto id = m_connection.id(evt->data.data32[2]);
|
|
||||||
m_log.err("Error while processing docking request for %s (%s)", id, err.what());
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
|
|
||||||
case SYSTEM_TRAY_BEGIN_MESSAGE:
|
|
||||||
// process_messages(...);
|
|
||||||
return;
|
|
||||||
|
|
||||||
case SYSTEM_TRAY_CANCEL_MESSAGE:
|
|
||||||
// process_messages(...);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
} else if (evt->type == WM_PROTOCOLS && evt->data.data32[0] == WM_DELETE_WINDOW) {
|
|
||||||
if (evt->window == m_tray) {
|
if (evt->window == m_tray) {
|
||||||
m_log.warn("Received WM_DELETE");
|
m_log.warn("Received WM_DELETE");
|
||||||
m_tray = 0;
|
m_tray = 0;
|
||||||
deactivate();
|
deactivate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (evt->type == _NET_SYSTEM_TRAY_OPCODE && evt->format == 32) {
|
||||||
|
m_log.trace("tray: Received client_message");
|
||||||
|
|
||||||
|
if (SYSTEM_TRAY_REQUEST_DOCK == evt->data.data32[1]) {
|
||||||
|
process_docking_request(evt->data.data32[2]);
|
||||||
|
}
|
||||||
|
}
|
||||||
} // }}}
|
} // }}}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -967,6 +942,7 @@ void tray_manager::handle(const evt::configure_request& evt) { // {{{
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto client = find_client(evt->window);
|
auto client = find_client(evt->window);
|
||||||
|
|
||||||
if (!client) {
|
if (!client) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -989,6 +965,7 @@ void tray_manager::handle(const evt::resize_request& evt) { // {{{
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto client = find_client(evt->window);
|
auto client = find_client(evt->window);
|
||||||
|
|
||||||
if (!client) {
|
if (!client) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1041,8 +1018,9 @@ void tray_manager::handle(const evt::property_notify& evt) { // {{{
|
|||||||
} else if (evt->atom == ESETROOT_PMAP_ID) {
|
} else if (evt->atom == ESETROOT_PMAP_ID) {
|
||||||
reconfigure_bg(true);
|
reconfigure_bg(true);
|
||||||
refresh_window();
|
refresh_window();
|
||||||
} else if (evt->atom != _XEMBED_INFO) {
|
} else if (evt->atom == _XEMBED_INFO) {
|
||||||
auto client = find_client(evt->window);
|
auto client = find_client(evt->window);
|
||||||
|
|
||||||
if (!client) {
|
if (!client) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1075,6 +1053,7 @@ void tray_manager::handle(const evt::reparent_notify& evt) { // {{{
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto client = find_client(evt->window);
|
auto client = find_client(evt->window);
|
||||||
|
|
||||||
if (client && evt->parent != m_tray) {
|
if (client && evt->parent != m_tray) {
|
||||||
m_log.trace("tray: Received reparent_notify for client, remove...");
|
m_log.trace("tray: Received reparent_notify for client, remove...");
|
||||||
remove_client(client);
|
remove_client(client);
|
||||||
@ -1093,6 +1072,7 @@ void tray_manager::handle(const evt::destroy_notify& evt) { // {{{
|
|||||||
// activate();
|
// activate();
|
||||||
} else if (m_activated) {
|
} else if (m_activated) {
|
||||||
auto client = find_client(evt->window);
|
auto client = find_client(evt->window);
|
||||||
|
|
||||||
if (client) {
|
if (client) {
|
||||||
m_log.trace("tray: Received destroy_notify for client, remove...");
|
m_log.trace("tray: Received destroy_notify for client, remove...");
|
||||||
remove_client(client);
|
remove_client(client);
|
||||||
@ -1108,15 +1088,15 @@ void tray_manager::handle(const evt::map_notify& evt) { // {{{
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (evt->window == m_tray && !m_mapped) {
|
if (evt->window == m_tray) {
|
||||||
if (m_mapped) {
|
if (!m_mapped) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
m_log.trace("tray: Received map_notify");
|
m_log.trace("tray: Received map_notify");
|
||||||
m_log.trace("tray: Update container mapped flag");
|
m_log.trace("tray: Update container mapped flag");
|
||||||
m_mapped = true;
|
m_mapped = true;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
auto client = find_client(evt->window);
|
auto client = find_client(evt->window);
|
||||||
|
|
||||||
if (client) {
|
if (client) {
|
||||||
m_log.trace("tray: Received map_notify");
|
m_log.trace("tray: Received map_notify");
|
||||||
m_log.trace("tray: Set client mapped");
|
m_log.trace("tray: Set client mapped");
|
||||||
@ -1139,17 +1119,19 @@ void tray_manager::handle(const evt::unmap_notify& evt) { // {{{
|
|||||||
|
|
||||||
if (evt->window == m_tray) {
|
if (evt->window == m_tray) {
|
||||||
m_log.trace("tray: Received unmap_notify");
|
m_log.trace("tray: Received unmap_notify");
|
||||||
if (!m_mapped) {
|
|
||||||
return;
|
if (m_mapped) {
|
||||||
}
|
|
||||||
m_log.trace("tray: Update container mapped flag");
|
m_log.trace("tray: Update container mapped flag");
|
||||||
m_mapped = false;
|
m_mapped = false;
|
||||||
if (!m_hidden) {
|
}
|
||||||
|
|
||||||
|
if (m_mapped && !m_hidden) {
|
||||||
m_opts.configured_w = 0;
|
m_opts.configured_w = 0;
|
||||||
m_opts.configured_x = 0;
|
m_opts.configured_x = 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
auto client = find_client(evt->window);
|
auto client = find_client(evt->window);
|
||||||
|
|
||||||
if (client) {
|
if (client) {
|
||||||
m_log.trace("tray: Received unmap_notify");
|
m_log.trace("tray: Received unmap_notify");
|
||||||
m_log.trace("tray: Set client unmapped");
|
m_log.trace("tray: Set client unmapped");
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
|
#include <xcb/xcb.h>
|
||||||
|
|
||||||
|
#include "x11/connection.hpp"
|
||||||
#include "x11/winspec.hpp"
|
#include "x11/winspec.hpp"
|
||||||
|
#include "x11/xutils.hpp"
|
||||||
|
|
||||||
POLYBAR_NS
|
POLYBAR_NS
|
||||||
|
|
||||||
|
@ -1,47 +1,48 @@
|
|||||||
|
#include <unistd.h>
|
||||||
#include <xcb/xcb_icccm.h>
|
#include <xcb/xcb_icccm.h>
|
||||||
|
|
||||||
#include "x11/atoms.hpp"
|
#include "x11/atoms.hpp"
|
||||||
#include "x11/connection.hpp"
|
|
||||||
#include "x11/wm.hpp"
|
#include "x11/wm.hpp"
|
||||||
|
|
||||||
POLYBAR_NS
|
POLYBAR_NS
|
||||||
|
|
||||||
namespace wm_util {
|
namespace wm_util {
|
||||||
void set_wmname(connection& conn, xcb_window_t win, const string& wm_name, const string& wm_class) {
|
void set_wmname(xcb_connection_t* conn, xcb_window_t win, const string& wm_name, const string& wm_class) {
|
||||||
xcb_icccm_set_wm_name(conn, win, XCB_ATOM_STRING, 8, wm_name.length(), wm_name.c_str());
|
xcb_icccm_set_wm_name(conn, win, XCB_ATOM_STRING, 8, wm_name.length(), wm_name.c_str());
|
||||||
xcb_icccm_set_wm_class(conn, win, wm_class.length(), wm_class.c_str());
|
xcb_icccm_set_wm_class(conn, win, wm_class.length(), wm_class.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_wmprotocols(connection& conn, xcb_window_t win, vector<xcb_atom_t> flags) {
|
void set_wmprotocols(xcb_connection_t* conn, xcb_window_t win, vector<xcb_atom_t> flags) {
|
||||||
xcb_icccm_set_wm_protocols(conn, win, WM_PROTOCOLS, flags.size(), flags.data());
|
xcb_icccm_set_wm_protocols(conn, win, WM_PROTOCOLS, flags.size(), flags.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_windowtype(connection& conn, xcb_window_t win, vector<xcb_atom_t> types) {
|
void set_windowtype(xcb_connection_t* conn, xcb_window_t win, vector<xcb_atom_t> types) {
|
||||||
conn.change_property(
|
xcb_change_property(
|
||||||
XCB_PROP_MODE_REPLACE, win, _NET_WM_WINDOW_TYPE, XCB_ATOM_ATOM, 32, types.size(), types.data());
|
conn, XCB_PROP_MODE_REPLACE, win, _NET_WM_WINDOW_TYPE, XCB_ATOM_ATOM, 32, types.size(), types.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_wmstate(connection& conn, xcb_window_t win, vector<xcb_atom_t> states) {
|
void set_wmstate(xcb_connection_t* conn, xcb_window_t win, vector<xcb_atom_t> states) {
|
||||||
conn.change_property(XCB_PROP_MODE_REPLACE, win, _NET_WM_STATE, XCB_ATOM_ATOM, 32, states.size(), states.data());
|
xcb_change_property(
|
||||||
|
conn, XCB_PROP_MODE_REPLACE, win, _NET_WM_STATE, XCB_ATOM_ATOM, 32, states.size(), states.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_wmpid(connection& conn, xcb_window_t win, pid_t pid) {
|
void set_wmpid(xcb_connection_t* conn, xcb_window_t win, pid_t pid) {
|
||||||
pid = getpid();
|
pid = getpid();
|
||||||
conn.change_property(XCB_PROP_MODE_REPLACE, win, _NET_WM_PID, XCB_ATOM_CARDINAL, 32, 1, &pid);
|
xcb_change_property(conn, XCB_PROP_MODE_REPLACE, win, _NET_WM_PID, XCB_ATOM_CARDINAL, 32, 1, &pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_wmdesktop(connection& conn, xcb_window_t win, uint32_t desktop) {
|
void set_wmdesktop(xcb_connection_t* conn, xcb_window_t win, uint32_t desktop) {
|
||||||
const uint32_t value_list[1]{desktop};
|
const uint32_t value_list[1]{desktop};
|
||||||
conn.change_property(XCB_PROP_MODE_REPLACE, win, _NET_WM_DESKTOP, XCB_ATOM_CARDINAL, 32, 1, value_list);
|
xcb_change_property(conn, XCB_PROP_MODE_REPLACE, win, _NET_WM_DESKTOP, XCB_ATOM_CARDINAL, 32, 1, value_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_trayorientation(connection& conn, xcb_window_t win, uint32_t orientation) {
|
void set_trayorientation(xcb_connection_t* conn, xcb_window_t win, uint32_t orientation) {
|
||||||
conn.change_property(
|
xcb_change_property(conn, XCB_PROP_MODE_REPLACE, win, _NET_SYSTEM_TRAY_ORIENTATION, _NET_SYSTEM_TRAY_ORIENTATION,
|
||||||
XCB_PROP_MODE_REPLACE, win, _NET_SYSTEM_TRAY_ORIENTATION, _NET_SYSTEM_TRAY_ORIENTATION, 32, 1, &orientation);
|
32, 1, &orientation);
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_trayvisual(connection& conn, xcb_window_t win, xcb_visualid_t visual) {
|
void set_trayvisual(xcb_connection_t* conn, xcb_window_t win, xcb_visualid_t visual) {
|
||||||
conn.change_property(XCB_PROP_MODE_REPLACE, win, _NET_SYSTEM_TRAY_VISUAL, XCB_ATOM_VISUALID, 32, 1, &visual);
|
xcb_change_property(conn, XCB_PROP_MODE_REPLACE, win, _NET_SYSTEM_TRAY_VISUAL, XCB_ATOM_VISUALID, 32, 1, &visual);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
#include "x11/xembed.hpp"
|
#include "x11/xembed.hpp"
|
||||||
#include "errors.hpp"
|
#include "errors.hpp"
|
||||||
|
#include "x11/atoms.hpp"
|
||||||
|
|
||||||
POLYBAR_NS
|
POLYBAR_NS
|
||||||
|
|
||||||
|
@ -1,24 +1,35 @@
|
|||||||
#include "x11/xutils.hpp"
|
#include <xcb/xcb.h>
|
||||||
|
|
||||||
|
#include "components/config.hpp"
|
||||||
|
#include "utils/memory.hpp"
|
||||||
#include "x11/atoms.hpp"
|
#include "x11/atoms.hpp"
|
||||||
#include "x11/connection.hpp"
|
#include "x11/connection.hpp"
|
||||||
#include "x11/xlib.hpp"
|
#include "x11/xlib.hpp"
|
||||||
|
#include "x11/xutils.hpp"
|
||||||
|
|
||||||
POLYBAR_NS
|
POLYBAR_NS
|
||||||
|
|
||||||
namespace xutils {
|
namespace xutils {
|
||||||
xcb_connection_t* g_connection_ptr = nullptr;
|
xcb_connection_t* g_connection_ptr{nullptr};
|
||||||
xcb_connection_t* get_connection() {
|
xcb_connection_t* get_connection() {
|
||||||
if (g_connection_ptr == nullptr) {
|
if (g_connection_ptr == nullptr) {
|
||||||
Display* dsp;
|
Display* dsp{xlib::get_display()};
|
||||||
if ((dsp = xlib::get_display()) == nullptr) {
|
if (dsp != nullptr) {
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
XSetEventQueueOwner(dsp, XCBOwnsEventQueue);
|
XSetEventQueueOwner(dsp, XCBOwnsEventQueue);
|
||||||
g_connection_ptr = XGetXCBConnection(dsp);
|
g_connection_ptr = XGetXCBConnection(dsp);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return g_connection_ptr;
|
return g_connection_ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t event_timer_ms(const config& conf, const xcb_button_press_event_t&) {
|
||||||
|
return conf.get<uint32_t>("settings", "x-delay-buttonpress", 25);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t event_timer_ms(const config& conf, const xcb_randr_notify_event_t&) {
|
||||||
|
return conf.get<uint32_t>("settings", "x-delay-randrnotify", 50);
|
||||||
|
}
|
||||||
|
|
||||||
void pack_values(uint32_t mask, const uint32_t* src, uint32_t* dest) {
|
void pack_values(uint32_t mask, const uint32_t* src, uint32_t* dest) {
|
||||||
for (; mask; mask >>= 1, src++) {
|
for (; mask; mask >>= 1, src++) {
|
||||||
if (mask & 1) {
|
if (mask & 1) {
|
||||||
@ -49,7 +60,7 @@ namespace xutils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void compton_shadow_exclude(connection& conn, const xcb_window_t& win) {
|
void compton_shadow_exclude(connection& conn, const xcb_window_t& win) {
|
||||||
const uint32_t shadow = 0;
|
const uint32_t shadow{0};
|
||||||
conn.change_property(XCB_PROP_MODE_REPLACE, win, _COMPTON_SHADOW, XCB_ATOM_CARDINAL, 32, 1, &shadow);
|
conn.change_property(XCB_PROP_MODE_REPLACE, win, _COMPTON_SHADOW, XCB_ATOM_CARDINAL, 32, 1, &shadow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user