void
tilemovemouse(const Arg *arg) {
	/* Could EnterNotify events be used instead? */
	Client *c, *d;
	Monitor *m;
	XEvent ev;
	int x, y;
	Bool after;

	if(!(c = selmon->sel))
		return;

	if((m = recttomon(c->x, c->y, c->w, c->h)) != selmon) {
		sendmon(c, m);
		selmon = m;
		focus(NULL);
	}

	if(c->isfloating || !selmon->lt[selmon->sellt]->arrange){
		movemouse(NULL);
		return;
	}
	if(XGrabPointer(dpy, root, False, MOUSEMASK, GrabModeAsync, GrabModeAsync,
		None, cursor[CurMove], CurrentTime) != GrabSuccess)
		return;
	do {
		XMaskEvent(dpy, MOUSEMASK|ExposureMask|SubstructureRedirectMask, &ev);
		switch (ev.type) {
		case ConfigureRequest:
		case Expose:
		case MapRequest:
			handler[ev.type](&ev);
			break;
		case MotionNotify:
			x = ev.xmotion.x;
			y = ev.xmotion.y;
			after = False;
			for(d = nexttiled(m->clients); d; d = nexttiled(d->next)){
				if(d == c)
					after = True;
				else if(INRECT(x, y, d->x, d->y, d->w+2*borderpx, d->h+2*borderpx)){
					detach(c);
					after ? insertafter(c, d) : insertbefore(c,d);
					arrange(c->mon);
					break;
				}
			}
		}
	} while(ev.type != ButtonRelease);
	XUngrabPointer(dpy, CurrentTime);
}
Exemple #2
0
/*
 * @implemented
 */
BOOL
WINAPI
PtInRegion(IN HRGN hrgn,
           int x,
           int y)
{
    PRGN_ATTR pRgn_Attr;

    // HACKFIX
    //if (!GdiGetHandleUserData((HGDIOBJ) hrgn, GDI_OBJECT_TYPE_REGION, (PVOID) &pRgn_Attr))
    return NtGdiPtInRegion(hrgn,x,y);

    if ( pRgn_Attr->iComplexity == NULLREGION)
        return FALSE;

    if ( pRgn_Attr->iComplexity != SIMPLEREGION)
        return NtGdiPtInRegion(hrgn,x,y);

    return INRECT( pRgn_Attr->Rect, x, y);
}
Exemple #3
0
void
setup(void) {
    int x, y, screen;
    XSetWindowAttributes wa;
#ifdef XINERAMA
    int n;
    XineramaScreenInfo *info;
#endif

    screen = DefaultScreen(dc->dpy);
    root = RootWindow(dc->dpy, screen);
    utf8 = XInternAtom(dc->dpy, "UTF8_STRING", False);

    normcol[ColBG] = getcolor(dc, normbgcolor);
    normcol[ColFG] = getcolor(dc, normfgcolor);
    selcol[ColBG] = getcolor(dc, selbgcolor);
    selcol[ColFG] = getcolor(dc, selfgcolor);

    /* menu geometry */
    bh = dc->font.height + 2;
    lines = MAX(lines, 0);
    mh = (MAX(MIN(lines + 1, itemcount), 1)) * bh;

    if(height < mh) {
        height = mh;
    }
#ifdef XINERAMA
    if((info = XineramaQueryScreens(dc->dpy, &n))) {
        int i, di;
        unsigned int du;
        Window dw;

        XQueryPointer(dc->dpy, root, &dw, &dw, &x, &y, &di, &di, &du);
        for(i = 0; i < n; i++)
            if((monitor == info[i].screen_number)
                    || (monitor < 0 && INRECT(x, y, info[i].x_org, info[i].y_org, info[i].width, info[i].height)))
                break;
        x = info[i].x_org;
        y = info[i].y_org + (topbar ? 0 : info[i].height - height);
        mw = info[i].width;
        XFree(info);
    }
    else
#endif
    {
        x = 0;
        y = topbar ? 0 : DisplayHeight(dc->dpy, screen) - height;
        mw = DisplayWidth(dc->dpy, screen);
    }
    /* menu window */
    wa.override_redirect = True;
    wa.background_pixmap = ParentRelative;
    wa.event_mask = ExposureMask | KeyPressMask | VisibilityChangeMask;
    win = XCreateWindow(dc->dpy, root, x, y, mw, height, 0,
                        DefaultDepth(dc->dpy, screen), CopyFromParent,
                        DefaultVisual(dc->dpy, screen),
                        CWOverrideRedirect | CWBackPixmap | CWEventMask, &wa);

    grabkeyboard();
    resizedc(dc, mw, height);
    inputw = MIN(inputw, mw/3);
    promptw = prompt ? textw(dc, prompt) : 0;
    XMapRaised(dc->dpy, win);
    text[0] = '\0';
    match();
}