aboutsummaryrefslogtreecommitdiff
path: root/sys/cmd/wm/input.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/cmd/wm/input.c')
-rw-r--r--sys/cmd/wm/input.c72
1 files changed, 37 insertions, 35 deletions
diff --git a/sys/cmd/wm/input.c b/sys/cmd/wm/input.c
index e155024..295f861 100644
--- a/sys/cmd/wm/input.c
+++ b/sys/cmd/wm/input.c
@@ -15,31 +15,16 @@ keymodifier(struct wl_listener *l, void *data)
static
int
-keybinding(xkb_keysym_t sym)
+keybinding(uint32 modifier, xkb_keysym_t sym)
{
- Client *current, *next;
-
- switch(sym) {
- case XKB_KEY_Escape:
- wl_display_terminate(server.display);
- break;
- case XKB_KEY_F1:
- /* cycle to the next client */
- if(wl_list_length(&server.clients) < 2) break;
-
- current = wl_container_of(server.clients.next, current, link);
- next = wl_container_of(current->link.next, next, link);
-
- focus(next, next->xdg->surface);
-
- /* move previous client to the end of the list */
- wl_list_remove(&current->link);
- wl_list_insert(server.clients.prev, &current->link);
- break;
- default:
- return false;
+ Key *key;
+ for(key=cfg·binding; key!=cfg·endbinding; ++key) {
+ if(modifier == key->modifier && sym == key->sym && key->action){
+ key->action(&key->arg);
+ return 1;
+ }
}
- return true;
+ return 0;
}
static
@@ -51,7 +36,6 @@ keypress(struct wl_listener *l, void *data)
const xkb_keysym_t *syms;
struct Keyboard *keyboard = wl_container_of(l, keyboard, event.press);
struct wlr_event_keyboard_key *event = data;
- struct wlr_seat *seat = server.input.seat;
keycode = event->keycode + 8;
@@ -59,20 +43,35 @@ keypress(struct wl_listener *l, void *data)
n = xkb_state_key_get_syms(keyboard->device->keyboard->xkb_state, keycode, &syms);
modifier = wlr_keyboard_get_modifiers(keyboard->device->keyboard);
- if((modifier & WLR_MODIFIER_ALT) && event->state == WL_KEYBOARD_KEY_STATE_PRESSED) {
+ if(event->state == WL_KEYBOARD_KEY_STATE_PRESSED) {
for(i=0; i<n; i++)
- h=keybinding(syms[i]);
+ h=keybinding(modifier, syms[i]);
}
if(!h) {
- wlr_seat_set_keyboard(seat, keyboard->device);
- wlr_seat_keyboard_notify_key(seat, event->time_msec,
- event->keycode, event->state);
+ wlr_seat_set_keyboard(server.input.seat, keyboard->device);
+ wlr_seat_keyboard_notify_key(server.input.seat, event->time_msec, event->keycode, event->state);
}
}
static
void
+free_keyboard(struct wl_listener *l, void *data)
+{
+ struct wlr_input_device *device = data;
+ Keyboard *keyboard = device->data;
+
+ /*
+ wl_list_remove(&keyboard->link);
+ wl_list_remove(&keyboard->event.modify.link);
+ wl_list_remove(&keyboard->event.press.link);
+ wl_list_remove(&keyboard->event.destroy.link);
+ free(keyboard);
+ */
+}
+
+static
+void
make_keyboard(struct wlr_input_device *device)
{
Keyboard *keyboard;
@@ -83,21 +82,24 @@ make_keyboard(struct wlr_input_device *device)
keymap = xkb_keymap_new_from_names(context, nil, XKB_KEYMAP_COMPILE_NO_FLAGS);
wlr_keyboard_set_keymap(device->keyboard, keymap);
- wlr_keyboard_set_keymap(device->keyboard, keymap);
xkb_keymap_unref(keymap);
xkb_context_unref(context);
- wlr_keyboard_set_repeat_info(device->keyboard, 25, 600);
+ wlr_keyboard_set_repeat_info(device->keyboard, cfg·repeat_rate, cfg·repeat_delay);
keyboard = calloc(1, sizeof(*keyboard));
keyboard->device = device;
keyboard->event.modify.notify = keymodifier;
wl_signal_add(&device->keyboard->events.modifiers, &keyboard->event.modify);
+
keyboard->event.press.notify = keypress;
wl_signal_add(&device->keyboard->events.key, &keyboard->event.press);
+ keyboard->event.destroy.notify = free_keyboard;
+ wl_signal_add(&device->keyboard->events.destroy, &keyboard->event.destroy);
+
wlr_seat_set_keyboard(server.input.seat, device);
wl_list_insert(&server.input.keyboards, &keyboard->link);
}
@@ -147,8 +149,8 @@ cursorresize(uint32 time)
}
wlr_xdg_surface_get_geometry(client->xdg, &box);
- client->x = new_left - box.x;
- client->y = new_top - box.y;
+ client->geo.x = new_left - box.x;
+ client->geo.y = new_top - box.y;
new_width = new_right - new_left;
new_height = new_bottom - new_top;
@@ -172,7 +174,7 @@ docursor(uint32 time)
/* Otherwise, find the client under the pointer and send the event along. */
seat = server.input.seat;
surface = nil;
- client = clientat(server.cursor.dot->x, server.cursor.dot->y, &surface, &sx, &sy);
+ client = client_at(server.cursor.dot->x, server.cursor.dot->y, &surface, &sx, &sy);
if(!client)
wlr_xcursor_manager_set_cursor_image(server.cursor.manager, "left_ptr", server.cursor.dot);
@@ -211,7 +213,7 @@ cursor_button(struct wl_listener *l, void *data)
wlr_seat_pointer_notify_button(server.input.seat,
event->time_msec, event->button, event->state);
- client = clientat(server.cursor.dot->x, server.cursor.dot->y, &surface, &sx, &sy);
+ client = client_at(server.cursor.dot->x, server.cursor.dot->y, &surface, &sx, &sy);
if (event->state == WLR_BUTTON_RELEASED)
server.cursor.mode = CursorPassthrough;
else