diff options
Diffstat (limited to 'harness/src/wl.c')
-rw-r--r-- | harness/src/wl.c | 59 |
1 files changed, 9 insertions, 50 deletions
diff --git a/harness/src/wl.c b/harness/src/wl.c index d01797c..3f00e06 100644 --- a/harness/src/wl.c +++ b/harness/src/wl.c @@ -171,44 +171,6 @@ static void keyboard_handle_modifiers(struct wl_listener *listener, void *data) &keyboard->device->keyboard->modifiers); } -static bool handle_keybinding(struct tinywl_server *server, xkb_keysym_t sym) -{ - plugin_call_update_state(server->plugin, plugin_handle_keybinding, sym); - /* - * Here we handle compositor keybindings. This is when the compositor is - * processing keys, rather than passing them on to the client for its own - * processing. - * - * This function assumes Alt is held down. - */ - dlhandle_t new_handle; - switch (sym) { - case XKB_KEY_Escape: - wl_display_terminate(server->wl_display); - break; - case XKB_KEY_F5: - plugin_hot_reload_same_state(&server->plugin); - break; - case XKB_KEY_F1: - /* Cycle to the next view */ - if (wl_list_length(&server->views) < 2) { - break; - } - struct tinywl_view *current_view = - wl_container_of(server->views.next, current_view, link); - struct tinywl_view *next_view = - wl_container_of(current_view->link.next, next_view, link); - focus_view(next_view, next_view->xdg_surface->surface); - /* Move the previous view to the end of the list */ - wl_list_remove(¤t_view->link); - wl_list_insert(server->views.prev, ¤t_view->link); - break; - default: - return false; - } - return true; -} - static void keyboard_handle_key(struct wl_listener *listener, void *data) { /* This event is raised when a key is pressed or released. */ @@ -223,17 +185,13 @@ static void keyboard_handle_key(struct wl_listener *listener, void *data) const xkb_keysym_t *syms; int nsyms = xkb_state_key_get_syms(keyboard->device->keyboard->xkb_state, keycode, &syms); - - bool handled = false; uint32_t modifiers = wlr_keyboard_get_modifiers(keyboard->device->keyboard); - if ((modifiers & WLR_MODIFIER_ALT) && - event->state == WL_KEYBOARD_KEY_STATE_PRESSED) { - /* If alt is held down and this button was _pressed_, we attempt to - * process it as a compositor keybinding. */ - for (int i = 0; i < nsyms; i++) { - handled = handle_keybinding(server, syms[i]); - } - } + /* Pass the information along to the plugin for the plugin to handle. The + * plugin will return via 'handled' whether or not the key event was handled + * or not. */ + int handled = 0; + plugin_call_update_state(server->plugin, plugin_handle_keybinding, event, + modifiers, syms[0], &handled); if (!handled) { /* Otherwise, we pass it along to the client. */ @@ -1043,8 +1001,9 @@ int main(int argc, char *argv[]) setenv("DISPLAY", xwayland->display_name, 1); } else { - fprintf(stderr, - "======= failed to setup XWayland X server. Continuing without it.\n"); + fprintf( + stderr, + "======= failed to setup XWayland X server. Continuing without it.\n"); } /* Set the WAYLAND_DISPLAY environment variable to our socket and run the |