[client] ds: add new minimize function to the ds interface

This change is to allow the application to minimize the window on focus
loss if the user's preferences are configured to do this.
This commit is contained in:
Geoffrey McRae 2021-05-06 22:24:42 +10:00
parent bdfb18299d
commit f698e4589d
3 changed files with 11 additions and 4 deletions

View File

@ -69,7 +69,6 @@ typedef struct LG_DSInitParams
bool resizable; bool resizable;
bool borderless; bool borderless;
bool maximize; bool maximize;
bool minimizeOnFocusLoss;
// if true the renderer requires an OpenGL context // if true the renderer requires an OpenGL context
bool opengl; bool opengl;
@ -158,10 +157,11 @@ 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);
/* get/set the window dimensions */ /* get/set the window dimensions & state */
void (*setWindowSize)(int x, int y); void (*setWindowSize)(int x, int y);
bool (*getFullscreen)(void); bool (*getFullscreen)(void);
void (*setFullscreen)(bool fs); void (*setFullscreen)(bool fs);
void (*minimize)(void);
/* clipboard support, optional, if not supported set to NULL */ /* clipboard support, optional, if not supported set to NULL */
bool (*cbInit)(void); bool (*cbInit)(void);
@ -213,6 +213,7 @@ struct LG_DisplayServerOps
assert((x)->wait ); \ assert((x)->wait ); \
assert((x)->setWindowSize ); \ assert((x)->setWindowSize ); \
assert((x)->setFullscreen ); \ assert((x)->setFullscreen ); \
assert((x)->getFullscreen ); assert((x)->getFullscreen ); \
assert((x)->minimize );
#endif #endif

View File

@ -67,7 +67,11 @@ void app_handleFocusEvent(bool focused)
{ {
g_state.focused = focused; g_state.focused = focused;
if (!core_inputEnabled()) if (!core_inputEnabled())
{
if (!focused && g_params.minimizeOnFocusLoss)
g_state.ds->minimize();
return; return;
}
if (!focused) if (!focused)
{ {
@ -81,6 +85,9 @@ void app_handleFocusEvent(bool focused)
if (!g_params.showCursorDot) if (!g_params.showCursorDot)
g_state.ds->showPointer(false); g_state.ds->showPointer(false);
if (g_params.minimizeOnFocusLoss)
g_state.ds->minimize();
} }
g_cursor.realign = true; g_cursor.realign = true;

View File

@ -765,7 +765,6 @@ static int lg_run(void)
.resizable = g_params.allowResize, .resizable = g_params.allowResize,
.borderless = g_params.borderless, .borderless = g_params.borderless,
.maximize = g_params.maximize, .maximize = g_params.maximize,
.minimizeOnFocusLoss = g_params.minimizeOnFocusLoss,
.opengl = needsOpenGL .opengl = needsOpenGL
}; };