From d97fa9e8b873eaa2f740ab4f9abcf86bd6087079 Mon Sep 17 00:00:00 2001 From: neauoire Date: Wed, 25 Oct 2023 14:16:23 -0700 Subject: [PATCH] Added F12 to toggle borderless --- README.md | 1 + src/uxnemu.c | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a3fc6d5..0cc431f 100644 --- a/README.md +++ b/README.md @@ -101,6 +101,7 @@ uxnemu orca.rom | shim - `F4` reboot - `F5` soft reboot - `F11` toggle fullscreen +- `F12` toggle decorations ### GUI Buttons diff --git a/src/uxnemu.c b/src/uxnemu.c index 4e58c93..bc8f6be 100644 --- a/src/uxnemu.c +++ b/src/uxnemu.c @@ -56,7 +56,7 @@ static SDL_Thread *stdin_thread; /* devices */ static int window_created = 0; -static int fullscreen = 0; +static int fullscreen = 0, borderless = 0; static Uint32 stdin_event, audio0_event, zoom = 1; static Uint64 exec_deadline, deadline_interval, ms_interval; @@ -189,9 +189,9 @@ set_zoom(Uint8 z, int win) } static void -set_fullscreen(int new_fullscreen, int win) +set_fullscreen(int value, int win) { - fullscreen = new_fullscreen; + fullscreen = value; Uint32 flags = 0; /* windowed mode; SDL2 has no constant for this */ if(fullscreen) { flags = SDL_WINDOW_FULLSCREEN_DESKTOP; @@ -200,6 +200,13 @@ set_fullscreen(int new_fullscreen, int win) SDL_SetWindowFullscreen(emu_window, flags); } +static void +set_borderless(int value) +{ + borderless = value; + SDL_SetWindowBordered(emu_window, !value); +} + /* emulator primitives */ int @@ -405,6 +412,8 @@ handle_events(Uxn *u) emu_restart(u, boot_rom, 1); else if(event.key.keysym.sym == SDLK_F11) set_fullscreen(!fullscreen, 1); + else if(event.key.keysym.sym == SDLK_F12) + set_borderless(!borderless); ksym = event.key.keysym.sym; if(SDL_PeepEvents(&event, 1, SDL_PEEKEVENT, SDL_KEYUP, SDL_KEYUP) == 1 && ksym == event.key.keysym.sym) return 1;