/* * xprAddPseudoramiXScreens * Add a single virtual screen encompassing all the physical screens * with PseudoramiX. */ static void xprAddPseudoramiXScreens(int *x, int *y, int *width, int *height, ScreenPtr pScreen) { CGDisplayCount i, displayCount; CGDirectDisplayID *displayList = NULL; CGRect unionRect = CGRectNull, frame; // Find all the CoreGraphics displays CGGetActiveDisplayList(0, NULL, &displayCount); DEBUG_LOG("displayCount: %d\n", (int)displayCount); if(!displayCount) { ErrorF("CoreGraphics has reported no connected displays. Creating a stub 800x600 display.\n"); *x = *y = 0; *width = 800; *height = 600; PseudoramiXAddScreen(*x, *y, *width, *height); return; } displayList = malloc(displayCount * sizeof(CGDirectDisplayID)); if(!displayList) FatalError("Unable to allocate memory for list of displays.\n"); CGGetActiveDisplayList(displayCount, displayList, &displayCount); QuartzCopyDisplayIDs(pScreen, displayCount, displayList); /* Get the union of all screens */ for (i = 0; i < displayCount; i++) { CGDirectDisplayID dpy = displayList[i]; frame = displayScreenBounds(dpy); unionRect = CGRectUnion(unionRect, frame); } /* Use unionRect as the screen size for the X server. */ *x = unionRect.origin.x; *y = unionRect.origin.y; *width = unionRect.size.width; *height = unionRect.size.height; DEBUG_LOG(" screen union origin: (%d,%d) size: (%d,%d).\n", *x, *y, *width, *height); /* Tell PseudoramiX about the real screens. */ for (i = 0; i < displayCount; i++) { CGDirectDisplayID dpy = displayList[i]; frame = displayScreenBounds(dpy); frame.origin.x -= unionRect.origin.x; frame.origin.y -= unionRect.origin.y; DEBUG_LOG(" placed at X11 coordinate (%d,%d).\n", (int)frame.origin.x, (int)frame.origin.y); PseudoramiXAddScreen(frame.origin.x, frame.origin.y, frame.size.width, frame.size.height); } free(displayList); }
/*********************************************************************** * macdrv_get_desktop_rect * * Returns the rectangle encompassing all the screens. */ CGRect macdrv_get_desktop_rect(void) { CGRect ret; CGDirectDisplayID displayIDs[32]; uint32_t count, i; EnterCriticalSection(&device_data_section); if (!device_data_valid) { desktop_rect = CGRectNull; if (CGGetActiveDisplayList(sizeof(displayIDs)/sizeof(displayIDs[0]), displayIDs, &count) != kCGErrorSuccess || !count) { displayIDs[0] = CGMainDisplayID(); count = 1; } for (i = 0; i < count; i++) desktop_rect = CGRectUnion(desktop_rect, CGDisplayBounds(displayIDs[i])); } ret = desktop_rect; LeaveCriticalSection(&device_data_section); TRACE("%s\n", wine_dbgstr_cgrect(ret)); return ret; }
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")); }
void COSXScreen::updateScreenShape(const CGDirectDisplayID, const CGDisplayChangeSummaryFlags flags) { // 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; if (m_isPrimary && !m_isOnScreen) { sendEvent(getShapeChangedEvent()); } LOG((CLOG_DEBUG "screen shape: %d,%d %dx%d on %u %s", m_x, m_y, m_w, m_h, displayCount, (displayCount == 1) ? "display" : "displays")); }
/* * xprAddPseudoramiXScreens * Add a single virtual screen encompassing all the physical screens * with PseudoramiX. */ static void xprAddPseudoramiXScreens(int *x, int *y, int *width, int *height) { CGDisplayCount i, displayCount; CGDirectDisplayID *displayList = NULL; CGRect unionRect = CGRectNull, frame; // Find all the CoreGraphics displays CGGetActiveDisplayList(0, NULL, &displayCount); displayList = xalloc(displayCount * sizeof(CGDirectDisplayID)); CGGetActiveDisplayList(displayCount, displayList, &displayCount); /* Get the union of all screens */ for (i = 0; i < displayCount; i++) { CGDirectDisplayID dpy = displayList[i]; frame = displayScreenBounds(dpy); unionRect = CGRectUnion(unionRect, frame); } /* Use unionRect as the screen size for the X server. */ *x = unionRect.origin.x; *y = unionRect.origin.y; *width = unionRect.size.width; *height = unionRect.size.height; /* Tell PseudoramiX about the real screens. */ for (i = 0; i < displayCount; i++) { CGDirectDisplayID dpy = displayList[i]; frame = displayScreenBounds(dpy); ErrorF("PseudoramiX screen %d added: %dx%d @ (%d,%d).\n", i, (int)frame.size.width, (int)frame.size.height, (int)frame.origin.x, (int)frame.origin.y); frame.origin.x -= unionRect.origin.x; frame.origin.y -= unionRect.origin.y; ErrorF("PseudoramiX screen %d placed at X11 coordinate (%d,%d).\n", i, (int)frame.origin.x, (int)frame.origin.y); PseudoramiXAddScreen(frame.origin.x, frame.origin.y, frame.size.width, frame.size.height); } xfree(displayList); }
JNIEXPORT void JNICALL OS_NATIVE(CGRectUnion) (JNIEnv *env, jclass that, jobject arg0, jobject arg1, jobject arg2) { CGRect _arg0, *lparg0=NULL; CGRect _arg1, *lparg1=NULL; CGRect _arg2, *lparg2=NULL; OS_NATIVE_ENTER(env, that, CGRectUnion_FUNC); if (arg0) if ((lparg0 = getCGRectFields(env, arg0, &_arg0)) == NULL) goto fail; if (arg1) if ((lparg1 = getCGRectFields(env, arg1, &_arg1)) == NULL) goto fail; if (arg2) if ((lparg2 = &_arg2) == NULL) goto fail; *lparg2 = CGRectUnion(*lparg0, *lparg1); fail: if (arg2 && lparg2) setCGRectFields(env, arg2, lparg2); OS_NATIVE_EXIT(env, that, CGRectUnion_FUNC); }
/*********************************************************************** * compute_desktop_rect */ static void compute_desktop_rect(void) { CGDirectDisplayID displayIDs[32]; uint32_t count, i; desktop_rect = CGRectNull; if (CGGetActiveDisplayList(sizeof(displayIDs)/sizeof(displayIDs[0]), displayIDs, &count) != kCGErrorSuccess || !count) { displayIDs[0] = CGMainDisplayID(); count = 1; } for (i = 0; i < count; i++) desktop_rect = CGRectUnion(desktop_rect, CGDisplayBounds(displayIDs[i])); desktop_rect = cgrect_win_from_mac(desktop_rect); }
// --------------------------------------------------------------------------- // // ----------- void bToolPrintArea::fit_to_objs(bArray* arr){ bGenericGeoElement* o; bGenericStyle* style; long j; CGRect ro,rg=CGRectZero; for(long i=1;i<=arr->count();i++){ arr->get(i,&o); for(j=1;j<=_gapp->layersAccessCtx()->count();j++){ style=_gapp->layersAccessCtx()->get(j); if(!style->visible()){ continue; } if(style->gettype()==NULL){ continue; } if(style->gettype()->index()!=o->getType()){ continue; } style->rect(o,&ro); if(CGRectIsEmpty(ro)){ continue; } if(CGRectIsEmpty(rg)){ rg=ro; } else{ rg=CGRectUnion(rg,ro); } } } if(CGRectIsEmpty(rg)){ return; } _vxr=cgr2ivr(_gapp,rg); }