diff options
| author | Federico Angelilli <code@fedang.net> | 2023-11-13 16:31:09 +0100 |
|---|---|---|
| committer | Federico Angelilli <code@fedang.net> | 2023-11-13 16:31:09 +0100 |
| commit | 8174acdccbe039b8cf8cbefce6fbbf24ce0a5eaf (patch) | |
| tree | 3e5112823c05efbd2a2f113f9e02b1162501bebf | |
| parent | faa64cf36a9cba87bce425206abc620661e402ba (diff) | |
Handle errors in `intern_atom` and fix randr version check
| -rw-r--r-- | x11.c | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -41,9 +41,14 @@ typedef struct { static xcb_atom_t intern_atom(Window *win, const char *atom) { - // TODO: Error handling + xcb_generic_error_t *error; xcb_intern_atom_cookie_t cookie = xcb_intern_atom(win->connection, false, strlen(atom), atom); - return xcb_intern_atom_reply(win->connection, cookie, NULL)->atom; + xcb_intern_atom_reply_t *reply = xcb_intern_atom_reply(win->connection, cookie, &error); + + g_assert_null(error); + xcb_atom_t id = reply->atom; + g_free(reply); + return id; } static gboolean xcb_source_check(GSource *source) @@ -154,8 +159,9 @@ Window *window_create(void) version_cookie, &error); + g_assert_null(error); log_debug("RandR version %d.%d", randr_version->major_version, randr_version->minor_version); - g_assert_true(error == NULL || randr_version->major_version < 1); + g_assert_cmpint(randr_version->major_version, >=, 1); xcb_randr_get_screen_info_cookie_t cookie = xcb_randr_get_screen_info(win->connection, win->screen->root); xcb_randr_get_screen_info_reply_t *info_reply = xcb_randr_get_screen_info_reply(win->connection, cookie, &error); |
