From 749880cedd052ed1b8c0e6b979778077084d6d45 Mon Sep 17 00:00:00 2001 From: "Devin J. Pohly" Date: Wed, 22 Apr 2020 11:29:13 -0500 Subject: [PATCH] calculate resize based just on cursor/window This eliminates the need for grab_height and grab_width. --- dwl.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/dwl.c b/dwl.c index d21a4dc..54aad07 100644 --- a/dwl.c +++ b/dwl.c @@ -176,7 +176,6 @@ static struct wl_list keyboards; static unsigned int cursor_mode; static Client *grabbed_client; static double grabsx, grabsy; -static int grab_width, grab_height; static struct wlr_output_layout *output_layout; static struct wl_list mons; @@ -566,10 +565,9 @@ motionnotify(uint32_t time) * compositor, you'd wait for the client to prepare a buffer at * the new size, then commit any movement that was prepared. */ - double dx = cursor->x - grabsx; - double dy = cursor->y - grabsy; wlr_xdg_toplevel_set_size(grabbed_client->xdg_surface, - grab_width + dx, grab_height + dy); + cursor->x - grabbed_client->x, + cursor->y - grabbed_client->y); return; } @@ -643,12 +641,6 @@ moveresize(Client *c, unsigned int mode) /* This function sets up an interactive move or resize operation, where the * compositor stops propagating pointer events to clients and instead * consumes them itself, to move or resize windows. */ - struct wlr_surface *focused_surface = - seat->pointer_state.focused_surface; - if (c->xdg_surface->surface != focused_surface) { - /* Deny move/resize requests from unfocused clients. */ - return; - } grabbed_client = c; cursor_mode = mode; struct wlr_box sbox; @@ -660,8 +652,6 @@ moveresize(Client *c, unsigned int mode) grabsx = cursor->x + sbox.x; grabsy = cursor->y + sbox.y; } - grab_width = sbox.width; - grab_height = sbox.height; } void