From 903cc9815f0d357d357d0518c76ac5f445899440 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Thu, 6 May 2021 22:25:38 +1000 Subject: [PATCH] [client] x11/sdl/wayland: implement new `minimize` (stub for wayland) This implements the new minimize function introduced in the last commit for x11 and SDL. Wayland at current is just a stub and needs some attention. --- client/displayservers/SDL/sdl.c | 9 +++++++-- client/displayservers/Wayland/shell_xdg.c | 5 +++++ client/displayservers/Wayland/wayland.c | 1 + client/displayservers/Wayland/wayland.h | 1 + client/displayservers/X11/x11.c | 6 ++++++ 5 files changed, 20 insertions(+), 2 deletions(-) diff --git a/client/displayservers/SDL/sdl.c b/client/displayservers/SDL/sdl.c index 37305773..0c95b672 100644 --- a/client/displayservers/SDL/sdl.c +++ b/client/displayservers/SDL/sdl.c @@ -120,8 +120,7 @@ static bool sdlInit(const LG_DSInitParams params) SDL_ShowWindow(sdl.window); - SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, - params.minimizeOnFocusLoss ? "1" : "0"); + SDL_SetHint(SDL_HINT_VIDEO_MINIMIZE_ON_FOCUS_LOSS, "0"); if (params.fullscreen) SDL_SetWindowFullscreen(sdl.window, SDL_WINDOW_FULLSCREEN_DESKTOP); @@ -507,6 +506,11 @@ static bool sdlGetFullscreen(void) return (SDL_GetWindowFlags(sdl.window) & SDL_WINDOW_FULLSCREEN_DESKTOP) != 0; } +static void sdlMinimize(void) +{ + SDL_MinimizeWindow(sdl.window); +} + struct LG_DisplayServerOps LGDS_SDL = { .setup = sdlSetup, @@ -548,6 +552,7 @@ struct LG_DisplayServerOps LGDS_SDL = .setWindowSize = sdlSetWindowSize, .setFullscreen = sdlSetFullscreen, .getFullscreen = sdlGetFullscreen, + .minimize = sdlMinimize, /* SDL does not have clipboard support */ .cbInit = NULL, diff --git a/client/displayservers/Wayland/shell_xdg.c b/client/displayservers/Wayland/shell_xdg.c index 38bec4c3..f489364e 100644 --- a/client/displayservers/Wayland/shell_xdg.c +++ b/client/displayservers/Wayland/shell_xdg.c @@ -146,3 +146,8 @@ bool waylandGetFullscreen(void) { return wlWm.fullscreen; } + +void waylandMinimize(void) +{ + //FIXME +} diff --git a/client/displayservers/Wayland/wayland.c b/client/displayservers/Wayland/wayland.c index e4821293..8c77cb7f 100644 --- a/client/displayservers/Wayland/wayland.c +++ b/client/displayservers/Wayland/wayland.c @@ -177,6 +177,7 @@ struct LG_DisplayServerOps LGDS_Wayland = .setWindowSize = waylandSetWindowSize, .setFullscreen = waylandSetFullscreen, .getFullscreen = waylandGetFullscreen, + .minimize = waylandMinimize, .cbInit = waylandCBInit, .cbNotice = waylandCBNotice, diff --git a/client/displayservers/Wayland/wayland.h b/client/displayservers/Wayland/wayland.h index 93c8a6c0..c9c53933 100644 --- a/client/displayservers/Wayland/wayland.h +++ b/client/displayservers/Wayland/wayland.h @@ -254,6 +254,7 @@ bool waylandShellInit(const char * title, bool fullscreen, bool maximize, bool b void waylandShellAckConfigureIfNeeded(void); void waylandSetFullscreen(bool fs); bool waylandGetFullscreen(void); +void waylandMinimize(void); // window module bool waylandWindowInit(const char * title, bool fullscreen, bool maximize, bool borderless); diff --git a/client/displayservers/X11/x11.c b/client/displayservers/X11/x11.c index 33e529d1..c016c4df 100644 --- a/client/displayservers/X11/x11.c +++ b/client/displayservers/X11/x11.c @@ -1215,6 +1215,11 @@ static bool x11GetFullscreen(void) return x11.fullscreen; } +static void x11Minimize(void) +{ + XIconifyWindow(x11.display, x11.window, XDefaultScreen(x11.display)); +} + struct LG_DisplayServerOps LGDS_X11 = { .setup = x11Setup, @@ -1254,6 +1259,7 @@ struct LG_DisplayServerOps LGDS_X11 = .setWindowSize = x11SetWindowSize, .setFullscreen = x11SetFullscreen, .getFullscreen = x11GetFullscreen, + .minimize = x11Minimize, .cbInit = x11CBInit, .cbNotice = x11CBNotice,