refactor(main): Parse args before connecting to X

This commit is contained in:
Michael Carlberg 2016-12-24 02:55:21 +01:00
parent bb0d6f580d
commit 85c915d35b

View File

@ -41,24 +41,6 @@ int main(int argc, char** argv) {
logger& logger{const_cast<decltype(logger)>(logger::make(loglevel::WARNING))};
try {
//==================================================
// Connect to X server
//==================================================
XInitThreads();
// Store the xcb connection pointer with a disconnect deleter
unique_ptr<xcb_connection_t, xutils::xcb_connection_deleter> 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<xcb_connection_t, xutils::xcb_connection_deleter> 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
//==================================================