当前位置: 首页>>代码示例>>C++>>正文


C++ CGDisplayBounds函数代码示例

本文整理汇总了C++中CGDisplayBounds函数的典型用法代码示例。如果您正苦于以下问题:C++ CGDisplayBounds函数的具体用法?C++ CGDisplayBounds怎么用?C++ CGDisplayBounds使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了CGDisplayBounds函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int 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,代码来源:main.c

示例2: CGDisplayBounds

void
COSXScreen::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,代码来源:COSXScreen.cpp

示例3: setMainDisplay

void
setMainDisplay(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,代码来源:fb-rotate.c

示例4: CGGetDisplaysWithPoint

void 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,代码来源:quartzWindow.cpp

示例5: max_bounds

CGRect
max_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,代码来源:win.c

示例6: MacGetBounds

OSStatus 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,代码来源:overlay.cpp

示例7: wxWindowDCImpl

// Create a DC representing the whole screen
wxScreenDCImpl::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,代码来源:dcscreen.cpp

示例8: CreateDefaultScreenInfo

screen_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,代码来源:display.cpp

示例9: screeninit

void
screeninit(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,代码来源:win.c

示例10: main

int 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,代码来源:main.c

示例11: main

int 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,代码来源:readfb.c

示例12: CGDisplayBounds

wxRect 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,代码来源:display.cpp

示例13: wxDisplaySize

// Get size of display
void 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,代码来源:utils_osx.cpp

示例14: infoDisplays

void
infoDisplays(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,代码来源:fb-rotate.c

示例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,代码来源:Platform.cpp


注:本文中的CGDisplayBounds函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。