8134669: Empty screen insets in Gnome 3, OEL 7 in multiscreen mode
authorssadetsky
Thu, 24 Mar 2016 20:28:53 +0300
changeset 36912 fe8c68b091aa
parent 36911 81adb67ad4ba
child 36913 bac425909021
8134669: Empty screen insets in Gnome 3, OEL 7 in multiscreen mode Reviewed-by: alexsch
jdk/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java
--- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java	Thu Mar 24 20:19:26 2016 +0300
+++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java	Thu Mar 24 20:28:53 2016 +0300
@@ -770,17 +770,20 @@
                 GraphicsEnvironment.getLocalGraphicsEnvironment();
             if (!x11ge.runningXinerama())
             {
-                Rectangle workArea = XToolkit.getWorkArea(root, scale);
-                if (workArea != null)
-                {
-                    return new Insets(workArea.y,
-                                      workArea.x,
-                                      rootBounds.height - workArea.height - workArea.y,
-                                      rootBounds.width - workArea.width - workArea.x);
-                }
+                Insets screenInsets = getInsets(root, rootBounds, scale);
+                if (screenInsets != null) return screenInsets;
             }
 
-            return getScreenInsetsManually(root, rootBounds, gc.getBounds(), scale);
+            Insets insets = getScreenInsetsManually(root, rootBounds,
+                    gc.getBounds(), scale);
+            if ((insets.left | insets.top | insets.bottom | insets.right) == 0
+                    && rootBounds != null ) {
+                root = XlibWrapper.RootWindow(XToolkit.getDisplay(),
+                        x11gd.getScreen());
+                Insets screenInsets = getInsets(root, rootBounds, scale);
+                if (screenInsets != null) return screenInsets;
+            }
+            return insets;
         }
         finally
         {
@@ -788,6 +791,16 @@
         }
     }
 
+    private Insets getInsets(long root, Rectangle rootBounds, int scale) {
+        Rectangle workArea = XToolkit.getWorkArea(root, scale);
+        if (workArea == null) {
+            return null;
+        }
+        return new Insets(workArea.y, workArea.x,
+                rootBounds.height - workArea.height - workArea.y,
+                rootBounds.width - workArea.width - workArea.x);
+    }
+
     /*
      * Manual calculation of screen insets: get all the windows with
      * _NET_WM_STRUT/_NET_WM_STRUT_PARTIAL hints and add these