2004-01-13 Thomas Fitzsimmons <fitzsim@redhat.com>
* gnu/java/awt/peer/gtk/GtkComponentPeer.java (initializeInsets): Remove method. (GtkComponentPeer): Initialize insets field. Remove call to initializeInsets. * gnu/java/awt/peer/gtk/GtkDialogPeer.java (initializeInsets): Remove method. * gnu/java/awt/peer/gtk/GtkFramePeer.java (initializeInsets): Remove method. * gnu/java/awt/peer/gtk/GtkWindowPeer.java, jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c: (latestInsets): Remove field. (native create): Add insets parameter. Call window_get_frame_extents. Set the window's default size and size request based on its frame extents. (create): Initialize insets. (postInsetsChangedEvent): New method. (postConfigureEvent): Remove parameters top, left, bottom, right. Remove insets-related logic. (connectJObject): Handle property-notify-event. (window_get_frame_extents, request_frame_extents, property_notify_predicate, window_property_changed_cb): New static functions. * jni/gtk-peer/gnu_java_awt_peer_gtk_GtkEvents.c (pre_event_handler): Remove insets-related logic for configure events. * jni/gtk-peer/gnu_java_awt_peer_gtk_GtkMainThread.c (gtkInit): Update postConfigureEvent signature. From-SVN: r75816
This commit is contained in:
parent
a4d8ec652b
commit
db19e39b82
8 changed files with 264 additions and 146 deletions
|
@ -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).
|
||||
insets.top = top;
|
||||
insets.left = left;
|
||||
insets.bottom = bottom;
|
||||
insets.right = 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);
|
||||
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;
|
||||
|
||||
// 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));
|
||||
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;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
awtComponent.validate();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue