[kaffe] CVS kaffe (riccardo): enhanced methods to match classpath
Kaffe CVS
cvs-commits at kaffe.org
Wed Jul 19 09:26:15 PDT 2006
PatchSet 7365
Date: 2006/07/19 16:12:03
Author: riccardo
Branch: HEAD
Tag: (none)
Log:
enhanced methods to match classpath
Members:
ChangeLog:1.4869->1.4870
libraries/javalib/awt-implementations/kaffe/java/awt/EventQueue.java:1.3->1.4
libraries/javalib/awt-implementations/kaffe/java/awt/Window.java:1.8->1.9
Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.4869 kaffe/ChangeLog:1.4870
--- kaffe/ChangeLog:1.4869 Tue Jul 18 10:50:32 2006
+++ kaffe/ChangeLog Wed Jul 19 16:12:03 2006
@@ -1,3 +1,9 @@
+2006-07-19 Riccardo Mottola <riccardo at kaffe.org>
+
+ * libraries/javalib/awt-implementations/kaffe/java/awt/EventQueue.java
+ libraries/javalib/awt-implementations/kaffe/java/awt/Window.java:
+ enhanced methods to match classpath
+
2006-07-18 Dalibor Topic <robilad at kaffe.org>
* libraries/javalib/external/classpath: Resynced.
Index: kaffe/libraries/javalib/awt-implementations/kaffe/java/awt/EventQueue.java
diff -u kaffe/libraries/javalib/awt-implementations/kaffe/java/awt/EventQueue.java:1.3 kaffe/libraries/javalib/awt-implementations/kaffe/java/awt/EventQueue.java:1.4
--- kaffe/libraries/javalib/awt-implementations/kaffe/java/awt/EventQueue.java:1.3 Sun Jan 29 19:18:26 2006
+++ kaffe/libraries/javalib/awt-implementations/kaffe/java/awt/EventQueue.java Wed Jul 19 16:12:11 2006
@@ -15,6 +15,8 @@
package java.awt;
+import java.awt.event.ActionEvent;
+import java.awt.event.InputEvent;
import java.awt.event.FocusEvent;
import java.awt.event.PaintEvent;
import java.awt.event.InvocationEvent;
@@ -26,6 +28,11 @@
AWTEvent localQueue;
AWTEvent localEnd;
+ private AWTEvent currentEvent;
+ private long lastWhen = System.currentTimeMillis();
+
+ private EventDispatchThread dispatchThread = new EventDispatchThread(this);
+
static {
// force static init of AWTEvent (need that for native event system
// initialization)
@@ -339,10 +346,67 @@
}
}
- /* taken from GNU Classpath */
+ /**
+ * Dispatches an event. The manner in which the event is dispatched depends
+ * upon the type of the event and the type of the event's source object.
+ *
+ * @exception NullPointerException If event is null.
+ */
+ protected void dispatchEvent(AWTEvent evt)
+ {
+ currentEvent = evt;
+
+ if (evt instanceof InputEvent)
+ lastWhen = ((InputEvent) evt).getWhen();
+ else if (evt instanceof ActionEvent)
+ lastWhen = ((ActionEvent) evt).getWhen();
+ else if (evt instanceof InvocationEvent)
+ lastWhen = ((InvocationEvent) evt).getWhen();
+
+ if (evt instanceof ActiveEvent)
+ {
+ ActiveEvent active_evt = (ActiveEvent) evt;
+ active_evt.dispatch();
+ }
+ else
+ {
+ Object source = evt.getSource();
+
+ if (source instanceof Component)
+ {
+ Component srccmp = (Component) source;
+ srccmp.dispatchEvent(evt);
+ }
+ else if (source instanceof MenuComponent)
+ {
+ MenuComponent srccmp = (MenuComponent) source;
+ srccmp.dispatchEvent(evt);
+ }
+ }
+ }
+
+ /**
+ * Returns the timestamp of the most recent event that had a timestamp, or
+ * the initialization time of the event queue if no events have been fired.
+ * At present, only <code>InputEvent</code>s, <code>ActionEvent</code>s,
+ * <code>InputMethodEvent</code>s, and <code>InvocationEvent</code>s have
+ * timestamps, but this may be added to other events in future versions.
+ * If this is called by the event dispatching thread, it can be any
+ * (sequential) value, but to other threads, the safest bet is to return
+ * System.currentTimeMillis().
+ *
+ * @return the most recent timestamp
+ * @see InputEvent#getWhen()
+ * @see ActionEvent#getWhen()
+ * @see InvocationEvent#getWhen()
+ * @see InputMethodEvent#getWhen()
+ * @since 1.4
+ */
public static long getMostRecentEventTime()
{
- // XXX For now, this ONLY does the current time.
- return System.currentTimeMillis();
+ EventQueue eq = Toolkit.getDefaultToolkit().getSystemEventQueue();
+ if (Thread.currentThread() != eq.dispatchThread)
+ return System.currentTimeMillis();
+ return eq.lastWhen;
}
}
Index: kaffe/libraries/javalib/awt-implementations/kaffe/java/awt/Window.java
diff -u kaffe/libraries/javalib/awt-implementations/kaffe/java/awt/Window.java:1.8 kaffe/libraries/javalib/awt-implementations/kaffe/java/awt/Window.java:1.9
--- kaffe/libraries/javalib/awt-implementations/kaffe/java/awt/Window.java:1.8 Fri May 12 14:38:38 2006
+++ kaffe/libraries/javalib/awt-implementations/kaffe/java/awt/Window.java Wed Jul 19 16:12:11 2006
@@ -18,8 +18,11 @@
import java.awt.event.FocusEvent;
import java.awt.event.WindowEvent;
+import java.awt.event.WindowFocusListener;
import java.awt.event.WindowListener;
+import java.awt.event.WindowStateListener;
import java.awt.peer.ComponentPeer;
+import java.util.Vector;
import gnu.classpath.Pointer;
@@ -33,9 +36,23 @@
static Window dummy = new Window();
private static int counter;
final private static long serialVersionUID = 4497834738069338734L;
+ /** @since 1.2 */
+ private int state = 0;
/** @since 1.4 */
private boolean focusableWindowState = true;
+ // A list of other top-level windows owned by this window.
+ private transient Vector ownedWindows = new Vector();
+
+ private transient WindowListener windowListener;
+ private transient WindowFocusListener windowFocusListener;
+ private transient WindowStateListener windowStateListener;
+ private transient GraphicsConfiguration graphicsConfiguration;
+
+ private transient boolean shown;
+
+ // This is package-private to avoid an accessor method.
+ transient Component windowFocusOwner;
Window () {
// windows aren't visible per se, but they are exposed, colored and fontified
flags = (IS_PARENT_SHOWING | IS_BG_COLORED | IS_FG_COLORED | IS_FONTIFIED);
@@ -209,6 +226,38 @@
validate();
}
+ /**
+ * Returns the child component of this window that would receive
+ * focus if this window were to become focused. If the window
+ * already has the top-level focus, then this method returns the
+ * same component as getFocusOwner. If no child component has
+ * requested focus within the window, then the initial focus owner
+ * is returned. If this is a non-focusable window, this method
+ * returns null.
+ *
+ * @return the child component of this window that most recently had
+ * the focus, or <code>null</code>
+ * @since 1.4
+ */
+ public Component getMostRecentFocusOwner ()
+ {
+ return windowFocusOwner;
+ }
+
+ /**
+ * Set the focus owner for this window. This method is used to
+ * remember which component was focused when this window lost
+ * top-level focus, so that when it regains top-level focus the same
+ * child component can be refocused.
+ *
+ * @param windowFocusOwner the component in this window that owns
+ * the focus.
+ */
+ void setFocusOwner (Component windowFocusOwner)
+ {
+ this.windowFocusOwner = windowFocusOwner;
+ }
+
void process ( FocusEvent event ) {
Component c;
@@ -404,7 +453,6 @@
if ( nativeData != null ) Toolkit.wndToFront( nativeData);
}
-// TODO this is only a stub
public void setLocationRelativeTo(Component c) {
int x = 0;
int y = 0;
More information about the kaffe
mailing list