SameBoy | Accurate GB/GBC emulator |
| download: https://git.y1.nz/archives/sameboy.tar.gz | |
| README | Files | Log | Refs | LICENSE |
commit e2b22a0df6b9e99accb26069a233aed31baa9694 parent 9c958a1cb46b7b0ba9e5fc4e2533d08fc7d40320 Author: Lior Halphon <LIJI32@gmail.com> Date: Sun, 23 Mar 2025 21:34:05 +0200 Make it possible to disable rounded corners on Windows 11 Diffstat:
| M | Makefile | 4 | ++-- |
| M | SDL/configuration.h | 3 | +++ |
| M | SDL/gui.c | 49 | +++++++++++++++++++++++++++++++++++++++++++++++++ |
| M | SDL/gui.h | 4 | ++++ |
| M | SDL/main.c | 4 | ++++ |
5 files changed, 62 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile @@ -272,7 +272,7 @@ endif ifeq ($(PLATFORM),windows32) CFLAGS += -IWindows -Drandom=rand --target=x86_64-pc-windows -LDFLAGS += -lmsvcrt -lcomdlg32 -luser32 -lshell32 -lole32 -ladvapi32 -lSDL2main -Wl,/MANIFESTFILE:NUL --target=x86_64-pc-windows +LDFLAGS += -lmsvcrt -lkernel32 -lcomdlg32 -luser32 -lshell32 -lole32 -ladvapi32 -ldwmapi -lSDL2main -Wl,/MANIFESTFILE:NUL --target=x86_64-pc-windows -v SDL_LDFLAGS := -lSDL2 GL_LDFLAGS := -lopengl32 @@ -692,7 +692,7 @@ ifeq ($(CONF), release) $(CODESIGN) $@ endif -$(BIN)/tester/sameboy_tester.exe: $(CORE_OBJECTS) $(SDL_OBJECTS) +$(BIN)/tester/sameboy_tester.exe: $(CORE_OBJECTS) -@$(MKDIR) -p $(dir $@) $(CC) $^ -o $@ $(LDFLAGS) -Wl,/subsystem:console diff --git a/SDL/configuration.h b/SDL/configuration.h @@ -157,6 +157,9 @@ typedef struct { /* v1.0 */ bool windows_associations_prompted; // Windows only + + /* v1.0.1 */ + bool disable_rounded_corners; // Windows only }; } configuration_t; diff --git a/SDL/gui.c b/SDL/gui.c @@ -13,7 +13,9 @@ #include "audio/audio.h" #ifdef _WIN32 +#include <dwmapi.h> #include <associations.h> +#include <SDL_syswm.h> #endif static const SDL_Color gui_palette[4] = {{8, 24, 16,}, {57, 97, 57,}, {132, 165, 99}, {198, 222, 140}}; @@ -1591,6 +1593,50 @@ static const char *current_osd_mode(unsigned index) return configuration.osd? "Enabled" : "Disabled"; } +#ifdef _WIN32 + +// Don't use the standard header definitions because we might not have the newest headers +typedef enum { + DWM_CORNER_DEFAULT = 0, + DWM_CORNER_SQUARE = 1, + DWM_CORNER_ROUND = 2, + DWM_CORNER_ROUNDSMALL = 3 +} DMW_corner_settings_t; + +#define DWM_CORNER_PREFERENCE 33 + +void configure_window_corners(void) +{ + SDL_SysWMinfo wmInfo; + SDL_VERSION(&wmInfo.version); + SDL_GetWindowWMInfo(window, &wmInfo); + HWND hwnd = wmInfo.info.win.window; + DMW_corner_settings_t pref = configuration.disable_rounded_corners? DWM_CORNER_SQUARE : DWM_CORNER_DEFAULT; + DwmSetWindowAttribute(hwnd, DWM_CORNER_PREFERENCE, &pref, sizeof(pref)); +} + +static void toggle_corners(unsigned index) +{ + configuration.disable_rounded_corners = !configuration.disable_rounded_corners; + configure_window_corners(); +} + +static const char *current_corner_mode(unsigned index) +{ + SDL_SysWMinfo wmInfo; + SDL_VERSION(&wmInfo.version); + SDL_GetWindowWMInfo(window, &wmInfo); + HWND hwnd = wmInfo.info.win.window; + DMW_corner_settings_t pref; + + if (DwmGetWindowAttribute(hwnd, DWM_CORNER_PREFERENCE, &pref, sizeof(pref)) || + pref == DWM_CORNER_SQUARE) { + return "Square"; + } + return "Rounded"; +} +#endif + static const struct menu_item graphics_menu[] = { {"Scaling Mode:", cycle_scaling, current_scaling_mode, cycle_scaling_backwards}, {"Default Window Scale:", cycle_default_scale, current_default_scale, cycle_default_scale_backwards}, @@ -1601,6 +1647,9 @@ static const struct menu_item graphics_menu[] = { {"Mono Palette:", cycle_palette, current_palette, cycle_palette_backwards}, {"Display Border:", cycle_border_mode, current_border_mode, cycle_border_mode_backwards}, {"On-Screen Display:", toggle_osd, current_osd_mode, toggle_osd}, +#ifdef _WIN32 + {"Window Corners:", toggle_corners, current_corner_mode, toggle_corners}, +#endif {"Back", enter_options_menu}, {NULL,} }; diff --git a/SDL/gui.h b/SDL/gui.h @@ -67,3 +67,7 @@ extern unsigned osd_text_lines; void convert_mouse_coordinates(signed *x, signed *y); const GB_palette_t *current_dmg_palette(void); void update_swap_interval(void); + +#ifdef _WIN32 +void configure_window_corners(void); +#endif diff --git a/SDL/main.c b/SDL/main.c @@ -1221,6 +1221,10 @@ int main(int argc, char **argv) if (fullscreen) { SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP); } + +#ifdef _WIN32 + configure_window_corners(); +#endif gl_context = nogl? NULL : SDL_GL_CreateContext(window);
This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.