diff options
Diffstat (limited to 'libjava/gnu/java/awt/peer/gtk/GtkContainerPeer.java')
-rw-r--r-- | libjava/gnu/java/awt/peer/gtk/GtkContainerPeer.java | 43 |
1 files changed, 31 insertions, 12 deletions
diff --git a/libjava/gnu/java/awt/peer/gtk/GtkContainerPeer.java b/libjava/gnu/java/awt/peer/gtk/GtkContainerPeer.java index 040499724fd..7fddd56619f 100644 --- a/libjava/gnu/java/awt/peer/gtk/GtkContainerPeer.java +++ b/libjava/gnu/java/awt/peer/gtk/GtkContainerPeer.java @@ -45,13 +45,16 @@ import java.awt.Container; import java.awt.Font; import java.awt.Graphics; import java.awt.Insets; +import java.awt.Window; import java.awt.event.PaintEvent; +import java.awt.peer.ComponentPeer; import java.awt.peer.ContainerPeer; public class GtkContainerPeer extends GtkComponentPeer implements ContainerPeer { Container c; + boolean isValidating; public GtkContainerPeer(Container c) { @@ -59,22 +62,38 @@ public class GtkContainerPeer extends GtkComponentPeer this.c = c; } - public void beginValidate() + public void beginValidate () { + isValidating = true; } - public void endValidate() + public void endValidate () { -// q.postEvent (new PaintEvent (awtComponent, PaintEvent.PAINT, -// new Rectangle (x, y, width, height))); -// Graphics gc = getGraphics (); -// if (gc != null) -// { -// awtComponent.update (gc); -// gc.dispose (); -// } -// System.out.println ("got here"); -// awtComponent.repaint (); + Component parent = awtComponent.getParent (); + + // Only set our parent on the GTK side if our parent on the AWT + // side is not showing. Otherwise the gtk peer will be shown + // before we've had a chance to position and size it properly. + if (parent != null && parent.isShowing ()) + { + Component[] components = ((Container) awtComponent).getComponents (); + int ncomponents = components.length; + + for (int i = 0; i < ncomponents; i++) + { + ComponentPeer peer = components[i].getPeer (); + + // Skip lightweight peers. + if (peer instanceof GtkComponentPeer) + ((GtkComponentPeer) peer).setParentAndBounds (); + } + + // GTK windows don't have parents. + if (!(awtComponent instanceof Window)) + setParentAndBounds (); + } + + isValidating = false; } public Insets getInsets() |