x: move redirection failure abort out of x_print_error

x_print_error aborts the program when it sees a redirect_subwindow
failure. A function called x_print_error really shouldn't cause the
program to terminate.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2020-03-27 21:02:38 +00:00
parent b88d98d6b1
commit 574eca3c25
No known key found for this signature in database
GPG Key ID: 37C999F617EA1A47
3 changed files with 22 additions and 22 deletions

View File

@ -1205,7 +1205,13 @@ static bool redirect_start(session_t *ps) {
xcb_map_window(ps->c, ps->overlay); xcb_map_window(ps->c, ps->overlay);
} }
xcb_composite_redirect_subwindows(ps->c, ps->root, session_redirection_mode(ps)); bool success = XCB_AWAIT_VOID(xcb_composite_redirect_subwindows, ps->c, ps->root,
session_redirection_mode(ps));
if (!success) {
log_fatal("Another composite manager is already running "
"(and does not handle _NET_WM_CM_Sn correctly)");
return false;
}
x_sync(ps->c); x_sync(ps->c);

View File

@ -334,12 +334,6 @@ void x_print_error(unsigned long serial, uint8_t major, uint16_t minor, uint8_t
int o = 0; int o = 0;
const char *name = "Unknown"; const char *name = "Unknown";
if (major == ps->composite_opcode && minor == XCB_COMPOSITE_REDIRECT_SUBWINDOWS) {
log_fatal("Another composite manager is already running "
"(and does not handle _NET_WM_CM_Sn correctly)");
exit(1);
}
#define CASESTRRET2(s) \ #define CASESTRRET2(s) \
case s: name = #s; break case s: name = #s; break

30
src/x.h
View File

@ -50,27 +50,27 @@ struct xvisual_info {
#define XCB_AWAIT_VOID(func, c, ...) \ #define XCB_AWAIT_VOID(func, c, ...) \
({ \ ({ \
bool success = true; \ bool __success = true; \
__auto_type e = xcb_request_check(c, func##_checked(c, __VA_ARGS__)); \ __auto_type __e = xcb_request_check(c, func##_checked(c, __VA_ARGS__)); \
if (e) { \ if (__e) { \
x_print_error(e->sequence, e->major_code, e->minor_code, \ x_print_error(__e->sequence, __e->major_code, __e->minor_code, \
e->error_code); \ __e->error_code); \
free(e); \ free(__e); \
success = false; \ __success = false; \
} \ } \
success; \ __success; \
}) })
#define XCB_AWAIT(func, c, ...) \ #define XCB_AWAIT(func, c, ...) \
({ \ ({ \
xcb_generic_error_t *e = NULL; \ xcb_generic_error_t *__e = NULL; \
__auto_type r = func##_reply(c, func(c, __VA_ARGS__), &e); \ __auto_type __r = func##_reply(c, func(c, __VA_ARGS__), &__e); \
if (e) { \ if (__e) { \
x_print_error(e->sequence, e->major_code, e->minor_code, \ x_print_error(__e->sequence, __e->major_code, __e->minor_code, \
e->error_code); \ __e->error_code); \
free(e); \ free(__e); \
} \ } \
r; \ __r; \
}) })
/// Wraps x_new_id. abort the program if x_new_id returns error /// Wraps x_new_id. abort the program if x_new_id returns error