[cp-patches] FYI: Implement getMousePosition

2007-11-27 Thread Thomas Fitzsimmons

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 

Re: [cp-patches] FYI: more CopyOnWriteArrayList fixlets

2007-11-27 Thread Mario Torre

Il giorno lun, 26/11/2007 alle 09.29 +, Ian Rogers ha scritto:

 Looking at the current status, TimeUnitTest looks to be failing as the 
 version of JSR166 in the external directory is old enough not to be 
 declaring TimeUnit.MILLISECONDS:
 
 http://www.cs.man.ac.uk/~irogers/jsr166/production/jsr166-tck/TimeUnitTest.default-output.txt
 
 I wonder if some of the other failures could be down to an old JSR 166. 
 What's the protocol to update the code in the external directory?

I think so. CopyOnWriteArrayList was also written by Doug Lea, I have no
reason to believe he has not released it under public domain like the
rest of the code (I admit I have not checked, though), so I think that
we simply ship an old version. Being it in the external I would just
download the new one (if any) and go with it.

Also, if that means to remove CopyOnWriteArrayList also, well, go for
it :)

Mark? hints?

Thanks,
Mario
-- 
Lima Software - http://www.limasoftware.net/
GNU Classpath Developer - http://www.classpath.org/
Fedora Ambassador - http://fedoraproject.org/wiki/MarioTorre
Jabber: [EMAIL PROTECTED]
pgp key: http://subkeys.pgp.net/ PGP Key ID: 80F240CF
Fingerprint: BA39 9666 94EC 8B73 27FA  FC7C 4086 63E3 80F2 40CF

Please, support open standards:
http://opendocumentfellowship.org/petition/
http://www.nosoftwarepatents.com/


signature.asc
Description: Questa รจ una parte del messaggio	firmata digitalmente


[commit-cp] classpath ChangeLog gnu/java/awt/peer/gtk/GdkGr...

2007-11-27 Thread Thomas Fitzsimmons
CVSROOT:/sources/classpath
Module name:classpath
Changes by: Thomas Fitzsimmons fitzsim07/11/27 22:07:00

Modified files:
.  : ChangeLog 
gnu/java/awt/peer/gtk: GdkGraphicsEnvironment.java 
   GtkComponentPeer.java 
   GtkMouseInfoPeer.java GtkWindowPeer.java 
include: gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.h 
java/awt   : Component.java Container.java 
native/jni/gtk-peer: 
 gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.c 
 gnu_java_awt_peer_gtk_GtkWindowPeer.c 

Log message:
2007-11-27  Thomas Fitzsimmons  [EMAIL PROTECTED]

* gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java,

native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.c
(isWindowUnderMouse): New method.
* include/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.h:
Regenerate.
* gnu/java/awt/peer/gtk/GtkComponentPeer.java
(getLocationOnScreen): Move WindowPeer section to...
* gnu/java/awt/peer/gtk/GtkWindowPeer.java 
(getLocationOnScreen):
New method.
* gnu/java/awt/peer/gtk/GtkMouseInfoPeer.java
(isWindowUnderMouse): Implement.
* java/awt/Component.java (getMousePosition): New method.
(getMousePositionHelper): Likewise.
(mouseOverComponent): Likewise.
* java/awt/Container.java (getMousePosition): New method.
(mouseOverComponent): Likewise.
* native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c:
Revert 2007-09-11 changes.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpathr1=1.9441r2=1.9442
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.java?cvsroot=classpathr1=1.17r2=1.18
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/awt/peer/gtk/GtkComponentPeer.java?cvsroot=classpathr1=1.129r2=1.130
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/awt/peer/gtk/GtkMouseInfoPeer.java?cvsroot=classpathr1=1.3r2=1.4
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/java/awt/peer/gtk/GtkWindowPeer.java?cvsroot=classpathr1=1.61r2=1.62
http://cvs.savannah.gnu.org/viewcvs/classpath/include/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.h?cvsroot=classpathr1=1.6r2=1.7
http://cvs.savannah.gnu.org/viewcvs/classpath/java/awt/Component.java?cvsroot=classpathr1=1.156r2=1.157
http://cvs.savannah.gnu.org/viewcvs/classpath/java/awt/Container.java?cvsroot=classpathr1=1.111r2=1.112
http://cvs.savannah.gnu.org/viewcvs/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphicsEnvironment.c?cvsroot=classpathr1=1.9r2=1.10
http://cvs.savannah.gnu.org/viewcvs/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkWindowPeer.c?cvsroot=classpathr1=1.73r2=1.74