make move-grab coords client-relative

This commit is contained in:
Devin J. Pohly 2020-04-30 11:33:32 -05:00
parent 3973ea5bfe
commit 33b0236858

10
dwl.c
View File

@ -204,7 +204,7 @@ static struct wl_listener request_cursor;
static struct wl_list keyboards; static struct wl_list keyboards;
static unsigned int cursor_mode; static unsigned int cursor_mode;
static Client *grabc; static Client *grabc;
static double grabsx, grabsy; /* surface-relative */ static int grabcx, grabcy; /* client-relative */
static struct wlr_output_layout *output_layout; static struct wlr_output_layout *output_layout;
static struct wlr_box sgeom; static struct wlr_box sgeom;
@ -690,8 +690,7 @@ motionnotify(uint32_t time)
if (cursor_mode == CurMove) { if (cursor_mode == CurMove) {
/* Move the grabbed client to the new position. */ /* Move the grabbed client to the new position. */
/* XXX assumes the surface is at (0,0) within grabc */ /* XXX assumes the surface is at (0,0) within grabc */
resize(grabc, cursor->x - grabsx - grabc->bw, resize(grabc, cursor->x - grabcx, cursor->y - grabcy,
cursor->y - grabsy - grabc->bw,
grabc->geom.width, grabc->geom.height, 1); grabc->geom.width, grabc->geom.height, 1);
return; return;
} else if (cursor_mode == CurResize) { } else if (cursor_mode == CurResize) {
@ -735,7 +734,8 @@ void
moveresize(const Arg *arg) moveresize(const Arg *arg)
{ {
struct wlr_surface *surface; struct wlr_surface *surface;
grabc = xytoclient(cursor->x, cursor->y, &surface, &grabsx, &grabsy); double sx, sy;
grabc = xytoclient(cursor->x, cursor->y, &surface, &sx, &sy);
if (!grabc) if (!grabc)
return; return;
@ -743,6 +743,8 @@ moveresize(const Arg *arg)
setfloating(grabc, 1); setfloating(grabc, 1);
switch (cursor_mode = arg->ui) { switch (cursor_mode = arg->ui) {
case CurMove: case CurMove:
grabcx = cursor->x - grabc->geom.x;
grabcy = cursor->y - grabc->geom.y;
wlr_xcursor_manager_set_cursor_image(cursor_mgr, "fleur", cursor); wlr_xcursor_manager_set_cursor_image(cursor_mgr, "fleur", cursor);
break; break;
case CurResize: case CurResize: