665 * Based on checkNewXineramaScreen() in awt_GraphicsEnv.c 666 */ 667 public void checkIfOnNewScreen(Rectangle newBounds) { 668 if (!XToolkit.localEnv.runningXinerama()) { 669 return; 670 } 671 672 if (log.isLoggable(PlatformLogger.Level.FINEST)) { 673 log.finest("XWindowPeer: Check if we've been moved to a new screen since we're running in Xinerama mode"); 674 } 675 676 int area = newBounds.width * newBounds.height; 677 int intAmt, vertAmt, horizAmt; 678 int largestAmt = 0; 679 int curScreenNum = ((X11GraphicsDevice)getGraphicsConfiguration().getDevice()).getScreen(); 680 int newScreenNum = 0; 681 GraphicsDevice gds[] = XToolkit.localEnv.getScreenDevices(); 682 GraphicsConfiguration newGC = null; 683 Rectangle screenBounds; 684 685 for (int i = 0; i < gds.length; i++) { 686 screenBounds = gds[i].getDefaultConfiguration().getBounds(); 687 if (newBounds.intersects(screenBounds)) { 688 horizAmt = Math.min(newBounds.x + newBounds.width, 689 screenBounds.x + screenBounds.width) - 690 Math.max(newBounds.x, screenBounds.x); 691 vertAmt = Math.min(newBounds.y + newBounds.height, 692 screenBounds.y + screenBounds.height)- 693 Math.max(newBounds.y, screenBounds.y); 694 intAmt = horizAmt * vertAmt; 695 if (intAmt == area) { 696 // Completely on this screen - done! 697 newScreenNum = i; 698 newGC = gds[i].getDefaultConfiguration(); 699 break; 700 } 701 if (intAmt > largestAmt) { 702 largestAmt = intAmt; 703 newScreenNum = i; 704 newGC = gds[i].getDefaultConfiguration(); 705 } 706 } 707 } 708 if (newScreenNum != curScreenNum) { 709 if (log.isLoggable(PlatformLogger.Level.FINEST)) { 710 log.finest("XWindowPeer: Moved to a new screen"); 711 } 712 executeDisplayChangedOnEDT(newGC); 713 } 714 } 715 716 /** 717 * Helper method that executes the displayChanged(screen) method on 718 * the event dispatch thread. This method is used in the Xinerama case 719 * and after display mode change events. 720 */ 721 private void executeDisplayChangedOnEDT(final GraphicsConfiguration gc) { 722 Runnable dc = new Runnable() { 723 public void run() { 724 AWTAccessor.getComponentAccessor(). 725 setGraphicsConfiguration(target, gc); 726 } | 665 * Based on checkNewXineramaScreen() in awt_GraphicsEnv.c 666 */ 667 public void checkIfOnNewScreen(Rectangle newBounds) { 668 if (!XToolkit.localEnv.runningXinerama()) { 669 return; 670 } 671 672 if (log.isLoggable(PlatformLogger.Level.FINEST)) { 673 log.finest("XWindowPeer: Check if we've been moved to a new screen since we're running in Xinerama mode"); 674 } 675 676 int area = newBounds.width * newBounds.height; 677 int intAmt, vertAmt, horizAmt; 678 int largestAmt = 0; 679 int curScreenNum = ((X11GraphicsDevice)getGraphicsConfiguration().getDevice()).getScreen(); 680 int newScreenNum = 0; 681 GraphicsDevice gds[] = XToolkit.localEnv.getScreenDevices(); 682 GraphicsConfiguration newGC = null; 683 Rectangle screenBounds; 684 685 XToolkit.awtUnlock(); 686 try { 687 for (int i = 0; i < gds.length; i++) { 688 screenBounds = gds[i].getDefaultConfiguration().getBounds(); 689 if (newBounds.intersects(screenBounds)) { 690 horizAmt = Math.min(newBounds.x + newBounds.width, 691 screenBounds.x + screenBounds.width) - 692 Math.max(newBounds.x, screenBounds.x); 693 vertAmt = Math.min(newBounds.y + newBounds.height, 694 screenBounds.y + screenBounds.height)- 695 Math.max(newBounds.y, screenBounds.y); 696 intAmt = horizAmt * vertAmt; 697 if (intAmt == area) { 698 // Completely on this screen - done! 699 newScreenNum = i; 700 newGC = gds[i].getDefaultConfiguration(); 701 break; 702 } 703 if (intAmt > largestAmt) { 704 largestAmt = intAmt; 705 newScreenNum = i; 706 newGC = gds[i].getDefaultConfiguration(); 707 } 708 } 709 } 710 } finally { 711 XToolkit.awtLock(); 712 } 713 if (newScreenNum != curScreenNum) { 714 if (log.isLoggable(PlatformLogger.Level.FINEST)) { 715 log.finest("XWindowPeer: Moved to a new screen"); 716 } 717 executeDisplayChangedOnEDT(newGC); 718 } 719 } 720 721 /** 722 * Helper method that executes the displayChanged(screen) method on 723 * the event dispatch thread. This method is used in the Xinerama case 724 * and after display mode change events. 725 */ 726 private void executeDisplayChangedOnEDT(final GraphicsConfiguration gc) { 727 Runnable dc = new Runnable() { 728 public void run() { 729 AWTAccessor.getComponentAccessor(). 730 setGraphicsConfiguration(target, gc); 731 } |