mirror of
https://codeberg.org/dwl/dwl.git
synced 2024-12-27 03:36:31 +00:00
simplify move/resizemouse functions
This commit is contained in:
parent
073c35ae2f
commit
288f6397fa
1 changed files with 11 additions and 19 deletions
30
dwl.c
30
dwl.c
|
@ -710,20 +710,15 @@ motionrelative(struct wl_listener *listener, void *data)
|
||||||
void
|
void
|
||||||
movemouse(const Arg *arg)
|
movemouse(const Arg *arg)
|
||||||
{
|
{
|
||||||
double sx, sy;
|
|
||||||
struct wlr_surface *surface;
|
struct wlr_surface *surface;
|
||||||
Client *c = xytoclient(cursor->x, cursor->y, &surface, &sx, &sy);
|
grabc = xytoclient(cursor->x, cursor->y, &surface, &grabsx, &grabsy);
|
||||||
if (!c)
|
if (!grabc)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Prepare for moving client in motionnotify */
|
/* Float the window and tell motionnotify to grab it */
|
||||||
grabc = c;
|
|
||||||
cursor_mode = CurMove;
|
|
||||||
grabsx = cursor->x - c->x;
|
|
||||||
grabsy = cursor->y - c->y;
|
|
||||||
/* Float the window */
|
|
||||||
if (!grabc->isfloating && selmon->lt[selmon->sellt]->arrange)
|
if (!grabc->isfloating && selmon->lt[selmon->sellt]->arrange)
|
||||||
grabc->isfloating = 1;
|
grabc->isfloating = 1;
|
||||||
|
cursor_mode = CurMove;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -893,26 +888,23 @@ resize(Client *c, int x, int y, int w, int h)
|
||||||
void
|
void
|
||||||
resizemouse(const Arg *arg)
|
resizemouse(const Arg *arg)
|
||||||
{
|
{
|
||||||
double sx, sy;
|
|
||||||
struct wlr_surface *surface;
|
struct wlr_surface *surface;
|
||||||
Client *c = xytoclient(cursor->x, cursor->y, &surface, &sx, &sy);
|
grabc = xytoclient(cursor->x, cursor->y, &surface, &grabsx, &grabsy);
|
||||||
if (!c)
|
if (!grabc)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
struct wlr_box sbox;
|
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
|
/* Doesn't work for X11 output - the next absolute motion event
|
||||||
* returns the cursor to where it started */
|
* returns the cursor to where it started */
|
||||||
wlr_cursor_warp_closest(cursor, NULL,
|
wlr_cursor_warp_closest(cursor, NULL,
|
||||||
c->x + sbox.x + sbox.width,
|
grabc->x + sbox.x + sbox.width,
|
||||||
c->y + sbox.y + sbox.height);
|
grabc->y + sbox.y + sbox.height);
|
||||||
|
|
||||||
/* Prepare for resizing client in motionnotify */
|
/* Float the window and tell motionnotify to resize it */
|
||||||
grabc = c;
|
|
||||||
cursor_mode = CurResize;
|
|
||||||
/* Float the window */
|
|
||||||
if (!grabc->isfloating && selmon->lt[selmon->sellt]->arrange)
|
if (!grabc->isfloating && selmon->lt[selmon->sellt]->arrange)
|
||||||
grabc->isfloating = 1;
|
grabc->isfloating = 1;
|
||||||
|
cursor_mode = CurResize;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
Loading…
Reference in a new issue