From 85c915d35b89278fa00c57fe8940fb2d278e6b3f Mon Sep 17 00:00:00 2001 From: Michael Carlberg Date: Sat, 24 Dec 2016 02:55:21 +0100 Subject: [PATCH] refactor(main): Parse args before connecting to X --- src/main.cpp | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 85c902f3..0152629a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -41,24 +41,6 @@ int main(int argc, char** argv) { logger& logger{const_cast(logger::make(loglevel::WARNING))}; try { - //================================================== - // Connect to X server - //================================================== - XInitThreads(); - - // Store the xcb connection pointer with a disconnect deleter - unique_ptr xcbconn{xutils::get_connection()}; - - if (!xcbconn) { - logger.err("A connection to X could not be established... "); - return EXIT_FAILURE; - } - - connection& conn{connection::make(&*xcbconn)}; - conn.preload_atoms(); - conn.query_extensions(); - conn.ensure_event_mask(conn.root(), XCB_EVENT_MASK_PROPERTY_CHANGE); - //================================================== // Parse command line arguments //================================================== @@ -85,6 +67,25 @@ int main(int argc, char** argv) { return EXIT_FAILURE; } + //================================================== + // Connect to X server + //================================================== + XInitThreads(); + + // Store the xcb connection pointer with a disconnect deleter + unique_ptr xcbconn{xutils::get_connection()}; + + if (!xcbconn) { + logger.err("A connection to X could not be established... "); + return EXIT_FAILURE; + } + + connection& conn{connection::make(&*xcbconn)}; + conn.preload_atoms(); + conn.query_extensions(); + conn.ensure_event_mask(conn.root(), XCB_EVENT_MASK_PROPERTY_CHANGE); + + //================================================== // Load user configuration //==================================================