Hi,
I committed this patch to implement Component.getMousePosition() and
Container.getMousePosition(boolean).
I also reverted Roman's 2007-09-11 changes to
gnu_java_awt_peer_gtk_GtkWindowPeer.c. As I mentioned here:
http://developer.classpath.org/pipermail/classpath-patches/2007-September/005610.html
the change breaks window inset calculations. To accomplish Roman's original
goal, the reverted sections should be ifdef'd based on the presence or absence of X.
I've attached a test case that demonstrates the new getMousePosition methods.
It also demonstrates the window inset breakage (compare screenshots of IcedTea's
and GNU Classpath's button placement relative to the window frame).
Tom
Index: gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java
===
RCS file: /sources/classpath/classpath/gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java,v
retrieving revision 1.17
diff -u -r1.17 GdkGraphicsEnvironment.java
--- gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java 25 Apr 2007 14:53:03 - 1.17
+++ gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java 27 Nov 2007 21:51:55 -
@@ -155,6 +155,7 @@
* Used by GtkMouseInfoPeer.
*/
native int[] getMouseCoordinates();
+ native boolean isWindowUnderMouse(GtkWindowPeer windowPeer);
public WritableRaster createRaster(ColorModel cm, SampleModel sm)
{
Index: gnu/java/awt/peer/gtk/GtkComponentPeer.java
===
RCS file: /sources/classpath/classpath/gnu/java/awt/peer/gtk/GtkComponentPeer.java,v
retrieving revision 1.129
diff -u -r1.129 GtkComponentPeer.java
--- gnu/java/awt/peer/gtk/GtkComponentPeer.java 23 Aug 2007 20:09:53 - 1.129
+++ gnu/java/awt/peer/gtk/GtkComponentPeer.java 27 Nov 2007 21:51:55 -
@@ -253,20 +253,10 @@
public Point getLocationOnScreen ()
{
int point[] = new int[2];
-if( this instanceof WindowPeer )
- {
-if (Thread.currentThread() == GtkMainThread.mainThread)
- gtkWindowGetLocationOnScreenUnlocked (point);
-else
- gtkWindowGetLocationOnScreen (point);
- }
+if (Thread.currentThread() == GtkMainThread.mainThread)
+gtkWidgetGetLocationOnScreenUnlocked (point);
else
- {
-if (Thread.currentThread() == GtkMainThread.mainThread)
- gtkWidgetGetLocationOnScreenUnlocked (point);
-else
- gtkWidgetGetLocationOnScreen (point);
- }
+gtkWidgetGetLocationOnScreen (point);
return new Point (point[0], point[1]);
}
Index: gnu/java/awt/peer/gtk/GtkMouseInfoPeer.java
===
RCS file: /sources/classpath/classpath/gnu/java/awt/peer/gtk/GtkMouseInfoPeer.java,v
retrieving revision 1.3
diff -u -r1.3 GtkMouseInfoPeer.java
--- gnu/java/awt/peer/gtk/GtkMouseInfoPeer.java 12 Feb 2007 21:39:20 - 1.3
+++ gnu/java/awt/peer/gtk/GtkMouseInfoPeer.java 27 Nov 2007 21:51:55 -
@@ -60,17 +60,7 @@
public boolean isWindowUnderMouse(Window w)
{
-int[] coords = gde.getMouseCoordinates();
-GraphicsDevice[] gds = gde.getScreenDevices();
-
-// Check if the screen of the Window and the cursor match
-if( gds[ coords[0] ] != w.getGraphicsConfiguration().getDevice() )
- return false;
-
-// Return the bounds-check.
-Point p = w.getLocationOnScreen();
-return (coords[1] = p.x coords[1] p.x + w.getWidth()
- coords[2] = p.y coords[2] p.y + w.getHeight() );
-}
+return gde.isWindowUnderMouse((GtkWindowPeer) w.getPeer());
+ }
}
Index: gnu/java/awt/peer/gtk/GtkWindowPeer.java
===
RCS file: /sources/classpath/classpath/gnu/java/awt/peer/gtk/GtkWindowPeer.java,v
retrieving revision 1.61
diff -u -r1.61 GtkWindowPeer.java
--- gnu/java/awt/peer/gtk/GtkWindowPeer.java 22 Jun 2007 14:27:57 - 1.61
+++ gnu/java/awt/peer/gtk/GtkWindowPeer.java 27 Nov 2007 21:51:55 -
@@ -45,6 +45,7 @@
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.KeyboardFocusManager;
+import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Window;
import java.awt.event.ComponentEvent;
@@ -392,6 +393,16 @@
clickCount, popupTrigger);
}
+ public Point getLocationOnScreen()
+ {
+int point[] = new int[2];
+if (Thread.currentThread() == GtkMainThread.mainThread)
+ gtkWindowGetLocationOnScreenUnlocked(point);
+else
+ gtkWindowGetLocationOnScreen(point);
+return new Point(point[0], point[1]);
+ }
+
// We override this to keep it in sync with our internal
// representation.
public Rectangle getBounds()
Index: include/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.h
===
RCS file: /sources/classpath/classpath/include/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.h,v
retrieving revision 1.6
diff -u