mirror of
https://github.com/0intro/wmii
synced 2025-02-19 15:54:24 +03:00
implemented proper cursor handling for input widget
This commit is contained in:
parent
3d6a47bba9
commit
d520de9001
@ -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];
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user