2007-12-05 Thomas Fitzsimmons <fitzsim@redhat.com>

* 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.
	* classpath/lib/java/awt/Component.class,
	classpath/lib/java/awt/Component$BltBufferStrategy.class,
	classpath/lib/java/awt/Container$GfxPaintAllVisitor.class,
	classpath/lib/java/awt/Component$AccessibleAWTComponent
	$AccessibleAWTFocusHandler.class,
	classpath/lib/java/awt/Component$FlipBufferStrategy.class,
	classpath/lib/java/awt/Container$GfxVisitor.class,
	classpath/lib/java/awt/Component$AccessibleAWTComponent
	$AccessibleAWTComponentHandler.class,
	classpath/lib/java/awt/Container$AccessibleAWTContainer
	$AccessibleContainerHandler.class,
	classpath/lib/java/awt/Container.class,
	classpath/lib/java/awt/Container$AccessibleAWTContainer.class,
	classpath/lib/java/awt/Container$GfxPrintAllVisitor.class,
	classpath/lib/java/awt/Component$AccessibleAWTComponent.class,
	classpath/lib/java/awt/Container$GfxPaintVisitor.class,
	classpath/lib/java/awt/Container$GfxPrintVisitor.class,
	classpath/lib/java/awt/Component$HeavyweightInLightweightListener.class,
	classpath/lib/gnu/java/awt/peer/gtk/GtkComponentPeer.class,
	classpath/lib/gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.class,
	classpath/lib/gnu/java/awt/peer/gtk/GtkMouseInfoPeer.class,
	classpath/lib/gnu/java/awt/peer/gtk/GtkWindowPeer.class,
	classpath/lib/gnu/java/awt/peer/gtk/GtkComponentPeer
	$RepaintTimerTask.class:
	Regenerate.

2007-12-05  Thomas Fitzsimmons  <fitzsim@redhat.com>

	* gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.h: Regenerate.
	* gnu/java/awt/peer/gtk/GtkWindowPeer.h: Likewise.
	* java/awt/Component.h: Likewise.
	* java/awt/Container.h: Likewise.

From-SVN: r130627
This commit is contained in:
Thomas Fitzsimmons 2007-12-05 18:04:44 +00:00 committed by Thomas Fitzsimmons
parent 0ec479dcfb
commit 3898fe8e7c
34 changed files with 196 additions and 19 deletions

View File

@ -1,3 +1,10 @@
2007-12-05 Thomas Fitzsimmons <fitzsim@redhat.com>
* gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.h: Regenerate.
* gnu/java/awt/peer/gtk/GtkWindowPeer.h: Likewise.
* java/awt/Component.h: Likewise.
* java/awt/Container.h: Likewise.
2007-11-05 H.J. Lu <hongjiu.lu@intel.com>
* configure.ac: Don't run config-ml.in directly.

View File

@ -1,3 +1,47 @@
2007-12-05 Thomas Fitzsimmons <fitzsim@redhat.com>
* 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.
* classpath/lib/java/awt/Component.class,
classpath/lib/java/awt/Component$BltBufferStrategy.class,
classpath/lib/java/awt/Container$GfxPaintAllVisitor.class,
classpath/lib/java/awt/Component$AccessibleAWTComponent
$AccessibleAWTFocusHandler.class,
classpath/lib/java/awt/Component$FlipBufferStrategy.class,
classpath/lib/java/awt/Container$GfxVisitor.class,
classpath/lib/java/awt/Component$AccessibleAWTComponent
$AccessibleAWTComponentHandler.class,
classpath/lib/java/awt/Container$AccessibleAWTContainer
$AccessibleContainerHandler.class,
classpath/lib/java/awt/Container.class,
classpath/lib/java/awt/Container$AccessibleAWTContainer.class,
classpath/lib/java/awt/Container$GfxPrintAllVisitor.class,
classpath/lib/java/awt/Component$AccessibleAWTComponent.class,
classpath/lib/java/awt/Container$GfxPaintVisitor.class,
classpath/lib/java/awt/Container$GfxPrintVisitor.class,
classpath/lib/java/awt/Component$HeavyweightInLightweightListener.class,
classpath/lib/gnu/java/awt/peer/gtk/GtkComponentPeer.class,
classpath/lib/gnu/java/awt/peer/gtk/GdkGraphicsEnvironment.class,
classpath/lib/gnu/java/awt/peer/gtk/GtkMouseInfoPeer.class,
classpath/lib/gnu/java/awt/peer/gtk/GtkWindowPeer.class,
classpath/lib/gnu/java/awt/peer/gtk/GtkComponentPeer
$RepaintTimerTask.class:
Regenerate.
2007-10-01 Alexandre Oliva <aoliva@redhat.com>
* scripts/check_jni_methods.sh: Don't depend on diff -b ignoring

View File

@ -155,6 +155,7 @@ public class GdkGraphicsEnvironment extends ClasspathGraphicsEnvironment
* Used by GtkMouseInfoPeer.
*/
native int[] getMouseCoordinates();
native boolean isWindowUnderMouse(GtkWindowPeer windowPeer);
public WritableRaster createRaster(ColorModel cm, SampleModel sm)
{

View File

@ -76,7 +76,6 @@ import java.awt.image.VolatileImage;
import java.awt.peer.ComponentPeer;
import java.awt.peer.ContainerPeer;
import java.awt.peer.LightweightPeer;
import java.awt.peer.WindowPeer;
import java.util.Timer;
import java.util.TimerTask;
@ -251,10 +250,7 @@ public class GtkComponentPeer extends GtkGenericPeer
public Point getLocationOnScreen ()
{
int point[] = new int[2];
if( this instanceof WindowPeer )
gtkWindowGetLocationOnScreen (point);
else
gtkWidgetGetLocationOnScreen (point);
gtkWidgetGetLocationOnScreen (point);
return new Point (point[0], point[1]);
}

View File

@ -60,17 +60,7 @@ public class GtkMouseInfoPeer implements MouseInfoPeer
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());
}
}

View File

@ -45,6 +45,7 @@ import java.awt.Font;
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,13 @@ public class GtkWindowPeer extends GtkContainerPeer
clickCount, popupTrigger);
}
public Point getLocationOnScreen()
{
int point[] = new int[2];
gtkWindowGetLocationOnScreen(point);
return new Point(point[0], point[1]);
}
// We override this to keep it in sync with our internal
// representation.
public Rectangle getBounds()

View File

@ -1,10 +1,10 @@
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
#ifndef __gnu_java_awt_peer_gtk_GdkGraphicsEnvironment__
#define __gnu_java_awt_peer_gtk_GdkGraphicsEnvironment__
#include <jni.h>
#ifdef __cplusplus
extern "C"
{
@ -17,6 +17,7 @@ JNIEXPORT jobject JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment_nati
JNIEXPORT jint JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment_nativeGetNumFontFamilies (JNIEnv *env, jobject);
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment_nativeGetFontFamilies (JNIEnv *env, jobject, jobjectArray);
JNIEXPORT jintArray JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment_getMouseCoordinates (JNIEnv *env, jobject);
JNIEXPORT jboolean JNICALL Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment_isWindowUnderMouse (JNIEnv *env, jobject, jobject);
#ifdef __cplusplus
}

View File

@ -5833,6 +5833,62 @@ p * <li>the set of backward traversal keys
return visible;
}
/**
* Returns the mouse pointer position relative to this Component's
* top-left corner.
*
* @return relative mouse pointer position
*
* @throws HeadlessException if in a headless environment
*/
public Point getMousePosition() throws HeadlessException
{
return getMousePositionHelper(true);
}
Point getMousePositionHelper(boolean allowChildren) throws HeadlessException
{
if (GraphicsEnvironment.isHeadless())
throw new HeadlessException("can't get mouse position"
+ " in headless environment");
if (!isShowing())
return null;
Component parent = this;
int windowRelativeXOffset = 0;
int windowRelativeYOffset = 0;
while (parent != null && !(parent instanceof Window))
{
windowRelativeXOffset += parent.getX();
windowRelativeYOffset += parent.getY();
parent = parent.getParent();
}
if (parent == null)
return null;
Window window = (Window) parent;
if (!Toolkit.getDefaultToolkit()
.getMouseInfoPeer().isWindowUnderMouse(window))
return null;
PointerInfo info = MouseInfo.getPointerInfo();
Point mouseLocation = info.getLocation();
Point windowLocation = window.getLocationOnScreen();
int x = mouseLocation.x - windowLocation.x;
int y = mouseLocation.y - windowLocation.y;
if (!mouseOverComponent(window.getComponentAt(x, y), allowChildren))
return null;
return new Point(x - windowRelativeXOffset, y - windowRelativeYOffset);
}
boolean mouseOverComponent(Component component, boolean allowChildren)
{
return component == this;
}
/**
* This method is used to implement transferFocus(). CHILD is the child
* making the request. This is overridden by Container; when called for an

View File

@ -1097,6 +1097,33 @@ public class Container extends Component
return locate (x, y);
}
/**
* Returns the mouse pointer position relative to this Container's
* top-left corner. If allowChildren is false, the mouse pointer
* must be directly over this container. If allowChildren is true,
* the mouse pointer may be over this container or any of its
* descendents.
*
* @param allowChildren true to allow descendents, false if pointer
* must be directly over Container.
*
* @return relative mouse pointer position
*
* @throws HeadlessException if in a headless environment
*/
public Point getMousePosition(boolean allowChildren) throws HeadlessException
{
return super.getMousePositionHelper(allowChildren);
}
boolean mouseOverComponent(Component component, boolean allowChildren)
{
if (allowChildren)
return isAncestorOf(component);
else
return component == this;
}
/**
* Returns the component located at the specified point. This is done
* by checking whether or not a child component claims to contain this

View File

@ -263,3 +263,37 @@ Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment_getMouseCoordinates
return retArray;
}
JNIEXPORT jboolean JNICALL
Java_gnu_java_awt_peer_gtk_GdkGraphicsEnvironment_isWindowUnderMouse
(JNIEnv *env, jobject obj, jobject windowPeer)
{
GdkDisplay *display = NULL;
gint x = 0;
gint y = 0;
GtkWidget *windowToTest = NULL;
GdkWindow *windowAtPointer = NULL;
jboolean retVal = JNI_FALSE;
display = (GdkDisplay *) gtkpeer_get_display (env, obj);
g_assert (display != NULL);
windowToTest = (GtkWidget *) gtkpeer_get_widget (env, windowPeer);
gdk_threads_enter ();
windowAtPointer = gdk_display_get_window_at_pointer (display, &x, &y);
while (windowAtPointer
&& windowAtPointer != windowToTest->window)
windowAtPointer = gdk_window_get_parent (windowAtPointer);
gdk_threads_leave ();
if (windowAtPointer)
retVal = JNI_TRUE;
else
retVal = JNI_FALSE;
return retVal;
}

View File

@ -27,6 +27,7 @@ extern "Java"
{
class GdkGraphicsEnvironment;
class GdkScreenGraphicsDevice;
class GtkWindowPeer;
}
}
}
@ -77,6 +78,7 @@ public:
virtual JArray< ::java::lang::String * > * getAvailableFontFamilyNames(::java::util::Locale *);
public: // actually package-private
virtual JArray< jint > * getMouseCoordinates();
virtual jboolean isWindowUnderMouse(::gnu::java::awt::peer::gtk::GtkWindowPeer *);
public:
virtual ::java::awt::image::WritableRaster * createRaster(::java::awt::image::ColorModel *, ::java::awt::image::SampleModel *);
private:

View File

@ -32,6 +32,7 @@ extern "Java"
class Component;
class Dialog;
class Graphics;
class Point;
class Rectangle;
class Window;
}
@ -101,6 +102,7 @@ public:
public: // actually protected
virtual void postMouseEvent(jint, jlong, jint, jint, jint, jint, jboolean);
public:
virtual ::java::awt::Point * getLocationOnScreen();
virtual ::java::awt::Rectangle * getBounds();
virtual void updateIconImages();
virtual void updateMinimumSize();

View File

@ -354,6 +354,11 @@ public: // actually package-private
virtual void dispatchEventImpl(::java::awt::AWTEvent *);
virtual jboolean eventTypeEnabled(jint);
virtual jboolean isHierarchyVisible();
public:
virtual ::java::awt::Point * getMousePosition();
public: // actually package-private
virtual ::java::awt::Point * getMousePositionHelper(jboolean);
virtual jboolean mouseOverComponent(::java::awt::Component *, jboolean);
virtual ::java::awt::Component * findNextFocusComponent(::java::awt::Component *);
private:
void readObject(::java::io::ObjectInputStream *);

View File

@ -97,6 +97,10 @@ public: // actually protected
public:
virtual void deliverEvent(::java::awt::Event *);
virtual ::java::awt::Component * getComponentAt(jint, jint);
virtual ::java::awt::Point * getMousePosition(jboolean);
public: // actually package-private
virtual jboolean mouseOverComponent(::java::awt::Component *, jboolean);
public:
virtual ::java::awt::Component * locate(jint, jint);
virtual ::java::awt::Component * getComponentAt(::java::awt::Point *);
virtual ::java::awt::Component * findComponentAt(jint, jint);