diff options
| author | Joel Klinghed <the_jk@yahoo.com> | 2017-09-27 19:38:44 +0200 |
|---|---|---|
| committer | Joel Klinghed <the_jk@yahoo.com> | 2017-09-27 19:38:44 +0200 |
| commit | 36ab6defac59d289a513e74c28e21f437adead98 (patch) | |
| tree | a578cf109f7a5da6973937c68fc00f9846032494 /src/main.cc | |
| parent | 62546e2a0fbd6d0e4730873480466dd1fef07d96 (diff) | |
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
Diffstat (limited to 'src/main.cc')
| -rw-r--r-- | src/main.cc | 25 |
1 files changed, 20 insertions, 5 deletions
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); + cmap_.reset(); - uint32_t values[2]; - values[0] = screen->black_pixel; - values[1] = XCB_EVENT_MASK_KEY_PRESS | XCB_EVENT_MASK_EXPOSURE + 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<x::Atoms> 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_; |
