jdk/src/java.desktop/windows/classes/sun/awt/Win32GraphicsDevice.java
author darcy
Tue, 16 Dec 2014 09:57:33 -0800
changeset 28234 f694f2576719
parent 25859 3317bb8137f4
child 30469 bac0a7ff7e1e
permissions -rw-r--r--
8067092: Suppress windows-specific deprecation warnings in the java.desktop module Reviewed-by: prr, alanb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 7668
diff changeset
     2
 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4285
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4285
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4285
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4285
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 4285
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package sun.awt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.awt.AWTPermission;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.awt.GraphicsDevice;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.awt.GraphicsConfiguration;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.awt.GraphicsEnvironment;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.awt.DisplayMode;
7492
494fbd1859a1 6709453: (dav)Screen flickers when a JFrame switches to fullscreen mode
dav
parents: 5506
diff changeset
    33
import java.awt.EventQueue;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.awt.Frame;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.awt.Rectangle;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.awt.Window;
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    37
import java.awt.event.WindowAdapter;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    38
import java.awt.event.WindowEvent;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    39
import java.awt.event.WindowListener;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import java.awt.image.ColorModel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import java.util.ArrayList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import java.util.Vector;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
import java.awt.peer.WindowPeer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
import sun.awt.windows.WWindowPeer;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
import sun.java2d.opengl.WGLGraphicsConfig;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
import sun.java2d.windows.WindowsFlags;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
 * This is an implementation of a GraphicsDevice object for a single
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
 * Win32 screen.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
 * @see GraphicsEnvironment
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
 * @see GraphicsConfiguration
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
public class Win32GraphicsDevice extends GraphicsDevice implements
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
 DisplayChangedListener {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    int screen;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    ColorModel dynamicColorModel;   // updated with dev changes
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    ColorModel colorModel;          // static for device
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    60
    protected GraphicsConfiguration[] configs;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    61
    protected GraphicsConfiguration defaultConfig;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    private final String idString;
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    64
    protected String descString;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    // Note that we do not synchronize access to this variable - it doesn't
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    // really matter if a thread does an operation on graphics device which is
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    // about to become invalid (or already become) - we are prepared to deal
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    // with this on the native level.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    private boolean valid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    // keep track of top-level windows on this display
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    private SunDisplayChanger topLevels = new SunDisplayChanger();
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    73
    // REMIND: we may disable the use of pixel formats for some accelerated
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    74
    // pipelines which are mutually exclusive with opengl, for which
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    75
    // pixel formats were added in the first place
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    76
    protected static boolean pfDisabled;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    private static AWTPermission fullScreenExclusivePermission;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    // the original display mode we had before entering the fullscreen
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    // mode
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    private DisplayMode defaultDisplayMode;
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    81
    // activation/deactivation listener for the full-screen window
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
    82
    private WindowListener fsWindowListener;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        // 4455041 - Even when ddraw is disabled, ddraw.dll is loaded when
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        // pixel format calls are made.  This causes problems when a Java app
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        // is run as an NT service.  To prevent the loading of ddraw.dll
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        // completely, sun.awt.nopixfmt should be set as well.  Apps which use
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        // OpenGL w/ Java probably don't want to set this.
22584
eed64ee05369 8032733: Fix cast lint warnings in client libraries
darcy
parents: 7668
diff changeset
    91
        String nopixfmt = java.security.AccessController.doPrivileged(
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
            new sun.security.action.GetPropertyAction("sun.awt.nopixfmt"));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
        pfDisabled = (nopixfmt != null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        initIDs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    private static native void initIDs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    native void initDevice(int screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    public Win32GraphicsDevice(int screennum) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
        this.screen = screennum;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        // we cache the strings because we want toString() and getIDstring
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        // to reflect the original screen number (which may change if the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        // device is removed)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        idString = "\\Display"+screen;
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   107
        // REMIND: may be should use class name?
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
        descString = "Win32GraphicsDevice[screen=" + screen;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        valid = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        initDevice(screennum);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
     * Returns the type of the graphics device.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * @see #TYPE_RASTER_SCREEN
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     * @see #TYPE_PRINTER
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
     * @see #TYPE_IMAGE_BUFFER
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    public int getType() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        return TYPE_RASTER_SCREEN;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     * Returns the Win32 screen of the device.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    public int getScreen() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
        return screen;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
     * Returns whether this is a valid devicie. Device can become
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
     * invalid as a result of device removal event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
     */
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   135
    public boolean isValid() {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        return valid;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
     * Called from native code when the device was removed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
     * @param defaultScreen the current default screen
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
     */
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   144
    protected void invalidate(int defaultScreen) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        valid = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        screen = defaultScreen;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     * Returns the identification string associated with this graphics
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
     * device.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    public String getIDstring() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
        return idString;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
     * Returns all of the graphics
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
     * configurations associated with this graphics device.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
    public GraphicsConfiguration[] getConfigurations() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        if (configs==null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
            if (WindowsFlags.isOGLEnabled() && isDefaultDevice()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
                defaultConfig = getDefaultConfiguration();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
                if (defaultConfig != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
                    configs = new GraphicsConfiguration[1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
                    configs[0] = defaultConfig;
4204
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents: 2459
diff changeset
   169
                    return configs.clone();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
            int max = getMaxConfigs(screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
            int defaultPixID = getDefaultPixID(screen);
25192
4e2dc0f8702d 8044551: Fix raw and unchecked lint warnings in platform-specific sun.awt files
henryjen
parents: 22584
diff changeset
   175
            Vector<GraphicsConfiguration> v = new Vector<>( max );
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
            if (defaultPixID == 0) {
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   177
                // Workaround for failing GDI calls
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
                defaultConfig = Win32GraphicsConfig.getConfig(this,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
                                                              defaultPixID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
                v.addElement(defaultConfig);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
            else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
                for (int i = 1; i <= max; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
                    if (isPixFmtSupported(i, screen)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
                        if (i == defaultPixID) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
                            defaultConfig = Win32GraphicsConfig.getConfig(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
                             this, i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
                            v.addElement(defaultConfig);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
                        else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
                            v.addElement(Win32GraphicsConfig.getConfig(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
                             this, i));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
                        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
            configs = new GraphicsConfiguration[v.size()];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
            v.copyInto(configs);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        }
4204
d8eff41661bf 6822057: X11 and Win32GraphicsDevice don't clone arrays returned from getConfigurations()
bae
parents: 2459
diff changeset
   200
        return configs.clone();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
     * Returns the maximum number of graphics configurations available, or 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
     * if PixelFormat calls fail or are disabled.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
     * This number is less than or equal to the number of graphics
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
     * configurations supported.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    protected int getMaxConfigs(int screen) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
        if (pfDisabled) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
            return 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
            return getMaxConfigsImpl(screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    private native int getMaxConfigsImpl(int screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
     * Returns whether or not the PixelFormat indicated by index is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
     * supported.  Supported PixelFormats support drawing to a Window
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
     * (PFD_DRAW_TO_WINDOW), support GDI (PFD_SUPPORT_GDI), and in the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
     * case of an 8-bit format (cColorBits <= 8) uses indexed colors
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
     * (iPixelType == PFD_TYPE_COLORINDEX).
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
     * We use the index 0 to indicate that PixelFormat calls don't work, or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
     * are disabled.  Do not call this function with an index of 0.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * @param index a PixelFormat index
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
    protected native boolean isPixFmtSupported(int index, int screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
     * Returns the PixelFormatID of the default graphics configuration
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
     * associated with this graphics device, or 0 if PixelFormats calls fail or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
     * are disabled.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
    protected int getDefaultPixID(int screen) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        if (pfDisabled) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
            return 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
            return getDefaultPixIDImpl(screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
     * Returns the default PixelFormat ID from GDI.  Do not call if PixelFormats
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
     * are disabled.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
    private native int getDefaultPixIDImpl(int screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
     * Returns the default graphics configuration
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
     * associated with this graphics device.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
    public GraphicsConfiguration getDefaultConfiguration() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        if (defaultConfig == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
            // first try to create a WGLGraphicsConfig if OGL is enabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
            // REMIND: the WGL code does not yet work properly in multimon
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
            // situations, so we will fallback on GDI if we are not on the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
            // default device...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
            if (WindowsFlags.isOGLEnabled() && isDefaultDevice()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
                int defPixID = WGLGraphicsConfig.getDefaultPixFmt(screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
                defaultConfig = WGLGraphicsConfig.getConfig(this, defPixID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
                if (WindowsFlags.isOGLVerbose()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
                    if (defaultConfig != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
                        System.out.print("OpenGL pipeline enabled");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
                        System.out.print("Could not enable OpenGL pipeline");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
                    System.out.println(" for default config on screen " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
                                       screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
            // Fix for 4669614.  Most apps are not concerned with PixelFormats,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
            // yet we ALWAYS used them for determining ColorModels and such.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
            // By passing in 0 as the PixelFormatID here, we signal that
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
            // PixelFormats should not be used, thus avoid loading the opengl
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
            // library.  Apps concerned with PixelFormats can still use
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
            // GraphicsConfiguration.getConfigurations().
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
            // Note that calling native pixel format functions tends to cause
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
            // problems between those functions (which are OpenGL-related)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
            // and our use of DirectX.  For example, some Matrox boards will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
            // crash or hang calling these functions when any app is running
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
            // in DirectX fullscreen mode.  So avoiding these calls unless
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
            // absolutely necessary is preferable.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
            if (defaultConfig == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
                defaultConfig = Win32GraphicsConfig.getConfig(this, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
        return defaultConfig;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
    public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
        return valid ? descString + "]" : descString + ", removed]";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
     * Returns true if this is the default GraphicsDevice for the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
     * GraphicsEnvironment.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
    private boolean isDefaultDevice() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
        return (this ==
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
                GraphicsEnvironment.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
                    getLocalGraphicsEnvironment().getDefaultScreenDevice());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
    private static boolean isFSExclusiveModeAllowed() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
        SecurityManager security = System.getSecurityManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
        if (security != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
            if (fullScreenExclusivePermission == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
                fullScreenExclusivePermission =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
                    new AWTPermission("fullScreenExclusive");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
            try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
                security.checkPermission(fullScreenExclusivePermission);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
            } catch (SecurityException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
                return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
        return true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
    /**
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   324
     * returns true unless we're not allowed to use fullscreen mode.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
     */
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   326
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
    public boolean isFullScreenSupported() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
        return isFSExclusiveModeAllowed();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   331
    @Override
28234
f694f2576719 8067092: Suppress windows-specific deprecation warnings in the java.desktop module
darcy
parents: 25859
diff changeset
   332
    @SuppressWarnings("deprecation")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
    public synchronized void setFullScreenWindow(Window w) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
        Window old = getFullScreenWindow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
        if (w == old) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
        if (!isFullScreenSupported()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
            super.setFullScreenWindow(w);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
        // Enter windowed mode.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
        if (old != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
            // restore the original display mode
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
            if (defaultDisplayMode != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
                setDisplayMode(defaultDisplayMode);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
                // we set the default display mode to null here
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
                // because the default mode could change during
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
                // the life of the application (user can change it through
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
                // the desktop properties dialog, for example), so
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
                // we need to record it every time prior to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
                // entering the fullscreen mode.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
                defaultDisplayMode = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
            WWindowPeer peer = (WWindowPeer)old.getPeer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
            if (peer != null) {
4256
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 2459
diff changeset
   358
                peer.setFullScreenExclusiveModeState(false);
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   359
                // we used to destroy the buffers on exiting fs mode, this
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   360
                // is no longer needed since fs change will cause a surface
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   361
                // data replacement
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
                synchronized(peer) {
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   363
                    exitFullScreenExclusive(screen, peer);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
            }
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   366
            removeFSWindowListener(old);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
        super.setFullScreenWindow(w);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
        if (w != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
            // always record the default display mode prior to going
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
            // fullscreen
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
            defaultDisplayMode = getDisplayMode();
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   373
            addFSWindowListener(w);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
            // Enter full screen exclusive mode.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
            WWindowPeer peer = (WWindowPeer)w.getPeer();
4256
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 2459
diff changeset
   376
            if (peer != null) {
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 2459
diff changeset
   377
                synchronized(peer) {
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 2459
diff changeset
   378
                    enterFullScreenExclusive(screen, peer);
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 2459
diff changeset
   379
                    // Note: removed replaceSurfaceData() call because
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 2459
diff changeset
   380
                    // changing the window size or making it visible
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 2459
diff changeset
   381
                    // will cause this anyway, and both of these events happen
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 2459
diff changeset
   382
                    // as part of switching into fullscreen mode.
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 2459
diff changeset
   383
                }
24d614d4764a 6711717: PIT: Security Icon is hidden for FullScreen apps, WinXP
anthony
parents: 2459
diff changeset
   384
                peer.setFullScreenExclusiveModeState(true);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
            // fix for 4868278
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
            peer.updateGC();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
    // Entering and exiting full-screen mode are done within a
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
    // tree-lock and should never lock on any resources which are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
    // required by other threads which may have them and may require
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
    // the tree-lock.
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   396
    // REMIND: in the future these methods may need to become protected so that
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   397
    // subclasses could override them and use appropriate api other than GDI
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   398
    // for implementing these functions.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   399
    protected native void enterFullScreenExclusive(int screen, WindowPeer w);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   400
    protected native void exitFullScreenExclusive(int screen, WindowPeer w);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   402
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
    public boolean isDisplayChangeSupported() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
        return (isFullScreenSupported() && getFullScreenWindow() != null);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   407
    @Override
28234
f694f2576719 8067092: Suppress windows-specific deprecation warnings in the java.desktop module
darcy
parents: 25859
diff changeset
   408
    @SuppressWarnings("deprecation")
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
    public synchronized void setDisplayMode(DisplayMode dm) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
        if (!isDisplayChangeSupported()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
            super.setDisplayMode(dm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
        if (dm == null || (dm = getMatchingDisplayMode(dm)) == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
            throw new IllegalArgumentException("Invalid display mode");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
        if (getDisplayMode().equals(dm)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
        Window w = getFullScreenWindow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
        if (w != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
            WWindowPeer peer = (WWindowPeer)w.getPeer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
            configDisplayMode(screen, peer, dm.getWidth(), dm.getHeight(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
                dm.getBitDepth(), dm.getRefreshRate());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
            // resize the fullscreen window to the dimensions of the new
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
            // display mode
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
            Rectangle screenBounds = getDefaultConfiguration().getBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
            w.setBounds(screenBounds.x, screenBounds.y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
                        dm.getWidth(), dm.getHeight());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
            // Note: no call to replaceSurfaceData is required here since
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
            // replacement will be caused by an upcoming display change event
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
            throw new IllegalStateException("Must be in fullscreen mode " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
                                            "in order to set display mode");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   438
    protected native DisplayMode getCurrentDisplayMode(int screen);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   439
    protected native void configDisplayMode(int screen, WindowPeer w, int width,
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
                                          int height, int bitDepth,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
                                          int refreshRate);
25192
4e2dc0f8702d 8044551: Fix raw and unchecked lint warnings in platform-specific sun.awt files
henryjen
parents: 22584
diff changeset
   442
    protected native void enumDisplayModes(int screen, ArrayList<DisplayMode> modes);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   444
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
    public synchronized DisplayMode getDisplayMode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
        DisplayMode res = getCurrentDisplayMode(screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
        return res;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   450
    @Override
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
    public synchronized DisplayMode[] getDisplayModes() {
25192
4e2dc0f8702d 8044551: Fix raw and unchecked lint warnings in platform-specific sun.awt files
henryjen
parents: 22584
diff changeset
   452
        ArrayList<DisplayMode> modes = new ArrayList<>();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
        enumDisplayModes(screen, modes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
        int listSize = modes.size();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
        DisplayMode[] retArray = new DisplayMode[listSize];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
        for (int i = 0; i < listSize; i++) {
25192
4e2dc0f8702d 8044551: Fix raw and unchecked lint warnings in platform-specific sun.awt files
henryjen
parents: 22584
diff changeset
   457
            retArray[i] = modes.get(i);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
        return retArray;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   462
    protected synchronized DisplayMode getMatchingDisplayMode(DisplayMode dm) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
        if (!isDisplayChangeSupported()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
        }
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   466
        DisplayMode[] modes = getDisplayModes();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   467
        for (DisplayMode mode : modes) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   468
            if (dm.equals(mode) ||
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   469
                (dm.getRefreshRate() == DisplayMode.REFRESH_RATE_UNKNOWN &&
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   470
                 dm.getWidth() == mode.getWidth() &&
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   471
                 dm.getHeight() == mode.getHeight() &&
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   472
                 dm.getBitDepth() == mode.getBitDepth()))
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   473
            {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   474
                return mode;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
        }
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   477
        return null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
     * From the DisplayChangeListener interface.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
     * Called from Win32GraphicsEnvironment when the display settings have
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
     * changed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
    public void displayChanged() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
        dynamicColorModel = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
        defaultConfig = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
        configs = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
        // pass on to all top-level windows on this display
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
        topLevels.notifyListeners();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
     * Part of the DisplayChangedListener interface: devices
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
     * do not need to react to this event
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
    public void paletteChanged() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
     * Add a DisplayChangeListener to be notified when the display settings
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
     * are changed.  Typically, only top-level containers need to be added
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
     * to Win32GraphicsDevice.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
    public void addDisplayChangedListener(DisplayChangedListener client) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
        topLevels.add(client);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
     * Remove a DisplayChangeListener from this Win32GraphicsDevice
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
     public void removeDisplayChangedListener(DisplayChangedListener client) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
        topLevels.remove(client);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
     * Creates and returns the color model associated with this device
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
    private native ColorModel makeColorModel (int screen,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
                                              boolean dynamic);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
     * Returns a dynamic ColorModel which is updated when there
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
     * are any changes (e.g., palette changes) in the device
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
    public ColorModel getDynamicColorModel() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
        if (dynamicColorModel == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
            dynamicColorModel = makeColorModel(screen, true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
        return dynamicColorModel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
     * Returns the non-dynamic ColorModel associated with this device
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
    public ColorModel getColorModel() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
        if (colorModel == null)  {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
            colorModel = makeColorModel(screen, false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
        return colorModel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   543
    /**
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   544
     * WindowAdapter class responsible for de/iconifying full-screen window
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   545
     * of this device.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   546
     *
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   547
     * The listener restores the default display mode when window is iconified
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   548
     * and sets it back to the one set by the user on de-iconification.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   549
     */
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   550
    private static class Win32FSWindowAdapter extends WindowAdapter {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   551
        private Win32GraphicsDevice device;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   552
        private DisplayMode dm;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   553
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   554
        Win32FSWindowAdapter(Win32GraphicsDevice device) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   555
            this.device = device;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   556
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   557
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   558
        private void setFSWindowsState(Window other, int state) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   559
            GraphicsDevice gds[] =
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   560
                    GraphicsEnvironment.getLocalGraphicsEnvironment().
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   561
                    getScreenDevices();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   562
            // check if the de/activation was caused by other
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   563
            // fs window and ignore the event if that's the case
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   564
            if (other != null) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   565
                for (GraphicsDevice gd : gds) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   566
                    if (other == gd.getFullScreenWindow()) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   567
                        return;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   568
                    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   569
                }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   570
            }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   571
            // otherwise apply state to all fullscreen windows
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   572
            for (GraphicsDevice gd : gds) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   573
                Window fsw = gd.getFullScreenWindow();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   574
                if (fsw instanceof Frame) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   575
                    ((Frame)fsw).setExtendedState(state);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   576
                }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   577
            }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   578
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   579
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   580
        @Override
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   581
        public void windowDeactivated(WindowEvent e) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   582
            setFSWindowsState(e.getOppositeWindow(), Frame.ICONIFIED);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   583
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   584
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   585
        @Override
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   586
        public void windowActivated(WindowEvent e) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   587
            setFSWindowsState(e.getOppositeWindow(), Frame.NORMAL);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   588
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   589
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   590
        @Override
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   591
        public void windowIconified(WindowEvent e) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   592
            // restore the default display mode for this device
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   593
            DisplayMode ddm = device.defaultDisplayMode;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   594
            if (ddm != null) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   595
                dm = device.getDisplayMode();
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   596
                device.setDisplayMode(ddm);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   597
            }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   598
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   599
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   600
        @Override
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   601
        public void windowDeiconified(WindowEvent e) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   602
            // restore the user-set display mode for this device
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   603
            if (dm != null) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   604
                device.setDisplayMode(dm);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   605
                dm = null;
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   606
            }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   607
        }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   608
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
    /**
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   611
     * Adds a WindowListener to be used as
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   612
     * activation/deactivation listener for the current full-screen window.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   613
     *
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   614
     * @param w full-screen window
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
     */
7492
494fbd1859a1 6709453: (dav)Screen flickers when a JFrame switches to fullscreen mode
dav
parents: 5506
diff changeset
   616
    protected void addFSWindowListener(final Window w) {
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   617
        // Note: even though we create a listener for Window instances of
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   618
        // fs windows they will not receive window events.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   619
        fsWindowListener = new Win32FSWindowAdapter(this);
7492
494fbd1859a1 6709453: (dav)Screen flickers when a JFrame switches to fullscreen mode
dav
parents: 5506
diff changeset
   620
494fbd1859a1 6709453: (dav)Screen flickers when a JFrame switches to fullscreen mode
dav
parents: 5506
diff changeset
   621
        // Fix for 6709453. Using invokeLater to avoid listening
494fbd1859a1 6709453: (dav)Screen flickers when a JFrame switches to fullscreen mode
dav
parents: 5506
diff changeset
   622
        // for the events already posted to the queue.
494fbd1859a1 6709453: (dav)Screen flickers when a JFrame switches to fullscreen mode
dav
parents: 5506
diff changeset
   623
        EventQueue.invokeLater(new Runnable() {
494fbd1859a1 6709453: (dav)Screen flickers when a JFrame switches to fullscreen mode
dav
parents: 5506
diff changeset
   624
            public void run() {
494fbd1859a1 6709453: (dav)Screen flickers when a JFrame switches to fullscreen mode
dav
parents: 5506
diff changeset
   625
                w.addWindowListener(fsWindowListener);
494fbd1859a1 6709453: (dav)Screen flickers when a JFrame switches to fullscreen mode
dav
parents: 5506
diff changeset
   626
            }
494fbd1859a1 6709453: (dav)Screen flickers when a JFrame switches to fullscreen mode
dav
parents: 5506
diff changeset
   627
        });
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   628
    }
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   629
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   630
    /**
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   631
     * Removes the fs window listener.
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   632
     *
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   633
     * @param w full-screen window
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   634
     */
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   635
    protected void removeFSWindowListener(Window w) {
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   636
        w.removeWindowListener(fsWindowListener);
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 2
diff changeset
   637
        fsWindowListener = null;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
}