From 31e9b4256afd293ebd7a7747f9f687a9fb891e2a Mon Sep 17 00:00:00 2001 From: Martin Duquesnoy Date: Tue, 25 Oct 2011 22:55:31 +0200 Subject: [PATCH] Apply size of configure event with _fac_resize --- src/client.c | 34 +++++++++++++++++++++------------- src/client.h | 2 ++ src/draw.h | 17 +++++++++++++++-- src/event.c | 13 ++++++------- src/layout.c | 2 +- 5 files changed, 45 insertions(+), 23 deletions(-) diff --git a/src/client.c b/src/client.c index ea497ee..63f84c4 100644 --- a/src/client.c +++ b/src/client.c @@ -212,7 +212,7 @@ _swap_get(struct client *c, enum position p) } #define _REV_SBORDER() \ - draw_reversed_rect(W->root, W->rgc, &c2->geo); + draw_reversed_rect(W->root, &c2->geo); void client_swap(struct client *c, enum position p) { @@ -729,7 +729,7 @@ _fac_arrange_row(struct client *c, enum position p, int fac) _fac_apply(cc, p, fac); } -static void +void _fac_resize(struct client *c, enum position p, int fac) { struct client *cc, *gc = client_next_with_pos(c, p); @@ -774,12 +774,26 @@ _fac_resize(struct client *c, enum position p, int fac) return; } - } -#define _REV_BORDER() \ - SLIST_FOREACH(gc, &c->tag->clients, tnext) \ - draw_reversed_rect(W->root, W->rgc, &gc->tgeo); +void +client_apply_tgeo(struct tag *t) +{ + struct client *c; + + SLIST_FOREACH(c, &t->clients, tnext) + { + client_moveresize(c, &c->tgeo); + c->flags &= ~CLIENT_FAC_APPLIED; + } +} + +#define _REV_BORDER() \ + do { \ + SLIST_FOREACH(gc, &c->tag->clients, tnext) \ + draw_reversed_rect(W->root, &gc->tgeo); \ + draw_reversed_cross(W->root, &c->tag->sel->tgeo); \ + } while(/* CONSTCOND */ 0); void client_fac_resize(struct client *c, enum position p, int fac) { @@ -864,13 +878,7 @@ client_fac_resize(struct client *c, enum position p, int fac) } /* Aborted with escape, Set back original geos */ else - { - SLIST_FOREACH(gc, &c->tag->clients, tnext) - { - gc->tgeo = gc->geo; - gc->flags &= ~CLIENT_DID_WINSIZE; - } - } + client_apply_tgeo(c->tag); XUngrabServer(W->dpy); XUngrabKeyboard(W->dpy, CurrentTime); diff --git a/src/client.h b/src/client.h index 4a4753f..f4462b2 100644 --- a/src/client.h +++ b/src/client.h @@ -28,6 +28,8 @@ void client_fac_resize(struct client *c, enum position p, int fac); void client_fac_adjust(struct client *c); void client_remove(struct client *c); void client_free(void); +void _fac_resize(struct client *c, enum position p, int fac); +void client_apply_tgeo(struct tag *t); /* Generated */ void uicb_client_resize_Right(Uicb); diff --git a/src/draw.h b/src/draw.h index 48f9be3..5ee4ef8 100644 --- a/src/draw.h +++ b/src/draw.h @@ -34,18 +34,31 @@ draw_rect(Drawable d, struct geo g, Color bg) * For client use */ static inline void -draw_reversed_rect(Drawable dr, GC gc, struct geo *g) +draw_reversed_rect(Drawable dr, struct geo *g) { struct geo *ug = &W->screen->ugeo; int i = THEME_DEFAULT->client_border_width; - XDrawRectangle(W->dpy, dr, gc, + XDrawRectangle(W->dpy, dr, W->rgc, ug->x + g->x + i, ug->y + g->y + i, g->w - (i << 1), g->h - (i << 1)); } +static inline void +draw_reversed_cross(Drawable dr, struct geo *g) +{ + int x = g->x + W->screen->ugeo.x; + int y = g->y + W->screen->ugeo.y; + + XDrawLine(W->dpy, dr, W->rgc, + x, y, x + g->w, y + g->h); + + XDrawLine(W->dpy, dr, W->rgc, + x + g->w, y, x, y + g->h); +} + static inline unsigned short draw_textw(struct theme *t, const char *str) { diff --git a/src/event.c b/src/event.c index 56a60af..d2064c7 100644 --- a/src/event.c +++ b/src/event.c @@ -73,18 +73,17 @@ event_configureevent(XEvent *e) if((c = client_gb_win(ev->window))) { - if(ev->value_mask & CWX) + /* if(ev->value_mask & CWX) c->geo.x = ev->x; if(ev->value_mask & CWY) - c->geo.y = ev->y; + c->geo.y = ev->y; */ + if(ev->value_mask & CWWidth) - c->geo.w = ev->width; + _fac_resize(c, Right, (ev->width - c->geo.w)); if(ev->value_mask & CWHeight) - c->geo.h = ev->height; + _fac_resize(c, Bottom, (ev->height - c->geo.h)); - client_configure(c); - - XMoveResizeWindow(EVDPY(e), c->win, c->geo.x, c->geo.y, c->geo.w, c->geo.h); + client_apply_tgeo(c->tag); } else { diff --git a/src/layout.c b/src/layout.c index fa072ef..0b144b0 100644 --- a/src/layout.c +++ b/src/layout.c @@ -105,7 +105,7 @@ layout_free_set(struct tag *t) #define _REV_BORDER() \ SLIST_FOREACH(g, &l->geos, next) \ - draw_reversed_rect(W->root, W->rgc, &g->geo); + draw_reversed_rect(W->root, &g->geo); static void _historic_set(struct tag *t, bool prev) {