diff --git a/config.def.h b/config.def.h index 9fc13e5e56..b7210565e8 100644 --- a/config.def.h +++ b/config.def.h @@ -155,7 +155,8 @@ static const float xscale = 3.0; // Real x res = aspect * base_size * xscale static const float yscale = 3.0; // Real y res = base_size * yscale // Fullscreen -static const bool fullscreen = false; // To start in Fullscreen or not +static const bool fullscreen = false; // To start in Fullscreen or not. +static const bool windowed_fullscreen = false; // To use windowed mode or not when going fullscreen. static const unsigned fullscreen_x = 0; // Fullscreen resolution. A value of 0 uses the desktop resolution. static const unsigned fullscreen_y = 0; diff --git a/general.h b/general.h index 63db4e97c8..a4c38cec3c 100644 --- a/general.h +++ b/general.h @@ -82,6 +82,7 @@ struct settings float xscale; float yscale; bool fullscreen; + bool windowed_fullscreen; unsigned fullscreen_x; unsigned fullscreen_y; bool vsync; diff --git a/gfx/context/glx_ctx.c b/gfx/context/glx_ctx.c index b0b56fbca8..a8a0dd68a3 100644 --- a/gfx/context/glx_ctx.c +++ b/gfx/context/glx_ctx.c @@ -236,6 +236,9 @@ static bool gfx_ctx_set_video_mode( sigaction(SIGINT, &sa, NULL); sigaction(SIGTERM, &sa, NULL); + bool windowed_full = g_settings.video.windowed_fullscreen; + bool true_full = false; + XSetWindowAttributes swa = {0}; XVisualInfo *vi = glXGetVisualFromFBConfig(g_dpy, g_fbc); @@ -247,22 +250,25 @@ static bool gfx_ctx_set_video_mode( swa.event_mask = StructureNotifyMask; swa.override_redirect = fullscreen ? True : False; - if (fullscreen) + if (fullscreen && !windowed_full) { if (x11_enter_fullscreen(g_dpy, width, height, &g_desktop_mode)) + { g_should_reset_mode = true; + true_full = true; + } } g_win = XCreateWindow(g_dpy, RootWindow(g_dpy, vi->screen), 0, 0, width ? width : 200, height ? height : 200, 0, vi->depth, InputOutput, vi->visual, - CWBorderPixel | CWColormap | CWEventMask | (fullscreen && g_should_reset_mode ? CWOverrideRedirect : 0), &swa); + CWBorderPixel | CWColormap | CWEventMask | (true_full ? CWOverrideRedirect : 0), &swa); XSetWindowBackground(g_dpy, g_win, 0); gfx_ctx_update_window_title(true); x11_hide_mouse(g_dpy, g_win); - if (fullscreen && g_should_reset_mode) + if (true_full) { XMapRaised(g_dpy, g_win); XGrabKeyboard(g_dpy, g_win, True, GrabModeAsync, GrabModeAsync, CurrentTime); @@ -270,7 +276,7 @@ static bool gfx_ctx_set_video_mode( else if (fullscreen) // We attempted true fullscreen, but failed. Attempt using windowed fullscreen. { XMapRaised(g_dpy, g_win); - RARCH_WARN("[GLX]: True fullscreen failed. Attempt using windowed fullscreen instead.\n"); + RARCH_WARN("[GLX]: Using windowed fullscreen.\n"); x11_windowed_fullscreen(g_dpy, g_win); } else diff --git a/gfx/context/xegl_ctx.c b/gfx/context/xegl_ctx.c index 9d122a2ae5..79c8c1865e 100644 --- a/gfx/context/xegl_ctx.c +++ b/gfx/context/xegl_ctx.c @@ -259,6 +259,8 @@ static bool gfx_ctx_set_video_mode( XVisualInfo temp = {0}; XSetWindowAttributes swa = {0}; XVisualInfo *vi = NULL; + bool windowed_full = g_settings.video.windowed_fullscreen; + bool true_full = false; EGLint vid; if (!eglGetConfigAttrib(g_egl_dpy, g_config, EGL_NATIVE_VISUAL_ID, &vid)) @@ -276,16 +278,19 @@ static bool gfx_ctx_set_video_mode( swa.event_mask = StructureNotifyMask; swa.override_redirect = fullscreen ? True : False; - if (fullscreen) + if (fullscreen && !windowed_full) { if (x11_enter_fullscreen(g_dpy, width, height, &g_desktop_mode)) + { g_should_reset_mode = true; + true_full = true; + } } g_win = XCreateWindow(g_dpy, RootWindow(g_dpy, vi->screen), 0, 0, width ? width : 200, height ? height : 200, 0, vi->depth, InputOutput, vi->visual, - CWBorderPixel | CWColormap | CWEventMask | (fullscreen && g_should_reset_mode ? CWOverrideRedirect : 0), &swa); + CWBorderPixel | CWColormap | CWEventMask | (fullscreen && true_full ? CWOverrideRedirect : 0), &swa); XSetWindowBackground(g_dpy, g_win, 0); // GLES 2.0. Don't use for any other API. @@ -310,7 +315,7 @@ static bool gfx_ctx_set_video_mode( gfx_ctx_update_window_title(true); x11_hide_mouse(g_dpy, g_win); - if (fullscreen && g_should_reset_mode) + if (true_full) { XMapRaised(g_dpy, g_win); XGrabKeyboard(g_dpy, g_win, True, GrabModeAsync, GrabModeAsync, CurrentTime); @@ -318,7 +323,7 @@ static bool gfx_ctx_set_video_mode( else if (fullscreen) // We attempted true fullscreen, but failed. Attempt using windowed fullscreen. { XMapRaised(g_dpy, g_win); - RARCH_WARN("[X/EGL]: True fullscreen failed. Attempt using windowed fullscreen instead.\n"); + RARCH_WARN("[X/EGL]: Using windowed fullscreen.\n"); x11_windowed_fullscreen(g_dpy, g_win); } else diff --git a/retroarch.cfg b/retroarch.cfg index f2f4c9348a..ef36e7ef96 100644 --- a/retroarch.cfg +++ b/retroarch.cfg @@ -50,6 +50,9 @@ # Start in fullscreen. Can be changed at runtime. # video_fullscreen = false +# If fullscreen, prefer using a windowed fullscreen mode. +# video_windowed_fullscreen = false + # Force 16-bit colors. Apparently some video cards in use today have troubles with 32-bit ... # video_force_16bit = false diff --git a/settings.c b/settings.c index 79540c8283..81846b7467 100644 --- a/settings.c +++ b/settings.c @@ -144,6 +144,7 @@ void config_set_defaults(void) g_settings.video.xscale = xscale; g_settings.video.yscale = yscale; g_settings.video.fullscreen = g_extern.force_fullscreen ? true : fullscreen; + g_settings.video.windowed_fullscreen = windowed_fullscreen; g_settings.video.fullscreen_x = fullscreen_x; g_settings.video.fullscreen_y = fullscreen_y; g_settings.video.force_16bit = force_16bit; @@ -370,6 +371,7 @@ bool config_load_file(const char *path) if (!g_extern.force_fullscreen) CONFIG_GET_BOOL(video.fullscreen, "video_fullscreen"); + CONFIG_GET_BOOL(video.windowed_fullscreen, "video_windowed_fullscreen"); CONFIG_GET_BOOL(video.force_16bit, "video_force_16bit"); CONFIG_GET_BOOL(video.disable_composition, "video_disable_composition"); CONFIG_GET_BOOL(video.vsync, "video_vsync");