From: Michael Stapelberg Date: Tue, 22 Dec 2009 10:29:24 +0000 (+0100) Subject: Correctly exit when another window manager is already running X-Git-Tag: 3.e~6^2~190 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=9df64a8d0ae1e622363b0483e1b7220c178be773;p=i3%2Fi3 Correctly exit when another window manager is already running This is implemented by checking if setting the redirect mask returned an error or not. --- diff --git a/src/mainx.c b/src/mainx.c index 1706294c..9c38c4ac 100644 --- a/src/mainx.c +++ b/src/mainx.c @@ -377,7 +377,9 @@ int main(int argc, char *argv[], char *env[]) { XCB_EVENT_MASK_POINTER_MOTION | XCB_EVENT_MASK_PROPERTY_CHANGE | XCB_EVENT_MASK_ENTER_WINDOW }; - xcb_change_window_attributes(conn, root, mask, values); + xcb_void_cookie_t cookie; + cookie = xcb_change_window_attributes_checked(conn, root, mask, values); + check_error(conn, cookie, "Another window manager seems to be running"); /* Setup NetWM atoms */ #define GET_ATOM(name) { \ diff --git a/src/util.c b/src/util.c index 47bcc8fd..915f8cde 100644 --- a/src/util.c +++ b/src/util.c @@ -144,7 +144,7 @@ void start_application(const char *command) { void check_error(xcb_connection_t *conn, xcb_void_cookie_t cookie, char *err_message) { xcb_generic_error_t *error = xcb_request_check(conn, cookie); if (error != NULL) { - fprintf(stderr, "ERROR: %s : %d\n", err_message , error->error_code); + fprintf(stderr, "ERROR: %s (X error %d)\n", err_message , error->error_code); xcb_disconnect(conn); exit(-1); }