summaryrefslogtreecommitdiff
path: root/src/main.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.cc')
-rw-r--r--src/main.cc25
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_;