From 36ab6defac59d289a513e74c28e21f437adead98 Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Wed, 27 Sep 2017 19:38:44 +0200 Subject: Add some rather quirky X fixes So, from the xserver code, if you don't specify a border pixel you must match the parent window depth. Also, if you don't specify a colormap you need to match the parent visual --- src/main.cc | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'src/main.cc') diff --git a/src/main.cc b/src/main.cc index 50fe463..a00d4c7 100644 --- a/src/main.cc +++ b/src/main.cc @@ -104,18 +104,32 @@ public: wnd_.reset(conn); pixmap_.reset(conn); gcontext_.reset(conn); - - uint32_t values[2]; - values[0] = screen->black_pixel; - values[1] = XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_EXPOSURE + cmap_.reset(); + + uint32_t values[4]; + size_t i = 0; + uint32_t mask = XCB_CW_BACK_PIXEL; + values[i++] = screen->black_pixel; + if (format.need_border()) { + mask |= XCB_CW_BORDER_PIXEL; + values[i++] = screen->black_pixel; + } + mask |= XCB_CW_EVENT_MASK; + values[i++] = XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_STRUCTURE_NOTIFY; + if (format.need_colormap()) { + mask |= XCB_CW_COLORMAP; + cmap_.reset(conn); + xcb_create_colormap(cmap_.conn(), XCB_COLORMAP_ALLOC_NONE, cmap_.get(), + screen->root, format.visual->visual_id); + values[i++] = cmap_.get(); + } xcb_create_window(wnd_.conn(), format.depth, wnd_.get(), screen->root, 0, 0, width, height, 0, XCB_WINDOW_CLASS_INPUT_OUTPUT, format.visual->visual_id, - XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK, - values); + mask, values); if (!normal) { if (atoms->get("_MOTIF_WM_INFO", false) != XCB_ATOM_NONE) { auto atom = atoms->get("_MOTIF_WM_HINTS"); @@ -779,6 +793,7 @@ private: std::shared_ptr atoms_; x::unique_window wnd_; x::unique_gcontext gcontext_; + x::unique_colormap cmap_; uint8_t depth_; uint32_t black_pixel_; xcb_screen_t const* screen_; -- cgit v1.3