diff options
Diffstat (limited to 'libjava/gnu/java/awt/peer')
| -rw-r--r-- | libjava/gnu/java/awt/peer/gtk/GtkComponentPeer.java | 8 | ||||
| -rw-r--r-- | libjava/gnu/java/awt/peer/gtk/GtkDialogPeer.java | 12 | ||||
| -rw-r--r-- | libjava/gnu/java/awt/peer/gtk/GtkFramePeer.java | 16 | ||||
| -rw-r--r-- | libjava/gnu/java/awt/peer/gtk/GtkWindowPeer.java | 107 |
4 files changed, 35 insertions, 108 deletions
diff --git a/libjava/gnu/java/awt/peer/gtk/GtkComponentPeer.java b/libjava/gnu/java/awt/peer/gtk/GtkComponentPeer.java index 0a712a0597c..6f71db9f17a 100644 --- a/libjava/gnu/java/awt/peer/gtk/GtkComponentPeer.java +++ b/libjava/gnu/java/awt/peer/gtk/GtkComponentPeer.java @@ -96,11 +96,6 @@ public class GtkComponentPeer extends GtkGenericPeer throw new RuntimeException (); } - void initializeInsets () - { - insets = new Insets (0, 0, 0, 0); - } - native void connectJObject (); native void connectSignals (); @@ -108,6 +103,7 @@ public class GtkComponentPeer extends GtkGenericPeer { super (awtComponent); this.awtComponent = awtComponent; + insets = new Insets (0, 0, 0, 0); /* temporary try/catch block until all peers use this creation method */ try { @@ -127,8 +123,6 @@ public class GtkComponentPeer extends GtkGenericPeer if (awtComponent.getFont() != null) setFont(awtComponent.getFont()); - initializeInsets (); - setCursor (awtComponent.getCursor ()); Rectangle bounds = awtComponent.getBounds (); setBounds (bounds.x, bounds.y, bounds.width, bounds.height); diff --git a/libjava/gnu/java/awt/peer/gtk/GtkDialogPeer.java b/libjava/gnu/java/awt/peer/gtk/GtkDialogPeer.java index 27867321c3c..6aefba608e6 100644 --- a/libjava/gnu/java/awt/peer/gtk/GtkDialogPeer.java +++ b/libjava/gnu/java/awt/peer/gtk/GtkDialogPeer.java @@ -41,7 +41,6 @@ package gnu.java.awt.peer.gtk; import java.awt.AWTEvent; import java.awt.Component; import java.awt.Dialog; -import java.awt.Insets; import java.awt.peer.DialogPeer; public class GtkDialogPeer extends GtkWindowPeer @@ -52,17 +51,6 @@ public class GtkDialogPeer extends GtkWindowPeer super (dialog); } - void initializeInsets () - { - synchronized (latestInsets) - { - insets = new Insets (latestInsets.top, - latestInsets.left, - latestInsets.bottom, - latestInsets.right); - } - } - void create () { // Create a decorated dialog window. diff --git a/libjava/gnu/java/awt/peer/gtk/GtkFramePeer.java b/libjava/gnu/java/awt/peer/gtk/GtkFramePeer.java index 13d2fc77a25..33d0fccd64f 100644 --- a/libjava/gnu/java/awt/peer/gtk/GtkFramePeer.java +++ b/libjava/gnu/java/awt/peer/gtk/GtkFramePeer.java @@ -43,7 +43,6 @@ import java.awt.Frame; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Image; -import java.awt.Insets; import java.awt.MenuBar; import java.awt.Rectangle; import java.awt.event.PaintEvent; @@ -71,21 +70,6 @@ public class GtkFramePeer extends GtkWindowPeer super (frame); } - void initializeInsets () - { - // Unfortunately, X does not provide a clean way to calculate the - // dimensions of a frame's borders before it has been displayed. - // So we guess and then fix the dimensions upon receipt of the - // first configure event. - synchronized (latestInsets) - { - insets = new Insets (latestInsets.top, - latestInsets.left, - latestInsets.bottom, - latestInsets.right); - } - } - void create () { // Create a normal decorated window. diff --git a/libjava/gnu/java/awt/peer/gtk/GtkWindowPeer.java b/libjava/gnu/java/awt/peer/gtk/GtkWindowPeer.java index 4a2d50805a1..7e77e0dcbf0 100644 --- a/libjava/gnu/java/awt/peer/gtk/GtkWindowPeer.java +++ b/libjava/gnu/java/awt/peer/gtk/GtkWindowPeer.java @@ -40,7 +40,6 @@ package gnu.java.awt.peer.gtk; import java.awt.Component; import java.awt.Dimension; -import java.awt.Insets; import java.awt.Window; import java.awt.Frame; import java.awt.event.WindowEvent; @@ -61,30 +60,30 @@ public class GtkWindowPeer extends GtkContainerPeer private boolean hasBeenShown = false; private int oldState = Frame.NORMAL; - // Unfortunately, X does not provide a clean way to calculate the - // dimensions of a window's borders before it has been displayed. - // So when creating the application's first window we guess the - // border dimensions. Then if need be for that window, we fix the - // dimensions upon receipt of the first configure event. Windows - // created after the first one will use the latest inset values - // received in postConfigureEvent. - static Insets latestInsets = new Insets (20, 6, 6, 6); - native void create (int type, boolean decorated, int width, int height, - GtkWindowPeer parent); + GtkWindowPeer parent, + int[] insets); void create (int type, boolean decorated) { GtkWindowPeer parent_peer = null; Component parent = awtComponent.getParent(); + int[] insets = new int [] { 0, 0, 0, 0 }; + if (parent != null) parent_peer = (GtkWindowPeer) awtComponent.getParent().getPeer(); create (type, decorated, awtComponent.getWidth(), awtComponent.getHeight(), - parent_peer); + parent_peer, + insets); + + this.insets.top = insets [0]; + this.insets.left = insets [1]; + this.insets.bottom = insets [2]; + this.insets.right = insets [3]; } void create () @@ -132,7 +131,7 @@ public class GtkWindowPeer extends GtkContainerPeer // false the window will shrink to the dimensions it had before it // was resizable. setSize (awtComponent.getWidth() - insets.left - insets.right, - awtComponent.getHeight() - insets.top - insets.bottom); + awtComponent.getHeight() - insets.top - insets.bottom); set ("allow_shrink", resizable); set ("allow_grow", resizable); } @@ -141,67 +140,29 @@ public class GtkWindowPeer extends GtkContainerPeer int x, int y, int width, int height); - protected void postConfigureEvent (int x, int y, int width, int height, - int top, int left, int bottom, int right) + protected void postInsetsChangedEvent (int top, int left, + int bottom, int right) { - // Configure events tell us the location and dimensions of the - // window within the frame borders, and the dimensions of the - // frame borders (top, left, bottom, right). - - // If our borders change we need to make sure that a new layout - // will happen, since Sun forgets to handle this case. - if (insets.top != top - || insets.left != left - || insets.bottom != bottom - || insets.right != right) - { - // When our insets change, we receive a configure event with - // the new insets, the old window location and the old window - // dimensions. We update our Window object's location and - // size using our old inset values. - setBoundsCallback ((Window) awtComponent, - x - insets.left, - y - insets.top, - width + insets.left + insets.right, - height + insets.top + insets.bottom); - - // The peer's dimensions do not get updated automatically when - // insets change so we need to do it manually. - setSize (width + (insets.left - left) + (insets.right - right), - height + (insets.top - top) + (insets.bottom - bottom)); - - insets.top = top; - insets.left = left; - insets.bottom = bottom; - insets.right = right; - - synchronized (latestInsets) - { - latestInsets.top = top; - latestInsets.left = left; - latestInsets.bottom = bottom; - latestInsets.right = right; - } - } - else - { - 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; - - if (frame_x != awtComponent.getX() - || frame_y != awtComponent.getY() - || frame_width != awtComponent.getWidth() - || frame_height != awtComponent.getHeight()) - { - setBoundsCallback ((Window) awtComponent, - frame_x, - frame_y, - frame_width, - frame_height); - } - } + insets.top = top; + insets.left = left; + insets.bottom = bottom; + insets.right = right; + } + + 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; + + if (frame_x != awtComponent.getX() + || frame_y != awtComponent.getY() + || frame_width != awtComponent.getWidth() + || frame_height != awtComponent.getHeight()) + setBoundsCallback ((Window) awtComponent, + frame_x, frame_y, frame_width, frame_height); + awtComponent.validate(); } |

