< prev index next >

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

Print this page
rev 10880 : 8198654: Switch FX's default GTK version to 3
Reviewed-by:
   1 /*
   2  * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 129         }
 130         str = str.trim();
 131         float val;
 132         if (str.endsWith("%")) {
 133             val = Integer.parseInt(str.substring(0, str.length()-1)) / 100.0f;
 134         } else if (str.endsWith("DPI") || str.endsWith("dpi")) {
 135             val = Integer.parseInt(str.substring(0, str.length()-3)) / 96.0f;
 136         } else {
 137             val = Float.parseFloat(str);
 138         }
 139         if (PrismSettings.verbose) {
 140             System.out.println(description+val);
 141         }
 142         return val;
 143     }
 144 
 145     GtkApplication() {
 146 
 147         final int gtkVersion = forcedGtkVersion == 0 ?
 148             AccessController.doPrivileged((PrivilegedAction<Integer>) () -> {
 149                 String v = System.getProperty("jdk.gtk.version","2");
 150                 int ret = 0;
 151                 if ("3".equals(v) || v.startsWith("3.")) {
 152                     ret = 3;
 153                 } else if ("2".equals(v) || v.startsWith("2.")) {
 154                     ret = 2;
 155                 }
 156                 return ret;
 157             }) : forcedGtkVersion;
 158         boolean gtkVersionVerbose =
 159                 AccessController.doPrivileged((PrivilegedAction<Boolean>) () -> {
 160             return Boolean.getBoolean("jdk.gtk.verbose");
 161         });
 162         if (PrismSettings.allowHiDPIScaling) {
 163             overrideUIScale = AccessController.doPrivileged((PrivilegedAction<Float>) () ->
 164                     getFloat("glass.gtk.uiScale", -1.0f, "Forcing UI scaling factor: "));
 165         } else {
 166             overrideUIScale = -1.0f;
 167         }
 168 
 169         int libraryToLoad = _queryLibrary(gtkVersion, gtkVersionVerbose);


   1 /*
   2  * Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 129         }
 130         str = str.trim();
 131         float val;
 132         if (str.endsWith("%")) {
 133             val = Integer.parseInt(str.substring(0, str.length()-1)) / 100.0f;
 134         } else if (str.endsWith("DPI") || str.endsWith("dpi")) {
 135             val = Integer.parseInt(str.substring(0, str.length()-3)) / 96.0f;
 136         } else {
 137             val = Float.parseFloat(str);
 138         }
 139         if (PrismSettings.verbose) {
 140             System.out.println(description+val);
 141         }
 142         return val;
 143     }
 144 
 145     GtkApplication() {
 146 
 147         final int gtkVersion = forcedGtkVersion == 0 ?
 148             AccessController.doPrivileged((PrivilegedAction<Integer>) () -> {
 149                 String v = System.getProperty("jdk.gtk.version","3");
 150                 int ret = 0;
 151                 if ("3".equals(v) || v.startsWith("3.")) {
 152                     ret = 3;
 153                 } else if ("2".equals(v) || v.startsWith("2.")) {
 154                     ret = 2;
 155                 }
 156                 return ret;
 157             }) : forcedGtkVersion;
 158         boolean gtkVersionVerbose =
 159                 AccessController.doPrivileged((PrivilegedAction<Boolean>) () -> {
 160             return Boolean.getBoolean("jdk.gtk.verbose");
 161         });
 162         if (PrismSettings.allowHiDPIScaling) {
 163             overrideUIScale = AccessController.doPrivileged((PrivilegedAction<Float>) () ->
 164                     getFloat("glass.gtk.uiScale", -1.0f, "Forcing UI scaling factor: "));
 165         } else {
 166             overrideUIScale = -1.0f;
 167         }
 168 
 169         int libraryToLoad = _queryLibrary(gtkVersion, gtkVersionVerbose);


< prev index next >