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:
parent
0ec479dcfb
commit
3898fe8e7c
34 changed files with 196 additions and 19 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue