]> git.sur5r.net Git - i3/i3/blob - i3-input/xcb.c
Add libi3/load_font, use it everywhere
[i3/i3] / i3-input / 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
16 #include <xcb/xcb.h>
17 #include <xcb/xcb_keysyms.h>
18
19 #include <X11/keysym.h>
20
21 #include "i3-input.h"
22
23 /*
24  * Opens the window we use for input/output and maps it
25  *
26  */
27 xcb_window_t open_input_window(xcb_connection_t *conn, uint32_t width, uint32_t height) {
28         xcb_window_t win = xcb_generate_id(conn);
29         //xcb_cursor_t cursor_id = xcb_generate_id(conn);
30
31 #if 0
32         /* Use the default cursor (left pointer) */
33         if (cursor > -1) {
34                 i3Font *cursor_font = load_font(conn, "cursor");
35                 xcb_create_glyph_cursor(conn, cursor_id, cursor_font->id, cursor_font->id,
36                                 XCB_CURSOR_LEFT_PTR, XCB_CURSOR_LEFT_PTR + 1,
37                                 0, 0, 0, 65535, 65535, 65535);
38         }
39 #endif
40
41         uint32_t mask = 0;
42         uint32_t values[3];
43
44         mask |= XCB_CW_BACK_PIXEL;
45         values[0] = 0;
46
47         mask |= XCB_CW_OVERRIDE_REDIRECT;
48         values[1] = 1;
49
50         mask |= XCB_CW_EVENT_MASK;
51         values[2] = XCB_EVENT_MASK_EXPOSURE;
52
53         xcb_create_window(conn,
54                           XCB_COPY_FROM_PARENT,
55                           win, /* the window id */
56                           root, /* parent == root */
57                           50, 50, width, height, /* dimensions */
58                           0, /* border = 0, we draw our own */
59                           XCB_WINDOW_CLASS_INPUT_OUTPUT,
60                           XCB_WINDOW_CLASS_COPY_FROM_PARENT, /* copy visual from parent */
61                           mask,
62                           values);
63
64 #if 0
65         if (cursor > -1)
66                 xcb_change_window_attributes(conn, result, XCB_CW_CURSOR, &cursor_id);
67 #endif
68
69         /* Map the window (= make it visible) */
70         xcb_map_window(conn, win);
71
72         return win;
73 }