[ALL] Add xprint function and some things..
This commit is contained in:
parent
8e426423e8
commit
3f5d307045
12
layout.c
12
layout.c
@ -77,7 +77,7 @@ layoutswitch(Bool b)
|
||||
}
|
||||
|
||||
void
|
||||
uicb_layout_next(char *cmd)
|
||||
uicb_layout_next(uicb_t cmd)
|
||||
{
|
||||
layoutswitch(True);
|
||||
|
||||
@ -85,7 +85,7 @@ uicb_layout_next(char *cmd)
|
||||
}
|
||||
|
||||
void
|
||||
uicb_layout_prev(char *cmd)
|
||||
uicb_layout_prev(uicb_t cmd)
|
||||
{
|
||||
layoutswitch(False);
|
||||
|
||||
@ -125,7 +125,7 @@ nexttiled(Client *c)
|
||||
}
|
||||
|
||||
void
|
||||
uicb_set_mwfact(char *cmd)
|
||||
uicb_set_mwfact(uicb_t cmd)
|
||||
{
|
||||
double c;
|
||||
|
||||
@ -142,7 +142,7 @@ uicb_set_mwfact(char *cmd)
|
||||
}
|
||||
|
||||
void
|
||||
uicb_set_nmaster(char *cmd)
|
||||
uicb_set_nmaster(uicb_t cmd)
|
||||
{
|
||||
int n = atoi(cmd);
|
||||
|
||||
@ -229,7 +229,7 @@ tile(void)
|
||||
}
|
||||
|
||||
void
|
||||
uicb_tile_switch(char *cmd)
|
||||
uicb_tile_switch(uicb_t cmd)
|
||||
{
|
||||
Client *c;
|
||||
|
||||
@ -247,7 +247,7 @@ uicb_tile_switch(char *cmd)
|
||||
}
|
||||
|
||||
void
|
||||
uicb_togglemax(char *cmd)
|
||||
uicb_togglemax(uicb_t cmd)
|
||||
{
|
||||
if(!sel || ishide(sel) || sel->hint)
|
||||
return;
|
||||
|
||||
8
tag.c
8
tag.c
@ -36,7 +36,7 @@
|
||||
/* if cmd is +X or -X, this is just switch
|
||||
* else {1, 2.. 9} it's go to the wanted tag. */
|
||||
void
|
||||
uicb_tag(char *cmd)
|
||||
uicb_tag(uicb_t cmd)
|
||||
{
|
||||
int tmp = atoi(cmd);
|
||||
|
||||
@ -63,7 +63,7 @@ uicb_tag(char *cmd)
|
||||
}
|
||||
|
||||
void
|
||||
uicb_tag_next(char *cmd)
|
||||
uicb_tag_next(uicb_t cmd)
|
||||
{
|
||||
uicb_tag("+1");
|
||||
|
||||
@ -71,7 +71,7 @@ uicb_tag_next(char *cmd)
|
||||
}
|
||||
|
||||
void
|
||||
uicb_tag_prev(char *cmd)
|
||||
uicb_tag_prev(uicb_t cmd)
|
||||
{
|
||||
uicb_tag("-1");
|
||||
|
||||
@ -79,7 +79,7 @@ uicb_tag_prev(char *cmd)
|
||||
}
|
||||
|
||||
void
|
||||
uicb_tagtransfert(char *cmd)
|
||||
uicb_tagtransfert(uicb_t cmd)
|
||||
{
|
||||
int n = atoi(cmd);
|
||||
|
||||
|
||||
15
util.c
15
util.c
@ -55,7 +55,7 @@ getcolor(char *color)
|
||||
}
|
||||
|
||||
void
|
||||
uicb_spawn(char *cmd)
|
||||
uicb_spawn(uicb_t cmd)
|
||||
{
|
||||
if(!strlen(cmd))
|
||||
return;
|
||||
@ -74,3 +74,16 @@ uicb_spawn(char *cmd)
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void
|
||||
xprint(Drawable d, int x, int y, char *str,
|
||||
unsigned int fg,unsigned int bg,
|
||||
int dec1,int dec2)
|
||||
{
|
||||
XSetForeground(dpy, gc, bg);
|
||||
XFillRectangle(dpy, d, gc, x - dec1, 0, TEXTW(str) - dec2, barheight);
|
||||
XSetForeground(dpy, gc, fg);
|
||||
XDrawString(dpy, d, gc, x, y, str, strlen(str));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
69
wmfs.c
69
wmfs.c
@ -116,7 +116,7 @@ client_switch(Bool b)
|
||||
}
|
||||
|
||||
void
|
||||
uicb_client_prev(char *cmd)
|
||||
uicb_client_prev(uicb_t cmd)
|
||||
{
|
||||
client_switch(False);
|
||||
|
||||
@ -124,7 +124,7 @@ uicb_client_prev(char *cmd)
|
||||
}
|
||||
|
||||
void
|
||||
uicb_client_next(char *cmd)
|
||||
uicb_client_next(uicb_t cmd)
|
||||
{
|
||||
client_switch(True);
|
||||
|
||||
@ -194,7 +194,7 @@ focus(Client *c)
|
||||
else
|
||||
XSetInputFocus(dpy, root, RevertToPointerRoot, CurrentTime);
|
||||
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
Client*
|
||||
@ -430,7 +430,7 @@ ishide(Client *c)
|
||||
}
|
||||
|
||||
void
|
||||
uicb_killclient(char *cmd)
|
||||
uicb_killclient(uicb_t cmd)
|
||||
{
|
||||
XEvent ev;
|
||||
|
||||
@ -466,7 +466,7 @@ mainloop(void)
|
||||
FD_SET(STDIN_FILENO, &fd);
|
||||
FD_SET(ConnectionNumber(dpy), &fd);
|
||||
if(select(ConnectionNumber(dpy) + 1, &fd, NULL, NULL, NULL) == -1)
|
||||
printf("WMFS Warning: Select failed\n");
|
||||
fprintf(stderr, "WMFS Warning: Select failed\n");
|
||||
if(FD_ISSET(STDIN_FILENO, &fd))
|
||||
{
|
||||
if((r = read(STDIN_FILENO, sbuf + offset, len - offset)))
|
||||
@ -711,7 +711,7 @@ moveresize(Client *c, int x, int y, int w, int h, bool r)
|
||||
}
|
||||
|
||||
void
|
||||
uicb_quit(char *cmd)
|
||||
uicb_quit(uicb_t cmd)
|
||||
{
|
||||
exiting = True;
|
||||
|
||||
@ -851,7 +851,7 @@ setsizehints(Client *c)
|
||||
}
|
||||
|
||||
void
|
||||
uicb_togglebarpos(char *cmd)
|
||||
uicb_togglebarpos(uicb_t cmd)
|
||||
{
|
||||
int i;
|
||||
|
||||
@ -867,6 +867,7 @@ uicb_togglebarpos(char *cmd)
|
||||
updatebutton(False);
|
||||
for(i = 0; i < conf.nbutton; ++i)
|
||||
XMapWindow(dpy, conf.barbutton[i].win);
|
||||
|
||||
arrange();
|
||||
|
||||
return;
|
||||
@ -948,30 +949,21 @@ updatebar(void)
|
||||
sprintf(buf[i], "%s<%s> ", tags[i+1].name, (clientpertag(i+1)) ? p : "");
|
||||
taglen[i+1] = taglen[i] + TEXTW(buf[i]);
|
||||
|
||||
/* Rectangle for the tag background */
|
||||
XSetForeground(dpy, gc, (i+1 == seltag) ? conf.colors.tagselbg : conf.colors.bar);
|
||||
XFillRectangle(dpy, dr, gc, taglen[i] - 3, 0, TEXTW(buf[i]) - 3, barheight);
|
||||
|
||||
/* Draw tag */
|
||||
XSetForeground(dpy, gc, (i+1 == seltag) ? conf.colors.tagselfg : conf.colors.text);
|
||||
XDrawString(dpy, dr, gc, taglen[i], fonth, buf[i], strlen(buf[i]));
|
||||
/* Draw tags */
|
||||
xprint(dr, taglen[i], fonth, buf[i],
|
||||
((i+1 == seltag) ? conf.colors.tagselfg : conf.colors.text),
|
||||
((i+1 == seltag) ? conf.colors.tagselbg : conf.colors.bar), 3, 3);
|
||||
}
|
||||
|
||||
/* Draw layout symbol */
|
||||
XSetForeground(dpy, gc, conf.colors.layout_bg);
|
||||
XFillRectangle(dpy, dr, gc, taglen[conf.ntag] - 5, 0,
|
||||
TEXTW(strdup(tags[seltag].layout.symbol)),
|
||||
barheight);
|
||||
XSetForeground(dpy, gc, conf.colors.layout_fg);
|
||||
XDrawString(dpy, dr, gc, taglen[conf.ntag] - 4,
|
||||
fonth,
|
||||
tags[seltag].layout.symbol,
|
||||
strlen(tags[seltag].layout.symbol));
|
||||
/* Layout symbol */
|
||||
xprint(dr, taglen[conf.ntag] - 4,
|
||||
fonth, tags[seltag].layout.symbol,
|
||||
conf.colors.layout_fg, conf.colors.layout_bg, 1, -1);
|
||||
|
||||
/* Draw status */
|
||||
/* Draw status text */
|
||||
k = TEXTW(bartext);
|
||||
XSetForeground(dpy, gc, conf.colors.text);
|
||||
XDrawString(dpy, dr, gc, mw - k, fonth-1, bartext, strlen(bartext));
|
||||
xprint(dr, mw-k, fonth - 1, bartext,
|
||||
conf.colors.text, conf.colors.bar, 0, 0);
|
||||
XDrawLine(dpy, dr, gc, mw-k-5, 0, mw-k-5, barheight);
|
||||
|
||||
XCopyArea(dpy, dr, bar, gc, 0, 0, mw, barheight, 0, 0);
|
||||
@ -1023,17 +1015,16 @@ updatebutton(Bool c)
|
||||
CWOverrideRedirect | CWBackPixmap | CWEventMask, &at);
|
||||
XSetWindowBackground(dpy, conf.barbutton[i].win, conf.barbutton[i].bg_color);
|
||||
XMapRaised(dpy, conf.barbutton[i].win);
|
||||
XSetForeground(dpy, gc, conf.barbutton[i].fg_color);
|
||||
XDrawString(dpy, conf.barbutton[i].win, gc, 1, fonth_l, conf.barbutton[i].text, p);
|
||||
xprint(conf.barbutton[i].win, 1, fonth_l, conf.barbutton[i].text,
|
||||
conf.barbutton[i].fg_color, conf.barbutton[i].bg_color, 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!conf.barbutton[i].win)
|
||||
return;
|
||||
XSetForeground(dpy, gc, conf.barbutton[i].fg_color);
|
||||
XMoveWindow(dpy, conf.barbutton[i].win, x, y);
|
||||
XDrawString(dpy, conf.barbutton[i].win, gc, 1, fonth_l,
|
||||
conf.barbutton[i].text, strlen(conf.barbutton[i].text));
|
||||
xprint(conf.barbutton[i].win, 1, fonth_l, conf.barbutton[i].text,
|
||||
conf.barbutton[i].fg_color, conf.barbutton[i].bg_color, 0, 0);
|
||||
}
|
||||
}
|
||||
XSync(dpy, False);
|
||||
@ -1067,19 +1058,15 @@ updatetitle(Client *c)
|
||||
if(conf.ttbarheight > 10)
|
||||
{
|
||||
XClearWindow(dpy, c->tbar);
|
||||
XSetForeground(dpy, gc, conf.colors.text);
|
||||
XDrawString(dpy, c->tbar, gc, 3,
|
||||
((fonth-2) + ((conf.ttbarheight - fonth) / 2)),
|
||||
c->title, strlen(c->title));
|
||||
xprint(c->tbar, 3, ((fonth-2) + ((conf.ttbarheight - fonth) / 2)),
|
||||
c->title, conf.colors.text, conf.colors.bar, 0, 0);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
dpy = XOpenDisplay(NULL);
|
||||
int i;
|
||||
|
||||
static struct option long_options[] = {
|
||||
@ -1090,7 +1077,7 @@ main(int argc, char **argv)
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
while ((i = getopt_long (argc, argv, "hvi", long_options, NULL)) != -1)
|
||||
while ((i = getopt_long(argc, argv, "hvi", long_options, NULL)) != -1)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
@ -1119,9 +1106,9 @@ main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if(!dpy)
|
||||
if(!(dpy = XOpenDisplay(NULL)))
|
||||
{
|
||||
printf("WMFS: cannot open X server.\n");
|
||||
fprintf(stderr, "WMFS: cannot open X server.\n");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
||||
44
wmfs.h
44
wmfs.h
@ -58,7 +58,7 @@
|
||||
#define KeyMask (KeyPressMask | KeyReleaseMask)
|
||||
#define ALT Mod1Mask
|
||||
#define ITOA(p ,n) sprintf(p, "%i", n)
|
||||
#define debug(p) printf("debug: %i\n", p)
|
||||
#define debug(p) fprintf(stderr, "debug: %i\n", p)
|
||||
#define MAXTAG 36
|
||||
#define NBUTTON 5
|
||||
#define BUTY(y) y - conf.ttbarheight + 3
|
||||
@ -67,7 +67,8 @@
|
||||
#define TEXTW(x) XTextWidth(font, x, strlen(x)) + (fonth / 10)
|
||||
#define MAXLAYOUT 3
|
||||
|
||||
/* Client Structure */
|
||||
/* Client Structure & Typedef */
|
||||
typedef const char* uicb_t;
|
||||
typedef struct Client Client;
|
||||
struct Client
|
||||
{
|
||||
@ -95,7 +96,7 @@ typedef struct
|
||||
{
|
||||
unsigned long mod;
|
||||
KeySym keysym;
|
||||
void (*func)(char *cmd);
|
||||
void (*func)(uicb_t);
|
||||
char *cmd;
|
||||
} Key;
|
||||
|
||||
@ -108,7 +109,7 @@ typedef struct
|
||||
int bg_color;
|
||||
unsigned int x;
|
||||
int nmousesec;
|
||||
void (*func[NBUTTON])(char *cmd);
|
||||
void (*func[NBUTTON])(uicb_t);
|
||||
char *cmd[NBUTTON];
|
||||
unsigned int mouse[NBUTTON];
|
||||
} BarButton;
|
||||
@ -209,13 +210,16 @@ void getevent(void);
|
||||
/* util.c */
|
||||
void *emalloc(unsigned int elemet, unsigned int size);
|
||||
unsigned long getcolor(char *color);
|
||||
void uicb_spawn(char *cmd);
|
||||
void uicb_spawn(uicb_t cmd);
|
||||
void xprint(Drawable d, int x, int y, char *str,
|
||||
unsigned int fg, unsigned int bg,
|
||||
int dec1, int dec2);
|
||||
|
||||
/* tag.c */
|
||||
void uicb_tag(char *cmd);
|
||||
void uicb_tag_next(char *cmd);
|
||||
void uicb_tag_prev(char *cmd);
|
||||
void uicb_tagtransfert(char *cmd);
|
||||
void uicb_tag(uicb_t cmd);
|
||||
void uicb_tag_next(uicb_t cmd);
|
||||
void uicb_tag_prev(uicb_t cmd);
|
||||
void uicb_tagtransfert(uicb_t cmd);
|
||||
|
||||
/* layout.c */
|
||||
void freelayout(void);
|
||||
@ -223,12 +227,12 @@ void layoutswitch(Bool b);
|
||||
void maxlayout(void);
|
||||
Client* nexttiled(Client *c);
|
||||
void tile(void);
|
||||
void uicb_tile_switch(char *cmd);
|
||||
void uicb_togglemax(char *cmd);
|
||||
void uicb_layout_prev(char *cmd);
|
||||
void uicb_layout_next(char *cmd);
|
||||
void uicb_set_mwfact(char *cmd);
|
||||
void uicb_set_nmaster(char *cmd);
|
||||
void uicb_tile_switch(uicb_t cmd);
|
||||
void uicb_togglemax(uicb_t cmd);
|
||||
void uicb_layout_prev(uicb_t cmd);
|
||||
void uicb_layout_next(uicb_t cmd);
|
||||
void uicb_set_mwfact(uicb_t cmd);
|
||||
void uicb_set_nmaster(uicb_t cmd);
|
||||
|
||||
/* wmfs.c */
|
||||
void arrange(void);
|
||||
@ -265,11 +269,11 @@ void updatebutton(Bool c);
|
||||
void unmapclient(Client *c);
|
||||
void updateall(void);
|
||||
void updatetitle(Client *c);
|
||||
void uicb_client_prev(char *cmd);
|
||||
void uicb_client_next(char *cmd);
|
||||
void uicb_killclient(char *cmd);
|
||||
void uicb_quit(char *cmd);
|
||||
void uicb_togglebarpos(char *cmd);
|
||||
void uicb_client_prev(uicb_t cmd);
|
||||
void uicb_client_next(uicb_t cmd);
|
||||
void uicb_killclient(uicb_t cmd);
|
||||
void uicb_quit(uicb_t cmd);
|
||||
void uicb_togglebarpos(uicb_t cmd);
|
||||
|
||||
/* Variables */
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user