mirror of https://github.com/LIJI32/SameBoy.git
Make it possible to disable rounded corners on Windows 11
This commit is contained in:
parent
9c958a1cb4
commit
e2b22a0df6
4
Makefile
4
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
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
49
SDL/gui.c
49
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,}
|
||||
};
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue