wmii

git clone git://oldgit.suckless.org/wmii/
Log | Files | Refs | README | LICENSE

commit d520de9001f8c0a84bb5a23e1b2c6bb34c95200c
parent 3d6a47bba9d8ab346b683ac9db0aab24cdb84104
Author: Anselm R. Garbe <garbeam@wmii.de>
Date:   Thu,  6 Jul 2006 14:31:30 +0200

implemented proper cursor handling for input widget


Diffstat:
cmd/wm/frame.c | 3++-
liblitz/blitz.h | 4+++-
liblitz/input.c | 30+++++++++++++++++++++++-------
3 files changed, 28 insertions(+), 9 deletions(-)

diff --git a/cmd/wm/frame.c b/cmd/wm/frame.c @@ -44,7 +44,8 @@ create_frame(Client *c, View *v) f->tagbar.win = c->framewin; f->tagbar.gc = c->gc; f->tagbar.font = &def.font; - f->tagbar.cursor = cursor[CurInput]; + f->tagbar.cursor = f->tagbar.def = cursor[CurNormal]; + f->tagbar.input = cursor[CurInput]; f->tagbar.color = def.normcolor; f->tagbar.bcolor[0] = def.bcolor[0]; f->tagbar.bcolor[1] = def.bcolor[1]; diff --git a/liblitz/blitz.h b/liblitz/blitz.h @@ -70,12 +70,14 @@ struct BlitzInput { char *curstart; char *curend; Cursor cursor; + Cursor input; + Cursor def; + Bool drag; unsigned int size; unsigned int len; unsigned long tdbclk; int xdbclk, ydbclk; int button; - Bool drag; Drawable drawable; Window win; GC gc; diff --git a/liblitz/input.c b/liblitz/input.c @@ -45,6 +45,13 @@ xdrawtextpart(BlitzInput *i, char *start, char *end, *xoff += blitz_textwidth_l(i->font, start, len); } +static void +setcursor(BlitzInput *i, Cursor cur) +{ + XDefineCursor(i->blitz->dpy, i->win, cur); + i->cursor = cur; +} + void blitz_setinput(BlitzInput *i, char *text) { @@ -174,8 +181,14 @@ blitz_bpress_input(BlitzInput *i, int button, int x, int y) XEvent ev; char *ostart, *oend; - if(!(i->drag = blitz_ispointinrect(x, y, &i->rect))) + if(blitz_ispointinrect(x, y, &i->rect)) { + i->drag = True; + setcursor(i, i->input); + } + else { + setcursor(i, i->def); return; + } XSetInputFocus(i->blitz->dpy, i->win, RevertToPointerRoot, CurrentTime); ostart = i->curstart; @@ -275,9 +288,10 @@ blitz_brelease_input(BlitzInput *i, int button, int x, int y, unsigned long time i->ydbclk = y; Drop: + i->drag = False; if(i->button) i->curstart = i->curend; - i->drag = False; + setcursor(i, i->def); xdraw(i); } @@ -285,18 +299,20 @@ void blitz_bmotion_input(BlitzInput *i, int x, int y) { char *oend; - Bool focus; - - focus = blitz_ispointinrect(x, y, &i->rect); - if(focus) + if(blitz_ispointinrect(x, y, &i->rect)) { + setcursor(i, i->input); XSetInputFocus(i->blitz->dpy, i->win, RevertToPointerRoot, CurrentTime); - else + } + else { + setcursor(i, i->def); return; + } if(!i->drag) return; + oend = i->curend; i->curend = charof(i, x, y);