307 }
308 return super.getCenterPoint();
309 }
310
311 /**
312 * Override for Xinerama case
313 */
314 public Rectangle getMaximumWindowBounds() {
315 if (runningXinerama()) {
316 return getXineramaWindowBounds();
317 } else {
318 return super.getMaximumWindowBounds();
319 }
320 }
321
322 public boolean runningXinerama() {
323 if (xinerState == null) {
324 // pRunningXinerama() simply returns a global boolean variable,
325 // so there is no need to synchronize here
326 xinerState = Boolean.valueOf(pRunningXinerama());
327 if (screenLog.isLoggable(PlatformLogger.FINER)) {
328 screenLog.finer("Running Xinerama: " + xinerState);
329 }
330 }
331 return xinerState.booleanValue();
332 }
333
334 /**
335 * Return the bounds for a centered Window on a system running in Xinerama
336 * mode.
337 *
338 * Calculations are based on the assumption of a perfectly rectangular
339 * display area (display edges line up with one another, and displays
340 * have consistent width and/or height).
341 *
342 * The bounds to return depend on the arrangement of displays and on where
343 * Windows are to be centered. There are two common situations:
344 *
345 * 1) The center point lies at the center of the combined area of all the
346 * displays. In this case, the combined area of all displays is
347 * returned.
391 for (i = 0; i < gds.length; i++) {
392 tempRect = getUsableBounds(gds[i]);
393 if (centerMonitorRect == null &&
394 // add a pixel or two for fudge-factor
395 (tempRect.width / 2) + tempRect.x > center.x - 1 &&
396 (tempRect.height / 2) + tempRect.y > center.y - 1 &&
397 (tempRect.width / 2) + tempRect.x < center.x + 1 &&
398 (tempRect.height / 2) + tempRect.y < center.y + 1) {
399 centerMonitorRect = tempRect;
400 }
401 unionRect = unionRect.union(tempRect);
402 }
403
404 // first: check for center of all monitors (video wall)
405 // add a pixel or two for fudge-factor
406 if ((unionRect.width / 2) + unionRect.x > center.x - 1 &&
407 (unionRect.height / 2) + unionRect.y > center.y - 1 &&
408 (unionRect.width / 2) + unionRect.x < center.x + 1 &&
409 (unionRect.height / 2) + unionRect.y < center.y + 1) {
410
411 if (screenLog.isLoggable(PlatformLogger.FINER)) {
412 screenLog.finer("Video Wall: center point is at center of all displays.");
413 }
414 return unionRect;
415 }
416
417 // next, check if at center of one monitor
418 if (centerMonitorRect != null) {
419 if (screenLog.isLoggable(PlatformLogger.FINER)) {
420 screenLog.finer("Center point at center of a particular " +
421 "monitor, but not of the entire virtual display.");
422 }
423 return centerMonitorRect;
424 }
425
426 // otherwise, the center is at some weird spot: return unionRect
427 if (screenLog.isLoggable(PlatformLogger.FINER)) {
428 screenLog.finer("Center point is somewhere strange - return union of all bounds.");
429 }
430 return unionRect;
431 }
432
433 /**
434 * From the DisplayChangedListener interface; devices do not need
435 * to react to this event.
436 */
437 @Override
438 public void paletteChanged() {
439 }
440 }
|
307 }
308 return super.getCenterPoint();
309 }
310
311 /**
312 * Override for Xinerama case
313 */
314 public Rectangle getMaximumWindowBounds() {
315 if (runningXinerama()) {
316 return getXineramaWindowBounds();
317 } else {
318 return super.getMaximumWindowBounds();
319 }
320 }
321
322 public boolean runningXinerama() {
323 if (xinerState == null) {
324 // pRunningXinerama() simply returns a global boolean variable,
325 // so there is no need to synchronize here
326 xinerState = Boolean.valueOf(pRunningXinerama());
327 if (screenLog.isLoggable(PlatformLogger.Level.FINER)) {
328 screenLog.finer("Running Xinerama: " + xinerState);
329 }
330 }
331 return xinerState.booleanValue();
332 }
333
334 /**
335 * Return the bounds for a centered Window on a system running in Xinerama
336 * mode.
337 *
338 * Calculations are based on the assumption of a perfectly rectangular
339 * display area (display edges line up with one another, and displays
340 * have consistent width and/or height).
341 *
342 * The bounds to return depend on the arrangement of displays and on where
343 * Windows are to be centered. There are two common situations:
344 *
345 * 1) The center point lies at the center of the combined area of all the
346 * displays. In this case, the combined area of all displays is
347 * returned.
391 for (i = 0; i < gds.length; i++) {
392 tempRect = getUsableBounds(gds[i]);
393 if (centerMonitorRect == null &&
394 // add a pixel or two for fudge-factor
395 (tempRect.width / 2) + tempRect.x > center.x - 1 &&
396 (tempRect.height / 2) + tempRect.y > center.y - 1 &&
397 (tempRect.width / 2) + tempRect.x < center.x + 1 &&
398 (tempRect.height / 2) + tempRect.y < center.y + 1) {
399 centerMonitorRect = tempRect;
400 }
401 unionRect = unionRect.union(tempRect);
402 }
403
404 // first: check for center of all monitors (video wall)
405 // add a pixel or two for fudge-factor
406 if ((unionRect.width / 2) + unionRect.x > center.x - 1 &&
407 (unionRect.height / 2) + unionRect.y > center.y - 1 &&
408 (unionRect.width / 2) + unionRect.x < center.x + 1 &&
409 (unionRect.height / 2) + unionRect.y < center.y + 1) {
410
411 if (screenLog.isLoggable(PlatformLogger.Level.FINER)) {
412 screenLog.finer("Video Wall: center point is at center of all displays.");
413 }
414 return unionRect;
415 }
416
417 // next, check if at center of one monitor
418 if (centerMonitorRect != null) {
419 if (screenLog.isLoggable(PlatformLogger.Level.FINER)) {
420 screenLog.finer("Center point at center of a particular " +
421 "monitor, but not of the entire virtual display.");
422 }
423 return centerMonitorRect;
424 }
425
426 // otherwise, the center is at some weird spot: return unionRect
427 if (screenLog.isLoggable(PlatformLogger.Level.FINER)) {
428 screenLog.finer("Center point is somewhere strange - return union of all bounds.");
429 }
430 return unionRect;
431 }
432
433 /**
434 * From the DisplayChangedListener interface; devices do not need
435 * to react to this event.
436 */
437 @Override
438 public void paletteChanged() {
439 }
440 }
|