From 26714f172aed01aa7fcfeb1cd5370d168f7d4d1f Mon Sep 17 00:00:00 2001 From: "Devin J. Pohly" Date: Tue, 21 Apr 2020 14:59:32 -0500 Subject: [PATCH] inline handlemove/handleresize --- dwl.c | 38 ++++++++++++-------------------------- 1 file changed, 12 insertions(+), 26 deletions(-) diff --git a/dwl.c b/dwl.c index 6978ea1..2531d78 100644 --- a/dwl.c +++ b/dwl.c @@ -101,8 +101,6 @@ static void cursorframe(struct wl_listener *listener, void *data); static void destroynotify(struct wl_listener *listener, void *data); static void focus(Client *c, struct wlr_surface *surface); static void focusnext(const Arg *arg); -static void handlemove(uint32_t time); -static void handleresize(uint32_t time); static void inputdevice(struct wl_listener *listener, void *data); static bool keybinding(uint32_t mods, xkb_keysym_t sym); static void keypress(struct wl_listener *listener, void *data); @@ -379,28 +377,6 @@ focusnext(const Arg *arg) wl_list_insert(clients.prev, &c->link); } -void -handlemove(uint32_t time) -{ - /* Move the grabbed client to the new position. */ - grabbed_client->x = cursor->x - grab_x; - grabbed_client->y = cursor->y - grab_y; -} - -void -handleresize(uint32_t time) -{ - /* - * Note that I took some shortcuts here. In a more fleshed-out 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 - grab_x; - double dy = cursor->y - grab_y; - wlr_xdg_toplevel_set_size(grabbed_client->xdg_surface, - grab_width + dx, grab_height + dy); -} - void inputdevice(struct wl_listener *listener, void *data) { @@ -525,10 +501,20 @@ motionnotify(uint32_t time) { /* If the mode is non-passthrough, delegate to those functions. */ if (cursor_mode == CurMove) { - handlemove(time); + /* Move the grabbed client to the new position. */ + grabbed_client->x = cursor->x - grab_x; + grabbed_client->y = cursor->y - grab_y; return; } else if (cursor_mode == CurResize) { - handleresize(time); + /* + * Note that I took some shortcuts here. In a more fleshed-out + * 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 - grab_x; + double dy = cursor->y - grab_y; + wlr_xdg_toplevel_set_size(grabbed_client->xdg_surface, + grab_width + dx, grab_height + dy); return; }