]> git.sur5r.net Git - i3/i3/blob - i3-config-wizard/xcb.c
Add libi3/load_font, use it everywhere
[i3/i3] / i3-config-wizard / xcb.c
1 /*
2  * vim:ts=8:expandtab
3  *
4  * i3 - an improved dynamic tiling window manager
5  *
6  * © 2009 Michael Stapelberg and contributors
7  *
8  * See file LICENSE for license information.
9  *
10  */
11 #include <stdint.h>
12 #include <stdlib.h>
13 #include <string.h>
14 #include <stdio.h>
15 #include <err.h>
16
17 #include <xcb/xcb.h>
18 #include <xcb/xcb_keysyms.h>
19
20 #include <X11/keysym.h>
21
22 #include "xcb.h"
23
24 extern xcb_window_t root;
25 unsigned int xcb_numlock_mask;
26
27 /*
28  * Opens the window we use for input/output and maps it
29  *
30  */
31 xcb_window_t open_input_window(xcb_connection_t *conn, uint32_t width, uint32_t height) {
32         xcb_window_t win = xcb_generate_id(conn);
33         //xcb_cursor_t cursor_id = xcb_generate_id(conn);
34
35 #if 0
36         /* Use the default cursor (left pointer) */
37         if (cursor > -1) {
38                 i3Font *cursor_font = load_font(conn, "cursor");
39                 xcb_create_glyph_cursor(conn, cursor_id, cursor_font->id, cursor_font->id,
40                                 XCB_CURSOR_LEFT_PTR, XCB_CURSOR_LEFT_PTR + 1,
41                                 0, 0, 0, 65535, 65535, 65535);
42         }
43 #endif
44
45         uint32_t mask = 0;
46         uint32_t values[3];
47
48         mask |= XCB_CW_BACK_PIXEL;
49         values[0] = 0;
50
51         mask |= XCB_CW_EVENT_MASK;
52         values[1] = XCB_EVENT_MASK_EXPOSURE |
53                     XCB_EVENT_MASK_BUTTON_PRESS;
54
55         xcb_create_window(conn,
56                           XCB_COPY_FROM_PARENT,
57                           win, /* the window id */
58                           root, /* parent == root */
59                           490, 297, width, height, /* dimensions */
60                           0, /* border = 0, we draw our own */
61                           XCB_WINDOW_CLASS_INPUT_OUTPUT,
62                           XCB_WINDOW_CLASS_COPY_FROM_PARENT, /* copy visual from parent */
63                           mask,
64                           values);
65
66 #if 0
67         if (cursor > -1)
68                 xcb_change_window_attributes(conn, result, XCB_CW_CURSOR, &cursor_id);
69 #endif
70
71         /* Map the window (= make it visible) */
72         xcb_map_window(conn, win);
73
74         return win;
75 }