aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsaac Freund <ifreund@ifreund.xyz>2020-03-24 00:18:18 +0100
committerSimon Ser <contact@emersion.fr>2020-03-24 00:22:50 +0100
commit8707a9b7ecbba0321804604d9ea954a46ecced21 (patch)
tree79a3e351330679496763aa0d02054184b3bd2e0d
parentc682d97841235cc328f044a4e2f2272f7a32b226 (diff)
Return false on wlr_keyboard_set_keymap() failure
This allows users of the library to handle or ignore the error as they see fit.
-rw-r--r--include/wlr/types/wlr_keyboard.h2
-rw-r--r--types/wlr_keyboard.c5
2 files changed, 4 insertions, 3 deletions
diff --git a/include/wlr/types/wlr_keyboard.h b/include/wlr/types/wlr_keyboard.h
index 9bd4acd9..616e2218 100644
--- a/include/wlr/types/wlr_keyboard.h
+++ b/include/wlr/types/wlr_keyboard.h
@@ -103,7 +103,7 @@ struct wlr_event_keyboard_key {
enum wlr_key_state state;
};
-void wlr_keyboard_set_keymap(struct wlr_keyboard *kb,
+bool wlr_keyboard_set_keymap(struct wlr_keyboard *kb,
struct xkb_keymap *keymap);
/**
* Sets the keyboard repeat info. `rate` is in key repeats/second and delay is
diff --git a/types/wlr_keyboard.c b/types/wlr_keyboard.c
index 1ea3bc7d..8b4bcf8f 100644
--- a/types/wlr_keyboard.c
+++ b/types/wlr_keyboard.c
@@ -145,7 +145,7 @@ void wlr_keyboard_led_update(struct wlr_keyboard *kb, uint32_t leds) {
}
}
-void wlr_keyboard_set_keymap(struct wlr_keyboard *kb,
+bool wlr_keyboard_set_keymap(struct wlr_keyboard *kb,
struct xkb_keymap *keymap) {
xkb_keymap_unref(kb->keymap);
kb->keymap = xkb_keymap_ref(keymap);
@@ -199,7 +199,7 @@ void wlr_keyboard_set_keymap(struct wlr_keyboard *kb,
keyboard_modifier_update(kb);
wlr_signal_emit_safe(&kb->events.keymap, kb);
- return;
+ return true;
err:
xkb_state_unref(kb->xkb_state);
@@ -208,6 +208,7 @@ err:
kb->keymap = NULL;
free(kb->keymap_string);
kb->keymap_string = NULL;
+ return false;
}
void wlr_keyboard_set_repeat_info(struct wlr_keyboard *kb, int32_t rate,