resize now takes `struct wlr_box` as parameter

main
Leonardo Hernández Hernández 2022-06-24 19:41:26 -05:00
parent ff70337c16
commit 829dec6598
No known key found for this signature in database
GPG Key ID: E538897EE11B9624
1 changed files with 18 additions and 22 deletions

40
dwl.c
View File

@ -262,7 +262,7 @@ static void quit(const Arg *arg);
static void quitsignal(int signo); static void quitsignal(int signo);
static void rendermon(struct wl_listener *listener, void *data); static void rendermon(struct wl_listener *listener, void *data);
static void requeststartdrag(struct wl_listener *listener, void *data); static void requeststartdrag(struct wl_listener *listener, void *data);
static void resize(Client *c, int x, int y, int w, int h, int interact); static void resize(Client *c, struct wlr_box geo, int interact);
static void run(char *startup_cmd); static void run(char *startup_cmd);
static Client *selclient(void); static Client *selclient(void);
static void setcursor(struct wl_listener *listener, void *data); static void setcursor(struct wl_listener *listener, void *data);
@ -751,8 +751,8 @@ closemon(Monitor *m)
wl_list_for_each(c, &clients, link) { wl_list_for_each(c, &clients, link) {
if (c->isfloating && c->geom.x > m->m.width) if (c->isfloating && c->geom.x > m->m.width)
resize(c, c->geom.x - m->w.width, c->geom.y, resize(c, (struct wlr_box){.x = c->geom.x - m->w.width, .y = c->geom.y,
c->geom.width, c->geom.height, 0); .width = c->geom.width, .height = c->geom.height}, 0);
if (c->mon == m) if (c->mon == m)
setmon(c, selmon, c->tags); setmon(c, selmon, c->tags);
} }
@ -1434,7 +1434,7 @@ monocle(Monitor *m)
wl_list_for_each(c, &clients, link) { wl_list_for_each(c, &clients, link) {
if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen) if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
continue; continue;
resize(c, m->w.x, m->w.y, m->w.width, m->w.height, 0); resize(c, m->w, 0);
} }
focusclient(focustop(m), 1); focusclient(focustop(m), 1);
} }
@ -1476,13 +1476,12 @@ motionnotify(uint32_t time)
/* If we are currently grabbing the mouse, handle and return */ /* If we are currently grabbing the mouse, handle and return */
if (cursor_mode == CurMove) { if (cursor_mode == CurMove) {
/* Move the grabbed client to the new position. */ /* Move the grabbed client to the new position. */
resize(grabc, cursor->x - grabcx, cursor->y - grabcy, resize(grabc, (struct wlr_box){.x = cursor->x - grabcx, .y = cursor->y - grabcy,
grabc->geom.width, grabc->geom.height, 1); .width = grabc->geom.width, .height = grabc->geom.height}, 1);
return; return;
} else if (cursor_mode == CurResize) { } else if (cursor_mode == CurResize) {
resize(grabc, grabc->geom.x, grabc->geom.y, resize(grabc, (struct wlr_box){.x = grabc->geom.x, .y = grabc->geom.y,
cursor->x - grabc->geom.x, .width = cursor->x - grabc->geom.x, .height = cursor->y - grabc->geom.y}, 1);
cursor->y - grabc->geom.y, 1);
return; return;
} }
@ -1726,13 +1725,10 @@ requeststartdrag(struct wl_listener *listener, void *data)
} }
void void
resize(Client *c, int x, int y, int w, int h, int interact) resize(Client *c, struct wlr_box geo, int interact)
{ {
struct wlr_box *bbox = interact ? &sgeom : &c->mon->w; struct wlr_box *bbox = interact ? &sgeom : &c->mon->w;
c->geom.x = x; c->geom = geo;
c->geom.y = y;
c->geom.width = w;
c->geom.height = h;
applybounds(c, bbox); applybounds(c, bbox);
/* Update scene-graph, including borders */ /* Update scene-graph, including borders */
@ -1851,11 +1847,11 @@ setfullscreen(Client *c, int fullscreen)
if (fullscreen) { if (fullscreen) {
c->prev = c->geom; c->prev = c->geom;
resize(c, c->mon->m.x, c->mon->m.y, c->mon->m.width, c->mon->m.height, 0); resize(c, c->mon->m, 0);
} else { } else {
/* restore previous size instead of arrange for floating windows since /* restore previous size instead of arrange for floating windows since
* client positions are set by the user and cannot be recalculated */ * client positions are set by the user and cannot be recalculated */
resize(c, c->prev.x, c->prev.y, c->prev.width, c->prev.height, 0); resize(c, c->prev, 0);
} }
arrange(c->mon); arrange(c->mon);
printstatus(); printstatus();
@ -1904,7 +1900,7 @@ setmon(Client *c, Monitor *m, unsigned int newtags)
} }
if (m) { if (m) {
/* Make sure window actually overlaps with the monitor */ /* Make sure window actually overlaps with the monitor */
resize(c, c->geom.x, c->geom.y, c->geom.width, c->geom.height, 0); resize(c, c->geom, 0);
wlr_surface_send_enter(client_surface(c), m->wlr_output); wlr_surface_send_enter(client_surface(c), m->wlr_output);
c->tags = newtags ? newtags : m->tagset[m->seltags]; /* assign tags of target monitor */ c->tags = newtags ? newtags : m->tagset[m->seltags]; /* assign tags of target monitor */
arrange(m); arrange(m);
@ -2170,7 +2166,7 @@ tagmon(const Arg *arg)
void void
tile(Monitor *m) tile(Monitor *m)
{ {
unsigned int i, n = 0, h, mw, my, ty; unsigned int i, n = 0, mw, my, ty;
Client *c; Client *c;
wl_list_for_each(c, &clients, link) wl_list_for_each(c, &clients, link)
@ -2188,12 +2184,12 @@ tile(Monitor *m)
if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen) if (!VISIBLEON(c, m) || c->isfloating || c->isfullscreen)
continue; continue;
if (i < m->nmaster) { if (i < m->nmaster) {
h = (m->w.height - my) / (MIN(n, m->nmaster) - i); resize(c, (struct wlr_box){.x = m->w.x, .y = m->w.y + my, .width = mw,
resize(c, m->w.x, m->w.y + my, mw, h, 0); .height = (m->w.height - my) / (MIN(n, m->nmaster) - i)}, 0);
my += c->geom.height; my += c->geom.height;
} else { } else {
h = (m->w.height - ty) / (n - i); resize(c, (struct wlr_box){.x = m->w.x + mw, .y = m->w.y + ty,
resize(c, m->w.x + mw, m->w.y + ty, m->w.width - mw, h, 0); .width = m->w.width - mw, .height = (m->w.height - ty) / (n - i)}, 0);
ty += c->geom.height; ty += c->geom.height;
} }
i++; i++;