Wmfs: Optimization & cosmetic

This commit is contained in:
Martin Duquesnoy 2011-06-04 20:27:27 +02:00
parent 82bea4cee8
commit 87b558b4b9
11 changed files with 121 additions and 143 deletions

View File

@ -90,7 +90,7 @@ cfactor_geo(XRectangle geo, int fact[4], int *err)
/* Too big/small */
if(cgeo.width > sgeo[selscreen].width || cgeo.height > sgeo[selscreen].height
|| cgeo.width < (BORDH * 2) || cgeo.height < (BORDH + TBARH))
|| cgeo.width < (BORDH << 1) || cgeo.height < (BORDH + TBARH))
{
*err = 1;
return geo;

View File

@ -202,8 +202,8 @@ client_get_next_with_direction(Client *bc, Position pos)
/* Start place of pointer for faster scanning */
x = bc->frame_geo.x + ((pos == Right) ? bc->frame_geo.width : 0);
y = bc->frame_geo.y + ((pos == Bottom) ? bc->frame_geo.height : 0);
y += ((LDIR(pos)) ? bc->frame_geo.height / 2 : 0);
x += ((pos > Left) ? bc->frame_geo.width / 2 : 0);
y += ((LDIR(pos)) ? (bc->frame_geo.height >> 1) : 0);
x += ((pos > Left) ? (bc->frame_geo.width >> 1) : 0);
/* Scan in right direction to next(p) physical client */
for(; (c = client_gb_pos(bc, x, y)) == bc; x += scanfac[pos][0], y += scanfac[pos][1]);
@ -229,8 +229,8 @@ client_above(Client *c)
geo.height = spgeo[c->screen].height * 0.75;
geo.width = spgeo[c->screen].width * 0.75;
geo.y = spgeo[c->screen].y + (spgeo[c->screen].height / 2) - (geo.height / 2);
geo.x = spgeo[c->screen].x + (spgeo[c->screen].width / 2)- (geo.width / 2);
geo.y = spgeo[c->screen].y + ((spgeo[c->screen].height - geo.height) >> 1);
geo.x = spgeo[c->screen].x + ((spgeo[c->screen].width - geo.width) >> 1);
client_moveresize(c, geo, (tags[c->screen][c->tag].flags & ResizeHintFlag));
client_raise(c);
@ -417,8 +417,8 @@ client_urgent(Client *c, Bool u)
{
Client *cc;
if(x < 0 || x > spgeo[c->screen].x + spgeo[c->screen].width
|| y < 0 || y > spgeo[c->screen].y + spgeo[c->screen].height)
if((x | y) < 0 || x > spgeo[c->screen].x + spgeo[c->screen].width
|| y > spgeo[c->screen].y + spgeo[c->screen].height)
return NULL;
for(cc = clients; cc; cc = cc->next)
@ -730,8 +730,8 @@ client_manage(Window w, XWindowAttributes *wa, Bool ar)
{
XRectangle tmp;
tmp = screen_get_geo(selscreen);
mx = (tmp.width + mx - wa->width) / 2;
my = (tmp.height + my - wa->height) / 2;
mx = (tmp.width + mx - wa->width) >> 1;
my = (tmp.height + my - wa->height) >> 1;
}
}
@ -804,8 +804,8 @@ client_manage(Window w, XWindowAttributes *wa, Bool ar)
/* Move pointer on client */
XQueryPointer(dpy, ROOT, &dw, &dw, &x, &y, &d, &d, (uint *)&d);
XWarpPointer(dpy, ROOT, ROOT, x, y, d, d,
c->geo.x + c->geo.width / 2,
c->geo.y + c->geo.height / 2);
c->geo.x + (c->geo.width >> 1),
c->geo.y + (c->geo.height >> 1));
}
return c;
@ -829,8 +829,7 @@ client_geo_hints(XRectangle *geo, Client *c)
geo->height -= c->baseh;
/* aspect */
if(c->minay > 0 && c->maxay > 0
&& c->minax > 0 && c->maxax > 0)
if((c->minay | c->maxay | c->minax | c->maxax) > 0)
{
if(geo->width * c->maxay > geo->height * c->maxax)
geo->width = geo->height * c->maxax / c->maxay;
@ -886,8 +885,8 @@ client_moveresize(Client *c, XRectangle geo, Bool r)
{
geo.x += conf.client.padding;
geo.y += conf.client.padding;
geo.width -= conf.client.padding * 2;
geo.height -= conf.client.padding * 2;
geo.width -= (conf.client.padding << 1);
geo.height -= (conf.client.padding << 1);
c->flags &= ~FLayFlag;
}
@ -902,7 +901,7 @@ client_moveresize(Client *c, XRectangle geo, Bool r)
client_geo_hints(&geo, c);
/* To balance position of window in frame */
rhx = ((c->wrgeo.width) - geo.width) / 2;
rhx = (((c->wrgeo.width) - geo.width) >> 1);
}
c->geo = geo;
@ -941,7 +940,7 @@ client_maximize(Client *c)
c->geo.x = sgeo[c->screen].x;
c->geo.y = sgeo[c->screen].y ;
c->geo.width = sgeo[c->screen].width - BORDH * 2;
c->geo.width = sgeo[c->screen].width - (BORDH << 1);
c->geo.height = sgeo[c->screen].height - BORDH;
client_moveresize(c, (c->pgeo = c->geo), (tags[c->screen][c->tag].flags & ResizeHintFlag));
@ -1276,8 +1275,8 @@ client_set_screen(Client *c, int s)
|| tags[os][seltag[os]].layout.func == freelayout
|| tags[os][seltag[os]].layout.func == maxlayout)
{
geo.x = (sgeo[s].x + sgeo[s].width / 2) - (c->geo.width / 2);
geo.y = (sgeo[s].y + sgeo[s].height / 2) - (c->geo.height / 2);
geo.x = ((sgeo[s].x + sgeo[s].width - c->geo.width) >> 1);
geo.y = ((sgeo[s].y + sgeo[s].height - c->geo.width) >> 1);
client_moveresize(c, geo, False);
}
@ -1344,11 +1343,7 @@ uicb_client_move(uicb_t cmd)
XRectangle geo;
int xi = 0, yi = 0;
if((sel->flags & TileFlag)
|| (sel->flags & MaxFlag)
|| (sel->flags & LMaxFlag)
|| (sel->flags & FSSFlag)
|| !sel)
if(!sel || sel->flags & (TileFlag | MaxFlag | LMaxFlag | FSSFlag))
return;
geo = sel->geo;
@ -1373,11 +1368,7 @@ uicb_client_resize(uicb_t cmd)
XRectangle geo;
int wi = 0, hi = 0;
if((sel->flags & TileFlag)
|| (sel->flags & MaxFlag)
|| (sel->flags & LMaxFlag)
|| (sel->flags & FSSFlag)
|| !sel)
if(!sel || sel->flags & (TileFlag | MaxFlag | LMaxFlag | FSSFlag))
return;
geo = sel->geo;
@ -1431,8 +1422,8 @@ uicb_client_select(uicb_t cmd)
/* Move pointer on client */
XQueryPointer(dpy, ROOT, &w, &w, &x, &y, &d, &d, (uint *)&d);
XWarpPointer(dpy, ROOT, ROOT, x, y, d, d,
clist_index[i].client->geo.x + clist_index[i].client->geo.width / 2,
clist_index[i].client->geo.y + clist_index[i].client->geo.height / 2);
clist_index[i].client->geo.x + (clist_index[i].client->geo.width >> 1),
clist_index[i].client->geo.y + (clist_index[i].client->geo.height >> 1));
}
return;

View File

@ -46,7 +46,7 @@ static void draw_image(Drawable dr, int x, int y, int w, int h, char *name)
if(!name)
return;
imlib_set_cache_size(2048 * 1024);
imlib_set_cache_size(2048 << 10);
imlib_context_set_display(dpy);
imlib_context_set_visual(DefaultVisual(dpy, DefaultScreen(dpy)));
imlib_context_set_colormap(DefaultColormap(dpy, DefaultScreen(dpy)));

View File

@ -87,8 +87,8 @@ frame_create(Client *c)
for(i = 0; i < conf.titlebar.nbutton; ++i)
{
CWIN(c->button[i], c->titlebar->win,
(c->button_last_x = (BORDH + (BUTTONWH * i) + (4 * i))),
((BUTTONWH - 1) / 2), BUTTONWH, BUTTONWH,
(c->button_last_x = (BORDH + (BUTTONWH * i) + (i << 2))),
((BUTTONWH - 1) >> 1), BUTTONWH, BUTTONWH,
1, CWEventMask|CWOverrideRedirect|CWBackPixmap,
c->colors.frame, &at);
@ -254,8 +254,8 @@ frame_update(Client *c)
if(conf.titlebar.nbutton && BUTTONWH >= 1)
{
if(conf.titlebar.stipple.active)
draw_rectangle(c->titlebar->dr, 0, 0, c->button_last_x + TBARH - (TBARH / 4),
TBARH + BORDH * 2, c->colors.frame);
draw_rectangle(c->titlebar->dr, 0, 0, c->button_last_x + TBARH - (TBARH >> 2),
TBARH + (BORDH << 2), c->colors.frame);
for(i = 0; i < conf.titlebar.nbutton; ++i)
{
@ -265,8 +265,8 @@ frame_update(Client *c)
if((!conf.titlebar.button[i].flags)
|| ((conf.titlebar.button[i].flags & FreeFlag)
&& ((c->flags & FreeFlag) || !(c->flags & (TileFlag | LMaxFlag))))
|| ((conf.titlebar.button[i].flags & MaxFlag)
&& ((c->flags & MaxFlag) || (c->flags & LMaxFlag)))
|| ((conf.titlebar.button[i].flags & MaxFlag)
&& ((c->flags & MaxFlag) || (c->flags & LMaxFlag)))
|| ((conf.titlebar.button[i].flags & TileFlag) && (c->flags & TileFlag)))
{
@ -312,9 +312,9 @@ frame_update(Client *c)
if(TBARH - BORDH)
barwin_draw_text(c->titlebar,
(c->frame_geo.width / 2) - (textw(c->title) / 2),
((font->height - font->descent) + (TBARH - font->height) / 2),
c->title);
(c->frame_geo.width >> 1) - (textw(c->title) >> 1),
((font->height - font->descent) + ((TBARH - font->height) / 2)),
c->title);
return;
}

View File

@ -54,7 +54,7 @@ infobar_init(void)
case IB_Hide:
sgeo[sc].y = spgeo[sc].y + TBARH;
sgeo[sc].height += INFOBARH;
infobar[sc].geo.y = -(infobar[sc].geo.height) * 2;
infobar[sc].geo.y = (-(infobar[sc].geo.height) << 2);
break;
case IB_Bottom:
sgeo[sc].y = TBARH;
@ -94,7 +94,7 @@ infobar_init(void)
/* Create layout switch barwindow */
infobar[sc].layout_button = barwin_create(infobar[sc].bar->win,
((conf.layout_placement) ? 0 : (j + PAD / 2)), 0,
((conf.layout_placement) ? 0 : (j + (PAD >> 1))), 0,
((conf.layout_button_width > 0) ? (uint)conf.layout_button_width : (textw(tags[sc][seltag[sc]].layout.symbol) + PAD)),
infobar[sc].geo.height,
conf.colors.layout_bg, conf.colors.layout_fg,
@ -104,8 +104,8 @@ infobar_init(void)
if(conf.bars.selbar)
infobar[sc].selbar = barwin_create(infobar[sc].bar->win,
((conf.layout_placement)
? (j + PAD / 2)
: infobar[sc].layout_button->geo.x + infobar[sc].layout_button->geo.width + PAD / 2), 1,
? (j + (PAD >> 1))
: infobar[sc].layout_button->geo.x + infobar[sc].layout_button->geo.width + (PAD >> 1)), 1,
(sel) ? textw(sel->title) + PAD : 1,
infobar[sc].geo.height - 2,
conf.selbar.bg, conf.selbar.fg, False, False, False);
@ -142,13 +142,13 @@ static void
infobar_draw_layout(int sc)
{
if(!conf.layout_placement)
barwin_move(infobar[sc].layout_button, infobar[sc].tags_board->geo.width + PAD / 2, 0);
barwin_move(infobar[sc].layout_button, infobar[sc].tags_board->geo.width + (PAD >> 1), 0);
barwin_resize(infobar[sc].layout_button, ((conf.layout_button_width > 0) ? (uint)conf.layout_button_width : (textw(tags[sc][seltag[sc]].layout.symbol) + PAD)), infobar[sc].geo.height);
barwin_refresh_color(infobar[sc].layout_button);
if(tags[sc][seltag[sc]].layout.symbol)
barwin_draw_text(infobar[sc].layout_button, PAD / 2, FHINFOBAR, tags[sc][seltag[sc]].layout.symbol);
barwin_draw_text(infobar[sc].layout_button, (PAD >> 1), FHINFOBAR, tags[sc][seltag[sc]].layout.symbol);
return;
}
@ -201,11 +201,11 @@ infobar_draw_selbar(int sc)
barwin_move(infobar[sc].selbar,
((conf.layout_placement)
? (infobar[sc].tags_board->geo.x + infobar[sc].tags_board->geo.width + PAD / 2)
: (infobar[sc].layout_button->geo.x + infobar[sc].layout_button->geo.width + PAD / 2)), 1);
? (infobar[sc].tags_board->geo.x + infobar[sc].tags_board->geo.width + (PAD >> 1))
: (infobar[sc].layout_button->geo.x + infobar[sc].layout_button->geo.width + (PAD >> 1))), 1);
barwin_refresh_color(infobar[sc].selbar);
barwin_draw_text(infobar[sc].selbar, PAD / 2, FHINFOBAR - 1, ((str) ? str : sel->title));
barwin_draw_text(infobar[sc].selbar, (PAD >> 1), FHINFOBAR - 1, ((str) ? str : sel->title));
barwin_refresh(infobar[sc].selbar);
@ -225,7 +225,7 @@ infobar_draw_taglist(int sc)
Bool is_occupied[MAXTAG + 1];
if(conf.layout_placement)
barwin_move(infobar[sc].tags_board, ((conf.layout_button_width > 0) ? (uint)conf.layout_button_width : (textw(tags[sc][seltag[sc]].layout.symbol) + PAD)) + PAD / 2, 0);
barwin_move(infobar[sc].tags_board, ((conf.layout_button_width > 0) ? (uint)conf.layout_button_width : (textw(tags[sc][seltag[sc]].layout.symbol) + PAD)) + (PAD >> 1), 0);
for(i = 0; i < MAXTAG; i++)
is_occupied[i] = False;
@ -276,7 +276,7 @@ infobar_draw_taglist(int sc)
barwin_refresh_color(infobar[sc].tags[i]);
if(tags[sc][i].name)
barwin_draw_text(infobar[sc].tags[i], PAD / 2, FHINFOBAR, tags[sc][i].name);
barwin_draw_text(infobar[sc].tags[i], (PAD >> 1), FHINFOBAR, tags[sc][i].name);
}
return;
@ -362,7 +362,7 @@ infobar_set_position(int pos)
case IB_Hide:
sgeo[selscreen].y = spgeo[selscreen].y + TBARH;
sgeo[selscreen].height = spgeo[selscreen].height - TBARH;
infobar[selscreen].geo.y = -(infobar[selscreen].geo.height) * 2;
infobar[selscreen].geo.y = (-(infobar[selscreen].geo.height) << 1);
break;
case IB_Bottom:
sgeo[selscreen].y = spgeo[selscreen].y + TBARH;

View File

@ -173,12 +173,9 @@ uicb_layout_prev(uicb_t cmd)
Client*
tiled_client(int screen, Client *c)
{
for(;c && ((c->flags & MaxFlag)
|| (c->flags & FreeFlag)
|| (c->flags & FSSFlag)
|| (c->flags & AboveFlag)
|| c->screen != screen
|| ishide(c, screen)); c = c->next);
for(;c && ((c->flags & (MaxFlag | FreeFlag | FSSFlag | AboveFlag))
|| c->screen != screen
|| ishide(c, screen)); c = c->next);
if(c)
c->flags |= FLayFlag;
@ -269,7 +266,7 @@ grid(int screen, Bool horizontal)
for(n = 0, c = tiled_client(screen, clients); c; c = tiled_client(screen, c->next), ++n);
CHECK((tags[screen][seltag[screen]].nclients = n));
for(rows = 0; rows <= n / 2; ++rows)
for(rows = 0; rows <= (n >> 1); ++rows)
if(rows * rows >= n)
break;
@ -293,7 +290,7 @@ grid(int screen, Bool horizontal)
cfactor_clean(c);
cgeo.width = (sg.width / cols) - (BORDH * 2);
cgeo.width = (sg.width / cols) - (BORDH << 1);
cgeo.height = (sg.height / rows) - BORDH;
/* Last row's and last client remainder */
@ -302,7 +299,7 @@ grid(int screen, Bool horizontal)
/* Last column's client remainder */
if(i >= rows * (cols - 1))
cgeo.width = sg.width - (cgeo.x - (sg.x - (BORDH * 2)));
cgeo.width = sg.width - (cgeo.x - (sg.x - (BORDH << 1)));
/* Resize */
client_moveresize(c, (c->pgeo = cgeo), (tags[screen][seltag[screen]].flags & ResizeHintFlag));
@ -313,7 +310,7 @@ grid(int screen, Bool horizontal)
if(cpcols + 1 > rows)
{
cpcols = 0;
cgeo.x = c->pgeo.x + c->pgeo.width + (BORDH * 2);
cgeo.x = c->pgeo.x + c->pgeo.width + (BORDH << 1);
cgeo.y = sg.y;
}
}
@ -348,28 +345,27 @@ multi_tile(int screen, Position type)
: tags[screen][seltag[screen]].mwfact * sg.width;
/* MASTER SIZE */
if(type == Top || type == Bottom)
if(LDIR(type))
{
if(type == Top)
mastergeo.y = (n <= nmaster) ? (uint)sg.y : sg.y + (sg.height - mwfact) - BORDH;
mastergeo.width = (sg.width / nmaster) - (BORDH * 4);
mastergeo.height = (n <= nmaster) ? (uint)(sg.height - BORDH) : mwfact;
if(type == Left)
mastergeo.x = (n <= nmaster) ? (uint)sg.x : (sg.x + sg.width) - mwfact - (BORDH << 1);
mastergeo.width = (n <= nmaster) ? (uint)(sg.width - (BORDH << 1)) : mwfact;
mastergeo.height = (sg.height / nmaster) - BORDH;
}
else
{
if(type == Left)
mastergeo.x = (n <= nmaster) ? (uint)sg.x : (sg.x + sg.width) - mwfact - (BORDH * 2);
mastergeo.width = (n <= nmaster) ? (uint)(sg.width - (BORDH * 2)) : mwfact;
mastergeo.height = (sg.height / nmaster) - BORDH;
if(type == Top)
mastergeo.y = (n <= nmaster) ? (uint)sg.y : sg.y + (sg.height - mwfact) - BORDH;
mastergeo.width = (sg.width / nmaster) - (BORDH << 2);
mastergeo.height = (n <= nmaster) ? (uint)(sg.height - BORDH) : mwfact;
}
/* TILED SIZE */
if(n > nmaster)
{
if(type == Top || type == Bottom)
tilesize = sg.width / (n - nmaster) - (BORDH * 4);
if(LDIR(type))
tilesize = sg.height / (n - nmaster) - ((BORDH << 1) + TBARH);
else
tilesize = sg.height / (n - nmaster) - ((BORDH * 2) + TBARH);
tilesize = sg.width / (n - nmaster) - (BORDH << 2);
}
@ -387,13 +383,13 @@ multi_tile(int screen, Position type)
cgeo.width = mastergeo.width;
cgeo.height = mastergeo.height;
if(type == Top || type == Bottom)
cgeo.y = mastergeo.y;
else
if(LDIR(type))
{
cgeo.x = mastergeo.x;
cgeo.height -= (TBARH + BORDH);
}
else
cgeo.y = mastergeo.y;
}
/* TILED */
@ -414,40 +410,40 @@ multi_tile(int screen, Position type)
break;
default:
case Right:
cgeo.x += mastergeo.width + (BORDH * 2);
cgeo.x += mastergeo.width + (BORDH << 1);
cgeo.y = sg.y;
break;
}
}
if(type == Top || type == Bottom)
if(LDIR(type))
{
cgeo.width = tilesize;
cgeo.height = sg.height - mastergeo.height - TBARH - (BORDH * 2);
cgeo.width = sg.width - mastergeo.width - (BORDH << 2);
cgeo.height = tilesize;
}
else
{
cgeo.width = sg.width - mastergeo.width - (BORDH * 4);
cgeo.height = tilesize;
cgeo.width = tilesize;
cgeo.height = sg.height - mastergeo.height - TBARH - (BORDH << 1);
}
}
/* REMAINDER */
if(i + 1 == n || i + 1 == (n < nmaster ? n : nmaster))
{
if(type == Top || type == Bottom)
cgeo.width = sg.width - (cgeo.x - (sg.x - (BORDH * 2)));
else
if(LDIR(type))
cgeo.height = (sg.y + sg.height) - cgeo.y - BORDH;
else
cgeo.width = sg.width - (cgeo.x - (sg.x - (BORDH << 1)));
}
/* Magic instant */
client_moveresize(c, (c->pgeo = cgeo), (tags[screen][seltag[screen]].flags & ResizeHintFlag));
/* Set the position of the next client */
if(type == Top || type == Bottom)
cgeo.x = c->pgeo.x + c->pgeo.width + (BORDH * 2);
else
if(LDIR(type))
cgeo.y = c->pgeo.y + c->pgeo.height + BORDH + TBARH;
else
cgeo.x = c->pgeo.x + c->pgeo.width + (BORDH << 1);
}
tags[screen][seltag[screen]].flags &= ~CleanFactFlag;
@ -481,8 +477,8 @@ mirror(int screen, Bool horizontal)
/* Fix nmaster */
nmaster = (n < nmaster) ? n : nmaster;
imp = ((n - (nmaster - 1)) / 2);
pa = ((n - (nmaster - 1)) / 2) - (((n - (nmaster - 1)) % 2) ? 0 : 1);
imp = ((n - (nmaster - 1)) >> 1);
pa = ((n - (nmaster - 1)) >> 1) - (((n - (nmaster - 1)) & 1) ? 0 : 1);
/* Set mwfact */
if(tags[screen][seltag[screen]].mwfact < 0.55)
@ -493,26 +489,26 @@ mirror(int screen, Bool horizontal)
/* Master size */
if(horizontal)
{
mastergeo.width = (sg.width / nmaster) - (BORDH * 2);
mastergeo.width = (sg.width / nmaster) - (BORDH << 1);
mastergeo.height -= BORDH;
}
else
{
mastergeo.width -= BORDH * 2;
mastergeo.height = (sg.height / nmaster) - (TBARH + (BORDH * 2));
mastergeo.width -= (BORDH << 1);
mastergeo.height = (sg.height / nmaster) - (TBARH + (BORDH << 1));
}
if(n == nmaster + 1)
{
if(horizontal)
{
mastergeo.height = mwfact - ((BORDH * 2) + TBARH);
tilesize = (sg.height - mastergeo.height) - ((BORDH * 2) + TBARH);
mastergeo.height = mwfact - ((BORDH << 1) + TBARH);
tilesize = (sg.height - mastergeo.height) - ((BORDH << 1) + TBARH);
}
else
{
mastergeo.width = mwfact - (BORDH * 3);
tilesize = (sg.width - mastergeo.width) - (BORDH * 4);
tilesize = (sg.width - mastergeo.width) - (BORDH << 2);
}
}
if(n > nmaster + 1)
@ -520,13 +516,13 @@ mirror(int screen, Bool horizontal)
if(horizontal)
{
mastergeo.y = (sg.y + (sg.height - mwfact)) + TBARH + BORDH;
mastergeo.height = (2 * mwfact - sg.height) - ((BORDH * 3) + (TBARH * 2));
tilesize = (mwfact - mastergeo.height) - ((BORDH * 3) + (TBARH * 2));
mastergeo.height = ((mwfact << 1) - sg.height) - ((BORDH * 3) + (TBARH << 1));
tilesize = (mwfact - mastergeo.height) - ((BORDH * 3) + (TBARH << 1));
}
else
{
mastergeo.x = (sg.x + (sg.width - mwfact)) + BORDH;
mastergeo.width = ((2 * mwfact - sg.width) - (BORDH * 4));
mastergeo.width = ((mwfact << 1) - sg.width) - (BORDH << 2);
tilesize = (mwfact - mastergeo.width) - (BORDH * 5);
}
}
@ -547,7 +543,7 @@ mirror(int screen, Bool horizontal)
if(i + 1 == nmaster)
{
if(horizontal)
cgeo.width = (sg.x + sg.width) - (cgeo.x + (BORDH * 2));
cgeo.width = (sg.x + sg.width) - (cgeo.x + (BORDH << 1));
else
cgeo.height = (sg.y + sg.height) - (cgeo.y + BORDH);
}
@ -566,12 +562,12 @@ mirror(int screen, Bool horizontal)
if(horizontal)
{
cgeo.y = sg.y;
cgeo.width = (sg.width / pa) - (BORDH * 2);
cgeo.width = (sg.width / pa) - (BORDH << 1);
}
else
{
cgeo.x = sg.x;
cgeo.height = (sg.height / pa) - (TBARH + (BORDH * 2));
cgeo.height = (sg.height / pa) - (TBARH + (BORDH << 1));
}
}
else
@ -581,12 +577,12 @@ mirror(int screen, Bool horizontal)
if(horizontal)
{
cgeo.y = (sg.y + mwfact) - BORDH;
cgeo.width = (sg.width / imp) - (BORDH * 2);
cgeo.width = (sg.width / imp) - (BORDH << 1);
}
else
{
cgeo.x = (sg.x + mwfact) - BORDH;
cgeo.height = (sg.height / imp) - (TBARH + (BORDH * 2));
cgeo.height = (sg.height / imp) - (TBARH + (BORDH << 1));
}
}
@ -594,7 +590,7 @@ mirror(int screen, Bool horizontal)
if(i + 1 == n || i + 1 == n - 1)
{
if(horizontal)
cgeo.width = (sg.x + sg.width) - (cgeo.x + (BORDH * 2));
cgeo.width = (sg.x + sg.width) - (cgeo.x + (BORDH << 1));
else
cgeo.height = (sg.y + sg.height) - (cgeo.y + BORDH);
}
@ -613,7 +609,7 @@ mirror(int screen, Bool horizontal)
if(i == nmaster || i == nmaster - 1)
cgeo.x = sg.x;
else
cgeo.x = nextg[isp].x + nextg[isp].width + BORDH * 2;
cgeo.x = nextg[isp].x + nextg[isp].width + (BORDH << 1);
}
else
{
@ -626,9 +622,9 @@ mirror(int screen, Bool horizontal)
else if (i <= nmaster - 1)
{
if(horizontal)
mastergeo.x = c->geo.x + c->geo.width + BORDH * 2;
mastergeo.x = cgeo.x + cgeo.width + (BORDH << 1);
else
mastergeo.y = c->geo.y + c->geo.height + BORDH + TBARH;
mastergeo.y = cgeo.y + cgeo.height + BORDH + TBARH;
}
}
@ -719,10 +715,6 @@ grid_vertical(int screen)
return;
}
/** Put the selected client to the master postion
* \param cmd uicb_t type unused
*/
/** Toggle the selected client to free
* \param cmd uicb_t type unused
*/
@ -766,8 +758,7 @@ uicb_togglemax(uicb_t cmd)
{
(void)cmd;
if(!sel || ishide(sel, selscreen)
|| (sel->flags & HintFlag)|| (sel->flags & FSSFlag))
if(!sel || ishide(sel, selscreen) || (sel->flags & (HintFlag | FSSFlag)))
return;
sel->flags ^= MaxFlag;
@ -883,8 +874,7 @@ layout_set_client_master(Client *c)
{
screen_get_sel();
if(!c || (c->flags & HintFlag) || !(c->flags & TileFlag)
|| (c->flags & FSSFlag))
if(!c || (c->flags & (HintFlag | FSSFlag)) || !(c->flags & TileFlag))
return;
if(c == tiled_client(selscreen, clients))

View File

@ -40,8 +40,8 @@ static void
mouse_dragborder(XRectangle geo, GC g)
{
XDrawRectangle(dpy, ROOT, g,
geo.x - BORDH / 2,
geo.y - (TBARH - (BORDH / 2)),
geo.x - (BORDH >> 1),
geo.y - (TBARH - (BORDH >> 1)),
geo.width + BORDH,
geo.height + TBARH);
@ -228,7 +228,7 @@ mouse_resize(Client *c)
XQueryPointer(dpy, ROOT, &w, &w, &omx, &omy, &d, &d, (uint *)&u);
if((omx - c->geo.x) < (c->geo.width / 2))
if((omx - c->geo.x) < (c->geo.width >> 1))
pos = Left;
if(XGrabPointer(dpy, ROOT, False, MouseMask, GrabModeAsync, GrabModeAsync, None,
@ -267,12 +267,12 @@ mouse_resize(Client *c)
{
mouse_cfactor_border(c, f, gci);
if(omx >= c->frame_geo.x + (c->frame_geo.width / 2))
if(omx >= c->frame_geo.x + (c->frame_geo.width >> 1))
f[Right] = ev.xmotion.x_root - omx;
else
f[Left] = omx - ev.xmotion.x_root;
if(omy >= c->frame_geo.y + (c->frame_geo.height / 2))
if(omy >= c->frame_geo.y + (c->frame_geo.height >> 1))
f[Bottom] = ev.xmotion.y_root - omy;
else
f[Top] = omy - ev.xmotion.y_root;

View File

@ -106,14 +106,14 @@ screen_get_geo(int s)
int
screen_get_with_geo(int x, int y)
{
int i, r = 0;
int i;
for(i = 0; i < screen_count(); ++i)
if((x >= spgeo[i].x && x < spgeo[i].x + spgeo[i].width)
&& y >= spgeo[i].y && y < spgeo[i].y + spgeo[i].height)
r = i;
return i;
return r;
return 0;
}
/** Set the selected screen
@ -130,8 +130,8 @@ screen_set_sel(int screen)
client_focus(NULL);
XWarpPointer(dpy, None, ROOT, 0, 0, 0, 0,
sgeo[screen].x + sgeo[screen].width / 2,
sgeo[screen].y + sgeo[screen].height / 2);
sgeo[screen].x + (sgeo[screen].width >> 1),
sgeo[screen].y + (sgeo[screen].height >> 1));
selscreen = screen;

View File

@ -242,9 +242,9 @@ split_client(Client *c, Bool p)
/* Vertical */
if(p)
{
geo.width /= 2;
geo.width >>= 1;
sgeo.x = FRAMEW(geo.x + geo.width);
sgeo.width = (sgeo.width / 2) - (BORDH * 2);
sgeo.width = (sgeo.width >> 1) - (BORDH << 1);
/* Remainder */
sgeo.width += (c->wrgeo.x + c->wrgeo.width) - (sgeo.x + sgeo.width);
@ -252,9 +252,9 @@ split_client(Client *c, Bool p)
/* Horizontal */
else
{
geo.height = (geo.height / 2) - TBARH;
geo.height = (geo.height >> 1) - TBARH;
sgeo.y = FRAMEH(geo.y + geo.height);
sgeo.height = (sgeo.height / 2) - BORDH;
sgeo.height = (sgeo.height >> 1) - BORDH;
/* Remainder */
sgeo.height += (c->wrgeo.y + c->wrgeo.height) - (sgeo.y + sgeo.height);
@ -294,8 +294,7 @@ split_client_integrate(Client *c, Client *sc, int screen, int tag)
Bool b = True;
XRectangle g;
if(!c || c->flags & FreeFlag
|| !(tags[screen][tag].flags & SplitFlag))
if(!c || c->flags & FreeFlag || !(tags[screen][tag].flags & SplitFlag))
return;
/* Can't integrate in sc */

View File

@ -350,8 +350,7 @@ tag_swap(int s, int t1, int t2)
Client *c;
Tag t;
if(t1 > conf.ntag[s] || t1 < 1
|| t2 > conf.ntag[s] || t2 < 1 || t1 == t2)
if(t1 == t2 || (t1 & t2) < 1 || (t1 | t2) > conf.ntag[s])
return;
t = tags[s][t1];
@ -378,6 +377,8 @@ tag_swap(int s, int t1, int t2)
void
uicb_tag_stay_last(uicb_t cmd)
{
int i;
(void)cmd;
screen_get_sel();
@ -387,13 +388,10 @@ uicb_tag_stay_last(uicb_t cmd)
else
{
int i;
remove_old_last_tag(selscreen);
for(i = seltag[selscreen]; i <= conf.ntag[selscreen]; i++)
{
tag_swap(selscreen, seltag[selscreen], seltag[selscreen] + 1);
}
tag_set(conf.ntag[selscreen]);
tags[selscreen][seltag[selscreen]].flags |= StayLastFlag;
@ -506,8 +504,8 @@ uicb_tag_urgent(uicb_t cmd)
void
tag_additional(int sc, int tag, int adtag)
{
if(tag < 0 || tag > conf.ntag[sc]
|| adtag < 1 || adtag > conf.ntag[sc] || adtag == seltag[sc])
if(tag < 0 || (tag | adtag) > conf.ntag[sc]
|| adtag < 1 || adtag == seltag[sc])
return;
if(tags[sc][tag].flags & SplitFlag)

View File

@ -103,7 +103,7 @@
} while (/* CONSTCOND */ 0)
#define ATOM(a) XInternAtom(dpy, (a), False)
#define FRAMEW(w) ((w) + BORDH * 2)
#define FRAMEW(w) ((w) + (BORDH << 1))
#define FRAMEH(h) ((h) + (BORDH + TBARH))
#define ROUND(x) (float)((x > 0) ? x + (float)0.5 : x - (float)0.5)
#define CHECK(x) if(!(x)) return