mirror of
https://github.com/glfw/glfw.git
synced 2026-09-21 08:39:45 +00:00
Add GLFW_RAW_INPUT and glfwRawInputSupported
This adds runtime per-window control of whether accelerated or raw mouse motion is provided when the cursor is disabled. Fixes #1400. Closes #1401.
This commit is contained in:
committed by
Camilla Löwy
parent
5f9cbd0ebc
commit
9e29f556fd
+22
-3
@@ -526,7 +526,7 @@ static void updateCursorImage(_GLFWwindow* window)
|
||||
//
|
||||
static void disableCursor(_GLFWwindow* window)
|
||||
{
|
||||
if (_glfw.x11.xi.available)
|
||||
if (_glfw.x11.xi.available && window->useRawInput)
|
||||
{
|
||||
XIEventMask em;
|
||||
unsigned char mask[XIMaskLen(XI_RawMotion)] = { 0 };
|
||||
@@ -557,7 +557,7 @@ static void disableCursor(_GLFWwindow* window)
|
||||
//
|
||||
static void enableCursor(_GLFWwindow* window)
|
||||
{
|
||||
if (_glfw.x11.xi.available)
|
||||
if (_glfw.x11.xi.available && window->useRawInput)
|
||||
{
|
||||
XIEventMask em;
|
||||
unsigned char mask[] = { 0 };
|
||||
@@ -1183,6 +1183,7 @@ static void processEvent(XEvent *event)
|
||||
_GLFWwindow* window = _glfw.x11.disabledCursorWindow;
|
||||
|
||||
if (window &&
|
||||
window->useRawInput &&
|
||||
event->xcookie.extension == _glfw.x11.xi.majorOpcode &&
|
||||
XGetEventData(_glfw.x11.display, &event->xcookie) &&
|
||||
event->xcookie.evtype == XI_RawMotion)
|
||||
@@ -1483,7 +1484,7 @@ static void processEvent(XEvent *event)
|
||||
{
|
||||
if (_glfw.x11.disabledCursorWindow != window)
|
||||
return;
|
||||
if (_glfw.x11.xi.available)
|
||||
if (_glfw.x11.xi.available && window->useRawInput)
|
||||
return;
|
||||
|
||||
const int dx = x - window->x11.lastCursorPosX;
|
||||
@@ -2652,6 +2653,24 @@ void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity)
|
||||
PropModeReplace, (unsigned char*) &value, 1);
|
||||
}
|
||||
|
||||
void _glfwPlatformSetRawInput(_GLFWwindow *window, GLFWbool enabled)
|
||||
{
|
||||
if (window->useRawInput != enabled)
|
||||
{
|
||||
int update = (_glfw.x11.disabledCursorWindow == window && _glfw.x11.xi.available);
|
||||
if (update)
|
||||
enableCursor(window);
|
||||
window->useRawInput = enabled;
|
||||
if (update)
|
||||
disableCursor(window);
|
||||
}
|
||||
}
|
||||
|
||||
GLFWbool _glfwPlatformRawInputSupported(void)
|
||||
{
|
||||
return _glfw.x11.xi.available;
|
||||
}
|
||||
|
||||
void _glfwPlatformPollEvents(void)
|
||||
{
|
||||
_GLFWwindow* window;
|
||||
|
||||
Reference in New Issue
Block a user