From 406e22a681635c6229bdc1b1e64291329e7b84f8 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Mon, 13 Jan 2020 22:21:12 +1100 Subject: [PATCH] [client] override new behaviour in SDL 2.0.15 and disable xinput2 xinput2 is used to get touch interface events with the side effect of consuming MotionNotify events which we use because of SDL2's inability to correctly track the window size. Since we are not that intertested in touch for our usecase, we just turn the events off again. --- VERSION | 2 +- client/CMakeLists.txt | 10 +++++++--- client/src/main.c | 24 ++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/VERSION b/VERSION index 9cf9a2b8..0fca67eb 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -B1-95-g9846762991+1 \ No newline at end of file +B1-96-g17e05c6fd5+1 \ No newline at end of file diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index 5183da12..ef504379 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -46,6 +46,10 @@ pkg_check_modules(PKGCONFIG REQUIRED x11 ) +pkg_check_modules(PKGCONFIG_OPT + xi +) + execute_process( COMMAND cat ../VERSION WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} @@ -63,12 +67,12 @@ get_filename_component(PROJECT_TOP "${PROJECT_SOURCE_DIR}/.." ABSOLUTE) include_directories( ${PROJECT_SOURCE_DIR}/include ${CMAKE_BINARY_DIR}/include - ${PKGCONFIG_INCLUDE_DIRS} + ${PKGCONFIG_INCLUDE_DIRS} ${PKGCONFIG_OPT_INCLUDE_DIRS} ${GMP_INCLUDE_DIR} ) link_libraries( - ${PKGCONFIG_LIBRARIES} + ${PKGCONFIG_LIBRARIES} ${PKGCONFIG_OPT_LIBRARIES} ${GMP_LIBRARIES} ${CMAKE_DL_LIBS} rt @@ -94,7 +98,7 @@ add_subdirectory(fonts) add_subdirectory(decoders) add_executable(looking-glass-client ${SOURCES}) -target_compile_options(looking-glass-client PUBLIC ${PKGCONFIG_CFLAGS_OTHER}) +target_compile_options(looking-glass-client PUBLIC ${PKGCONFIG_CFLAGS_OTHER} ${PKGCONFIG_OPT_CFLAGS_OTHER}) target_link_libraries(looking-glass-client ${EXE_FLAGS} lg_common diff --git a/client/src/main.c b/client/src/main.c index d43fa606..74938179 100644 --- a/client/src/main.c +++ b/client/src/main.c @@ -35,6 +35,11 @@ Place, Suite 330, Boston, MA 02111-1307 USA #include #include +#if SDL_VIDEO_DRIVER_X11_XINPUT2 +// because SDL2 sucks and we need to turn it off +#include +#endif + #include "common/debug.h" #include "common/crash.h" #include "common/KVMFR.h" @@ -1331,6 +1336,25 @@ static int lg_run() // enable X11 events to work around SDL2 bugs SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE); +#if SDL_VIDEO_DRIVER_X11_XINPUT2 + // SDL2 bug, using xinput2 disables all motion notify events + // we really don't care about touch, so turn it off and go back + // to the default behaiovur. + XIEventMask xinputmask = + { + .deviceid = XIAllMasterDevices, + .mask = 0, + .mask_len = 0 + }; + + XISelectEvents( + state.wminfo.info.x11.display, + state.wminfo.info.x11.window, + &xinputmask, + 1 + ); +#endif + Atom NETWM_BYPASS_COMPOSITOR = XInternAtom( state.wminfo.info.x11.display, "NETWM_BYPASS_COMPOSITOR",