mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-24 06:51:17 +01:00
Inhibit the screensaver while the emulator is running on linux. Fixes issue 3279. Uses the xdg-screensaver method suggested in that issue.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6477 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
7fe6a0b451
commit
fae12f43c2
@ -186,6 +186,15 @@ if(ENCODE_FRAMEDUMPS)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
find_program(XDG_SCREENSAVER xdg-screensaver)
|
||||||
|
if(XDG_SCREENSAVER)
|
||||||
|
message("xdg-screensaver found, enabling screensaver inhibition")
|
||||||
|
add_definitions(-DHAVE_XDG_SCREENSAVER=1)
|
||||||
|
else()
|
||||||
|
message("xdg-screensaver not found, disabling screensaver inhibition")
|
||||||
|
add_definitions(-DHAVE_XDG_SCREENSAVER=0)
|
||||||
|
endif()
|
||||||
|
|
||||||
include(CheckCXXSourceRuns)
|
include(CheckCXXSourceRuns)
|
||||||
set(CMAKE_REQUIRED_LIBRARIES portaudio)
|
set(CMAKE_REQUIRED_LIBRARIES portaudio)
|
||||||
CHECK_CXX_SOURCE_RUNS(
|
CHECK_CXX_SOURCE_RUNS(
|
||||||
|
@ -815,6 +815,11 @@ void CFrame::StartGame(const std::string& filename)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
#if defined(HAVE_XDG_SCREENSAVER) && HAVE_XDG_SCREENSAVER
|
||||||
|
X11Utils::InhibitScreensaver(X11Utils::XDisplayFromHandle(GetHandle()),
|
||||||
|
X11Utils::XWindowFromHandle(GetHandle()), true);
|
||||||
|
#endif
|
||||||
|
|
||||||
DoFullscreen(SConfig::GetInstance().m_LocalCoreStartupParameter.bFullscreen);
|
DoFullscreen(SConfig::GetInstance().m_LocalCoreStartupParameter.bFullscreen);
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
@ -915,6 +920,11 @@ void CFrame::DoStop()
|
|||||||
|
|
||||||
BootManager::Stop();
|
BootManager::Stop();
|
||||||
|
|
||||||
|
#if defined(HAVE_XDG_SCREENSAVER) && HAVE_XDG_SCREENSAVER
|
||||||
|
X11Utils::InhibitScreensaver(X11Utils::XDisplayFromHandle(GetHandle()),
|
||||||
|
X11Utils::XWindowFromHandle(GetHandle()), false);
|
||||||
|
#endif
|
||||||
|
|
||||||
// Destroy the renderer frame when not rendering to main
|
// Destroy the renderer frame when not rendering to main
|
||||||
m_RenderParent->Disconnect(wxID_ANY, wxEVT_SIZE,
|
m_RenderParent->Disconnect(wxID_ANY, wxEVT_SIZE,
|
||||||
wxSizeEventHandler(CFrame::OnRenderParentResize),
|
wxSizeEventHandler(CFrame::OnRenderParentResize),
|
||||||
|
@ -141,6 +141,10 @@ void X11_MainLoop()
|
|||||||
Window win = (Window)Core::GetWindowHandle();
|
Window win = (Window)Core::GetWindowHandle();
|
||||||
XSelectInput(dpy, win, KeyPressMask | FocusChangeMask);
|
XSelectInput(dpy, win, KeyPressMask | FocusChangeMask);
|
||||||
|
|
||||||
|
#if defined(HAVE_XDG_SCREENSAVER) && HAVE_XDG_SCREENSAVER
|
||||||
|
X11Utils::InhibitScreensaver(dpy, win, true);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(HAVE_XRANDR) && HAVE_XRANDR
|
#if defined(HAVE_XRANDR) && HAVE_XRANDR
|
||||||
X11Utils::XRRConfiguration *XRRConfig = new X11Utils::XRRConfiguration(dpy, win);
|
X11Utils::XRRConfiguration *XRRConfig = new X11Utils::XRRConfiguration(dpy, win);
|
||||||
#endif
|
#endif
|
||||||
@ -251,6 +255,11 @@ void X11_MainLoop()
|
|||||||
#if defined(HAVE_XRANDR) && HAVE_XRANDR
|
#if defined(HAVE_XRANDR) && HAVE_XRANDR
|
||||||
delete XRRConfig;
|
delete XRRConfig;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(HAVE_XDG_SCREENSAVER) && HAVE_XDG_SCREENSAVER
|
||||||
|
X11Utils::InhibitScreensaver(dpy, win, false);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor)
|
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor)
|
||||||
XFreeCursor(dpy, blankCursor);
|
XFreeCursor(dpy, blankCursor);
|
||||||
XCloseDisplay(dpy);
|
XCloseDisplay(dpy);
|
||||||
|
@ -17,6 +17,14 @@
|
|||||||
|
|
||||||
#include "X11Utils.h"
|
#include "X11Utils.h"
|
||||||
|
|
||||||
|
#if defined(HAVE_XDG_SCREENSAVER) && HAVE_XDG_SCREENSAVER
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <spawn.h>
|
||||||
|
#include <sys/wait.h>
|
||||||
|
|
||||||
|
extern char **environ;
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace X11Utils
|
namespace X11Utils
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -78,6 +86,7 @@ void EWMH_Fullscreen(Display *dpy, int action)
|
|||||||
ERROR_LOG(VIDEO, "Failed to switch fullscreen/windowed mode.");
|
ERROR_LOG(VIDEO, "Failed to switch fullscreen/windowed mode.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if defined(HAVE_WX) && HAVE_WX
|
#if defined(HAVE_WX) && HAVE_WX
|
||||||
Window XWindowFromHandle(void *Handle)
|
Window XWindowFromHandle(void *Handle)
|
||||||
{
|
{
|
||||||
@ -90,6 +99,39 @@ Display *XDisplayFromHandle(void *Handle)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(HAVE_XDG_SCREENSAVER) && HAVE_XDG_SCREENSAVER
|
||||||
|
void InhibitScreensaver(Display *dpy, Window win, bool suspend)
|
||||||
|
{
|
||||||
|
// Get X server window id
|
||||||
|
Atom actual_type;
|
||||||
|
int actual_format, status;
|
||||||
|
unsigned long nitems, bytes_after;
|
||||||
|
unsigned char *prop;
|
||||||
|
|
||||||
|
status = XGetWindowProperty(dpy, win, XInternAtom(dpy, "_NET_FRAME_WINDOW", True),
|
||||||
|
0, 125000, False, AnyPropertyType,
|
||||||
|
&actual_type, &actual_format, &nitems, &bytes_after, &prop);
|
||||||
|
|
||||||
|
char id[11];
|
||||||
|
snprintf(id, sizeof(id), "0x%lx", *(unsigned long *)prop & 0xffffffff);
|
||||||
|
|
||||||
|
// Call xdg-screensaver
|
||||||
|
char *argv[4] = {
|
||||||
|
(char *)"xdg-screensaver",
|
||||||
|
(char *)(suspend ? "suspend" : "resume"),
|
||||||
|
id,
|
||||||
|
NULL};
|
||||||
|
pid_t pid;
|
||||||
|
if (!posix_spawnp(&pid, "xdg-screensaver", NULL, NULL, argv, environ))
|
||||||
|
{
|
||||||
|
int status;
|
||||||
|
while (waitpid (pid, &status, 0) == -1);
|
||||||
|
|
||||||
|
DEBUG_LOG(VIDEO, "Started xdg-screensaver (PID = %d)", (int)pid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(HAVE_XRANDR) && HAVE_XRANDR
|
#if defined(HAVE_XRANDR) && HAVE_XRANDR
|
||||||
XRRConfiguration::XRRConfiguration(Display *_dpy, Window _win)
|
XRRConfiguration::XRRConfiguration(Display *_dpy, Window _win)
|
||||||
: dpy(_dpy)
|
: dpy(_dpy)
|
||||||
@ -125,7 +167,6 @@ XRRConfiguration::~XRRConfiguration()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void XRRConfiguration::Update()
|
void XRRConfiguration::Update()
|
||||||
{
|
{
|
||||||
if (!bValid)
|
if (!bValid)
|
||||||
|
@ -52,6 +52,10 @@ Window XWindowFromHandle(void *Handle);
|
|||||||
Display *XDisplayFromHandle(void *Handle);
|
Display *XDisplayFromHandle(void *Handle);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(HAVE_XDG_SCREENSAVER) && HAVE_XDG_SCREENSAVER
|
||||||
|
void InhibitScreensaver(Display *dpy, Window win, bool suspend);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(HAVE_XRANDR) && HAVE_XRANDR
|
#if defined(HAVE_XRANDR) && HAVE_XRANDR
|
||||||
class XRRConfiguration
|
class XRRConfiguration
|
||||||
{
|
{
|
||||||
|
@ -34,7 +34,7 @@ set(LIBS videocommon
|
|||||||
if((${CMAKE_SYSTEM_NAME} MATCHES "Darwin") AND NOT wxWidgets_FOUND)
|
if((${CMAKE_SYSTEM_NAME} MATCHES "Darwin") AND NOT wxWidgets_FOUND)
|
||||||
set(SRCS ${SRCS} Src/cocoaGL.m)
|
set(SRCS ${SRCS} Src/cocoaGL.m)
|
||||||
elseif(WIN32)
|
elseif(WIN32)
|
||||||
set(SRCS ${SRCS} Src/OS/Win32.cpp)
|
set(SRCS ${SRCS} Src/Win32.cpp)
|
||||||
elseif(NOT (${CMAKE_SYSTEM_NAME} MATCHES "Darwin"))
|
elseif(NOT (${CMAKE_SYSTEM_NAME} MATCHES "Darwin"))
|
||||||
set(LIBS ${LIBS} clrun)
|
set(LIBS ${LIBS} clrun)
|
||||||
endif()
|
endif()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user