/* In some case (like compiz which doesn't provide us with clipping regions) we
 * have to make sure that *all* open OpenGL windows are clipped to the main
 * application window. This is done here when called from the event handler
 * which monitor bounding changes of the main window. */
static void crClipRootHelper(unsigned long key, void *data1, void *data2)
{
    /* The window with id zero is the base window, which isn't displayed at
     * all. So ignore it. */
    if (key > 0)
    {
        /* Fetch the actually window info & the user data */
        WindowInfo *pWin = (WindowInfo *) data1;
        /* We need to assign the context with this window */
        ContextInfo *context = renderspuGetWindowContext(pWin);
        if (context &&
            context->context)
        {
            RTSemFastMutexRequest(render_spu.syncMutex);
            GLboolean result = render_spu.ws.aglSetCurrentContext(context->context);
            CHECK_AGL_RC (result, "Render SPU (crClipRootHelper): SetCurrentContext Failed");
            if (result)
            {
                result = render_spu.ws.aglUpdateContext(context->context);
                CHECK_AGL_RC (result, "Render SPU (crClipRootHelper): UpdateContext Failed");
                /* Update the clipping region */
                renderspu_SystemWindowApplyVisibleRegion(pWin);
            }
            RTSemFastMutexRelease(render_spu.syncMutex);
            /* Make sure that the position is updated relative to the Qt main
             * view */
            renderspu_SystemWindowPosition(pWin, pWin->x, pWin->y);
        }
    }
}
示例#2
0
文件: renderspu.c 项目: apaka/vbox
static void RENDER_APIENTRY
renderspuWindowPosition( GLint win, GLint x, GLint y )
{
    if (!render_spu.ignore_window_moves) {
        WindowInfo *window;
        CRASSERT(win >= 0);
        window = (WindowInfo *) crHashtableSearch(render_spu.windowTable, win);
        if (window) {
            renderspu_SystemWindowPosition( window, x, y );
            window->x = x;
            window->y = y;
        }
        else {
            crDebug("Render SPU: Attempt to move invalid window (%d)", win);
        }
    }
}
/* Either show or hide the render SPU's window. */
void
renderspu_SystemShowWindow(WindowInfo *window, GLboolean showIt)
{
    CRASSERT(window);
    CRASSERT(window->window);

    if (!IsValidWindowPtr(window->window))
        return;

    if(showIt)
    {
        /* Force moving the win to the right position before we show it */
        renderspu_SystemWindowPosition (window, window->x, window->y);
        OSStatus status = noErr;
        /* Send a event to the main thread, cause some function of Carbon
         * aren't thread safe */
        EventRef evt;
        status = CreateEvent(NULL, kEventClassVBox, kEventVBoxShowWindow, 0, kEventAttributeNone, &evt);
        CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemShowWindow): CreateEvent Failed");
        status = SetEventParameter(evt, kEventParamWindowRef, typeWindowRef, sizeof (window->window), &window->window);
        CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemShowWindow): SetEventParameter Failed");
        status = SetEventParameter(evt, kEventParamUserData, typeVoidPtr, sizeof (window), &window);
        CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemWindowShow): SetEventParameter Failed");
        //status = SendEventToEventTarget (evt, GetWindowEventTarget (HIViewGetWindow ((HIViewRef)render_spu_parent_window_id)));
        status = PostEventToQueue(GetMainEventQueue(), evt, kEventPriorityStandard);
        CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemShowWindow): PostEventToQueue Failed");
    }
    else
    {
        EventRef evt;
        OSStatus status = CreateEvent(NULL, kEventClassVBox, kEventVBoxHideWindow, 0, kEventAttributeNone, &evt);
        CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemShowWindow): CreateEvent Failed");
        status = SetEventParameter(evt, kEventParamWindowRef, typeWindowRef, sizeof (window->window), &window->window);
        CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemShowWindow): SetEventParameter Failed");
        status = PostEventToQueue(GetMainEventQueue(), evt, kEventPriorityStandard);
        CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemShowWindow): PostEventToQueue Failed");
    }
}