--- old/src/java.desktop/unix/classes/sun/awt/UNIXToolkit.java 2016-03-18 09:05:34.586985317 +0300 +++ new/src/java.desktop/unix/classes/sun/awt/UNIXToolkit.java 2016-03-18 09:05:34.450985321 +0300 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2016, 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 @@ -29,9 +29,12 @@ import java.awt.color.ColorSpace; import java.awt.image.*; import java.security.AccessController; +import java.security.PrivilegedAction; + import sun.security.action.GetIntegerAction; import com.sun.java.swing.plaf.gtk.GTKConstants.TextDirection; import sun.java2d.opengl.OGLRenderQueue; +import sun.security.action.GetPropertyAction; public abstract class UNIXToolkit extends SunToolkit { @@ -42,6 +45,8 @@ private static final int[] BAND_OFFSETS_ALPHA = { 0, 1, 2, 3 }; private static final int DEFAULT_DATATRANSFER_TIMEOUT = 10000; + public enum GtkVersions {ANY, GTK1, GTK2, GTK3}; + private Boolean nativeGTKAvailable; private Boolean nativeGTKLoaded; private BufferedImage tmpImage = null; @@ -79,7 +84,7 @@ return nativeGTKAvailable; } else { - boolean success = check_gtk(); + boolean success = check_gtk(getEnabledGtkVersion().ordinal()); nativeGTKAvailable = success; return success; } @@ -97,7 +102,8 @@ public boolean loadGTK() { synchronized (GTK_LOCK) { if (nativeGTKLoaded == null) { - nativeGTKLoaded = load_gtk(); + nativeGTKLoaded = load_gtk(getEnabledGtkVersion().ordinal(), + isGtkVerbose()); } } return nativeGTKLoaded; @@ -241,14 +247,15 @@ tmpImage = new BufferedImage(colorModel, raster, false, null); } - private static native boolean check_gtk(); - private static native boolean load_gtk(); + private static native boolean check_gtk(int version); + private static native boolean load_gtk(int version, boolean verbose); private static native boolean unload_gtk(); private native boolean load_gtk_icon(String filename); private native boolean load_stock_icon(int widget_type, String stock_id, int iconSize, int textDirection, String detail); private native void nativeSync(); + private static native int get_gtk_version(); @Override public void sync() { @@ -338,4 +345,26 @@ } return false; } + + public static GtkVersions getEnabledGtkVersion() { + String version = AccessController.doPrivileged( + new GetPropertyAction("jdk.gtk.version")); + if (version == null) { + return GtkVersions.ANY; + } else if (version.startsWith("2")) { + return GtkVersions.GTK2; + } else if("3".equals(version) ){ + return GtkVersions.GTK3; + } + return GtkVersions.ANY; + } + + public static GtkVersions getGtkVersion() { + return GtkVersions.values()[get_gtk_version()]; + } + + public static boolean isGtkVerbose() { + return AccessController.doPrivileged((PrivilegedAction)() + -> Boolean.getBoolean("jdk.gtk.verbose")); + } }