Skip to content

Commit

Permalink
Handle unsupported compositors more gracefully
Browse files Browse the repository at this point in the history
If the virtual keyboard or virtual pointer protocols are not supported,
produce a meaningful error message rather than dereference NULL and
segfault. Related to #16
  • Loading branch information
r-c-f committed Sep 23, 2021
1 parent b918691 commit 9467f62
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/wayland.c
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,15 @@ bool wlSetup(struct wlContext *ctx, int width, int height)
wl_display_dispatch(ctx->display);
wl_display_roundtrip(ctx->display);

if (!ctx->pointer_manager) {
logErr("Compositor does not support wlr_virtual_pointer_unstable_v1");
return false;
}
if (!ctx->keyboard_manager) {
logErr("Compositor does not support virtual_keyboard_unstable_v1");
return false;
}

ctx->pointer = zwlr_virtual_pointer_manager_v1_create_virtual_pointer(ctx->pointer_manager, ctx->seat);
ctx->keyboard = zwp_virtual_keyboard_manager_v1_create_virtual_keyboard(ctx->keyboard_manager, ctx->seat);
if(wlKeySetConfigLayout(ctx)) {
Expand Down

0 comments on commit 9467f62

Please sign in to comment.