mirror of https://github.com/0intro/wmii
removed bh/bw occurences (go rid of code)
This commit is contained in:
parent
54b7d6dd2a
commit
c243337350
|
@ -16,7 +16,6 @@ alloc_client(Window w, XWindowAttributes *wa)
|
|||
XTextProperty name;
|
||||
Client *c = (Client *) cext_emallocz(sizeof(Client));
|
||||
XSetWindowAttributes fwa;
|
||||
int bw = def.border, bh;
|
||||
long msize;
|
||||
static unsigned short id = 1;
|
||||
|
||||
|
@ -43,10 +42,9 @@ alloc_client(Window w, XWindowAttributes *wa)
|
|||
fwa.background_pixmap = ParentRelative;
|
||||
fwa.event_mask = SubstructureRedirectMask | ExposureMask | ButtonPressMask | PointerMotionMask;
|
||||
|
||||
bh = bar_height();
|
||||
c->frect = c->rect;
|
||||
c->frect.width += 2 * bw;
|
||||
c->frect.height += bw + (bh ? bh : bw);
|
||||
c->frect.width += 2 * def.border;
|
||||
c->frect.height += def.border + bar_height();
|
||||
c->framewin = XCreateWindow(dpy, root, c->frect.x, c->frect.y,
|
||||
c->frect.width, c->frect.height, 0,
|
||||
DefaultDepth(dpy, screen), CopyFromParent,
|
||||
|
@ -241,9 +239,6 @@ void
|
|||
draw_client(Client *c)
|
||||
{
|
||||
Draw d = { 0 };
|
||||
unsigned int bh = bar_height();
|
||||
unsigned int bw = def.border;
|
||||
XRectangle notch;
|
||||
|
||||
d.align = WEST;
|
||||
d.drawable = c->framewin;
|
||||
|
@ -256,27 +251,16 @@ draw_client(Client *c)
|
|||
d.color = def.norm;
|
||||
|
||||
/* draw border */
|
||||
if(bw) {
|
||||
notch.x = bw;
|
||||
notch.y = bw;
|
||||
notch.width = c->frect.width - 2 * bw;
|
||||
notch.height = c->frect.height - 2 * bw;
|
||||
if(def.border) {
|
||||
d.rect = c->frect;
|
||||
d.rect.x = d.rect.y = 0;
|
||||
d.notch = ¬ch;
|
||||
|
||||
d.rect.x = d.rect.y = 0;
|
||||
d.notch = &c->rect;
|
||||
blitz_drawlabel(dpy, &d);
|
||||
}
|
||||
XSync(dpy, False);
|
||||
|
||||
/* draw bar */
|
||||
if(!bh)
|
||||
return;
|
||||
|
||||
d.rect.x = 0;
|
||||
d.rect.y = 0;
|
||||
d.rect.width = c->frect.width;
|
||||
d.rect.height = bh;
|
||||
d.rect.height = bar_height();
|
||||
d.notch = nil;
|
||||
d.data = c->name;
|
||||
blitz_drawlabel(dpy, &d);
|
||||
|
@ -284,7 +268,7 @@ draw_client(Client *c)
|
|||
}
|
||||
|
||||
void
|
||||
gravitate(Client * c, unsigned int tabh, unsigned int bw, int invert)
|
||||
gravitate(Client *c, Bool invert)
|
||||
{
|
||||
int dx = 0, dy = 0;
|
||||
int gravity = NorthWestGravity;
|
||||
|
@ -298,19 +282,19 @@ gravitate(Client * c, unsigned int tabh, unsigned int bw, int invert)
|
|||
case NorthWestGravity:
|
||||
case NorthGravity:
|
||||
case NorthEastGravity:
|
||||
dy = tabh;
|
||||
dy = bar_height();
|
||||
break;
|
||||
case EastGravity:
|
||||
case CenterGravity:
|
||||
case WestGravity:
|
||||
dy = -(c->rect.height / 2) + tabh;
|
||||
dy = -(c->rect.height / 2) + bar_height();
|
||||
break;
|
||||
case SouthEastGravity:
|
||||
case SouthGravity:
|
||||
case SouthWestGravity:
|
||||
dy = -c->rect.height;
|
||||
break;
|
||||
default: /* don't care */
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -320,19 +304,19 @@ gravitate(Client * c, unsigned int tabh, unsigned int bw, int invert)
|
|||
case NorthWestGravity:
|
||||
case WestGravity:
|
||||
case SouthWestGravity:
|
||||
dx = bw;
|
||||
dx = def.border;
|
||||
break;
|
||||
case NorthGravity:
|
||||
case CenterGravity:
|
||||
case SouthGravity:
|
||||
dx = -(c->rect.width / 2) + bw;
|
||||
dx = -(c->rect.width / 2) + def.border;
|
||||
break;
|
||||
case NorthEastGravity:
|
||||
case EastGravity:
|
||||
case SouthEastGravity:
|
||||
dx = -(c->rect.width + bw);
|
||||
dx = -(c->rect.width + def.border);
|
||||
break;
|
||||
default: /* don't care */
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -415,7 +399,7 @@ win2clientframe(Window w)
|
|||
}
|
||||
|
||||
static void
|
||||
match_sizehints(Client *c, unsigned int tabh, unsigned int bw)
|
||||
match_sizehints(Client *c)
|
||||
{
|
||||
XSizeHints *s = &c->size;
|
||||
|
||||
|
@ -444,11 +428,11 @@ match_sizehints(Client *c, unsigned int tabh, unsigned int bw)
|
|||
h = c->size.min_height;
|
||||
}
|
||||
/* client_width = base_width + i * c->size.width_inc for an integer i */
|
||||
w = c->frect.width - 2 * bw - w;
|
||||
w = c->frect.width - 2 * def.border - w;
|
||||
if(s->width_inc > 0)
|
||||
c->frect.width -= w % s->width_inc;
|
||||
|
||||
h = c->frect.height - bw - (tabh ? tabh : bw) - h;
|
||||
h = c->frect.height - def.border - bar_height() - h;
|
||||
if(s->height_inc > 0)
|
||||
c->frect.height -= h % s->height_inc;
|
||||
}
|
||||
|
@ -457,8 +441,6 @@ match_sizehints(Client *c, unsigned int tabh, unsigned int bw)
|
|||
void
|
||||
resize_client(Client *c, XRectangle *r, XPoint *pt, Bool ignore_xcall)
|
||||
{
|
||||
unsigned int bh = bar_height();
|
||||
unsigned int bw = def.border;
|
||||
int pi = tag2index(c->area->tag);
|
||||
int px = sel * rect.width;
|
||||
|
||||
|
@ -469,17 +451,17 @@ resize_client(Client *c, XRectangle *r, XPoint *pt, Bool ignore_xcall)
|
|||
c->frect = *r;
|
||||
|
||||
if((c->area->mode != Colstack) || (c->area->sel == client2index(c)))
|
||||
match_sizehints(c, bh, bw);
|
||||
match_sizehints(c);
|
||||
|
||||
if(!ignore_xcall)
|
||||
XMoveResizeWindow(dpy, c->framewin, px - (pi * rect.width) + c->frect.x, c->frect.y,
|
||||
c->frect.width, c->frect.height);
|
||||
|
||||
if((c->area->mode != Colstack) || (c->area->sel == client2index(c))) {
|
||||
c->rect.x = bw;
|
||||
c->rect.y = bh ? bh : bw;
|
||||
c->rect.width = c->frect.width - 2 * bw;
|
||||
c->rect.height = c->frect.height - bw - (bh ? bh : bw);
|
||||
c->rect.x = def.border;
|
||||
c->rect.y = bar_height();
|
||||
c->rect.width = c->frect.width - 2 * def.border;
|
||||
c->rect.height = c->frect.height - def.border - bar_height();
|
||||
XMoveResizeWindow(dpy, c->win, c->rect.x, c->rect.y, c->rect.width, c->rect.height);
|
||||
configure_client(c);
|
||||
}
|
||||
|
|
|
@ -126,18 +126,12 @@ handle_configurerequest(XEvent *e)
|
|||
XConfigureRequestEvent *ev = &e->xconfigurerequest;
|
||||
XWindowChanges wc;
|
||||
Client *c;
|
||||
unsigned int bw = 0, bh = 0;
|
||||
|
||||
c = win2client(ev->window);
|
||||
ev->value_mask &= ~CWSibling;
|
||||
|
||||
if(c) {
|
||||
if(c->area) {
|
||||
bw = def.border;
|
||||
bh = bar_height();
|
||||
}
|
||||
|
||||
gravitate(c, bh ? bh : bw, bw, 1);
|
||||
gravitate(c, True);
|
||||
|
||||
if(ev->value_mask & CWX)
|
||||
c->rect.x = ev->x;
|
||||
|
@ -150,13 +144,13 @@ handle_configurerequest(XEvent *e)
|
|||
if(ev->value_mask & CWBorderWidth)
|
||||
c->border = ev->border_width;
|
||||
|
||||
gravitate(c, bh ? bh : bw, bw, 0);
|
||||
gravitate(c, False);
|
||||
|
||||
if(c->area) {
|
||||
c->frect.x = wc.x = c->rect.x - bw;
|
||||
c->frect.y = wc.y = c->rect.y - (bh ? bh : bw);
|
||||
c->frect.width = wc.width = c->rect.width + 2 * bw;
|
||||
c->frect.height = wc.height = c->rect.height + bw + (bh ? bh : bw);
|
||||
c->frect.x = wc.x = c->rect.x - def.border;
|
||||
c->frect.y = wc.y = c->rect.y - bar_height();
|
||||
c->frect.width = wc.width = c->rect.width + 2 * def.border;
|
||||
c->frect.height = wc.height = c->rect.height + def.border + bar_height();
|
||||
wc.border_width = 1;
|
||||
wc.sibling = None;
|
||||
wc.stack_mode = ev->detail;
|
||||
|
@ -168,9 +162,8 @@ handle_configurerequest(XEvent *e)
|
|||
wc.x = ev->x;
|
||||
wc.y = ev->y;
|
||||
if(c && c->area) {
|
||||
/* if so, then bw and bh are already initialized */
|
||||
wc.x = bw;
|
||||
wc.y = (bh ? bh : bw);
|
||||
wc.x = def.border;
|
||||
wc.y = bar_height();
|
||||
}
|
||||
wc.width = ev->width;
|
||||
wc.height = ev->height;
|
||||
|
|
|
@ -13,24 +13,20 @@ Cursor
|
|||
cursor_for_motion(Client *c, int x, int y)
|
||||
{
|
||||
int n, e, w, s, tn, te, tw, ts;
|
||||
unsigned int bh, bw;
|
||||
|
||||
bw = def.border;
|
||||
bh = bar_height();
|
||||
|
||||
if(!bw)
|
||||
if(!def.border)
|
||||
return normal_cursor;
|
||||
|
||||
/* rectangle attributes of client are used */
|
||||
w = x < bw;
|
||||
e = x >= c->frect.width - bw;
|
||||
n = y < bw;
|
||||
s = y >= c->frect.height - bw;
|
||||
w = x < def.border;
|
||||
e = x >= c->frect.width - def.border;
|
||||
n = y < def.border;
|
||||
s = y >= c->frect.height - def.border;
|
||||
|
||||
tw = x < (bh ? bh : 2 * bw);
|
||||
te = x > c->frect.width - (bh ? bh : 2 * bw);
|
||||
tn = y < (bh ? bh : 2 * bw);
|
||||
ts = s > c->frect.height - (bh ? bh : 2 * bw);
|
||||
tw = x < bar_height();
|
||||
te = x > c->frect.width - bar_height();
|
||||
tn = y < bar_height();
|
||||
ts = s > c->frect.height - bar_height();
|
||||
|
||||
if((w && n) || (w && tn) || (n && tw))
|
||||
return nw_cursor;
|
||||
|
@ -53,7 +49,7 @@ cursor_for_motion(Client *c, int x, int y)
|
|||
}
|
||||
|
||||
Align
|
||||
xy2align(XRectangle * rect, int x, int y)
|
||||
xy2align(XRectangle *rect, int x, int y)
|
||||
{
|
||||
|
||||
int w = x <= rect->x + rect->width / 2;
|
||||
|
|
|
@ -215,7 +215,7 @@ void configure_client(Client *c);
|
|||
void handle_client_property(Client *c, XPropertyEvent *e);
|
||||
void kill_client(Client *c);
|
||||
void draw_client(Client *client);
|
||||
void gravitate(Client *c, unsigned int tabh, unsigned int bw, int invert);
|
||||
void gravitate(Client *c, Bool invert);
|
||||
void unmap_client(Client *c);
|
||||
void map_client(Client *c);
|
||||
void reparent_client(Client *c, Window w, int x, int y);
|
||||
|
|
Loading…
Reference in New Issue