On Tue, 2006-02-14 at 14:41 -0500, Lillian Angel wrote:
> When the location of a Dialog is changed before it is visible, it does
> not take any effect. The Dialog would appear at some arbitrary location.
> This is now fixed.
> 
> 2006-02-14  Lillian Angel  <[EMAIL PROTECTED]>
> 
>         * gnu/java/awt/peer/gtk/GtkDialogPeer.java
>         (setVisible): New method to override super. Need to set the
>         native bounds of the component, so it appears at the
>         correct location.
> 

This patch caused some problems, because if the bounds is set before we
make the Dialog visible, it could be resized to 0x0. We just want to
make sure that the location is correct for all Windows. I made this
patch, but I would like approval before I commit it.

Thanks
Lillian

2006-02-14  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.
        * 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.

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	14 Feb 2006 22:43:17 -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	14 Feb 2006 22:43:17 -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	14 Feb 2006 22:43:17 -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	14 Feb 2006 22:43:19 -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.
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.62
diff -u -r1.62 gnu_java_awt_peer_gtk_GtkWindowPeer.c
--- native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c	15 Nov 2005 22:50:53 -0000	1.62
+++ native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c	14 Feb 2006 22:43:20 -0000
@@ -1393,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