--- old/src/java.desktop/windows/classes/sun/java2d/d3d/D3DGraphicsDevice.java 2015-05-05 17:09:21.906090000 +0530 +++ new/src/java.desktop/windows/classes/sun/java2d/d3d/D3DGraphicsDevice.java 2015-05-05 17:09:21.380023200 +0530 @@ -268,7 +268,7 @@ } fsWindowWasAlwaysOnTop = realFSWindow.isAlwaysOnTop(); - ((WWindowPeer)realFSWindow.getPeer()).setAlwaysOnTop(true); + //((WWindowPeer)realFSWindow.getPeer()).setAlwaysOnTop(true); fsWindowListener = new D3DFSWindowAdapter(); realFSWindow.addWindowListener(fsWindowListener); --- old/src/java.desktop/windows/native/libawt/windows/awt_Win32GraphicsDevice.cpp 2015-05-05 17:09:24.952976900 +0530 +++ new/src/java.desktop/windows/native/libawt/windows/awt_Win32GraphicsDevice.cpp 2015-05-05 17:09:24.421909500 +0530 @@ -1020,7 +1020,9 @@ // with the WWindowPeer object HWND hWnd = window->GetHWnd(); - if (!::SetWindowPos(hWnd, HWND_TOPMOST, 0, 0, 0, 0, + // Place the window at top of Z-order. we do not want HWND_TOPMOST as it + // maintains topmost position even when it is not in focus + if (!::SetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOOWNERZORDER|SWP_NOSIZE)) { J2dTraceLn1(J2D_TRACE_ERROR, --- old/src/java.desktop/windows/native/libawt/java2d/d3d/D3DGraphicsDevice.cpp 2015-05-05 17:09:27.973360500 +0530 +++ new/src/java.desktop/windows/native/libawt/java2d/d3d/D3DGraphicsDevice.cpp 2015-05-05 17:09:27.482798200 +0530 @@ -178,7 +178,9 @@ newParams = *pCurParams; newParams.hDeviceWindow = hWnd; - newParams.Windowed = FALSE; + // Since we are not creating hwnd with WS_EX_TOPMOST flag, so Windowed flag + // needs to be TRUE for fullscreen window + newParams.Windowed = TRUE; newParams.BackBufferCount = 1; newParams.BackBufferFormat = dm.Format; newParams.FullScreen_RefreshRateInHz = dm.RefreshRate; --- /dev/null 2015-05-05 17:09:31.000000000 +0530 +++ new/test/java/awt/FullScreen/AWTFullScreen/AWTFullScreenTest.java 2015-05-05 17:09:30.446674500 +0530 @@ -0,0 +1,90 @@ +/* + * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +import java.awt.Canvas; +import java.awt.Component; +import java.awt.Color; +import java.awt.EventQueue; +import java.awt.GraphicsDevice; +import java.awt.GraphicsEnvironment; +import javax.swing.JFrame; +import javax.swing.JOptionPane; +import javax.swing.SwingUtilities; + +/** + * @test + * @bug 7011935 + * @summary Verifies a fullscreen window with proper background is shown. + * @run main/manual AWTFullscreenTest + */ + +public class AWTFullScreenTest +{ + public static void main(String[] arg) throws Exception + { + try { + String temp1 = "The test should show a red canvas on topleft"; + String temp2 = " corner of blue fullscreen window"; + SwingUtilities.invokeAndWait(() -> { + JOptionPane.showMessageDialog( + (Component) null, + temp1.concat(temp2), + "information", JOptionPane.INFORMATION_MESSAGE); + }); + final GraphicsDevice screen = + GraphicsEnvironment.getLocalGraphicsEnvironment(). + getDefaultScreenDevice(); + JFrame frame = new JFrame(); + frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); + frame.getContentPane().setBackground(Color.BLUE); + frame.getContentPane().setLayout(null); + frame.setUndecorated(true); + + Canvas canvas = new Canvas(); + canvas.setBackground(Color.RED); + canvas.setBounds(10, 10, 100, 100); + frame.getContentPane().add(canvas); + + System.out.println("isFullscreenSupported=" + + screen.isFullScreenSupported()); + screen.setFullScreenWindow(frame); + Thread.sleep(5000); + String str1 = "Did a blue fullscreen window"; + String str2 = " was shown with red canvas on top?"; + SwingUtilities.invokeAndWait(() -> { + int confirm = JOptionPane.showConfirmDialog( + (Component) null, + str1.concat(str2), + "alert", JOptionPane.YES_NO_OPTION); + if (confirm == JOptionPane.YES_OPTION) { + System.out.println("Test passed"); + } else { + System.out.println("Test failed"); + throw new RuntimeException("Fullscreen window not shown"); + } + }); + SwingUtilities.invokeLater(() -> { + frame.dispose(); + }); + } catch (Exception e) {} + } +}