From 7b01bc5eb703a8191f53a464cac6339db89420b5 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Fri, 28 Jan 2011 00:41:53 +0100 Subject: [PATCH] =?utf8?q?Bugfix:=20use=20the=20global=20root=20variable,?= =?utf8?q?=20don=E2=80=99t=20get=20the=20first=20one=20(Thanks=20quaec)?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The case of an X11 server having multiple displays is handled correctly by the code in src/mainx.c. However, due to some functions not being correctly refactored and still getting the first screen (and also the first root window) from the XCB connection, i3 was operating on the wrong root window. --- i3-input/i3-input.h | 2 ++ i3-input/main.c | 6 ++++-- i3-input/xcb.c | 1 - src/floating.c | 1 - src/sighandler.c | 1 - src/xcb.c | 1 - 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/i3-input/i3-input.h b/i3-input/i3-input.h index c699f6c5..581203d4 100644 --- a/i3-input/i3-input.h +++ b/i3-input/i3-input.h @@ -12,6 +12,8 @@ } \ while (0) +extern xcb_window_t root; + char *convert_ucs_to_utf8(char *input); char *convert_utf8_to_ucs2(char *input, int *real_strlen); uint32_t get_colorpixel(xcb_connection_t *conn, char *hex); diff --git a/i3-input/main.c b/i3-input/main.c index b9b4ba81..6efbbdec 100644 --- a/i3-input/main.c +++ b/i3-input/main.c @@ -50,6 +50,7 @@ static char *command_prefix; static char *prompt; static int prompt_len; static int limit; +xcb_window_t root; /* * Concats the glyphs (either UCS-2 or UTF-8) to a single string, suitable for @@ -302,6 +303,9 @@ int main(int argc, char *argv[]) { if (xcb_connection_has_error(conn)) die("Cannot open display\n"); + xcb_screen_t *root_screen = xcb_aux_get_screen(conn, screens); + root = root_screen->root; + /* Set up event handlers for key press and key release */ xcb_event_handlers_t evenths; memset(&evenths, 0, sizeof(xcb_event_handlers_t)); @@ -320,8 +324,6 @@ int main(int argc, char *argv[]) { win = open_input_window(conn, 500, font_height + 8); /* Create pixmap */ - xcb_screen_t *root_screen = xcb_aux_get_screen(conn, screens); - pixmap = xcb_generate_id(conn); pixmap_gc = xcb_generate_id(conn); xcb_create_pixmap(conn, root_screen->root_depth, pixmap, win, 500, font_height + 8); diff --git a/i3-input/xcb.c b/i3-input/xcb.c index 661d4863..3c1d99e1 100644 --- a/i3-input/xcb.c +++ b/i3-input/xcb.c @@ -86,7 +86,6 @@ uint32_t get_mod_mask(xcb_connection_t *conn, uint32_t keycode) { * */ xcb_window_t open_input_window(xcb_connection_t *conn, uint32_t width, uint32_t height) { - xcb_window_t root = xcb_setup_roots_iterator(xcb_get_setup(conn)).data->root; xcb_window_t win = xcb_generate_id(conn); //xcb_cursor_t cursor_id = xcb_generate_id(conn); diff --git a/src/floating.c b/src/floating.c index b4d21963..c912dc71 100644 --- a/src/floating.c +++ b/src/floating.c @@ -325,7 +325,6 @@ void floating_resize_window(Con *con, bool proportional, void drag_pointer(Con *con, xcb_button_press_event_t *event, xcb_window_t confine_to, border_t border, callback_t callback, void *extra) { - xcb_window_t root = xcb_setup_roots_iterator(xcb_get_setup(conn)).data->root; uint32_t new_x, new_y; Rect old_rect; if (con != NULL) diff --git a/src/sighandler.c b/src/sighandler.c index ea2bf9fe..3a9ad82f 100644 --- a/src/sighandler.c +++ b/src/sighandler.c @@ -113,7 +113,6 @@ static int sig_handle_key_press(void *ignored, xcb_connection_t *conn, xcb_key_p * */ static xcb_window_t open_input_window(xcb_connection_t *conn, Rect screen_rect, uint32_t width, uint32_t height) { - xcb_window_t root = xcb_setup_roots_iterator(xcb_get_setup(conn)).data->root; xcb_window_t win = xcb_generate_id(conn); uint32_t mask = 0; diff --git a/src/xcb.c b/src/xcb.c index ff7dadbc..53a90685 100644 --- a/src/xcb.c +++ b/src/xcb.c @@ -82,7 +82,6 @@ uint32_t get_colorpixel(char *hex) { */ xcb_window_t create_window(xcb_connection_t *conn, Rect dims, uint16_t window_class, enum xcursor_cursor_t cursor, bool map, uint32_t mask, uint32_t *values) { - xcb_window_t root = xcb_setup_roots_iterator(xcb_get_setup(conn)).data->root; xcb_window_t result = xcb_generate_id(conn); xcb_cursor_t cursor_id = xcb_generate_id(conn); -- 2.39.5