other cursor fixes

This commit is contained in:
Anselm R. Garbe 2006-03-22 17:08:21 +01:00
parent 8fac4081d7
commit 32426641d5
4 changed files with 15 additions and 10 deletions

View File

@ -72,7 +72,7 @@ handle_buttonpress(XEvent *e)
}
else if((c = win2clientframe(ev->window))) {
if(ev->button == Button1) {
Align align = xy2align(&c->frame[c->sel]->rect, ev->x, ev->y);
Align align = xy2align(&c->rect, ev->x, ev->y);
if(sel_client() != c) {
focus(c);
return;
@ -82,7 +82,6 @@ handle_buttonpress(XEvent *e)
else
mouse_resize(c, align);
}
if(c->nframe) {
snprintf(buf, sizeof(buf), "ClientClick %d %d\n", frame2index(c->frame[c->sel]) + 1, ev->button);
write_event(buf);
@ -91,7 +90,7 @@ handle_buttonpress(XEvent *e)
else if((c = win2client(ev->window))) {
ev->state &= valid_mask;
if(ev->state & Mod1Mask) {
Align align = xy2align(&c->frame[c->sel]->rect, ev->x, ev->y);
Align align = xy2align(&c->rect, ev->x, ev->y);
switch (ev->button) {
case Button1:
focus(c);
@ -247,7 +246,7 @@ handle_motionnotify(XEvent *e)
Client *c = win2clientframe(e->xmotion.window);
if(c) {
Cursor cur = cursor4motion(c, e->xmotion.x, e->xmotion.y);
if(cur == cursor[CurNormal])
if(cur == cursor[CurUnknown])
XUndefineCursor(dpy, c->framewin);
else
XDefineCursor(dpy, c->framewin, cur);

View File

@ -45,8 +45,10 @@ cursor4motion(Client *c, int x, int y)
return cursor[CurN];
else if(s)
return cursor[CurS];
return cursor[CurNormal];
if(tn)
return cursor[CurNormal];
return cursor[CurUnknown];
}
Align
@ -78,6 +80,7 @@ xy2align(XRectangle *rect, int x, int y)
return NORTH;
else if(s)
return SOUTH;
return CENTER;
}

View File

@ -139,6 +139,7 @@ init_atoms()
static void
init_cursors()
{
cursor[CurUnknown] = XCreateFontCursor(dpy, XC_cross);
cursor[CurNormal] = XCreateFontCursor(dpy, XC_left_ptr);
cursor[CurResize] = XCreateFontCursor(dpy, XC_sizing);
cursor[CurMove] = XCreateFontCursor(dpy, XC_fleur);
@ -169,8 +170,6 @@ init_screen()
rect.x = rect.y = 0;
rect.width = DisplayWidth(dpy, screen);
rect.height = DisplayHeight(dpy, screen);
XDefineCursor(dpy, root, cursor[CurNormal]);
}
/*
@ -331,10 +330,15 @@ main(int argc, char *argv[])
init_lock_modifiers();
init_screen();
wa.event_mask = ROOT_MASK;
wa.cursor = cursor[CurNormal];
XChangeWindowAttributes(dpy, root, CWEventMask | CWCursor, &wa);
wa.override_redirect = 1;
wa.background_pixmap = ParentRelative;
wa.event_mask = ExposureMask | ButtonPressMask
| SubstructureRedirectMask | SubstructureNotifyMask;
brect = rect;
brect.height = xfont->ascent + xfont->descent + 4;
brect.y = rect.height - brect.height;
@ -342,8 +346,6 @@ main(int argc, char *argv[])
brect.width, brect.height, 0, DefaultDepth(dpy, screen),
CopyFromParent, DefaultVisual(dpy, screen),
CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);
XDefineCursor(dpy, barwin, XCreateFontCursor(dpy, XC_left_ptr));
XSync(dpy, False);
bargc = XCreateGC(dpy, barwin, 0, 0);

View File

@ -27,6 +27,7 @@ enum {
/* Cursor */
enum {
CurUnknown,
CurNormal,
CurResize,
CurMove,