VirtualBox

Ignore:
Timestamp:
Apr 1, 2009 5:20:48 PM (16 years ago)
Author:
vboxsync
Message:

crOpenGL-OSX: more fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_agl.c

    r18568 r18610  
    2525GLint gCurrentBufferName = 1;
    2626uint64_t gDockUpdateTS = 0;
     27static EventHandlerUPP gParentEventHandler = NULL;
    2728
    2829enum
     
    3637    kEventVBoxResizeWindow  = 'rwin',
    3738    kEventVBoxDisposeWindow = 'dwin',
    38     kEventVBoxUpdateDock    = 'udck'
     39    kEventVBoxUpdateDock    = 'udck',
     40    kEventVBoxUpdateContext = 'uctx'
    3941};
    4042
     
    8890windowEvtHndlr(EventHandlerCallRef myHandler, EventRef event, void* userData)
    8991{
    90     /* Currently this is *NOT* used */
    91 
    92 #pragma unused (userData)
    9392    WindowRef   window = NULL;
    94     Rect        rectPort = { 0, 0, 0, 0 };
    9593    OSStatus    result = eventNotHandledErr;
    96     UInt32      class = GetEventClass( event );
    97     UInt32      kind = GetEventKind( event );
     94    UInt32      class = GetEventClass (event);
     95    UInt32      kind = GetEventKind (event);
    9896
    9997    GetEventParameter(event, kEventParamDirectObject, typeWindowRef,
    10098                      NULL, sizeof(WindowRef), NULL, &window);
     99    /*
     100    Rect rectPort = { 0, 0, 0, 0 };
    101101    if( window )
    102102        GetWindowPortBounds( window, &rectPort );
    103 
    104     switch (class) {
    105     case kEventClassWindow:
    106         switch (kind) {
    107         case kEventWindowActivated:
     103    */
     104
     105    switch (class)
     106    {
     107        case kEventClassWindow:
     108        {
     109            WindowInfo *wi = (WindowInfo*)userData;
     110            switch (kind)
     111            {
    108112#ifndef __LP64__ /* not available for 64-bit processes? */
    109         case kEventWindowDrawContent:
    110 #endif
     113                case kEventWindowDrawContent:
     114                {
     115                    break;
     116                }
     117#endif
     118#ifndef __LP64__ /** @todo port to 64-bit darwin! Need to cehck if this event is generated or not (it probably isn't). */
     119                case kEventWindowShown:
     120                {
     121                //InvalWindowRect( window, &rectPort );
     122                    break;
     123                }
     124#endif
     125                case kEventWindowBoundsChanged:
     126                {
     127                    GLboolean result = true;
     128                    ContextInfo *context = renderspuGetWindowContext(wi);
     129
     130                    if (context &&
     131                        context->context)
     132                    {
     133                        DEBUG_MSG_POETZSCH (("kEventWindowBoundsChanged %x %x\n", wi->window, context->context));
     134                        //result = render_spu.ws.aglSetCurrentContext(context->context);
     135                        //result = render_spu.ws.aglUpdateContext(context->context);
     136                        //CHECK_AGL_RC (result, "Render SPU (windowEvtHndlr): UpdateContext Failed");
     137                        //render_spu.self.Flush();
     138                    }
     139                    //InvalWindowRect (window, &rectPort);
     140                    break;
     141                }
     142            };
    111143            break;
    112 
    113         case kEventWindowClose:
    114             HideWindow( window );
    115 #ifdef __LP64__ /** @todo port to 64-bit darwin. */
    116 #else
    117             SetWRefCon( window, (int)NULL );
    118 #endif
    119 
    120             crWarning( "Render SPU: caught kEventWindowClose -- quitting." );
    121             break;
    122 
    123         case kEventWindowShown:
    124             /* build gl */
     144        }
     145        case kEventClassVBox:
     146        {
     147            switch (kind)
     148            {
     149                case kEventVBoxUpdateContext:
     150                {
    125151#ifndef __LP64__ /** @todo port to 64-bit darwin! Need to cehck if this event is generated or not (it probably isn't). */
    126             if( window == FrontWindow() )
    127                 SetUserFocusWindow( window );
    128             InvalWindowRect( window, &rectPort );
    129 #endif
    130             break;
    131 
    132         case kEventWindowBoundsChanged:
    133             /* resize
    134                update */
    135             break;
    136 
    137         case kEventWindowZoomed:
    138             /* zoom button */
     152                    WindowInfo *wi1;
     153                    GetEventParameter(event, kEventParamUserData, typeVoidPtr,
     154                                      NULL, sizeof(wi1), NULL, &wi1);
     155                    ContextInfo *context = renderspuGetWindowContext(wi1);
     156                    GLboolean result1 = true;
     157                    if (context &&
     158                        context->context)
     159                    {
     160                        DEBUG_MSG_POETZSCH (("kEventVBoxUpdateContext %x %x\n", window, context->context));
     161                        result1 = render_spu.ws.aglSetCurrentContext(context->context);
     162                        result1 = render_spu.ws.aglUpdateContext(context->context);
     163                        CHECK_AGL_RC (result, "Render SPU (windowEvtHndlr): UpdateContext Failed");
     164                        //glFlush();
     165                    }
     166                    result = noErr;
     167#endif
     168                    break;
     169                }
     170            };
    139171            break;
    140172        }
    141173        break;
    142     }
     174    };
    143175
    144176    return result;
     
    149181{
    150182    if(visual->visAttribs & CR_PBUFFER_BIT)
    151         crWarning("Render SPU: PBuffers not support on Darwin/AGL yet.");
     183        crWarning("Render SPU (renderspu_SystemInitVisual): PBuffers not support on Darwin/AGL yet.");
    152184
    153185    return GL_TRUE;
     
    231263
    232264    if( !renderspuChoosePixelFormat(context, &pix) ) {
    233         crError( "Render SPU: Unable to create pixel format" );
     265        crError( "Render SPU (renderspu_SystemCreateContext): Unable to create pixel format" );
    234266        return GL_FALSE;
    235267    }
     
    239271
    240272    if( !context->context ) {
    241         crError( "Render SPU: Could not create rendering context" );
     273        crError( "Render SPU (renderspu_SystemCreateContext): Could not create rendering context" );
    242274        return GL_FALSE;
    243275    }
     
    292324        if( !renderspuChoosePixelFormat(context, &pix) )
    293325        {
    294             crError( "Render SPU: Unable to create pixel format" );
     326            crError( "Render SPU (renderspuWindowAttachContext): Unable to create pixel format" );
    295327            return GL_FALSE;
    296328        }
     
    300332        if( !wi->dummyContext )
    301333        {
    302             crError( "Render SPU: Could not create rendering context" );
     334            crError( "Render SPU (renderspuWindowAttachContext): Could not create rendering context" );
    303335            return GL_FALSE;
    304336        }
     
    314346         * sharing of the same hardware buffer afterwards. */
    315347        result = render_spu.ws.aglSetInteger(wi->dummyContext, AGL_BUFFER_NAME, &wi->bufferName);
    316         CHECK_AGL_RC (result, "Render SPU: SetInteger Failed");
     348        CHECK_AGL_RC (result, "Render SPU (renderspuWindowAttachContext): SetInteger Failed");
    317349        /* Assign the dummy context to the window */
    318350        result = render_spu.ws.aglSetDrawable(wi->dummyContext, drawable);
    319         CHECK_AGL_RC (result, "Render SPU: SetDrawable Failed");
     351        CHECK_AGL_RC (result, "Render SPU (renderspuWindowAttachContext): SetDrawable Failed");
    320352    }
    321353
     
    334366        /* Reset the current context */
    335367        result = render_spu.ws.aglSetDrawable(context->context, NULL);
    336         CHECK_AGL_RC (result, "Render SPU: SetDrawable Failed");
     368        CHECK_AGL_RC (result, "Render SPU (renderspuWindowAttachContext): SetDrawable Failed");
    337369        /* Set the buffer name of the dummy context to the current context
    338370         * also. After that both share the same hardware buffer. */
    339371        render_spu.ws.aglSetInteger (context->context, AGL_BUFFER_NAME, &wi->bufferName);
    340         CHECK_AGL_RC (result, "Render SPU: SetInteger Failed");
     372        CHECK_AGL_RC (result, "Render SPU (renderspuWindowAttachContext): SetInteger Failed");
    341373        /* Set the new drawable */
    342374#ifdef __LP64__ /** @todo port to 64-bit darwin. */
     
    345377        result = render_spu.ws.aglSetDrawable(context->context, newDrawable);
    346378#endif
    347         CHECK_AGL_RC (result, "Render SPU: SetDrawable Failed");
     379        CHECK_AGL_RC (result, "Render SPU (renderspuWindowAttachContext): SetDrawable Failed");
    348380        renderspuSetWindowContext( window, context );
    349381    }
    350382    result = render_spu.ws.aglSetCurrentContext(context->context);
    351     CHECK_AGL_RC (result, "Render SPU: SetCurrentContext Failed");
     383    CHECK_AGL_RC (result, "Render SPU (renderspuWindowAttachContext): SetCurrentContext Failed");
    352384    result = render_spu.ws.aglUpdateContext(context->context);
    353     CHECK_AGL_RC (result, "Render SPU: UpdateContext Failed");
     385    CHECK_AGL_RC (result, "Render SPU (renderspuWindowAttachContext): UpdateContext Failed");
    354386
    355387    return result;
     
    373405        EventRef evt;
    374406        OSStatus status = CreateEvent(NULL, kEventClassVBox, kEventVBoxDisposeWindow, 0, kEventAttributeNone, &evt);
    375         CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU: CreateEvent Failed");
     407        CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemDestroyWindow): CreateEvent Failed");
    376408        status = SetEventParameter(evt, kEventParamWindowRef, typeWindowRef, sizeof (window->window), &window->window);
    377         CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU: SetEventParameter Failed");
    378         status = SendEventToEventTarget (evt, GetWindowEventTarget (HIViewGetWindow ((HIViewRef)render_spu_parent_window_id)));
    379         CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU: PostEventToQueue Failed");
     409        CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemDestroyWindow): SetEventParameter Failed");
     410        //status = SendEventToEventTarget (evt, GetWindowEventTarget (HIViewGetWindow ((HIViewRef)render_spu_parent_window_id)));
     411        status = PostEventToQueue(GetMainEventQueue(), evt, kEventPriorityStandard);
     412        CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemDestroyWindow): PostEventToQueue Failed");
    380413    }
    381414
     
    405438    EventRef evt;
    406439    status = CreateEvent(NULL, kEventClassVBox, kEventVBoxResizeWindow, 0, kEventAttributeNone, &evt);
    407     CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU: CreateEvent Failed");
     440    CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemWindowSize): CreateEvent Failed ");
    408441    status = SetEventParameter(evt, kEventParamWindowRef, typeWindowRef, sizeof(window->window), &window->window);
    409     CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU: SetEventParameter Failed");
     442    CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemWindowSize): SetEventParameter Failed");
    410443    HISize s = CGSizeMake (w, h);
    411444    status = SetEventParameter(evt, kEventParamDimensions, typeHISize, sizeof (s), &s);
    412     CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU: SetEventParameter Failed");
    413     status = SendEventToEventTarget (evt, GetWindowEventTarget (HIViewGetWindow ((HIViewRef)render_spu_parent_window_id)));
    414     CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU: PostEventToQueue Failed");
    415 
    416     /* Update the context */
    417     GLboolean result = true;
    418     ContextInfo *context = renderspuGetWindowContext(window);
    419     if (context &&
    420         context->context)
    421     {
    422         DEBUG_MSG_POETZSCH (("Size %d context %x visible %d\n", window->id, context->context, IsWindowVisible (window->window)));
    423         result = render_spu.ws.aglUpdateContext(context->context);
    424         CHECK_AGL_RC (result, "Render SPU: UpdateContext Failed");
    425         render_spu.self.Flush();
    426     }
     445    CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemWindowSize): SetEventParameter Failed");
     446    status = SetEventParameter(evt, kEventParamUserData, typeVoidPtr, sizeof (window), &window);
     447    CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemWindowSize): SetEventParameter Failed");
     448    //status = SendEventToEventTarget (evt, GetWindowEventTarget (HIViewGetWindow ((HIViewRef)render_spu_parent_window_id)));
     449    status = PostEventToQueue(GetMainEventQueue(), evt, kEventPriorityStandard);
     450    CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemWindowSize): SendEventToEventTarget Failed");
     451
     452    /* We are tracking the position of the overlay window ourself. If the user
     453       switch to fullscreen/seamless there is no hint that the position has
     454       changed. (In the guest point of view it hasn't changed when the pos is
     455       at (0, 0). So to be on the save side we post an additional pos event if
     456       this is the case. */
     457    if (window->x == 0 &&
     458        window->y == 0)
     459        renderspu_SystemWindowPosition (window, 0, 0);
     460    else
     461    {
     462        /* Update the context. If the above position call is done this isn't
     463           necessary cause its already done there. */
     464        GLboolean result = true;
     465        ContextInfo *context = renderspuGetWindowContext(window);
     466        if (context &&
     467            context->context)
     468        {
     469            //result = render_spu.ws.aglUpdateContext(context->context);
     470            //CHECK_AGL_RC (result, "Render SPU (renderspu_SystemWindowSize): UpdateContext Failed");
     471            //glFlush();
     472        }
     473    }
     474    DEBUG_MSG_POETZSCH (("Size %d visible %d\n", window->id, IsWindowVisible (window->window)));
    427475    /* save the new size */
    428476    window->width = w;
     
    441489    Rect r;
    442490    status = GetWindowBounds(window->window, kWindowStructureRgn, &r);
    443     CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU: GetWindowBounds Failed");
     491    CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemGetWindowGeometry): GetWindowBounds Failed");
    444492
    445493    *x = (int) r.left;
     
    463511    status = GetWindowResizeLimits (window->window, NULL, &s);
    464512#endif
    465     CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU: GetWindowResizeLimits Failed");
     513    CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemGetMaxWindowSize): GetWindowResizeLimits Failed");
    466514
    467515    *w = s.width;
     
    481529    EventRef evt;
    482530    status = CreateEvent(NULL, kEventClassVBox, kEventVBoxMoveWindow, 0, kEventAttributeNone, &evt);
    483     CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU: CreateEvent Failed");
     531    CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemWindowPosition): CreateEvent Failed");
    484532    status = SetEventParameter(evt, kEventParamWindowRef, typeWindowRef, sizeof(window->window), &window->window);
    485     CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU: SetEventParameter Failed");
     533    CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemWindowPosition): SetEventParameter Failed");
    486534    HIPoint p = CGPointMake (x, y);
    487535    status = SetEventParameter(evt, kEventParamOrigin, typeHIPoint, sizeof (p), &p);
    488     CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU: SetEventParameter Failed");
    489     status = SendEventToEventTarget (evt, GetWindowEventTarget (HIViewGetWindow ((HIViewRef)render_spu_parent_window_id)));
    490     CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU: PostEventToQueue Failed");
     536    CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemWindowPosition): SetEventParameter Failed");
     537    status = SetEventParameter(evt, kEventParamUserData, typeVoidPtr, sizeof (window), &window);
     538    CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemWindowPosition): SetEventParameter Failed");
     539    //status = SendEventToEventTarget (evt, GetWindowEventTarget (HIViewGetWindow ((HIViewRef)render_spu_parent_window_id)));
     540    status = PostEventToQueue(GetMainEventQueue(), evt, kEventPriorityStandard);
     541    CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemWindowPosition): PostEventToQueue Failed");
    491542
    492543    /* Update the context */
     
    497548    {
    498549        DEBUG_MSG_POETZSCH (("Position %d context %x visible %d\n", window->id, context->context, IsWindowVisible (window->window)));
    499         result = render_spu.ws.aglUpdateContext(context->context);
    500         CHECK_AGL_RC (result, "Render SPU: UpdateContext Failed");
    501         render_spu.self.Flush();
    502     }
     550        //result = render_spu.ws.aglUpdateContext(context->context);
     551        //CHECK_AGL_RC (result, "Render SPU (renderspu_SystemWindowPosition): UpdateContext Failed");
     552        //glFlush();
     553    }
     554    /* save the new pos */
     555    window->x = x;
     556    window->y = y;
    503557}
    504558
     
    522576        EventRef evt;
    523577        status = CreateEvent(NULL, kEventClassVBox, kEventVBoxShowWindow, 0, kEventAttributeNone, &evt);
    524         CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU: CreateEvent Failed");
     578        CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemShowWindow): CreateEvent Failed");
    525579        status = SetEventParameter(evt, kEventParamWindowRef, typeWindowRef, sizeof (window->window), &window->window);
    526         CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU: SetEventParameter Failed");
    527         status = SendEventToEventTarget (evt, GetWindowEventTarget (HIViewGetWindow ((HIViewRef)render_spu_parent_window_id)));
    528         CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU: PostEventToQueue Failed");
     580        CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemShowWindow): SetEventParameter Failed");
     581        status = SetEventParameter(evt, kEventParamUserData, typeVoidPtr, sizeof (window), &window);
     582        CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemWindowShow): SetEventParameter Failed");
     583        //status = SendEventToEventTarget (evt, GetWindowEventTarget (HIViewGetWindow ((HIViewRef)render_spu_parent_window_id)));
     584        status = PostEventToQueue(GetMainEventQueue(), evt, kEventPriorityStandard);
     585        CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemShowWindow): PostEventToQueue Failed");
    529586    }
    530587    else
     
    532589        EventRef evt;
    533590        OSStatus status = CreateEvent(NULL, kEventClassVBox, kEventVBoxHideWindow, 0, kEventAttributeNone, &evt);
    534         CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU: CreateEvent Failed");
     591        CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemShowWindow): CreateEvent Failed");
    535592        status = SetEventParameter(evt, kEventParamWindowRef, typeWindowRef, sizeof (window->window), &window->window);
    536         CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU: SetEventParameter Failed");
    537         status = SendEventToEventTarget (evt, GetWindowEventTarget (HIViewGetWindow ((HIViewRef)render_spu_parent_window_id)));
    538         CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU: PostEventToQueue Failed");
     593        CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemShowWindow): SetEventParameter Failed");
     594        //status = SendEventToEventTarget (evt, GetWindowEventTarget (HIViewGetWindow ((HIViewRef)render_spu_parent_window_id)));
     595        status = PostEventToQueue(GetMainEventQueue(), evt, kEventPriorityStandard);
     596        CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemShowWindow): PostEventToQueue Failed");
    539597    }
    540598
     
    547605        DEBUG_MSG_POETZSCH (("Showed %d context %x visible %d\n", window->id, context->context, IsWindowVisible (window->window)));
    548606        result = render_spu.ws.aglUpdateContext(context->context);
    549         CHECK_AGL_RC (result, "Render SPU: UpdateContext Failed");
    550         render_spu.self.Flush();
     607        CHECK_AGL_RC (result, "Render SPU (renderspu_SystemShowWindow): UpdateContext Failed");
     608        glFlush();
    551609    }
    552610
     
    562620
    563621    CRASSERT(render_spu.ws.aglSetCurrentContext);
    564     crDebug( "renderspu_SystemMakeCurrent( %x, %i, %x )", window, nativeWindow, context );
     622    //crDebug( "renderspu_SystemMakeCurrent( %x, %i, %x )", window, nativeWindow, context );
    565623
    566624    if(window && context)
     
    571629        if(window->visual != context->visual)
    572630        {
    573             crDebug("Render SPU: MakeCurrent visual mismatch (0x%x != 0x%x); remaking window.",
     631            crDebug("Render SPU (renderspu_SystemMakeCurrent): MakeCurrent visual mismatch (0x%x != 0x%x); remaking window.",
    574632                    (uint)window->visual->visAttribs, (uint)context->visual->visAttribs);
    575633            /*
     
    594652            if (!window->everCurrent || f[1] < 0.0)
    595653            {
    596                 crDebug("Render SPU: Resetting raster pos");
     654                crDebug("Render SPU (renderspu_SystemMakeCurrent): Resetting raster pos");
    597655                render_spu.self.WindowPos2iARB(0, 0);
    598656            }
     
    612670
    613671    if(!context)
    614         crError("Render SPU: SwapBuffers got a null context from the window");
    615 
    616     DEBUG_MSG_POETZSCH (("Swapped %d context %x visible: %d\n", window->id, context->context, IsWindowVisible (window->window)));
    617     render_spu.ws.aglSwapBuffers(context->context);
     672        crError("Render SPU (renderspu_SystemSwapBuffers): SwapBuffers got a null context from the window");
     673
     674//    DEBUG_MSG_POETZSCH (("Swapped %d context %x visible: %d\n", window->id, context->context, IsWindowVisible (window->window)));
     675    if (context->visual->visAttribs & CR_DOUBLE_BIT)
     676        render_spu.ws.aglSwapBuffers(context->context);
     677    else
     678        glFlush();
    618679
    619680    /* This method seems called very often. To prevent the dock using all free
     
    627688        EventRef evt;
    628689        status = CreateEvent(NULL, kEventClassVBox, kEventVBoxUpdateDock, 0, kEventAttributeNone, &evt);
    629         CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU: CreateEvent Failed");
     690        CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemSwapBuffers): CreateEvent Failed");
    630691        status = PostEventToQueue(GetMainEventQueue(), evt, kEventPriorityStandard);
    631         CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU: PostEventToQueue Failed");
     692        CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemSwapBuffers): PostEventToQueue Failed");
    632693
    633694        gDockUpdateTS = curTS;
     
    640701    CRASSERT(window->window);
    641702
     703    DEBUG_MSG_POETZSCH (("Visible region \n"));
    642704    ContextInfo *c;
    643705    c = renderspuGetWindowContext (window);
     
    662724        /* Set the clip region to the context */
    663725        result = render_spu.ws.aglSetInteger(c->context, AGL_CLIP_REGION, (const GLint*)rgn);
    664         CHECK_AGL_RC (result, "Render SPU: SetInteger Failed");
     726        CHECK_AGL_RC (result, "Render SPU (renderspu_SystemWindowVisibleRegion): SetInteger Failed");
    665727        result = render_spu.ws.aglEnable(c->context, AGL_CLIP_REGION);
    666         CHECK_AGL_RC (result, "Render SPU: Enable Failed");
     728        CHECK_AGL_RC (result, "Render SPU (renderspu_SystemWindowVisibleRegion): Enable Failed");
    667729        /* Clear the region structure */
    668730        DisposeRgn (rgn);
     
    689751        EventRef evt;
    690752        status = CreateEvent(NULL, kEventClassVBox, kEventVBoxDisposeWindow, 0, kEventAttributeNone, &evt);
    691         CHECK_CARBON_RC_RETURN (status, "Render SPU: CreateEvent Failed", false);
     753        CHECK_CARBON_RC_RETURN (status, "Render SPU (renderspu_SystemVBoxCreateWindow): CreateEvent Failed", false);
    692754        status = SetEventParameter(evt, kEventParamWindowRef, typeWindowRef, sizeof (window->window), &window->window);
    693         CHECK_CARBON_RC_RETURN (status, "Render SPU: SetEventParameter Failed", false);
    694         status = SendEventToEventTarget (evt, GetWindowEventTarget (HIViewGetWindow ((HIViewRef)render_spu_parent_window_id)));
    695         CHECK_CARBON_RC_RETURN (status, "Render SPU: PostEventToQueue Failed", false);
     755        CHECK_CARBON_RC_RETURN (status, "Render SPU (renderspu_SystemVBoxCreateWindow): SetEventParameter Failed", false);
     756        //status = SendEventToEventTarget (evt, GetWindowEventTarget (HIViewGetWindow ((HIViewRef)render_spu_parent_window_id)));
     757        status = PostEventToQueue(GetMainEventQueue(), evt, kEventPriorityStandard);
     758        CHECK_CARBON_RC_RETURN (status, "Render SPU (renderspu_SystemVBoxCreateWindow): PostEventToQueue Failed", false);
    696759    }
    697760
     
    702765
    703766    status = CreateNewWindow(winClass, winAttr, &windowRect, &window->window);
    704     CHECK_CARBON_RC_RETURN (status, "Render SPU: CreateNewWindow Failed", GL_FALSE);
     767    CHECK_CARBON_RC_RETURN (status, "Render SPU (renderspu_SystemVBoxCreateWindow): CreateNewWindow Failed", GL_FALSE);
    705768
    706769    /* We set a title for debugging purposes */
     
    716779    {
    717780        status = CreateWindowGroup(kWindowGroupAttrMoveTogether | kWindowGroupAttrLayerTogether | kWindowGroupAttrSharedActivation | kWindowGroupAttrHideOnCollapse | kWindowGroupAttrFixedLevel, &gMasterGroup);
    718         CHECK_CARBON_RC_RETURN (status, "Render SPU: CreateWindowGroup Failed", GL_FALSE);
     781        CHECK_CARBON_RC_RETURN (status, "Render SPU (renderspu_SystemVBoxCreateWindow): CreateWindowGroup Failed", GL_FALSE);
    719782        status = CreateWindowGroup(kWindowGroupAttrMoveTogether | kWindowGroupAttrLayerTogether | kWindowGroupAttrSharedActivation | kWindowGroupAttrHideOnCollapse | kWindowGroupAttrFixedLevel, &gParentGroup);
    720         CHECK_CARBON_RC_RETURN (status, "Render SPU: CreateWindowGroup Failed", GL_FALSE);
     783        CHECK_CARBON_RC_RETURN (status, "Render SPU (renderspu_SystemVBoxCreateWindow): CreateWindowGroup Failed", GL_FALSE);
    721784        /* Make the correct z-layering */
    722785        SendWindowGroupBehind (gParentGroup, gMasterGroup);
     
    734797        parent = HIViewGetWindow ((HIViewRef)render_spu_parent_window_id);
    735798        SetWindowGroup (parent, gParentGroup);
     799
     800        /* We need to process events from our main window */
     801        if(!gParentEventHandler)
     802        {
     803            /* Install the event handlers */
     804            EventTypeSpec eventList[] =
     805            {
     806                {kEventClassVBox, kEventVBoxUpdateContext}
     807            };
     808
     809            gParentEventHandler = NewEventHandlerUPP(windowEvtHndlr);
     810
     811            InstallApplicationEventHandler (gParentEventHandler,
     812                                            GetEventTypeCount(eventList), eventList,
     813                                            NULL, NULL);
     814        }
    736815    }
    737816    /* Add the new window to the master group */
     
    742821        /* Even though there are still issues with the windows themselves,
    743822           install the event handlers */
    744         EventTypeSpec event_list[] = { {kEventClassWindow, kEventWindowClose} };
     823        EventTypeSpec event_list[] = { {kEventClassWindow, kEventWindowBoundsChanged} };
    745824
    746825        window->event_handler = NewEventHandlerUPP( windowEvtHndlr );
    747826
    748         /*InstallWindowEventHandler(window->window, window->event_handler,
    749                                    GetEventTypeCount(event_list), event_list,
    750                                    NULL, NULL);*/
    751     }
     827        /*
     828        InstallWindowEventHandler(window->window, window->event_handler,
     829                                  GetEventTypeCount(event_list), event_list,
     830                                  window, NULL);
     831                                  */
     832    }
     833
    752834
    753835    /* This will be initialized on the first attempt to attach the global
     
    759841        renderspu_SystemShowWindow(window, GL_TRUE);
    760842
    761     crDebug("Render SPU: actual window (x, y, width, height): %d, %d, %d, %d",
     843    crDebug("Render SPU (renderspu_SystemVBoxCreateWindow): actual window (x, y, width, height): %d, %d, %d, %d",
    762844            window->x, window->y, window->width, window->height);
    763845
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette