> Can you run the gnu.testlet.java.awt tests from Mauve as well as the
> Window/Frame/Dialog related vte tests?  I think we found that we needed
> to set the width and height, as well as the location (i.e. we needed to
> call setBounds) before showing the window.

These tests still pass. I also found a problem with preferredSize in
Component, This is now fixed.

2006-02-15  Lillian Angel  <[EMAIL PROTECTED]>

        * gnu/java/awt/peer/gtk/GtkDialogPeer.java
        (setVisible): Removed method.
        * gnu/java/awt/peer/gtk/GtkWindowPeer.java
        (setLocation): New method.
        (setLocationUnlocked): New method.
        (show): Changed to use setLocation instead of setBounds.
        * java/awt/Component.java
        (show): Should call peer.show(), not peer.setVisible(), so the
        location of the component is correctly set.
        (preferredSize): Added curly braces so else statements are
        properly associated with if's.
        * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
        (Java_gnu_java_awt_peer_gtk_GtkWindowPeer_nativeSetLocation):
        New function.
        (Java_gnu_java_awt_peer_gtk_GtkWindowPeer_nativeSet
        LocationUnlocked): New function.
        * include/gnu_java_awt_peer_gtk_GtkWindowPeer.h:
        Added declarations for Java_gnu_java_awt_peer_gtk_
        GtkWindowPeer_nativeSetLocation and
        Java_gnu_java_awt_peer_gtk_GtkWindowPeer
        _nativeSetLocationUnlocked.

Committed.

Thanks,
Lillian

Index: gnu/java/awt/peer/gtk/GtkDialogPeer.java
===================================================================
RCS file: /sources/classpath/classpath/gnu/java/awt/peer/gtk/GtkDialogPeer.java,v
retrieving revision 1.31
diff -u -r1.31 GtkDialogPeer.java
--- gnu/java/awt/peer/gtk/GtkDialogPeer.java	14 Feb 2006 19:40:07 -0000	1.31
+++ gnu/java/awt/peer/gtk/GtkDialogPeer.java	15 Feb 2006 18:17:34 -0000
@@ -62,16 +62,6 @@
     g.translate (-insets.left, -insets.top);
     return g;
   }  
-
-  public void setVisible (boolean b)
-  {
-    // Prevent the window manager from automatically placing this
-    // window when it is shown.
-    setBounds(awtComponent.getX(), awtComponent.getY(),
-              awtComponent.getWidth(), awtComponent.getHeight());
-    
-    super.setVisible(b);
-  }
   
   protected void postMouseEvent(int id, long when, int mods, int x, int y, 
 				int clickCount, boolean popupTrigger)
Index: gnu/java/awt/peer/gtk/GtkWindowPeer.java
===================================================================
RCS file: /sources/classpath/classpath/gnu/java/awt/peer/gtk/GtkWindowPeer.java,v
retrieving revision 1.45
diff -u -r1.45 GtkWindowPeer.java
--- gnu/java/awt/peer/gtk/GtkWindowPeer.java	13 Feb 2006 14:32:53 -0000	1.45
+++ gnu/java/awt/peer/gtk/GtkWindowPeer.java	15 Feb 2006 18:17:34 -0000
@@ -126,7 +126,23 @@
 
   native void nativeSetBounds (int x, int y, int width, int height);
   native void nativeSetBoundsUnlocked (int x, int y, int width, int height);
+  native void nativeSetLocation (int x, int y);
+  native void nativeSetLocationUnlocked (int x, int y);
 
+  public void setLocation (int x, int y)
+  {
+    // prevent window_configure_cb -> awtComponent.setSize ->
+    // peer.setBounds -> nativeSetBounds self-deadlock on GDK lock.
+    if (Thread.currentThread() == GtkToolkit.mainThread)
+      return;
+    nativeSetLocation (x, y);
+  }
+
+  public void setLocationUnlocked (int x, int y)
+  {
+    nativeSetLocationUnlocked (x, y);
+  }
+  
   public void setBounds (int x, int y, int width, int height)
   {
     // prevent window_configure_cb -> awtComponent.setSize ->
@@ -195,12 +211,7 @@
 
   public void show ()
   {
-    // Prevent the window manager from automatically placing this
-    // window when it is shown.
-    setBounds (awtComponent.getX(),
-	       awtComponent.getY(),
-	       awtComponent.getWidth(),
-	       awtComponent.getHeight());
+    setLocation(awtComponent.getX(), awtComponent.getY());
     setVisible (true);
   }
 
Index: include/gnu_java_awt_peer_gtk_GtkWindowPeer.h
===================================================================
RCS file: /sources/classpath/classpath/include/gnu_java_awt_peer_gtk_GtkWindowPeer.h,v
retrieving revision 1.19
diff -u -r1.19 gnu_java_awt_peer_gtk_GtkWindowPeer.h
--- include/gnu_java_awt_peer_gtk_GtkWindowPeer.h	26 Aug 2005 04:35:49 -0000	1.19
+++ include/gnu_java_awt_peer_gtk_GtkWindowPeer.h	15 Feb 2006 18:17:34 -0000
@@ -22,6 +22,8 @@
 JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkWindowPeer_toFront (JNIEnv *env, jobject);
 JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkWindowPeer_nativeSetBounds (JNIEnv *env, jobject, jint, jint, jint, jint);
 JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkWindowPeer_nativeSetBoundsUnlocked (JNIEnv *env, jobject, jint, jint, jint, jint);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkWindowPeer_nativeSetLocation (JNIEnv *env, jobject, jint, jint);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkWindowPeer_nativeSetLocationUnlocked (JNIEnv *env, jobject, jint, jint);
 JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkWindowPeer_setSize (JNIEnv *env, jobject, jint, jint);
 #undef gnu_java_awt_peer_gtk_GtkWindowPeer_GDK_WINDOW_TYPE_HINT_NORMAL
 #define gnu_java_awt_peer_gtk_GtkWindowPeer_GDK_WINDOW_TYPE_HINT_NORMAL 0L
Index: java/awt/Component.java
===================================================================
RCS file: /sources/classpath/classpath/java/awt/Component.java,v
retrieving revision 1.98
diff -u -r1.98 Component.java
--- java/awt/Component.java	13 Feb 2006 15:12:25 -0000	1.98
+++ java/awt/Component.java	15 Feb 2006 18:17:35 -0000
@@ -900,7 +900,7 @@
         // Avoid NullPointerExceptions by creating a local reference.
         ComponentPeer currentPeer=peer;
         if (currentPeer != null)
-            currentPeer.setVisible(true);
+            currentPeer.show();
 
         // The JDK repaints the component before invalidating the parent.
         // So do we.
@@ -1598,16 +1596,18 @@
   public Dimension preferredSize()
   {
     if (prefSize == null)
-      if (peer == null)
-	return new Dimension(width, height);
-      else 
-        prefSize = peer.getPreferredSize();
+      {
+        if (peer == null)
+          prefSize = size();
+        else
+          prefSize = peer.getPreferredSize();
+      }
     return prefSize;
   }
 
   /**
    * Returns the component's minimum size.
-   *
+   * 
    * @return the component's minimum size
    * @see #getPreferredSize()
    * @see LayoutManager
Index: native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c
===================================================================
RCS file: /sources/classpath/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c,v
retrieving revision 1.63
diff -u -r1.63 gnu_java_awt_peer_gtk_GtkWindowPeer.c
--- native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c	15 Feb 2006 09:00:25 -0000	1.63
+++ native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c	15 Feb 2006 18:17:35 -0000
@@ -1394,6 +1394,32 @@
 }
 
 JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GtkWindowPeer_nativeSetLocation
+  (JNIEnv *env, jobject obj, jint x, jint y)
+{
+  gdk_threads_enter ();
+
+  Java_gnu_java_awt_peer_gtk_GtkWindowPeer_nativeSetLocationUnlocked
+    (env, obj, x, y);
+
+  gdk_threads_leave ();
+}
+
+JNIEXPORT void JNICALL
+Java_gnu_java_awt_peer_gtk_GtkWindowPeer_nativeSetLocationUnlocked
+  (JNIEnv *env, jobject obj, jint x, jint y)
+{
+  void *ptr;
+
+  ptr = NSA_GET_PTR (env, obj);
+
+  gtk_window_move (GTK_WINDOW(ptr), x, y);
+
+  if (GTK_WIDGET (ptr)->window != NULL)
+    gdk_window_move (GTK_WIDGET (ptr)->window, x, y);
+}
+
+JNIEXPORT void JNICALL
 Java_gnu_java_awt_peer_gtk_GtkWindowPeer_nativeSetBoundsUnlocked
   (JNIEnv *env, jobject obj, jint x, jint y, jint width, jint height)
 {

Reply via email to