mirror of
https://github.com/NickHu/sway
synced 2024-11-16 19:49:56 +01:00
Add some more keyboard handling for wayland clients
This commit is contained in:
parent
19fd979af4
commit
029e0c7a2c
4 changed files with 58 additions and 55 deletions
|
@ -49,7 +49,7 @@ Run these commands:
|
|||
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ..
|
||||
cmake -DCMAKE_BUILD_TYPE=Release ..
|
||||
make
|
||||
sudo make install
|
||||
|
||||
|
|
|
@ -44,8 +44,6 @@ struct xkb {
|
|||
};
|
||||
|
||||
struct input {
|
||||
int *repeat_fd;
|
||||
|
||||
struct xkb xkb;
|
||||
|
||||
xkb_keysym_t sym;
|
||||
|
@ -53,17 +51,7 @@ struct input {
|
|||
uint32_t last_code;
|
||||
uint32_t modifiers;
|
||||
|
||||
xkb_keysym_t repeat_sym;
|
||||
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;
|
||||
void (*notify)(enum wl_keyboard_key_state state, xkb_keysym_t sym, uint32_t code);
|
||||
};
|
||||
|
||||
struct registry {
|
||||
|
|
|
@ -34,9 +34,9 @@ int main(int argc, char **argv) {
|
|||
surfaces = create_list();
|
||||
registry = registry_poll();
|
||||
|
||||
if (!registry->swaylock) {
|
||||
/*if (!registry->swaylock) {
|
||||
sway_abort("swaylock requires the compositor to support the swaylock extension.");
|
||||
}
|
||||
}*/
|
||||
|
||||
int i;
|
||||
for (i = 0; i < registry->outputs->length; ++i) {
|
||||
|
@ -45,7 +45,7 @@ int main(int argc, char **argv) {
|
|||
if (!window) {
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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,
|
||||
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,
|
||||
uint32_t serial, struct wl_surface *surface) {
|
||||
// this space intentionally left blank
|
||||
}
|
||||
|
||||
static void keyboard_handle_key(void *data, struct wl_keyboard *keyboard,
|
||||
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,
|
||||
|
|
Loading…
Reference in a new issue