commit 906f5fb079eb7711f484602ad83c33f44b27cdaf
parent f6dee3c0a0796b473224d88d8beae63f85f35722
Author: Kris Maglione <bsdaemon@wmii.de>
Date: Fri, 23 Jun 2006 17:40:04 -0400
merge
Diffstat:
9 files changed, 43 insertions(+), 41 deletions(-)
diff --git a/cmd/wm/bar.c b/cmd/wm/bar.c
@@ -70,10 +70,6 @@ resize_bar()
brect.y = rect.height - brect.height;
XMoveResizeWindow(blz.display, barwin, brect.x, brect.y, brect.width, brect.height);
XSync(blz.display, False);
- XFreePixmap(blz.display, bbrush.drawable);
- bbrush.drawable = XCreatePixmap(blz.display, barwin, brect.width, brect.height,
- DefaultDepth(blz.display, blz.screen));
- XSync(blz.display, False);
draw_bar();
for(v=view; v; v=v->next) {
diff --git a/cmd/wm/event.c b/cmd/wm/event.c
@@ -88,8 +88,7 @@ handle_buttonrelease(XEvent *e)
}
else if((c = frame_of_win(ev->window)) && c->frame) {
if(ispointinrect(ev->x, ev->y, &c->sel->tagbar.rect)) {
- c->sel->tagbar.cursor = c->sel->tagbar.selend
- = blitz_charof(&c->sel->tagbar, ev->x, ev->y);
+ c->sel->tagbar.curend = blitz_charof(&c->sel->tagbar, ev->x, ev->y);
draw_frame(c->sel);
}
snprintf(buf, sizeof(buf), "ClientClick %d %d\n",
@@ -110,11 +109,11 @@ handle_motionnotify(XEvent *e)
if((c = frame_of_win(ev->window))) {
if(ispointinrect(ev->x, ev->y, &c->sel->tagbar.rect)) {
- c->sel->tagbar.selend = blitz_charof(&c->sel->tagbar, ev->x, ev->y);
- if(c->sel->tagbar.selend < c->sel->tagbar.selstart) {
- char *tmp = c->sel->tagbar.selend;
- c->sel->tagbar.selend = c->sel->tagbar.selstart;
- c->sel->tagbar.selstart = tmp;
+ c->sel->tagbar.curend = blitz_charof(&c->sel->tagbar, ev->x, ev->y);
+ if(c->sel->tagbar.curend < c->sel->tagbar.curstart) {
+ char *tmp = c->sel->tagbar.curend;
+ c->sel->tagbar.curend = c->sel->tagbar.curstart;
+ c->sel->tagbar.curstart = tmp;
}
draw_frame(c->sel);
}
@@ -130,8 +129,7 @@ handle_buttonpress(XEvent *e)
if((c = frame_of_win(ev->window))) {
ev->state &= valid_mask;
if(ispointinrect(ev->x, ev->y, &c->sel->tagbar.rect)) {
- c->sel->tagbar.cursor = c->sel->tagbar.selstart
- = c->sel->tagbar.selend
+ c->sel->tagbar.curstart = c->sel->tagbar.curend
= blitz_charof(&c->sel->tagbar, ev->x, ev->y);
draw_frame(c->sel);
drag = True;
diff --git a/cmd/wm/frame.c b/cmd/wm/frame.c
@@ -29,6 +29,7 @@ create_frame(Area *a, Client *c)
f->tile.gc = c->gc;
f->tile.font = &def.font;
f->tile.color = def.normcolor;
+ f->tile.border = True;
f->titlebar = f->posbar = f->tile;
f->titlebar.align = WEST;
f->posbar.align = CENTER;
@@ -37,8 +38,7 @@ create_frame(Area *a, Client *c)
f->tagbar.drawable = pmap;
f->tagbar.gc = c->gc;
f->tagbar.font = &def.font;
- f->tagbar.norm = def.normcolor;
- f->tagbar.sel = def.selcolor;
+ f->tagbar.color = def.normcolor;
a->sel = f;
c->sel = f;
@@ -127,9 +127,9 @@ void
update_frame_widget_colors(Frame *f)
{
if(sel_screen && (f->client == sel_client()))
- f->tile.color = f->titlebar.color = def.selcolor;
+ f->tagbar.color = f->tile.color = f->titlebar.color = def.selcolor;
else
- f->tile.color = f->titlebar.color = def.normcolor;
+ f->tagbar.color = f->tile.color = f->titlebar.color = def.normcolor;
if(f->area->sel == f)
f->posbar.color = def.selcolor;
diff --git a/cmd/wm/wm.c b/cmd/wm/wm.c
@@ -315,6 +315,9 @@ main(int argc, char *argv[])
init_lock_keys();
init_screen();
+ pmap = XCreatePixmap(blz.display, blz.root, rect.width, rect.height,
+ DefaultDepth(blz.display, blz.screen));
+
wa.event_mask = SubstructureRedirectMask | EnterWindowMask | LeaveWindowMask;
wa.cursor = cursor[CurNormal];
XChangeWindowAttributes(blz.display, blz.root, CWEventMask | CWCursor, &wa);
@@ -335,16 +338,14 @@ main(int argc, char *argv[])
bbrush.blitz = &blz;
bbrush.gc = XCreateGC(blz.display, barwin, 0, 0);
- bbrush.drawable = XCreatePixmap(blz.display, barwin, brect.width, brect.height,
- DefaultDepth(blz.display, blz.screen));
+ bbrush.drawable = pmap;
bbrush.rect = brect;
bbrush.rect.x = 0;
bbrush.rect.y = 0;
bbrush.color = def.normcolor;
bbrush.font = &def.font;
+ bbrush.border = True;
- pmap = XCreatePixmap(blz.display, blz.root, rect.width, rect.height,
- DefaultDepth(blz.display, blz.screen));
XMapRaised(blz.display, barwin);
draw_bar();
diff --git a/cmd/wmiimenu.c b/cmd/wmiimenu.c
@@ -134,6 +134,7 @@ draw_menu()
brush.rect.x = 0;
brush.rect.y = 0;
brush.color = normcolor;
+ brush.border = True;
blitz_draw_tile(&brush);
/* print command */
@@ -162,13 +163,16 @@ draw_menu()
/* determine maximum items */
for(i = curroff; i < nextoff; i++) {
+ brush.border = False;
brush.rect.x = offx;
brush.rect.width = blitz_textwidth(brush.font, item.data[i]);
if(brush.rect.width > irect.width / 3)
brush.rect.width = irect.width / 3;
brush.rect.width += irect.height;
- if(sel == i)
+ if(sel == i) {
brush.color = selcolor;
+ brush.border = True;
+ }
else
brush.color = normcolor;
blitz_draw_label(&brush, item.data[i]);
@@ -176,6 +180,7 @@ draw_menu()
}
brush.color = normcolor;
+ brush.border = False;
brush.rect.x = irect.width - seek;
brush.rect.width = seek;
blitz_draw_label(&brush, item.size > nextoff ? ">" : nil);
@@ -311,7 +316,7 @@ static char *
read_allitems()
{
static char *maxname = nil;
- char *p, buf[1024];
+ char *p, buf[1024];
unsigned int len = 0, max = 0;
while(fgets(buf, sizeof(buf), stdin)) {
diff --git a/liblitz/blitz.h b/liblitz/blitz.h
@@ -56,6 +56,7 @@ struct BlitzBrush {
Blitz *blitz;
Drawable drawable;
GC gc;
+ Bool border;
BlitzColor color;
BlitzAlign align;
BlitzFont *font;
@@ -65,14 +66,12 @@ struct BlitzBrush {
struct BlitzInput {
Blitz *blitz;
char *text;
- char *selstart;
- char *selend;
- char *cursor;
+ char *curstart;
+ char *curend;
unsigned int size;
Drawable drawable;
GC gc;
- BlitzColor sel;
- BlitzColor norm;
+ BlitzColor color;
BlitzFont *font;
XRectangle rect; /* relative rect */
};
@@ -84,8 +83,9 @@ void blitz_draw_tile(BlitzBrush *b);
/* color.c */
int blitz_loadcolor(Blitz *blitz, BlitzColor *c);
+/* draw.c */
void blitz_drawbg(Display *dpy, Drawable drawable, GC gc,
- XRectangle rect, BlitzColor c);
+ XRectangle rect, BlitzColor c, Bool border);
/* font.c */
unsigned int blitz_textwidth(BlitzFont *font, char *text);
diff --git a/liblitz/brush.c b/liblitz/brush.c
@@ -12,7 +12,8 @@
void
blitz_draw_tile(BlitzBrush *b)
{
- blitz_drawbg(b->blitz->display, b->drawable, b->gc, b->rect, b->color);
+ blitz_drawbg(b->blitz->display, b->drawable, b->gc, b->rect,
+ b->color, b->border);
}
void
diff --git a/liblitz/draw.c b/liblitz/draw.c
@@ -6,11 +6,14 @@
#include "blitz.h"
void
-blitz_drawbg(Display *dpy, Drawable drawable, GC gc, XRectangle rect, BlitzColor c)
+blitz_drawbg(Display *dpy, Drawable drawable, GC gc, XRectangle rect,
+ BlitzColor c, Bool border)
{
XPoint points[5];
XSetForeground(dpy, gc, c.bg);
XFillRectangles(dpy, drawable, gc, &rect, 1);
+ if(!border)
+ return;
XSetLineAttributes(dpy, gc, 1, LineSolid, CapButt, JoinMiter);
XSetForeground(dpy, gc, c.border);
points[0].x = rect.x;
diff --git a/liblitz/input.c b/liblitz/input.c
@@ -31,17 +31,14 @@ xchangegc(BlitzInput *i, BlitzColor *c, Bool invert)
}
static void
-xdrawtextpart(BlitzInput *i, BlitzColor *c, char *start, char *end,
+xdrawtextpart(BlitzInput *i, char *start, char *end,
int *xoff, int yoff, unsigned int boxw)
{
char *p, buf[2];
- xchangegc(i, c, False);
buf[1] = 0;
for(p = start; p && *p && p != end; p++) {
*buf = *p;
- if(p == i->cursor)
- xchangegc(i, c, True);
if(i->font->set)
XmbDrawImageString(i->blitz->display, i->drawable, i->font->set, i->gc,
*xoff, yoff, buf, 1);
@@ -49,8 +46,6 @@ xdrawtextpart(BlitzInput *i, BlitzColor *c, char *start, char *end,
XDrawImageString(i->blitz->display, i->drawable, i->gc, *xoff, yoff,
buf, 1);
*xoff += boxw;
- if(p == i->cursor)
- xchangegc(i, c, False);
}
}
@@ -74,16 +69,19 @@ blitz_draw_input(BlitzInput *i)
if (!i)
return;
- blitz_drawbg(i->blitz->display, i->drawable, i->gc, i->rect, i->norm);
+ blitz_drawbg(i->blitz->display, i->drawable, i->gc, i->rect, i->color, True);
xget_fontmetric(i, &xoff, &yoff, &boxw, &boxh);
nbox = i->rect.width / boxw;
/* draw normal text */
- xdrawtextpart(i, &i->norm, i->text, i->selstart, &xoff, yoff, boxw);
+ xchangegc(i, &i->color, False);
+ xdrawtextpart(i, i->text, i->curstart, &xoff, yoff, boxw);
/* draw sel text */
- xdrawtextpart(i, &i->sel, i->selstart, i->selend, &xoff, yoff, boxw);
+ xchangegc(i, &i->color, True);
+ xdrawtextpart(i, i->curstart, i->curend, &xoff, yoff, boxw);
/* draw remaining normal text */
- xdrawtextpart(i, &i->norm, i->selend, nil, &xoff, yoff, boxw);
+ xchangegc(i, &i->color, False);
+ xdrawtextpart(i, i->curend, nil, &xoff, yoff, boxw);
}
char *