Index: dataobj/environment.cc =================================================================== --- dataobj/environment.cc (revisión: 10142) +++ dataobj/environment.cc (copia de trabajo) @@ -17,6 +17,7 @@ void rdwr_win_settings(loadsave_t *file); // simwin sint16 env_t::menupos = MENU_TOP; +int env_t::fullscreen = WINDOWED; bool env_t::reselect_closes_tool = true; sint8 env_t::pak_tile_height_step = 16; @@ -559,6 +560,8 @@ file->rdwr_bool( single_line_gui ); file->rdwr_byte( show_factory_storage_bar ); + + file->rdwr_long( fullscreen ); } // server settings are not saved, since they are server specific Index: dataobj/environment.h =================================================================== --- dataobj/environment.h (revisión: 10142) +++ dataobj/environment.h (copia de trabajo) @@ -37,6 +37,8 @@ static sint16 menupos; + static int fullscreen; + static bool reselect_closes_tool; /// points to the current user directory for loading and saving Index: dataobj/settings.cc =================================================================== --- dataobj/settings.cc (revisión: 10142) +++ dataobj/settings.cc (copia de trabajo) @@ -928,7 +928,7 @@ // read the settings from this file -void settings_t::parse_simuconf( tabfile_t& simuconf, sint16& disp_width, sint16& disp_height, bool &fullscreen, std::string& objfilename ) +void settings_t::parse_simuconf( tabfile_t& simuconf, sint16& disp_width, sint16& disp_height, int &fullscreen, std::string& objfilename ) { tabfileobj_t contents; @@ -1573,7 +1573,7 @@ */ disp_width = contents.get_int_clamped("display_width", disp_width, 0, 0x7FFF ); disp_height = contents.get_int_clamped("display_height", disp_height, 0, 0x7FFF ); - fullscreen = contents.get_int("fullscreen", fullscreen ) != 0; + fullscreen = contents.get_int("fullscreen", fullscreen ); with_private_paks = contents.get_int("with_private_paks", with_private_paks)!=0; Index: dataobj/settings.h =================================================================== --- dataobj/settings.h (revisión: 10142) +++ dataobj/settings.h (copia de trabajo) @@ -387,12 +387,12 @@ void copy_city_road(settings_t const& other); // init from this file ... - void parse_simuconf(tabfile_t& simuconf, sint16& disp_width, sint16& disp_height, bool& fullscreen, std::string& objfilename); + void parse_simuconf(tabfile_t& simuconf, sint16& disp_width, sint16& disp_height, int& fullscreen, std::string& objfilename); // init without screen parameters ... void parse_simuconf(tabfile_t& simuconf) { sint16 idummy = 0; - bool bdummy = false; + int bdummy = 0; std::string sdummy; parse_simuconf(simuconf, idummy, idummy, bdummy, sdummy); Index: display/simgraph.h =================================================================== --- display/simgraph.h (revisión: 10142) +++ display/simgraph.h (copia de trabajo) @@ -128,7 +128,7 @@ /** * Initialises the graphics module */ -bool simgraph_init(scr_size window_size, bool fullscreen); +bool simgraph_init(scr_size window_size, int fullscreen); bool is_display_init(); void simgraph_exit(); void simgraph_resize(scr_size new_window_size); Index: display/simgraph0.cc =================================================================== --- display/simgraph0.cc (revisión: 10142) +++ display/simgraph0.cc (copia de trabajo) @@ -341,7 +341,7 @@ { } -bool simgraph_init(scr_size, bool) +bool simgraph_init(scr_size, int) { return true; } Index: display/simgraph16.cc =================================================================== --- display/simgraph16.cc (revisión: 10142) +++ display/simgraph16.cc (copia de trabajo) @@ -5304,7 +5304,7 @@ /** * Initialises the graphics module */ -bool simgraph_init(scr_size window_size, bool full_screen) +bool simgraph_init(scr_size window_size, int full_screen) { disp_actual_width = window_size.w; disp_height = window_size.h; Index: gui/display_settings.cc =================================================================== --- gui/display_settings.cc (revisión: 10142) +++ gui/display_settings.cc (copia de trabajo) @@ -18,6 +18,7 @@ #include "../simmenu.h" #include "../player/simplay.h" #include "../utils/simstring.h" +#include "../sys/simsys.h" #include "gui_theme.h" #include "themeselector.h" @@ -104,6 +105,15 @@ } add_component(&toolbar_pos); + fullscreen.init( button_t::square_state, "Fullscreen (needs restart)" ); + fullscreen.pressed = ( get_fullscreen() == FULLSCREEN ); + add_component( &fullscreen, 2 ); + + borderless.init( button_t::square_state, "Borderless (disabled on fullscreen)" ); + borderless.enable ( get_fullscreen() != FULLSCREEN ); + borderless.pressed = ( get_fullscreen() == BORDERLESS ); + add_component( &borderless, 2 ); + reselect_closes_tool.init( button_t::square_state, "Reselect closes tools" ); reselect_closes_tool.pressed = env_t::reselect_closes_tool; add_component( &reselect_closes_tool, 2 ); @@ -498,6 +508,8 @@ buttons[ i ].add_listener( this ); } gui_settings.toolbar_pos.add_listener( this ); + gui_settings.fullscreen.add_listener( this ); + gui_settings.borderless.add_listener( this ); gui_settings.reselect_closes_tool.add_listener(this); set_resizemode(diagonal_resize); @@ -528,6 +540,23 @@ return true; } + if( comp == &gui_settings.fullscreen ) { + if ( get_fullscreen() == BORDERLESS ) { + toggle_borderless(); + } + env_t::fullscreen = gui_settings.fullscreen.pressed ? WINDOWED : FULLSCREEN; + gui_settings.fullscreen.pressed = !gui_settings.fullscreen.pressed; + gui_settings.borderless.pressed = false; + return true; + } + + if( comp == &gui_settings.borderless ) { + env_t::fullscreen = toggle_borderless(); + gui_settings.borderless.pressed = ( get_fullscreen() == BORDERLESS ); + gui_settings.fullscreen.pressed = false; + return true; + } + if( comp == &gui_settings.reselect_closes_tool ) { env_t::reselect_closes_tool = !env_t::reselect_closes_tool; gui_settings.reselect_closes_tool.pressed = env_t::reselect_closes_tool; Index: gui/display_settings.h =================================================================== --- gui/display_settings.h (revisión: 10142) +++ gui/display_settings.h (copia de trabajo) @@ -29,7 +29,7 @@ simloops_value_label; public: - button_t toolbar_pos, reselect_closes_tool; + button_t toolbar_pos, reselect_closes_tool, fullscreen, borderless; gui_settings_t(); void draw( scr_coord offset ) OVERRIDE; Index: simmain.cc =================================================================== --- simmain.cc (revisión: 10142) +++ simmain.cc (copia de trabajo) @@ -487,6 +487,7 @@ " -easyserver set up every for server (query own IP, port forwarding)\n" " -freeplay play with endless money\n" " -fullscreen starts simutrans in fullscreen mode\n" + " -borderless starts simutrans in borderless fullscreen mode\n" " -fps COUNT framerate (from 5 to 100)\n" " -h | -help | --help displays this help\n" " -lang CODE starts with specified language\n" @@ -730,7 +731,7 @@ sint16 disp_width = 0; sint16 disp_height = 0; - bool fullscreen = false; + int fullscreen = WINDOWED; // continue parsing dr_chdir( env_t::data_dir ); @@ -888,7 +889,15 @@ } } - fullscreen |= args.has_arg("-fullscreen"); + if ( !fullscreen ) { + fullscreen = args.has_arg("-fullscreen") ? FULLSCREEN : WINDOWED; + } + if ( !fullscreen ) { + fullscreen = args.has_arg("-borderless") ? BORDERLESS : WINDOWED; + } + if ( !fullscreen ) { + fullscreen = env_t::fullscreen; + } if(args.has_arg("-screensize")) { const char* res_str = args.gimme_arg("-screensize", 1); @@ -933,8 +942,8 @@ } } - DBG_MESSAGE("simu_main()", "simgraph_init disp_width=%d, disp_height=%d, fullscreen=%d", disp_width, disp_height, (int)fullscreen); - if (!simgraph_init(scr_size(disp_width, disp_height), fullscreen != 0)) { + DBG_MESSAGE("simu_main()", "simgraph_init disp_width=%d, disp_height=%d, fullscreen=%d", disp_width, disp_height, fullscreen); + if (!simgraph_init(scr_size(disp_width, disp_height), fullscreen)) { dbg->error("simu_main()", "Failed to initialize graphics system."); return EXIT_FAILURE; } Index: simutrans/config/simuconf.tab =================================================================== --- simutrans/config/simuconf.tab (revisión: 10142) +++ simutrans/config/simuconf.tab (copia de trabajo) @@ -654,6 +654,9 @@ #display_height = 560 # show full screen +# 0: disable fullscreen +# 1: enable fullscreen +# 2: enable borderless fullscreen #fullscreen = 0 # How many frames per second to use? Display may look pretty until 10 or so Index: sys/simsys.h =================================================================== --- sys/simsys.h (revisión: 10142) +++ sys/simsys.h (copia de trabajo) @@ -65,6 +65,8 @@ unsigned int key_mod; /* key mod, like ALT, CTRL, SHIFT */ }; +enum { WINDOWED, FULLSCREEN, BORDERLESS }; + extern sys_event_t sys_event; extern char const PATH_SEPARATOR[]; @@ -82,7 +84,7 @@ }; resolution dr_query_screen_resolution(); -int dr_os_open(int w, int h, bool fullscreen); +int dr_os_open(int w, int h, int fullscreen); void dr_os_close(); // returns the locale; NULL if unknown @@ -216,6 +218,20 @@ /// returns current two byte languange ID const char* dr_get_locale(); +/** + * @return + * 0: if windowed + * 1: if fullscreen + * 2: if borderless fullscreen + */ +int get_fullscreen(); + +/** + * Toggle between borderless and windowed mode + * @return the fullscreen state after the toggle + */ +int toggle_borderless(); + int sysmain(int argc, char** argv); #endif Index: sys/simsys_d.cc =================================================================== --- sys/simsys_d.cc (revisión: 10142) +++ sys/simsys_d.cc (copia de trabajo) @@ -23,6 +23,7 @@ static int width = 800; static int height = 600; +static int fullscreen = WINDOWED; /* event-handling */ @@ -223,10 +224,11 @@ } -int dr_os_open(int const w, int const h, bool fullscreen) +int dr_os_open(int const w, int const h, int fs) { width = w; height = h; + fullscreen = fs; install_keyboard(); @@ -470,7 +472,16 @@ return ""; } +int get_fullscreen() +{ + return fullscreen; +} +int toggle_borderless() +{ + return fullscreen; +} + int main(int argc, char **argv) { return sysmain(argc, argv); Index: sys/simsys_posix.cc =================================================================== --- sys/simsys_posix.cc (revisión: 10142) +++ sys/simsys_posix.cc (copia de trabajo) @@ -50,7 +50,7 @@ } // open the window -int dr_os_open(int, int, bool) +int dr_os_open(int, int, int) { return 1; } @@ -186,7 +186,16 @@ return ""; } +int get_fullscreen() +{ + return 0; +} +int toggle_borderless() +{ + return 0; +} + int main(int argc, char **argv) { signal( SIGTERM, posix_sigterm ); Index: sys/simsys_s.cc =================================================================== --- sys/simsys_s.cc (revisión: 10142) +++ sys/simsys_s.cc (copia de trabajo) @@ -78,6 +78,7 @@ static SDL_Surface *screen; static int width = 16; static int height = 16; +static int fullscreen = WINDOWED; // switch on is a little faster (<3%) static int async_blit = 0; @@ -236,7 +237,7 @@ // open the window -int dr_os_open(int w, int const h, bool fullscreen) +int dr_os_open(int w, int const h, int fs) { #ifdef MULTI_THREAD // init barrier @@ -269,6 +270,7 @@ width = w; height = h; + fullscreen = fs; flags |= (fullscreen ? SDL_FULLSCREEN : SDL_RESIZABLE); if( use_hw ) { @@ -739,6 +741,16 @@ return NULL; } +int get_fullscreen() +{ + return fullscreen; +} + +int toggle_borderless() +{ + return fullscreen; +} + #ifdef _MSC_VER // Needed for MS Visual C++ with /SUBSYSTEM:CONSOLE to work , if /SUBSYSTEM:WINDOWS this function is compiled but unreachable #undef main Index: sys/simsys_s2.cc =================================================================== --- sys/simsys_s2.cc (revisión: 10142) +++ sys/simsys_s2.cc (copia de trabajo) @@ -105,6 +105,7 @@ static int sync_blit = 0; static int use_dirty_tiles = 1; +static int fullscreen = WINDOWED; static SDL_Cursor *arrow; static SDL_Cursor *hourglass; @@ -296,17 +297,20 @@ // open the window -int dr_os_open(int screen_width, int screen_height, bool fullscreen) +int dr_os_open(int screen_width, int screen_height, int fs) { // scale up const int tex_w = SCREEN_TO_TEX_X(screen_width); const int tex_h = SCREEN_TO_TEX_Y(screen_height); + fullscreen = fs; + // some cards need those alignments // especially 64bit want a border of 8bytes const int tex_pitch = max((tex_w + 15) & 0x7FF0, 16); - Uint32 flags = fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP: SDL_WINDOW_RESIZABLE; + // SDL2 only works with borderless fullscreen (SDL_WINDOW_FULLSCREEN_DESKTOP) + Uint32 flags = fullscreen ? SDL_WINDOW_FULLSCREEN_DESKTOP : SDL_WINDOW_RESIZABLE; flags |= SDL_WINDOW_ALLOW_HIGHDPI; // apparently needed for Apple retina displays window = SDL_CreateWindow( SIM_TITLE, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, screen_width, screen_height, flags ); @@ -938,7 +942,23 @@ return NULL; } +int get_fullscreen() +{ + return fullscreen; +} +int toggle_borderless() +{ + if ( fullscreen == BORDERLESS ) { + SDL_SetWindowFullscreen(window, 0); + fullscreen = WINDOWED; + } else { + SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP); + fullscreen = BORDERLESS; + } + return fullscreen; +} + #ifdef _MSC_VER // Needed for MS Visual C++ with /SUBSYSTEM:CONSOLE to work , if /SUBSYSTEM:WINDOWS this function is compiled but unreachable #undef main Index: sys/simsys_w.cc =================================================================== --- sys/simsys_w.cc (revisión: 10142) +++ sys/simsys_w.cc (copia de trabajo) @@ -53,7 +53,7 @@ static const LPCWSTR WINDOW_CLASS_NAME = L"Simu"; static volatile HWND hwnd; -static bool is_fullscreen = false; +static int fullscreen = WINDOWED; static bool is_not_top = false; static MSG msg; static RECT WindowSize = { 0, 0, 0, 0 }; @@ -145,10 +145,11 @@ // open the window -int dr_os_open(int const w, int const h, bool fullscreen) +int dr_os_open(int const w, int const h, int fs) { MaxSize.right = ((w*x_scale)/32+15) & 0x7FF0; MaxSize.bottom = (h*y_scale)/32; + fullscreen = fs; #ifdef MULTI_THREAD InitializeCriticalSection( &redraw_underway ); @@ -156,7 +157,7 @@ #endif // fake fullscreen - if (fullscreen) { + if ( fullscreen ) { // try to force display mode and size DEVMODE settings; @@ -177,14 +178,13 @@ } if( ChangeDisplaySettings(&settings, CDS_TEST)!=DISP_CHANGE_SUCCESSFUL ) { ChangeDisplaySettings( NULL, 0 ); - fullscreen = false; + fullscreen = WINDOWED; } else { ChangeDisplaySettings(&settings, CDS_FULLSCREEN); } - is_fullscreen = fullscreen; } - if( fullscreen ) { + if( fullscreen ) { create_window(WS_EX_TOPMOST, WS_POPUP, 0, 0, MaxSize.right, MaxSize.bottom); } else { @@ -239,7 +239,7 @@ AllDibData = NULL; free(AllDib); AllDib = NULL; - if( is_fullscreen ) { + if( fullscreen == FULLSCREEN ) { ChangeDisplaySettings(NULL, 0); } } @@ -426,7 +426,7 @@ return 0; case WM_ACTIVATE: // may check, if we have to restore color depth - if(is_fullscreen) { + if(fullscreen) { // avoid double calls static bool while_handling = false; if(while_handling) { @@ -479,7 +479,7 @@ break; case WM_GETMINMAXINFO: - if(is_fullscreen) { + if(fullscreen) { LPMINMAXINFO lpmmi = (LPMINMAXINFO) lParam; lpmmi->ptMaxPosition.x = 0; lpmmi->ptMaxPosition.y = 0; @@ -974,7 +974,16 @@ return LanguageCode; } +int get_fullscreen() +{ + return fullscreen; +} +int toggle_borderless() +{ + return fullscreen; +} + int CALLBACK WinMain(HINSTANCE const hInstance, HINSTANCE, LPSTR, int) { WNDCLASSW wc;