aboutsummaryrefslogtreecommitdiffstats
path: root/grab.c
diff options
context:
space:
mode:
Diffstat (limited to 'grab.c')
-rw-r--r--grab.c113
1 files changed, 1 insertions, 112 deletions
diff --git a/grab.c b/grab.c
index d4abc87..3aa7ff3 100644
--- a/grab.c
+++ b/grab.c
@@ -15,7 +15,7 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
- * $Id: grab.c,v 1.13 2008/05/20 14:50:51 oga Exp $
+ * $Id: grab.c,v 1.14 2008/05/21 14:11:19 oga Exp $
*/
#include "headers.h"
@@ -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)
{