From 59e9c69097c7a5c4e0cf9f87e97468964b54eec6 Mon Sep 17 00:00:00 2001 From: Rafael Kitover Date: Fri, 22 Mar 2019 11:30:31 -0700 Subject: [PATCH] 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 --- src/wx/CMakeLists.txt | 12 ++++++++++++ src/wx/panel.cpp | 18 ++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/src/wx/CMakeLists.txt b/src/wx/CMakeLists.txt index 967f422b..fbd99529 100644 --- a/src/wx/CMakeLists.txt +++ b/src/wx/CMakeLists.txt @@ -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) diff --git a/src/wx/panel.cpp b/src/wx/panel.cpp index 1b395825..40d49b27 100644 --- a/src/wx/panel.cpp +++ b/src/wx/panel.cpp @@ -1292,6 +1292,14 @@ void GameArea::OnSize(wxSizeEvent& ev) ev.Skip(true); } +#if defined(__WXGTK__) && defined(HAVE_XSS) + #include + #define Status int + #include + #include + #include +#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)