aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgotmor <gotmor@f2baff5b-bf2c-0410-a398-912abdc3d8b2>2009-02-02 01:44:07 +0000
committergotmor <gotmor@f2baff5b-bf2c-0410-a398-912abdc3d8b2>2009-02-02 01:44:07 +0000
commit487a15633b9706bf44a18e7ff484e63c0311f347 (patch)
treeb9acce99348b034e9d691783660e0e57e271cd33
parentba251b7444fd9fa0a38b065ad5ca9b00028022c4 (diff)
downloaddzen-487a15633b9706bf44a18e7ff484e63c0311f347.tar.gz
dzen-487a15633b9706bf44a18e7ff484e63c0311f347.zip
correct handling of '-geometry' and '-y' options for dzen at
the bottom of the screen cosmetic code clean ups Courtesy of Valery V. Vorotyntsev git-svn-id: http://dzen.googlecode.com/svn/trunk@240 f2baff5b-bf2c-0410-a398-912abdc3d8b2
-rw-r--r--CREDITS4
-rw-r--r--Makefile2
-rw-r--r--TODO17
-rw-r--r--action.c61
-rw-r--r--config.mk14
-rw-r--r--draw.c172
-rw-r--r--main.c246
7 files changed, 261 insertions, 255 deletions
diff --git a/CREDITS b/CREDITS
index 0a194ed..294655c 100644
--- a/CREDITS
+++ b/CREDITS
@@ -22,4 +22,8 @@ Mauke <mauke at ...>
Alexander V. Inyukhin <shurick at sectorb dot msk dot ru>
* fix to action handling
+Valery V. Vorotyntsev <valery dot vv at gmail.com>
+ * patch to correctly handle the -geometry and -y options for
+ dzen at the bottom of the screen
+ * cosmetic code clean ups
diff --git a/Makefile b/Makefile
index ec24d53..478d6f0 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-# dzen2
+# dzen2
# (C)opyright MMVII Robert Manea
include config.mk
diff --git a/TODO b/TODO
index b4348c3..57c1a20 100644
--- a/TODO
+++ b/TODO
@@ -1,8 +1,13 @@
+# documentation
+
+ o `-dock' and `-geometry' options are undocumented
+
+
# X related
o XRandR support (MEDIUM PRIORITY)
- o cache XPM files in order to improve drawing
- performace (HIGH PRIORITY)
+ o cache XPM files in order to improve drawing
+ performace (HIGH PRIORITY, done in svn trunk)
# extend available actions
@@ -13,7 +18,7 @@
# user interface
- o improve in-text command to draw
- to the title window (MEDIUM PRIORITY)
- o auto fit window width to
- text length (MEDIUM PRIORITY)
+ o improve in-text command to draw
+ to the title window (MEDIUM PRIORITY, done in svn trunk)
+ o auto fit window width to
+ text length (MEDIUM PRIORITY, done in svn trunk)
diff --git a/action.c b/action.c
index 7d4c63e..103f45f 100644
--- a/action.c
+++ b/action.c
@@ -1,4 +1,4 @@
-/*
+/*
* (C)opyright MMVII Robert Manea <rob dot manea at gmail dot com>
* See LICENSE file for license details.
*
@@ -63,7 +63,7 @@ struct action_lookup ac_lookup_table[] = {
ev_list *head = NULL;
-static int
+static int
new_event(long evid) {
ev_list *item, *newitem;
@@ -71,7 +71,7 @@ new_event(long evid) {
head = emalloc(sizeof (ev_list));
head->id = evid;
head->next = NULL;
- }
+ }
else {
item = head;
/* check if we already handle this event */
@@ -132,7 +132,7 @@ find_event(long evid) {
item = head;
while(item) {
- if(item->id == evid)
+ if(item->id == evid)
return item->id;
item = item->next;
}
@@ -207,9 +207,9 @@ void
fill_ev_table(char *input) {
char *str1, *str2, *str3, *str4,
*token, *subtoken, *kommatoken, *dptoken;
- char *saveptr1=NULL,
- *saveptr2=NULL,
- *saveptr3=NULL,
+ char *saveptr1=NULL,
+ *saveptr2=NULL,
+ *saveptr3=NULL,
*saveptr4=NULL;
int j, i=0, k=0;
long eid=0;
@@ -257,7 +257,7 @@ fill_ev_table(char *input) {
}
new_event(eid);
add_handler(eid, i, NULL);
- i=0;
+ i=0;
}
}
}
@@ -266,7 +266,7 @@ fill_ev_table(char *input) {
/* actions */
int
a_exit(char * opt[]) {
- if(opt[0])
+ if(opt[0])
dzen.ret_val = atoi(opt[0]);
dzen.running = False;
return 0;
@@ -275,8 +275,8 @@ a_exit(char * opt[]) {
int
a_collapse(char * opt[]){
(void)opt;
- if(!dzen.slave_win.ishmenu
- && dzen.slave_win.max_lines
+ if(!dzen.slave_win.ishmenu
+ && dzen.slave_win.max_lines
&& !dzen.slave_win.issticky) {
XUnmapWindow(dzen.dpy, dzen.slave_win.win);
}
@@ -287,8 +287,8 @@ int
a_uncollapse(char * opt[]){
int i;
(void)opt;
- if(!dzen.slave_win.ishmenu
- && dzen.slave_win.max_lines
+ if(!dzen.slave_win.ishmenu
+ && dzen.slave_win.max_lines
&& !dzen.slave_win.issticky) {
XMapRaised(dzen.dpy, dzen.slave_win.win);
for(i=0; i < dzen.slave_win.max_lines; i++)
@@ -302,7 +302,7 @@ a_togglecollapse(char * opt[]){
XWindowAttributes wa;
(void)opt;
- if(dzen.slave_win.max_lines &&
+ if(dzen.slave_win.max_lines &&
(XGetWindowAttributes(dzen.dpy, dzen.slave_win.win, &wa), wa.map_state == IsUnmapped))
a_uncollapse(NULL);
else
@@ -314,7 +314,7 @@ a_togglecollapse(char * opt[]){
int
a_stick(char * opt[]) {
(void)opt;
- if(!dzen.slave_win.ishmenu
+ if(!dzen.slave_win.ishmenu
&& dzen.slave_win.max_lines)
dzen.slave_win.issticky = True;
return 0;
@@ -323,7 +323,7 @@ a_stick(char * opt[]) {
int
a_unstick(char * opt[]) {
(void)opt;
- if(!dzen.slave_win.ishmenu
+ if(!dzen.slave_win.ishmenu
&& dzen.slave_win.max_lines)
dzen.slave_win.issticky = False;
return 0;
@@ -349,7 +349,7 @@ scroll(int n) {
else if(dzen.slave_win.last_line_vis + n > dzen.slave_win.tcnt) {
dzen.slave_win.first_line_vis = dzen.slave_win.tcnt - dzen.slave_win.max_lines;
dzen.slave_win.last_line_vis = dzen.slave_win.tcnt;
- }
+ }
else {
dzen.slave_win.first_line_vis += n;
dzen.slave_win.last_line_vis += n;
@@ -362,9 +362,9 @@ int
a_scrollup(char * opt[]) {
int n=1;
- if(opt[0])
+ if(opt[0])
n = atoi(opt[0]);
- if(dzen.slave_win.max_lines)
+ if(dzen.slave_win.max_lines)
scroll(-1*n);
return 0;
@@ -374,7 +374,7 @@ int
a_scrolldown(char * opt[]) {
int n=1;
- if(opt[0])
+ if(opt[0])
n = atoi(opt[0]);
if(dzen.slave_win.max_lines)
scroll(n);
@@ -414,8 +414,8 @@ int
a_togglehide(char * opt[]) {
(void)opt;
- dzen.title_win.ishidden ?
- a_unhide(NULL) :
+ dzen.title_win.ishidden ?
+ a_unhide(NULL) :
a_hide(NULL);
return 0;
@@ -425,8 +425,8 @@ int
a_exec(char * opt[]) {
int i;
- if(opt)
- for(i=0; opt[i]; i++)
+ if(opt)
+ for(i=0; opt[i]; i++)
if(opt[i]) spawn(opt[i]);
return 0;
}
@@ -435,7 +435,7 @@ int
a_print(char * opt[]) {
int i;
- if(opt)
+ if(opt)
for(i=0; opt[i]; i++)
puts(opt[i]);
return 0;
@@ -446,7 +446,7 @@ a_menuprint(char * opt[]) {
char *text;
(void)opt;
- if(dzen.slave_win.ismenu && dzen.slave_win.sel_line != -1
+ if(dzen.slave_win.ismenu && dzen.slave_win.sel_line != -1
&& (dzen.slave_win.sel_line + dzen.slave_win.first_line_vis) < dzen.slave_win.tcnt) {
text = parse_line(NULL, dzen.slave_win.sel_line, 0, 0, 1);
puts(text); fflush(stdout);
@@ -458,10 +458,9 @@ a_menuprint(char * opt[]) {
int
a_menuprint_noparse(char * opt[]) {
- char *text;
(void)opt;
- if(dzen.slave_win.ismenu && dzen.slave_win.sel_line != -1
+ if(dzen.slave_win.ismenu && dzen.slave_win.sel_line != -1
&& (dzen.slave_win.sel_line + dzen.slave_win.first_line_vis) < dzen.slave_win.tcnt) {
puts(dzen.slave_win.tbuf[dzen.slave_win.sel_line]); fflush(stdout);
dzen.slave_win.sel_line = -1;
@@ -508,7 +507,7 @@ int
a_scrollhome(char * opt[]) {
(void)opt;
if(dzen.slave_win.max_lines) {
- dzen.slave_win.first_line_vis = 0;
+ dzen.slave_win.first_line_vis = 0;
dzen.slave_win.last_line_vis = dzen.slave_win.max_lines;
x_draw_body();
@@ -520,9 +519,9 @@ int
a_scrollend(char * opt[]) {
(void)opt;
if(dzen.slave_win.max_lines) {
- dzen.slave_win.first_line_vis = dzen.slave_win.tcnt - dzen.slave_win.max_lines ;
+ dzen.slave_win.first_line_vis = dzen.slave_win.tcnt - dzen.slave_win.max_lines ;
dzen.slave_win.last_line_vis = dzen.slave_win.tcnt;
-
+
x_draw_body();
}
return 0;
diff --git a/config.mk b/config.mk
index 5512b70..d54ea0c 100644
--- a/config.mk
+++ b/config.mk
@@ -12,27 +12,27 @@ X11LIB = /usr/X11R6/lib
INCS = -I. -I/usr/include -I${X11INC}
# Configure the features you want to be supported
-# Only one of the following options has to be uncommented,
+# Only one of the following options has to be uncommented,
# all others must be commented!
#
# Uncomment: Remove # from the beginning of respective lines
# Comment : Add # to the beginning of the respective lines
# Option 1: No Xinerama no XPM
-#LIBS = -L/usr/lib -lc -L${X11LIB} -lX11
-#CFLAGS = -Os ${INCS} -DVERSION=\"${VERSION}\"
+LIBS = -L/usr/lib -lc -L${X11LIB} -lX11
+CFLAGS = -Wall -Os ${INCS} -DVERSION=\"${VERSION}\"
# Option 2: No Xinerama with XPM
#LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 -lXpm
-#CFLAGS = -Os ${INCS} -DVERSION=\"${VERSION}\" -DDZEN_XPM
+#CFLAGS = -Wall -Os ${INCS} -DVERSION=\"${VERSION}\" -DDZEN_XPM
# Option 3: With Xinerama no XPM
#LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 -lXinerama
-#CFLAGS = -Os ${INCS} -DVERSION=\"${VERSION}\" -DDZEN_XINERAMA
+#CFLAGS = -Wall -Os ${INCS} -DVERSION=\"${VERSION}\" -DDZEN_XINERAMA
# Option 4: With Xinerama and XPM
-LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 -lXinerama -lXpm
-CFLAGS = -Os ${INCS} -DVERSION=\"${VERSION}\" -DDZEN_XINERAMA -DDZEN_XPM
+#LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 -lXinerama -lXpm
+#CFLAGS = -Wall -Os ${INCS} -DVERSION=\"${VERSION}\" -DDZEN_XINERAMA -DDZEN_XPM
# END of feature configuration
diff --git a/draw.c b/draw.c
index a1be746..d627fa9 100644
--- a/draw.c
+++ b/draw.c
@@ -1,5 +1,5 @@
-/*
+/*
* (C)opyright MMVII Robert Manea <rob dot manea at gmail dot com>
* See LICENSE file for license details.
*
@@ -21,7 +21,7 @@
typedef struct ICON_C {
char name[ARGLEN];
Pixmap p;
-
+
int w, h;
} icon_c;
@@ -108,7 +108,7 @@ setfont(const char *fontstr) {
missing = NULL;
if(dzen.font.set)
XFreeFontSet(dzen.dpy, dzen.font.set);
-
+
dzen.font.set = XCreateFontSet(dzen.dpy, fontstr, &missing, &n, &def);
if(missing)
XFreeStringList(missing);
@@ -165,7 +165,7 @@ get_token(const char *line, int * t, char **tval) {
line++;
for(i=0; cmd_lookup_table[i].name; ++i) {
- if( off=cmd_lookup_table[i].off,
+ if( off=cmd_lookup_table[i].off,
!strncmp(line, cmd_lookup_table[i].name, off) ) {
next_pos = get_tokval(line+off, &tokval);
*t = cmd_lookup_table[i].id;
@@ -201,7 +201,7 @@ get_rect_vals(char *s, int *w, int *h, int *x, int *y) {
static int
get_circle_vals(char *s, int *d, int *a) {
- int i, ret;
+ int ret;
*d=*a=ret=0;
return sscanf(s, "%5d%5d", d, a);
@@ -235,21 +235,21 @@ get_pos_vals(char *s, int *d, int *a) {
if(!strncmp(s, "_TOP", 4)) {
*d = TOP;
}
-
+
return 5;
} else {
for(i=0; s[i] && i<128; i++) {
if(s[i] == ';') {
onlyx=0;
break;
- } else
+ } else
buf[i]=s[i];
}
if(i) {
buf[i]='\0';
*d=atoi(buf);
- } else
+ } else
ret=2;
if(s[++i]) {
@@ -267,18 +267,17 @@ static int
search_icon_cache(const char* name) {
int i;
- for(i=0; i < MAX_ICON_CACHE; i++)
+ for(i=0; i < MAX_ICON_CACHE; i++)
if(!strncmp(icons[i].name, name, ARGLEN))
return i;
return -1;
}
+#ifdef DZEN_XPM
static void
cache_icon(const char* name, Pixmap pm, int w, int h) {
- int i;
-
- if(icon_cnt >= MAX_ICON_CACHE)
+ if(icon_cnt >= MAX_ICON_CACHE)
icon_cnt = 0;
if(icons[icon_cnt].p)
@@ -290,17 +289,18 @@ cache_icon(const char* name, Pixmap pm, int w, int h) {
icons[icon_cnt].p = pm;
icon_cnt++;
}
+#endif
char *
parse_line(const char *line, int lnr, int align, int reverse, int nodraw) {
/* bitmaps */
- unsigned int bm_w, bm_h;
+ unsigned int bm_w, bm_h;
int bm_xh, bm_yh;
/* rectangles, cirlcles*/
int rectw, recth, rectx, recty;
/* positioning */
int n_posx, n_posy, set_posy=0;
- int px=0, py=0, xorig;
+ int px=0, py=0, xorig=0;
int i, next_pos=0, j=0, h=0, tw=0, ow;
/* fonts */
int font_was_set=0;
@@ -333,7 +333,7 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) {
if(nodraw) {
rbuf = emalloc(MAX_LINE_LEN);
rbuf[0] = '\0';
- if( (lnr + dzen.slave_win.first_line_vis) >= dzen.slave_win.tcnt)
+ if( (lnr + dzen.slave_win.first_line_vis) >= dzen.slave_win.tcnt)
line = NULL;
else
line = dzen.slave_win.tbuf[dzen.slave_win.first_line_vis+lnr];
@@ -343,15 +343,15 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) {
else {
h = dzen.font.height;
py = (dzen.line_height - h) / 2;
- xorig = 0;
+ xorig = 0;
if(lnr != -1) {
- pm = XCreatePixmap(dzen.dpy, RootWindow(dzen.dpy, DefaultScreen(dzen.dpy)), dzen.slave_win.width,
+ pm = XCreatePixmap(dzen.dpy, RootWindow(dzen.dpy, DefaultScreen(dzen.dpy)), dzen.slave_win.width,
dzen.line_height, DefaultDepth(dzen.dpy, dzen.screen));
}
else {
- pm = XCreatePixmap(dzen.dpy, RootWindow(dzen.dpy, DefaultScreen(dzen.dpy)), dzen.title_win.width,
+ pm = XCreatePixmap(dzen.dpy, RootWindow(dzen.dpy, DefaultScreen(dzen.dpy)), dzen.title_win.width,
dzen.line_height, DefaultDepth(dzen.dpy, dzen.screen));
}
@@ -388,7 +388,7 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) {
xpma.valuemask = XpmColormap|XpmDepth|XpmVisual|XpmColorSymbols;
#endif
- if(!dzen.font.set){
+ if(!dzen.font.set){
gcv.font = dzen.font.xfont->fid;
XChangeGC(dzen.dpy, dzen.tgc, GCFont, &gcv);
}
@@ -415,20 +415,20 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) {
switch(t) {
case icon:
if(MAX_ICON_CACHE && (ip=search_icon_cache(tval)) != -1) {
- XCopyArea(dzen.dpy, icons[ip].p, pm, dzen.tgc,
+ XCopyArea(dzen.dpy, icons[ip].p, pm, dzen.tgc,
0, 0, icons[ip].w, icons[ip].h, px, set_posy ? py :
- (dzen.line_height >= (signed)icons[ip].h ?
+ (dzen.line_height >= (signed)icons[ip].h ?
(dzen.line_height - icons[ip].h)/2 : 0));
px += !pos_is_fixed ? icons[ip].w : 0;
} else {
- if(XReadBitmapFile(dzen.dpy, pm, tval, &bm_w,
- &bm_h, &bm, &bm_xh, &bm_yh) == BitmapSuccess
+ if(XReadBitmapFile(dzen.dpy, pm, tval, &bm_w,
+ &bm_h, &bm, &bm_xh, &bm_yh) == BitmapSuccess
&& (h/2 + px + (signed)bm_w < dzen.w)) {
setcolor(&pm, px, bm_w, lastfg, lastbg, reverse, nobg);
- XCopyPlane(dzen.dpy, bm, pm, dzen.tgc,
- 0, 0, bm_w, bm_h, px, set_posy ? py :
- (dzen.line_height >= (signed)bm_h ? (dzen.line_height - bm_h)/2 : 0), 1);
+ XCopyPlane(dzen.dpy, bm, pm, dzen.tgc,
+ 0, 0, bm_w, bm_h, px, set_posy ? py :
+ (dzen.line_height >= (int)bm_h ? (dzen.line_height - (int)bm_h)/2 : 0), 1);
XFreePixmap(dzen.dpy, bm);
px += !pos_is_fixed ? bm_w : 0; }
#ifdef DZEN_XPM
@@ -438,9 +438,9 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) {
if(MAX_ICON_CACHE)
cache_icon(tval, xpm_pm, xpma.width, xpma.height);
- XCopyArea(dzen.dpy, xpm_pm, pm, dzen.tgc,
+ XCopyArea(dzen.dpy, xpm_pm, pm, dzen.tgc,
0, 0, xpma.width, xpma.height, px, set_posy ? py :
- (dzen.line_height >= (signed)xpma.height ? (dzen.line_height - xpma.height)/2 : 0));
+ (dzen.line_height >= (int)xpma.height ? (dzen.line_height - (int)xpma.height)/2 : 0));
px += !pos_is_fixed ? xpma.width : 0;
/* freed by cache_icon() */
@@ -451,25 +451,25 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) {
}
break;
-
+
case rect:
get_rect_vals(tval, &rectw, &recth, &rectx, &recty);
recth = recth > dzen.line_height ? dzen.line_height : recth;
if(set_posy)
py += recty;
- recty = recty == 0 ? (dzen.line_height - recth)/2 :
+ recty = recty == 0 ? (dzen.line_height - recth)/2 :
(dzen.line_height - recth)/2 + recty;
px += !pos_is_fixed ? rectx : 0;
setcolor(&pm, px, rectw, lastfg, lastbg, reverse, nobg);
-
- XFillRectangle(dzen.dpy, pm, dzen.tgc, px,
- set_posy ? py :
- ((int)recty < 0 ? dzen.line_height + recty : recty),
+
+ XFillRectangle(dzen.dpy, pm, dzen.tgc, px,
+ set_posy ? py :
+ ((int)recty < 0 ? dzen.line_height + recty : recty),
rectw, recth);
px += !pos_is_fixed ? rectw : 0;
break;
-
+
case recto:
get_rect_vals(tval, &rectw, &recth, &rectx, &recty);
if (!rectw) break;
@@ -477,14 +477,14 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) {
recth = recth > dzen.line_height ? dzen.line_height-2 : recth-1;
if(set_posy)
py += recty;
- recty = recty == 0 ? (dzen.line_height - recth)/2 :
+ recty = recty == 0 ? (dzen.line_height - recth)/2 :
(dzen.line_height - recth)/2 + recty;
px = (rectx == 0) ? px : rectx+px;
/* prevent from stairs effect when rounding recty */
if (!((dzen.line_height - recth) % 2)) recty--;
setcolor(&pm, px, rectw, lastfg, lastbg, reverse, nobg);
- XDrawRectangle(dzen.dpy, pm, dzen.tgc, px,
- set_posy ? py :
+ XDrawRectangle(dzen.dpy, pm, dzen.tgc, px,
+ set_posy ? py :
((int)recty<0 ? dzen.line_height + recty : recty), rectw-1, recth);
px += !pos_is_fixed ? rectw : 0;
break;
@@ -492,7 +492,7 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) {
case circle:
rectx = get_circle_vals(tval, &rectw, &recth);
setcolor(&pm, px, rectw, lastfg, lastbg, reverse, nobg);
- XFillArc(dzen.dpy, pm, dzen.tgc, px, set_posy ? py :(dzen.line_height - rectw)/2,
+ XFillArc(dzen.dpy, pm, dzen.tgc, px, set_posy ? py :(dzen.line_height - rectw)/2,
rectw, rectw, 90*64, rectx>1?recth*64:64*360);
px += !pos_is_fixed ? rectw : 0;
break;
@@ -500,7 +500,7 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) {
case circleo:
rectx = get_circle_vals(tval, &rectw, &recth);
setcolor(&pm, px, rectw, lastfg, lastbg, reverse, nobg);
- XDrawArc(dzen.dpy, pm, dzen.tgc, px, set_posy ? py : (dzen.line_height - rectw)/2,
+ XDrawArc(dzen.dpy, pm, dzen.tgc, px, set_posy ? py : (dzen.line_height - rectw)/2,
rectw, rectw, 90*64, rectx>1?recth*64:64*360);
px += !pos_is_fixed ? rectw : 0;
break;
@@ -513,10 +513,10 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) {
set_posy=0;
else if (r == 5) {
switch(n_posx) {
- case LOCK_X:
+ case LOCK_X:
pos_is_fixed = 1;
break;
- case UNLOCK_X:
+ case UNLOCK_X:
pos_is_fixed = 0;
break;
case LEFT:
@@ -536,12 +536,12 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) {
set_posy = 1;
py = 0;
break;
- }
+ }
} else
set_posy=1;
if(r != 2)
- px = px+n_posx<0? 0 : px + n_posx;
+ px = px+n_posx<0? 0 : px + n_posx;
if(r != 1)
py += n_posy;
} else {
@@ -581,7 +581,7 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) {
lastfg = tval[0] ? (unsigned)getcolor(tval) : dzen.norm[ColFG];
XSetForeground(dzen.dpy, dzen.tgc, lastfg);
break;
-
+
case fn:
if(tval[0]) {
if(!strncmp(tval, "dfnt", 4)) {
@@ -597,7 +597,7 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) {
}
else {
cur_fnt = &dzen.font;
- if(!cur_fnt->set){
+ if(!cur_fnt->set){
gcv.font = cur_fnt->xfont->fid;
XChangeGC(dzen.dpy, dzen.tgc, GCFont, &gcv);
}
@@ -628,11 +628,11 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) {
if(!nobg)
setcolor(&pm, px, tw, lastfg, lastbg, reverse, nobg);
- if(cur_fnt->set)
+ if(cur_fnt->set)
XmbDrawString(dzen.dpy, pm, cur_fnt->set,
dzen.tgc, px, py + cur_fnt->ascent, lbuf, strlen(lbuf));
- else
- XDrawString(dzen.dpy, pm, dzen.tgc, px, py+dzen.font.ascent, lbuf, strlen(lbuf));
+ else
+ XDrawString(dzen.dpy, pm, dzen.tgc, px, py+dzen.font.ascent, lbuf, strlen(lbuf));
px += !pos_is_fixed ? tw : 0;
}
@@ -642,10 +642,10 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) {
i += next_pos;
/* ^^ escapes */
- if(next_pos == 0)
+ if(next_pos == 0)
lbuf[j++] = line[i++];
- }
- else
+ }
+ else
lbuf[j++] = line[i];
}
@@ -658,19 +658,19 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) {
switch(t) {
case icon:
if(MAX_ICON_CACHE && (ip=search_icon_cache(tval)) != -1) {
- XCopyArea(dzen.dpy, icons[ip].p, pm, dzen.tgc,
+ XCopyArea(dzen.dpy, icons[ip].p, pm, dzen.tgc,
0, 0, icons[ip].w, icons[ip].h, px, set_posy ? py :
- (dzen.line_height >= (signed)icons[ip].h ?
+ (dzen.line_height >= (signed)icons[ip].h ?
(dzen.line_height - icons[ip].h)/2 : 0));
px += !pos_is_fixed ? icons[ip].w : 0;
} else {
- if(XReadBitmapFile(dzen.dpy, pm, tval, &bm_w,
- &bm_h, &bm, &bm_xh, &bm_yh) == BitmapSuccess
+ if(XReadBitmapFile(dzen.dpy, pm, tval, &bm_w,
+ &bm_h, &bm, &bm_xh, &bm_yh) == BitmapSuccess
&& (h/2 + px + (signed)bm_w < dzen.w)) {
setcolor(&pm, px, bm_w, lastfg, lastbg, reverse, nobg);
- XCopyPlane(dzen.dpy, bm, pm, dzen.tgc,
- 0, 0, bm_w, bm_h, px, set_posy ? py :
- (dzen.line_height >= (signed)bm_h ? (dzen.line_height - bm_h)/2 : 0), 1);
+ XCopyPlane(dzen.dpy, bm, pm, dzen.tgc,
+ 0, 0, bm_w, bm_h, px, set_posy ? py :
+ (dzen.line_height >= (int)bm_h ? (dzen.line_height - (int)bm_h)/2 : 0), 1);
XFreePixmap(dzen.dpy, bm);
px += !pos_is_fixed ? bm_w : 0;
}
@@ -681,9 +681,9 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) {
if(MAX_ICON_CACHE)
cache_icon(tval, xpm_pm, xpma.width, xpma.height);
- XCopyArea(dzen.dpy, xpm_pm, pm, dzen.tgc,
+ XCopyArea(dzen.dpy, xpm_pm, pm, dzen.tgc,
0, 0, xpma.width, xpma.height, px, set_posy ? py :
- (dzen.line_height >= (signed)xpma.height ? (dzen.line_height - xpma.height)/2 : 0));
+ (dzen.line_height >= (int)xpma.height ? (dzen.line_height - (int)xpma.height)/2 : 0));
px += !pos_is_fixed ? xpma.width : 0;
//XFreePixmap(dzen.dpy, xpm_pm);
@@ -698,14 +698,14 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) {
recth = recth > dzen.line_height ? dzen.line_height : recth;
if(set_posy)
py += recty;
- recty = recty == 0 ? (dzen.line_height - recth)/2 :
+ recty = recty == 0 ? (dzen.line_height - recth)/2 :
(dzen.line_height - recth)/2 + recty;
px += rectx;
setcolor(&pm, px, rectw, lastfg, lastbg, reverse, nobg);
- XFillRectangle(dzen.dpy, pm, dzen.tgc, px,
- set_posy ? py :
- ((int)recty < 0 ? dzen.line_height + recty : recty),
+ XFillRectangle(dzen.dpy, pm, dzen.tgc, px,
+ set_posy ? py :
+ ((int)recty < 0 ? dzen.line_height + recty : recty),
rectw, recth);
px += !pos_is_fixed ? rectw : 0;
@@ -724,8 +724,8 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) {
/* prevent from stairs effect when rounding recty */
if (!((dzen.line_height - recth) % 2)) recty--;
setcolor(&pm, px, rectw, lastfg, lastbg, reverse, nobg);
- XDrawRectangle(dzen.dpy, pm, dzen.tgc, px,
- set_posy ? py :
+ XDrawRectangle(dzen.dpy, pm, dzen.tgc, px,
+ set_posy ? py :
((int)recty<0 ? dzen.line_height + recty : recty), rectw-1, recth);
px += !pos_is_fixed ? rectw : 0;
break;
@@ -733,7 +733,7 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) {
case circle:
rectx = get_circle_vals(tval, &rectw, &recth);
setcolor(&pm, px, rectw, lastfg, lastbg, reverse, nobg);
- XFillArc(dzen.dpy, pm, dzen.tgc, px, set_posy ? py :(dzen.line_height - rectw)/2,
+ XFillArc(dzen.dpy, pm, dzen.tgc, px, set_posy ? py :(dzen.line_height - rectw)/2,
rectw, rectw, 90*64, rectx>1?recth*64:64*360);
px += !pos_is_fixed ? rectw : 0;
break;
@@ -741,7 +741,7 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) {
case circleo:
rectx = get_circle_vals(tval, &rectw, &recth);
setcolor(&pm, px, rectw, lastfg, lastbg, reverse, nobg);
- XDrawArc(dzen.dpy, pm, dzen.tgc, px, set_posy ? py : (dzen.line_height - rectw)/2,
+ XDrawArc(dzen.dpy, pm, dzen.tgc, px, set_posy ? py : (dzen.line_height - rectw)/2,
rectw, rectw, 90*64, rectx>1?recth*64:64*360);
px += !pos_is_fixed ? rectw : 0;
break;
@@ -754,10 +754,10 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) {
set_posy=0;
else if (r == 5) {
switch(n_posx) {
- case LOCK_X:
+ case LOCK_X:
pos_is_fixed = 1;
break;
- case UNLOCK_X:
+ case UNLOCK_X:
pos_is_fixed = 0;
break;
case LEFT:
@@ -777,12 +777,12 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) {
set_posy = 1;
py = 0;
break;
- }
+ }
} else
set_posy=1;
if(r != 2)
- px = px+n_posx<0? 0 : px + n_posx;
+ px = px+n_posx<0? 0 : px + n_posx;
if(r != 1)
py += n_posy;
} else {
@@ -838,7 +838,7 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) {
}
else {
cur_fnt = &dzen.font;
- if(!cur_fnt->set){
+ if(!cur_fnt->set){
gcv.font = cur_fnt->xfont->fid;
XChangeGC(dzen.dpy, dzen.tgc, GCFont, &gcv);
}
@@ -869,11 +869,11 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) {
if(!nobg)
setcolor(&pm, px, tw, lastfg, lastbg, reverse, nobg);
- if(cur_fnt->set)
+ if(cur_fnt->set)
XmbDrawString(dzen.dpy, pm, cur_fnt->set,
dzen.tgc, px, py + cur_fnt->ascent, lbuf, strlen(lbuf));
- else
- XDrawString(dzen.dpy, pm, dzen.tgc, px, py+dzen.font.ascent, lbuf, strlen(lbuf));
+ else
+ XDrawString(dzen.dpy, pm, dzen.tgc, px, py+dzen.font.ascent, lbuf, strlen(lbuf));
px += !pos_is_fixed ? tw : 0;
/* expand/shrink dynamically */
@@ -883,7 +883,7 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) {
case left:
/* grow left end */
otx = dzen.title_win.x_right_corner - i > dzen.title_win.x ?
- dzen.title_win.x_right_corner - i : dzen.title_win.x;
+ dzen.title_win.x_right_corner - i : dzen.title_win.x;
XMoveResizeWindow(dzen.dpy, dzen.title_win.win, otx, dzen.title_win.y, px, dzen.line_height);
break;
case right:
@@ -902,10 +902,10 @@ parse_line(const char *line, int lnr, int align, int reverse, int nodraw) {
else if(align == ALIGNRIGHT) {
xorig = (lnr != -1) ?
(dzen.slave_win.width - px) :
- (dzen.title_win.width - px);
+ (dzen.title_win.width - px);
}
}
-
+
if(lnr != -1) {
XCopyArea(dzen.dpy, pm, dzen.slave_win.drawable[lnr], dzen.gc,
@@ -980,12 +980,12 @@ parse_non_drawing_commands(char * text) {
return 1;
}
-
+
void
drawheader(const char * text) {
- if(parse_non_drawing_commands((char *)text)) {
- if (text){
+ if(parse_non_drawing_commands((char *)text)) {
+ if (text){
dzen.w = dzen.title_win.width;
dzen.h = dzen.line_height;
@@ -997,7 +997,7 @@ drawheader(const char * text) {
dzen.cur_line = 0;
}
- XCopyArea(dzen.dpy, dzen.title_win.drawable, dzen.title_win.win,
+ XCopyArea(dzen.dpy, dzen.title_win.drawable, dzen.title_win.win,
dzen.gc, 0, 0, dzen.title_win.width, dzen.line_height, 0, 0);
}
@@ -1018,12 +1018,12 @@ drawbody(char * text) {
XFillRectangle(dzen.dpy, dzen.title_win.drawable, dzen.rgc, 0, 0, dzen.w, dzen.h);
parse_line(ec+5, -1, dzen.title_win.alignment, 0, 0);
- XCopyArea(dzen.dpy, dzen.title_win.drawable, dzen.title_win.win,
+ XCopyArea(dzen.dpy, dzen.title_win.drawable, dzen.title_win.win,
dzen.gc, 0, 0, dzen.w, dzen.h, 0, 0);
return;
}
- if(dzen.slave_win.tcnt == dzen.slave_win.tsize)
+ if(dzen.slave_win.tcnt == dzen.slave_win.tsize)
free_buffer();
write_buffer = parse_non_drawing_commands(text);
diff --git a/main.c b/main.c
index cf86b0c..2b9c303 100644
--- a/main.c
+++ b/main.c
@@ -20,8 +20,8 @@
#include <sys/time.h>
#include <sys/types.h>
-#ifndef HOST_NAME_MAX
-#define HOST_NAME_MAX 255
+#ifndef HOST_NAME_MAX
+#define HOST_NAME_MAX 255
#endif
Dzen dzen = {0};
@@ -29,7 +29,7 @@ static int last_cnt = 0;
typedef void sigfunc(int);
-static void
+static void
clean_up(void) {
int i;
@@ -114,7 +114,7 @@ chomp(char *inbuf, char *outbuf, int start, int len) {
}
if(inbuf[off] != '\n') {
outbuf[i++] = inbuf[off++];
- }
+ }
else if(inbuf[off] == '\n') {
outbuf[i] = '\0';
return ++off;
@@ -133,14 +133,14 @@ free_buffer(void) {
free(dzen.slave_win.tbuf[i]);
dzen.slave_win.tbuf[i] = NULL;
}
- dzen.slave_win.tcnt =
- dzen.slave_win.last_line_vis =
+ dzen.slave_win.tcnt =
+ dzen.slave_win.last_line_vis =
last_cnt = 0;
}
-static int
+static int
read_stdin(void) {
- char buf[MAX_LINE_LEN],
+ char buf[MAX_LINE_LEN],
retbuf[MAX_LINE_LEN];
ssize_t n, n_off=0;
@@ -148,22 +148,22 @@ read_stdin(void) {
if(!dzen.ispersistent) {
dzen.running = False;
return -1;
- }
- else
+ }
+ else
return -2;
- }
+ }
else {
while((n_off = chomp(buf, retbuf, n_off, n))) {
- if(!dzen.slave_win.ishmenu
- && dzen.tsupdate
- && dzen.slave_win.max_lines
+ if(!dzen.slave_win.ishmenu
+ && dzen.tsupdate
+ && dzen.slave_win.max_lines
&& ((dzen.cur_line == 0) || !(dzen.cur_line % (dzen.slave_win.max_lines+1))))
drawheader(retbuf);
- else if(!dzen.slave_win.ishmenu
- && !dzen.tsupdate
+ else if(!dzen.slave_win.ishmenu
+ && !dzen.tsupdate
&& ((dzen.cur_line == 0) || !dzen.slave_win.max_lines))
drawheader(retbuf);
- else
+ else
drawbody(retbuf);
dzen.cur_line++;
}
@@ -185,7 +185,7 @@ x_unhilight_line(int line) {
0, 0, dzen.slave_win.width, dzen.line_height, 0, 0);
}
-void
+void
x_draw_body(void) {
int i;
dzen.x = 0;
@@ -205,8 +205,8 @@ x_draw_body(void) {
}
for(i=0; i < dzen.slave_win.max_lines; i++) {
- if(i < dzen.slave_win.last_line_vis)
- drawtext(dzen.slave_win.tbuf[i + dzen.slave_win.first_line_vis],
+ if(i < dzen.slave_win.last_line_vis)
+ drawtext(dzen.slave_win.tbuf[i + dzen.slave_win.first_line_vis],
0, i, dzen.slave_win.alignment);
}
for(i=0; i < dzen.slave_win.max_lines; i++)
@@ -215,53 +215,47 @@ x_draw_body(void) {
}
static void
-x_check_geometry(XRectangle si) {
-
- dzen.title_win.x = dzen.title_win.x < 0 ?
- si.width + dzen.title_win.x + si.x :
- dzen.title_win.x + si.x;
- dzen.title_win.y = dzen.title_win.y < 0 ?
- si.height + dzen.title_win.y + si.y :
- dzen.title_win.y + si.y;
+x_check_geometry(XRectangle scr) {
+ TWIN *t = &dzen.title_win;
+ SWIN *s = &dzen.slave_win;
+ t->x = t->x < 0 ? scr.width + t->x + scr.x : t->x + scr.x;
+ t->y = t->y < 0 ? scr.height + t->y + scr.y : t->y + scr.y;
- if(dzen.title_win.x > si.x + si.width)
- dzen.title_win.x = si.x;
- if (dzen.title_win.x < si.x)
- dzen.title_win.x = si.x;
+ if(t->x < scr.x || scr.x + scr.width < t->x)
+ t->x = scr.x;
- if(!dzen.title_win.width)
- dzen.title_win.width = si.width;
+ if(!t->width)
+ t->width = scr.width;
- if((dzen.title_win.x + dzen.title_win.width) > (si.x + si.width) && (dzen.title_win.expand != left))
- dzen.title_win.width = si.width - (dzen.title_win.x - si.x);
+ if((t->x + t->width) > (scr.x + scr.width) && (t->expand != left))
+ t->width = scr.width - (t->x - scr.x);
- if(dzen.title_win.expand == left) {
- dzen.title_win.x_right_corner = dzen.title_win.x + dzen.title_win.width;
- //dzen.title_win.width = dzen.title_win.width ? dzen.title_win.width : dzen.title_win.x_right_corner - si.x;
- dzen.title_win.x = dzen.title_win.width ? dzen.title_win.x_right_corner - dzen.title_win.width : si.x;
+ if(t->expand == left) {
+ t->x_right_corner = t->x + t->width;
+ t->x = t->width ? t->x_right_corner - t->width : scr.x;
}
- if(!dzen.slave_win.width) {
- dzen.slave_win.x = si.x;
- dzen.slave_win.width = si.width;
+ if(!s->width) {
+ s->x = scr.x;
+ s->width = scr.width;
}
- if( dzen.title_win.width == dzen.slave_win.width) {
- dzen.slave_win.x = dzen.title_win.x;
+ if(t->width == s->width)
+ s->x = t->x;
+
+ if(s->width != scr.width) {
+ s->x = t->x + (t->width - s->width)/2;
+ if(s->x < scr.x)
+ s->x = scr.x;
+ if(s->x + s->width > scr.x + scr.width)
+ s->x = scr.x + (scr.width - s->width);
}
- if(dzen.slave_win.width != si.width) {
- dzen.slave_win.x = dzen.title_win.x + (dzen.title_win.width - dzen.slave_win.width)/2;
- if(dzen.slave_win.x < si.x)
- dzen.slave_win.x = si.x;
- if(dzen.slave_win.x + dzen.slave_win.width > si.x + si.width)
- dzen.slave_win.x = si.x + (si.width - dzen.slave_win.width);
- }
if(!dzen.line_height)
dzen.line_height = dzen.font.height + 2;
- if (dzen.title_win.y + dzen.line_height > si.y + si.height)
- dzen.title_win.y = 0;
+ if(t->y + dzen.line_height > scr.y + scr.height)
+ t->y = scr.y + scr.height - dzen.line_height;
}
static void
@@ -283,7 +277,7 @@ queryscreeninfo(Display *dpy, XRectangle *rect, int screen) {
if(xsi == NULL || screen > nscreens || screen <= 0) {
qsi_no_xinerama(dpy, rect);
- }
+ }
else {
rect->x = xsi[screen-1].x_org;
rect->y = xsi[screen-1].y_org;
@@ -293,7 +287,7 @@ queryscreeninfo(Display *dpy, XRectangle *rect, int screen) {
}
#endif
-static void
+static void
set_docking_ewmh_info(Display *dpy, Window w, int dock) {
unsigned long strut[12] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
unsigned long strut_s[4] = { 0, 0, 0, 0 };
@@ -313,7 +307,7 @@ set_docking_ewmh_info(Display *dpy, Window w, int dock) {
XFree(txt_prop.value);
XChangeProperty(
- dpy,
+ dpy,
w,
XInternAtom(dpy, "_NET_WM_PID", False),
XInternAtom(dpy, "CARDINAL", False),
@@ -334,8 +328,8 @@ set_docking_ewmh_info(Display *dpy, Window w, int dock) {
strut[8] = wa.x;
strut[9] = wa.x + wa.width - 1;
- strut_s[2] = wa.height;
- }
+ strut_s[2] = wa.height;
+ }
else if((wa.y + wa.height) == DisplayHeight(dpy, DefaultScreen(dpy))) {
strut[3] = wa.height;
strut[10] = wa.x;
@@ -346,21 +340,21 @@ set_docking_ewmh_info(Display *dpy, Window w, int dock) {
if(strut[2] != 0 || strut[3] != 0) {
XChangeProperty(
- dpy,
- w,
+ dpy,
+ w,
XInternAtom(dpy, "_NET_WM_STRUT_PARTIAL", False),
XInternAtom(dpy, "CARDINAL", False),
- 32,
+ 32,
PropModeReplace,
(unsigned char *)&strut,
12
);
XChangeProperty(
- dpy,
- w,
+ dpy,
+ w,
XInternAtom(dpy, "_NET_WM_STRUT", False),
XInternAtom(dpy, "CARDINAL", False),
- 32,
+ 32,
PropModeReplace,
(unsigned char *)&strut,
4
@@ -371,7 +365,7 @@ set_docking_ewmh_info(Display *dpy, Window w, int dock) {
type = XInternAtom(dpy, "_NET_WM_WINDOW_TYPE_DOCK", False);
XChangeProperty(
- dpy,
+ dpy,
w,
XInternAtom(dpy, "_NET_WM_WINDOW_TYPE", False),
XInternAtom(dpy, "ATOM", False),
@@ -384,7 +378,7 @@ set_docking_ewmh_info(Display *dpy, Window w, int dock) {
desktop = 0xffffffff;
XChangeProperty(
- dpy,
+ dpy,
w,
XInternAtom(dpy, "_NET_WM_DESKTOP", False),
XInternAtom(dpy, "CARDINAL", False),
@@ -417,7 +411,7 @@ x_create_gcs(void) {
static void
x_connect(void) {
dzen.dpy = XOpenDisplay(0);
- if(!dzen.dpy)
+ if(!dzen.dpy)
eprint("dzen: cannot open display\n");
dzen.screen = DefaultScreen(dzen.dpy);
}
@@ -433,11 +427,11 @@ x_read_resources(void) {
xrm = XResourceManagerString(dzen.dpy);
if( xrm != NULL ) {
xdb = XrmGetStringDatabase(xrm);
- if( XrmGetResource(xdb, "dzen2.font", "*", datatype, &xvalue) == True )
+ if( XrmGetResource(xdb, "dzen2.font", "*", datatype, &xvalue) == True )
dzen.fnt = estrdup(xvalue.addr);
- if( XrmGetResource(xdb, "dzen2.foreground", "*", datatype, &xvalue) == True )
+ if( XrmGetResource(xdb, "dzen2.foreground", "*", datatype, &xvalue) == True )
dzen.fg = estrdup(xvalue.addr);
- if( XrmGetResource(xdb, "dzen2.background", "*", datatype, &xvalue) == True )
+ if( XrmGetResource(xdb, "dzen2.background", "*", datatype, &xvalue) == True )
dzen.bg = estrdup(xvalue.addr);
XrmDestroyDatabase(xdb);
}
@@ -474,22 +468,22 @@ x_create_windows(int use_ewmh_dock) {
x_check_geometry(si);
/* title window */
- dzen.title_win.win = XCreateWindow(dzen.dpy, root,
+ dzen.title_win.win = XCreateWindow(dzen.dpy, root,
dzen.title_win.x, dzen.title_win.y, dzen.title_win.width, dzen.line_height, 0,
DefaultDepth(dzen.dpy, dzen.screen), CopyFromParent,
DefaultVisual(dzen.dpy, dzen.screen),
CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
XStoreName(dzen.dpy, dzen.title_win.win, dzen.title_win.name);
- dzen.title_win.drawable = XCreatePixmap(dzen.dpy, root, dzen.title_win.width,
+ dzen.title_win.drawable = XCreatePixmap(dzen.dpy, root, dzen.title_win.width,
dzen.line_height, DefaultDepth(dzen.dpy, dzen.screen));
- XFillRectangle(dzen.dpy, dzen.title_win.drawable, dzen.rgc, 0, 0, dzen.title_win.width, dzen.line_height);
+ XFillRectangle(dzen.dpy, dzen.title_win.drawable, dzen.rgc, 0, 0, dzen.title_win.width, dzen.line_height);
/* set some hints for windowmanagers*/
set_docking_ewmh_info(dzen.dpy, dzen.title_win.win, use_ewmh_dock);
/* TODO: Smarter approach to window creation so we can reduce the
- * size of this function.
+ * size of this function.
*/
if(dzen.slave_win.max_lines) {
@@ -508,7 +502,7 @@ x_create_windows(int use_ewmh_dock) {
dzen.slave_win.issticky = True;
dzen.slave_win.y = dzen.title_win.y;
- dzen.slave_win.win = XCreateWindow(dzen.dpy, root,
+ dzen.slave_win.win = XCreateWindow(dzen.dpy, root,
dzen.slave_win.x, dzen.slave_win.y, dzen.slave_win.width, dzen.line_height, 0,
DefaultDepth(dzen.dpy, dzen.screen), CopyFromParent,
DefaultVisual(dzen.dpy, dzen.screen),
@@ -516,22 +510,22 @@ x_create_windows(int use_ewmh_dock) {
XStoreName(dzen.dpy, dzen.slave_win.win, dzen.slave_win.name);
for(i=0; i < dzen.slave_win.max_lines; i++) {
- dzen.slave_win.drawable[i] = XCreatePixmap(dzen.dpy, root, ew+r,
+ dzen.slave_win.drawable[i] = XCreatePixmap(dzen.dpy, root, ew+r,
dzen.line_height, DefaultDepth(dzen.dpy, dzen.screen));
- XFillRectangle(dzen.dpy, dzen.slave_win.drawable[i], dzen.rgc, 0, 0,
- ew+r, dzen.line_height);
+ XFillRectangle(dzen.dpy, dzen.slave_win.drawable[i], dzen.rgc, 0, 0,
+ ew+r, dzen.line_height);
}
/* windows holding the lines */
for(i=0; i < dzen.slave_win.max_lines; i++)
- dzen.slave_win.line[i] = XCreateWindow(dzen.dpy, dzen.slave_win.win,
+ dzen.slave_win.line[i] = XCreateWindow(dzen.dpy, dzen.slave_win.win,
i*ew, 0, (i == dzen.slave_win.max_lines-1) ? ew+r : ew, dzen.line_height, 0,
DefaultDepth(dzen.dpy, dzen.screen), CopyFromParent,
DefaultVisual(dzen.dpy, dzen.screen),
CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
/* As we don't use the title window in this mode,
- * we reuse it's width value
+ * we reuse it's width value
*/
dzen.title_win.width = dzen.slave_win.width;
dzen.slave_win.width = ew+r;
@@ -545,7 +539,7 @@ x_create_windows(int use_ewmh_dock) {
if(dzen.title_win.y + dzen.line_height*dzen.slave_win.max_lines > si.y + si.height)
dzen.slave_win.y = (dzen.title_win.y - dzen.line_height) - dzen.line_height*(dzen.slave_win.max_lines) + dzen.line_height;
- dzen.slave_win.win = XCreateWindow(dzen.dpy, root,
+ dzen.slave_win.win = XCreateWindow(dzen.dpy, root,
dzen.slave_win.x, dzen.slave_win.y, dzen.slave_win.width, dzen.slave_win.max_lines * dzen.line_height, 0,
DefaultDepth(dzen.dpy, dzen.screen), CopyFromParent,
DefaultVisual(dzen.dpy, dzen.screen),
@@ -553,15 +547,15 @@ x_create_windows(int use_ewmh_dock) {
XStoreName(dzen.dpy, dzen.slave_win.win, dzen.slave_win.name);
for(i=0; i < dzen.slave_win.max_lines; i++) {
- dzen.slave_win.drawable[i] = XCreatePixmap(dzen.dpy, root, dzen.slave_win.width,
+ dzen.slave_win.drawable[i] = XCreatePixmap(dzen.dpy, root, dzen.slave_win.width,
dzen.line_height, DefaultDepth(dzen.dpy, dzen.screen));
- XFillRectangle(dzen.dpy, dzen.slave_win.drawable[i], dzen.rgc, 0, 0,
- dzen.slave_win.width, dzen.line_height);
+ XFillRectangle(dzen.dpy, dzen.slave_win.drawable[i], dzen.rgc, 0, 0,
+ dzen.slave_win.width, dzen.line_height);
}
/* windows holding the lines */
- for(i=0; i < dzen.slave_win.max_lines; i++)
- dzen.slave_win.line[i] = XCreateWindow(dzen.dpy, dzen.slave_win.win,
+ for(i=0; i < dzen.slave_win.max_lines; i++)
+ dzen.slave_win.line[i] = XCreateWindow(dzen.dpy, dzen.slave_win.win,
0, i*dzen.line_height, dzen.slave_win.width, dzen.line_height, 0,
DefaultDepth(dzen.dpy, dzen.screen), CopyFromParent,
DefaultVisual(dzen.dpy, dzen.screen),
@@ -571,7 +565,7 @@ x_create_windows(int use_ewmh_dock) {
}
-static void
+static void
x_map_window(Window win) {
XMapRaised(dzen.dpy, win);
XSync(dzen.dpy, False);
@@ -582,7 +576,7 @@ x_redraw(Window w) {
int i;
if(!dzen.slave_win.ishmenu
- && w == dzen.title_win.win)
+ && w == dzen.title_win.win)
drawheader(NULL);
if(!dzen.tsupdate && w == dzen.slave_win.win) {
for(i=0; i < dzen.slave_win.max_lines; i++)
@@ -590,7 +584,7 @@ x_redraw(Window w) {
0, 0, dzen.slave_win.width, dzen.line_height, 0, 0);
}
else {
- for(i=0; i < dzen.slave_win.max_lines; i++)
+ for(i=0; i < dzen.slave_win.max_lines; i++)
if(w == dzen.slave_win.line[i]) {
XCopyArea(dzen.dpy, dzen.slave_win.drawable[i], dzen.slave_win.line[i], dzen.gc,
0, 0, dzen.slave_win.width, dzen.line_height, 0, 0);
@@ -612,16 +606,16 @@ handle_xev(void) {
XNextEvent(dzen.dpy, &ev);
switch(ev.type) {
case Expose:
- if(ev.xexpose.count == 0)
+ if(ev.xexpose.count == 0)
x_redraw(ev.xexpose.window);
break;
case EnterNotify:
- if(dzen.slave_win.ismenu) {
- for(i=0; i < dzen.slave_win.max_lines; i++)
+ if(dzen.slave_win.ismenu) {
+ for(i=0; i < dzen.slave_win.max_lines; i++)
if(ev.xcrossing.window == dzen.slave_win.line[i])
x_hilight_line(i);
}
- if(!dzen.slave_win.ishmenu
+ if(!dzen.slave_win.ishmenu
&& ev.xcrossing.window == dzen.title_win.win)
do_action(entertitle);
if(ev.xcrossing.window == dzen.slave_win.win)
@@ -633,7 +627,7 @@ handle_xev(void) {
if(ev.xcrossing.window == dzen.slave_win.line[i])
x_unhilight_line(i);
}
- if(!dzen.slave_win.ishmenu
+ if(!dzen.slave_win.ishmenu
&& ev.xcrossing.window == dzen.title_win.win)
do_action(leavetitle);
if(ev.xcrossing.window == dzen.slave_win.win) {
@@ -642,8 +636,8 @@ handle_xev(void) {
break;
case ButtonRelease:
if(dzen.slave_win.ismenu) {
- for(i=0; i < dzen.slave_win.max_lines; i++)
- if(ev.xbutton.window == dzen.slave_win.line[i])
+ for(i=0; i < dzen.slave_win.max_lines; i++)
+ if(ev.xbutton.window == dzen.slave_win.line[i])
dzen.slave_win.sel_line = i;
}
switch(ev.xbutton.button) {
@@ -674,17 +668,17 @@ handle_xev(void) {
XLookupString(&ev.xkey, buf, sizeof buf, &ksym, 0);
do_action(ksym+keymarker);
break;
-
+
/* TODO: XRandR rotation and size chnages */
#if 0
-#ifdef DZEN_XRANDR
+#ifdef DZEN_XRANDR
case RRScreenChangeNotify:
handle_xrandr();
#endif
#endif
-
+
}
}
@@ -698,16 +692,16 @@ handle_newl(void) {
if (XGetWindowAttributes(dzen.dpy, dzen.slave_win.win, &wa),
wa.map_state != IsUnmapped
- /* autoscroll and redraw only if we're
- * currently viewing the last line of input
+ /* autoscroll and redraw only if we're
+ * currently viewing the last line of input
*/
&& (dzen.slave_win.last_line_vis == last_cnt)) {
dzen.slave_win.first_line_vis = 0;
dzen.slave_win.last_line_vis = 0;
x_draw_body();
- }
+ }
/* needed for a_scrollhome */
- else if(wa.map_state != IsUnmapped
+ else if(wa.map_state != IsUnmapped
&& dzen.slave_win.last_line_vis == dzen.slave_win.max_lines)
x_draw_body();
/* forget state if window was unmapped */
@@ -754,7 +748,7 @@ event_loop(void) {
handle_xev();
}
}
- return;
+ return;
}
static void
@@ -763,7 +757,7 @@ x_preload(const char *fontstr, int p) {
int i, n;
missing = NULL;
-
+
dzen.fnpl[p].set = XCreateFontSet(dzen.dpy, fontstr, &missing, &n, &def);
if(missing)
XFreeStringList(missing);
@@ -798,7 +792,7 @@ x_preload(const char *fontstr, int p) {
static void
font_preload(char *s) {
int k = 0;
- char *buf = strtok(s,",");
+ char *buf = strtok(s,",");
while( buf != NULL ) {
if(k<64)
x_preload(buf, k++);
@@ -866,17 +860,22 @@ main(int argc, char *argv[]) {
init_input_buffer();
}
}
- else if(!strncmp(argv[i], "-geometry", 8)) {
- if(++i < argc) {
+ else if(!strncmp(argv[i], "-geometry", 10)) {
+ if(++i < argc) {
int t;
- unsigned int tx, ty, tw, th;
+ int tx, ty;
+ unsigned int tw, th;
t = XParseGeometry(argv[i], &tx, &ty, &tw, &th);
- if(t & XValue)
- dzen.title_win.x = (signed int) tx;
- if(t & YValue)
- dzen.title_win.y = (signed int) ty;
+ if(t & XValue)
+ dzen.title_win.x = tx;
+ if(t & YValue) {
+ dzen.title_win.y = ty;
+ if(!ty && (t & YNegative))
+ /* -0 != +0 */
+ dzen.title_win.y = -1;
+ }
if(t & WidthValue)
dzen.title_win.width = (signed int) tw;
if(t & HeightValue)
@@ -923,7 +922,7 @@ main(int argc, char *argv[]) {
dzen.slave_win.ismenu = True;
if(i+1 < argc) {
dzen.slave_win.ishmenu = (argv[i+1][0] == 'h') ? ++i, True : False;
- if( argv[i+1][0] == 'v')
+ if( argv[i+1][0] == 'v')
++i;
}
}
@@ -972,7 +971,7 @@ main(int argc, char *argv[]) {
#endif
else if(!strncmp(argv[i], "-dock", 6))
use_ewmh_dock = 1;
- else if(!strncmp(argv[i], "-v", 3))
+ else if(!strncmp(argv[i], "-v", 3))
eprint("dzen-"VERSION", (C)opyright 2007-2008 Robert Manea\n");
else
eprint("usage: dzen2 [-v] [-p [seconds]] [-m [v|h]] [-ta <l|c|r>] [-sa <l|c|r>]\n"
@@ -994,7 +993,7 @@ main(int argc, char *argv[]) {
if(!setlocale(LC_ALL, "") || !XSupportsLocale())
puts("dzen: locale not available, expect problems with fonts.\n");
- if(action_string)
+ if(action_string)
fill_ev_table(action_string);
else {
if(!dzen.slave_win.max_lines) {
@@ -1020,18 +1019,18 @@ main(int argc, char *argv[]) {
}
}
- if((find_event(onexit) != -1)
+ if((find_event(onexit) != -1)
&& (setup_signal(SIGTERM, catch_sigterm) == SIG_ERR))
fprintf(stderr, "dzen: error hooking SIGTERM\n");
- if((find_event(sigusr1) != -1)
+ if((find_event(sigusr1) != -1)
&& (setup_signal(SIGUSR1, catch_sigusr1) == SIG_ERR))
fprintf(stderr, "dzen: error hooking SIGUSR1\n");
-
- if((find_event(sigusr2) != -1)
+
+ if((find_event(sigusr2) != -1)
&& (setup_signal(SIGUSR2, catch_sigusr2) == SIG_ERR))
fprintf(stderr, "dzen: error hooking SIGUSR2\n");
-
+
if(setup_signal(SIGALRM, catch_alrm) == SIG_ERR)
fprintf(stderr, "dzen: error hooking SIGALARM\n");
@@ -1041,8 +1040,7 @@ main(int argc, char *argv[]) {
x_create_windows(use_ewmh_dock);
- //dzen.title_win.x_right_corner = dzen.title_win.x + dzen.title_win.width;
-
+
if(!dzen.slave_win.ishmenu)
x_map_window(dzen.title_win.win);
else {