Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/intern
diff options
context:
space:
mode:
authorCampbell Barton <campbell@blender.org>2022-05-27 09:29:45 +0300
committerCampbell Barton <campbell@blender.org>2022-05-27 09:48:20 +0300
commitda9e14b0b91c81d29c4e44f40ac299ae847367de (patch)
tree276accf8a2ba95497654b5038c7711e199b2213f /intern
parent46456a59c44f228f763bee1bee9357648a208359 (diff)
Fix GHOST_kGrabHide in Wayland
Dragging number buttons wasn't grabbing the cursor and would stop when the pointer reached the screen edge & wasn't setting the cursor visible on completion.
Diffstat (limited to 'intern')
-rw-r--r--intern/ghost/intern/GHOST_SystemWayland.cpp59
-rw-r--r--intern/ghost/intern/GHOST_SystemWayland.h4
-rw-r--r--intern/ghost/intern/GHOST_WindowWayland.cpp2
3 files changed, 35 insertions, 30 deletions
diff --git a/intern/ghost/intern/GHOST_SystemWayland.cpp b/intern/ghost/intern/GHOST_SystemWayland.cpp
index 4a25b8bb9bb..24d3f525c97 100644
--- a/intern/ghost/intern/GHOST_SystemWayland.cpp
+++ b/intern/ghost/intern/GHOST_SystemWayland.cpp
@@ -1920,6 +1920,8 @@ GHOST_TSuccess GHOST_SystemWayland::setCursorVisibility(bool visible)
}
GHOST_TSuccess GHOST_SystemWayland::setCursorGrab(const GHOST_TGrabCursorMode mode,
+ const GHOST_TGrabCursorMode mode_current,
+
wl_surface *surface)
{
/* ignore, if the required protocols are not supported */
@@ -1933,36 +1935,37 @@ GHOST_TSuccess GHOST_SystemWayland::setCursorGrab(const GHOST_TGrabCursorMode mo
input_t *input = d->inputs[0];
- switch (mode) {
- case GHOST_kGrabDisable:
- if (input->relative_pointer) {
- zwp_relative_pointer_v1_destroy(input->relative_pointer);
- input->relative_pointer = nullptr;
- }
- if (input->locked_pointer) {
- zwp_locked_pointer_v1_destroy(input->locked_pointer);
- input->locked_pointer = nullptr;
- }
- break;
-
- case GHOST_kGrabNormal:
- break;
- case GHOST_kGrabWrap:
- input->relative_pointer = zwp_relative_pointer_manager_v1_get_relative_pointer(
- d->relative_pointer_manager, input->pointer);
- zwp_relative_pointer_v1_add_listener(
- input->relative_pointer, &relative_pointer_listener, input);
- input->locked_pointer = zwp_pointer_constraints_v1_lock_pointer(
- d->pointer_constraints,
- surface,
- input->pointer,
- nullptr,
- ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_PERSISTENT);
- break;
+ if (mode != GHOST_kGrabDisable) {
+ /* TODO(@campbellbarton): Support #GHOST_kGrabWrap,
+ * where the cursor moves but is constrained to a region. */
+ input->relative_pointer = zwp_relative_pointer_manager_v1_get_relative_pointer(
+ d->relative_pointer_manager, input->pointer);
+ zwp_relative_pointer_v1_add_listener(
+ input->relative_pointer, &relative_pointer_listener, input);
+ input->locked_pointer = zwp_pointer_constraints_v1_lock_pointer(
+ d->pointer_constraints,
+ surface,
+ input->pointer,
+ nullptr,
+ ZWP_POINTER_CONSTRAINTS_V1_LIFETIME_PERSISTENT);
+
+ if (mode == GHOST_kGrabHide) {
+ setCursorVisibility(false);
+ }
+ }
+ else {
+ if (input->relative_pointer) {
+ zwp_relative_pointer_v1_destroy(input->relative_pointer);
+ input->relative_pointer = nullptr;
+ }
+ if (input->locked_pointer) {
+ zwp_locked_pointer_v1_destroy(input->locked_pointer);
+ input->locked_pointer = nullptr;
+ }
- case GHOST_kGrabHide:
+ if (mode_current == GHOST_kGrabHide) {
setCursorVisibility(false);
- break;
+ }
}
return GHOST_kSuccess;
diff --git a/intern/ghost/intern/GHOST_SystemWayland.h b/intern/ghost/intern/GHOST_SystemWayland.h
index 1f664915ad3..01b47358618 100644
--- a/intern/ghost/intern/GHOST_SystemWayland.h
+++ b/intern/ghost/intern/GHOST_SystemWayland.h
@@ -103,7 +103,9 @@ class GHOST_SystemWayland : public GHOST_System {
GHOST_TSuccess setCursorVisibility(bool visible);
- GHOST_TSuccess setCursorGrab(const GHOST_TGrabCursorMode mode, wl_surface *surface);
+ GHOST_TSuccess setCursorGrab(const GHOST_TGrabCursorMode mode,
+ const GHOST_TGrabCursorMode mode_current,
+ wl_surface *surface);
private:
struct display_t *d;
diff --git a/intern/ghost/intern/GHOST_WindowWayland.cpp b/intern/ghost/intern/GHOST_WindowWayland.cpp
index 7ae06623c91..7f2a2c992d9 100644
--- a/intern/ghost/intern/GHOST_WindowWayland.cpp
+++ b/intern/ghost/intern/GHOST_WindowWayland.cpp
@@ -320,7 +320,7 @@ int &GHOST_WindowWayland::scale()
GHOST_TSuccess GHOST_WindowWayland::setWindowCursorGrab(GHOST_TGrabCursorMode mode)
{
- return m_system->setCursorGrab(mode, w->surface);
+ return m_system->setCursorGrab(mode, m_cursorGrab, w->surface);
}
GHOST_TSuccess GHOST_WindowWayland::setWindowCursorShape(GHOST_TStandardCursor shape)