titlebar: Fix size and position in frame.c, fix layout with these changes
This commit is contained in:
parent
73d90d6c8f
commit
0d60b5dd90
@ -266,7 +266,7 @@ barwin_refresh_color(BarWindow *bw)
|
||||
if(bw->stipple)
|
||||
{
|
||||
XSetForeground(dpy, gc_stipple, getcolor(bw->fg));
|
||||
XFillRectangle(dpy, bw->dr, gc_stipple, 3, 2, bw->geo.width - 6, bw->geo.height - 6);
|
||||
XFillRectangle(dpy, bw->dr, gc_stipple, 3, 2, bw->geo.width - 6, bw->geo.height - 4);
|
||||
}
|
||||
|
||||
if(bw->bord)
|
||||
|
||||
14
src/client.c
14
src/client.c
@ -207,7 +207,7 @@ client_focus(Client *c)
|
||||
{
|
||||
Client *c;
|
||||
|
||||
if(!TBARH)
|
||||
if(!(TBARH - BORDH))
|
||||
return NULL;
|
||||
|
||||
for(c = clients; c && c->titlebar->win != w; c = c->next);
|
||||
@ -238,6 +238,9 @@ client_focus(Client *c)
|
||||
Client *c;
|
||||
int i;
|
||||
|
||||
if(!BUTTONWH)
|
||||
return NULL;
|
||||
|
||||
for(c = clients; c; c = c->next)
|
||||
for(i = 0; i < conf.titlebar.nbutton; ++i)
|
||||
if(c->button[i] == w)
|
||||
@ -372,7 +375,7 @@ client_map(Client *c)
|
||||
|
||||
XMapWindow(dpy, c->frame);
|
||||
XMapSubwindows(dpy, c->frame);
|
||||
if(TBARH)
|
||||
if(TBARH - BORDH)
|
||||
{
|
||||
barwin_map(c->titlebar);
|
||||
barwin_map_subwin(c->titlebar);
|
||||
@ -533,7 +536,8 @@ client_moveresize(Client *c, XRectangle geo, Bool r)
|
||||
|
||||
frame_moveresize(c, c->geo);
|
||||
|
||||
XMoveResizeWindow(dpy, c->win, BORDH, BORDH + TBARH, c->geo.width, c->geo.height);
|
||||
XMoveResizeWindow(dpy, c->win, BORDH, TBARH, c->geo.width,
|
||||
c->geo.height);
|
||||
|
||||
client_configure(c);
|
||||
|
||||
@ -557,7 +561,7 @@ client_maximize(Client *c)
|
||||
geo.x = sgeo[c->screen].x;
|
||||
geo.y = sgeo[c->screen].y;
|
||||
geo.width = sgeo[c->screen].width - BORDH * 2;
|
||||
geo.height = sgeo[c->screen].height - BORDH * 2;
|
||||
geo.height = sgeo[c->screen].height - BORDH;
|
||||
|
||||
|
||||
if(c->state_fullscreen)
|
||||
@ -795,7 +799,7 @@ client_unmap(Client *c)
|
||||
{
|
||||
CHECK(c);
|
||||
|
||||
if(TBARH)
|
||||
if(TBARH - BORDH)
|
||||
{
|
||||
barwin_unmap_subwin(c->titlebar);
|
||||
barwin_unmap(c->titlebar);
|
||||
|
||||
29
src/frame.c
29
src/frame.c
@ -69,25 +69,26 @@ frame_create(Client *c)
|
||||
CWOverrideRedirect|CWBackPixmap|CWEventMask,
|
||||
c->colors.frame, &at);
|
||||
|
||||
|
||||
/* Create titlebar window */
|
||||
if(TBARH)
|
||||
if(TBARH - BORDH)
|
||||
{
|
||||
c->titlebar = barwin_create(c->frame, 0, 0,
|
||||
c->frame_geo.width ,
|
||||
TBARH + BORDH * 2,
|
||||
TBARH,
|
||||
c->colors.frame,
|
||||
c->colors.fg,
|
||||
True, conf.titlebar.stipple, False);
|
||||
|
||||
/* Buttons */
|
||||
if(BUTTONWH)
|
||||
if(BUTTONWH >= 1)
|
||||
{
|
||||
c->button = emalloc(conf.titlebar.nbutton, sizeof(Window));
|
||||
for(i = 0; i < conf.titlebar.nbutton; ++i)
|
||||
{
|
||||
CWIN(c->button[i], c->titlebar->win,
|
||||
(BORDH + (BUTTONWH * i) + (4 * i)),
|
||||
(((TBARH + BORDH) - BUTTONWH) / 2), BUTTONWH, BUTTONWH,
|
||||
((BUTTONWH - 1) / 2), BUTTONWH, BUTTONWH,
|
||||
1, CWEventMask|CWOverrideRedirect|CWBackPixmap,
|
||||
c->colors.frame, &at);
|
||||
|
||||
@ -95,7 +96,7 @@ frame_create(Client *c)
|
||||
|
||||
/* Save the position of the last button to draw the font rectangle (frame_update) */
|
||||
if(i == conf.titlebar.nbutton - 1)
|
||||
c->button_last_x = (BORDH + (BUTTONWH * i) + (4 * i)) + TBARH + 1;
|
||||
c->button_last_x = (BORDH + (BUTTONWH * i) + (4 * i)) + TBARH;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -122,7 +123,7 @@ frame_create(Client *c)
|
||||
}
|
||||
|
||||
/* Reparent window with the frame */
|
||||
XReparentWindow(dpy, c->win, c->frame, BORDH, BORDH + TBARH);
|
||||
XReparentWindow(dpy, c->win, c->frame, BORDH, TBARH);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -134,7 +135,7 @@ void
|
||||
frame_delete(Client *c)
|
||||
{
|
||||
/* If there is, delete the titlebar */
|
||||
if(TBARH)
|
||||
if(TBARH - BORDH)
|
||||
{
|
||||
barwin_delete_subwin(c->titlebar);
|
||||
barwin_delete(c->titlebar);
|
||||
@ -169,8 +170,8 @@ frame_moveresize(Client *c, XRectangle geo)
|
||||
c->frame_geo.height);
|
||||
|
||||
/* Titlebar */
|
||||
if(TBARH)
|
||||
barwin_resize(c->titlebar, c->frame_geo.width, TBARH + BORDH * 2);
|
||||
if(TBARH - BORDH)
|
||||
barwin_resize(c->titlebar, c->frame_geo.width, TBARH);
|
||||
|
||||
/* Resize area */
|
||||
XMoveWindow(dpy, c->resize, c->frame_geo.width - RESHW, c->frame_geo.height - RESHW);
|
||||
@ -194,11 +195,11 @@ frame_moveresize(Client *c, XRectangle geo)
|
||||
void
|
||||
frame_update(Client *c)
|
||||
{
|
||||
int i ;
|
||||
int i ;
|
||||
|
||||
CHECK(c);
|
||||
|
||||
if(TBARH)
|
||||
if(TBARH - BORDH)
|
||||
{
|
||||
c->titlebar->bg = c->colors.frame;
|
||||
c->titlebar->fg = c->colors.fg;
|
||||
@ -206,7 +207,7 @@ frame_update(Client *c)
|
||||
barwin_refresh_color(c->titlebar);
|
||||
|
||||
/* Buttons */
|
||||
if(conf.titlebar.nbutton && BUTTONWH)
|
||||
if(conf.titlebar.nbutton && BUTTONWH >= 1)
|
||||
{
|
||||
draw_rectangle(c->titlebar->dr, 0, 0, c->button_last_x,
|
||||
TBARH + BORDH * 2, c->colors.frame);
|
||||
@ -241,10 +242,10 @@ frame_update(Client *c)
|
||||
XClearWindow(dpy, c->bottom);
|
||||
}
|
||||
|
||||
if(TBARH && (TBARH + BORDH + 1) > font->height)
|
||||
if((TBARH - BORDH) && (TBARH + BORDH + 1) > font->height)
|
||||
barwin_draw_text(c->titlebar,
|
||||
(c->frame_geo.width / 2) - (textw(c->title) / 2),
|
||||
(font->height - (font->descent)) + (((TBARH + BORDH) - font->height) / 2),
|
||||
((font->height - font->descent) + (TBARH - font->height) / 2),
|
||||
c->title);
|
||||
|
||||
return;
|
||||
|
||||
38
src/layout.c
38
src/layout.c
@ -50,7 +50,6 @@ arrange(int screen)
|
||||
|
||||
tags[screen][seltag[screen]].layout.func(screen);
|
||||
infobar_draw(screen);
|
||||
// infobar_set_position(tags[screen][seltag[screen]].barpos);
|
||||
|
||||
return;
|
||||
}
|
||||
@ -220,7 +219,6 @@ grid(int screen)
|
||||
XRectangle sg = sgeo[screen];
|
||||
XRectangle cgeo = {sg.x, sg.y, 0, 0};
|
||||
unsigned int i, n, cols, rows, cpcols = 0;
|
||||
unsigned int border = BORDH * 2;
|
||||
|
||||
for(n = 0, c = tiled_client(screen, clients); c; c = tiled_client(screen, c->next), ++n);
|
||||
CHECK(n);
|
||||
@ -239,26 +237,26 @@ grid(int screen)
|
||||
c->max = c->lmax = False;
|
||||
c->tile = True;
|
||||
++cpcols;
|
||||
cgeo.width = (sg.width / cols) - border;
|
||||
cgeo.height = (sg.height / rows) - border;
|
||||
cgeo.width = (sg.width / cols) - (BORDH * 2);
|
||||
cgeo.height = (sg.height / rows) - BORDH;
|
||||
|
||||
/* Last row's and last client remainder */
|
||||
if(cpcols == rows || i + 1 == n)
|
||||
cgeo.height = sg.y + sg.height - cgeo.y - border;
|
||||
cgeo.height = sg.y + sg.height - cgeo.y - BORDH;
|
||||
|
||||
/* Last column's client remainder */
|
||||
if(i >= rows * (cols - 1))
|
||||
cgeo.width = sg.width - (cgeo.x - (sg.x - border));
|
||||
cgeo.width = sg.width - (cgeo.x - (sg.x - (BORDH * 2)));
|
||||
|
||||
/* Resize */
|
||||
client_moveresize(c, cgeo, tags[screen][seltag[screen]].resizehint);
|
||||
|
||||
/* Set all the other size with current client info */
|
||||
cgeo.y = c->geo.y + c->geo.height + border + TBARH;
|
||||
cgeo.y = c->geo.y + c->geo.height + BORDH + TBARH;
|
||||
if(cpcols + 1 > rows)
|
||||
{
|
||||
cpcols = 0;
|
||||
cgeo.x = c->geo.x + c->geo.width + border;
|
||||
cgeo.x = c->geo.x + c->geo.width + (BORDH * 2);
|
||||
cgeo.y = sg.y;
|
||||
}
|
||||
}
|
||||
@ -296,25 +294,25 @@ multi_tile(int screen, Position type)
|
||||
if(type == Top || type == Bottom)
|
||||
{
|
||||
if(type == Top)
|
||||
mastergeo.y = (n <= nmaster) ? sg.y : sg.y + (sg.height - mwfact) - border;
|
||||
mastergeo.y = (n <= nmaster) ? sg.y : sg.y + (sg.height - mwfact) - BORDH;
|
||||
mastergeo.width = (sg.width / nmaster) - (border * 2);
|
||||
mastergeo.height = (n <= nmaster) ? sg.height - border : mwfact;
|
||||
mastergeo.height = (n <= nmaster) ? sg.height - BORDH : mwfact;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(type == Left)
|
||||
mastergeo.x = (n <= nmaster) ? sg.x : (sg.x + sg.width) - mwfact - border;
|
||||
mastergeo.width = (n <= nmaster) ? sg.width - border : mwfact;
|
||||
mastergeo.height = (sg.height / nmaster) - border;
|
||||
mastergeo.height = (sg.height / nmaster) - BORDH;
|
||||
}
|
||||
|
||||
/* TILED SIZE */
|
||||
if(n > nmaster)
|
||||
{
|
||||
if(type == Top || type == Bottom)
|
||||
tilesize = sg.width / (n - nmaster) - border;
|
||||
tilesize = sg.width / (n - nmaster) - (border * 2);
|
||||
else
|
||||
tilesize = sg.height / (n - nmaster) - border;
|
||||
tilesize = sg.height / (n - nmaster) - (border + TBARH);
|
||||
}
|
||||
|
||||
|
||||
@ -335,7 +333,7 @@ multi_tile(int screen, Position type)
|
||||
else
|
||||
{
|
||||
cgeo.x = mastergeo.x;
|
||||
cgeo.height -= (TBARH + border);
|
||||
cgeo.height -= (TBARH + BORDH);
|
||||
}
|
||||
}
|
||||
|
||||
@ -352,7 +350,7 @@ multi_tile(int screen, Position type)
|
||||
cgeo.x = sg.x;
|
||||
break;
|
||||
case Bottom:
|
||||
cgeo.y += mastergeo.height + TBARH + border;
|
||||
cgeo.y += mastergeo.height + TBARH + BORDH;
|
||||
cgeo.x = sg.x;
|
||||
break;
|
||||
default:
|
||||
@ -365,14 +363,12 @@ multi_tile(int screen, Position type)
|
||||
if(type == Top || type == Bottom)
|
||||
{
|
||||
cgeo.width = tilesize;
|
||||
cgeo.width -= border;
|
||||
cgeo.height = sg.height - mastergeo.height - TBARH - border*2;
|
||||
cgeo.height = sg.height - mastergeo.height - TBARH - border;
|
||||
}
|
||||
else
|
||||
{
|
||||
cgeo.width = sg.width - mastergeo.width - border*2;
|
||||
cgeo.width = sg.width - mastergeo.width - border * 2;
|
||||
cgeo.height = tilesize;
|
||||
cgeo.height -= border + TBARH;
|
||||
}
|
||||
}
|
||||
|
||||
@ -382,7 +378,7 @@ multi_tile(int screen, Position type)
|
||||
if(type == Top || type == Bottom)
|
||||
cgeo.width = sg.width - (cgeo.x - (sg.x - border));
|
||||
else
|
||||
cgeo.height = (sg.y + sg.height) - cgeo.y - border;
|
||||
cgeo.height = (sg.y + sg.height) - cgeo.y - BORDH;
|
||||
}
|
||||
|
||||
/* Magic instant */
|
||||
@ -392,7 +388,7 @@ multi_tile(int screen, Position type)
|
||||
if(type == Top || type == Bottom)
|
||||
cgeo.x = c->geo.x + c->geo.width + border;
|
||||
else
|
||||
cgeo.y = c->geo.y + c->geo.height + border + TBARH;
|
||||
cgeo.y = c->geo.y + c->geo.height + BORDH + TBARH;
|
||||
}
|
||||
|
||||
ewmh_get_current_layout();
|
||||
|
||||
@ -78,11 +78,11 @@
|
||||
#define SHADH 1
|
||||
#define SHADC 0x000000 /* 'Cause i don't know how darken a color yet */
|
||||
#define BORDH conf.client.borderheight
|
||||
#define TBARH conf.titlebar.height
|
||||
#define TBARH ((conf.titlebar.height < BORDH) ? BORDH : conf.titlebar.height)
|
||||
#define FRAMEW(w) ((w) + BORDH * 2)
|
||||
#define FRAMEH(h) ((h) + (BORDH * 2) + TBARH)
|
||||
#define FRAMEH(h) ((h) + (BORDH + TBARH))
|
||||
#define RESHW (5 * BORDH)
|
||||
#define BUTTONWH (TBARH - 4)
|
||||
#define BUTTONWH (TBARH / 2)
|
||||
#define CHECK(x) if(!(x)) return
|
||||
#define IFREE(x) if(x) free(x)
|
||||
#define LEN(x) (sizeof(x) / sizeof((x)[0]))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user