On Tue, 2006-02-21 at 12:19 -0500, Scott Gilbertson wrote: 
> I wonder if you could have a look at this change, half of which I claim is
> related:
> http://developer.classpath.org/pipermail/classpath/2006-February/000157.html

Attached is a newly updated patch to incorporate Scott's patch, Mark
approved this on the Classpath mailing list.

This patch includes the renaming of the lightweight peer classes that
Tom suggested.

I, also, fixed up LightweightComponentPeer to only implement
ComponentPeer and GtkLightweightContainerPeer to only implement
ContainerPeer.

Here is an updated ChangeLog entry:


2006-02-21  Lillian Angel  <[EMAIL PROTECTED]>

        * gnu/java/awt/peer/gtk/GtkLightweightContainerPeer.java:
        New class to handle Container Lightweights. This class
        implements ContainerPeer.
        * gnu/java/awt/peer/gtk/GtkToolkit.java:
        Fixed imports.
        (createComponent): New method to override Toolkit's
        createComponent. Returns an instance of GtkLightweightPeer
        if the target is a container, and a LightweightComponentPeer if 
        the target is a Component.
        * include/Makefile.am:
        Added gnu_java_awt_peer_gtk_GtkLightweightContainerPeer.h.
        * include/gnu_java_awt_peer_gtk_GtkLightweightContainterPeer.h:
        New header file.
        * java/awt/Toolkit.java
        (createComponent): Changed to return null. This method
        should be overridden. Added comment explaining why.
        * native/jni/gtk-peer/Makefile.am:
        Added gnu_java_awt_peer_gtk_GtkLightweightContainerPeer.c.
        * native/jni/gtk-peer/gnu_java_awt_peer_gtk_
        GtkLightweightContainerPeer.c: New class.
        * gnu/java/awt/peer/GLightweightPeer.java:
        Removed class, replaced with LightweightComponentPeer.
        * gnu/java/awt/peer/LightweightComponentPeer.java:
        New class. Replaces GLightweightPeer, but only implements
        ComponentPeer now. Updated comments.
        (repaint): Incorporate Scott's patch. Sends event to parent 
        using tm, not 0.
        * gnu/java/awt/peer/gtk/GtkComponentPeer.java
        (setParent): Removed check for LightweightPeer. The parent
        should be set for all components.
        (setBounds): Removed code for lightweights. The placement
        of the lightweight containers is now handled by
        GtkLightweightContainerPeer.
        * gnu/java/awt/peer/gtk/GtkContainerPeer.java
        (endValidate): Removed comment.
        * java/awt/Graphics.java
        (hitClip): Incorporates Scott's patch to handle null clip.

Index: gnu/java/awt/peer/GLightweightPeer.java
===================================================================
RCS file: gnu/java/awt/peer/GLightweightPeer.java
diff -N gnu/java/awt/peer/GLightweightPeer.java
--- gnu/java/awt/peer/GLightweightPeer.java	19 Aug 2005 01:29:26 -0000	1.6
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,339 +0,0 @@
-/* GLightweightPeer.java --
-   Copyright (C) 2003, 2004 Free Software Foundation, Inc.
-
-This file is part of GNU Classpath.
-
-GNU Classpath is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU Classpath is distributed in the hope that it will be useful, but
-WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with GNU Classpath; see the file COPYING.  If not, write to the
-Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 USA.
-
-Linking this library statically or dynamically with other modules is
-making a combined work based on this library.  Thus, the terms and
-conditions of the GNU General Public License cover the whole
-combination.
-
-As a special exception, the copyright holders of this library give you
-permission to link this library with independent modules to produce an
-executable, regardless of the license terms of these independent
-modules, and to copy and distribute the resulting executable under
-terms of your choice, provided that you also meet, for each linked
-independent module, the terms and conditions of the license of that
-module.  An independent module is a module which is not derived from
-or based on this library.  If you modify this library, you may extend
-this exception to your version of the library, but you are not
-obligated to do so.  If you do not wish to do so, delete this
-exception statement from your version. */
-
-
-package gnu.java.awt.peer;
-
-import java.awt.AWTEvent;
-import java.awt.AWTException;
-import java.awt.BufferCapabilities;
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.Cursor;
-import java.awt.Dimension;
-import java.awt.Font;
-import java.awt.FontMetrics;
-import java.awt.Graphics;
-import java.awt.GraphicsConfiguration;
-import java.awt.Image;
-import java.awt.Insets;
-import java.awt.Point;
-import java.awt.Rectangle;
-import java.awt.Toolkit;
-import java.awt.event.PaintEvent;
-import java.awt.image.ColorModel;
-import java.awt.image.ImageObserver;
-import java.awt.image.ImageProducer;
-import java.awt.image.VolatileImage;
-import java.awt.peer.ContainerPeer;
-import java.awt.peer.LightweightPeer;
-
-/*
- * Another possible implementation strategy for lightweight peers is
- * to make GLightweightPeer a placeholder class that implements
- * LightweightPeer.  Then the Component and Container classes could
- * identify a peer as lightweight and handle it specially.  The
- * current approach is probably more clear but less efficient.
- */
-
-/**
- * A stub class that implements the ComponentPeer and ContainerPeer
- * interfaces using callbacks into the Component and Container
- * classes.  GLightweightPeer allows the Component and Container
- * classes to treat lightweight and heavyweight peers in the same way.
- *
- * Lightweight components are painted directly onto their parent
- * containers through an Image object provided by the toolkit.
- */
-public class GLightweightPeer
-  implements LightweightPeer, ContainerPeer
-{
-  private Component comp;
-
-  private Insets containerInsets;
-
-  public GLightweightPeer(Component comp)
-  {
-    this.comp = comp;
-  }
-
-  // -------- java.awt.peer.ContainerPeer implementation:
-  
-  public Insets insets()
-  {
-    return getInsets ();
-  }
-  
-  public Insets getInsets()
-  {
-    if (containerInsets == null)
-      containerInsets = new Insets (0,0,0,0);
-    return containerInsets;
-  }
-  
-  public void beginValidate()
-  {
-  }
-  
-  public void endValidate()
-  {
-  }
-  
-  public void beginLayout()
-  {
-  }
-  
-  public void endLayout()
-  {
-  }
-  
-  public boolean isPaintPending()
-  {
-    return false;
-  }
-
-  // -------- java.awt.peer.ComponentPeer implementation:
-
-  public int checkImage(Image img, int width, int height, ImageObserver o)
-  {
-    return comp.getToolkit().checkImage(img, width, height, o);
-  }
-
-  public Image createImage(ImageProducer prod)
-  {
-    return comp.getToolkit().createImage(prod);
-  }
-
-  /* This method is not called. */
-  public Image createImage(int width, int height)
-  {
-    return null;
-  }
-
-  public void disable() {}
-
-  public void dispose() {}
-
-  public void enable() {}
-
-  public GraphicsConfiguration getGraphicsConfiguration()
-  {
-    return null;
-  }
-
-  public FontMetrics getFontMetrics(Font f)
-  {
-    return comp.getToolkit().getFontMetrics(f);
-  }
-
-  /* Returning null here tells the Component object that called us to
-   * use its parent's Graphics. */
-  public Graphics getGraphics()
-  {
-    return null;
-  }
-
-  public Point getLocationOnScreen()
-  {
-    Point parentLocation = comp.getParent().getLocationOnScreen();
-    return new Point (parentLocation.x + comp.getX(),
-                      parentLocation.y + comp.getY());
-  }
-
-  public Dimension getMinimumSize()
-  {
-    return new Dimension(comp.getWidth(), comp.getHeight());
-  }
-
-  /* A lightweight component's preferred size is equivalent to its
-   * Component width and height values. */
-  public Dimension getPreferredSize()
-  {
-    return new Dimension(comp.getWidth(), comp.getHeight());
-  }
-
-  /* Returning null here tells the Component object that called us to
-   * use its parent's Toolkit. */
-  public Toolkit getToolkit()
-  {
-    return null;
-  }
-
-  public void handleEvent(AWTEvent e) {}
-
-  public void hide() {}
-
-  public boolean isFocusable() 
-  {
-    return false;
-  }
-
-  public boolean isFocusTraversable()
-  {
-    return false;
-  }
-
-  public Dimension minimumSize()
-  {
-    return getMinimumSize();
-  }
-
-  public Dimension preferredSize()
-  {
-    return getPreferredSize();
-  }
-
-  public void paint(Graphics graphics) {}
-
-  public boolean prepareImage(Image img, int width, int height,
-			      ImageObserver o)
-  {
-    return comp.getToolkit().prepareImage(img, width, height, o);
-  }
-
-  public void print(Graphics graphics) {}
-
-  public void repaint(long tm, int x, int y, int width, int height) {}
-
-  public void requestFocus() {}
-
-  public boolean requestFocus(Component source, boolean bool1, boolean bool2, long x)
-  {
-    return false;
-  }
-
-  public void reshape(int x, int y, int width, int height) {}
-
-  public void setBackground(Color color) {}
-
-  public void setBounds(int x, int y, int width, int height) {}
-
-  public void setCursor(Cursor cursor) {}
-
-  public void setEnabled(boolean enabled) {}
-
-  public void setEventMask(long eventMask) {}
-
-  public void setFont(Font font) {}
-
-  public void setForeground(Color color) {}
-
-  public void setVisible(boolean visible) {}
-
-  public void show() {}
-
-  public ColorModel getColorModel ()
-  {
-    return comp.getColorModel ();
-  }
-
-  public boolean isObscured()
-  {
-    return false;
-  }
-
-  public boolean canDetermineObscurity()
-  {
-    return false;
-  }
-
-  public void coalescePaintEvent(PaintEvent e) { }
-
-  public void updateCursorImmediately() { }
-
-  public VolatileImage createVolatileImage(int width, int height) 
-  { 
-    return null; 
-  }
-
-  public boolean handlesWheelScrolling()
-  {
-    return false;
-  }
-
-  public void createBuffers(int x, BufferCapabilities capabilities) 
-    throws AWTException { }
-
-  public Image getBackBuffer()
-  {
-    return null;
-  }
-
-  public void flip(BufferCapabilities.FlipContents contents) { }
-
-  public void destroyBuffers() { }
-
-  public boolean isRestackSupported()
-  {
-    return false;
-  }
-
-  public void cancelPendingPaint(int x, int y, int width, int height)
-  {
-    
-  }
-
-  public void restack()
-  {
-    
-  }
-
-  public Rectangle getBounds()
-  {
-    return null;
-  }
-
-  public void reparent(ContainerPeer parent)
-  {
-    
-  }
-
-  public void setBounds(int x, int y, int z, int width, int height)
-  {
-    
-  }
-
-  public boolean isReparentSupported()
-  {
-    return false;
-  }
-
-  public void layout()
-  {
-    
-  }
-}
Index: gnu/java/awt/peer/LightweightComponentPeer.java
===================================================================
RCS file: gnu/java/awt/peer/LightweightComponentPeer.java
diff -N gnu/java/awt/peer/LightweightComponentPeer.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/java/awt/peer/LightweightComponentPeer.java	21 Feb 2006 18:38:37 -0000
@@ -0,0 +1,332 @@
+/* LightweightComponentPeer.java --
+   Copyright (C) 2003, 2004 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.awt.peer;
+
+import java.awt.AWTEvent;
+import java.awt.AWTException;
+import java.awt.BufferCapabilities;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Cursor;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Graphics;
+import java.awt.GraphicsConfiguration;
+import java.awt.Image;
+import java.awt.Point;
+import java.awt.Rectangle;
+import java.awt.Toolkit;
+import java.awt.event.PaintEvent;
+import java.awt.image.ColorModel;
+import java.awt.image.ImageObserver;
+import java.awt.image.ImageProducer;
+import java.awt.image.VolatileImage;
+import java.awt.peer.ComponentPeer;
+import java.awt.peer.ContainerPeer;
+import java.awt.peer.LightweightPeer;
+
+/**
+ * A stub class that implements the ComponentPeer 
+ * interface using callbacks into the Component classes.  
+ * LightweightComponentPeer allows the Component
+ * classes to treat lightweight and heavyweight peers in the same way.
+ * GtkLightweightContainerPeer is used for Containers.
+ *
+ * Lightweight components are painted directly onto their parent
+ * containers through an Image object provided by the toolkit.
+ */
+public class LightweightComponentPeer
+    implements LightweightPeer, ComponentPeer
+{
+  private Component comp;
+
+  public LightweightComponentPeer(Component comp)
+  {
+    this.comp = comp;
+  }
+
+  public int checkImage(Image img, int width, int height, ImageObserver o)
+  {
+    return comp.getToolkit().checkImage(img, width, height, o);
+  }
+
+  public Image createImage(ImageProducer prod)
+  {
+    return comp.getToolkit().createImage(prod);
+  }
+
+  /* This method is not called. */
+  public Image createImage(int width, int height)
+  {
+    return null;
+  }
+
+  public void disable()
+  {
+  }
+
+  public void dispose()
+  {
+  }
+
+  public void enable()
+  {
+  }
+
+  public GraphicsConfiguration getGraphicsConfiguration()
+  {
+    return null;
+  }
+
+  public FontMetrics getFontMetrics(Font f)
+  {
+    return comp.getToolkit().getFontMetrics(f);
+  }
+
+  /*
+   * Returning null here tells the Component object that called us to use its
+   * parent's Graphics.
+   */
+  public Graphics getGraphics()
+  {
+    return null;
+  }
+
+  public Point getLocationOnScreen()
+  {
+    Point parentLocation = comp.getParent().getLocationOnScreen();
+    return new Point(parentLocation.x + comp.getX(), parentLocation.y
+                                                     + comp.getY());
+  }
+
+  public Dimension getMinimumSize()
+  {
+    return new Dimension(comp.getWidth(), comp.getHeight());
+  }
+
+  /*
+   * A lightweight component's preferred size is equivalent to its Component
+   * width and height values.
+   */
+  public Dimension getPreferredSize()
+  {
+    return new Dimension(comp.getWidth(), comp.getHeight());
+  }
+
+  /*
+   * Returning null here tells the Component object that called us to use its
+   * parent's Toolkit.
+   */
+  public Toolkit getToolkit()
+  {
+    return null;
+  }
+
+  public void handleEvent(AWTEvent e)
+  {
+  }
+
+  public void hide()
+  {
+  }
+
+  public boolean isFocusable()
+  {
+    return false;
+  }
+
+  public boolean isFocusTraversable()
+  {
+    return false;
+  }
+
+  public Dimension minimumSize()
+  {
+    return getMinimumSize();
+  }
+
+  public Dimension preferredSize()
+  {
+    return getPreferredSize();
+  }
+
+  public void paint(Graphics graphics)
+  {
+  }
+
+  public boolean prepareImage(Image img, int width, int height, ImageObserver o)
+  {
+    return comp.getToolkit().prepareImage(img, width, height, o);
+  }
+
+  public void print(Graphics graphics)
+  {
+  }
+
+  public void repaint(long tm, int x, int y, int width, int height)
+  {
+    Component p = comp.getParent();
+    if (p != null)
+      p.repaint(tm, x + comp.getX(), y + comp.getY(), width, height);
+  }
+
+  public void requestFocus()
+  {
+  }
+
+  public boolean requestFocus(Component source, boolean bool1, boolean bool2,
+                              long x)
+  {
+    return false;
+  }
+
+  public void reshape(int x, int y, int width, int height)
+  {
+  }
+
+  public void setBackground(Color color)
+  {
+  }
+
+  public void setBounds(int x, int y, int width, int height)
+  {
+  }
+
+  public void setCursor(Cursor cursor)
+  {
+  }
+
+  public void setEnabled(boolean enabled)
+  {
+  }
+
+  public void setEventMask(long eventMask)
+  {
+  }
+
+  public void setFont(Font font)
+  {
+  }
+
+  public void setForeground(Color color)
+  {
+  }
+
+  public void setVisible(boolean visible)
+  {
+  }
+
+  public void show()
+  {
+  }
+
+  public ColorModel getColorModel()
+  {
+    return comp.getColorModel();
+  }
+
+  public boolean isObscured()
+  {
+    return false;
+  }
+
+  public boolean canDetermineObscurity()
+  {
+    return false;
+  }
+
+  public void coalescePaintEvent(PaintEvent e)
+  {
+  }
+
+  public void updateCursorImmediately()
+  {
+  }
+
+  public VolatileImage createVolatileImage(int width, int height)
+  {
+    return null;
+  }
+
+  public boolean handlesWheelScrolling()
+  {
+    return false;
+  }
+
+  public void createBuffers(int x, BufferCapabilities capabilities)
+      throws AWTException
+  {
+  }
+
+  public Image getBackBuffer()
+  {
+    return null;
+  }
+
+  public void flip(BufferCapabilities.FlipContents contents)
+  {
+  }
+
+  public void destroyBuffers()
+  {
+  }
+
+  public Rectangle getBounds()
+  {
+    return null;
+  }
+
+  public void reparent(ContainerPeer parent)
+  {
+  }
+
+  public void setBounds(int x, int y, int z, int width, int height)
+  {
+  }
+
+  public boolean isReparentSupported()
+  {
+    return false;
+  }
+
+  public void layout()
+  {
+  }
+}
Index: gnu/java/awt/peer/gtk/GtkComponentPeer.java
===================================================================
RCS file: /sources/classpath/classpath/gnu/java/awt/peer/gtk/GtkComponentPeer.java,v
retrieving revision 1.105
diff -u -r1.105 GtkComponentPeer.java
--- gnu/java/awt/peer/gtk/GtkComponentPeer.java	17 Feb 2006 19:53:06 -0000	1.105
+++ gnu/java/awt/peer/gtk/GtkComponentPeer.java	21 Feb 2006 18:38:37 -0000
@@ -44,7 +44,6 @@
 import java.awt.BufferCapabilities;
 import java.awt.Color;
 import java.awt.Component;
-import java.awt.Container;
 import java.awt.Cursor;
 import java.awt.Dimension;
 import java.awt.EventQueue;
@@ -166,19 +165,16 @@
     setVisibleAndEnabled ();
   }
 
-  void setParent ()
+  void setParent()
   {
     ComponentPeer p;
     Component component = awtComponent;
-    do
-      {
-        component = component.getParent ();
-        p = component.getPeer ();
-      }
-    while (p instanceof java.awt.peer.LightweightPeer);
+
+    component = component.getParent();
+    p = component.getPeer();
 
     if (p != null)
-      gtkWidgetSetParent (p);
+      gtkWidgetSetParent(p);
   }
 
   void beginNativeRepaint ()
@@ -443,38 +439,11 @@
   {
     int new_x = x;
     int new_y = y;
-
-    Component parent = awtComponent.getParent ();
-    Component next_parent;
-
-    // Heavyweight components that are children of one or more
-    // lightweight containers have to be handled specially.  Because
-    // calls to GLightweightPeer.setBounds do nothing, GTK has no
-    // knowledge of the lightweight containers' positions.  So we have
-    // to add the offsets manually when placing a heavyweight
-    // component within a lightweight container.  The lightweight
-    // container may itself be in a lightweight container and so on,
-    // so we need to continue adding offsets until we reach a
-    // container whose position GTK knows -- that is, the first
-    // non-lightweight.
-    boolean lightweightChild = false;
-    Insets i;
-    while (parent.isLightweight())
-      {
-        lightweightChild = true;
-
-        next_parent = parent.getParent();
-
-        i = ((Container) parent).getInsets();
-        new_x += parent.getX() + i.left;
-        new_y += parent.getY() + i.top;
-
-        parent = next_parent;
-      }
+    Component parent = awtComponent.getParent();
 
     // We only need to convert from Java to GTK coordinates if we're
     // placing a heavyweight component in a Window.
-    if (parent instanceof Window && !lightweightChild)
+    if (parent instanceof Window)
       {
         GtkWindowPeer peer = (GtkWindowPeer) parent.getPeer ();
         // important: we want the window peer's insets here, not the
@@ -490,7 +459,7 @@
         new_x = x - insets.left;
         new_y = y - insets.top + menuBarHeight;
       }
-
+    
     setNativeBounds (new_x, new_y, width, height);
   }
 
Index: gnu/java/awt/peer/gtk/GtkContainerPeer.java
===================================================================
RCS file: /sources/classpath/classpath/gnu/java/awt/peer/gtk/GtkContainerPeer.java,v
retrieving revision 1.33
diff -u -r1.33 GtkContainerPeer.java
--- gnu/java/awt/peer/gtk/GtkContainerPeer.java	19 Feb 2006 22:32:45 -0000	1.33
+++ gnu/java/awt/peer/gtk/GtkContainerPeer.java	21 Feb 2006 18:38:37 -0000
@@ -81,8 +81,7 @@
         for (int i = 0; i < ncomponents; i++)
           {
             ComponentPeer peer = components[i].getPeer ();
-
-            // Skip lightweight peers.
+            
             if (peer instanceof GtkComponentPeer)
               ((GtkComponentPeer) peer).setParentAndBounds ();
           }
Index: gnu/java/awt/peer/gtk/GtkLightweightContainerPeer.java
===================================================================
RCS file: gnu/java/awt/peer/gtk/GtkLightweightContainerPeer.java
diff -N gnu/java/awt/peer/gtk/GtkLightweightContainerPeer.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ gnu/java/awt/peer/gtk/GtkLightweightContainerPeer.java	21 Feb 2006 18:38:37 -0000
@@ -0,0 +1,135 @@
+/* GtkLightweightContainerPeer.java -- 
+   Copyright (C) 2006 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.awt.peer.gtk;
+
+import java.awt.Container;
+import java.awt.Graphics;
+import java.awt.Insets;
+import java.awt.Point;
+import java.awt.peer.ContainerPeer;
+import java.awt.peer.LightweightPeer;
+
+/**
+ * A stub class that implements the ContainerPeer 
+ * interface using callbacks into the Container classes.  
+ * LightweightComponentPeer allows the Container
+ * classes to treat lightweight and heavyweight peers in the same way.
+ * LightweightComponentPeer is used for Components.
+ */
+public class GtkLightweightContainerPeer
+  extends GtkContainerPeer
+    implements LightweightPeer, ContainerPeer
+{
+  
+  private Container cont;
+  private Insets containerInsets;
+  
+  native void create();
+  native void connectSignals();
+  
+  public GtkLightweightContainerPeer(Container c)
+  {
+    super(c);
+    cont = c;
+  }
+  
+  /*
+   * Returning null here tells the Component object that called us to use its
+   * parent's Graphics.
+   */
+  public Graphics getGraphics()
+  {
+    return null;
+  }
+  
+  public Point getLocationOnScreen()
+  {
+    Point parentLocation = cont.getParent().getLocationOnScreen();
+    return new Point (parentLocation.x + cont.getX(),
+                      parentLocation.y + cont.getY());
+  }
+  
+  // -------- java.awt.peer.ContainerPeer implementation:
+  
+  public Insets insets()
+  {
+    return getInsets ();
+  }
+  
+  public Insets getInsets()
+  {
+    if (containerInsets == null)
+      containerInsets = new Insets (0,0,0,0);
+    return containerInsets;
+  }
+  
+  public void beginValidate()
+  {
+  }
+  
+  public void endValidate()
+  {
+  }
+  
+  public void beginLayout()
+  {
+  }
+  
+  public void endLayout()
+  {
+  }
+  
+  public boolean isPaintPending()
+  {
+    return false;
+  }
+
+  public void restack()
+  {
+  }
+  
+  public boolean isRestackSupported()
+  {
+    return false;
+  }
+
+  public void cancelPendingPaint(int x, int y, int width, int height)
+  {
+  }
+}
Index: gnu/java/awt/peer/gtk/GtkToolkit.java
===================================================================
RCS file: /sources/classpath/classpath/gnu/java/awt/peer/gtk/GtkToolkit.java,v
retrieving revision 1.81
diff -u -r1.81 GtkToolkit.java
--- gnu/java/awt/peer/gtk/GtkToolkit.java	14 Feb 2006 22:49:18 -0000	1.81
+++ gnu/java/awt/peer/gtk/GtkToolkit.java	21 Feb 2006 18:38:37 -0000
@@ -44,27 +44,77 @@
 import gnu.java.awt.peer.ClasspathFontPeer;
 import gnu.java.awt.peer.ClasspathTextLayoutPeer;
 import gnu.java.awt.peer.EmbeddedWindowPeer;
+import gnu.java.awt.peer.LightweightComponentPeer;
 
-import java.awt.*;
+import java.awt.AWTException;
+import java.awt.Button;
+import java.awt.Canvas;
+import java.awt.Checkbox;
+import java.awt.CheckboxMenuItem;
+import java.awt.Choice;
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.Dialog;
+import java.awt.Dimension;
+import java.awt.EventQueue;
+import java.awt.FileDialog;
+import java.awt.Font;
+import java.awt.FontMetrics;
+import java.awt.Frame;
+import java.awt.GraphicsDevice;
+import java.awt.GraphicsEnvironment;
+import java.awt.Image;
+import java.awt.Label;
+import java.awt.List;
+import java.awt.Menu;
+import java.awt.MenuBar;
+import java.awt.MenuItem;
+import java.awt.Panel;
+import java.awt.PopupMenu;
+import java.awt.PrintJob;
+import java.awt.Rectangle;
+import java.awt.ScrollPane;
+import java.awt.Scrollbar;
+import java.awt.TextArea;
+import java.awt.TextField;
+import java.awt.Window;
 import java.awt.datatransfer.Clipboard;
 import java.awt.dnd.DragGestureEvent;
 import java.awt.dnd.peer.DragSourceContextPeer;
 import java.awt.font.FontRenderContext;
 import java.awt.im.InputMethodHighlight;
-import java.awt.image.BufferedImage;
 import java.awt.image.ColorModel;
 import java.awt.image.DirectColorModel;
-import java.awt.image.ImageConsumer;
 import java.awt.image.ImageObserver;
 import java.awt.image.ImageProducer;
-import java.awt.peer.*;
+import java.awt.peer.ButtonPeer;
+import java.awt.peer.CanvasPeer;
+import java.awt.peer.CheckboxMenuItemPeer;
+import java.awt.peer.CheckboxPeer;
+import java.awt.peer.ChoicePeer;
+import java.awt.peer.DialogPeer;
+import java.awt.peer.FileDialogPeer;
+import java.awt.peer.FontPeer;
+import java.awt.peer.FramePeer;
+import java.awt.peer.LabelPeer;
+import java.awt.peer.LightweightPeer;
+import java.awt.peer.ListPeer;
+import java.awt.peer.MenuBarPeer;
+import java.awt.peer.MenuItemPeer;
+import java.awt.peer.MenuPeer;
+import java.awt.peer.PanelPeer;
+import java.awt.peer.PopupMenuPeer;
+import java.awt.peer.RobotPeer;
+import java.awt.peer.ScrollPanePeer;
+import java.awt.peer.ScrollbarPeer;
+import java.awt.peer.TextAreaPeer;
+import java.awt.peer.TextFieldPeer;
+import java.awt.peer.WindowPeer;
 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.Properties;
@@ -610,6 +660,23 @@
   {
     GdkPixbufDecoder.registerSpis(reg);
   }
-
+  
+  /**
+   * Creates a peer object for the specified <code>Component</code>.  The
+   * peer returned by this method is not a native windowing system peer
+   * with its own native window.  Instead, this method allows the component
+   * to draw on its parent window as a "lightweight" widget.
+   *
+   * @param target The <code>Component</code> to create the peer for.
+   *
+   * @return The peer for the specified <code>Component</code> object.
+   */
+  protected LightweightPeer createComponent(Component target)
+  {
+    if (target instanceof Container)
+      return new GtkLightweightContainerPeer((Container) target);
+    return new LightweightComponentPeer(target);
+  }
+  
   public static native void gtkMain();
 } // class GtkToolkit
Index: include/Makefile.am
===================================================================
RCS file: /sources/classpath/classpath/include/Makefile.am,v
retrieving revision 1.53
diff -u -r1.53 Makefile.am
--- include/Makefile.am	13 Feb 2006 16:12:53 -0000	1.53
+++ include/Makefile.am	21 Feb 2006 18:38:37 -0000
@@ -59,6 +59,7 @@
 $(top_srcdir)/include/gnu_java_awt_peer_gtk_GtkImage.h \
 $(top_srcdir)/include/gnu_java_awt_peer_gtk_GtkLabelPeer.h \
 $(top_srcdir)/include/gnu_java_awt_peer_gtk_GtkListPeer.h \
+$(top_srcdir)/include/gnu_java_awt_peer_gtk_GtkLightweightContainerPeer.h \
 $(top_srcdir)/include/gnu_java_awt_peer_gtk_GtkMenuBarPeer.h \
 $(top_srcdir)/include/gnu_java_awt_peer_gtk_GtkMenuComponentPeer.h \
 $(top_srcdir)/include/gnu_java_awt_peer_gtk_GtkMenuItemPeer.h \
Index: include/gnu_java_awt_peer_gtk_GtkLightweightContainerPeer.h
===================================================================
RCS file: include/gnu_java_awt_peer_gtk_GtkLightweightContainerPeer.h
diff -N include/gnu_java_awt_peer_gtk_GtkLightweightContainerPeer.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ include/gnu_java_awt_peer_gtk_GtkLightweightContainerPeer.h	21 Feb 2006 18:38:37 -0000
@@ -0,0 +1,20 @@
+/* DO NOT EDIT THIS FILE - it is machine generated */
+
+#ifndef __gnu_java_awt_peer_gtk_GtkLightweightContainerPeer__
+#define __gnu_java_awt_peer_gtk_GtkLightweightContainerPeer__
+
+#include <jni.h>
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkLightweightContainerPeer_create (JNIEnv *env, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkLightweightContainerPeer_connectSignals (JNIEnv *env, jobject);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gnu_java_awt_peer_gtk_GtkLightweightContainerPeer__ */
Index: java/awt/Graphics.java
===================================================================
RCS file: /sources/classpath/classpath/java/awt/Graphics.java,v
retrieving revision 1.15
diff -u -r1.15 Graphics.java
--- java/awt/Graphics.java	10 Oct 2005 12:18:05 -0000	1.15
+++ java/awt/Graphics.java	21 Feb 2006 18:38:37 -0000
@@ -617,6 +617,9 @@
    */
   public boolean hitClip(int x, int y, int width, int height)
   {
+    Shape clip = getClip();
+    if (clip == null)
+      return true;
     return getClip().intersects(x, y, width, height);
   }
 
Index: java/awt/Toolkit.java
===================================================================
RCS file: /sources/classpath/classpath/java/awt/Toolkit.java,v
retrieving revision 1.31
diff -u -r1.31 Toolkit.java
--- java/awt/Toolkit.java	2 Aug 2005 15:29:25 -0000	1.31
+++ java/awt/Toolkit.java	21 Feb 2006 18:38:37 -0000
@@ -349,7 +349,16 @@
    */
   protected LightweightPeer createComponent(Component target)
   {
-    return new gnu.java.awt.peer.GLightweightPeer (target);
+    // This should be overridden by default Toolkit (eg. GtkToolkit).
+    // If target is an instance of Container, then a GtkLightweightPeer
+    // should be returned. Otherwise, an instance of GLightweightPeer is
+    // returned for Components. This is because, all the properties of a
+    // Container should be accessible (bounds, location etc).
+    // A lightweight Component should _just_ be drawn on its parent window,
+    // but we should be able to reshape a Container. Therefore, Component
+    // and Container lightweights should be treated differently.
+    
+    return null;
   }
 
   /**
Index: native/jni/gtk-peer/Makefile.am
===================================================================
RCS file: /sources/classpath/classpath/native/jni/gtk-peer/Makefile.am,v
retrieving revision 1.34
diff -u -r1.34 Makefile.am
--- native/jni/gtk-peer/Makefile.am	25 Jan 2006 10:40:12 -0000	1.34
+++ native/jni/gtk-peer/Makefile.am	21 Feb 2006 18:38:37 -0000
@@ -31,6 +31,7 @@
 			gnu_java_awt_peer_gtk_GtkImage.c \
 			gnu_java_awt_peer_gtk_GtkLabelPeer.c \
 			gnu_java_awt_peer_gtk_GtkListPeer.c \
+			gnu_java_awt_peer_gtk_GtkLightweightContainerPeer.c \
 			gnu_java_awt_peer_gtk_GtkMenuBarPeer.c \
 			gnu_java_awt_peer_gtk_GtkMenuComponentPeer.c \
 			gnu_java_awt_peer_gtk_GtkMenuItemPeer.c \
Index: native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkLightweightContainerPeer.c
===================================================================
RCS file: native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkLightweightContainerPeer.c
diff -N native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkLightweightContainerPeer.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkLightweightContainerPeer.c	21 Feb 2006 18:38:37 -0000
@@ -0,0 +1,110 @@
+/* GtkLightweightContainerPeer.c -- Native implementation of GtkLightweightPeer
+   Copyright (C) 1998, 1999, 2002 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+#include "gtkpeer.h"
+#include "gnu_java_awt_peer_gtk_GtkComponentPeer.h"
+#include "gnu_java_awt_peer_gtk_GtkLightweightContainerPeer.h"
+
+static gboolean panel_focus_in_cb (GtkWidget * widget,
+                                   GdkEventFocus *event,
+                                   jobject peer);
+static gboolean panel_focus_out_cb (GtkWidget * widget,
+                                    GdkEventFocus *event,
+                                    jobject peer);
+
+JNIEXPORT void JNICALL 
+Java_gnu_java_awt_peer_gtk_GtkLightweightContainerPeer_create
+  (JNIEnv *env, jobject obj)
+{
+  GtkWidget *widget;
+
+  gdk_threads_enter ();
+
+  NSA_SET_GLOBAL_REF (env, obj);
+
+  widget = gtk_fixed_new ();
+
+  gtk_fixed_set_has_window (GTK_FIXED (widget), FALSE);
+
+  NSA_SET_PTR (env, obj, widget);
+
+  gdk_threads_leave ();
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GtkLightweightContainerPeer_connectSignals
+  (JNIEnv *env, jobject obj)
+{
+  void *ptr;
+  jobject *gref;
+
+  gdk_threads_enter ();
+
+  ptr = NSA_GET_PTR (env, obj);
+  gref = NSA_GET_GLOBAL_REF (env, obj);
+
+  /* Panel signals.  These callbacks prevent expose events being
+     delivered to the panel when it is focused. */
+  g_signal_connect (G_OBJECT (ptr), "focus-in-event",
+                    G_CALLBACK (panel_focus_in_cb), *gref);
+
+  g_signal_connect (G_OBJECT (ptr), "focus-out-event",
+                    G_CALLBACK (panel_focus_out_cb), *gref);
+
+  /* Component signals.  Exclude focus signals. */
+  cp_gtk_component_connect_expose_signals (ptr, gref);
+  cp_gtk_component_connect_mouse_signals (ptr, gref);
+
+  gdk_threads_leave ();
+}
+
+static gboolean
+panel_focus_in_cb (GtkWidget * widget  __attribute__((unused)),
+		    GdkEventFocus *event  __attribute__((unused)),
+		    jobject peer __attribute__((unused)))
+{
+  return TRUE;
+}
+
+static gboolean
+panel_focus_out_cb (GtkWidget * widget __attribute__((unused)),
+		     GdkEventFocus *event __attribute__((unused)),
+		     jobject peer __attribute__((unused)))
+{
+  return TRUE;
+}

Reply via email to