Hi,

GtkComponentPeer had a empty getGraphicsConfiguration() which meant that
similar methods on Component and ComponentGraphics would always return
null. This prevented some applications from getting a back buffer
graphics object in some cases. I have added code to GtkComponentPeer
that returns the default screen device of the toolkit. This is still not
ideal since a component could be showing on a non-default display. But
it is much better than returning null. The FIXME has been adapted to
note that we might want to return different screen devices for each
component. The patch also unstubs the same method in
VolatileImageGraphics by recording the initiating Component of the
VolatileImage.

2006-06-15  Mark Wielaard  <[EMAIL PROTECTED]>

    * gnu/java/awt/peer/gtk/GtkComponentPeer.java
    (getGraphicsConfiguration): Return default screen device.
    * gnu/java/awt/peer/gtk/GtkVolatileImage.java (component):
    New field.
    (GtkVolatileImage): Record initiating component.
    * gnu/java/awt/peer/gtk/VolatileImageGraphics.java
    (getDeviceConfiguration): Return configuration of image component.

Committed,

Mark
Index: gnu/java/awt/peer/gtk/GtkComponentPeer.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/gtk/GtkComponentPeer.java,v
retrieving revision 1.115
diff -u -r1.115 GtkComponentPeer.java
--- gnu/java/awt/peer/gtk/GtkComponentPeer.java	4 Jun 2006 20:21:39 -0000	1.115
+++ gnu/java/awt/peer/gtk/GtkComponentPeer.java	15 Jun 2006 18:28:24 -0000
@@ -52,6 +52,8 @@
 import java.awt.FontMetrics;
 import java.awt.Graphics;
 import java.awt.GraphicsConfiguration;
+import java.awt.GraphicsDevice;
+import java.awt.GraphicsEnvironment;
 import java.awt.Image;
 import java.awt.Insets;
 import java.awt.ItemSelectable;
@@ -647,8 +649,10 @@
 
   public GraphicsConfiguration getGraphicsConfiguration ()
   {
-    // FIXME: just a stub for now.
-    return null;
+    // FIXME: The component might be showing on a non-default screen.
+    GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
+    GraphicsDevice dev = env.getDefaultScreenDevice();
+    return dev.getDefaultConfiguration();
   }
 
   public void setEventMask (long mask)
Index: gnu/java/awt/peer/gtk/GtkVolatileImage.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/gtk/GtkVolatileImage.java,v
retrieving revision 1.7
diff -u -r1.7 GtkVolatileImage.java
--- gnu/java/awt/peer/gtk/GtkVolatileImage.java	10 Jun 2006 10:33:18 -0000	1.7
+++ gnu/java/awt/peer/gtk/GtkVolatileImage.java	15 Jun 2006 18:28:24 -0000
@@ -50,6 +50,8 @@
   int width, height;
   private ImageCapabilities caps;
 
+  final GtkComponentPeer component;
+
   /**
    * Don't touch, accessed from native code.
    */
@@ -85,6 +87,7 @@
     this.width = width;
     this.height = height;
     this.caps = caps;
+    this.component = component;
     nativePointer = init( component, width, height );
   }
 
Index: gnu/java/awt/peer/gtk/VolatileImageGraphics.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/gtk/VolatileImageGraphics.java,v
retrieving revision 1.5
diff -u -r1.5 VolatileImageGraphics.java
--- gnu/java/awt/peer/gtk/VolatileImageGraphics.java	12 Jun 2006 21:10:11 -0000	1.5
+++ gnu/java/awt/peer/gtk/VolatileImageGraphics.java	15 Jun 2006 18:28:24 -0000
@@ -83,7 +83,7 @@
 
   public GraphicsConfiguration getDeviceConfiguration()
   {
-    return null;
+    return owner.component.getGraphicsConfiguration();
   }
 
   public Graphics create()

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to