> http://www.physto.se/~sven/pr24350.patch

I reverted my patch and applied Sven's patch for this bug. He had
implemented a new function to get the location for a window on the
screen.

2005-11-15  Lillian Angel  <[EMAIL PROTECTED]>

        * gnu/java/awt/peer/gtk/GtkComponentPeer.java
        (gtkWindowGetLocationOnScreen): Added declaration
        for native function.
        (getLocationOnScreen): Changed to handle 2 different cases.
        If the component is a window, gtkWindowGetLocationOnScreen is
        called; otherwise, gtkWidetGetLocationOnScreen.
        * include/gnu_java_awt_peer_gtk_GtkComponentPeer.h:
        Added signature for new function Java_gnu_java_awt_peer_         
        gtk_GtkComponentPeer_gtkWindowGetLocationOnScreen.
        * native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
        
(Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetGetLocationOnScreen):
        Implemented.

Index: gnu/java/awt/peer/gtk/GtkComponentPeer.java
===================================================================
RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/gtk/GtkComponentPeer.java,v
retrieving revision 1.97
diff -u -r1.97 GtkComponentPeer.java
--- gnu/java/awt/peer/gtk/GtkComponentPeer.java	14 Nov 2005 21:37:26 -0000	1.97
+++ gnu/java/awt/peer/gtk/GtkComponentPeer.java	15 Nov 2005 15:04:09 -0000
@@ -71,6 +71,7 @@
 import java.awt.image.VolatileImage;
 import java.awt.peer.ComponentPeer;
 import java.awt.peer.ContainerPeer;
+import java.awt.peer.WindowPeer;
 import java.util.Timer;
 import java.util.TimerTask;
 
@@ -98,6 +99,7 @@
   native int[] gtkWidgetGetBackground ();
   native void gtkWidgetGetDimensions (int[] dim);
   native void gtkWidgetGetPreferredDimensions (int[] dim);
+  native void gtkWindowGetLocationOnScreen (int[] point);
   native void gtkWidgetGetLocationOnScreen (int[] point);
   native void gtkWidgetSetCursor (int type);
   native void gtkWidgetSetCursorUnlocked (int type);
@@ -270,8 +272,11 @@
   public Point getLocationOnScreen () 
   { 
     int point[] = new int[2];
-    gtkWidgetGetLocationOnScreen (point);
-    return new Point (point[0] - insets.left, point[1] - insets.top);
+    if( this instanceof WindowPeer )
+      gtkWindowGetLocationOnScreen (point);
+    else
+      gtkWidgetGetLocationOnScreen (point);
+    return new Point (point[0], point[1]);
   }
 
   public Dimension getMinimumSize () 
Index: include/gnu_java_awt_peer_gtk_GtkComponentPeer.h
===================================================================
RCS file: /cvsroot/classpath/classpath/include/gnu_java_awt_peer_gtk_GtkComponentPeer.h,v
retrieving revision 1.19
diff -u -r1.19 gnu_java_awt_peer_gtk_GtkComponentPeer.h
--- include/gnu_java_awt_peer_gtk_GtkComponentPeer.h	25 Aug 2005 02:26:49 -0000	1.19
+++ include/gnu_java_awt_peer_gtk_GtkComponentPeer.h	15 Nov 2005 15:04:09 -0000
@@ -16,6 +16,7 @@
 JNIEXPORT jintArray JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetGetBackground (JNIEnv *env, jobject);
 JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetGetDimensions (JNIEnv *env, jobject, jintArray);
 JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetGetPreferredDimensions (JNIEnv *env, jobject, jintArray);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWindowGetLocationOnScreen (JNIEnv *env, jobject, jintArray);
 JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetGetLocationOnScreen (JNIEnv *env, jobject, jintArray);
 JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetCursor (JNIEnv *env, jobject, jint);
 JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetSetCursorUnlocked (JNIEnv *env, jobject, jint);
Index: native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c
===================================================================
RCS file: /cvsroot/classpath/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c,v
retrieving revision 1.56
diff -u -r1.56 gnu_java_awt_peer_gtk_GtkComponentPeer.c
--- native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c	25 Oct 2005 10:26:24 -0000	1.56
+++ native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkComponentPeer.c	15 Nov 2005 15:04:11 -0000
@@ -454,7 +454,7 @@
  * Find the origin of a widget's window.
  */
 JNIEXPORT void JNICALL 
-Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetGetLocationOnScreen
+Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWindowGetLocationOnScreen
   (JNIEnv * env, jobject obj, jintArray jpoint)
 {
   void *ptr;
@@ -467,11 +467,34 @@
 
   gdk_window_get_root_origin (GTK_WIDGET (ptr)->window, point, point+1);
 
-  if (!GTK_IS_CONTAINER (ptr))
-    {
-      *point += GTK_WIDGET(ptr)->allocation.x;
-      *(point+1) += GTK_WIDGET(ptr)->allocation.y;
-    }
+  (*env)->ReleaseIntArrayElements(env, jpoint, point, 0);
+
+  gdk_threads_leave ();
+}
+
+/*
+ * Find the origin of a widget
+ */
+JNIEXPORT void JNICALL 
+Java_gnu_java_awt_peer_gtk_GtkComponentPeer_gtkWidgetGetLocationOnScreen
+  (JNIEnv * env, jobject obj, jintArray jpoint)
+{
+  void *ptr;
+  jint *point;
+  GtkWidget *widget;
+
+  gdk_threads_enter ();
+
+  ptr = NSA_GET_PTR (env, obj);
+  point = (*env)->GetIntArrayElements (env, jpoint, 0);
+
+  widget = GTK_WIDGET(ptr);
+  while(gtk_widget_get_parent(widget) != NULL)
+    widget = gtk_widget_get_parent(widget);
+  gdk_window_get_position (GTK_WIDGET(widget)->window, point, point+1);
+
+  *point += GTK_WIDGET(ptr)->allocation.x;
+  *(point+1) += GTK_WIDGET(ptr)->allocation.y;
 
   (*env)->ReleaseIntArrayElements(env, jpoint, point, 0);
 
_______________________________________________
Classpath-patches mailing list
Classpath-patches@gnu.org
http://lists.gnu.org/mailman/listinfo/classpath-patches

Reply via email to