jdk/src/solaris/classes/sun/awt/X11GraphicsDevice.java
author xdono
Wed, 02 Jul 2008 12:55:45 -0700
changeset 715 f16baef3a20e
parent 438 2ae294e4518c
child 889 6549643c008c
permissions -rw-r--r--
6719955: Update copyright year Summary: Update copyright year for files that have been modified in 2008 Reviewed-by: ohair, tbell
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
715
f16baef3a20e 6719955: Update copyright year
xdono
parents: 438
diff changeset
     2
 * Copyright 1997-2008 Sun Microsystems, Inc.  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
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
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
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
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.DisplayMode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.awt.GraphicsEnvironment;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.awt.GraphicsDevice;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.awt.GraphicsConfiguration;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
import java.awt.Rectangle;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.awt.Window;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
import java.util.ArrayList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.util.HashSet;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.util.HashMap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import sun.java2d.opengl.GLXGraphicsConfig;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import sun.java2d.loops.SurfaceType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
 * This is an implementation of a GraphicsDevice object for a single
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
 * X11 screen.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
 * @see GraphicsEnvironment
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
 * @see GraphicsConfiguration
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
public class X11GraphicsDevice
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    extends GraphicsDevice
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    implements DisplayChangedListener
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    int screen;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    HashMap x11ProxyKeyMap = new HashMap();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    private static AWTPermission fullScreenExclusivePermission;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    private static Boolean xrandrExtSupported;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    private final Object configLock = new Object();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    private SunDisplayChanger topLevels = new SunDisplayChanger();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    private DisplayMode origDisplayMode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    private boolean shutdownHookRegistered;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
    public X11GraphicsDevice(int screennum) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
        this.screen = screennum;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
     * Initialize JNI field and method IDs for fields that may be
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
     * accessed from C.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    private static native void initIDs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    static {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
        if (!GraphicsEnvironment.isHeadless()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
            initIDs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
     * Returns the X11 screen of the device.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    public int getScreen() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        return screen;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    public Object getProxyKeyFor(SurfaceType st) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
        synchronized (x11ProxyKeyMap) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
            Object o = x11ProxyKeyMap.get(st);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
            if (o == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
                o = new Object();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
                x11ProxyKeyMap.put(st, o);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
            return o;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
     * Returns the X11 Display of this device.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
     * This method is also in MDrawingSurfaceInfo but need it here
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
     * to be able to allow a GraphicsConfigTemplate to get the Display.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    public native long getDisplay();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
     * Returns the type of the graphics device.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
     * @see #TYPE_RASTER_SCREEN
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
     * @see #TYPE_PRINTER
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
     * @see #TYPE_IMAGE_BUFFER
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    public int getType() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        return TYPE_RASTER_SCREEN;
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 identification string associated with this graphics
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
     * device.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    public String getIDstring() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
        return ":0."+screen;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    GraphicsConfiguration[] configs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    GraphicsConfiguration defaultConfig;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    HashSet doubleBufferVisuals;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
     * Returns all of the graphics
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
     * configurations associated with this graphics device.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    public GraphicsConfiguration[] getConfigurations() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        if (configs == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
            synchronized (configLock) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                makeConfigurations();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        return configs;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    private void makeConfigurations() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
        if (configs == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
            int i = 1;  // Index 0 is always the default config
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
            int num = getNumConfigs(screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
            GraphicsConfiguration[] ret = new GraphicsConfiguration[num];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
            if (defaultConfig == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
                ret [0] = getDefaultConfiguration();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
            else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
                ret [0] = defaultConfig;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
            boolean glxSupported = X11GraphicsEnvironment.isGLXAvailable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
            boolean dbeSupported = isDBESupported();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
            if (dbeSupported && doubleBufferVisuals == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
                doubleBufferVisuals = new HashSet();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
                getDoubleBufferVisuals(screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
            for ( ; i < num; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
                int visNum = getConfigVisualId(i, screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
                int depth = getConfigDepth (i, screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
                if (glxSupported) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
                    ret[i] = GLXGraphicsConfig.getConfig(this, visNum);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
                if (ret[i] == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
                    boolean doubleBuffer =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
                        (dbeSupported &&
438
2ae294e4518c 6613529: Avoid duplicate object creation within JDK packages
dav
parents: 2
diff changeset
   167
                         doubleBufferVisuals.contains(Integer.valueOf(visNum)));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
                    ret[i] = X11GraphicsConfig.getConfig(this, visNum, depth,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
                            getConfigColormap(i, screen),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
                            doubleBuffer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
            configs = ret;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
     * Returns the number of X11 visuals representable as an
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
     * X11GraphicsConfig object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
    public native int getNumConfigs(int screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
     * Returns the visualid for the given index of graphics configurations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    public native int getConfigVisualId (int index, int screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
     * Returns the depth for the given index of graphics configurations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
    public native int getConfigDepth (int index, int screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
     * Returns the colormap for the given index of graphics configurations.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    public native int getConfigColormap (int index, int screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    // Whether or not double-buffering extension is supported
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
    public static native boolean isDBESupported();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    // Callback for adding a new double buffer visual into our set
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
    private void addDoubleBufferVisual(int visNum) {
438
2ae294e4518c 6613529: Avoid duplicate object creation within JDK packages
dav
parents: 2
diff changeset
   202
        doubleBufferVisuals.add(Integer.valueOf(visNum));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    // Enumerates all visuals that support double buffering
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
    private native void getDoubleBufferVisuals(int screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
     * Returns the default graphics configuration
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
     * associated with this graphics device.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    public GraphicsConfiguration getDefaultConfiguration() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        if (defaultConfig == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
            synchronized (configLock) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
                makeDefaultConfiguration();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        return defaultConfig;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    private void makeDefaultConfiguration() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        if (defaultConfig == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
            int visNum = getConfigVisualId(0, screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
            if (X11GraphicsEnvironment.isGLXAvailable()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
                defaultConfig = GLXGraphicsConfig.getConfig(this, visNum);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                if (X11GraphicsEnvironment.isGLXVerbose()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
                    if (defaultConfig != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
                        System.out.print("OpenGL pipeline enabled");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
                        System.out.print("Could not enable OpenGL pipeline");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
                    System.out.println(" for default config on screen " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
                                       screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
            if (defaultConfig == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
                int depth = getConfigDepth(0, screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
                boolean doubleBuffer = false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
                if (isDBESupported() && doubleBufferVisuals == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
                    doubleBufferVisuals = new HashSet();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
                    getDoubleBufferVisuals(screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
                    doubleBuffer =
438
2ae294e4518c 6613529: Avoid duplicate object creation within JDK packages
dav
parents: 2
diff changeset
   242
                        doubleBufferVisuals.contains(Integer.valueOf(visNum));
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
                defaultConfig = X11GraphicsConfig.getConfig(this, visNum,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
                                                            depth, getConfigColormap(0, screen),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
                                                            doubleBuffer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    private static native void enterFullScreenExclusive(long window);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
    private static native void exitFullScreenExclusive(long window);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    private static native boolean initXrandrExtension();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
    private static native DisplayMode getCurrentDisplayMode(int screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    private static native void enumDisplayModes(int screen,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
                                                ArrayList<DisplayMode> modes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    private static native void configDisplayMode(int screen,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
                                                 int width, int height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
                                                 int displayMode);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    private static native void resetNativeData(int screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
     * Returns true only if:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
     *   - the Xrandr extension is present
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
     *   - the necessary Xrandr functions were loaded successfully
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
     *   - XINERAMA is not enabled
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    private static synchronized boolean isXrandrExtensionSupported() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
        if (xrandrExtSupported == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
            xrandrExtSupported =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
                Boolean.valueOf(initXrandrExtension());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
        return xrandrExtSupported.booleanValue();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
    @Override
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
    public boolean isFullScreenSupported() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
        // REMIND: for now we will only allow fullscreen exclusive mode
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
        // on the primary screen; we could change this behavior slightly
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
        // in the future by allowing only one screen to be in fullscreen
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
        // exclusive mode at any given time...
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        boolean fsAvailable = (screen == 0) && isXrandrExtensionSupported();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
        if (fsAvailable) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
            SecurityManager security = System.getSecurityManager();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
            if (security != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
                if (fullScreenExclusivePermission == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
                    fullScreenExclusivePermission =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
                        new AWTPermission("fullScreenExclusive");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
                    security.checkPermission(fullScreenExclusivePermission);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
                } catch (SecurityException e) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
                    return false;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
        return fsAvailable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
    @Override
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
    public boolean isDisplayChangeSupported() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
        return (isFullScreenSupported() && (getFullScreenWindow() != null));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
    private static void enterFullScreenExclusive(Window w) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
        X11ComponentPeer peer = (X11ComponentPeer)w.getPeer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
        if (peer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
            enterFullScreenExclusive(peer.getContentWindow());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
    private static void exitFullScreenExclusive(Window w) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
        X11ComponentPeer peer = (X11ComponentPeer)w.getPeer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
        if (peer != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
            exitFullScreenExclusive(peer.getContentWindow());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
    @Override
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
    public synchronized void setFullScreenWindow(Window w) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
        Window old = getFullScreenWindow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
        if (w == old) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
        boolean fsSupported = isFullScreenSupported();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
        if (fsSupported && old != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
            // enter windowed mode (and restore original display mode)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
            exitFullScreenExclusive(old);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
            setDisplayMode(origDisplayMode);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
        super.setFullScreenWindow(w);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
        if (fsSupported && w != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
            // save original display mode
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
            if (origDisplayMode == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
                origDisplayMode = getDisplayMode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
            // enter fullscreen mode
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
            enterFullScreenExclusive(w);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
    private DisplayMode getDefaultDisplayMode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
        GraphicsConfiguration gc = getDefaultConfiguration();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
        Rectangle r = gc.getBounds();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
        return new DisplayMode(r.width, r.height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
                               DisplayMode.BIT_DEPTH_MULTI,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
                               DisplayMode.REFRESH_RATE_UNKNOWN);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
    @Override
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
    public synchronized DisplayMode getDisplayMode() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
        if (isFullScreenSupported()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
            return getCurrentDisplayMode(screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
        } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
            if (origDisplayMode == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
                origDisplayMode = getDefaultDisplayMode();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
            return origDisplayMode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
    @Override
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
    public synchronized DisplayMode[] getDisplayModes() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
        if (!isFullScreenSupported()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
            return super.getDisplayModes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
        ArrayList<DisplayMode> modes = new ArrayList<DisplayMode>();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
        enumDisplayModes(screen, modes);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
        DisplayMode[] retArray = new DisplayMode[modes.size()];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
        return modes.toArray(retArray);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
    @Override
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
    public synchronized void setDisplayMode(DisplayMode dm) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
        if (!isDisplayChangeSupported()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
            super.setDisplayMode(dm);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
            return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
        Window w = getFullScreenWindow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
        if (w == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
            throw new IllegalStateException("Must be in fullscreen mode " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
                                            "in order to set display mode");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
        if (dm == null ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
            (dm = getMatchingDisplayMode(dm)) == null)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
            throw new IllegalArgumentException("Invalid display mode");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
        if (!shutdownHookRegistered) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
            // register a shutdown hook so that we return to the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
            // original DisplayMode when the VM exits (if the application
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
            // is already in the original DisplayMode at that time, this
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
            // hook will have no effect)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
            shutdownHookRegistered = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
            Runnable r = new Runnable() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
                public void run() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
                    Window old = getFullScreenWindow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
                    if (old != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
                        exitFullScreenExclusive(old);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
                        setDisplayMode(origDisplayMode);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
            };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
            Thread t = new Thread(r,"Display-Change-Shutdown-Thread-"+screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
            Runtime.getRuntime().addShutdownHook(t);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
        // switch to the new DisplayMode
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
        configDisplayMode(screen,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
                          dm.getWidth(), dm.getHeight(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
                          dm.getRefreshRate());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
        // update bounds of the fullscreen window
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
        w.setBounds(0, 0, dm.getWidth(), dm.getHeight());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
        // configDisplayMode() is synchronous, so the display change will be
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
        // complete by the time we get here (and it is therefore safe to call
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
        // displayChanged() now)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
        ((X11GraphicsEnvironment)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
         GraphicsEnvironment.getLocalGraphicsEnvironment()).displayChanged();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
    private synchronized DisplayMode getMatchingDisplayMode(DisplayMode dm) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
        if (!isDisplayChangeSupported()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
            return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
        DisplayMode[] modes = getDisplayModes();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
        for (DisplayMode mode : modes) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
            if (dm.equals(mode) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
                (dm.getRefreshRate() == DisplayMode.REFRESH_RATE_UNKNOWN &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
                 dm.getWidth() == mode.getWidth() &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
                 dm.getHeight() == mode.getHeight() &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
                 dm.getBitDepth() == mode.getBitDepth()))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
                return mode;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
        return null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
     * From the DisplayChangedListener interface; called from
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
     * X11GraphicsEnvironment when the display mode has been changed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
    public synchronized void displayChanged() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
        // reset the list of configs (and default config)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
        defaultConfig = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
        configs = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
        doubleBufferVisuals = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
        // reset the native data structures associated with this device (they
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
        // will be reinitialized when the GraphicsConfigs are configured)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
        resetNativeData(screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
        // pass on to all top-level windows on this screen
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
        topLevels.notifyListeners();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
     * From the DisplayChangedListener interface; devices do not need
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
     * to react to this event.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
    public void paletteChanged() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
     * Add a DisplayChangeListener to be notified when the display settings
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
     * are changed.  Typically, only top-level containers need to be added
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
     * to X11GraphicsDevice.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
    public void addDisplayChangedListener(DisplayChangedListener client) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
        topLevels.add(client);
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
     * Remove a DisplayChangeListener from this X11GraphicsDevice.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
    public void removeDisplayChangedListener(DisplayChangedListener client) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
        topLevels.remove(client);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
    public String toString() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
        return ("X11GraphicsDevice[screen="+screen+"]");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
}