aboutsummaryrefslogtreecommitdiff
path: root/libjava/gnu/java/awt/peer/gtk/GtkWindowPeer.java
diff options
context:
space:
mode:
Diffstat (limited to 'libjava/gnu/java/awt/peer/gtk/GtkWindowPeer.java')
-rw-r--r--libjava/gnu/java/awt/peer/gtk/GtkWindowPeer.java107
1 files changed, 34 insertions, 73 deletions
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();
}