diff --git a/BUILD.gn b/BUILD.gn index 5ffa0b3..eff1577 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -157,6 +157,7 @@ ohos_shared_library("glfw") { "Xrandr", ] defines += [ "_GLFW_X11" ] + defines += [ "USE_DUMMPY_XINPUT2" ] } part_name = "glfw" diff --git a/bundle.json b/bundle.json index 412f6b2..9b30031 100644 --- a/bundle.json +++ b/bundle.json @@ -18,7 +18,7 @@ "subsystem": "thirdparty", "syscap": [], "features": [], - "adapted_system_type": ["standard"], + "adapted_system_type": [ "standard" ], "rom": "", "ram": "", "deps": { diff --git a/src/x11_init.c b/src/x11_init.c index 982c526..80b2db2 100644 --- a/src/x11_init.c +++ b/src/x11_init.c @@ -637,8 +637,10 @@ static GLFWbool initExtensions(void) { _glfw.x11.xi.QueryVersion = (PFN_XIQueryVersion) _glfwPlatformGetModuleSymbol(_glfw.x11.xi.handle, "XIQueryVersion"); +#ifndef USE_DUMMPY_XINPUT2 _glfw.x11.xi.SelectEvents = (PFN_XISelectEvents) _glfwPlatformGetModuleSymbol(_glfw.x11.xi.handle, "XISelectEvents"); +#endif if (XQueryExtension(_glfw.x11.display, "XInputExtension", diff --git a/src/x11_platform.h b/src/x11_platform.h index 30326c5..715ac62 100644 --- a/src/x11_platform.h +++ b/src/x11_platform.h @@ -45,7 +45,9 @@ #include // The XInput extension provides raw mouse motion input +#ifndef USE_DUMMPY_XINPUT2 #include +#endif // The Shape extension provides custom window shapes #include @@ -370,9 +372,13 @@ typedef Bool (* PFN_XF86VidModeGetGammaRampSize)(Display*,int,int*); #define XF86VidModeGetGammaRampSize _glfw.x11.vidmode.GetGammaRampSize typedef Status (* PFN_XIQueryVersion)(Display*,int*,int*); +#ifndef USE_DUMMPY_XINPUT2 typedef int (* PFN_XISelectEvents)(Display*,Window,XIEventMask*,int); +#endif #define XIQueryVersion _glfw.x11.xi.QueryVersion +#ifndef USE_DUMMPY_XINPUT2 #define XISelectEvents _glfw.x11.xi.SelectEvents +#endif typedef Bool (* PFN_XRenderQueryExtension)(Display*,int*,int*); typedef Status (* PFN_XRenderQueryVersion)(Display*dpy,int*,int*); @@ -847,7 +853,9 @@ typedef struct _GLFWlibraryX11 int major; int minor; PFN_XIQueryVersion QueryVersion; +#ifndef USE_DUMMPY_XINPUT2 PFN_XISelectEvents SelectEvents; +#endif } xi; struct { diff --git a/src/x11_window.c b/src/x11_window.c index 322349f..6a036cd 100644 --- a/src/x11_window.c +++ b/src/x11_window.c @@ -497,6 +497,7 @@ static void releaseCursor(void) // static void enableRawMouseMotion(_GLFWwindow* window) { +#ifndef USE_DUMMPY_XINPUT2 XIEventMask em; unsigned char mask[XIMaskLen(XI_RawMotion)] = { 0 }; @@ -506,12 +507,14 @@ static void enableRawMouseMotion(_GLFWwindow* window) XISetMask(mask, XI_RawMotion); XISelectEvents(_glfw.x11.display, _glfw.x11.root, &em, 1); +#endif } // Disable XI2 raw mouse motion events // static void disableRawMouseMotion(_GLFWwindow* window) { +#ifndef USE_DUMMPY_XINPUT2 XIEventMask em; unsigned char mask[] = { 0 }; @@ -520,6 +523,7 @@ static void disableRawMouseMotion(_GLFWwindow* window) em.mask = mask; XISelectEvents(_glfw.x11.display, _glfw.x11.root, &em, 1); +#endif } // Apply disabled cursor mode to a focused window @@ -1182,6 +1186,7 @@ static void processEvent(XEvent *event) { if (_glfw.x11.xi.available) { +#ifndef USE_DUMMPY_XINPUT2 _GLFWwindow* window = _glfw.x11.disabledCursorWindow; if (window && @@ -1211,6 +1216,7 @@ static void processEvent(XEvent *event) } XFreeEventData(_glfw.x11.display, &event->xcookie); +#endif } return;