mirror of
https://github.com/gnif/LookingGlass.git
synced 2024-12-23 06:11:46 +00:00
[client] displayserver: move screensaver handling into displayservers
This also makes Wayland idle inhibition respect noScreensaver setting.
This commit is contained in:
parent
44a949f5c6
commit
2f11024db8
5 changed files with 33 additions and 8 deletions
|
@ -222,6 +222,16 @@ static void sdlRealignPointer(void)
|
|||
app_handleMouseNormal(0, 0);
|
||||
}
|
||||
|
||||
static void sdlInhibitIdle(void)
|
||||
{
|
||||
SDL_DisableScreenSaver();
|
||||
}
|
||||
|
||||
static void sdlUninhibitIdle(void)
|
||||
{
|
||||
SDL_EnableScreenSaver();
|
||||
}
|
||||
|
||||
struct LG_DisplayServerOps LGDS_SDL =
|
||||
{
|
||||
.subsystem = SDL_SYSWM_UNKNOWN,
|
||||
|
@ -238,6 +248,8 @@ struct LG_DisplayServerOps LGDS_SDL =
|
|||
.ungrabKeyboard = sdlUngrabKeyboard,
|
||||
.warpPointer = sdlWarpPointer,
|
||||
.realignPointer = sdlRealignPointer,
|
||||
.inhibitIdle = sdlInhibitIdle,
|
||||
.uninhibitIdle = sdlUninhibitIdle,
|
||||
|
||||
/* SDL does not have clipboard support */
|
||||
.cbInit = NULL,
|
||||
|
|
|
@ -206,14 +206,14 @@ static const struct wl_pointer_listener pointerListener = {
|
|||
.axis = pointerAxisHandler,
|
||||
};
|
||||
|
||||
static void inhibitIdle(void)
|
||||
static void waylandInhibitIdle(void)
|
||||
{
|
||||
if (wm.idleInhibitManager && !wm.idleInhibitor)
|
||||
wm.idleInhibitor = zwp_idle_inhibit_manager_v1_create_inhibitor(
|
||||
wm.idleInhibitManager, wm.surface);
|
||||
}
|
||||
|
||||
static void uninhibitIdle(void)
|
||||
static void waylandUninhibitIdle(void)
|
||||
{
|
||||
if (wm.idleInhibitor)
|
||||
{
|
||||
|
@ -238,14 +238,12 @@ static void keyboardEnterHandler(void * data, struct wl_keyboard * keyboard,
|
|||
uint32_t * key;
|
||||
wl_array_for_each(key, keys)
|
||||
app_handleKeyPress(*key);
|
||||
|
||||
inhibitIdle();
|
||||
}
|
||||
|
||||
static void keyboardLeaveHandler(void * data, struct wl_keyboard * keyboard,
|
||||
uint32_t serial, struct wl_surface * surface)
|
||||
{
|
||||
uninhibitIdle();
|
||||
// Do nothing.
|
||||
}
|
||||
|
||||
static void keyboardKeyHandler(void * data, struct wl_keyboard * keyboard,
|
||||
|
@ -473,7 +471,7 @@ static void waylandFree(void)
|
|||
|
||||
if (wm.idleInhibitManager)
|
||||
{
|
||||
uninhibitIdle();
|
||||
waylandUninhibitIdle();
|
||||
zwp_idle_inhibit_manager_v1_destroy(wm.idleInhibitManager);
|
||||
}
|
||||
|
||||
|
@ -862,6 +860,8 @@ struct LG_DisplayServerOps LGDS_Wayland =
|
|||
.ungrabKeyboard = waylandUngrabKeyboard,
|
||||
.warpPointer = waylandWarpPointer,
|
||||
.realignPointer = waylandRealignPointer,
|
||||
.inhibitIdle = waylandInhibitIdle,
|
||||
.uninhibitIdle = waylandUninhibitIdle,
|
||||
|
||||
.cbInit = waylandCBInit,
|
||||
.cbNotice = waylandCBNotice,
|
||||
|
|
|
@ -850,6 +850,10 @@ struct LG_DisplayServerOps LGDS_X11 =
|
|||
.ungrabKeyboard = x11UngrabKeyboard,
|
||||
.warpPointer = x11WarpPointer,
|
||||
|
||||
/* Use SDL implementation for now */
|
||||
.inhibitIdle = NULL,
|
||||
.uninhibitIdle = NULL,
|
||||
|
||||
.cbInit = x11CBInit,
|
||||
.cbNotice = x11CBNotice,
|
||||
.cbRelease = x11CBRelease,
|
||||
|
|
|
@ -100,6 +100,10 @@ struct LG_DisplayServerOps
|
|||
* deltas */
|
||||
void (*realignPointer)();
|
||||
|
||||
/* called to disable/enable the screensaver */
|
||||
void (*inhibitIdle)();
|
||||
void (*uninhibitIdle)();
|
||||
|
||||
/* clipboard support */
|
||||
bool (* cbInit)(void);
|
||||
void (* cbNotice)(LG_ClipboardData type);
|
||||
|
|
|
@ -1816,6 +1816,8 @@ static int lg_run(void)
|
|||
SET_FALLBACK(ungrabKeyboard);
|
||||
SET_FALLBACK(warpPointer);
|
||||
SET_FALLBACK(realignPointer);
|
||||
SET_FALLBACK(inhibitIdle);
|
||||
SET_FALLBACK(uninhibitIdle);
|
||||
SET_FALLBACK(cbInit);
|
||||
SET_FALLBACK(cbNotice);
|
||||
SET_FALLBACK(cbRelease);
|
||||
|
@ -1829,8 +1831,8 @@ static int lg_run(void)
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (!params.noScreensaver)
|
||||
SDL_SetHint(SDL_HINT_VIDEO_ALLOW_SCREENSAVER, "1");
|
||||
// Allow screensavers for now: we will enable and disable as needed.
|
||||
SDL_SetHint(SDL_HINT_VIDEO_ALLOW_SCREENSAVER, "1");
|
||||
|
||||
if (SDL_Init(SDL_INIT_VIDEO) < 0)
|
||||
{
|
||||
|
@ -1961,6 +1963,9 @@ static int lg_run(void)
|
|||
if (!params.center)
|
||||
SDL_SetWindowPosition(g_state.window, params.x, params.y);
|
||||
|
||||
if (!params.noScreensaver)
|
||||
g_state.ds->inhibitIdle();
|
||||
|
||||
// ensure the initial window size is stored in the state
|
||||
SDL_GetWindowSize(g_state.window, &g_state.windowW, &g_state.windowH);
|
||||
|
||||
|
|
Loading…
Reference in a new issue