diff options
author | oga <oga> | 2008-05-21 14:11:19 +0000 |
---|---|---|
committer | oga <oga> | 2008-05-21 14:11:19 +0000 |
commit | 779cf04f0557baa2f94ab788e0a1c36cd3a613c5 (patch) | |
tree | 6f2ddece2052ee53f72065e48457a90ace015602 /grab.c | |
parent | 1e46ba72f706d7ab2b0f7a6a14054b908348d10e (diff) | |
download | cwm-779cf04f0557baa2f94ab788e0a1c36cd3a613c5.tar.gz cwm-779cf04f0557baa2f94ab788e0a1c36cd3a613c5.tar.xz cwm-779cf04f0557baa2f94ab788e0a1c36cd3a613c5.zip |
Make menu_filter handle mouse movement too. This enables the keyboard
search dialogues to be manipulated with the mouse, too. It also allows me to shrink the codebase further by killing grab_menu(). One known issue with highlighting the first entry in a search dialogue, that'll be fixed soonish. ok okan@, tested by Edd Barrett and todd@.
Diffstat (limited to 'grab.c')
-rw-r--r-- | grab.c | 111 |
1 files changed, 0 insertions, 111 deletions
diff --git a/grab.c b/grab.c index e27eb28..8a901c0 100644 --- a/grab.c +++ b/grab.c @@ -145,117 +145,6 @@ grab_drag(struct client_ctx *cc) /* NOTREACHED */ } -#define MenuMask (ButtonMask|ButtonMotionMask|ExposureMask) -#define MenuGrabMask (ButtonMask|ButtonMotionMask|StructureNotifyMask) -#define AllButtonMask (Button1Mask|Button2Mask|Button3Mask|Button4Mask|Button5Mask) - -void * -grab_menu(XButtonEvent *e, struct menu_q *menuq) -{ - struct screen_ctx *sc; - struct menu *mi; - XEvent event; - struct fontdesc *font = DefaultFont; - int x, y, width, height, tothigh, i, no, entry, prev; - int fx, fy; - - no = i = width = 0; - - if ((sc = screen_fromroot(e->root)) == NULL || e->window == sc->menuwin) - return (NULL); - - TAILQ_FOREACH(mi, menuq, entry) { - i = font_width(font, mi->text, strlen(mi->text)) + 4; - if (i > width) - width = i; - no++; - } - - height = font_ascent(font) + font_descent(font) + 1; - tothigh = height * no; - - x = e->x - width/2; - y = e->y - height/2; - - /* does it fit on the screen? */ - if (x < 0) - x = 0; - else if (x+width >= sc->xmax) - x = sc->xmax - width; - - if (y < 0) - y = 0; - else if (y+tothigh >= sc->ymax) - y = sc->ymax - tothigh; - - xu_ptr_setpos(e->root, x + width/2, y + height/2); - - XMoveResizeWindow(X_Dpy, sc->menuwin, x, y, width, tothigh); - XSelectInput(X_Dpy, sc->menuwin, MenuMask); - XMapRaised(X_Dpy, sc->menuwin); - - if (xu_ptr_grab(sc->menuwin, MenuGrabMask, Cursor_select) < 0) { - XUnmapWindow(X_Dpy, sc->menuwin); - return (NULL); - } - - entry = prev = -1; - - for (;;) { - XMaskEvent(X_Dpy, MenuMask, &event); - switch (event.type) { - case Expose: - XClearWindow(X_Dpy, sc->menuwin); - i = 0; - TAILQ_FOREACH(mi, menuq, entry) { - fx = (width - font_width(font, mi->text, - strlen(mi->text)))/2; - fy = height*i + font_ascent(font) + 1; - font_draw(font, mi->text, strlen(mi->text), - sc->menuwin, fx, fy); - i++; - } - /* FALLTHROUGH */ - case MotionNotify: - prev = entry; - entry = menu_calc_entry(event.xbutton.x, - event.xbutton.y, width, height, no); - if (prev != -1) - XFillRectangle(X_Dpy, sc->menuwin, sc->hlgc, - 0, height*prev, width, height); - if (entry != -1) { - xu_ptr_regrab(MenuGrabMask, Cursor_select); - XFillRectangle(X_Dpy, sc->menuwin, sc->hlgc, - 0, height*entry, width, height); - } else - xu_ptr_regrab(MenuGrabMask, Cursor_default); - break; - case ButtonRelease: - if (event.xbutton.button != e->button) - break; - entry = menu_calc_entry(event.xbutton.x, - event.xbutton.y, width, height, no); - xu_ptr_ungrab(); - XUnmapWindow(X_Dpy, sc->menuwin); - - i = 0; - TAILQ_FOREACH(mi, menuq, entry) - if (entry == i++) - break; - return (mi); - default: - break; - } - } -} - -void -grab_menuinit(struct screen_ctx *sc) -{ - sc->menuwin = XCreateSimpleWindow(X_Dpy, sc->rootwin, 0, 0, - 1, 1, 1, sc->blackpixl, sc->whitepixl); -} - static int _sweepcalc(struct client_ctx *cc, int x0, int y0, int motionx, int motiony) { |