diff --git a/src/aswm/aswm.c b/src/aswm/aswm.c index 1c346ec..a87e8b7 100644 --- a/src/aswm/aswm.c +++ b/src/aswm/aswm.c @@ -17,20 +17,14 @@ Aswm _aswm; void aswm_open(const char* zlog_conf) { - atexit(aswm_close); - set_up_logger(zlog_conf); - XSetErrorHandler(aswm_error_handler); - _aswm.display = XOpenDisplay(NULL); _aswm.desktops = malloc(0); _aswm.desktops_count = 0; - if(_aswm.display == NULL) { - aswm_error("Cannot open X Display. Check the DISPLAY environement variable, and ensure an X server is running for the corresponding DISPLAY."); - exit(1); - } + XSetErrorHandler(aswm_error_handler); + Window x_root_window = DefaultRootWindow(_aswm.display); XWindowAttributes x_root_attributes; XGetWindowAttributes(_aswm.display, x_root_window, &x_root_attributes); @@ -56,6 +50,8 @@ void aswm_open(const char* zlog_conf) { aswm_debug("ASWM Root window %lu", _aswm.root_window); aswm_log_tree(aswm_debug, &_aswm, DefaultRootWindow(_aswm.display), 1); + + atexit(aswm_close); } void aswm_create_workspace() { @@ -157,8 +153,7 @@ void aswm_event_loop() { void aswm_close() { free(_aswm.desktops); tear_down_logger(); - if(_aswm.display != NULL) - XCloseDisplay(_aswm.display); + XCloseDisplay(_aswm.display); } Window aswm_currently_active() { diff --git a/test/test_set_up.c b/test/test_set_up.c index 6ece3f2..8a7a280 100644 --- a/test/test_set_up.c +++ b/test/test_set_up.c @@ -34,7 +34,7 @@ void set_up_test_logger(void) { printf("Init test zlog failed\n"); } - test_log = zlog_get_category("test"); + test_log = zlog_get_category("test_log"); if (!test_log) { printf("Get zlog test_log category failed\n"); }