diff options
Diffstat (limited to 'libjava/gnu/java/awt/peer/gtk/GtkToolkit.java')
| -rw-r--r-- | libjava/gnu/java/awt/peer/gtk/GtkToolkit.java | 82 |
1 files changed, 62 insertions, 20 deletions
diff --git a/libjava/gnu/java/awt/peer/gtk/GtkToolkit.java b/libjava/gnu/java/awt/peer/gtk/GtkToolkit.java index def22e9874e..f57f53a17a7 100644 --- a/libjava/gnu/java/awt/peer/gtk/GtkToolkit.java +++ b/libjava/gnu/java/awt/peer/gtk/GtkToolkit.java @@ -51,7 +51,6 @@ import java.awt.datatransfer.Clipboard; import java.awt.dnd.DragGestureEvent; import java.awt.dnd.peer.DragSourceContextPeer; import java.awt.font.FontRenderContext; -import java.awt.font.TextAttribute; import java.awt.im.InputMethodHighlight; import java.awt.image.BufferedImage; import java.awt.image.ColorModel; @@ -59,15 +58,17 @@ import java.awt.image.ImageConsumer; import java.awt.image.ImageObserver; import java.awt.image.ImageProducer; import java.awt.peer.*; +import java.io.InputStream; import java.net.URL; import java.text.AttributedString; import java.util.HashMap; import java.util.HashSet; import java.util.Hashtable; import java.util.Iterator; +import java.util.LinkedHashMap; import java.util.Map; -import java.util.MissingResourceException; import java.util.Properties; +import javax.imageio.spi.IIORegistry; /* This class uses a deprecated method java.awt.peer.ComponentPeer.getPeer(). This merits comment. We are basically calling Sun's bluff on this one. @@ -86,9 +87,8 @@ import java.util.Properties; public class GtkToolkit extends gnu.java.awt.ClasspathToolkit implements EmbeddedWindowSupport { - GtkMainThread main; Hashtable containers = new Hashtable(); - static EventQueue q = new EventQueue(); + static EventQueue q; static Clipboard systemClipboard; static boolean useGraphics2dSet; static boolean useGraphics2d; @@ -103,19 +103,32 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit return useGraphics2d; } + static native void gtkInit(int portableNativeSync); + static { if (Configuration.INIT_LOAD_LIBRARY) System.loadLibrary("gtkpeer"); + + int portableNativeSync; + String portNatSyncProp = + System.getProperty("gnu.classpath.awt.gtk.portable.native.sync"); + + if (portNatSyncProp == null) + portableNativeSync = -1; // unset + else if (Boolean.valueOf(portNatSyncProp).booleanValue()) + portableNativeSync = 1; // true + else + portableNativeSync = 0; // false + + gtkInit(portableNativeSync); } public GtkToolkit () { - main = new GtkMainThread (); systemClipboard = new GtkClipboard (); - GtkGenericPeer.enableQueue (q); } - + native public void beep (); native private void getScreenSizeDimensions (int[] xy); @@ -313,7 +326,7 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit "SansSerif" }); } - private class LRUCache extends java.util.LinkedHashMap + private class LRUCache extends LinkedHashMap { int max_entries; public LRUCache(int max) @@ -333,15 +346,18 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit public FontMetrics getFontMetrics (Font font) { - if (metricsCache.containsKey(font)) - return (FontMetrics) metricsCache.get(font); - else + synchronized (metricsCache) + { + if (metricsCache.containsKey(font)) + return (FontMetrics) metricsCache.get(font); + } + + FontMetrics m = new GdkFontMetrics (font); + synchronized (metricsCache) { - FontMetrics m; - m = new GdkFontMetrics (font); metricsCache.put(font, m); - return m; - } + } + return m; } public Image getImage (String filename) @@ -594,6 +610,14 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit protected EventQueue getSystemEventQueueImpl() { + synchronized (GtkToolkit.class) + { + if (q == null) + { + q = new EventQueue(); + GtkGenericPeer.enableQueue (q); + } + } return q; } @@ -609,19 +633,37 @@ public class GtkToolkit extends gnu.java.awt.ClasspathToolkit throw new Error("not implemented"); } + public Rectangle getBounds() + { + int[] dims = new int[2]; + getScreenSizeDimensions(dims); + return new Rectangle(0, 0, dims[0], dims[1]); + } + // ClasspathToolkit methods public GraphicsEnvironment getLocalGraphicsEnvironment() { - GraphicsEnvironment ge; - ge = new GdkGraphicsEnvironment (); - return ge; + return new GdkGraphicsEnvironment(this); + } + + public Font createFont(int format, InputStream stream) + { + throw new UnsupportedOperationException(); + } + + public RobotPeer createRobot (GraphicsDevice screen) throws AWTException + { + return new GdkRobotPeer (screen); } - public Font createFont(int format, java.io.InputStream stream) + public void registerImageIOSpis(IIORegistry reg) { - throw new java.lang.UnsupportedOperationException (); + GdkPixbufDecoder.registerSpis(reg); } + public native boolean nativeQueueEmpty(); + public native void wakeNativeQueue(); + public native void iterateNativeQueue(EventQueue locked, boolean block); } // class GtkToolkit |

