Ejemplo n.º 1
0
int 
TkRectInRegion(
    TkRegion region,
    int x,
    int y,
    unsigned int width,
    unsigned int height)
{
    RgnHandle rgn = (RgnHandle) region;
    RgnHandle rectRgn, destRgn;
    int result;
    
    rectRgn = NewRgn();
    destRgn = NewRgn();
    SetRectRgn(rectRgn, x,  y, x + width, y + height);
    SectRgn(rgn, rectRgn, destRgn);
    if (EmptyRgn(destRgn)) {
	result = RectangleOut;
    } else if (EqualRgn(rgn, destRgn)) {
	result = RectangleIn;
    } else {
	result = RectanglePart;
    }
    DisposeRgn(rectRgn);
    DisposeRgn(destRgn);
    return result;
}
Ejemplo n.º 2
0
/*****************************************************************************
 * GdipIsEqualRegion [GDIPLUS.@]
 */
GpStatus WINGDIPAPI GdipIsEqualRegion(GpRegion *region, GpRegion *region2, GpGraphics *graphics,
                                      BOOL *res)
{
    HRGN hrgn1, hrgn2;
    GpStatus stat;

    TRACE("(%p, %p, %p, %p)\n", region, region2, graphics, res);

    if(!region || !region2 || !graphics || !res)
        return InvalidParameter;

    stat = GdipGetRegionHRgn(region, graphics, &hrgn1);
    if(stat != Ok)
        return stat;
    stat = GdipGetRegionHRgn(region2, graphics, &hrgn2);
    if(stat != Ok){
        DeleteObject(hrgn1);
        return stat;
    }

    *res = EqualRgn(hrgn1, hrgn2);

    /* one of GpRegions is infinite */
    if(*res == ERROR)
        *res = (!hrgn1 && !hrgn2);

    DeleteObject(hrgn1);
    DeleteObject(hrgn2);

    return Ok;
}
Ejemplo n.º 3
0
// Return true if region not equal to this one
FXbool FXRegion::operator!=(const FXRegion& r) const {
#ifdef WIN32
  return EqualRgn((HRGN)region,(HRGN)r.region)==0;
#else
  return !XEqualRegion((Region)region,(Region)r.region);
#endif
  }
Ejemplo n.º 4
0
// Return TRUE if region equal to this one
bool FXRegion::operator==(const FXRegion& r) const {
#ifndef WIN32
  return XEqualRegion((Region)region,(Region)r.region);
#else
  return EqualRgn((HRGN)region,(HRGN)r.region)!=0;
#endif
  }
Ejemplo n.º 5
0
static void hugsprim_EqualRgn_9(HugsStackPtr hugs_root)
{
    HsPtr arg1;
    HsPtr arg2;
    HsBool res1;
    arg1 = hugs->getPtr();
    arg2 = hugs->getPtr();
    res1 = EqualRgn(arg1, arg2);
    hugs->putBool(res1);
    hugs->returnIO(hugs_root,1);
}
Ejemplo n.º 6
0
// does this rectangle intersect current clip?
int Fl_Device::not_clipped(int x, int y, int w, int h)
{
    fl_transform(x,y);
    // first check against the window so we get rid of coordinates
    // outside the 16-bit range the X/Win32 calls take:
    if (x+w <= 0 || y+h <= 0 || x >= Fl_Window::current()->w()
        || y >= Fl_Window::current()->h()) return 0;
    Region r = rstack[rstackptr];
    if (!r) return 1;
#ifndef _WIN32
    return XRectInRegion(r, x, y, w, h);
#else
    //RECT rect;
    //rect.left = x; rect.top = y; rect.right = x+w; rect.bottom = y+h;
    //return RectInRegion(r,&rect);
    // The win32 API makes no distinction between partial and complete
    // intersection, so we have to check for partial intersection ourselves.
    int ret = 0;
    Region rr = XRectangleRegion(x,y,w,h);
    Region temp = CreateRectRgn(0,0,0,0);
                                 // disjoint
    if (CombineRgn(temp, rr, r, RGN_AND) == NULLREGION)
    {
        ret = 0;
    }                            // complete
    else if (EqualRgn(temp, rr))
    {
        ret = 1;
    }                            // parital intersection
    else
    {
        ret = 2;
    }
    DeleteObject(temp);
    DeleteObject(rr);
    return ret;
#endif
}
Ejemplo n.º 7
0
BOOL DSObjects::RMAEqualRegion(REGION* reg1, REGION* reg2)
{
	return EqualRgn((HRGN)reg1->pOSRegion, (HRGN)reg2->pOSRegion)
		&& !memcmp(&reg1->extents, &reg2->extents, sizeof(PNxRect)) ? TRUE : FALSE;
}
Ejemplo n.º 8
0
Archivo: load.c Proyecto: OSLL/vboxhsm
static void stubSyncTrUpdateWindowCB(unsigned long key, void *data1, void *data2)
{
    WindowInfo *pWindow = (WindowInfo *) data1;
    PVBOXCR_UPDATEWNDCB pCbData = (PVBOXCR_UPDATEWNDCB) data2;
    VBOXDISPMP_REGIONS *pRegions = &pCbData->Regions;
    bool bChanged = false, bDoMap = false;
    HRGN hNewRgn = INVALID_HANDLE_VALUE;

    if (pRegions->hWnd != pWindow->hWnd)
    {
        return;
    }

    stub.spu->dispatch_table.VBoxPackSetInjectID(pWindow->u32ClientID);

    if (!stubSystemWindowExist(pWindow))
    {
        stubDestroyWindow(0, (GLint)pWindow->hWnd);
        return;
    }

    if (pRegions->pRegions->fFlags.bAddVisibleRects || pRegions->pRegions->fFlags.bSetViewRect)
    {
        if (!pWindow->mapped)
        {
            bDoMap = true;
        }

        /* ensure data integrity */
        Assert(!pRegions->pRegions->fFlags.bAddHiddenRects);

        if (pRegions->pRegions->fFlags.bSetViewRect)
        {
            int winX, winY;
            unsigned int winW, winH;
            BOOL bRc;

            winX = pRegions->pRegions->RectsInfo.aRects[0].left;
            winY = pRegions->pRegions->RectsInfo.aRects[0].top;
            winW = pRegions->pRegions->RectsInfo.aRects[0].right - winX;
            winH = pRegions->pRegions->RectsInfo.aRects[0].bottom - winY;

            if (stub.trackWindowPos && (bDoMap || winX!=pWindow->x || winY!=pWindow->y))
            {
                crDebug("Dispatched WindowPosition (%i)", pWindow->spuWindow);
                stub.spuDispatch.WindowPosition(pWindow->spuWindow, winX, winY);
                pWindow->x = winX;
                pWindow->y = winY;
                bChanged = true;
            }

            if (stub.trackWindowSize && (bDoMap || winW!=pWindow->width || winH!=pWindow->height))
            {
                crDebug("Dispatched WindowSize (%i)", pWindow->spuWindow);
                stub.spuDispatch.WindowSize(pWindow->spuWindow, winW, winH);
                pWindow->width = winW;
                pWindow->height = winH;
                bChanged = true;
            }

            bRc = MoveWindow(pRegions->hWnd, winX, winY, winW, winH, FALSE /*BOOL bRepaint*/);
            if (!bRc)
            {
                DWORD winEr = GetLastError();
                crWarning("stubSyncTrUpdateWindowCB: MoveWindow failed winEr(%d)", winEr);
            }
        }

        if (pRegions->pRegions->fFlags.bAddVisibleRects)
        {
            hNewRgn = stubMakeRegionFromRects(pRegions->pRegions, pRegions->pRegions->fFlags.bSetViewRect ? 1 : 0);
        }
    }
    else if (!pRegions->pRegions->fFlags.bHide)
    {
        Assert(pRegions->pRegions->fFlags.bAddHiddenRects);
        hNewRgn = stubMakeRegionFromRects(pRegions->pRegions, 0);
    }
    else
    {
        Assert(pRegions->pRegions->fFlags.bAddHiddenRects);
        hNewRgn = CreateRectRgn(pWindow->x, pWindow->y, pWindow->x + pWindow->width, pWindow->y + pWindow->height);
    }

    if (hNewRgn!=INVALID_HANDLE_VALUE)
    {
        if (pRegions->pRegions->fFlags.bAddVisibleRects)
        {
            HRGN hEmptyRgn = CreateRectRgn(0, 0, 0, 0);

            if (hEmptyRgn!=INVALID_HANDLE_VALUE)
            {
                if (pWindow->hVisibleRegion==INVALID_HANDLE_VALUE || EqualRgn(pWindow->hVisibleRegion, hEmptyRgn))
                {
                    pCbData->fSendUpdateMsg = true;
                }

                DeleteObject(hEmptyRgn);
            }
            else
            {
                crWarning("Failed to created empty region!");
            }
        }

        OffsetRgn(hNewRgn, -pWindow->x, -pWindow->y);

        if (pWindow->hVisibleRegion!=INVALID_HANDLE_VALUE)
        {
            CombineRgn(hNewRgn, pWindow->hVisibleRegion, hNewRgn,
                       pRegions->pRegions->fFlags.bAddHiddenRects ? RGN_DIFF:RGN_OR);

            if (!EqualRgn(pWindow->hVisibleRegion, hNewRgn))
            {
                DeleteObject(pWindow->hVisibleRegion);
                pWindow->hVisibleRegion = hNewRgn;
                stubDispatchVisibleRegions(pWindow);
                bChanged = true;
            }
            else
            {
                DeleteObject(hNewRgn);
            }
        }
        else
        {
            if (pRegions->pRegions->fFlags.bAddVisibleRects)
            {
                pWindow->hVisibleRegion = hNewRgn;
                stubDispatchVisibleRegions(pWindow);
                bChanged = true;
            }
        }
    }

    if (bDoMap)
    {
        pWindow->mapped = GL_TRUE;
        bChanged = true;
        crDebug("Dispatched: WindowShow(%i, %i)", pWindow->spuWindow, pWindow->mapped);
        stub.spu->dispatch_table.WindowShow(pWindow->spuWindow, pWindow->mapped);
    }

    if (bChanged)
    {
        stub.spu->dispatch_table.Flush();
    }
}
Ejemplo n.º 9
0
static void test_GetClipRgn(void)
{
    HDC hdc;
    HRGN hrgn, hrgn2, hrgn3, hrgn4;
    int ret;

    /* Test calling GetClipRgn with NULL device context and region handles. */
    ret = GetClipRgn(NULL, NULL);
    ok(ret == -1, "Expected GetClipRgn to return -1, got %d\n", ret);

    hdc = GetDC(NULL);
    ok(hdc != NULL, "Expected GetDC to return a valid device context handle\n");

    /* Test calling GetClipRgn with a valid device context and NULL region. */
    ret = GetClipRgn(hdc, NULL);
    ok(ret == 0 ||
       ret == -1 /* Win9x */,
       "Expected GetClipRgn to return 0, got %d\n", ret);

    /* Initialize the test regions. */
    hrgn = CreateRectRgn(100, 100, 100, 100);
    ok(hrgn != NULL,
       "Expected CreateRectRgn to return a handle to a new rectangular region\n");

    hrgn2 = CreateRectRgn(1, 2, 3, 4);
    ok(hrgn2 != NULL,
       "Expected CreateRectRgn to return a handle to a new rectangular region\n");

    hrgn3 = CreateRectRgn(1, 2, 3, 4);
    ok(hrgn3 != NULL,
       "Expected CreateRectRgn to return a handle to a new rectangular region\n");

    hrgn4 = CreateRectRgn(1, 2, 3, 4);
    ok(hrgn4 != NULL,
       "Expected CreateRectRgn to return a handle to a new rectangular region\n");

    /* Try getting a clipping region from the device context
     * when the device context's clipping region isn't set. */
    ret = GetClipRgn(hdc, hrgn2);
    ok(ret == 0, "Expected GetClipRgn to return 0, got %d\n", ret);

    /* The region passed to GetClipRgn should be unchanged. */
    ret = EqualRgn(hrgn2, hrgn3);
    ok(ret == 1,
       "Expected EqualRgn to compare the two regions as equal, got %d\n", ret);

    /* Try setting and getting back a clipping region. */
    ret = SelectClipRgn(hdc, hrgn);
    ok(ret == NULLREGION,
       "Expected SelectClipRgn to return NULLREGION, got %d\n", ret);

    /* Passing a NULL region handle when the device context
     * has a clipping region results in an error. */
    ret = GetClipRgn(hdc, NULL);
    ok(ret == -1, "Expected GetClipRgn to return -1, got %d\n", ret);

    ret = GetClipRgn(hdc, hrgn2);
    ok(ret == 1, "Expected GetClipRgn to return 1, got %d\n", ret);

    ret = EqualRgn(hrgn, hrgn2);
    ok(ret == 1,
       "Expected EqualRgn to compare the two regions as equal, got %d\n", ret);

    /* Try unsetting and then query the clipping region. */
    ret = SelectClipRgn(hdc, NULL);
    ok(ret == SIMPLEREGION || (ret == COMPLEXREGION && GetSystemMetrics(SM_CMONITORS) > 1),
       "Expected SelectClipRgn to return SIMPLEREGION, got %d\n", ret);

    ret = GetClipRgn(hdc, NULL);
    ok(ret == 0 ||
       ret == -1 /* Win9x */,
       "Expected GetClipRgn to return 0, got %d\n", ret);

    ret = GetClipRgn(hdc, hrgn3);
    ok(ret == 0, "Expected GetClipRgn to return 0, got %d\n", ret);

    ret = EqualRgn(hrgn3, hrgn4);
    ok(ret == 1,
       "Expected EqualRgn to compare the two regions as equal, got %d\n", ret);

    DeleteObject(hrgn4);
    DeleteObject(hrgn3);
    DeleteObject(hrgn2);
    DeleteObject(hrgn);
    ReleaseDC(NULL, hdc);
}
Ejemplo n.º 10
0
/*
 *  Updates visible regions for given spu window.
 *  Returns GL_TRUE if regions changed since last call, GL_FALSE otherwise.
 */
GLboolean stubUpdateWindowVisibileRegions(WindowInfo *pWindow)
{
    HRGN hVisRgn;
    HWND hwnd;
    DWORD dwCount;
    LPRGNDATA lpRgnData;
    POINT pt;
    int iret;

    if (!pWindow) return GL_FALSE;
    hwnd = pWindow->hWnd;
    if (!hwnd) return GL_FALSE;

    if (hwnd!=WindowFromDC(pWindow->drawable))
    {
        crWarning("Window(%i) DC is no longer valid", pWindow->spuWindow);
        return GL_FALSE;
    }
    
    hVisRgn = CreateRectRgn(0,0,0,0);
    iret = GetRandomRgn(pWindow->drawable, hVisRgn, SYSRGN);

    if (iret==1)
    {
        /*@todo check win95/win98 here, as rects should be already in client space there*/
        /* Convert screen related rectangles to client related rectangles */
        pt.x = 0;
        pt.y = 0;
        ScreenToClient(hwnd, &pt);
        OffsetRgn(hVisRgn, pt.x, pt.y);

        /*
        dwCount = GetRegionData(hVisRgn, 0, NULL);
        lpRgnData = crAlloc(dwCount);
        crDebug("GetRandomRgn returned 1, dwCount=%d", dwCount);
        GetRegionData(hVisRgn, dwCount, lpRgnData);
        crDebug("Region consists of %d rects", lpRgnData->rdh.nCount);

        pRects = (RECT*) lpRgnData->Buffer;
        for (i=0; i<lpRgnData->rdh.nCount; ++i)
        {
            crDebug("Rgn[%d] = (%d, %d, %d, %d)", i, pRects[i].left, pRects[i].top, pRects[i].right, pRects[i].bottom);
        }
        crFree(lpRgnData);
        */

        if (pWindow->hVisibleRegion==INVALID_HANDLE_VALUE 
            || !EqualRgn(pWindow->hVisibleRegion, hVisRgn))
        {
            DeleteObject(pWindow->hVisibleRegion);
            pWindow->hVisibleRegion = hVisRgn;

            dwCount = GetRegionData(hVisRgn, 0, NULL);
            lpRgnData = crAlloc(dwCount);

            if (lpRgnData)
            {
                GetRegionData(hVisRgn, dwCount, lpRgnData);
                crDebug("Dispatched WindowVisibleRegion (%i, cRects=%i)", pWindow->spuWindow, lpRgnData->rdh.nCount);
                stub.spuDispatch.WindowVisibleRegion(pWindow->spuWindow, lpRgnData->rdh.nCount, (GLint*) lpRgnData->Buffer);
                crFree(lpRgnData);
                return GL_TRUE;
            }
            else crWarning("GetRegionData failed, VisibleRegions update failed");
        }
        else
        {
            DeleteObject(hVisRgn);
        }
    }
    else 
    {
        crWarning("GetRandomRgn returned (%d) instead of (1), VisibleRegions update failed", iret);
        DeleteObject(hVisRgn);
    }

    return GL_FALSE;
}
Ejemplo n.º 11
0
// return rectangle surrounding intersection of this rectangle and clip,
int Fl_Device::clip_box(int x, int y, int w, int h, int& X, int& Y, int& W, int& H)
{
    Region r = rstack[rstackptr];
    if (!r) {X = x; Y = y; W = w; H = h; return 0;}
    // Test against the window to get 16-bit values (this is only done if
    // a clip region exists as otherwise it breaks fl_push_no_clip()):
    int ret = 1;
    int dx = x; 
	int dy = y; 
	fl_transform(x,y); 
	dx = x-dx; 
	dy = y-dy;
    if (x < 0) { w += x; x = 0; ret = 2; }
    int t = Fl_Window::current()->w(); 
	if (x+w > t) { w = t-x; ret = 2; }
    if (y < 0) { h += y; y = 0; ret = 2; }
    t = Fl_Window::current()->h(); 
	if (y+h > t) { h = t-y; ret = 2; }
    
	// check for total clip (or for empty rectangle):
    if (w <= 0 || h <= 0) { W = H = 0; return 0; }

#ifndef _WIN32
    switch (XRectInRegion(r, x, y, w, h))
    {
        case 0:                  // completely outside
            W = H = 0;
            return 0;
        case 1:                  // completely inside:
            X = x-dx;
            Y = y-dy;
            W = w; H = h;
            return ret;
        default:                 // partial:
        {
            Region rr = XRectangleRegion(x,y,w,h);
            Region temp = XCreateRegion();
            XIntersectRegion(r, rr, temp);
            XRectangle rect;
            XClipBox(temp, &rect);
            X = rect.x-dx; Y = rect.y-dy; W = rect.width; H = rect.height;
            XDestroyRegion(temp);
            XDestroyRegion(rr);
            return 2;
        }
    }
#else
    // The win32 API makes no distinction between partial and complete
    // intersection, so we have to check for partial intersection ourselves.
    // However, given that the regions may be composite, we have to do
    // some voodoo stuff...
    Region rr = XRectangleRegion(x,y,w,h);
    Region temp = CreateRectRgn(0,0,0,0);
	
    if (CombineRgn(temp, rr, r, RGN_AND) == NULLREGION) {
		// disjoint
        W = H = 0;
        ret = 0;
    }
    else if (EqualRgn(temp, rr)) {
		// complete
        X = x-dx;
        Y = y-dy;
        W = w; H = h;
        // ret = ret
    } else {
		// parital intersection
        RECT rect;
        GetRgnBox(temp, &rect);
        X = rect.left-dx; Y = rect.top-dy;
        W = rect.right - rect.left; H = rect.bottom - rect.top;
        ret = 2;
    }
    DeleteObject(temp);
    DeleteObject(rr);
    return ret;
#endif
}