suggestion picker: a persistent layer to complement virtual keyboards like wvkbd
| -rw-r--r-- | README.md | 6 | ||||
| -rw-r--r-- | main.c | 31 |
2 files changed, 31 insertions, 6 deletions
@@ -7,11 +7,7 @@ This is derived from wvkbd. ## Interface -Reads from a FIFO, implementing the 'normal strings' mode from fbp. - -* `\f` Clear the list of strings -* `\r` Enable newlines -* `\t` Restore default strings +Each line of input is treated as TSV. ## Install @@ -1,3 +1,4 @@ +#include <poll.h> #include "proto/wlr-layer-shell-unstable-v1-client-protocol.h" #include <stdio.h> #include <stdlib.h> @@ -383,6 +384,18 @@ show(int sigint) { drwsurf_flip(&draw_surf); } +void +handle_input(FILE *fd) { + char *line; + line = malloc(1024); + + if (fgets(line, 1024, fd) != NULL) { + printf("Retrieved line: %s\n", line); + } + + free(line); +} + int main(int argc, char **argv) { /* parse command line arguments */ @@ -494,11 +507,27 @@ main(int argc, char **argv) { signal(SIGUSR1, hide); signal(SIGUSR2, show); + // We need a more complicated event loop than wayland's default. + struct pollfd fds[2]; + fds[0].fd = STDIN_FILENO; + fds[0].events = POLLIN; + fds[1].fd = wl_display_get_fd(display); + fds[1].events = POLLIN; + // Initial dispatch so that bar appears (and can take events). + wl_display_dispatch(display); while (run_display) { - while (wl_display_dispatch(display) != -1 && layer_surface) { + while(layer_surface && poll(fds, 2, -1) != -1) { + if (fds[0].revents & POLLIN) { + handle_input(stdin); + } + if (wl_display_dispatch(display) == -1) { + break; + } + wl_display_flush(display); } wl_display_roundtrip(display); while (run_display && !layer_surface) { + // Hidden sleep(1); } } |