| 37 | | // the following code will query the system for the available rect on the main-display (typically the displaying showing the menubar + the dock |
| 38 | | |
| 39 | | NSRect rect = [[[NSScreen screens] objectAtIndex: 0] visibleFrame]; |
| 40 | | _availRect = toCGRect(rect); |
| 41 | | |
| 42 | | // now we need the rect of the main-display including the menubar and the dock |
| 43 | | _mainScreenBounds = CGDisplayBounds( CGMainDisplayID() ); |
| 44 | | |
| 45 | | |
| 46 | | // NSRect 0/0 is bottom/left, _mainScreenBounds 0/0 is top/left |
| 47 | | _availRect.origin.y = _mainScreenBounds.size.height - _availRect.size.height - _availRect.origin.y; |
| 48 | | |
| 49 | | |
| 50 | | // hide the menubar initially |
| 51 | | SetSystemUIMode(kUIModeAllHidden, kUIOptionAutoShowMenuBar); |
| | 37 | // the following code will query the system for the available rect on the main-display (typically the displaying showing the menubar + the dock |
| | 38 | |
| | 39 | NSRect rect = [[[NSScreen screens] objectAtIndex: 0] visibleFrame]; |
| | 40 | _availRect = toCGRect(rect); |
| | 41 | |
| | 42 | // now we need the rect of the main-display including the menubar and the dock |
| | 43 | _mainScreenBounds = CGDisplayBounds( CGMainDisplayID() ); |
| | 44 | |
| | 45 | |
| | 46 | // NSRect 0/0 is bottom/left, _mainScreenBounds 0/0 is top/left |
| | 47 | _availRect.origin.y = _mainScreenBounds.size.height - _availRect.size.height - _availRect.origin.y; |
| | 48 | |
| | 49 | |
| | 50 | // hide the menubar initially |
| | 51 | SetSystemUIMode(kUIModeAllHidden, kUIOptionAutoShowMenuBar); |
| 135 | | double value; |
| 136 | | CFNumberRef number_value = (CFNumberRef) CFDictionaryGetValue(refDict, key); |
| 137 | | if (!number_value) // if can't get a number for the dictionary |
| 138 | | return -1; // fail |
| 139 | | if (!CFNumberGetValue(number_value, kCFNumberDoubleType, &value)) // or if cant convert it |
| 140 | | return -1; // fail |
| 141 | | return value; // otherwise return the long value |
| | 135 | double value; |
| | 136 | CFNumberRef number_value = (CFNumberRef) CFDictionaryGetValue(refDict, key); |
| | 137 | if (!number_value) // if can't get a number for the dictionary |
| | 138 | return -1; // fail |
| | 139 | if (!CFNumberGetValue(number_value, kCFNumberDoubleType, &value)) // or if cant convert it |
| | 140 | return -1; // fail |
| | 141 | return value; // otherwise return the long value |
| 147 | | long value = 0; |
| 148 | | CFNumberRef number_value = (CFNumberRef)CFDictionaryGetValue(refDict, key); |
| 149 | | if (!number_value) // if can't get a number for the dictionary |
| 150 | | return -1; // fail |
| 151 | | if (!CFNumberGetValue(number_value, kCFNumberLongType, &value)) // or if cant convert it |
| 152 | | return -1; // fail |
| 153 | | return value; |
| | 147 | long value = 0; |
| | 148 | CFNumberRef number_value = (CFNumberRef)CFDictionaryGetValue(refDict, key); |
| | 149 | if (!number_value) // if can't get a number for the dictionary |
| | 150 | return -1; // fail |
| | 151 | if (!CFNumberGetValue(number_value, kCFNumberLongType, &value)) // or if cant convert it |
| | 152 | return -1; // fail |
| | 153 | return value; |
| 160 | | _displayCount(0), |
| 161 | | _displayIds(NULL) |
| 162 | | { |
| 163 | | ProcessSerialNumber sn = { 0, kCurrentProcess }; |
| 164 | | TransformProcessType(&sn,kProcessTransformToForegroundApplication); |
| 165 | | SetFrontProcess(&sn); |
| 166 | | |
| 167 | | if( CGGetActiveDisplayList( 0, NULL, &_displayCount ) != CGDisplayNoErr ) |
| 168 | | osg::notify(osg::WARN) << "DarwinWindowingSystemInterface: could not get # of screens" << std::endl; |
| 169 | | |
| 170 | | _displayIds = new CGDirectDisplayID[_displayCount]; |
| 171 | | if( CGGetActiveDisplayList( _displayCount, _displayIds, &_displayCount ) != CGDisplayNoErr ) |
| 172 | | osg::notify(osg::WARN) << "DarwinWindowingSystemInterface: CGGetActiveDisplayList failed" << std::endl; |
| 173 | | |
| 174 | | } |
| | 160 | _displayCount(0), |
| | 161 | _displayIds(NULL) |
| | 162 | { |
| | 163 | ProcessSerialNumber sn = { 0, kCurrentProcess }; |
| | 164 | TransformProcessType(&sn,kProcessTransformToForegroundApplication); |
| | 165 | SetFrontProcess(&sn); |
| | 166 | |
| | 167 | if( CGGetActiveDisplayList( 0, NULL, &_displayCount ) != CGDisplayNoErr ) |
| | 168 | osg::notify(osg::WARN) << "DarwinWindowingSystemInterface: could not get # of screens" << std::endl; |
| | 169 | |
| | 170 | _displayIds = new CGDirectDisplayID[_displayCount]; |
| | 171 | if( CGGetActiveDisplayList( _displayCount, _displayIds, &_displayCount ) != CGDisplayNoErr ) |
| | 172 | osg::notify(osg::WARN) << "DarwinWindowingSystemInterface: CGGetActiveDisplayList failed" << std::endl; |
| | 173 | |
| | 174 | } |
| 207 | | CGDirectDisplayID id = getDisplayID(si); |
| 208 | | resolution.width = CGDisplayPixelsWide(id); |
| 209 | | resolution.height = CGDisplayPixelsHigh(id); |
| 210 | | resolution.colorDepth = CGDisplayBitsPerPixel(id); |
| 211 | | resolution.refreshRate = getDictDouble (CGDisplayCurrentMode(id), kCGDisplayRefreshRate); // Not tested |
| 212 | | if (resolution.refreshRate<0) resolution.refreshRate = 0; |
| | 207 | CGDirectDisplayID id = getDisplayID(si); |
| | 208 | resolution.width = CGDisplayPixelsWide(id); |
| | 209 | resolution.height = CGDisplayPixelsHigh(id); |
| | 210 | resolution.colorDepth = CGDisplayBitsPerPixel(id); |
| | 211 | resolution.refreshRate = getDictDouble (CGDisplayCurrentMode(id), kCGDisplayRefreshRate); // Not tested |
| | 212 | if (resolution.refreshRate<0) resolution.refreshRate = 0; |
| 243 | | CGRect bounds = CGDisplayBounds( getDisplayID(si) ); |
| 244 | | x = static_cast<int>(bounds.origin.x); |
| 245 | | y = static_cast<int>(bounds.origin.y); |
| 246 | | |
| 247 | | // osg::notify(osg::DEBUG_INFO) << "topleft of screen " << si.screenNum <<" " << bounds.origin.x << "/" << bounds.origin.y << std::endl; |
| | 243 | CGRect bounds = CGDisplayBounds( getDisplayID(si) ); |
| | 244 | x = static_cast<int>(bounds.origin.x); |
| | 245 | y = static_cast<int>(bounds.origin.y); |
| | 246 | |
| | 247 | // osg::notify(osg::DEBUG_INFO) << "topleft of screen " << si.screenNum <<" " << bounds.origin.x << "/" << bounds.origin.y << std::endl; |
| 255 | | CGDirectDisplayID displayID = getDisplayID(screenIdentifier); |
| 256 | | |
| 257 | | // add next line and on following line replace hard coded depth and refresh rate |
| 258 | | CGRefreshRate refresh = getDictDouble (CGDisplayCurrentMode(displayID), kCGDisplayRefreshRate); |
| 259 | | CFDictionaryRef display_mode_values = |
| 260 | | CGDisplayBestModeForParametersAndRefreshRate( |
| 261 | | displayID, |
| 262 | | CGDisplayBitsPerPixel(displayID), |
| 263 | | width, height, |
| 264 | | refresh, |
| 265 | | NULL); |
| 266 | | |
| 267 | | |
| 268 | | CGDisplaySwitchToMode(displayID, display_mode_values); |
| 269 | | return true; |
| | 255 | CGDirectDisplayID displayID = getDisplayID(screenIdentifier); |
| | 256 | |
| | 257 | // add next line and on following line replace hard coded depth and refresh rate |
| | 258 | CGRefreshRate refresh = getDictDouble (CGDisplayCurrentMode(displayID), kCGDisplayRefreshRate); |
| | 259 | CFDictionaryRef display_mode_values = |
| | 260 | CGDisplayBestModeForParametersAndRefreshRate( |
| | 261 | displayID, |
| | 262 | CGDisplayBitsPerPixel(displayID), |
| | 263 | width, height, |
| | 264 | refresh, |
| | 265 | NULL); |
| | 266 | |
| | 267 | |
| | 268 | CGDisplaySwitchToMode(displayID, display_mode_values); |
| | 269 | return true; |
| 274 | | |
| 275 | | boolean_t success(false); |
| 276 | | unsigned width, height; |
| 277 | | getScreenResolution(screenIdentifier, width, height); |
| 278 | | |
| 279 | | CGDirectDisplayID displayID = getDisplayID(screenIdentifier); |
| 280 | | |
| 281 | | // add next line and on following line replace hard coded depth and refresh rate |
| 282 | | CFDictionaryRef display_mode_values = |
| 283 | | CGDisplayBestModeForParametersAndRefreshRate( |
| 284 | | displayID, |
| 285 | | CGDisplayBitsPerPixel(displayID), |
| 286 | | width, height, |
| 287 | | refreshRate, |
| 288 | | &success); |
| 289 | | |
| 290 | | |
| 291 | | if (success) |
| 292 | | CGDisplaySwitchToMode(displayID, display_mode_values); |
| 293 | | |
| 294 | | return (success != 0); |
| | 274 | |
| | 275 | boolean_t success(false); |
| | 276 | unsigned width, height; |
| | 277 | getScreenResolution(screenIdentifier, width, height); |
| | 278 | |
| | 279 | CGDirectDisplayID displayID = getDisplayID(screenIdentifier); |
| | 280 | |
| | 281 | // add next line and on following line replace hard coded depth and refresh rate |
| | 282 | CFDictionaryRef display_mode_values = |
| | 283 | CGDisplayBestModeForParametersAndRefreshRate( |
| | 284 | displayID, |
| | 285 | CGDisplayBitsPerPixel(displayID), |
| | 286 | width, height, |
| | 287 | refreshRate, |
| | 288 | &success); |
| | 289 | |
| | 290 | |
| | 291 | if (success) |
| | 292 | CGDisplaySwitchToMode(displayID, display_mode_values); |
| | 293 | |
| | 294 | return (success != 0); |
| 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 | | } |
| | 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 | } |