aboutsummaryrefslogtreecommitdiff
path: root/harness/src/wl.c
diff options
context:
space:
mode:
Diffstat (limited to 'harness/src/wl.c')
-rw-r--r--harness/src/wl.c48
1 files changed, 38 insertions, 10 deletions
diff --git a/harness/src/wl.c b/harness/src/wl.c
index 0bd0410..f083a5e 100644
--- a/harness/src/wl.c
+++ b/harness/src/wl.c
@@ -105,15 +105,43 @@ static void keyboard_handle_key(struct wl_listener *listener, void *data)
int handled = false;
uint32_t modifiers = wlr_keyboard_get_modifiers(keyboard->wlr_keyboard);
uint32_t codepoint;
- /* 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. */
- if (nsyms > 0) {
- codepoint =
- xkb_state_key_get_utf32(keyboard->wlr_keyboard->xkb_state, keycode);
- plugin_call_update_state(server->plugin, plugin_handle_keybinding,
- keyboard->wlr_keyboard, event, modifiers, syms[0],
- codepoint, &handled);
+ int ec;
+
+ if (nsyms > 0 && syms[0] >= XKB_KEY_XF86Switch_VT_1 &&
+ syms[0] <= XKB_KEY_XF86Switch_VT_12) {
+ /* Escape-hatch to change sessions. These should always be available key
+ * bindings regardless of what the plugin dictates. This allows an escape
+ * hatch to edit the plugin in a different vterm and then use the escape
+ * hatch below to hot-restart the plugin if things get borked. */
+ if (event->state == WL_KEYBOARD_KEY_STATE_PRESSED) {
+ wlr_session_change_vt(server->session,
+ syms[0] - XKB_KEY_XF86Switch_VT_1 + 1);
+ }
+ }
+ else if (modifiers ==
+ (WLR_MODIFIER_SHIFT | WLR_MODIFIER_CTRL | WLR_MODIFIER_ALT) &&
+ nsyms > 0 && syms[0] == XKB_KEY_Escape) {
+ /* Escape-hatch to hot-reload the plugin in case the plugin got borked and
+ * stops accepting keybindings. Ctrl+Shift+Alt+Escape will always reload the
+ * plugin.*/
+ if (event->state == WL_KEYBOARD_KEY_STATE_PRESSED) {
+ if ((ec = plugin_hot_reload_same_state(&server->plugin)) != 0) {
+ fprintf(stderr, "Failed to hot reload plugin");
+ exit(1);
+ }
+ }
+ }
+ else {
+ /* 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. */
+ if (nsyms > 0) {
+ codepoint =
+ xkb_state_key_get_utf32(keyboard->wlr_keyboard->xkb_state, keycode);
+ plugin_call_update_state(server->plugin, plugin_handle_keybinding,
+ keyboard->wlr_keyboard, event, modifiers,
+ syms[0], codepoint, &handled);
+ }
}
}
@@ -806,7 +834,7 @@ int main(int argc, char *argv[])
* output hardware. The autocreate option will choose the most suitable
* backend based on the current environment, such as opening an X11 window
* if an X11 server is running. */
- server.backend = wlr_backend_autocreate(server.wl_display, NULL);
+ server.backend = wlr_backend_autocreate(server.wl_display, &server.session);
if (server.backend == NULL) {
wlr_log(WLR_ERROR, "failed to create wlr_backend");
return 1;