Use connection.root() to get root window
This commit is contained in:
parent
6043f856b6
commit
b5c742a63e
@ -24,14 +24,6 @@ class screen : public xpp::event::sink<evt::randr_screen_change_notify> {
|
||||
explicit screen(connection& conn, signal_emitter& emitter, const logger& logger, const config& conf);
|
||||
~screen();
|
||||
|
||||
struct size size() const {
|
||||
return m_size;
|
||||
}
|
||||
|
||||
xcb_window_t root() const {
|
||||
return m_root;
|
||||
}
|
||||
|
||||
protected:
|
||||
void handle(const evt::randr_screen_change_notify& evt) override;
|
||||
|
||||
|
@ -40,7 +40,7 @@ namespace detail {
|
||||
, Extensions(m_c.get())...
|
||||
, Extensions::error_dispatcher(static_cast<Extensions&>(*this).get())... {
|
||||
core::m_screen = s;
|
||||
m_root_window = screen_of_display(default_screen())->root;
|
||||
m_root_window = screen_of_display(s)->root;
|
||||
}
|
||||
|
||||
virtual ~connection_base() {}
|
||||
@ -54,10 +54,8 @@ namespace detail {
|
||||
return static_cast<const Extension&>(*this);
|
||||
}
|
||||
|
||||
template <typename WindowType = xcb_window_t>
|
||||
WindowType root() const {
|
||||
using make = xpp::generic::factory::make<connection_base, xcb_window_t, WindowType>;
|
||||
return make()(*this, m_root_window);
|
||||
xcb_window_t root() const {
|
||||
return m_root_window;
|
||||
}
|
||||
|
||||
shared_ptr<xcb_generic_event_t> wait_for_event() const override {
|
||||
|
@ -57,8 +57,7 @@ namespace randr_util {
|
||||
|
||||
monitor_t make_monitor(xcb_randr_output_t randr, string name, unsigned short int w, unsigned short int h, short int x,
|
||||
short int y, bool primary);
|
||||
vector<monitor_t> get_monitors(
|
||||
connection& conn, xcb_window_t root, bool connected_only = false, bool purge_clones = true);
|
||||
vector<monitor_t> get_monitors(connection& conn, bool connected_only = false, bool purge_clones = true);
|
||||
monitor_t match_monitor(vector<monitor_t> monitors, const string& name, bool exact_match);
|
||||
|
||||
void get_backlight_range(connection& conn, const monitor_t& mon, backlight_values& dst);
|
||||
|
@ -80,7 +80,7 @@ bar::bar(connection& conn, signal_emitter& emitter, const config& config, const
|
||||
auto monitor_name_fallback = m_conf.get(bs, "monitor-fallback", ""s);
|
||||
m_opts.monitor_strict = m_conf.get(bs, "monitor-strict", m_opts.monitor_strict);
|
||||
m_opts.monitor_exact = m_conf.get(bs, "monitor-exact", m_opts.monitor_exact);
|
||||
auto monitors = randr_util::get_monitors(m_connection, m_connection.screen()->root, m_opts.monitor_strict, false);
|
||||
auto monitors = randr_util::get_monitors(m_connection, m_opts.monitor_strict, false);
|
||||
|
||||
if (monitors.empty()) {
|
||||
throw application_error("No monitors found");
|
||||
@ -98,7 +98,7 @@ bar::bar(connection& conn, signal_emitter& emitter, const config& config, const
|
||||
|
||||
// if still not found (and not strict matching), get first connected monitor
|
||||
if (monitor_name.empty() && !m_opts.monitor_strict) {
|
||||
auto connected_monitors = randr_util::get_monitors(m_connection, m_connection.screen()->root, true, false);
|
||||
auto connected_monitors = randr_util::get_monitors(m_connection, true, false);
|
||||
if (!connected_monitors.empty()) {
|
||||
monitor_name = connected_monitors[0]->name;
|
||||
m_log.warn("No monitor specified, using \"%s\"", monitor_name);
|
||||
@ -497,7 +497,7 @@ void bar::restack_window() {
|
||||
|
||||
if (wm_restack == "generic") {
|
||||
try {
|
||||
auto children = m_connection.query_tree(m_connection.screen()->root).children();
|
||||
auto children = m_connection.query_tree(m_connection.root()).children();
|
||||
if (children.begin() != children.end() && *children.begin() != m_opts.window) {
|
||||
const unsigned int value_mask = XCB_CONFIG_WINDOW_SIBLING | XCB_CONFIG_WINDOW_STACK_MODE;
|
||||
const unsigned int value_list[2]{*children.begin(), XCB_STACK_MODE_BELOW};
|
||||
@ -556,7 +556,7 @@ void bar::reconfigure_pos() {
|
||||
* Reconfigure window strut values
|
||||
*/
|
||||
void bar::reconfigure_struts() {
|
||||
auto geom = m_connection.get_geometry(m_screen->root());
|
||||
auto geom = m_connection.get_geometry(m_connection.root());
|
||||
int h = m_opts.size.h + m_opts.offset.y;
|
||||
|
||||
// Apply user-defined margins
|
||||
|
@ -61,7 +61,7 @@ renderer::renderer(connection& conn, signal_emitter& sig, const config& conf, co
|
||||
|
||||
m_log.trace("renderer: Allocate colormap");
|
||||
m_colormap = m_connection.generate_id();
|
||||
m_connection.create_colormap(XCB_COLORMAP_ALLOC_NONE, m_colormap, m_connection.screen()->root, m_visual->visual_id);
|
||||
m_connection.create_colormap(XCB_COLORMAP_ALLOC_NONE, m_colormap, m_connection.root(), m_visual->visual_id);
|
||||
|
||||
m_log.trace("renderer: Allocate output window");
|
||||
// clang-format off
|
||||
|
@ -35,7 +35,7 @@ screen::screen(connection& conn, signal_emitter& emitter, const logger& logger,
|
||||
, m_log(logger)
|
||||
, m_conf(conf)
|
||||
, m_root(conn.root())
|
||||
, m_monitors(randr_util::get_monitors(m_connection, m_root, true, false))
|
||||
, m_monitors(randr_util::get_monitors(m_connection, true, false))
|
||||
, m_size({conn.screen()->width_in_pixels, conn.screen()->height_in_pixels}) {
|
||||
// Check if the reloading has been disabled by the user
|
||||
if (!m_conf.get("settings", "screenchange-reload", false)) {
|
||||
@ -120,7 +120,7 @@ void screen::handle(const evt::randr_screen_change_notify& evt) {
|
||||
* Fetches the monitor list and compares it with the one stored
|
||||
*/
|
||||
bool screen::have_monitors_changed() const {
|
||||
auto monitors = randr_util::get_monitors(m_connection, m_root, true, false);
|
||||
auto monitors = randr_util::get_monitors(m_connection, true, false);
|
||||
|
||||
if (monitors.size() != m_monitors.size()) {
|
||||
return true;
|
||||
|
@ -82,7 +82,7 @@ int main(int argc, char** argv) {
|
||||
//==================================================
|
||||
if (cli->has("list-monitors") || cli->has("list-all-monitors")) {
|
||||
bool purge_clones = !cli->has("list-all-monitors");
|
||||
auto monitors = randr_util::get_monitors(conn, conn.root(), true, purge_clones);
|
||||
auto monitors = randr_util::get_monitors(conn, true, purge_clones);
|
||||
for (auto&& mon : monitors) {
|
||||
if (mon->output == XCB_NONE) {
|
||||
printf("%s: %ix%i+%i+%i (no output%s)\n", mon->name.c_str(), mon->w, mon->h, mon->x, mon->y,
|
||||
|
@ -23,7 +23,7 @@ namespace modules {
|
||||
|
||||
auto output = m_conf.get(name(), "output", m_bar.monitor->name);
|
||||
|
||||
auto monitors = randr_util::get_monitors(m_connection, m_connection.root(), bar.monitor_strict, false);
|
||||
auto monitors = randr_util::get_monitors(m_connection, bar.monitor_strict, false);
|
||||
|
||||
m_output = randr_util::match_monitor(monitors, output, bar.monitor_exact);
|
||||
|
||||
|
@ -84,7 +84,7 @@ namespace modules {
|
||||
}
|
||||
|
||||
// Get list of monitors
|
||||
m_monitors = randr_util::get_monitors(m_connection, m_connection.root(), false);
|
||||
m_monitors = randr_util::get_monitors(m_connection, false);
|
||||
|
||||
// Get desktop details
|
||||
m_desktop_names = get_desktop_names();
|
||||
|
@ -1,7 +1,8 @@
|
||||
#include "utils/bspwm.hpp"
|
||||
|
||||
#include <sys/un.h>
|
||||
|
||||
#include "errors.hpp"
|
||||
#include "utils/bspwm.hpp"
|
||||
#include "utils/env.hpp"
|
||||
#include "x11/connection.hpp"
|
||||
|
||||
@ -13,7 +14,7 @@ namespace bspwm_util {
|
||||
*/
|
||||
vector<xcb_window_t> root_windows(connection& conn) {
|
||||
vector<xcb_window_t> roots;
|
||||
auto children = conn.query_tree(conn.screen()->root).children();
|
||||
auto children = conn.query_tree(conn.root()).children();
|
||||
|
||||
for (auto it = children.begin(); it != children.end(); it++) {
|
||||
xcb_icccm_get_wm_class_reply_t reply{};
|
||||
@ -146,6 +147,6 @@ namespace bspwm_util {
|
||||
}
|
||||
return conn;
|
||||
}
|
||||
}
|
||||
} // namespace bspwm_util
|
||||
|
||||
POLYBAR_NS_END
|
||||
|
@ -1,9 +1,11 @@
|
||||
#include "utils/i3.hpp"
|
||||
|
||||
#include <xcb/xcb.h>
|
||||
|
||||
#include <i3ipc++/ipc.hpp>
|
||||
|
||||
#include "common.hpp"
|
||||
#include "settings.hpp"
|
||||
#include "utils/i3.hpp"
|
||||
#include "utils/socket.hpp"
|
||||
#include "utils/string.hpp"
|
||||
#include "x11/connection.hpp"
|
||||
@ -42,7 +44,7 @@ namespace i3_util {
|
||||
* Get main root window
|
||||
*/
|
||||
xcb_window_t root_window(connection& conn) {
|
||||
auto children = conn.query_tree(conn.screen()->root).children();
|
||||
auto children = conn.query_tree(conn.root()).children();
|
||||
const auto wm_name = [&](xcb_connection_t* conn, xcb_window_t win) -> string {
|
||||
string title;
|
||||
if (!(title = ewmh_util::get_wm_name(win)).empty()) {
|
||||
@ -78,6 +80,6 @@ namespace i3_util {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} // namespace i3_util
|
||||
|
||||
POLYBAR_NS_END
|
||||
|
@ -96,8 +96,8 @@ void background_manager::fetch_root_pixmap() {
|
||||
}
|
||||
|
||||
// fill the slice
|
||||
auto translated = m_connection.translate_coordinates(
|
||||
slice->m_window, m_connection.screen()->root, slice->m_rect.x, slice->m_rect.y);
|
||||
auto translated =
|
||||
m_connection.translate_coordinates(slice->m_window, m_connection.root(), slice->m_rect.x, slice->m_rect.y);
|
||||
auto src_x = math_util::cap(translated->dst_x, pixmap_geom.x, int16_t(pixmap_geom.x + pixmap_geom.width));
|
||||
auto src_y = math_util::cap(translated->dst_y, pixmap_geom.y, int16_t(pixmap_geom.y + pixmap_geom.height));
|
||||
auto w = math_util::cap(slice->m_rect.width, uint16_t(0), uint16_t(pixmap_geom.width - (src_x - pixmap_geom.x)));
|
||||
|
@ -169,7 +169,7 @@ bool connection::root_pixmap(xcb_pixmap_t* pixmap, int* depth, xcb_rectangle_t*
|
||||
const xcb_atom_t pixmap_properties[3]{_XROOTPMAP_ID, ESETROOT_PMAP_ID, _XSETROOT_ID};
|
||||
for (auto&& property : pixmap_properties) {
|
||||
try {
|
||||
auto prop = get_property(false, screen()->root, property, XCB_ATOM_PIXMAP, 0L, 1L);
|
||||
auto prop = get_property(false, root(), property, XCB_ATOM_PIXMAP, 0L, 1L);
|
||||
if (prop->format == 32 && prop->value_len == 1) {
|
||||
*pixmap = *prop.value<xcb_pixmap_t>().begin();
|
||||
}
|
||||
|
@ -105,7 +105,8 @@ namespace randr_util {
|
||||
/**
|
||||
* Create a list of all available randr outputs
|
||||
*/
|
||||
vector<monitor_t> get_monitors(connection& conn, xcb_window_t root, bool connected_only, bool purge_clones) {
|
||||
vector<monitor_t> get_monitors(connection& conn, bool connected_only, bool purge_clones) {
|
||||
xcb_window_t root = conn.root();
|
||||
vector<monitor_t> monitors;
|
||||
bool found = false;
|
||||
|
||||
@ -113,14 +114,11 @@ namespace randr_util {
|
||||
#if WITH_XRANDR_MONITORS
|
||||
/* Use C, because XPP does not provide access to output info from monitors. */
|
||||
xcb_generic_error_t* err;
|
||||
auto rrmonitors =
|
||||
xcb_randr_get_monitors_reply(
|
||||
conn, xcb_randr_get_monitors(conn, root, true), &err);
|
||||
auto rrmonitors = xcb_randr_get_monitors_reply(conn, xcb_randr_get_monitors(conn, root, true), &err);
|
||||
if (err != NULL) {
|
||||
free(err);
|
||||
} else {
|
||||
for (auto iter = xcb_randr_get_monitors_monitors_iterator(rrmonitors);
|
||||
iter.rem;
|
||||
for (auto iter = xcb_randr_get_monitors_monitors_iterator(rrmonitors); iter.rem;
|
||||
xcb_randr_monitor_info_next(&iter)) {
|
||||
auto mon = iter.data;
|
||||
auto name = conn.get_atom_name(mon->name).name();
|
||||
@ -129,7 +127,8 @@ namespace randr_util {
|
||||
int randr_output_len = xcb_randr_monitor_info_outputs_length(mon);
|
||||
auto randr_outputs = xcb_randr_monitor_info_outputs(mon);
|
||||
auto output = (randr_output_len >= 1) ? randr_outputs[0] : XCB_NONE;
|
||||
monitors.emplace_back(make_monitor(output, move(name), mon->width, mon->height, mon->x, mon->y, mon->primary));
|
||||
monitors.emplace_back(
|
||||
make_monitor(output, move(name), mon->width, mon->height, mon->x, mon->y, mon->primary));
|
||||
found = true;
|
||||
}
|
||||
free(rrmonitors);
|
||||
@ -160,8 +159,10 @@ namespace randr_util {
|
||||
|
||||
auto crtc = conn.get_crtc_info(info->crtc);
|
||||
auto primary = (primary_name == name);
|
||||
if (!std::any_of(monitors.begin(), monitors.end(), [name](const auto &monitor) { return monitor->name == name; })) {
|
||||
monitors.emplace_back(make_monitor(output, move(name), crtc->width, crtc->height, crtc->x, crtc->y, primary));
|
||||
if (!std::any_of(
|
||||
monitors.begin(), monitors.end(), [name](const auto& monitor) { return monitor->name == name; })) {
|
||||
monitors.emplace_back(
|
||||
make_monitor(output, move(name), crtc->width, crtc->height, crtc->x, crtc->y, primary));
|
||||
}
|
||||
} catch (const exception&) {
|
||||
// silently ignore output
|
||||
|
@ -573,8 +573,9 @@ void tray_manager::create_bg() {
|
||||
* Set window WM hints
|
||||
*/
|
||||
void tray_manager::set_wm_hints() {
|
||||
const unsigned int visual{m_connection.screen()->root_visual};
|
||||
const unsigned int orientation{_NET_SYSTEM_TRAY_ORIENTATION_HORZ};
|
||||
// TODO use same visual as bar/tray window
|
||||
const xcb_visualid_t visual{m_connection.screen()->root_visual};
|
||||
const uint32_t orientation{_NET_SYSTEM_TRAY_ORIENTATION_HORZ};
|
||||
|
||||
m_log.trace("bar: Set window WM_NAME / WM_CLASS");
|
||||
icccm_util::set_wm_name(m_connection, m_tray, TRAY_WM_NAME, 19_z, TRAY_WM_CLASS, 12_z);
|
||||
|
@ -21,7 +21,7 @@ xcb_window_t winspec::operator<<(const cw_flush& f) {
|
||||
m_window = m_connection.generate_id();
|
||||
}
|
||||
if (m_parent == XCB_NONE) {
|
||||
m_parent = m_connection.screen()->root;
|
||||
m_parent = m_connection.root();
|
||||
}
|
||||
|
||||
if (m_width <= 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user