From: Michael Stapelberg Date: Sun, 23 Oct 2011 22:20:57 +0000 (+0100) Subject: get rid of xcb.c in all i3-* tools X-Git-Tag: 4.1~51 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=f4469eee0b0988c082a5df580c24c15b5eed2c2e;p=i3%2Fi3 get rid of xcb.c in all i3-* tools open_input_window was slightly different for each of them, so it made no sense to generalize it (then we would end up with a thin and useless wrapper). --- diff --git a/i3-config-wizard/main.c b/i3-config-wizard/main.c index 896574e5..b9862f2b 100644 --- a/i3-config-wizard/main.c +++ b/i3-config-wizard/main.c @@ -57,6 +57,7 @@ enum { STEP_WELCOME, STEP_GENERATE } current_step = STEP_WELCOME; enum { MOD_Mod1, MOD_Mod4 } modifier = MOD_Mod4; static char *config_path; +static uint32_t xcb_numlock_mask; xcb_connection_t *conn; static xcb_get_modifier_mapping_reply_t *modmap_reply; static i3Font font; @@ -442,7 +443,25 @@ int main(int argc, char *argv[]) { bold_font = load_font(patternbold, true); /* Open an input window */ - win = open_input_window(conn, 300, 205); + win = xcb_generate_id(conn); + xcb_create_window( + conn, + XCB_COPY_FROM_PARENT, + win, /* the window id */ + root, /* parent == root */ + 490, 297, 300, 205, /* dimensions */ + 0, /* X11 border = 0, we draw our own */ + XCB_WINDOW_CLASS_INPUT_OUTPUT, + XCB_WINDOW_CLASS_COPY_FROM_PARENT, /* copy visual from parent */ + XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK, + (uint32_t[]){ + 0, /* back pixel: black */ + XCB_EVENT_MASK_EXPOSURE | + XCB_EVENT_MASK_BUTTON_PRESS + }); + + /* Map the window (make it visible) */ + xcb_map_window(conn, win); /* Setup NetWM atoms */ #define xmacro(name) \ diff --git a/i3-config-wizard/xcb.c b/i3-config-wizard/xcb.c deleted file mode 100644 index cabc0926..00000000 --- a/i3-config-wizard/xcb.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - * vim:ts=8:expandtab - * - * i3 - an improved dynamic tiling window manager - * - * © 2009 Michael Stapelberg and contributors - * - * See file LICENSE for license information. - * - */ -#include -#include -#include -#include -#include - -#include -#include - -#include - -#include "xcb.h" - -extern xcb_window_t root; -unsigned int xcb_numlock_mask; - -/* - * Opens the window we use for input/output and maps it - * - */ -xcb_window_t open_input_window(xcb_connection_t *conn, uint32_t width, uint32_t height) { - xcb_window_t win = xcb_generate_id(conn); - //xcb_cursor_t cursor_id = xcb_generate_id(conn); - -#if 0 - /* Use the default cursor (left pointer) */ - if (cursor > -1) { - i3Font *cursor_font = load_font(conn, "cursor"); - xcb_create_glyph_cursor(conn, cursor_id, cursor_font->id, cursor_font->id, - XCB_CURSOR_LEFT_PTR, XCB_CURSOR_LEFT_PTR + 1, - 0, 0, 0, 65535, 65535, 65535); - } -#endif - - uint32_t mask = 0; - uint32_t values[3]; - - mask |= XCB_CW_BACK_PIXEL; - values[0] = 0; - - mask |= XCB_CW_EVENT_MASK; - values[1] = XCB_EVENT_MASK_EXPOSURE | - XCB_EVENT_MASK_BUTTON_PRESS; - - xcb_create_window(conn, - XCB_COPY_FROM_PARENT, - win, /* the window id */ - root, /* parent == root */ - 490, 297, width, height, /* dimensions */ - 0, /* border = 0, we draw our own */ - XCB_WINDOW_CLASS_INPUT_OUTPUT, - XCB_WINDOW_CLASS_COPY_FROM_PARENT, /* copy visual from parent */ - mask, - values); - -#if 0 - if (cursor > -1) - xcb_change_window_attributes(conn, result, XCB_CW_CURSOR, &cursor_id); -#endif - - /* Map the window (= make it visible) */ - xcb_map_window(conn, win); - - return win; -} diff --git a/i3-config-wizard/xcb.h b/i3-config-wizard/xcb.h index 4e273f66..4ed182c4 100644 --- a/i3-config-wizard/xcb.h +++ b/i3-config-wizard/xcb.h @@ -8,8 +8,4 @@ #include "atoms.xmacro" #undef xmacro -extern unsigned int xcb_numlock_mask; - -xcb_window_t open_input_window(xcb_connection_t *conn, uint32_t width, uint32_t height); - #endif diff --git a/i3-input/i3-input.h b/i3-input/i3-input.h index ae0e0fc0..d97807d1 100644 --- a/i3-input/i3-input.h +++ b/i3-input/i3-input.h @@ -16,6 +16,5 @@ extern xcb_window_t root; char *convert_ucs_to_utf8(char *input); char *convert_utf8_to_ucs2(char *input, int *real_strlen); -xcb_window_t open_input_window(xcb_connection_t *conn, uint32_t width, uint32_t height); #endif diff --git a/i3-input/main.c b/i3-input/main.c index 0e3a3f7b..2d4def7c 100644 --- a/i3-input/main.c +++ b/i3-input/main.c @@ -366,7 +366,25 @@ int main(int argc, char *argv[]) { font = load_font(pattern, true); /* Open an input window */ - win = open_input_window(conn, 500, font.height + 8); + win = xcb_generate_id(conn); + xcb_create_window( + conn, + XCB_COPY_FROM_PARENT, + win, /* the window id */ + root, /* parent == root */ + 50, 50, 500, font.height + 8, /* dimensions */ + 0, /* X11 border = 0, we draw our own */ + XCB_WINDOW_CLASS_INPUT_OUTPUT, + XCB_WINDOW_CLASS_COPY_FROM_PARENT, /* copy visual from parent */ + XCB_CW_BACK_PIXEL | XCB_CW_OVERRIDE_REDIRECT | XCB_CW_EVENT_MASK, + (uint32_t[]){ + 0, /* back pixel: black */ + 1, /* override redirect: don’t manage this window */ + XCB_EVENT_MASK_EXPOSURE + }); + + /* Map the window (make it visible) */ + xcb_map_window(conn, win); /* Create pixmap */ pixmap = xcb_generate_id(conn); diff --git a/i3-input/xcb.c b/i3-input/xcb.c deleted file mode 100644 index d6e73307..00000000 --- a/i3-input/xcb.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - * vim:ts=8:expandtab - * - * i3 - an improved dynamic tiling window manager - * - * © 2009 Michael Stapelberg and contributors - * - * See file LICENSE for license information. - * - */ -#include -#include -#include -#include - -#include -#include - -#include - -#include "i3-input.h" - -/* - * Opens the window we use for input/output and maps it - * - */ -xcb_window_t open_input_window(xcb_connection_t *conn, uint32_t width, uint32_t height) { - xcb_window_t win = xcb_generate_id(conn); - //xcb_cursor_t cursor_id = xcb_generate_id(conn); - -#if 0 - /* Use the default cursor (left pointer) */ - if (cursor > -1) { - i3Font *cursor_font = load_font(conn, "cursor"); - xcb_create_glyph_cursor(conn, cursor_id, cursor_font->id, cursor_font->id, - XCB_CURSOR_LEFT_PTR, XCB_CURSOR_LEFT_PTR + 1, - 0, 0, 0, 65535, 65535, 65535); - } -#endif - - uint32_t mask = 0; - uint32_t values[3]; - - mask |= XCB_CW_BACK_PIXEL; - values[0] = 0; - - mask |= XCB_CW_OVERRIDE_REDIRECT; - values[1] = 1; - - mask |= XCB_CW_EVENT_MASK; - values[2] = XCB_EVENT_MASK_EXPOSURE; - - xcb_create_window(conn, - XCB_COPY_FROM_PARENT, - win, /* the window id */ - root, /* parent == root */ - 50, 50, width, height, /* dimensions */ - 0, /* border = 0, we draw our own */ - XCB_WINDOW_CLASS_INPUT_OUTPUT, - XCB_WINDOW_CLASS_COPY_FROM_PARENT, /* copy visual from parent */ - mask, - values); - -#if 0 - if (cursor > -1) - xcb_change_window_attributes(conn, result, XCB_CW_CURSOR, &cursor_id); -#endif - - /* Map the window (= make it visible) */ - xcb_map_window(conn, win); - - return win; -} diff --git a/i3-nagbar/i3-nagbar.h b/i3-nagbar/i3-nagbar.h index b1375840..5a21226b 100644 --- a/i3-nagbar/i3-nagbar.h +++ b/i3-nagbar/i3-nagbar.h @@ -18,6 +18,4 @@ while (0) extern xcb_window_t root; -xcb_window_t open_input_window(xcb_connection_t *conn, uint32_t width, uint32_t height); - #endif diff --git a/i3-nagbar/main.c b/i3-nagbar/main.c index 43b17553..120503c6 100644 --- a/i3-nagbar/main.c +++ b/i3-nagbar/main.c @@ -305,7 +305,28 @@ int main(int argc, char *argv[]) { font = load_font(pattern, true); /* Open an input window */ - win = open_input_window(conn, 500, font.height + 8 + 8 /* 8px padding */); + win = xcb_generate_id(conn); + + xcb_create_window( + conn, + XCB_COPY_FROM_PARENT, + win, /* the window id */ + root, /* parent == root */ + 50, 50, 500, font.height + 8 + 8 /* 8 px padding */, /* dimensions */ + 0, /* x11 border = 0, we draw our own */ + XCB_WINDOW_CLASS_INPUT_OUTPUT, + XCB_WINDOW_CLASS_COPY_FROM_PARENT, /* copy visual from parent */ + XCB_CW_BACK_PIXEL | XCB_CW_EVENT_MASK, + (uint32_t[]){ + 0, /* back pixel: black */ + XCB_EVENT_MASK_EXPOSURE | + XCB_EVENT_MASK_STRUCTURE_NOTIFY | + XCB_EVENT_MASK_BUTTON_PRESS | + XCB_EVENT_MASK_BUTTON_RELEASE + }); + + /* Map the window (make it visible) */ + xcb_map_window(conn, win); /* Setup NetWM atoms */ #define xmacro(name) \ diff --git a/i3-nagbar/xcb.c b/i3-nagbar/xcb.c deleted file mode 100644 index b38cd9a4..00000000 --- a/i3-nagbar/xcb.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - * vim:ts=8:expandtab - * - * i3 - an improved dynamic tiling window manager - * - * © 2009 Michael Stapelberg and contributors - * - * See file LICENSE for license information. - * - */ -#include -#include -#include -#include - -#include -#include - -#include - -#include "i3-nagbar.h" - -/* - * Opens the window we use for input/output and maps it - * - */ -xcb_window_t open_input_window(xcb_connection_t *conn, uint32_t width, uint32_t height) { - xcb_window_t win = xcb_generate_id(conn); - //xcb_cursor_t cursor_id = xcb_generate_id(conn); - -#if 0 - /* Use the default cursor (left pointer) */ - if (cursor > -1) { - i3Font *cursor_font = load_font(conn, "cursor"); - xcb_create_glyph_cursor(conn, cursor_id, cursor_font->id, cursor_font->id, - XCB_CURSOR_LEFT_PTR, XCB_CURSOR_LEFT_PTR + 1, - 0, 0, 0, 65535, 65535, 65535); - } -#endif - - uint32_t mask = 0; - uint32_t values[3]; - - mask |= XCB_CW_BACK_PIXEL; - values[0] = 0; - - mask |= XCB_CW_EVENT_MASK; - values[1] = XCB_EVENT_MASK_EXPOSURE | - XCB_EVENT_MASK_STRUCTURE_NOTIFY | - XCB_EVENT_MASK_BUTTON_PRESS | - XCB_EVENT_MASK_BUTTON_RELEASE; - - xcb_create_window(conn, - XCB_COPY_FROM_PARENT, - win, /* the window id */ - root, /* parent == root */ - 50, 50, width, height, /* dimensions */ - 0, /* border = 0, we draw our own */ - XCB_WINDOW_CLASS_INPUT_OUTPUT, - XCB_WINDOW_CLASS_COPY_FROM_PARENT, /* copy visual from parent */ - mask, - values); - -#if 0 - if (cursor > -1) - xcb_change_window_attributes(conn, result, XCB_CW_CURSOR, &cursor_id); -#endif - - /* Map the window (= make it visible) */ - xcb_map_window(conn, win); - - return win; -}