aboutsummaryrefslogtreecommitdiff
path: root/harness/src
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2024-03-04 01:46:17 -0700
committerJosh Rahm <joshuarahm@gmail.com>2024-03-04 01:46:17 -0700
commit9cd976a21d0c78e6c9291685b4d2efcb6d65a1d7 (patch)
tree12d80e8c31152c4b392e90190aa57134f6dcf06b /harness/src
parent6ebfbf75a551c3cb464b410654249d9a11204c17 (diff)
downloadmontis-9cd976a21d0c78e6c9291685b4d2efcb6d65a1d7.tar.gz
montis-9cd976a21d0c78e6c9291685b4d2efcb6d65a1d7.tar.bz2
montis-9cd976a21d0c78e6c9291685b4d2efcb6d65a1d7.zip
Added a new KeysM monad.
This monad allows keybindings to look and feel like one is writing blocking code with constructs like: key <- nextKey when (key == x) $ do key2 <- nextKey ... ... but this code does not block or do any io shenanigans, it under the hood just changes the handler on the state. It seems pretty awesome and opens the doors for some pretty expressive key bindings.
Diffstat (limited to 'harness/src')
-rw-r--r--harness/src/wl.c34
1 files changed, 3 insertions, 31 deletions
diff --git a/harness/src/wl.c b/harness/src/wl.c
index 1535c6d..0bd0410 100644
--- a/harness/src/wl.c
+++ b/harness/src/wl.c
@@ -87,34 +87,6 @@ static void keyboard_handle_modifiers(struct wl_listener *listener, void *data)
&keyboard->wlr_keyboard->modifiers);
}
-static bool handle_keybinding(struct tinywl_server *server, xkb_keysym_t 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.
- */
- switch (sym) {
- case XKB_KEY_Escape:
- wl_display_terminate(server->wl_display);
- break;
- case XKB_KEY_F1:
- /* Cycle to the next toplevel */
- if (wl_list_length(&server->toplevels) < 2) {
- break;
- }
- struct tinywl_toplevel *next_toplevel =
- wl_container_of(server->toplevels.prev, next_toplevel, link);
- focus_toplevel(next_toplevel, next_toplevel->xdg_toplevel->base->surface);
- 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. */
@@ -609,7 +581,7 @@ static void xdg_toplevel_map(struct wl_listener *listener, void *data)
wl_list_insert(&toplevel->server->toplevels, &toplevel->link);
plugin_call_update_state(toplevel->server->plugin, plugin_handle_surface,
- data, SURFACE_MAP);
+ toplevel, SURFACE_MAP);
focus_toplevel(toplevel, toplevel->xdg_toplevel->base->surface);
}
@@ -625,7 +597,7 @@ static void xdg_toplevel_unmap(struct wl_listener *listener, void *data)
}
plugin_call_update_state(toplevel->server->plugin, plugin_handle_surface,
- data, SURFACE_UNMAP);
+ toplevel, SURFACE_UNMAP);
wl_list_remove(&toplevel->link);
}
@@ -645,7 +617,7 @@ static void xdg_toplevel_destroy(struct wl_listener *listener, void *data)
wl_list_remove(&toplevel->request_fullscreen.link);
plugin_call_update_state(toplevel->server->plugin, plugin_handle_surface,
- data, SURFACE_DELETE);
+ toplevel, SURFACE_DELETE);
free(toplevel);
}