aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDevin J. Pohly <djpohly@gmail.com>2020-04-23 22:26:43 -0500
committerDevin J. Pohly <djpohly@gmail.com>2020-04-23 23:35:54 -0500
commit288f6397faea0285cf4eba9fc84459c60c2ed690 (patch)
treefdcef5e65f2b10dd96310a51beef3dd7ebab0125
parent073c35ae2f96bb6a48e628e49897cb392e63094a (diff)
simplify move/resizemouse functions
-rw-r--r--dwl.c30
1 files changed, 11 insertions, 19 deletions
diff --git a/dwl.c b/dwl.c
index cc41d3a..69c124d 100644
--- a/dwl.c
+++ b/dwl.c
@@ -710,20 +710,15 @@ motionrelative(struct wl_listener *listener, void *data)
void
movemouse(const Arg *arg)
{
- double sx, sy;
struct wlr_surface *surface;
- Client *c = xytoclient(cursor->x, cursor->y, &surface, &sx, &sy);
- if (!c)
+ grabc = xytoclient(cursor->x, cursor->y, &surface, &grabsx, &grabsy);
+ if (!grabc)
return;
- /* Prepare for moving client in motionnotify */
- grabc = c;
- cursor_mode = CurMove;
- grabsx = cursor->x - c->x;
- grabsy = cursor->y - c->y;
- /* Float the window */
+ /* Float the window and tell motionnotify to grab it */
if (!grabc->isfloating && selmon->lt[selmon->sellt]->arrange)
grabc->isfloating = 1;
+ cursor_mode = CurMove;
}
void
@@ -893,26 +888,23 @@ resize(Client *c, int x, int y, int w, int h)
void
resizemouse(const Arg *arg)
{
- double sx, sy;
struct wlr_surface *surface;
- Client *c = xytoclient(cursor->x, cursor->y, &surface, &sx, &sy);
- if (!c)
+ grabc = xytoclient(cursor->x, cursor->y, &surface, &grabsx, &grabsy);
+ if (!grabc)
return;
struct wlr_box sbox;
- wlr_xdg_surface_get_geometry(c->xdg_surface, &sbox);
+ wlr_xdg_surface_get_geometry(grabc->xdg_surface, &sbox);
/* Doesn't work for X11 output - the next absolute motion event
* returns the cursor to where it started */
wlr_cursor_warp_closest(cursor, NULL,
- c->x + sbox.x + sbox.width,
- c->y + sbox.y + sbox.height);
+ grabc->x + sbox.x + sbox.width,
+ grabc->y + sbox.y + sbox.height);
- /* Prepare for resizing client in motionnotify */
- grabc = c;
- cursor_mode = CurResize;
- /* Float the window */
+ /* Float the window and tell motionnotify to resize it */
if (!grabc->isfloating && selmon->lt[selmon->sellt]->arrange)
grabc->isfloating = 1;
+ cursor_mode = CurResize;
}
void