wmii

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

commit 1e99e3beb39b8219c36b56f0e25c43efabfa978e
parent 7351dc80582735a2ba7e1c3ada7ccc1d6a242848
Author: Anselm R. Garbe <garbeam@wmii.de>
Date:   Wed, 22 Mar 2006 16:25:24 +0100

hopefully fixed cursor issue (following what rio did)


Diffstat:
cmd/wm/client.c | 4----
cmd/wm/event.c | 13++++++-------
cmd/wm/mouse.c | 24+-----------------------
cmd/wm/wm.h | 4+---
4 files changed, 8 insertions(+), 37 deletions(-)

diff --git a/cmd/wm/client.c b/cmd/wm/client.c @@ -51,12 +51,8 @@ alloc_client(Window w, XWindowAttributes *wa) c->rect.width + 2 * def.border, c->rect.height + def.border + bar_height(), 0, DefaultDepth(dpy, screen), CopyFromParent, DefaultVisual(dpy, screen), CWOverrideRedirect | CWBackPixmap | CWEventMask, &fwa); - - c->cursor = cursor[CurNormal]; - XDefineCursor(dpy, c->framewin, c->cursor); c->gc = XCreateGC(dpy, c->framewin, 0, 0); XSync(dpy, False); - client = (Client **)cext_array_attach((void **)client, c, sizeof(Client *), &clientsz); nclient++; diff --git a/cmd/wm/event.c b/cmd/wm/event.c @@ -60,7 +60,6 @@ handle_buttonpress(XEvent *e) { Client *c; XButtonPressedEvent *ev = &e->xbutton; - Align align; static char buf[32]; if(ev->window == barwin) { unsigned int i; @@ -73,11 +72,11 @@ 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); if(sel_client() != c) { focus(c); return; } - align = cursor2align(c->cursor); if(align == CENTER) mouse_move(c); else @@ -92,6 +91,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); switch (ev->button) { case Button1: focus(c); @@ -99,7 +99,6 @@ handle_buttonpress(XEvent *e) break; case Button3: focus(c); - align = xy2align(&c->rect, ev->x, ev->y); if(align == CENTER) mouse_move(c); else @@ -247,11 +246,11 @@ handle_motionnotify(XEvent *e) { Client *c = win2clientframe(e->xmotion.window); if(c) { - Cursor cur = cursor_for_motion(c, e->xmotion.x, e->xmotion.y); - if(cur != c->cursor) { - c->cursor = cur; + Cursor cur = cursor4motion(c, e->xmotion.x, e->xmotion.y); + if(cur == cursor[CurNormal]) + XUndefineCursor(dpy, c->framewin); + else XDefineCursor(dpy, c->framewin, cur); - } } } diff --git a/cmd/wm/mouse.c b/cmd/wm/mouse.c @@ -10,7 +10,7 @@ #include "wm.h" Cursor -cursor_for_motion(Client *c, int x, int y) +cursor4motion(Client *c, int x, int y) { Frame *f = c->frame[c->sel]; int n, e, w, s, tn, te, tw, ts; @@ -81,28 +81,6 @@ xy2align(XRectangle *rect, int x, int y) return CENTER; } -Align -cursor2align(Cursor cur) -{ - if(cur == cursor[CurW]) - return WEST; - else if(cur == cursor[CurNW]) - return NWEST; - else if(cur == cursor[CurN]) - return NORTH; - else if(cur == cursor[CurNE]) - return NEAST; - else if(cur == cursor[CurE]) - return EAST; - else if(cur == cursor[CurSE]) - return SEAST; - else if(cur == cursor[CurS]) - return SOUTH; - else if(cur == cursor[CurSW]) - return SWEST; - return CENTER; /* should not happen */ -} - static int check_vert_match(XRectangle *r, XRectangle *neighbor) { diff --git a/cmd/wm/wm.h b/cmd/wm/wm.h @@ -132,7 +132,6 @@ struct Client { XSizeHints size; Window framewin; GC gc; - Cursor cursor; Frame **frame; unsigned int framesz; unsigned int sel; @@ -284,8 +283,7 @@ void init_lock_modifiers(); /* mouse.c */ void mouse_resize(Client *c, Align align); void mouse_move(Client *c); -Cursor cursor_for_motion(Client *c, int x, int y); -Align cursor2align(Cursor cur); +Cursor cursor4motion(Client *c, int x, int y); Align xy2align(XRectangle *rect, int x, int y); void drop_move(Client *c, XRectangle *new, XPoint *pt); void grab_mouse(Window w, unsigned long mod, unsigned int button);