Replace wlr_key_state with wl_keyboard_key_state

There's no reason to have duplicate enums
This commit is contained in:
Isaac Freund 2020-10-21 17:21:23 +02:00 committed by Simon Ser
parent 238d1c078f
commit 7693f61d81
9 changed files with 26 additions and 28 deletions

View file

@ -58,11 +58,11 @@ bool keyboard_modifier_update(struct wlr_keyboard *keyboard) {
void keyboard_key_update(struct wlr_keyboard *keyboard,
struct wlr_event_keyboard_key *event) {
if (event->state == WLR_KEY_PRESSED) {
if (event->state == WL_KEYBOARD_KEY_STATE_PRESSED) {
set_add(keyboard->keycodes, &keyboard->num_keycodes,
WLR_KEYBOARD_KEYS_CAP, event->keycode);
}
if (event->state == WLR_KEY_RELEASED) {
if (event->state == WL_KEYBOARD_KEY_STATE_RELEASED) {
set_remove(keyboard->keycodes, &keyboard->num_keycodes,
WLR_KEYBOARD_KEYS_CAP, event->keycode);
}
@ -99,7 +99,7 @@ void wlr_keyboard_notify_key(struct wlr_keyboard *keyboard,
if (event->update_state) {
uint32_t keycode = event->keycode + 8;
xkb_state_update_key(keyboard->xkb_state, keycode,
event->state == WLR_KEY_PRESSED ? XKB_KEY_DOWN : XKB_KEY_UP);
event->state == WL_KEYBOARD_KEY_STATE_PRESSED ? XKB_KEY_DOWN : XKB_KEY_UP);
}
bool updated = keyboard_modifier_update(keyboard);

View file

@ -4,6 +4,7 @@
#include <stdio.h>
#include <time.h>
#include <wayland-server-core.h>
#include <wayland-server-protocol.h>
#include <xkbcommon/xkbcommon.h>
#include "types/wlr_keyboard.h"
#include "util/signal.h"
@ -95,11 +96,11 @@ static bool process_key(struct keyboard_group_device *group_device,
if (key->keycode != event->keycode) {
continue;
}
if (event->state == WLR_KEY_PRESSED) {
if (event->state == WL_KEYBOARD_KEY_STATE_PRESSED) {
key->count++;
return false;
}
if (event->state == WLR_KEY_RELEASED) {
if (event->state == WL_KEYBOARD_KEY_STATE_RELEASED) {
key->count--;
if (key->count > 0) {
return false;
@ -110,7 +111,7 @@ static bool process_key(struct keyboard_group_device *group_device,
break;
}
if (event->state == WLR_KEY_PRESSED) {
if (event->state == WL_KEYBOARD_KEY_STATE_PRESSED) {
struct keyboard_group_key *key =
calloc(1, sizeof(struct keyboard_group_key));
if (!key) {
@ -199,7 +200,7 @@ static void handle_keyboard_repeat_info(struct wl_listener *listener,
}
static void refresh_state(struct keyboard_group_device *device,
enum wlr_key_state state) {
enum wl_keyboard_key_state state) {
struct wl_array keys;
wl_array_init(&keys);
@ -229,7 +230,7 @@ static void refresh_state(struct keyboard_group_device *device,
// If there are any unique keys, emit the enter/leave event
if (keys.size > 0) {
if (state == WLR_KEY_PRESSED) {
if (state == WL_KEYBOARD_KEY_STATE_PRESSED) {
wlr_signal_emit_safe(&device->keyboard->group->events.enter, &keys);
} else {
wlr_signal_emit_safe(&device->keyboard->group->events.leave, &keys);
@ -240,7 +241,7 @@ static void refresh_state(struct keyboard_group_device *device,
}
static void remove_keyboard_group_device(struct keyboard_group_device *device) {
refresh_state(device, WLR_KEY_RELEASED);
refresh_state(device, WL_KEYBOARD_KEY_STATE_RELEASED);
device->keyboard->group = NULL;
wl_list_remove(&device->link);
wl_list_remove(&device->key.link);
@ -312,7 +313,7 @@ bool wlr_keyboard_group_add_keyboard(struct wlr_keyboard_group *group,
group_kb->repeat_info.delay);
}
refresh_state(device, WLR_KEY_PRESSED);
refresh_state(device, WL_KEYBOARD_KEY_STATE_PRESSED);
return true;
}