这篇教程C++ CGDisplayBounds函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中CGDisplayBounds函数的典型用法代码示例。如果您正苦于以下问题:C++ CGDisplayBounds函数的具体用法?C++ CGDisplayBounds怎么用?C++ CGDisplayBounds使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了CGDisplayBounds函数的26个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: mainint main (int argc, const char * argv[]) { uint32_t displayCount; CGGetActiveDisplayList(0, NULL, &displayCount); if (displayCount != 2) { fprintf(stderr, "Error: expected exactly 2 displays, %d found/n", displayCount); exit(1); } CGDirectDisplayID activeDisplays[displayCount]; CGGetActiveDisplayList(displayCount, activeDisplays, &displayCount); const int32_t xTranslation = -CGRectGetMinX(CGDisplayBounds(activeDisplays[1])); CGDisplayConfigRef config; CGBeginDisplayConfiguration(&config); CGConfigureDisplayFadeEffect(config, 0.2, 0.2, 0, 0, 0); for (int i = 0; i < displayCount; ++i) { CGDirectDisplayID display = activeDisplays[i]; CGRect displayBounds = CGDisplayBounds(display); CGConfigureDisplayOrigin(config, display, CGRectGetMinX(displayBounds) + xTranslation, CGRectGetMinY(displayBounds)); } CGCompleteDisplayConfiguration(config, kCGConfigurePermanently); return 0;}
开发者ID:michelschinz,项目名称:ScreenSwap,代码行数:26,
示例2: CGDisplayBoundsvoidCOSXScreen::updateScreenShape(){ // get info for each display CGDisplayCount displayCount = 0; if (CGGetActiveDisplayList(0, NULL, &displayCount) != CGDisplayNoErr) { return; } if (displayCount == 0) { return; } CGDirectDisplayID* displays = new CGDirectDisplayID[displayCount]; if (displays == NULL) { return; } if (CGGetActiveDisplayList(displayCount, displays, &displayCount) != CGDisplayNoErr) { delete[] displays; return; } // get smallest rect enclosing all display rects CGRect totalBounds = CGRectZero; for (CGDisplayCount i = 0; i < displayCount; ++i) { CGRect bounds = CGDisplayBounds(displays[i]); totalBounds = CGRectUnion(totalBounds, bounds); } // get shape of default screen m_x = (SInt32)totalBounds.origin.x; m_y = (SInt32)totalBounds.origin.y; m_w = (SInt32)totalBounds.size.width; m_h = (SInt32)totalBounds.size.height; // get center of default screen CGDirectDisplayID main = CGMainDisplayID(); const CGRect rect = CGDisplayBounds(main); m_xCenter = (rect.origin.x + rect.size.width) / 2; m_yCenter = (rect.origin.y + rect.size.height) / 2; delete[] displays; // We want to notify the peer screen whether we are primary screen or not sendEvent(m_events->forIScreen().shapeChanged()); LOG((CLOG_DEBUG "screen shape: center=%d,%d size=%dx%d on %u %s", m_x, m_y, m_w, m_h, displayCount, (displayCount == 1) ? "display" : "displays"));}
开发者ID:rakete,项目名称:synergy-foss,代码行数:52,
示例3: setMainDisplayvoidsetMainDisplay(CGDirectDisplayID targetDisplay){ int deltaX, deltaY, flag; CGDisplayErr dErr; CGDisplayCount displayCount, i; CGDirectDisplayID mainDisplay; CGDisplayCount maxDisplays = MAX_DISPLAYS; CGDirectDisplayID onlineDisplays[MAX_DISPLAYS]; CGDisplayConfigRef config; mainDisplay = CGMainDisplayID(); if (mainDisplay == targetDisplay) { exit(0); } dErr = CGGetOnlineDisplayList(maxDisplays, onlineDisplays, &displayCount); if (dErr != kCGErrorSuccess) { fprintf(stderr, "CGGetOnlineDisplayList: error %d./n", dErr); exit(1); } flag = 0; for (i = 0; i < displayCount; i++) { CGDirectDisplayID dID = onlineDisplays[i]; if (dID == targetDisplay) { flag = 1; } } if (flag == 0) { fprintf(stderr, "No such display ID: %10p./n", targetDisplay); exit(1); } deltaX = -CGRectGetMinX (CGDisplayBounds (targetDisplay)); deltaY = -CGRectGetMinY (CGDisplayBounds (targetDisplay)); CGBeginDisplayConfiguration (&config); for (i = 0; i < displayCount; i++) { CGDirectDisplayID dID = onlineDisplays[i]; CGConfigureDisplayOrigin (config, dID, CGRectGetMinX (CGDisplayBounds (dID)) + deltaX, CGRectGetMinY (CGDisplayBounds (dID)) + deltaY ); } CGCompleteDisplayConfiguration (config, kCGConfigureForSession); exit(0);}
开发者ID:Pfiver,项目名称:fb-rotate,代码行数:51,
示例4: CGGetDisplaysWithPointvoid QuartzWindow::warp_pointer(int x, int y) { // lprintf("warping to: %d, %d/n", x, y);# if TARGET_OS_VERSION == MACOSX_VERSION CGPoint pt; pt.x = x; pt.y = y; const int n = 16; CGDisplayCount count = 0; CGDirectDisplayID dspys[n]; CGDisplayErr err = CGGetDisplaysWithPoint( pt, n, dspys, &count); if (err != noErr) { lprintf("CGGetDisplaysWithPoint failed: %d/n", err); return; } // lprintf("CGGetDisplaysWithPoint count = %d/n", count); for (int i = 0; i < count; ++i) { // MUST adj pt to be relative to TL of display -- dmu 5/03 CGRect bounds = CGDisplayBounds(dspys[i]); CGPoint adjusted_pt; adjusted_pt.x = pt.x - bounds.origin.x; adjusted_pt.y = pt.y - bounds.origin.y; err = CGDisplayMoveCursorToPoint( dspys[i], adjusted_pt); // lprintf("CGDisplayMoveCursorToPoint %d returned %d/n", i, err); }# else Unused(x); Unused(y);# endif}
开发者ID:ardeujho,项目名称:self,代码行数:28,
示例5: max_boundsCGRectmax_bounds(){ OSErr err; CGDirectDisplayID* d; CGDisplayCount c, i; CGRect r; int bx=0, by=0, rx=0, ry=0; err = CGGetActiveDisplayList(0, NULL, &c); if(err != noErr) sysfatal("can not enumerate active displays"); d = (CGDirectDisplayID *)malloc(c * sizeof(CGDirectDisplayID)); if(d == NULL) sysfatal("can not allocate memory for display list"); err = CGGetActiveDisplayList(c, d, &c); if(err != noErr) sysfatal("can not obtain active display list"); for (i = 0; i < c; i++) { r = CGDisplayBounds(d[i]); rx = r.size.width; ry = r.size.height; if(rx > bx) bx = rx; if(ry > by) by = ry; } return CGRectMake(0,0,bx,by);}
开发者ID:Vykook,项目名称:acme-sac,代码行数:33,
示例6: MacGetBoundsOSStatus wxOverlayImpl::CreateOverlayWindow(){ OSStatus err; WindowAttributes overlayAttributes = kWindowIgnoreClicksAttribute; if ( m_window ) { m_overlayParentWindow =(WindowRef) m_window->MacGetTopLevelWindowRef(); Rect bounds ; MacGetBounds(&bounds); err = CreateNewWindow( kOverlayWindowClass, overlayAttributes, &bounds, &m_overlayWindow ); if ( err == noErr ) { SetWindowGroup( m_overlayWindow, GetWindowGroup(m_overlayParentWindow)); // Put them in the same group so that their window layers are consistent } } else { m_overlayParentWindow = NULL ; CGRect cgbounds ; cgbounds = CGDisplayBounds(CGMainDisplayID()); Rect bounds; bounds.top = (short)cgbounds.origin.y; bounds.left = (short)cgbounds.origin.x; bounds.bottom = (short)(bounds.top + cgbounds.size.height); bounds.right = (short)(bounds.left + cgbounds.size.width); err = CreateNewWindow( kOverlayWindowClass, overlayAttributes, &bounds, &m_overlayWindow ); } ShowWindow(m_overlayWindow); return err;}
开发者ID:EdgarTx,项目名称:wx,代码行数:33,
示例7: wxWindowDCImpl// Create a DC representing the whole screenwxScreenDCImpl::wxScreenDCImpl( wxDC *owner ) : wxWindowDCImpl( owner ){#if wxOSX_USE_COCOA_OR_CARBON CGRect cgbounds ; cgbounds = CGDisplayBounds(CGMainDisplayID()); m_width = (wxCoord)cgbounds.size.width; m_height = (wxCoord)cgbounds.size.height;#else wxDisplaySize( &m_width, &m_height );#endif#if wxOSX_USE_COCOA_OR_IPHONE SetGraphicsContext( wxGraphicsContext::Create() );#else Rect bounds; bounds.top = (short)cgbounds.origin.y; bounds.left = (short)cgbounds.origin.x; bounds.bottom = bounds.top + (short)cgbounds.size.height; bounds.right = bounds.left + (short)cgbounds.size.width; WindowAttributes overlayAttributes = kWindowIgnoreClicksAttribute; CreateNewWindow( kOverlayWindowClass, overlayAttributes, &bounds, (WindowRef*) &m_overlayWindow ); ShowWindow((WindowRef)m_overlayWindow); SetGraphicsContext( wxGraphicsContext::CreateFromNativeWindow( m_overlayWindow ) );#endif m_ok = true ;}
开发者ID:erwincoumans,项目名称:wxWidgets,代码行数:27,
示例8: CreateDefaultScreenInfoscreen_info CreateDefaultScreenInfo(int DisplayIndex, int ScreenIndex){ CGRect DisplayRect = CGDisplayBounds(DisplayIndex); screen_info Screen; Screen.ID = ScreenIndex; Screen.ForceContainerUpdate = false; Screen.ActiveSpace = 0; Screen.OldWindowListCount = -1; Screen.X = DisplayRect.origin.x; Screen.Y = DisplayRect.origin.y; Screen.Width = DisplayRect.size.width; Screen.Height = DisplayRect.size.height; Screen.PaddingTop = DefaultPaddingTop; Screen.PaddingLeft = DefaultPaddingLeft; Screen.PaddingRight = DefaultPaddingRight; Screen.PaddingBottom = DefaultPaddingBottom; Screen.VerticalGap = DefaultGapVertical; Screen.HorizontalGap = DefaultGapHorizontal; return Screen;}
开发者ID:fjolnir,项目名称:kwm,代码行数:25,
示例9: screeninitvoidscreeninit(void){ int fmt; int dx, dy; ProcessSerialNumber psn = { 0, kCurrentProcess }; TransformProcessType(&psn, kProcessTransformToForegroundApplication); SetFrontProcess(&psn); fmt = XBGR32; //XRGB32; devRect = max_bounds(); dx = devRect.size.width; dy = devRect.size.height; gscreen = allocmemimage(Rect(0,0,dx,dy), fmt); dataProviderRef = CGDataProviderCreateWithData(0, gscreen->data->bdata, dx * dy * 4, 0); fullScreenImage = CGImageCreate(dx, dy, 8, 32, dx * 4, CGColorSpaceCreateDeviceRGB(), kCGImageAlphaNoneSkipLast, dataProviderRef, 0, 0, kCGRenderingIntentDefault); devRect = CGDisplayBounds(CGMainDisplayID()); kproc("osxscreen", winproc, nil, 0); kproc("osxflush", flushproc, nil, 0); Sleep(&rend, isready, nil);}
开发者ID:Vykook,项目名称:acme-sac,代码行数:28,
示例10: mainint main(int argc, const char * argv[]) { uint32_t maxDisplays = 256; CGDirectDisplayID activeDisplays[maxDisplays]; uint32_t displayCount = 0; CGError error = CGGetActiveDisplayList(maxDisplays, activeDisplays, &displayCount); if (error != kCGErrorSuccess) { fprintf(stderr, "Quartz error %d. See http://developer.apple.com/library/mac/#documentation/CoreGraphics/Reference/CoreGraphicsConstantsRef/Reference/reference.html#//apple_ref/doc/uid/TP40008794", error); return error; } if (argc != 1) { fprintf(stderr, "usage: screenarrangement/nprints all active display {origin, size} as an AppleScript list"); return 2; } printf("{"); for (int i = 0; i < displayCount; i++) { CGRect bounds = CGDisplayBounds(activeDisplays[i]); CGPoint origin = bounds.origin; CGSize size = bounds.size; printf("{{%d, %d}, {%d, %d}}", (uint32_t) origin.x, (uint32_t) origin.y, (uint32_t) size.width, (uint32_t) size.height); if (i != displayCount - 1) { printf(", "); } } printf("}/n"); return 0;}
开发者ID:concept-not-found,项目名称:screen-arrangement,代码行数:32,
示例11: mainint main(int argc, char * argv[]){ IOReturn err; CGDirectDisplayID dspy = CGMainDisplayID(); io_service_t framebuffer; CGRect bounds; vm_address_t buffer; vm_size_t size, rowBytes; framebuffer = CGDisplayIOServicePort(dspy); assert (framebuffer != MACH_PORT_NULL); dspy = CGMainDisplayID(); bounds = CGDisplayBounds(dspy); rowBytes = CGDisplayBytesPerRow(dspy); err = IOAccelReadFramebuffer(framebuffer, bounds.size.width, bounds.size.height, rowBytes, &buffer, &size); if (kIOReturnSuccess == err) { fprintf(stderr, "writing 0x%x bytes from 0x%x/n", size, buffer); write(STDOUT_FILENO, (const void *) buffer, size); vm_deallocate(mach_task_self(), buffer, size); } return (0);}
开发者ID:alfintatorkace,项目名称:osx-10.9-opensource,代码行数:25,
示例12: CGDisplayBoundswxRect wxDisplayImplMacOSX::GetGeometry() const{ CGRect theRect = CGDisplayBounds(m_id); return wxRect( (int)theRect.origin.x, (int)theRect.origin.y, (int)theRect.size.width, (int)theRect.size.height ); //floats}
开发者ID:CyberIntelMafia,项目名称:clamav-devel,代码行数:8,
示例13: wxDisplaySize// Get size of displayvoid wxDisplaySize(int *width, int *height){ // TODO adapt for multi-displays CGRect bounds = CGDisplayBounds(CGMainDisplayID()); if ( width ) *width = (int)bounds.size.width ; if ( height ) *height = (int)bounds.size.height;}
开发者ID:Kaoswerk,项目名称:newton-dynamics,代码行数:10,
示例14: infoDisplaysvoidinfoDisplays(void){ CGDisplayErr dErr; CGDisplayCount displayCount, i; CGDirectDisplayID mainDisplay; CGDisplayCount maxDisplays = MAX_DISPLAYS; CGDirectDisplayID onlineDisplays[MAX_DISPLAYS]; CGEventRef ourEvent = CGEventCreate(NULL); CGPoint ourLoc = CGEventGetLocation(ourEvent); CFRelease(ourEvent); mainDisplay = CGMainDisplayID(); dErr = CGGetOnlineDisplayList(maxDisplays, onlineDisplays, &displayCount); if (dErr != kCGErrorSuccess) { fprintf(stderr, "CGGetOnlineDisplayList: error %d./n", dErr); exit(1); } printf("# Display_ID Resolution ____Display_Bounds____ Rotation/n"); for (i = 0; i < displayCount; i++) { CGDirectDisplayID dID = onlineDisplays[i]; printf("%-2d %10p %4lux%-4lu %5.0f %5.0f %5.0f %5.0f %3.0f %s%s%s", CGDisplayUnitNumber (dID), dID, CGDisplayPixelsWide(dID), CGDisplayPixelsHigh(dID), CGRectGetMinX (CGDisplayBounds (dID)), CGRectGetMinY (CGDisplayBounds (dID)), CGRectGetMaxX (CGDisplayBounds (dID)), CGRectGetMaxY (CGDisplayBounds (dID)), CGDisplayRotation (dID), (CGDisplayIsActive (dID)) ? "" : "[inactive]", (dID == mainDisplay) ? "[main]" : "", (CGDisplayIsBuiltin (dID)) ? "[internal]/n" : "/n"); } printf("Mouse Cursor Position: ( %5.0f , %5.0f )/n", (float)ourLoc.x, (float)ourLoc.y); exit(0);}
开发者ID:Pfiver,项目名称:fb-rotate,代码行数:43,
示例15: CGDisplayBounds std::string Platform::GetScreenResolution() { CGRect mainMonitor = CGDisplayBounds(CGMainDisplayID()); CGFloat monitorHeight = CGRectGetHeight(mainMonitor); CGFloat monitorWidth = CGRectGetWidth(mainMonitor); std::stringstream ss; ss << int(monitorWidth) << "x" << int(monitorHeight); return ss.str(); }
开发者ID:JamesRGM,项目名称:GAI--,代码行数:11,
示例16: OS_NATIVEJNIEXPORT void JNICALL OS_NATIVE(CGDisplayBounds) (JNIEnv *env, jclass that, jint arg0, jobject arg1){ CGRect _arg1, *lparg1=NULL; OS_NATIVE_ENTER(env, that, CGDisplayBounds_FUNC); if (arg1) if ((lparg1 = getCGRectFields(env, arg1, &_arg1)) == NULL) goto fail; *lparg1 = CGDisplayBounds((CGDirectDisplayID)arg0);fail: if (arg1 && lparg1) setCGRectFields(env, arg1, lparg1); OS_NATIVE_EXIT(env, that, CGDisplayBounds_FUNC);}
开发者ID:andreyvit,项目名称:yoursway-swt,代码行数:11,
示例17: MW_display_size/* Return dimensions of current main display as an array of two integers */VALUE MW_display_size(VALUE module) { CGRect bounds; VALUE retval; bounds = CGDisplayBounds(CGMainDisplayID()); retval = rb_ary_new(); rb_ary_push(retval, INT2NUM((int)CGRectGetMaxX(bounds))); rb_ary_push(retval, INT2NUM((int)CGRectGetMaxY(bounds))); return retval;}
开发者ID:andrewgho,项目名称:movewin-ruby,代码行数:12,
示例18: UpdateExistingScreenInfovoid UpdateExistingScreenInfo(screen_info *Screen, int DisplayIndex, int ScreenIndex){ CGRect DisplayRect = CGDisplayBounds(DisplayIndex); Screen->ID = ScreenIndex; Screen->X = DisplayRect.origin.x; Screen->Y = DisplayRect.origin.y; Screen->Width = DisplayRect.size.width; Screen->Height = DisplayRect.size.height; Screen->Settings.Offset = KWMScreen.DefaultOffset; Screen->Settings.Mode = SpaceModeDefault;}
开发者ID:JakimLi,项目名称:kwm,代码行数:13,
示例19: CGDisplayBounds/* Calculate the _bottom_left and _top_right corners of our virtual display. * Must be called after init_displays. */void ScreenShooter::calculate_bounds() { _display_bounds = new CGRect[_dsp_count]; for(unsigned int i = 0; i < _dsp_count; i++) { _display_bounds[i] = CGDisplayBounds(_displays[i]); CGRect bounds = _display_bounds[i]; _bottom_left.x = min(_bottom_left.x, bounds.origin.x); _bottom_left.y = max(_bottom_left.y, bounds.origin.y+bounds.size.height); _top_right.x = max(_top_right.x, bounds.origin.x+bounds.size.width); _top_right.y = min(_top_right.y, bounds.origin.y); }}
开发者ID:leopoldodonnell,项目名称:screenshot,代码行数:16,
示例20: UpdateExistingScreenInfovoid UpdateExistingScreenInfo(screen_info *Screen, int DisplayIndex, int ScreenIndex){ CGRect DisplayRect = CGDisplayBounds(DisplayIndex); Screen->ID = ScreenIndex; Screen->X = DisplayRect.origin.x; Screen->Y = DisplayRect.origin.y; Screen->Width = DisplayRect.size.width; Screen->Height = DisplayRect.size.height; Screen->Offset = DefaultContainerOffset; Screen->ForceContainerUpdate = true;}
开发者ID:Speaky10k,项目名称:kwm,代码行数:13,
示例21: hook_create_screen_info/* The following function was contributed by Anthony Liguori Jan 18 2015. * https://github.com/kwhat/libuiohook/pull/18 */UIOHOOK_API screen_data* hook_create_screen_info(unsigned char *count) { CGError status = kCGErrorFailure; screen_data* screens = NULL; // Initialize count to zero. *count = 0; // Allocate memory to hold each display id. We will just allocate our MAX // because its only about 1K of memory. // TODO This can probably be realistically cut to something like 16 or 32.... // If you have more than 32 monitors, send me a picture and make a donation ;) CGDirectDisplayID *display_ids = malloc(sizeof(CGDirectDisplayID) * UCHAR_MAX); if (display_ids != NULL) { // NOTE Pass UCHAR_MAX to make sure uint32_t doesn't overflow uint8_t. // TOOD Test/Check whether CGGetOnlineDisplayList is more suitable... status = CGGetActiveDisplayList(UCHAR_MAX, display_ids, (uint32_t *) count); // If there is no error and at least one monitor. if (status == kCGErrorSuccess && *count > 0) { logger(LOG_LEVEL_INFO, "%s [%u]: CGGetActiveDisplayList: %li./n", __FUNCTION__, __LINE__, *count); // Allocate memory for the number of screens found. screens = malloc(sizeof(screen_data) * (*count)); if (screens != NULL) { for (uint8_t i = 0; i < *count; i++) { //size_t width = CGDisplayPixelsWide(display_ids[i]); //size_t height = CGDisplayPixelsHigh(display_ids[i]); CGRect boundsDisp = CGDisplayBounds(display_ids[i]); if (boundsDisp.size.width > 0 && boundsDisp.size.height > 0) { screens[i] = (screen_data) { .number = i + 1, //TODO: make sure we follow the same convention for the origin //in all other platform implementations (upper-left) //TODO: document the approach with examples in order to show different //cases -> different resolutions (secondary monitors origin might be //negative) .x = boundsDisp.origin.x, .y = boundsDisp.origin.y, .width = boundsDisp.size.width, .height = boundsDisp.size.height }; } } } }
开发者ID:InspectorWidget,项目名称:libuiohook,代码行数:49,
示例22: displayScreenBounds/* * displayScreenBounds * Return the bounds of a particular display. */static CGRectdisplayScreenBounds(CGDirectDisplayID id){ CGRect frame; frame = CGDisplayBounds(id); /* Remove menubar to help standard X11 window managers. */ if (frame.origin.x == 0 && frame.origin.y == 0) { frame.origin.y += aquaMenuBarHeight; frame.size.height -= aquaMenuBarHeight; } return frame;}
开发者ID:BackupTheBerlios,项目名称:dri-ex-svn,代码行数:21,
示例23: CGGetDisplaysWithPoint |