Fixes for "rpi" backend in SDL2: Start in Fullscreen mode by default, if not using "x11" backend.

This commit is contained in:
Dimitris Panokostas 2018-02-02 16:16:33 +01:00
parent 324c87a622
commit 43df2906dd
4 changed files with 38 additions and 19 deletions

View file

@ -51,8 +51,8 @@
<ImportGroup Label="PropertySheets" /> <ImportGroup Label="PropertySheets" />
<PropertyGroup Label="UserMacros" /> <PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM'">
<RemoteBuildCommandLine>cd ~/projects/Amiberry-sdl2; make -j3 PLATFORM=rpi3-sdl2</RemoteBuildCommandLine> <RemoteBuildCommandLine>cd ~/projects/Amiberry-sdl2; make -j2 PLATFORM=rpi3-sdl2</RemoteBuildCommandLine>
<RemoteReBuildCommandLine>cd ~/projects/Amiberry-sdl2; make clean; make -j3 PLATFORM=rpi3-sdl2</RemoteReBuildCommandLine> <RemoteReBuildCommandLine>cd ~/projects/Amiberry-sdl2; make clean; make -j2 PLATFORM=rpi3-sdl2</RemoteReBuildCommandLine>
<RemoteCleanCommandLine>cd ~/projects/Amiberry-sdl2; make clean</RemoteCleanCommandLine> <RemoteCleanCommandLine>cd ~/projects/Amiberry-sdl2; make clean</RemoteCleanCommandLine>
<NMakeIncludeSearchPath>C:\SysGCC\raspberry\lib\gcc\arm-linux-gnueabihf\6\include;C:\SysGCC\raspberry\arm-linux-gnueabihf\include\c++\6;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\usr\include;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\usr\include\arm-linux-gnueabihf;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\usr\local\include\SDL2;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\usr\include\SDL2;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\usr\include\libxml2;..\src;..\src\include;..\src\osdep;..\src\archivers;..\src\guisan\include;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\opt\vc\include;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\opt\vc\include\interface\vmcs_host\linux;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\opt\vc\include\interface\vcos\pthreads;$(NMakeIncludeSearchPath)</NMakeIncludeSearchPath> <NMakeIncludeSearchPath>C:\SysGCC\raspberry\lib\gcc\arm-linux-gnueabihf\6\include;C:\SysGCC\raspberry\arm-linux-gnueabihf\include\c++\6;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\usr\include;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\usr\include\arm-linux-gnueabihf;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\usr\local\include\SDL2;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\usr\include\SDL2;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\usr\include\libxml2;..\src;..\src\include;..\src\osdep;..\src\archivers;..\src\guisan\include;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\opt\vc\include;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\opt\vc\include\interface\vmcs_host\linux;C:\SysGCC\raspberry\arm-linux-gnueabihf\sysroot\opt\vc\include\interface\vcos\pthreads;$(NMakeIncludeSearchPath)</NMakeIncludeSearchPath>
<NMakePreprocessorDefinitions>DEBUG;ARMV6T2;USE_ARMNEON;ARMV6_ASSEMBLY;AMIBERRY;CPU_arm;CAPSLOCK_DEBIAN_WORKAROUND;USE_SDL2;_REENTRANT;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions> <NMakePreprocessorDefinitions>DEBUG;ARMV6T2;USE_ARMNEON;ARMV6_ASSEMBLY;AMIBERRY;CPU_arm;CAPSLOCK_DEBIAN_WORKAROUND;USE_SDL2;_REENTRANT;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>

View file

@ -53,6 +53,9 @@ SDL_Surface* screen = nullptr;
#if (defined USE_SDL2) && (defined USE_RENDER_THREAD) #if (defined USE_SDL2) && (defined USE_RENDER_THREAD)
SDL_Thread * renderthread = nullptr; SDL_Thread * renderthread = nullptr;
#endif #endif
#ifdef USE_SDL2
const char* sdl_video_driver;
#endif
#ifdef USE_DISPMANX #ifdef USE_DISPMANX
static unsigned int current_vsync_frame = 0; static unsigned int current_vsync_frame = 0;
@ -304,6 +307,20 @@ int graphics_setup(void)
abort(); abort();
} }
sdl_video_driver = SDL_GetCurrentVideoDriver();
Uint32 sdl_window_mode;
if (strcmp(sdl_video_driver,"x11") == 0)
{
// Only enable Windowed mode if we're running under x11
sdl_window_mode = SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE;
}
else
{
// otherwise go for Fullscreen
sdl_window_mode = SDL_WINDOW_FULLSCREEN_DESKTOP;
}
if (sdlWindow == nullptr) if (sdlWindow == nullptr)
{ {
sdlWindow = SDL_CreateWindow("Amiberry", sdlWindow = SDL_CreateWindow("Amiberry",
@ -311,9 +328,7 @@ int graphics_setup(void)
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
800, 800,
480, 480,
//SDL_WINDOW_FULLSCREEN); sdl_window_mode);
//SDL_WINDOW_FULLSCREEN_DESKTOP);
SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE);
check_error_sdl(sdlWindow == nullptr, "Unable to create window"); check_error_sdl(sdlWindow == nullptr, "Unable to create window");
} }
@ -360,11 +375,11 @@ int graphics_setup(void)
void toggle_fullscreen() void toggle_fullscreen()
{ {
#ifdef USE_SDL2 #ifdef USE_SDL2
Uint32 FullscreenFlag = SDL_WINDOW_FULLSCREEN; const Uint32 fullscreen_flag = SDL_WINDOW_FULLSCREEN_DESKTOP;
if (sdlWindow) if (sdlWindow)
{ {
const bool is_fullscreen = SDL_GetWindowFlags(sdlWindow) & FullscreenFlag; const bool is_fullscreen = SDL_GetWindowFlags(sdlWindow) & fullscreen_flag;
SDL_SetWindowFullscreen(sdlWindow, is_fullscreen ? 0 : FullscreenFlag); SDL_SetWindowFullscreen(sdlWindow, is_fullscreen ? 0 : fullscreen_flag);
SDL_ShowCursor(is_fullscreen); SDL_ShowCursor(is_fullscreen);
} }
#endif #endif
@ -548,14 +563,14 @@ static void open_screen(struct uae_prefs* p)
SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0xFF); SDL_SetRenderDrawColor(renderer, 0, 0, 0, 0xFF);
SDL_RenderClear(renderer); SDL_RenderClear(renderer);
if (sdlWindow) if (sdlWindow && strcmp(sdl_video_driver, "x11") == 0)
{ {
const bool is_fullscreen = SDL_GetWindowFlags(sdlWindow) & SDL_WINDOW_FULLSCREEN; const bool is_fullscreen = SDL_GetWindowFlags(sdlWindow) & SDL_WINDOW_FULLSCREEN_DESKTOP;
if (p->gfx_apmode[0].gfx_fullscreen == GFX_FULLSCREEN) if (p->gfx_apmode[0].gfx_fullscreen == GFX_FULLSCREEN)
{ {
// Switch to Fullscreen mode, if we don't have it already // Switch to Fullscreen mode, if we don't have it already
if (!is_fullscreen) if (!is_fullscreen)
SDL_SetWindowFullscreen(sdlWindow, SDL_WINDOW_FULLSCREEN); SDL_SetWindowFullscreen(sdlWindow, SDL_WINDOW_FULLSCREEN_DESKTOP);
} }
else else
{ {
@ -564,13 +579,14 @@ static void open_screen(struct uae_prefs* p)
SDL_SetWindowFullscreen(sdlWindow, 0); SDL_SetWindowFullscreen(sdlWindow, 0);
} }
if ((SDL_GetWindowFlags(sdlWindow) & SDL_WINDOW_MAXIMIZED) == 0) if (!is_fullscreen)
{ if ((SDL_GetWindowFlags(sdlWindow) & SDL_WINDOW_MAXIMIZED) == 0)
if (screen_is_picasso) {
SDL_SetWindowSize(sdlWindow, display_width, display_height); if (screen_is_picasso)
else SDL_SetWindowSize(sdlWindow, display_width, display_height);
SDL_SetWindowSize(sdlWindow, display_width, display_height * 2 >> p->gfx_vresolution); else
} SDL_SetWindowSize(sdlWindow, display_width, display_height * 2 >> p->gfx_vresolution);
}
} }
screen = SDL_CreateRGBSurface(0, display_width, display_height, 16, 0, 0, 0, 0); screen = SDL_CreateRGBSurface(0, display_width, display_height, 16, 0, 0, 0, 0);

View file

@ -14,6 +14,7 @@ extern SDL_Surface* gui_screen;
#ifdef USE_SDL2 #ifdef USE_SDL2
extern SDL_Texture* gui_texture; extern SDL_Texture* gui_texture;
extern SDL_DisplayMode sdlMode; extern SDL_DisplayMode sdlMode;
extern const char* sdl_video_driver;
#endif #endif
extern bool can_have_linedouble; extern bool can_have_linedouble;

View file

@ -338,8 +338,10 @@ namespace sdl
#else #else
setup_cursor(); setup_cursor();
#endif #endif
if (sdlWindow)
if (sdlWindow && strcmp(sdl_video_driver, "x11") == 0)
{ {
// Only resize the window if we're under x11, otherwise we're fullscreen anyway
if ((SDL_GetWindowFlags(sdlWindow) & SDL_WINDOW_MAXIMIZED) == 0) if ((SDL_GetWindowFlags(sdlWindow) & SDL_WINDOW_MAXIMIZED) == 0)
SDL_SetWindowSize(sdlWindow, GUI_WIDTH, GUI_HEIGHT); SDL_SetWindowSize(sdlWindow, GUI_WIDTH, GUI_HEIGHT);
} }