reset Xorg screensaver on joy events

Use the libXss Xorg screensaver extension library to call
`XResetScreenSaver()` on joystick events to inhibit screen blanking when
for whatever reason the joystick driver or DE (xboxdrv and KDE in this
case) does not do this.

Signed-off-by: Rafael Kitover <rkitover@gmail.com>
This commit is contained in:
Rafael Kitover 2019-03-22 11:30:31 -07:00
parent a0283eadb6
commit 59e9c69097
No known key found for this signature in database
GPG Key ID: 08AB596679D86240
2 changed files with 30 additions and 0 deletions

View File

@ -651,6 +651,17 @@ IF( WIN32 )
ENDIF(ENABLE_DEBUGGER)
ENDIF( WIN32 )
unset(EXTRA_X11_LIBS)
if(NOT WIN32 AND NOT APPLE)
find_package(X11)
if(X11_X11_LIB AND X11_Xscreensaver_LIB)
include_directories(${X11_INCLUDE_DIR})
set(EXTRA_X11_LIBS ${X11_X11_LIB} ${X11_Xscreensaver_LIB})
add_definitions(-DHAVE_XSS)
endif()
endif()
link_directories( ${CMAKE_BINARY_DIR} )
SET(VBAM_ICON vbam.icns)
@ -683,6 +694,7 @@ TARGET_LINK_LIBRARIES (
${GTK_LIBRARIES}
${OPENAL_LIBRARY}
${FAUDIO_LIBS}
${EXTRA_X11_LIBS}
)
if(ENABLE_FFMPEG)

View File

@ -1292,6 +1292,14 @@ void GameArea::OnSize(wxSizeEvent& ev)
ev.Skip(true);
}
#if defined(__WXGTK__) && defined(HAVE_XSS)
#include <X11/Xlib.h>
#define Status int
#include <X11/extensions/scrnsaver.h>
#include <gdk/gdkx.h>
#include <gtk/gtk.h>
#endif
void GameArea::OnSDLJoy(wxSDLJoyEvent& ev)
{
int key = ev.GetControlIndex();
@ -1313,6 +1321,16 @@ void GameArea::OnSDLJoy(wxSDLJoyEvent& ev)
process_key_press(value & SDL_HAT_LEFT, key, WXJB_HAT_W, joy);
} else
process_key_press(ev.GetControlValue() != 0, key, mod, joy);
// tell Linux to turn off the screensaver/screen-blank if joystick button was pressed
// this shouldn't be necessary of course
#if defined(__WXGTK__) && defined(HAVE_XSS)
if (!wxGetApp().UsingWayland()) {
Display* display = GDK_WINDOW_XDISPLAY(gtk_widget_get_window(wxGetApp().frame->GetHandle()));
XResetScreenSaver(display);
XFlush(display);
}
#endif
}
BEGIN_EVENT_TABLE(GameArea, wxPanel)