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
23 * questions.
24 */
25 package sun.awt;
26
27 import java.awt.RenderingHints;
28 import static java.awt.RenderingHints.*;
29 import java.awt.color.ColorSpace;
30 import java.awt.image.*;
31 import java.security.AccessController;
32 import sun.security.action.GetIntegerAction;
33 import com.sun.java.swing.plaf.gtk.GTKConstants.TextDirection;
34 import sun.awt.X11.XToolkit;
35 import sun.java2d.opengl.OGLRenderQueue;
36
37 public abstract class UNIXToolkit extends SunToolkit
38 {
39 /** All calls into GTK should be synchronized on this lock */
40 public static final Object GTK_LOCK = new Object();
41
42 private static final int[] BAND_OFFSETS = { 0, 1, 2 };
43 private static final int[] BAND_OFFSETS_ALPHA = { 0, 1, 2, 3 };
44 private static final int DEFAULT_DATATRANSFER_TIMEOUT = 10000;
45
46 private Boolean nativeGTKAvailable;
47 private Boolean nativeGTKLoaded;
48 private BufferedImage tmpImage = null;
49
50 public static int getDatatransferTimeout() {
51 Integer dt = AccessController.doPrivileged(
52 new GetIntegerAction("sun.awt.datatransfer.timeout"));
53 if (dt == null || dt <= 0) {
54 return DEFAULT_DATATRANSFER_TIMEOUT;
81
82 } else {
83 boolean success = check_gtk();
84 nativeGTKAvailable = success;
85 return success;
86 }
87 }
88 }
89
90 /**
91 * Loads the GTK libraries, if necessary. The first time this method
92 * is called, it will attempt to load the native GTK library. If
93 * successful, it leaves the library open and returns true; otherwise,
94 * the library is left closed and returns false. On future calls to
95 * this method, the status of the first attempt is returned (a simple
96 * lightweight boolean check, no native calls required).
97 */
98 public boolean loadGTK() {
99 synchronized (GTK_LOCK) {
100 if (nativeGTKLoaded == null) {
101 XToolkit.awtLock();
102 try {
103 nativeGTKLoaded = load_gtk();
104 } finally {
105 XToolkit.awtUnlock();
106 }
107 }
108 }
109 return nativeGTKLoaded;
110 }
111
112 /**
113 * Overridden to handle GTK icon loading
114 */
115 protected Object lazilyLoadDesktopProperty(String name) {
116 if (name.startsWith("gtk.icon.")) {
117 return lazilyLoadGTKIcon(name);
118 }
119 return super.lazilyLoadDesktopProperty(name);
120 }
121
122 /**
123 * Load a native Gtk stock icon.
124 *
125 * @param longname a desktop property name. This contains icon name, size
126 * and orientation, e.g. <code>"gtk.icon.gtk-add.4.rtl"</code>
|
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
23 * questions.
24 */
25 package sun.awt;
26
27 import java.awt.RenderingHints;
28 import static java.awt.RenderingHints.*;
29 import java.awt.color.ColorSpace;
30 import java.awt.image.*;
31 import java.security.AccessController;
32 import sun.security.action.GetIntegerAction;
33 import com.sun.java.swing.plaf.gtk.GTKConstants.TextDirection;
34 import sun.java2d.opengl.OGLRenderQueue;
35
36 public abstract class UNIXToolkit extends SunToolkit
37 {
38 /** All calls into GTK should be synchronized on this lock */
39 public static final Object GTK_LOCK = new Object();
40
41 private static final int[] BAND_OFFSETS = { 0, 1, 2 };
42 private static final int[] BAND_OFFSETS_ALPHA = { 0, 1, 2, 3 };
43 private static final int DEFAULT_DATATRANSFER_TIMEOUT = 10000;
44
45 private Boolean nativeGTKAvailable;
46 private Boolean nativeGTKLoaded;
47 private BufferedImage tmpImage = null;
48
49 public static int getDatatransferTimeout() {
50 Integer dt = AccessController.doPrivileged(
51 new GetIntegerAction("sun.awt.datatransfer.timeout"));
52 if (dt == null || dt <= 0) {
53 return DEFAULT_DATATRANSFER_TIMEOUT;
80
81 } else {
82 boolean success = check_gtk();
83 nativeGTKAvailable = success;
84 return success;
85 }
86 }
87 }
88
89 /**
90 * Loads the GTK libraries, if necessary. The first time this method
91 * is called, it will attempt to load the native GTK library. If
92 * successful, it leaves the library open and returns true; otherwise,
93 * the library is left closed and returns false. On future calls to
94 * this method, the status of the first attempt is returned (a simple
95 * lightweight boolean check, no native calls required).
96 */
97 public boolean loadGTK() {
98 synchronized (GTK_LOCK) {
99 if (nativeGTKLoaded == null) {
100 nativeGTKLoaded = load_gtk();
101 }
102 }
103 return nativeGTKLoaded;
104 }
105
106 /**
107 * Overridden to handle GTK icon loading
108 */
109 protected Object lazilyLoadDesktopProperty(String name) {
110 if (name.startsWith("gtk.icon.")) {
111 return lazilyLoadGTKIcon(name);
112 }
113 return super.lazilyLoadDesktopProperty(name);
114 }
115
116 /**
117 * Load a native Gtk stock icon.
118 *
119 * @param longname a desktop property name. This contains icon name, size
120 * and orientation, e.g. <code>"gtk.icon.gtk-add.4.rtl"</code>
|