aboutsummaryrefslogtreecommitdiff
path: root/dwl.c
diff options
context:
space:
mode:
authorLeonardo Hernández Hernández <leohdz172@protonmail.com>2022-09-28 18:29:59 -0500
committerLeonardo Hernández <leohdz172@protonmail.com>2022-10-01 23:10:54 -0500
commitb8bc54b65d7dfaf1c7aa92de32f8ca37d8e011f9 (patch)
treebd26bc7b7d990b9564b6493dc6837d607720db5a /dwl.c
parentb5776e5180010ead5232efb36b2490f4fc9e1366 (diff)
properly handle cursor motion when button is held
Based on: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/3653
Diffstat (limited to 'dwl.c')
-rw-r--r--dwl.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/dwl.c b/dwl.c
index 339ebe5..b4fa1ef 100644
--- a/dwl.c
+++ b/dwl.c
@@ -66,7 +66,7 @@
#define LISTEN(E, L, H) wl_signal_add((E), ((L)->notify = (H), (L)))
/* enums */
-enum { CurNormal, CurMove, CurResize }; /* cursor */
+enum { CurNormal, CurPressed, CurMove, CurResize }; /* cursor */
enum { XDGShell, LayerShell, X11Managed, X11Unmanaged }; /* client types */
enum { LyrBg, LyrBottom, LyrTop, LyrOverlay, LyrTile, LyrFloat, LyrNoFocus, NUM_LAYERS }; /* scene layers */
#ifdef XWAYLAND
@@ -672,10 +672,11 @@ buttonpress(struct wl_listener *listener, void *data)
return;
}
}
+ cursor_mode = CurPressed;
break;
case WLR_BUTTON_RELEASED:
/* If you released any buttons, we exit interactive move/resize mode. */
- if (cursor_mode != CurNormal) {
+ if (cursor_mode != CurNormal && cursor_mode != CurPressed) {
cursor_mode = CurNormal;
/* Clear the pointer focus, this way if the cursor is over a surface
* we will send an enter event after which the client will provide us
@@ -686,6 +687,8 @@ buttonpress(struct wl_listener *listener, void *data)
selmon = xytomon(cursor->x, cursor->y);
setmon(grabc, selmon, 0);
return;
+ } else {
+ cursor_mode = CurNormal;
}
break;
}
@@ -1532,6 +1535,13 @@ motionnotify(uint32_t time)
/* Find the client under the pointer and send the event along. */
xytonode(cursor->x, cursor->y, &surface, &c, NULL, &sx, &sy);
+ if (cursor_mode == CurPressed) {
+ surface = seat->pointer_state.focused_surface;
+ c = client_from_wlr_surface(surface);
+ sx = c ? cursor->x - c->geom.x : 0;
+ sy = c ? cursor->y - c->geom.y : 0;
+ }
+
/* If there's no client surface under the cursor, set the cursor image to a
* default. This is what makes the cursor image appear when you move it
* off of a client or over its border. */