Changeset 18654 in vbox for trunk/src/VBox/HostServices
- Timestamp:
- Apr 2, 2009 4:38:05 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/SharedOpenGL/render/renderspu_agl.c
r18637 r18654 38 38 kEventVBoxDisposeWindow = 'dwin', 39 39 kEventVBoxUpdateDock = 'udck', 40 kEventVBoxUpdateContext = 'uctx' 40 kEventVBoxUpdateContext = 'uctx', 41 kEventVBoxBoundsChanged = 'bchg' 41 42 }; 42 43 … … 86 87 } 87 88 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. */ 93 static 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 88 119 /* Window event handler */ 89 120 static pascal OSStatus … … 97 128 GetEventParameter(event, kEventParamDirectObject, typeWindowRef, 98 129 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 { 145 132 case kEventClassVBox: 146 133 { 147 switch (kind) 134 switch (kind) 148 135 { 149 136 case kEventVBoxUpdateContext: … … 168 155 break; 169 156 } 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 } 170 177 }; 171 178 break; … … 310 317 return render_spu.ws.aglSetCurrentContext( NULL ); 311 318 312 DEBUG_MSG_POETZSCH (("WindowAttachContext %d\n", wi->id)); 319 /* DEBUG_MSG_POETZSCH (("WindowAttachContext %d\n", wi->id));*/ 313 320 314 321 /* Flush old context first */ … … 408 415 status = SetEventParameter(evt, kEventParamWindowRef, typeWindowRef, sizeof (window->window), &window->window); 409 416 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 417 status = PostEventToQueue(GetMainEventQueue(), evt, kEventPriorityStandard); 412 418 CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemDestroyWindow): PostEventToQueue Failed"); … … 452 458 status = SetEventParameter(evt, kEventParamUserData, typeVoidPtr, sizeof (window), &window); 453 459 CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemWindowSize): SetEventParameter Failed"); 454 //status = SendEventToEventTarget (evt, GetWindowEventTarget (HIViewGetWindow ((HIViewRef)render_spu_parent_window_id)));455 460 status = PostEventToQueue(GetMainEventQueue(), evt, kEventPriorityStandard); 456 461 CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemWindowSize): SendEventToEventTarget Failed"); 457 462 458 /* We are tracking the position of the overlay window ourself. If the user459 switch to fullscreen/seamless there is no hint that the position has460 changed. (In the guest point of view it hasn't changed when the pos is461 at (0, 0). So to be on the save side we post an additional pos event if462 this is the case. */463 if (window->x == 0 &&464 window->y == 0)465 renderspu_SystemWindowPosition (window, 0, 0);466 else467 {468 /* Update the context. If the above position call is done this isn't469 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 }480 463 DEBUG_MSG_POETZSCH (("Size %d visible %d\n", window->id, IsWindowVisible (window->window))); 481 464 /* save the new size */ … … 543 526 status = SetEventParameter(evt, kEventParamUserData, typeVoidPtr, sizeof (window), &window); 544 527 CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemWindowPosition): SetEventParameter Failed"); 545 //status = SendEventToEventTarget (evt, GetWindowEventTarget (HIViewGetWindow ((HIViewRef)render_spu_parent_window_id)));546 528 status = PostEventToQueue(GetMainEventQueue(), evt, kEventPriorityStandard); 547 529 CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemWindowPosition): PostEventToQueue Failed"); 548 530 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 }560 531 /* save the new pos */ 561 532 window->x = x; … … 598 569 status = SetEventParameter(evt, kEventParamWindowRef, typeWindowRef, sizeof (window->window), &window->window); 599 570 CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemShowWindow): SetEventParameter Failed"); 600 //status = SendEventToEventTarget (evt, GetWindowEventTarget (HIViewGetWindow ((HIViewRef)render_spu_parent_window_id)));601 571 status = PostEventToQueue(GetMainEventQueue(), evt, kEventPriorityStandard); 602 572 CHECK_CARBON_RC_RETURN_VOID (status, "Render SPU (renderspu_SystemShowWindow): PostEventToQueue Failed"); 603 573 } 604 574 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 617 575 window->visible = showIt; 618 576 } … … 623 581 { 624 582 Boolean result; 625 DEBUG_MSG_POETZSCH (("makecurrent %d: \n", window->id)); 583 /* DEBUG_MSG_POETZSCH (("makecurrent %d: \n", window->id));*/ 626 584 627 585 CRASSERT(render_spu.ws.aglSetCurrentContext); … … 727 685 pRects[4*i] , pRects[4*i+1], 728 686 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])); 729 689 UnionRgn (rgn, tmpRgn, rgn); 730 690 } … … 822 782 status = SetEventParameter(evt, kEventParamWindowRef, typeWindowRef, sizeof (window->window), &window->window); 823 783 CHECK_CARBON_RC_RETURN (status, "Render SPU (renderspu_SystemVBoxCreateWindow): SetEventParameter Failed", false); 824 //status = SendEventToEventTarget (evt, GetWindowEventTarget (HIViewGetWindow ((HIViewRef)render_spu_parent_window_id)));825 784 status = PostEventToQueue(GetMainEventQueue(), evt, kEventPriorityStandard); 826 785 CHECK_CARBON_RC_RETURN (status, "Render SPU (renderspu_SystemVBoxCreateWindow): PostEventToQueue Failed", false); … … 871 830 /* Install the event handlers */ 872 831 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 */ 875 835 }; 876 836 877 837 gParentEventHandler = NewEventHandlerUPP(windowEvtHndlr); 878 879 838 InstallApplicationEventHandler (gParentEventHandler, 880 839 GetEventTypeCount(eventList), eventList, … … 885 844 SetWindowGroup(window->window, gMasterGroup); 886 845 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 903 846 /* This will be initialized on the first attempt to attach the global 904 847 * context to this new window */
Note:
See TracChangeset
for help on using the changeset viewer.