Skip to content
Permalink
Browse files

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>
  • Loading branch information
rkitover committed Mar 22, 2019
1 parent a0283ea commit 59e9c69097c7a5c4e0cf9f87e97468964b54eec6
Showing with 30 additions and 0 deletions.
  1. +12 −0 src/wx/CMakeLists.txt
  2. +18 −0 src/wx/panel.cpp
@@ -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)
@@ -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)

0 comments on commit 59e9c69

Please sign in to comment.
You can’t perform that action at this time.