[client] ds: added new getFullscreen operation

As the window manager may change our mode to full screen without our
request we must ask the ds backend for the current state when we want to
toggle the mode.
This commit is contained in:
Geoffrey McRae 2021-01-27 11:11:53 +11:00
parent cfa9171465
commit f4c1927f56
6 changed files with 23 additions and 4 deletions

View File

@ -452,6 +452,11 @@ static void sdlSetFullscreen(bool fs)
SDL_SetWindowFullscreen(sdl.window, fs ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0); SDL_SetWindowFullscreen(sdl.window, fs ? SDL_WINDOW_FULLSCREEN_DESKTOP : 0);
} }
static bool sdlGetFullscreen(void)
{
return (SDL_GetWindowFlags(sdl.window) & SDL_WINDOW_FULLSCREEN_DESKTOP) != 0;
}
struct LG_DisplayServerOps LGDS_SDL = struct LG_DisplayServerOps LGDS_SDL =
{ {
.probe = sdlProbe, .probe = sdlProbe,
@ -482,6 +487,7 @@ struct LG_DisplayServerOps LGDS_SDL =
.wait = sdlWait, .wait = sdlWait,
.setWindowSize = sdlSetWindowSize, .setWindowSize = sdlSetWindowSize,
.setFullscreen = sdlSetFullscreen, .setFullscreen = sdlSetFullscreen,
.getFullscreen = sdlGetFullscreen,
/* SDL does not have clipboard support */ /* SDL does not have clipboard support */
.cbInit = NULL, .cbInit = NULL,

View File

@ -1026,6 +1026,11 @@ static void x11SetFullscreen(bool fs)
SubstructureNotifyMask | SubstructureRedirectMask, &e); SubstructureNotifyMask | SubstructureRedirectMask, &e);
} }
static bool x11GetFullscreen(void)
{
return x11.fullscreen;
}
static bool x11CBInit() static bool x11CBInit()
{ {
x11.aSelection = XInternAtom(x11.display, "CLIPBOARD" , False); x11.aSelection = XInternAtom(x11.display, "CLIPBOARD" , False);
@ -1380,6 +1385,7 @@ struct LG_DisplayServerOps LGDS_X11 =
.wait = x11Wait, .wait = x11Wait,
.setWindowSize = x11SetWindowSize, .setWindowSize = x11SetWindowSize,
.setFullscreen = x11SetFullscreen, .setFullscreen = x11SetFullscreen,
.getFullscreen = x11GetFullscreen,
.cbInit = x11CBInit, .cbInit = x11CBInit,
.cbNotice = x11CBNotice, .cbNotice = x11CBNotice,

View File

@ -55,6 +55,7 @@ void app_handleFocusEvent(bool focused);
void app_handleCloseEvent(void); void app_handleCloseEvent(void);
void app_setFullscreen(bool fs); void app_setFullscreen(bool fs);
bool app_getFullscreen(void);
bool app_getProp(LG_DSProperty prop, void * ret); bool app_getProp(LG_DSProperty prop, void * ret);
EGLDisplay app_getEGLDisplay(void); EGLDisplay app_getEGLDisplay(void);

View File

@ -130,8 +130,9 @@ struct LG_DisplayServerOps
/* wait for the specified time without blocking UI processing/event loops */ /* wait for the specified time without blocking UI processing/event loops */
void (*wait)(unsigned int time); void (*wait)(unsigned int time);
/* set the window dimensions */ /* get/set the window dimensions */
void (*setWindowSize)(int x, int y); void (*setWindowSize)(int x, int y);
bool (*getFullscreen)(void);
void (*setFullscreen)(bool fs); void (*setFullscreen)(bool fs);
/* clipboard support */ /* clipboard support */
@ -162,5 +163,6 @@ struct LG_DisplayServerOps
(x)->uninhibitIdle && \ (x)->uninhibitIdle && \
(x)->wait && \ (x)->wait && \
(x)->setWindowSize && \ (x)->setWindowSize && \
(x)->setFullscreen) (x)->setFullscreen && \
(x)->getFullscreen)
#endif #endif

View File

@ -556,6 +556,11 @@ void app_setFullscreen(bool fs)
g_state.ds->setFullscreen(fs); g_state.ds->setFullscreen(fs);
} }
bool app_getFullscreen(void)
{
return g_state.ds->getFullscreen();
}
bool app_getProp(LG_DSProperty prop, void * ret) bool app_getProp(LG_DSProperty prop, void * ret)
{ {
return g_state.ds->getProp(prop, ret); return g_state.ds->getProp(prop, ret);

View File

@ -30,8 +30,7 @@ Place, Suite 330, Boston, MA 02111-1307 USA
static void bind_fullscreen(int sc, void * opaque) static void bind_fullscreen(int sc, void * opaque)
{ {
g_params.fullscreen = !g_params.fullscreen; app_setFullscreen(!app_getFullscreen());
app_setFullscreen(g_params.fullscreen);
} }
static void bind_video(int sc, void * opaque) static void bind_video(int sc, void * opaque)