simple-shm: Allow to make simple-shm fullscreen with just the keyboard

Similarly to simple-egl, teach simple-shm to also do that if pressing
F11. Allows testing stuff much easier -- without installing key-bindings
in the shell.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
This commit is contained in:
Marius Vlad 2025-06-02 16:45:11 +03:00 committed by Daniel Stone
parent 6070dd8069
commit 683d7df164

View file

@ -48,6 +48,8 @@
#define MAX_BUFFER_ALLOC 2 #define MAX_BUFFER_ALLOC 2
struct window;
struct format { struct format {
uint32_t code; uint32_t code;
const char *string; const char *string;
@ -66,6 +68,7 @@ struct display {
const struct format *format; const struct format *format;
bool paint_format; bool paint_format;
bool has_format; bool has_format;
struct window *window;
}; };
struct buffer { struct buffer {
@ -295,8 +298,16 @@ keyboard_handle_key(void *data, struct wl_keyboard *keyboard,
uint32_t serial, uint32_t time, uint32_t key, uint32_t serial, uint32_t time, uint32_t key,
uint32_t state) uint32_t state)
{ {
if (key == KEY_ESC && state) struct display *d = data;
if (key == KEY_F11 && state) {
if (d->window->fullscreen)
xdg_toplevel_unset_fullscreen(d->window->xdg_toplevel);
else
xdg_toplevel_set_fullscreen(d->window->xdg_toplevel, NULL);
} else if (key == KEY_ESC && state) {
running = 0; running = 0;
}
} }
static void static void
@ -949,6 +960,7 @@ main(int argc, char **argv)
if (!window) if (!window)
return 1; return 1;
display->window = window;
sigint.sa_handler = signal_int; sigint.sa_handler = signal_int;
sigemptyset(&sigint.sa_mask); sigemptyset(&sigint.sa_mask);
sigint.sa_flags = SA_RESETHAND; sigint.sa_flags = SA_RESETHAND;