|
@@ -2241,15 +2241,14 @@ void _glfwGetCursorPosWayland(_GLFWwindow* window, double* xpos, double* ypos)
|
|
*ypos = window->wl.cursorPosY;
|
|
*ypos = window->wl.cursorPosY;
|
|
}
|
|
}
|
|
|
|
|
|
-static GLFWbool isPointerLocked(_GLFWwindow* window);
|
|
|
|
-
|
|
|
|
void _glfwSetCursorPosWayland(_GLFWwindow* window, double x, double y)
|
|
void _glfwSetCursorPosWayland(_GLFWwindow* window, double x, double y)
|
|
{
|
|
{
|
|
- if (isPointerLocked(window))
|
|
|
|
|
|
+ if (window->wl.lockedPointer)
|
|
{
|
|
{
|
|
zwp_locked_pointer_v1_set_cursor_position_hint(
|
|
zwp_locked_pointer_v1_set_cursor_position_hint(
|
|
- window->wl.pointerLock.lockedPointer,
|
|
|
|
- wl_fixed_from_double(x), wl_fixed_from_double(y));
|
|
|
|
|
|
+ window->wl.lockedPointer,
|
|
|
|
+ wl_fixed_from_double(x),
|
|
|
|
+ wl_fixed_from_double(y));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -2486,20 +2485,13 @@ static void lockedPointerHandleLocked(void* userData,
|
|
|
|
|
|
static void unlockPointer(_GLFWwindow* window)
|
|
static void unlockPointer(_GLFWwindow* window)
|
|
{
|
|
{
|
|
- struct zwp_relative_pointer_v1* relativePointer =
|
|
|
|
- window->wl.pointerLock.relativePointer;
|
|
|
|
- struct zwp_locked_pointer_v1* lockedPointer =
|
|
|
|
- window->wl.pointerLock.lockedPointer;
|
|
|
|
-
|
|
|
|
- zwp_relative_pointer_v1_destroy(relativePointer);
|
|
|
|
- zwp_locked_pointer_v1_destroy(lockedPointer);
|
|
|
|
|
|
+ zwp_relative_pointer_v1_destroy(window->wl.relativePointer);
|
|
|
|
+ window->wl.relativePointer = NULL;
|
|
|
|
|
|
- window->wl.pointerLock.relativePointer = NULL;
|
|
|
|
- window->wl.pointerLock.lockedPointer = NULL;
|
|
|
|
|
|
+ zwp_locked_pointer_v1_destroy(window->wl.lockedPointer);
|
|
|
|
+ window->wl.lockedPointer = NULL;
|
|
}
|
|
}
|
|
|
|
|
|
-static void lockPointer(_GLFWwindow* window);
|
|
|
|
-
|
|
|
|
static void lockedPointerHandleUnlocked(void* userData,
|
|
static void lockedPointerHandleUnlocked(void* userData,
|
|
struct zwp_locked_pointer_v1* lockedPointer)
|
|
struct zwp_locked_pointer_v1* lockedPointer)
|
|
{
|
|
{
|
|
@@ -2513,9 +2505,6 @@ static const struct zwp_locked_pointer_v1_listener lockedPointerListener =
|
|
|
|
|
|
static void lockPointer(_GLFWwindow* window)
|
|
static void lockPointer(_GLFWwindow* window)
|
|
{
|
|
{
|
|
- struct zwp_relative_pointer_v1* relativePointer;
|
|
|
|
- struct zwp_locked_pointer_v1* lockedPointer;
|
|
|
|
-
|
|
|
|
if (!_glfw.wl.relativePointerManager)
|
|
if (!_glfw.wl.relativePointerManager)
|
|
{
|
|
{
|
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
|
@@ -2523,42 +2512,28 @@ static void lockPointer(_GLFWwindow* window)
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- relativePointer =
|
|
|
|
|
|
+ window->wl.relativePointer =
|
|
zwp_relative_pointer_manager_v1_get_relative_pointer(
|
|
zwp_relative_pointer_manager_v1_get_relative_pointer(
|
|
_glfw.wl.relativePointerManager,
|
|
_glfw.wl.relativePointerManager,
|
|
_glfw.wl.pointer);
|
|
_glfw.wl.pointer);
|
|
- zwp_relative_pointer_v1_add_listener(relativePointer,
|
|
|
|
|
|
+ zwp_relative_pointer_v1_add_listener(window->wl.relativePointer,
|
|
&relativePointerListener,
|
|
&relativePointerListener,
|
|
window);
|
|
window);
|
|
|
|
|
|
- lockedPointer =
|
|
|
|
|
|
+ window->wl.lockedPointer =
|
|
zwp_pointer_constraints_v1_lock_pointer(
|
|
zwp_pointer_constraints_v1_lock_pointer(
|
|
_glfw.wl.pointerConstraints,
|
|
_glfw.wl.pointerConstraints,
|
|
window->wl.surface,
|
|
window->wl.surface,
|
|
_glfw.wl.pointer,
|
|
_glfw.wl.pointer,
|
|
NULL,
|
|
NULL,
|
|
ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_PERSISTENT);
|
|
ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_PERSISTENT);
|
|
- zwp_locked_pointer_v1_add_listener(lockedPointer,
|
|
|
|
|
|
+ zwp_locked_pointer_v1_add_listener(window->wl.lockedPointer,
|
|
&lockedPointerListener,
|
|
&lockedPointerListener,
|
|
window);
|
|
window);
|
|
-
|
|
|
|
- window->wl.pointerLock.relativePointer = relativePointer;
|
|
|
|
- window->wl.pointerLock.lockedPointer = lockedPointer;
|
|
|
|
-
|
|
|
|
- wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.pointerEnterSerial,
|
|
|
|
- NULL, 0, 0);
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-static GLFWbool isPointerLocked(_GLFWwindow* window)
|
|
|
|
-{
|
|
|
|
- return window->wl.pointerLock.lockedPointer != NULL;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
void _glfwSetCursorWayland(_GLFWwindow* window, _GLFWcursor* cursor)
|
|
void _glfwSetCursorWayland(_GLFWwindow* window, _GLFWcursor* cursor)
|
|
{
|
|
{
|
|
- struct wl_cursor* defaultCursor;
|
|
|
|
- struct wl_cursor* defaultCursorHiDPI = NULL;
|
|
|
|
-
|
|
|
|
if (!_glfw.wl.pointer)
|
|
if (!_glfw.wl.pointer)
|
|
return;
|
|
return;
|
|
|
|
|
|
@@ -2569,9 +2544,17 @@ void _glfwSetCursorWayland(_GLFWwindow* window, _GLFWcursor* cursor)
|
|
if (window != _glfw.wl.pointerFocus || window->wl.decorations.focus != mainWindow)
|
|
if (window != _glfw.wl.pointerFocus || window->wl.decorations.focus != mainWindow)
|
|
return;
|
|
return;
|
|
|
|
|
|
- // Unlock possible pointer lock if no longer disabled.
|
|
|
|
- if (window->cursorMode != GLFW_CURSOR_DISABLED && isPointerLocked(window))
|
|
|
|
- unlockPointer(window);
|
|
|
|
|
|
+ // Update pointer lock to match cursor mode
|
|
|
|
+ if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
|
|
|
+ {
|
|
|
|
+ if (!window->wl.lockedPointer)
|
|
|
|
+ lockPointer(window);
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ if (window->wl.lockedPointer)
|
|
|
|
+ unlockPointer(window);
|
|
|
|
+ }
|
|
|
|
|
|
if (window->cursorMode == GLFW_CURSOR_NORMAL)
|
|
if (window->cursorMode == GLFW_CURSOR_NORMAL)
|
|
{
|
|
{
|
|
@@ -2579,19 +2562,24 @@ void _glfwSetCursorWayland(_GLFWwindow* window, _GLFWcursor* cursor)
|
|
setCursorImage(window, &cursor->wl);
|
|
setCursorImage(window, &cursor->wl);
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- defaultCursor = wl_cursor_theme_get_cursor(_glfw.wl.cursorTheme,
|
|
|
|
- "left_ptr");
|
|
|
|
|
|
+ struct wl_cursor* defaultCursor =
|
|
|
|
+ wl_cursor_theme_get_cursor(_glfw.wl.cursorTheme, "left_ptr");
|
|
if (!defaultCursor)
|
|
if (!defaultCursor)
|
|
{
|
|
{
|
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
|
"Wayland: Standard cursor not found");
|
|
"Wayland: Standard cursor not found");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ struct wl_cursor* defaultCursorHiDPI = NULL;
|
|
if (_glfw.wl.cursorThemeHiDPI)
|
|
if (_glfw.wl.cursorThemeHiDPI)
|
|
|
|
+ {
|
|
defaultCursorHiDPI =
|
|
defaultCursorHiDPI =
|
|
- wl_cursor_theme_get_cursor(_glfw.wl.cursorThemeHiDPI,
|
|
|
|
- "left_ptr");
|
|
|
|
- _GLFWcursorWayland cursorWayland = {
|
|
|
|
|
|
+ wl_cursor_theme_get_cursor(_glfw.wl.cursorThemeHiDPI, "left_ptr");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ _GLFWcursorWayland cursorWayland =
|
|
|
|
+ {
|
|
defaultCursor,
|
|
defaultCursor,
|
|
defaultCursorHiDPI,
|
|
defaultCursorHiDPI,
|
|
NULL,
|
|
NULL,
|
|
@@ -2599,18 +2587,12 @@ void _glfwSetCursorWayland(_GLFWwindow* window, _GLFWcursor* cursor)
|
|
0, 0,
|
|
0, 0,
|
|
0
|
|
0
|
|
};
|
|
};
|
|
|
|
+
|
|
setCursorImage(window, &cursorWayland);
|
|
setCursorImage(window, &cursorWayland);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- else if (window->cursorMode == GLFW_CURSOR_DISABLED)
|
|
|
|
- {
|
|
|
|
- if (!isPointerLocked(window))
|
|
|
|
- lockPointer(window);
|
|
|
|
- }
|
|
|
|
- else if (window->cursorMode == GLFW_CURSOR_HIDDEN)
|
|
|
|
- {
|
|
|
|
|
|
+ else
|
|
wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.pointerEnterSerial, NULL, 0, 0);
|
|
wl_pointer_set_cursor(_glfw.wl.pointer, _glfw.wl.pointerEnterSerial, NULL, 0, 0);
|
|
- }
|
|
|
|
}
|
|
}
|
|
|
|
|
|
static void dataSourceHandleTarget(void* userData,
|
|
static void dataSourceHandleTarget(void* userData,
|