Changeset 9870
- Timestamp:
- 03/09/09 10:39:55 (4 years ago)
- Location:
- OpenSceneGraph/branches/osg-cocoa-dev
- Files:
-
- 4 modified
-
include/osgViewer/api/Cocoa/GraphicsWindowCocoa (modified) (1 diff)
-
src/osgViewer/DarwinUtils.h (modified) (1 diff)
-
src/osgViewer/DarwinUtils.mm (modified) (1 diff)
-
src/osgViewer/GraphicsWindowCocoa.mm (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/branches/osg-cocoa-dev/include/osgViewer/api/Cocoa/GraphicsWindowCocoa
r9836 r9870 139 139 140 140 void setVSync(bool f); 141 142 /** adapts a resize / move of the window, coords in global screen space */ 143 void adaptResize(int x, int y, int w, int h); 141 144 142 145 protected: -
OpenSceneGraph/branches/osg-cocoa-dev/src/osgViewer/DarwinUtils.h
r9845 r9870 89 89 virtual bool setScreenRefreshRate(const osg::GraphicsContext::ScreenIdentifier& screenIdentifier, double refreshRate); 90 90 91 92 /** returns screen-ndx containing rect x,y,w,h */ 93 unsigned int getScreenContaining(int x, int y, int w, int h); 94 91 95 protected: 92 96 -
OpenSceneGraph/branches/osg-cocoa-dev/src/osgViewer/DarwinUtils.mm
r9845 r9870 295 295 } 296 296 297 298 299 300 301 302 303 304 } 297 298 unsigned int DarwinWindowingSystemInterface::getScreenContaining(int x, int y, int w, int h) 299 { 300 CGRect rect = CGRectMake(x,y,w,h); 301 for(unsigned int i = 0; i < _displayCount; ++i) { 302 CGRect bounds = CGDisplayBounds( getDisplayID(i) ); 303 if (CGRectIntersectsRect(bounds, rect)) { 304 return i; 305 } 306 } 307 308 return 0; 309 } 310 311 312 313 314 315 316 } -
OpenSceneGraph/branches/osg-cocoa-dev/src/osgViewer/GraphicsWindowCocoa.mm
r9852 r9870 731 731 // std::cout << "windowdidmove: " << bounds.origin.x << " " << bounds.origin.y << " " << bounds.size.width << " " << bounds.size.height << std::endl; 732 732 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()); 735 735 _win->requestRedraw(); 736 736 _inDidMove = false; … … 840 840 int screenLeft(0), screenTop(0); 841 841 if (wsi) { 842 843 842 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); 849 846 850 847 _window = [[GraphicsWindowCocoaWindow alloc] initWithContentRect: rect styleMask: style backing: NSBackingStoreBuffered defer: NO]; … … 1093 1090 void GraphicsWindowCocoa::resizedImplementation(int x, int y, int width, int height) 1094 1091 { 1092 std::cout << "resized implementation" << x << " " << y << " " << width << " " << height << std::endl; 1095 1093 GraphicsContext::resizedImplementation(x, y, width, height); 1096 1094 1097 1095 [_context update]; 1098 1096 MenubarController::instance()->update(); 1099 } 1097 getEventQueue()->windowResize(x,y,width, height, getEventQueue()->getTime()); 1098 } 1099 1100 1100 1101 1101 1102 … … 1105 1106 bool GraphicsWindowCocoa::setWindowRectangleImplementation(int x, int y, int width, int height) 1106 1107 { 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); 1109 1116 rect = convertFromQuartzCoordinates(rect); 1110 1117 … … 1116 1123 } 1117 1124 1125 1126 // ---------------------------------------------------------------------------------------------------------- 1127 // 1128 // ---------------------------------------------------------------------------------------------------------- 1129 1130 void 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 } 1118 1149 1119 1150
