[ALL] Fix bar status bug and some little things
This commit is contained in:
2
config.c
2
config.c
@@ -269,7 +269,7 @@ init_conf(void)
|
||||
conf.borderheight = cfg_getint(cfg_misc, "border_height");
|
||||
conf.ttbarheight = cfg_getint(cfg_misc, "titlebar_height");
|
||||
|
||||
if( strcmp( strdup(cfg_getstr(cfg_misc, "bar_position")) ,"top" ) == 0)
|
||||
if(strcmp(strdup(cfg_getstr(cfg_misc, "bar_position")) ,"top" ) == 0)
|
||||
conf.bartop = True;
|
||||
else
|
||||
conf.bartop = False;
|
||||
|
||||
3
event.c
3
event.c
@@ -98,7 +98,8 @@ buttonpress(XEvent ev)
|
||||
}
|
||||
/* layout switch */
|
||||
if(ev.xbutton.x >= taglen[conf.ntag] - 3
|
||||
&& ev.xbutton.x < taglen[conf.ntag] + TEXTW(getlayoutsym(seltag)))
|
||||
&& ev.xbutton.x < taglen[conf.ntag] +
|
||||
TEXTW(getlayoutsym(seltag)) - 3)
|
||||
{
|
||||
if(ev.xbutton.button == Button1
|
||||
|| ev.xbutton.button == Button4)
|
||||
|
||||
4
util.c
4
util.c
@@ -33,12 +33,12 @@
|
||||
#include "wmfs.h"
|
||||
|
||||
void*
|
||||
emallocz(unsigned int size)
|
||||
emalloc(unsigned int size)
|
||||
{
|
||||
void *res = calloc(1, size);
|
||||
|
||||
if(!res)
|
||||
fprintf(stderr,"fatal: could not malloc() %u bytes\n", size);
|
||||
fprintf(stderr,"WMFS Error: could not malloc() %u bytes\n", size);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
39
wmfs.c
39
wmfs.c
@@ -115,12 +115,9 @@ focus(Client *c)
|
||||
if(conf.ttbarheight)
|
||||
setborder(sel->tbar, conf.colors.bordernormal);
|
||||
}
|
||||
|
||||
if(c)
|
||||
grabbuttons(c, True);
|
||||
|
||||
sel = c;
|
||||
|
||||
if(c)
|
||||
{
|
||||
setborder(c->win, conf.colors.borderfocus);
|
||||
@@ -315,7 +312,7 @@ init(void)
|
||||
if(!font)
|
||||
{
|
||||
fprintf(stderr, "XLoadQueryFont: failed loading font '%s'\n", conf.font);
|
||||
exit(0);
|
||||
exit(0);
|
||||
}
|
||||
XSetFont(dpy, gc, font->fid);
|
||||
fonth = (font->ascent + font->descent) - 1;
|
||||
@@ -494,7 +491,7 @@ lowerclient(Client *c)
|
||||
void
|
||||
mainloop(void)
|
||||
{
|
||||
fd_set rd;
|
||||
fd_set fd;
|
||||
char sbuf[sizeof bartext], *p;
|
||||
int len, r, offset = 0;
|
||||
Bool readstdin = True;
|
||||
@@ -504,13 +501,13 @@ mainloop(void)
|
||||
|
||||
while(!exiting)
|
||||
{
|
||||
FD_ZERO(&rd);
|
||||
FD_ZERO(&fd);
|
||||
if(readstdin)
|
||||
FD_SET(STDIN_FILENO, &rd);
|
||||
FD_SET(ConnectionNumber(dpy), &rd);
|
||||
if(select(ConnectionNumber(dpy) + 1, &rd, NULL, NULL, NULL) == -1)
|
||||
FD_SET(STDIN_FILENO, &fd);
|
||||
FD_SET(ConnectionNumber(dpy), &fd);
|
||||
if(select(ConnectionNumber(dpy) + 1, &fd, NULL, NULL, NULL) == -1)
|
||||
printf("WARNING: Select failed\n");
|
||||
if(FD_ISSET(STDIN_FILENO, &rd)) {
|
||||
if(FD_ISSET(STDIN_FILENO, &fd)) {
|
||||
if((r = read(STDIN_FILENO, sbuf + offset, len - offset)))
|
||||
{
|
||||
for(p = sbuf + offset; r > 0; ++p, --r, ++offset)
|
||||
@@ -567,7 +564,7 @@ manage(Window w, XWindowAttributes *wa)
|
||||
Status rettrans;
|
||||
XWindowChanges winc;
|
||||
|
||||
c = emallocz(sizeof(Client));
|
||||
c = emalloc(sizeof(Client));
|
||||
c->win = w;
|
||||
c->x = wa->x;
|
||||
c->y = wa->y + conf.ttbarheight + barheight;
|
||||
@@ -782,7 +779,8 @@ nexttiled(Client *c)
|
||||
}
|
||||
|
||||
void
|
||||
quit(char *cmd) {
|
||||
quit(char *cmd)
|
||||
{
|
||||
exiting = True;
|
||||
return;
|
||||
}
|
||||
@@ -1177,13 +1175,12 @@ updatebar(void)
|
||||
{
|
||||
int i , k;
|
||||
char buf[conf.ntag][sizeof(char)];
|
||||
char *p = malloc(sizeof(char));
|
||||
char p[4];
|
||||
tm = localtime(<);
|
||||
lt = time(NULL);
|
||||
|
||||
XSetForeground(dpy, gc, conf.colors.bar);
|
||||
XFillRectangle(dpy, dr, gc, 0, 0, mw, barheight);
|
||||
|
||||
for(i = 0; i < conf.ntag; ++i)
|
||||
{
|
||||
/* Make the tags string */
|
||||
@@ -1202,7 +1199,7 @@ updatebar(void)
|
||||
|
||||
/* Draw layout symbol */
|
||||
XSetForeground(dpy, gc, conf.colors.layout_bg);
|
||||
XFillRectangle(dpy, dr, gc, taglen[conf.ntag] - 5, 0, TEXTW(getlayoutsym(seltag)) + 2, barheight);
|
||||
XFillRectangle(dpy, dr, gc, taglen[conf.ntag] - 5, 0, TEXTW(getlayoutsym(seltag)), barheight);
|
||||
XSetForeground(dpy, gc, conf.colors.layout_fg);
|
||||
XDrawString(dpy, dr, gc, taglen[conf.ntag] - 4,
|
||||
fonth,
|
||||
@@ -1210,21 +1207,19 @@ updatebar(void)
|
||||
strlen(getlayoutsym(seltag)));
|
||||
|
||||
/* Draw status */
|
||||
|
||||
k = TEXTW(bartext);
|
||||
XSetForeground(dpy, gc, conf.colors.text);
|
||||
XDrawString(dpy, dr, gc, mw - k, fonth-1, bartext, k);
|
||||
XDrawString(dpy, dr, gc, mw - k, fonth-1, bartext, strlen(bartext));
|
||||
XDrawLine(dpy, dr, gc, mw-k-5, 0, mw-k-5, barheight);
|
||||
|
||||
XCopyArea(dpy, dr, bar, gc, 0, 0, mw, barheight, 0, 0);
|
||||
XSync(dpy, False);
|
||||
|
||||
/* Update Bar Buttons */
|
||||
updatebutton(1);
|
||||
free(p);
|
||||
updatebutton(True);
|
||||
}
|
||||
|
||||
/* if c is 0, you can execute this function for the first time
|
||||
/* if c is False, you can execute this function for the first time
|
||||
* else the button is just updated */
|
||||
void
|
||||
updatebutton(Bool c)
|
||||
@@ -1244,8 +1239,6 @@ updatebutton(Bool c)
|
||||
if(!conf.bartop)
|
||||
y = bary + 3;
|
||||
|
||||
//XSetFont(dpy, gc, font_b->fid);
|
||||
|
||||
for(i = 0; i < conf.nbutton; ++i)
|
||||
{
|
||||
p = TEXTW(conf.barbutton[i].text);
|
||||
@@ -1279,7 +1272,6 @@ updatebutton(Bool c)
|
||||
conf.barbutton[i].text, strlen(conf.barbutton[i].text));
|
||||
}
|
||||
}
|
||||
XSetFont(dpy, gc, font->fid);
|
||||
XSync(dpy, False);
|
||||
return;
|
||||
}
|
||||
@@ -1408,7 +1400,6 @@ main(int argc,char **argv)
|
||||
init_conf();
|
||||
init();
|
||||
scan();
|
||||
updatebar();
|
||||
mainloop();
|
||||
|
||||
/* Exiting WMFS :'( */
|
||||
|
||||
3
wmfs.h
3
wmfs.h
@@ -68,6 +68,7 @@
|
||||
#define BUTH conf.ttbarheight - 6
|
||||
#define BUTX(x, w) x + w - BUTH/400
|
||||
#define TEXTW(x) XTextWidth(font, x, strlen(x)) + (fonth / 10)
|
||||
#define NLAYOUT 3
|
||||
|
||||
/* Client Structure */
|
||||
typedef struct Client Client;
|
||||
@@ -208,7 +209,7 @@ void unmapnotify(XEvent ev);
|
||||
void getevent(void);
|
||||
|
||||
/* util.c */
|
||||
void *emallocz(unsigned int size);
|
||||
void *emalloc(unsigned int size);
|
||||
void spawn(char *cmd);
|
||||
|
||||
/* wmfs.c */
|
||||
|
||||
Reference in New Issue
Block a user