Bugfix: use the global root variable, don’t get the first one (Thanks quaec)

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.
next
Michael Stapelberg 2011-01-28 00:41:53 +01:00
parent 79bbde8766
commit 7b01bc5eb7
6 changed files with 6 additions and 6 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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)

View File

@ -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;

View File

@ -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);