diff options
Diffstat (limited to 'libjava/classpath/gnu/java/awt/peer/gtk/GtkWindowPeer.java')
-rw-r--r-- | libjava/classpath/gnu/java/awt/peer/gtk/GtkWindowPeer.java | 78 |
1 files changed, 52 insertions, 26 deletions
diff --git a/libjava/classpath/gnu/java/awt/peer/gtk/GtkWindowPeer.java b/libjava/classpath/gnu/java/awt/peer/gtk/GtkWindowPeer.java index 866d9c8816a..8d49719b1d3 100644 --- a/libjava/classpath/gnu/java/awt/peer/gtk/GtkWindowPeer.java +++ b/libjava/classpath/gnu/java/awt/peer/gtk/GtkWindowPeer.java @@ -38,7 +38,10 @@ exception statement from your version. */ package gnu.java.awt.peer.gtk; +import gnu.java.awt.ComponentReshapeEvent; + import java.awt.Component; +import java.awt.Font; import java.awt.Frame; import java.awt.Graphics; import java.awt.KeyboardFocusManager; @@ -62,8 +65,7 @@ public class GtkWindowPeer extends GtkContainerPeer protected static final int GDK_WINDOW_TYPE_HINT_DOCK = 6; protected static final int GDK_WINDOW_TYPE_HINT_DESKTOP = 7; - private boolean hasBeenShown = false; - private int oldState = Frame.NORMAL; + protected int windowState = Frame.NORMAL; // Cached awt window component location, width and height. private int x, y, width, height; @@ -75,6 +77,12 @@ public class GtkWindowPeer extends GtkContainerPeer native boolean gtkWindowHasFocus(); native void realize (); + public void dispose() + { + super.dispose(); + GtkMainThread.destroyWindow(); + } + /** Returns the cached width of the AWT window component. */ int getX () { @@ -144,6 +152,8 @@ public class GtkWindowPeer extends GtkContainerPeer public GtkWindowPeer (Window window) { super (window); + // Set reasonable font for the window. + window.setFont(new Font("Dialog", Font.PLAIN, 12)); } public native void toBack(); @@ -218,9 +228,31 @@ public class GtkWindowPeer extends GtkContainerPeer // only called from GTK thread protected void postConfigureEvent (int x, int y, int width, int height) { + int frame_x = x - insets.left; + int frame_y = y - insets.top; int frame_width = width + insets.left + insets.right; int frame_height = height + insets.top + insets.bottom; + // Update the component's knowledge about the size. + // Important: Please look at the big comment in ComponentReshapeEvent + // to learn why we did it this way. If you change this code, make + // sure that the peer->AWT bounds update still works. + // (for instance: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29448 ) + + // We do this befor we post the ComponentEvent, because (in Window) + // we invalidate() / revalidate() when a ComponentEvent is seen, + // and the AWT must already know about the new size then. + if (frame_x != this.x || frame_y != this.y || frame_width != this.width + || frame_height != this.height) + { + ComponentReshapeEvent ev = new ComponentReshapeEvent(awtComponent, + frame_x, + frame_y, + frame_width, + frame_height); + awtComponent.dispatchEvent(ev); + } + if (frame_width != getWidth() || frame_height != getHeight()) { @@ -230,9 +262,6 @@ public class GtkWindowPeer extends GtkContainerPeer ComponentEvent.COMPONENT_RESIZED)); } - int frame_x = x - insets.left; - int frame_y = y - insets.top; - if (frame_x != getX() || frame_y != getY()) { @@ -241,6 +270,7 @@ public class GtkWindowPeer extends GtkContainerPeer q().postEvent(new ComponentEvent(awtComponent, ComponentEvent.COMPONENT_MOVED)); } + } public void show () @@ -255,23 +285,26 @@ public class GtkWindowPeer extends GtkContainerPeer void postWindowEvent (int id, Window opposite, int newState) { - if (id == WindowEvent.WINDOW_OPENED) + if (id == WindowEvent.WINDOW_STATE_CHANGED) { - // Post a WINDOW_OPENED event the first time this window is shown. - if (!hasBeenShown) + if (windowState != newState) { + // Post old styleWindowEvent with WINDOW_ICONIFIED or + // WINDOW_DEICONIFIED if appropriate. + if ((windowState & Frame.ICONIFIED) != 0 + && (newState & Frame.ICONIFIED) == 0) + q().postEvent(new WindowEvent((Window) awtComponent, + WindowEvent.WINDOW_DEICONIFIED, + opposite, 0, 0)); + else if ((windowState & Frame.ICONIFIED) == 0 + && (newState & Frame.ICONIFIED) != 0) + q().postEvent(new WindowEvent((Window) awtComponent, + WindowEvent.WINDOW_ICONIFIED, + opposite, 0, 0)); + // Post new-style WindowStateEvent. q().postEvent (new WindowEvent ((Window) awtComponent, id, - opposite)); - hasBeenShown = true; - } - } - else if (id == WindowEvent.WINDOW_STATE_CHANGED) - { - if (oldState != newState) - { - q().postEvent (new WindowEvent ((Window) awtComponent, id, opposite, - oldState, newState)); - oldState = newState; + opposite, windowState, newState)); + windowState = newState; } } else @@ -350,13 +383,6 @@ public class GtkWindowPeer extends GtkContainerPeer return g; } - protected void updateComponent (PaintEvent event) - { - // Do not clear anything before painting. Sun never calls - // Window.update, only Window.paint. - paintComponent(event); - } - protected void postMouseEvent(int id, long when, int mods, int x, int y, int clickCount, boolean popupTrigger) { |