mirror of
https://github.com/0intro/wmii
synced 2025-01-11 12:49:38 +03:00
using a global pixmap now
This commit is contained in:
parent
9ada8edddc
commit
993611c95d
@ -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) {
|
||||
|
@ -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;
|
||||
|
@ -37,8 +37,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 +126,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;
|
||||
|
@ -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,13 @@ 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;
|
||||
|
||||
pmap = XCreatePixmap(blz.display, blz.root, rect.width, rect.height,
|
||||
DefaultDepth(blz.display, blz.screen));
|
||||
|
||||
XMapRaised(blz.display, barwin);
|
||||
draw_bar();
|
||||
|
@ -65,14 +65,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 */
|
||||
};
|
||||
|
@ -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);
|
||||
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 *
|
||||
|
Loading…
Reference in New Issue
Block a user