From bda18bc899ccf3667233680e75202d7f2eee0446 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sun, 21 Feb 2016 18:17:04 +0100 Subject: [PATCH] Remove XInput2 XI_Motion support Sadly, this interferes with the Steam overlay. Fixes #304. --- CMakeLists.txt | 15 ---------- README.md | 1 + docs/compat.dox | 4 --- docs/compile.dox | 2 -- src/glfw_config.h.in | 2 -- src/x11_init.c | 22 --------------- src/x11_platform.h | 16 ----------- src/x11_window.c | 65 -------------------------------------------- 8 files changed, 1 insertion(+), 126 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e6585a1c..9fa78e5e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -234,21 +234,6 @@ if (_GLFW_X11) list(APPEND glfw_LIBRARIES "${X11_Xinerama_LIB}") list(APPEND glfw_PKG_DEPS "xinerama") - # Check for XInput (high-resolution cursor motion) - if (X11_Xinput_FOUND) - list(APPEND glfw_INCLUDE_DIRS "${X11_Xinput_INCLUDE_PATH}") - list(APPEND glfw_PKG_DEPS "xi") - - if (X11_Xinput_LIB) - list(APPEND glfw_LIBRARIES "${X11_Xinput_LIB}") - else() - # Backwards compatibility (bug in CMake 2.8.7) - list(APPEND glfw_LIBRARIES Xi) - endif() - - set(_GLFW_HAS_XINPUT TRUE) - endif() - # Check for Xf86VidMode (fallback gamma control) if (X11_xf86vmode_FOUND) list(APPEND glfw_INCLUDE_DIRS "${X11_xf86vmode_INCLUDE_PATH}") diff --git a/README.md b/README.md index 87b85864..f50333f1 100644 --- a/README.md +++ b/README.md @@ -104,6 +104,7 @@ does not find Doxygen, the documentation will not be generated. - [X11] Bugfix: Monitor connection and disconnection events were not reported - [X11] Bugfix: Decoding of UTF-8 text from XIM could continue past the end - [X11] Bugfix: An XKB structure was leaked during `glfwInit` + - [X11] Bugfix: XInput2 `XI_Motion` events interfered with the Steam overlay - [POSIX] Bugfix: An unrelated TLS key could be deleted by `glfwTerminate` - [WGL] Changed extension loading to only be performed once - [WGL] Removed dependency on external WGL headers diff --git a/docs/compat.dox b/docs/compat.dox index 030d359a..ee10770f 100644 --- a/docs/compat.dox +++ b/docs/compat.dox @@ -63,10 +63,6 @@ GLFW uses the to provide file drop events. If the application originating the drag does not support this protocol, drag and drop will not work. -GLFW uses the XInput 2 extension to provide sub-pixel cursor motion events. If -the running X server does not support this version of this extension, cursor -motion will be snapped to the pixel grid. - GLFW uses the XRandR 1.3 extension to provide multi-monitor support. If the running X server does not support this version of this extension, multi-monitor support will not function and only a single, desktop-spanning monitor will be diff --git a/docs/compile.dox b/docs/compile.dox index 38710008..4bcc623c 100644 --- a/docs/compile.dox +++ b/docs/compile.dox @@ -274,8 +274,6 @@ must also define `_GLFW_BUILD_DLL`. Otherwise, you must not define it. If you are using the X11 window creation API, support for the following X11 extensions can be enabled: - - `_GLFW_HAS_XINPUT` to use XInput2 for high-resolution cursor motion - (recommended) - `_GLFW_HAS_XF86VM` to use Xxf86vm as a fallback when RandR gamma is broken (recommended) diff --git a/src/glfw_config.h.in b/src/glfw_config.h.in index 6de97509..ab57dd59 100644 --- a/src/glfw_config.h.in +++ b/src/glfw_config.h.in @@ -60,8 +60,6 @@ // Define this to 1 to force use of high-performance GPU on hybrid systems #cmakedefine _GLFW_USE_HYBRID_HPG -// Define this to 1 if the XInput X11 extension is available -#cmakedefine _GLFW_HAS_XINPUT // Define this to 1 if the Xxf86vm X11 extension is available #cmakedefine _GLFW_HAS_XF86VM diff --git a/src/x11_init.c b/src/x11_init.c index bf9253b0..4e8eb696 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -544,25 +544,6 @@ static GLFWbool initExtensions(void) _glfw.x11.xinerama.available = GLFW_TRUE; } -#if defined(_GLFW_HAS_XINPUT) - if (XQueryExtension(_glfw.x11.display, - "XInputExtension", - &_glfw.x11.xi.majorOpcode, - &_glfw.x11.xi.eventBase, - &_glfw.x11.xi.errorBase)) - { - _glfw.x11.xi.major = 2; - _glfw.x11.xi.minor = 0; - - if (XIQueryVersion(_glfw.x11.display, - &_glfw.x11.xi.major, - &_glfw.x11.xi.minor) != BadRequest) - { - _glfw.x11.xi.available = GLFW_TRUE; - } - } -#endif /*_GLFW_HAS_XINPUT*/ - // Check if Xkb is supported on this display _glfw.x11.xkb.major = 1; _glfw.x11.xkb.minor = 0; @@ -856,9 +837,6 @@ const char* _glfwPlatformGetVersionString(void) #if defined(__linux__) " /dev/js" #endif -#if defined(_GLFW_HAS_XINPUT) - " XI" -#endif #if defined(_GLFW_HAS_XF86VM) " Xf86vm" #endif diff --git a/src/x11_platform.h b/src/x11_platform.h index 6d0f43a1..8d791f07 100644 --- a/src/x11_platform.h +++ b/src/x11_platform.h @@ -47,11 +47,6 @@ // The Xinerama extension provides legacy monitor indices #include -#if defined(_GLFW_HAS_XINPUT) - // The XInput2 extension provides improved input events - #include -#endif - #if defined(_GLFW_HAS_XF86VM) // The Xf86VidMode extension provides fallback gamma control #include @@ -250,17 +245,6 @@ typedef struct _GLFWlibraryX11 XGETXCBCONNECTION_T XGetXCBConnection; } x11xcb; -#if defined(_GLFW_HAS_XINPUT) - struct { - GLFWbool available; - int majorOpcode; - int eventBase; - int errorBase; - int major; - int minor; - } xi; -#endif /*_GLFW_HAS_XINPUT*/ - #if defined(_GLFW_HAS_XF86VM) struct { GLFWbool available; diff --git a/src/x11_window.c b/src/x11_window.c index beba43cc..24ebba32 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -469,23 +469,6 @@ static GLFWbool createWindow(_GLFWwindow* window, XFree(hint); } -#if defined(_GLFW_HAS_XINPUT) - if (_glfw.x11.xi.available) - { - // Select for XInput2 events - - XIEventMask eventmask; - unsigned char mask[] = { 0 }; - - eventmask.deviceid = 2; - eventmask.mask_len = sizeof(mask); - eventmask.mask = mask; - XISetMask(mask, XI_Motion); - - XISelectEvents(_glfw.x11.display, window->x11.handle, &eventmask, 1); - } -#endif /*_GLFW_HAS_XINPUT*/ - if (_glfw.x11.XdndAware) { // Announce support for Xdnd (drag and drop) @@ -1388,54 +1371,6 @@ static void processEvent(XEvent *event) case DestroyNotify: return; - -#if defined(_GLFW_HAS_XINPUT) - case GenericEvent: - { - if (event->xcookie.extension == _glfw.x11.xi.majorOpcode && - XGetEventData(_glfw.x11.display, &event->xcookie)) - { - if (event->xcookie.evtype == XI_Motion) - { - XIDeviceEvent* data = (XIDeviceEvent*) event->xcookie.data; - - window = findWindowByHandle(data->event); - if (window) - { - if (data->event_x != window->x11.warpPosX || - data->event_y != window->x11.warpPosY) - { - // The cursor was moved by something other than GLFW - - double x, y; - - if (window->cursorMode == GLFW_CURSOR_DISABLED) - { - if (_glfw.cursorWindow != window) - return; - - x = data->event_x - window->x11.cursorPosX; - y = data->event_y - window->x11.cursorPosY; - } - else - { - x = data->event_x; - y = data->event_y; - } - - _glfwInputCursorMotion(window, x, y); - } - - window->x11.cursorPosX = data->event_x; - window->x11.cursorPosY = data->event_y; - } - } - } - - XFreeEventData(_glfw.x11.display, &event->xcookie); - return; - } -#endif /*_GLFW_HAS_XINPUT*/ } }