From b16ab02cc7014359940f4248775f82a06f08b0a5 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Wed, 24 Jun 2009 23:50:04 +0200 Subject: [PATCH] Bugfix: Correctly initialize screens when Xinerama is disabled (Thanks Moredread) --- src/xinerama.c | 54 +++++++++++++++++++++++++++----------------------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/src/xinerama.c b/src/xinerama.c index 818df00a..f1becf8c 100644 --- a/src/xinerama.c +++ b/src/xinerama.c @@ -100,6 +100,31 @@ i3Screen *get_screen_most(direction_t direction) { return candidate; } +static void initialize_screen(xcb_connection_t *conn, i3Screen *screen, Workspace *workspace) { + i3Font *font = load_font(conn, config.font); + + workspace->screen = screen; + screen->current_workspace = workspace->num; + + /* Create a bar for each screen */ + Rect bar_rect = {screen->rect.x, + screen->rect.height - (font->height + 6), + screen->rect.x + screen->rect.width, + font->height + 6}; + uint32_t mask = XCB_CW_OVERRIDE_REDIRECT | XCB_CW_EVENT_MASK; + uint32_t values[] = {1, XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_BUTTON_PRESS}; + screen->bar = create_window(conn, bar_rect, XCB_WINDOW_CLASS_INPUT_OUTPUT, XCB_CURSOR_LEFT_PTR, mask, values); + screen->bargc = xcb_generate_id(conn); + xcb_create_gc(conn, screen->bargc, screen->bar, 0, 0); + + SLIST_INIT(&(screen->dock_clients)); + + /* Copy dimensions */ + memcpy(&(workspace->rect), &(screen->rect), sizeof(Rect)); + LOG("that is virtual screen at %d x %d with %d x %d\n", + screen->rect.x, screen->rect.y, screen->rect.width, screen->rect.height); +} + /* * Fills virtual_screens with exactly one screen with width/height of the whole X server. * @@ -114,6 +139,10 @@ static void disable_xinerama(xcb_connection_t *conn) { s->rect.width = root_screen->width_in_pixels; s->rect.height = root_screen->height_in_pixels; + num_screens = 1; + s->num = 0; + initialize_screen(conn, s, &(workspaces[0])); + TAILQ_INSERT_TAIL(virtual_screens, s, screens); xinerama_enabled = false; @@ -170,31 +199,6 @@ static void query_screens(xcb_connection_t *conn, struct screens_head *screenlis } } -static void initialize_screen(xcb_connection_t *conn, i3Screen *screen, Workspace *workspace) { - i3Font *font = load_font(conn, config.font); - - workspace->screen = screen; - screen->current_workspace = workspace->num; - - /* Create a bar for each screen */ - Rect bar_rect = {screen->rect.x, - screen->rect.height - (font->height + 6), - screen->rect.x + screen->rect.width, - font->height + 6}; - uint32_t mask = XCB_CW_OVERRIDE_REDIRECT | XCB_CW_EVENT_MASK; - uint32_t values[] = {1, XCB_EVENT_MASK_EXPOSURE | XCB_EVENT_MASK_BUTTON_PRESS}; - screen->bar = create_window(conn, bar_rect, XCB_WINDOW_CLASS_INPUT_OUTPUT, XCB_CURSOR_LEFT_PTR, mask, values); - screen->bargc = xcb_generate_id(conn); - xcb_create_gc(conn, screen->bargc, screen->bar, 0, 0); - - SLIST_INIT(&(screen->dock_clients)); - - /* Copy dimensions */ - memcpy(&(workspace->rect), &(screen->rect), sizeof(Rect)); - LOG("that is virtual screen at %d x %d with %d x %d\n", - screen->rect.x, screen->rect.y, screen->rect.width, screen->rect.height); -} - /* * We have just established a connection to the X server and need the initial Xinerama * information to setup workspaces for each screen. -- 2.39.5