Show
Ignore:
Timestamp:
03/09/09 10:39:55 (6 years ago)
Author:
shuber
Message:

Fix for multiple windows on different screens. the coords of windows are now local to the screen, as in other implementations.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • OpenSceneGraph/branches/osg-cocoa-dev/src/osgViewer/GraphicsWindowCocoa.mm

    r9852 r9870  
    731731    // std::cout << "windowdidmove: " << bounds.origin.x << " " << bounds.origin.y << " " << bounds.size.width << " " << bounds.size.height << std::endl; 
    732732    
    733     _win->resized(bounds.origin.x, bounds.origin.y, bounds.size.width, bounds.size.height); 
    734     _win->getEventQueue()->windowResize(bounds.origin.x, bounds.origin.y, bounds.size.width, bounds.size.height, _win->getEventQueue()->getTime()); 
     733    _win->adaptResize(bounds.origin.x, bounds.origin.y, bounds.size.width, bounds.size.height); 
     734    //_win->getEventQueue()->windowResize(bounds.origin.x, bounds.origin.y, bounds.size.width, bounds.size.height, _win->getEventQueue()->getTime()); 
    735735    _win->requestRedraw(); 
    736736    _inDidMove = false; 
     
    840840    int screenLeft(0), screenTop(0); 
    841841    if (wsi) { 
    842          
    843842        wsi->getScreenTopLeft((*_traits), screenLeft, screenTop); 
    844         _traits->y += screenTop; 
    845         _traits->x += screenLeft; 
    846     } 
    847      
    848         NSRect rect = NSMakeRect(_traits->x, _traits->y, _traits->width, _traits->height); 
     843    } 
     844     
     845        NSRect rect = NSMakeRect(_traits->x + screenLeft, _traits->y + screenTop, _traits->width, _traits->height); 
    849846     
    850847        _window = [[GraphicsWindowCocoaWindow alloc] initWithContentRect: rect styleMask: style backing: NSBackingStoreBuffered defer: NO]; 
     
    10931090void GraphicsWindowCocoa::resizedImplementation(int x, int y, int width, int height) 
    10941091{ 
     1092        std::cout << "resized implementation" << x << " " << y << " " << width << " " << height << std::endl;  
    10951093        GraphicsContext::resizedImplementation(x, y, width, height); 
    1096      
     1094    
    10971095    [_context update]; 
    10981096    MenubarController::instance()->update(); 
    1099 } 
     1097        getEventQueue()->windowResize(x,y,width, height, getEventQueue()->getTime()); 
     1098} 
     1099 
     1100 
    11001101 
    11011102 
     
    11051106bool GraphicsWindowCocoa::setWindowRectangleImplementation(int x, int y, int width, int height) 
    11061107{ 
    1107     
    1108     NSRect rect = NSMakeRect(x,y,width, height); 
     1108        DarwinWindowingSystemInterface* wsi = dynamic_cast<DarwinWindowingSystemInterface*>(osg::GraphicsContext::getWindowingSystemInterface()); 
     1109    int screenLeft(0), screenTop(0); 
     1110    if (wsi) { 
     1111        wsi->getScreenTopLeft((*_traits), screenLeft, screenTop); 
     1112    } 
     1113 
     1114 
     1115    NSRect rect = NSMakeRect(x+screenLeft,y+screenTop,width, height); 
    11091116    rect = convertFromQuartzCoordinates(rect); 
    11101117     
     
    11161123} 
    11171124 
     1125 
     1126// ---------------------------------------------------------------------------------------------------------- 
     1127//  
     1128// ---------------------------------------------------------------------------------------------------------- 
     1129 
     1130void GraphicsWindowCocoa::adaptResize(int x, int y, int w, int h) 
     1131{ 
     1132 
     1133        DarwinWindowingSystemInterface* wsi = dynamic_cast<DarwinWindowingSystemInterface*>(osg::GraphicsContext::getWindowingSystemInterface()); 
     1134    int screenLeft(0), screenTop(0); 
     1135    if (wsi) { 
     1136                 
     1137                // get the screen containing the window 
     1138                unsigned int screenNdx = wsi->getScreenContaining(x,y,w,h); 
     1139                 
     1140                // update traits 
     1141                _traits->screenNum = screenNdx; 
     1142                 
     1143                // get top left of screen 
     1144        wsi->getScreenTopLeft((*_traits), screenLeft, screenTop); 
     1145    } 
     1146         
     1147        resized(x-screenLeft,y-screenTop,w,h); 
     1148} 
    11181149 
    11191150