@@ -1860,6 +1860,9 @@ void _glfwDestroyWindowWayland(_GLFWwindow* window)
1860
1860
if (window -> wl .lockedPointer )
1861
1861
zwp_locked_pointer_v1_destroy (window -> wl .lockedPointer );
1862
1862
1863
+ if (window -> wl .confinedPointer )
1864
+ zwp_confined_pointer_v1_destroy (window -> wl .confinedPointer );
1865
+
1863
1866
if (window -> context .destroy )
1864
1867
window -> context .destroy (window );
1865
1868
@@ -2538,6 +2541,43 @@ static void lockPointer(_GLFWwindow* window)
2538
2541
window );
2539
2542
}
2540
2543
2544
+ static void confinedPointerHandleConfined (void * userData ,
2545
+ struct zwp_confined_pointer_v1 * confinedPointer )
2546
+ {
2547
+ }
2548
+
2549
+ static void confinedPointerHandleUnconfined (void * userData ,
2550
+ struct zwp_confined_pointer_v1 * confinedPointer )
2551
+ {
2552
+ }
2553
+
2554
+ static const struct zwp_confined_pointer_v1_listener confinedPointerListener =
2555
+ {
2556
+ confinedPointerHandleConfined ,
2557
+ confinedPointerHandleUnconfined
2558
+ };
2559
+
2560
+ static void confinePointer (_GLFWwindow * window )
2561
+ {
2562
+ window -> wl .confinedPointer =
2563
+ zwp_pointer_constraints_v1_confine_pointer (
2564
+ _glfw .wl .pointerConstraints ,
2565
+ window -> wl .surface ,
2566
+ _glfw .wl .pointer ,
2567
+ NULL ,
2568
+ ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_PERSISTENT );
2569
+
2570
+ zwp_confined_pointer_v1_add_listener (window -> wl .confinedPointer ,
2571
+ & confinedPointerListener ,
2572
+ window );
2573
+ }
2574
+
2575
+ static void unconfinePointer (_GLFWwindow * window )
2576
+ {
2577
+ zwp_confined_pointer_v1_destroy (window -> wl .confinedPointer );
2578
+ window -> wl .confinedPointer = NULL ;
2579
+ }
2580
+
2541
2581
void _glfwSetCursorWayland (_GLFWwindow * window , _GLFWcursor * cursor )
2542
2582
{
2543
2583
if (!_glfw .wl .pointer )
@@ -2553,17 +2593,29 @@ void _glfwSetCursorWayland(_GLFWwindow* window, _GLFWcursor* cursor)
2553
2593
// Update pointer lock to match cursor mode
2554
2594
if (window -> cursorMode == GLFW_CURSOR_DISABLED )
2555
2595
{
2596
+ if (window -> wl .confinedPointer )
2597
+ unconfinePointer (window );
2556
2598
if (!window -> wl .lockedPointer )
2557
2599
lockPointer (window );
2558
2600
}
2601
+ else if (window -> cursorMode == GLFW_CURSOR_CAPTURED )
2602
+ {
2603
+ if (window -> wl .lockedPointer )
2604
+ unlockPointer (window );
2605
+ if (!window -> wl .confinedPointer )
2606
+ confinePointer (window );
2607
+ }
2559
2608
else if (window -> cursorMode == GLFW_CURSOR_NORMAL ||
2560
2609
window -> cursorMode == GLFW_CURSOR_HIDDEN )
2561
2610
{
2562
2611
if (window -> wl .lockedPointer )
2563
2612
unlockPointer (window );
2613
+ else if (window -> wl .confinedPointer )
2614
+ unconfinePointer (window );
2564
2615
}
2565
2616
2566
- if (window -> cursorMode == GLFW_CURSOR_NORMAL )
2617
+ if (window -> cursorMode == GLFW_CURSOR_NORMAL ||
2618
+ window -> cursorMode == GLFW_CURSOR_CAPTURED )
2567
2619
{
2568
2620
if (cursor )
2569
2621
setCursorImage (window , & cursor -> wl );
0 commit comments