< prev index next >

src/java.desktop/macosx/classes/sun/awt/CGraphicsEnvironment.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -77,10 +77,14 @@
      */
     private native void deregisterDisplayReconfiguration(long context);
 
     /** Available CoreGraphics displays. */
     private final Map<Integer, CGraphicsDevice> devices = new HashMap<>(5);
+    /**
+     * The key in the {@link #devices} for the main display.
+     */
+    private int mainDisplayID;
 
     /** Reference to the display reconfiguration callback context. */
     private final long displayReconfigContext;
 
     /**

@@ -134,19 +138,19 @@
     private void initDevices() {
         synchronized (this) {
             final Map<Integer, CGraphicsDevice> old = new HashMap<>(devices);
             devices.clear();
 
-            int mainID = getMainDisplayID();
+            mainDisplayID = getMainDisplayID();
 
             // initialization of the graphics device may change
             // list of displays on hybrid systems via an activation
             // of discrete video.
             // So, we initialize the main display first, and then
             // retrieve actual list of displays.
-            if (!old.containsKey(mainID)) {
-                old.put(mainID, new CGraphicsDevice(mainID));
+            if (!old.containsKey(mainDisplayID)) {
+                old.put(mainDisplayID, new CGraphicsDevice(mainDisplayID));
             }
 
             for (final int id : getDisplayIDs()) {
                 devices.put(id, old.containsKey(id) ? old.get(id)
                                                     : new CGraphicsDevice(id));

@@ -155,11 +159,10 @@
         displayChanged();
     }
 
     @Override
     public synchronized GraphicsDevice getDefaultScreenDevice() throws HeadlessException {
-        final int mainDisplayID = getMainDisplayID();
         CGraphicsDevice d = devices.get(mainDisplayID);
         if (d == null) {
             // we do not expect that this may happen, the only response
             // is to re-initialize the list of devices
             initDevices();
< prev index next >