From b904c9a34aa986ebde868c9d22cff0b7643ad916 Mon Sep 17 00:00:00 2001
From: Michael Stapelberg <michael@stapelberg.de>
Date: Sun, 10 Oct 2010 20:18:31 +0200
Subject: [PATCH] Bugfix: Initialize variable 'root' earlier

Fixes a regression introduced in commit f2896d3 (create_window(), invoked
indirectly in expand_table_{rows,cols}, uses the root variable).
---
 src/mainx.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/mainx.c b/src/mainx.c
index 234f86ef..17f2bec8 100644
--- a/src/mainx.c
+++ b/src/mainx.c
@@ -283,6 +283,11 @@ int main(int argc, char *argv[], char *env[]) {
         if (xcb_connection_has_error(conn))
                 die("Cannot open display\n");
 
+        /* Get the root window */
+        xcb_screen_t *root_screen = xcb_aux_get_screen(conn, screens);
+        root = root_screen->root;
+        root_depth = root_screen->root_depth;
+
         load_configuration(conn, override_configpath, false);
         if (only_check_config) {
                 LOG("Done checking configuration file. Exiting.\n");
@@ -441,11 +446,7 @@ int main(int argc, char *argv[], char *env[]) {
         /* Watch size hints (to obey correct aspect ratio) */
         xcb_property_set_handler(&prophs, WM_NORMAL_HINTS, UINT_MAX, handle_normal_hints, NULL);
 
-        /* Get the root window and set the event mask */
-        xcb_screen_t *root_screen = xcb_aux_get_screen(conn, screens);
-        root = root_screen->root;
-        root_depth = root_screen->root_depth;
-
+        /* set event mask */
         uint32_t mask = XCB_CW_EVENT_MASK;
         uint32_t values[] = { XCB_EVENT_MASK_SUBSTRUCTURE_REDIRECT |
                               XCB_EVENT_MASK_STRUCTURE_NOTIFY |         /* when the user adds a screen (e.g. video