VirtualBox

Changeset 18654 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Apr 2, 2009 4:38:05 PM (16 years ago)
Author:
vboxsync
Message:

crOpenGL-OSX: more fixes for clipping on the root window

Location:
trunk/src/VBox
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxConsoleView.h

    r17349 r18654  
    200200
    201201    void resizeEvent (QResizeEvent *);
     202    void moveEvent (QMoveEvent *);
    202203    void paintEvent (QPaintEvent *);
    203204
  • trunk/src/VBox/Frontends/VirtualBox/include/VBoxUtils-darwin.h

    r18610 r18654  
    230230    kEventVBoxDisposeWindow = 'dwin',
    231231    kEventVBoxUpdateDock    = 'udck',
    232     kEventVBoxUpdateContext = 'uctx'
     232    kEventVBoxUpdateContext = 'uctx',
     233    kEventVBoxBoundsChanged = 'bchg'
    233234};
     235
     236void PostBoundsChanged (const QRect& rect);
    234237OSStatus darwinOverlayWindowHandler (EventHandlerCallRef aInHandlerCallRef, EventRef aInEvent, void *aInUserData);
    235238
  • trunk/src/VBox/Frontends/VirtualBox/src/VBoxConsoleView.cpp

    r18565 r18654  
    32293229{
    32303230    updateSliders();
     3231#ifdef Q_WS_MAC
     3232    QRect r = frameGeometry();
     3233//    printf ("qt resize: %d %d %d %d\n", r.x(), r.y(), r.width(), r.height());
     3234    PostBoundsChanged (r);
     3235#endif /* Q_WS_MAC */
     3236}
     3237
     3238void VBoxConsoleView::moveEvent (QMoveEvent *)
     3239{
     3240#ifdef Q_WS_MAC
     3241    QRect r = frameGeometry();
     3242//    printf ("qt resize: %d %d %d %d\n", r.x(), r.y(), r.width(), r.height());
     3243    PostBoundsChanged (r);
     3244#endif /* Q_WS_MAC */
    32313245}
    32323246
  • trunk/src/VBox/Frontends/VirtualBox/src/darwin/VBoxUtils-darwin-carbon.cpp

    r18610 r18654  
    236236}
    237237
     238void PostBoundsChanged (const QRect& rect)
     239{
     240    EventRef evt;
     241    OSStatus status = CreateEvent(NULL, kEventClassVBox, kEventVBoxBoundsChanged, 0, kEventAttributeNone, &evt);
     242    CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (PostUpdateContext): CreateEvent Failed");
     243    HIPoint p = CGPointMake (rect.x(), rect.y());
     244    status = SetEventParameter(evt, kEventParamOrigin, typeHIPoint, sizeof (p), &p);
     245    CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (PostUpdateContext): SetEventParameter Failed");
     246    HISize s = CGSizeMake (rect.width(), rect.height());
     247    status = SetEventParameter(evt, kEventParamDimensions, typeHISize, sizeof (s), &s);
     248    CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (PostUpdateContext): SetEventParameter Failed");
     249    status = PostEventToQueue(GetMainEventQueue(), evt, kEventPriorityStandard);
     250    CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (PostUpdateContext): PostEventToQueue Failed");
     251}
     252
    238253OSStatus darwinOverlayWindowHandler (EventHandlerCallRef aInHandlerCallRef, EventRef aInEvent, void *aInUserData)
    239254{
     
    258273            if (GetEventParameter (aInEvent, kEventParamWindowRef, typeWindowRef, NULL, sizeof (w), NULL, &w) != noErr)
    259274                return noErr;
    260             void *wp; 
     275            void *wp;
    261276            if (GetEventParameter (aInEvent, kEventParamUserData, typeVoidPtr, NULL, sizeof (wp), NULL, &wp) != noErr)
    262277                return noErr;
     
    289304            if (GetEventParameter (aInEvent, kEventParamOrigin, typeHIPoint, NULL, sizeof (p), NULL, &p) != noErr)
    290305                return noErr;
    291             void *wp; 
     306            void *wp;
    292307            if (GetEventParameter (aInEvent, kEventParamUserData, typeVoidPtr, NULL, sizeof (wp), NULL, &wp) != noErr)
    293308                return noErr;
     
    309324            if (GetEventParameter (aInEvent, kEventParamDimensions, typeHISize, NULL, sizeof (s), NULL, &s) != noErr)
    310325                return noErr;
    311             void *wp; 
     326            void *wp;
    312327            if (GetEventParameter (aInEvent, kEventParamUserData, typeVoidPtr, NULL, sizeof (wp), NULL, &wp) != noErr)
    313328                return noErr;
  • trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_agl.c

    r18637 r18654  
    3838    kEventVBoxDisposeWindow = 'dwin',
    3939    kEventVBoxUpdateDock    = 'udck',
    40     kEventVBoxUpdateContext = 'uctx'
     40    kEventVBoxUpdateContext = 'uctx',
     41    kEventVBoxBoundsChanged = 'bchg'
    4142};
    4243
     
    8687    }
    8788
     89/* In some case (like compiz which doesn't provide us with clipping regions) we
     90 * have to make sure that *all* open OpenGL windows are clipped to the main
     91 * application window. This is done here when called from the event handler
     92 * which monitor bounding changes of the main window. */
     93static void crClipRootHelper(unsigned long key, void *data1, void *data2)
     94{
     95    /* The window with id zero is the base window, which isn't displayed at
     96     * all. So ignore it. */
     97    if (key > 0)
     98    {
     99        /* Fetch the actually window info & the user data */
     100        WindowInfo *pWin = (WindowInfo *) data1;
     101        /* We need to assign the context with this window */
     102        ContextInfo *context = renderspuGetWindowContext(pWin);
     103        if (context &&
     104            context->context)
     105        {
     106            OSStatus result = render_spu.ws.aglSetCurrentContext(context->context);
     107            CHECK_AGL_RC (result, "Render SPU (renderspuWindowAttachContext): SetCurrentContext Failed");
     108            result = render_spu.ws.aglUpdateContext(context->context);
     109            CHECK_AGL_RC (result, "Render SPU (renderspuWindowAttachContext): UpdateContext Failed");
     110            /* Update the clipping region */
     111            renderspu_SystemWindowApplyVisibleRegion(pWin);
     112            /* Make sure that the position is updated relative to the Qt main
     113             * view */
     114            renderspu_SystemWindowPosition(pWin, pWin->x, pWin->y);
     115        }
     116    }
     117}
     118
    88119/* Window event handler */
    89120static pascal OSStatus
     
    97128    GetEventParameter(event, kEventParamDirectObject, typeWindowRef,
    98129                      NULL, sizeof(WindowRef), NULL, &window);
    99     /*
    100     Rect rectPort = { 0, 0, 0, 0 };
    101     if( window )
    102         GetWindowPortBounds( window, &rectPort );
    103     */
    104 
    105     switch (class)
    106     {
    107         case kEventClassWindow:
    108         {
    109             WindowInfo *wi = (WindowInfo*)userData;
    110             switch (kind)
    111             {
    112 #ifndef __LP64__ /* not available for 64-bit processes? */
    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             };
    143             break;
    144         }
     130    switch (class)
     131    {
    145132        case kEventClassVBox:
    146133        {
    147             switch (kind) 
     134            switch (kind)
    148135            {
    149136                case kEventVBoxUpdateContext:
     
    168155                    break;
    169156                }
     157                case kEventVBoxBoundsChanged:
     158                {
     159#ifndef __LP64__ /** @todo port to 64-bit darwin! Need to cehck if this event is generated or not (it probably isn't). */
     160                    HIPoint p;
     161                    GetEventParameter(event, kEventParamOrigin, typeHIPoint,
     162                                      NULL, sizeof(p), NULL, &p);
     163                    HISize s;
     164                    GetEventParameter(event, kEventParamDimensions, typeHISize,
     165                                      NULL, sizeof(s), NULL, &s);
     166                    HIRect r = CGRectMake (0, 0, s.width, s.height);
     167                    DEBUG_MSG_POETZSCH (("kEventVBoxBoundsChanged %f %f %f %f\n", p.x, p.y, s.width, s.height));
     168                    GLint l[4] = { 0,
     169                                   0,
     170                                   r.size.width,
     171                                   r.size.height };
     172                    renderspu_SystemSetRootVisibleRegion(1, &l);
     173                    crHashtableWalk(render_spu.windowTable, crClipRootHelper, NULL);
     174#endif
     175                    break;
     176                }
    170177            };
    171178            break;
     
    310317        return render_spu.ws.aglSetCurrentContext( NULL );
    311318
    312     DEBUG_MSG_POETZSCH (("WindowAttachContext %d\n", wi->id));
     319/*    DEBUG_MSG_POETZSCH (("WindowAttachContext %d\n", wi->id));*/
    313320
    314321    /* Flush old context first */
     
    408415        status = SetEventParameter(evt, kEventParamWindowRef, typeWindowRef, sizeof (window->window), &window->window);
    409416        CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemDestroyWindow): SetEventParameter Failed");
    410         //status = SendEventToEventTarget (evt, GetWindowEventTarget (HIViewGetWindow ((HIViewRef)render_spu_parent_window_id)));
    411417        status = PostEventToQueue(GetMainEventQueue(), evt, kEventPriorityStandard);
    412418        CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemDestroyWindow): PostEventToQueue Failed");
     
    452458    status = SetEventParameter(evt, kEventParamUserData, typeVoidPtr, sizeof (window), &window);
    453459    CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemWindowSize): SetEventParameter Failed");
    454     //status = SendEventToEventTarget (evt, GetWindowEventTarget (HIViewGetWindow ((HIViewRef)render_spu_parent_window_id)));
    455460    status = PostEventToQueue(GetMainEventQueue(), evt, kEventPriorityStandard);
    456461    CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemWindowSize): SendEventToEventTarget Failed");
    457462
    458     /* We are tracking the position of the overlay window ourself. If the user
    459        switch to fullscreen/seamless there is no hint that the position has
    460        changed. (In the guest point of view it hasn't changed when the pos is
    461        at (0, 0). So to be on the save side we post an additional pos event if
    462        this is the case. */
    463     if (window->x == 0 &&
    464         window->y == 0)
    465         renderspu_SystemWindowPosition (window, 0, 0);
    466     else
    467     {
    468         /* Update the context. If the above position call is done this isn't
    469            necessary cause its already done there. */
    470         GLboolean result = true;
    471         ContextInfo *context = renderspuGetWindowContext(window);
    472         if (context &&
    473             context->context)
    474         {
    475             //result = render_spu.ws.aglUpdateContext(context->context);
    476             //CHECK_AGL_RC (result, "Render SPU (renderspu_SystemWindowSize): UpdateContext Failed");
    477             //glFlush();
    478         }
    479     }
    480463    DEBUG_MSG_POETZSCH (("Size %d visible %d\n", window->id, IsWindowVisible (window->window)));
    481464    /* save the new size */
     
    543526    status = SetEventParameter(evt, kEventParamUserData, typeVoidPtr, sizeof (window), &window);
    544527    CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemWindowPosition): SetEventParameter Failed");
    545     //status = SendEventToEventTarget (evt, GetWindowEventTarget (HIViewGetWindow ((HIViewRef)render_spu_parent_window_id)));
    546528    status = PostEventToQueue(GetMainEventQueue(), evt, kEventPriorityStandard);
    547529    CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemWindowPosition): PostEventToQueue Failed");
    548530
    549     /* Update the context */
    550     GLboolean result = true;
    551     ContextInfo *context = renderspuGetWindowContext(window);
    552     if (context &&
    553         context->context)
    554     {
    555         DEBUG_MSG_POETZSCH (("Position %d context %x visible %d\n", window->id, context->context, IsWindowVisible (window->window)));
    556         //result = render_spu.ws.aglUpdateContext(context->context);
    557         //CHECK_AGL_RC (result, "Render SPU (renderspu_SystemWindowPosition): UpdateContext Failed");
    558         //glFlush();
    559     }
    560531    /* save the new pos */
    561532    window->x = x;
     
    598569        status = SetEventParameter(evt, kEventParamWindowRef, typeWindowRef, sizeof (window->window), &window->window);
    599570        CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemShowWindow): SetEventParameter Failed");
    600         //status = SendEventToEventTarget (evt, GetWindowEventTarget (HIViewGetWindow ((HIViewRef)render_spu_parent_window_id)));
    601571        status = PostEventToQueue(GetMainEventQueue(), evt, kEventPriorityStandard);
    602572        CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemShowWindow): PostEventToQueue Failed");
    603573    }
    604574
    605     /* Update the context */
    606     GLboolean result = true;
    607     ContextInfo *context = renderspuGetWindowContext(window);
    608     if (context &&
    609         context->context)
    610     {
    611         DEBUG_MSG_POETZSCH (("Showed %d context %x visible %d\n", window->id, context->context, IsWindowVisible (window->window)));
    612         result = render_spu.ws.aglUpdateContext(context->context);
    613         CHECK_AGL_RC (result, "Render SPU (renderspu_SystemShowWindow): UpdateContext Failed");
    614         glFlush();
    615     }
    616 
    617575    window->visible = showIt;
    618576}
     
    623581{
    624582    Boolean result;
    625     DEBUG_MSG_POETZSCH (("makecurrent %d: \n", window->id));
     583/*    DEBUG_MSG_POETZSCH (("makecurrent %d: \n", window->id));*/
    626584
    627585    CRASSERT(render_spu.ws.aglSetCurrentContext);
     
    727685                        pRects[4*i]  , pRects[4*i+1],
    728686                        pRects[4*i+2], pRects[4*i+3]);
     687            DEBUG_MSG_POETZSCH (("visible rect %d %d %d %d\n", pRects[4*i]  , pRects[4*i+1],
     688                                 pRects[4*i+2], pRects[4*i+3]));
    729689            UnionRgn (rgn, tmpRgn, rgn);
    730690        }
     
    822782        status = SetEventParameter(evt, kEventParamWindowRef, typeWindowRef, sizeof (window->window), &window->window);
    823783        CHECK_CARBON_RC_RETURN (status, "Render SPU (renderspu_SystemVBoxCreateWindow): SetEventParameter Failed", false);
    824         //status = SendEventToEventTarget (evt, GetWindowEventTarget (HIViewGetWindow ((HIViewRef)render_spu_parent_window_id)));
    825784        status = PostEventToQueue(GetMainEventQueue(), evt, kEventPriorityStandard);
    826785        CHECK_CARBON_RC_RETURN (status, "Render SPU (renderspu_SystemVBoxCreateWindow): PostEventToQueue Failed", false);
     
    871830            /* Install the event handlers */
    872831            EventTypeSpec eventList[] =
    873             {
    874                 {kEventClassVBox, kEventVBoxUpdateContext}
     832            {
     833                {kEventClassVBox, kEventVBoxUpdateContext}, /* Update the context after show/size/move events */
     834                {kEventClassVBox, kEventVBoxBoundsChanged}  /* Clip/Pos the OpenGL windows when the main window is changed in pos/size */
    875835            };
    876836
    877837            gParentEventHandler = NewEventHandlerUPP(windowEvtHndlr);
    878 
    879838            InstallApplicationEventHandler (gParentEventHandler,
    880839                                            GetEventTypeCount(eventList), eventList,
     
    885844    SetWindowGroup(window->window, gMasterGroup);
    886845
    887     /* Own handler needed? */
    888     {
    889         /* Even though there are still issues with the windows themselves,
    890            install the event handlers */
    891         EventTypeSpec event_list[] = { {kEventClassWindow, kEventWindowBoundsChanged} };
    892 
    893         window->event_handler = NewEventHandlerUPP( windowEvtHndlr );
    894 
    895         /*
    896         InstallWindowEventHandler(window->window, window->event_handler,
    897                                   GetEventTypeCount(event_list), event_list,
    898                                   window, NULL);
    899                                   */
    900     }
    901 
    902 
    903846    /* This will be initialized on the first attempt to attach the global
    904847     * context to this new window */
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