Commit f92cc6ca authored by Steve Lhomme's avatar Steve Lhomme

vout: win32: add a module to handle the inhibit mode

Inhibit the screensaver when the player is running, and restore the original
when paused or stopped.

Similar to what is done on X11 windows.

Fixes #19463
parent 81c09ce3
...@@ -334,6 +334,11 @@ if HAVE_WIN32_DESKTOP ...@@ -334,6 +334,11 @@ if HAVE_WIN32_DESKTOP
vout_LTLIBRARIES += libwingdi_plugin.la vout_LTLIBRARIES += libwingdi_plugin.la
endif endif
libwinhibit_plugin_la_SOURCES = video_output/win32/inhibit.c
if HAVE_WIN32_DESKTOP
vout_LTLIBRARIES += libwinhibit_plugin.la
endif
libegl_win32_plugin_la_SOURCES = video_output/opengl/egl.c libegl_win32_plugin_la_SOURCES = video_output/opengl/egl.c
libegl_win32_plugin_la_CPPFLAGS = $(AM_CPPFLAGS) -DUSE_PLATFORM_WIN32=1 libegl_win32_plugin_la_CPPFLAGS = $(AM_CPPFLAGS) -DUSE_PLATFORM_WIN32=1
libegl_win32_plugin_la_CFLAGS = $(AM_CFLAGS) $(EGL_CFLAGS) libegl_win32_plugin_la_CFLAGS = $(AM_CFLAGS) $(EGL_CFLAGS)
......
...@@ -188,10 +188,6 @@ static void *EventThread( void *p_this ) ...@@ -188,10 +188,6 @@ static void *EventThread( void *p_this )
return NULL; return NULL;
} }
/* Prevent monitor from powering off */
if (var_GetBool(vd, "disable-screensaver"))
SetThreadExecutionState( ES_DISPLAY_REQUIRED | ES_SYSTEM_REQUIRED | ES_CONTINUOUS );
/* Main loop */ /* Main loop */
/* GetMessage will sleep if there's no message in the queue */ /* GetMessage will sleep if there's no message in the queue */
for( ;; ) for( ;; )
......
/*****************************************************************************
* inhibit.c: Windows video output common code
*****************************************************************************
* Copyright (C) 2018 VLC authors and VideoLAN
*
* Authors: Steve Lhomme <robux4@ycbcr.xyz>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <vlc_common.h>
#include <vlc_inhibit.h>
#include <vlc_plugin.h>
struct vlc_inhibit_sys
{
EXECUTION_STATE prev_state;
};
static void Inhibit (vlc_inhibit_t *ih, unsigned mask)
{
vlc_inhibit_sys_t *sys = ih->p_sys;
bool suspend = (mask & VLC_INHIBIT_DISPLAY) != 0;
if (suspend)
/* Prevent monitor from powering off */
sys->prev_state =
SetThreadExecutionState( ES_DISPLAY_REQUIRED | ES_SYSTEM_REQUIRED | ES_CONTINUOUS );
else
SetThreadExecutionState( sys->prev_state );
}
static int OpenInhibit (vlc_object_t *obj)
{
vlc_inhibit_t *ih = (vlc_inhibit_t *)obj;
ih->p_sys = vlc_obj_malloc(obj, sizeof(vlc_inhibit_sys_t));
if (unlikely(ih->p_sys == NULL))
return VLC_ENOMEM;
ih->inhibit = Inhibit;
return VLC_SUCCESS;
}
vlc_module_begin ()
set_shortname (N_("Windows screensaver"))
set_description (N_("Windows screen saver inhibition"))
set_category (CAT_ADVANCED)
set_subcategory (SUBCAT_ADVANCED_MISC)
set_capability ("inhibit", 10)
set_callbacks (OpenInhibit, NULL)
vlc_module_end ()
...@@ -78,7 +78,8 @@ vout_window_t *vout_window_New(vlc_object_t *obj, const char *module, ...@@ -78,7 +78,8 @@ vout_window_t *vout_window_New(vlc_object_t *obj, const char *module,
/* Hook for screensaver inhibition */ /* Hook for screensaver inhibition */
if (var_InheritBool(obj, "disable-screensaver") && if (var_InheritBool(obj, "disable-screensaver") &&
window->type == VOUT_WINDOW_TYPE_XID) { (window->type == VOUT_WINDOW_TYPE_XID || window->type == VOUT_WINDOW_TYPE_HWND))
{
w->inhibit = vlc_inhibit_Create(VLC_OBJECT (window)); w->inhibit = vlc_inhibit_Create(VLC_OBJECT (window));
if (w->inhibit != NULL) if (w->inhibit != NULL)
vlc_inhibit_Set(w->inhibit, VLC_INHIBIT_VIDEO); vlc_inhibit_Set(w->inhibit, VLC_INHIBIT_VIDEO);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment