< prev index next >

modules/javafx.graphics/src/main/java/com/sun/glass/ui/gtk/GtkApplication.java

Print this page

        

*** 43,52 **** --- 43,53 ---- import java.nio.IntBuffer; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.Map; import java.util.concurrent.CountDownLatch; + import java.lang.annotation.Native; final class GtkApplication extends Application implements InvokeLaterDispatcher.InvokeLaterSubmitter { static { AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
*** 86,106 **** return val; } GtkApplication() { - // Check whether the Display is valid and throw an exception if not. - // We use UnsupportedOperationException rather than HeadlessException - // so as not to introduce a dependency on AWT. - if (!isDisplayValid()) { - throw new UnsupportedOperationException("Unable to open DISPLAY"); - } - int gtkVersion = AccessController.doPrivileged((PrivilegedAction<Integer>) () -> { String v = System.getProperty("jdk.gtk.version","2"); ! int ret = 0; if ("3".equals(v) || v.startsWith("3.")) { ret = 3; } else if ("2".equals(v) || v.startsWith("2.")) { ret = 2; } --- 87,100 ---- return val; } GtkApplication() { int gtkVersion = AccessController.doPrivileged((PrivilegedAction<Integer>) () -> { String v = System.getProperty("jdk.gtk.version","2"); ! int ret = 0; // start with "no preference if ("3".equals(v) || v.startsWith("3.")) { ret = 3; } else if ("2".equals(v) || v.startsWith("2.")) { ret = 2; }
*** 114,123 **** --- 108,137 ---- overrideUIScale = AccessController.doPrivileged((PrivilegedAction<Float>) () -> getFloat("glass.gtk.uiScale", -1.0f, "Forcing UI scaling factor: ")); } else { overrideUIScale = -1.0f; } + + int libraryToLoad = _queryLibrary(gtkVersion, gtkVersionVerbose); + + if (libraryToLoad == QUERY_NO_DISPLAY) { + throw new UnsupportedOperationException("Unable to open DISPLAY"); + } else if (libraryToLoad == QUERY_USE_CURRENT) { + if (gtkVersionVerbose) + System.out.println("Glass GTK library to load is already loaded"); + } else if (libraryToLoad == QUERY_LOAD_GTK2) { + if (gtkVersionVerbose) + System.out.println("Glass GTK library to load is glassgtk2"); + com.sun.glass.utils.NativeLibLoader.loadLibrary("glassgtk2"); + } else if (libraryToLoad == QUERY_LOAD_GTK3) { + if (gtkVersionVerbose) + System.out.println("Glass GTK library to load is glassgtk3"); + com.sun.glass.utils.NativeLibLoader.loadLibrary("glassgtk3"); + } else { + throw new UnsupportedOperationException("Internal Error"); + } + int version = _initGTK(gtkVersion, gtkVersionVerbose, overrideUIScale); if (version == -1) { throw new RuntimeException("Error loading GTK libraries"); }
*** 131,145 **** } else { invokeLaterDispatcher = null; } } ! private static native int _initGTK(int version, boolean verbose, float overrideUIScale); ! private static boolean isDisplayValid() { ! return _isDisplayValid(); ! } private void initDisplay() { Map ds = getDeviceDetails(); if (ds != null) { Object value; --- 145,166 ---- } else { invokeLaterDispatcher = null; } } ! @Native private static final int QUERY_ERROR = -2; ! @Native private static final int QUERY_NO_DISPLAY = -1; ! @Native private static final int QUERY_USE_CURRENT = 1; ! @Native private static final int QUERY_LOAD_GTK2 = 2; ! @Native private static final int QUERY_LOAD_GTK3 = 3; ! /* ! * check the system and return an indication of which library to load ! * return values are the QUERY_ constants ! */ ! private static native int _queryLibrary(int version, boolean verbose); ! private static native int _initGTK(int version, boolean verbose, float overrideUIScale); private void initDisplay() { Map ds = getDeviceDetails(); if (ds != null) { Object value;
*** 210,221 **** @Override public boolean shouldUpdateWindow() { return true; } - private static native boolean _isDisplayValid(); - private native void _terminateLoop(); private native void _init(long eventProc, boolean disableGrab); private native void _runLoop(Runnable launchable, boolean noErrorTrap); --- 231,240 ----
< prev index next >