1 /* 2 * Copyright (c) 2005, 2007, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* 25 test 26 @bug 4868278 27 @summary Tests that GraphicsConfig for invisible (peerless) window is 28 updated after showing the window 29 @author artem.ananiev, area=awt.multiscreen 30 @library ../../regtesthelpers 31 @build Util 32 @run applet WindowGCChangeTest.html 33 */ 34 35 import java.applet.Applet; 36 37 import java.awt.*; 38 import java.awt.event.*; 39 40 import test.java.awt.regtesthelpers.Util; 41 42 public class WindowGCChangeTest extends Applet 43 { 44 public void init() 45 { 46 } 47 48 public void start() 49 { 50 Robot robot = null; 51 try 52 { 53 robot = new Robot(); 54 } 55 catch (Exception z) 56 { 57 z.printStackTrace(System.err); 58 throw new RuntimeException("Test FAILED: couldn't create Robot instance", z); 59 } 60 61 setSize(200, 200); 62 setVisible(true); 63 validate(); 64 Util.waitForIdle(robot); 65 66 GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); 67 GraphicsDevice[] gds = ge.getScreenDevices(); 68 // check 2-screens systems only 69 if (gds.length != 2) 70 { 71 return; 72 } 73 74 int defGDNo = 0; 75 int nondefGDNo = 0; 76 boolean isVirtualScreen = false; 77 GraphicsDevice defgd = ge.getDefaultScreenDevice(); 78 for (int i = 0; i < gds.length; i++) 79 { 80 Rectangle r = gds[i].getDefaultConfiguration().getBounds(); 81 if ((r.x != 0) || (r.y != 0)) 82 { 83 isVirtualScreen = true; | 1 /* 2 * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. 8 * 9 * This code is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 /* 25 @test 26 @key headful 27 @bug 4868278 28 @summary Tests that GraphicsConfig for invisible (peerless) windows is 29 updated after showing the window 30 @library ../../regtesthelpers 31 @build Util 32 @run main WindowGCChangeTest 33 */ 34 35 import java.awt.*; 36 import java.awt.event.*; 37 38 import test.java.awt.regtesthelpers.Util; 39 40 public class WindowGCChangeTest { 41 42 public static void main(final String[] args) { 43 Robot robot = null; 44 try 45 { 46 robot = new Robot(); 47 } 48 catch (Exception z) 49 { 50 z.printStackTrace(System.err); 51 throw new RuntimeException("Test FAILED: couldn't create Robot instance", z); 52 } 53 Util.waitForIdle(robot); 54 55 GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); 56 GraphicsDevice[] gds = ge.getScreenDevices(); 57 // check 2-screens systems only 58 if (gds.length != 2) 59 { 60 return; 61 } 62 63 int defGDNo = 0; 64 int nondefGDNo = 0; 65 boolean isVirtualScreen = false; 66 GraphicsDevice defgd = ge.getDefaultScreenDevice(); 67 for (int i = 0; i < gds.length; i++) 68 { 69 Rectangle r = gds[i].getDefaultConfiguration().getBounds(); 70 if ((r.x != 0) || (r.y != 0)) 71 { 72 isVirtualScreen = true; |