Add some more keyboard handling for wayland clients

This commit is contained in:
Drew DeVault 2015-12-12 12:53:55 -05:00
parent 19fd979af4
commit 029e0c7a2c
4 changed files with 58 additions and 55 deletions

View file

@ -49,7 +49,7 @@ Run these commands:
mkdir build mkdir build
cd build cd build
cmake .. cmake -DCMAKE_BUILD_TYPE=Release ..
make make
sudo make install sudo make install

View file

@ -44,8 +44,6 @@ struct xkb {
}; };
struct input { struct input {
int *repeat_fd;
struct xkb xkb; struct xkb xkb;
xkb_keysym_t sym; xkb_keysym_t sym;
@ -53,17 +51,7 @@ struct input {
uint32_t last_code; uint32_t last_code;
uint32_t modifiers; uint32_t modifiers;
xkb_keysym_t repeat_sym; void (*notify)(enum wl_keyboard_key_state state, xkb_keysym_t sym, uint32_t code);
uint32_t repeat_key;
int32_t repeat_rate_sec;
int32_t repeat_rate_nsec;
int32_t repeat_delay_sec;
int32_t repeat_delay_nsec;
struct {
void (*key)(enum wl_keyboard_key_state state, xkb_keysym_t sym, uint32_t code);
} notify;
}; };
struct registry { struct registry {

View file

@ -34,9 +34,9 @@ int main(int argc, char **argv) {
surfaces = create_list(); surfaces = create_list();
registry = registry_poll(); registry = registry_poll();
if (!registry->swaylock) { /*if (!registry->swaylock) {
sway_abort("swaylock requires the compositor to support the swaylock extension."); sway_abort("swaylock requires the compositor to support the swaylock extension.");
} }*/
int i; int i;
for (i = 0; i < registry->outputs->length; ++i) { for (i = 0; i < registry->outputs->length; ++i) {
@ -45,7 +45,7 @@ int main(int argc, char **argv) {
if (!window) { if (!window) {
sway_abort("Failed to create surfaces."); sway_abort("Failed to create surfaces.");
} }
lock_set_lock_surface(registry->swaylock, output->output, window->surface); //lock_set_lock_surface(registry->swaylock, output->output, window->surface);
list_add(surfaces, window); list_add(surfaces, window);
} }

View file

@ -113,14 +113,29 @@ static void keyboard_handle_keymap(void *data, struct wl_keyboard *keyboard,
static void keyboard_handle_enter(void *data, struct wl_keyboard *keyboard, static void keyboard_handle_enter(void *data, struct wl_keyboard *keyboard,
uint32_t serial, struct wl_surface *surface, struct wl_array *keys) { uint32_t serial, struct wl_surface *surface, struct wl_array *keys) {
// this space intentionally left blank
} }
static void keyboard_handle_leave(void *data, struct wl_keyboard *keyboard, static void keyboard_handle_leave(void *data, struct wl_keyboard *keyboard,
uint32_t serial, struct wl_surface *surface) { uint32_t serial, struct wl_surface *surface) {
// this space intentionally left blank
} }
static void keyboard_handle_key(void *data, struct wl_keyboard *keyboard, static void keyboard_handle_key(void *data, struct wl_keyboard *keyboard,
uint32_t serial, uint32_t time, uint32_t key, uint32_t state_w) { uint32_t serial, uint32_t time, uint32_t key, uint32_t state_w) {
struct registry *registry = data;
enum wl_keyboard_key_state state = state_w;
if (!input->xkb.state) {
return;
}
xkb_keysym_t sym = xkb_state_key_get_one_sym(input->xkb.state, key + 8);
registry->input->sym = (state == WL_KEYBOARD_KEY_STATE_PRESSED ? sym : XKB_KEY_NoSymbol);
registry->input->code = (state == WL_KEYBOARD_KEY_STATE_PRESSED ? key + 8 : 0);
if (registry->input->notify) {
registry->input->notify(state, sym, key);
}
} }
static void keyboard_handle_modifiers(void *data, struct wl_keyboard *keyboard, static void keyboard_handle_modifiers(void *data, struct wl_keyboard *keyboard,