Changeset 9871

Show
Ignore:
Timestamp:
03/09/09 10:58:45 (5 years ago)
Author:
shuber
Message:

Bugfix for GraphicsWindowCarbon? and multiple windows on multiple screens. The windows keep track to what screen they belong, and the window coords are now local to the screen they belong to.

Buildfix for CMake, added missing link to Cocoa framework

Location:
OpenSceneGraph/branches/osg-cocoa-dev
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/branches/osg-cocoa-dev/include/osgViewer/api/Carbon/GraphicsWindowCarbon

    r9831 r9871  
    143143        // get the pixelformat 
    144144        AGLPixelFormat getAGLPixelFormat() { return _pixelFormat; } 
     145                 
     146                void adaptResize(int x, int y, int w, int h); 
    145147 
    146148    protected: 
     
    148150        void init(); 
    149151         
    150         void transformMouseXY(float& x, float& y); 
    151          
    152          
    153          
     152        void transformMouseXY(float& x, float& y);       
    154153 
    155154 
  • OpenSceneGraph/branches/osg-cocoa-dev/src/osgViewer/CMakeLists.txt

    r9845 r9871  
    100100                PixelBufferCarbon.cpp 
    101101            ) 
     102            SET(LIB_EXTRA_LIBS ${COCOA_LIBRARY} ${LIB_EXTRA_LIBS}) 
    102103 
    103104        ELSE(${OSG_WINDOWING_SYSTEM} STREQUAL "Carbon") 
  • OpenSceneGraph/branches/osg-cocoa-dev/src/osgViewer/GraphicsWindowCarbon.cpp

    r9831 r9871  
    7070                        GetEventParameter( event, kEventParamCurrentBounds, typeQDRectangle, NULL, sizeof(Rect), NULL, &bounds ); 
    7171                         
    72                         w->resized(bounds.left, bounds.top, bounds.right - bounds.left, bounds.bottom - bounds.top); 
    73                         w->getEventQueue()->windowResize(bounds.left, bounds.top, bounds.right - bounds.left, bounds.bottom - bounds.top, w->getEventQueue()->getTime()); 
    74                         w->requestRedraw(); 
     72                        w->adaptResize(bounds.left, bounds.top, bounds.right - bounds.left, bounds.bottom - bounds.top); 
     73                                                w->requestRedraw(); 
    7574                        result = noErr; 
    7675                        break; 
     
    7978                        InvalWindowRect(window, GetWindowPortBounds(window, &bounds)); 
    8079                        GetWindowBounds(window, kWindowContentRgn, &bounds); 
    81                         w->resized(bounds.left, bounds.top, bounds.right - bounds.left, bounds.bottom - bounds.top); 
    82                         w->getEventQueue()->windowResize(bounds.left, bounds.top, bounds.right - bounds.left, bounds.bottom - bounds.top, w->getEventQueue()->getTime()); 
     80                        w->adaptResize(bounds.left, bounds.top, bounds.right - bounds.left, bounds.bottom - bounds.top); 
    8381                        result = noErr; 
    8482                        break; 
     
    359357    DarwinWindowingSystemInterface* wsi = dynamic_cast<DarwinWindowingSystemInterface*>(osg::GraphicsContext::getWindowingSystemInterface()); 
    360358    int screenLeft(0), screenTop(0); 
    361     if (wsi) { 
    362          
     359    if (wsi)  
     360        { 
    363361        wsi->getScreenTopLeft((*_traits), screenLeft, screenTop); 
    364         _traits->y += screenTop; 
    365         _traits->x += screenLeft; 
    366     } 
     362        } 
    367363     
    368364    WindowData *windowData = ( _traits.get() && _traits->inheritedWindowData.get() ) ? static_cast<osgViewer::GraphicsWindowCarbon::WindowData*>(_traits->inheritedWindowData.get()) : 0;  
     
    373369         
    374370        // create the window 
    375         Rect bounds = {_traits->y, _traits->x, _traits->y + _traits->height, _traits->x + _traits->width}; 
     371        Rect bounds = {_traits->y + screenTop, _traits->x + screenLeft, _traits->y + _traits->height + screenTop, _traits->x + _traits->width + screenLeft}; 
    376372        OSStatus err = 0; 
    377373        WindowAttributes attr = computeWindowAttributes(_useWindowDecoration, _traits->supportsResize); 
     
    532528    aglUpdateContext(_context); 
    533529    MenubarController::instance()->update(); 
     530         
     531        getEventQueue()->windowResize(x,y,width, height, getEventQueue()->getTime()); 
    534532} 
    535533 
     
    900898bool GraphicsWindowCarbon::setWindowRectangleImplementation(int x, int y, int width, int height) 
    901899{ 
    902     Rect bounds = {y, x, y + height, x + width}; 
     900        int screenLeft(0), screenTop(0); 
     901        DarwinWindowingSystemInterface* wsi = dynamic_cast<DarwinWindowingSystemInterface*>(osg::GraphicsContext::getWindowingSystemInterface()); 
     902   if (wsi)  
     903        { 
     904        wsi->getScreenTopLeft((*_traits), screenLeft, screenTop); 
     905        } 
     906         
     907        Rect bounds = {y + screenTop, x + screenLeft, y + height + screenTop, x + width + screenLeft}; 
    903908    SetWindowBounds(getNativeWindowRef(), kWindowContentRgn, &bounds); 
    904909    aglUpdateContext(_context); 
     
    906911    return true; 
    907912} 
     913 
     914 
     915 
     916void GraphicsWindowCarbon::adaptResize(int x, int y, int w, int h) 
     917{ 
     918        DarwinWindowingSystemInterface* wsi = dynamic_cast<DarwinWindowingSystemInterface*>(osg::GraphicsContext::getWindowingSystemInterface()); 
     919    int screenLeft(0), screenTop(0); 
     920    if (wsi) { 
     921                 
     922                // get the screen containing the window 
     923                unsigned int screenNdx = wsi->getScreenContaining(x,y,w,h); 
     924                 
     925                // update traits 
     926                _traits->screenNum = screenNdx; 
     927                 
     928                // get top left of screen 
     929        wsi->getScreenTopLeft((*_traits), screenLeft, screenTop); 
     930    } 
     931         
     932        resized(x-screenLeft,y-screenTop,w,h); 
     933} 
     934 
     935 
    908936 
    909937void GraphicsWindowCarbon::grabFocus()