diff --git a/CHANGELOG b/CHANGELOG index faed32a2f2..95ed78f6ec 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,4 +1,6 @@ -Next + - fix off-center and off-screen window after entering the + configuration tool while using TTF output mode (aybe). + - add menu item for centering window "Video/Center window" (aybe). - Fixed update-version-number script to patch all *.iss files, not just the specific one it did before, to ensure future releases have correct version numbers. (joncampbell123). diff --git a/src/gui/menu.cpp b/src/gui/menu.cpp index 1c4c6bf381..2b0780d606 100644 --- a/src/gui/menu.cpp +++ b/src/gui/menu.cpp @@ -525,6 +525,9 @@ static const char *def_menu_video[] = #endif "VideoRatioMenu", "mapper_aspratio", +#if defined(C_SDL2) + "center_window", +#endif #if !defined(C_SDL2) && defined(MACOSX) "highdpienable", #endif diff --git a/src/gui/menu_callback.cpp b/src/gui/menu_callback.cpp index fb77cee1c3..f65c0d3c3b 100644 --- a/src/gui/menu_callback.cpp +++ b/src/gui/menu_callback.cpp @@ -2071,6 +2071,15 @@ bool vsync_set_syncrate_menu_callback(DOSBoxMenu * const menu,DOSBoxMenu::item * return true; } +bool center_window_menu_callback(DOSBoxMenu * const menu,DOSBoxMenu::item * const menuitem) { + (void)menu;//UNUSED + (void)menuitem;//UNUSED +#if defined(C_SDL2) + SDL_SetWindowPosition(sdl.window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED); +#endif + return true; +} + bool set_titletext_menu_callback(DOSBoxMenu * const menu,DOSBoxMenu::item * const menuitem) { (void)menu;//UNUSED (void)menuitem;//UNUSED @@ -3198,6 +3207,11 @@ void AllocCallback1() { set_callback_function(scaler_set_menu_callback); } +#if defined(C_SDL2) + mainMenu.alloc_item(DOSBoxMenu::item_type_id,"center_window").set_text("Center window"). + set_callback_function(center_window_menu_callback); +#endif + mainMenu.alloc_item(DOSBoxMenu::item_type_id,"set_titletext").set_text("Set title bar text..."). set_callback_function(set_titletext_menu_callback); diff --git a/src/output/output_ttf.cpp b/src/output/output_ttf.cpp index 110efdcf3e..a3e6ca6e88 100644 --- a/src/output/output_ttf.cpp +++ b/src/output/output_ttf.cpp @@ -1455,6 +1455,7 @@ void ttf_switch_on(bool ss=true) { #ifdef C_SDL2 transparency = 0; SetWindowTransparency(static_cast(control->GetSection("sdl"))->Get_int("transparency")); + SDL_SetWindowPosition(sdl.window, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED); #endif if (!IS_PC98_ARCH && vga.draw.address_add != ttf.cols * 2) checkcol = ss?2:1; }