[kaffe] CVS kaffe (dalibor): AWT clipping and mouse event handling fixes
Fabien Renaud
renaud at nentec.de
Thu Jul 8 03:12:44 PDT 2004
Kaffe CVS wrote:
>PatchSet 4902
>Date: 2004/07/07 12:58:43
>Author: dalibor
>Branch: HEAD
>Tag: (none)
>Log:
>AWT clipping and mouse event handling fixes
>
>2004-07-07 Jim Huang <jserv at kaffe.org>
>
> * libraries/javalib/java/awt/Graphics.java:
> * libraries/javalib/java/awt/Image.java:
> * libraries/javalib/java/awt/NativeGraphics.java:
> * libraries/javalib/java/awt/PSGraphics.java:
> Adapt the AWT clipping fixing patch from
> Benja Fallenstein <b.fallenstein at gmx.de>.
> Update the copyright notice.
>
> * libraries/javalib/java/awt/event/MouseEvent.java
> (MouseEvent)
> (getButton):
> Adapt the Java 1.4 features to java.awt.event.MouseEvent
> patch from Benja Fallenstein <b.fallenstein at gmx.de>.
> This only affects MouseEvent via making the old
> constructor do the work of figuring out which button
> it is from the modifiers list.
> Update the copyright notice.
>
>Members:
> ChangeLog:1.2468->1.2469
> libraries/javalib/java/awt/Graphics.java:1.7->1.8
> libraries/javalib/java/awt/Image.java:1.17->1.18
> libraries/javalib/java/awt/NativeGraphics.java:1.11->1.12
> libraries/javalib/java/awt/PSGraphics.java:1.4->1.5
> libraries/javalib/java/awt/event/MouseEvent.java:1.9->1.10
>
>Index: kaffe/ChangeLog
>diff -u kaffe/ChangeLog:1.2468 kaffe/ChangeLog:1.2469
>--- kaffe/ChangeLog:1.2468 Wed Jul 7 08:46:38 2004
>+++ kaffe/ChangeLog Wed Jul 7 12:58:43 2004
>@@ -1,3 +1,23 @@
>+2004-07-07 Jim Huang <jserv at kaffe.org>
>+
>+ * libraries/javalib/java/awt/Graphics.java:
>+ * libraries/javalib/java/awt/Image.java:
>+ * libraries/javalib/java/awt/NativeGraphics.java:
>+ * libraries/javalib/java/awt/PSGraphics.java:
>+ Adapt the AWT clipping fixing patch from
>+ Benja Fallenstein <b.fallenstein at gmx.de>.
>+ Update the copyright notice.
>+
>+ * libraries/javalib/java/awt/event/MouseEvent.java
>+ (MouseEvent)
>+ (getButton):
>+ Adapt the Java 1.4 features to java.awt.event.MouseEvent
>+ patch from Benja Fallenstein <b.fallenstein at gmx.de>.
>+ This only affects MouseEvent via making the old
>+ constructor do the work of figuring out which button
>+ it is from the modifiers list.
>+ Update the copyright notice.
>+
> 2004-07-07 Guilhem Lavaux <guilhem at kaffe.org>
>
> * WHATNEW: Added some news line.
>Index: kaffe/libraries/javalib/java/awt/Graphics.java
>diff -u kaffe/libraries/javalib/java/awt/Graphics.java:1.7 kaffe/libraries/javalib/java/awt/Graphics.java:1.8
>--- kaffe/libraries/javalib/java/awt/Graphics.java:1.7 Wed Feb 10 21:34:31 1999
>+++ kaffe/libraries/javalib/java/awt/Graphics.java Wed Jul 7 12:58:45 2004
>@@ -1,8 +1,4 @@
>-package java.awt;
>-
>-import java.awt.image.ImageObserver;
>-
>-/**
>+/*
> * Graphics - abstract draw object
> *
> * Note that this had to be changed into an abstract class with *some*
>@@ -12,11 +8,19 @@
> * Copyright (c) 1998
> * Transvirtual Technologies, Inc. All rights reserved.
> *
>+ * Copyright (c) 2004
>+ * The Kaffe.org's developers. See ChangeLog for details.
>+ *
> * See the file "license.terms" for information on usage and redistribution
> * of this file.
> *
> * @author P.C.Mehlitz
> */
>+
>+package java.awt;
>+
>+import java.awt.image.ImageObserver;
>+
> abstract public class Graphics
> {
> protected Graphics () {
>@@ -171,7 +175,12 @@
>
> abstract public Shape getClip ();
>
>-abstract public Rectangle getClipBounds();
>+public Rectangle getClipBounds() {
>+ // Another return object which is modified by Swing, causing more garbage
>+ return (getClipBounds(new Rectangle()));
>+}
>+
>+abstract public Rectangle getClipBounds(Rectangle rect);
>
> int getClipHeight () {
> // this is only here to be resolved in concrete subclasses
>Index: kaffe/libraries/javalib/java/awt/Image.java
>diff -u kaffe/libraries/javalib/java/awt/Image.java:1.17 kaffe/libraries/javalib/java/awt/Image.java:1.18
>--- kaffe/libraries/javalib/java/awt/Image.java:1.17 Wed Jun 9 17:40:16 2004
>+++ kaffe/libraries/javalib/java/awt/Image.java Wed Jul 7 12:58:45 2004
>@@ -1,3 +1,16 @@
>+/*
>+ * Copyright (c) 1998
>+ * Transvirtual Technologies, Inc. All rights reserved.
>+ *
>+ * Copyright (c) 2004
>+ * The Kaffe.org's developers. See ChangeLog for details.
>+ *
>+ * See the file "license.terms" for information on usage and redistribution
>+ * of this file.
>+ *
>+ * @author P.C.Mehlitz
>+ */
>+
> package java.awt;
>
> import java.awt.image.ImageObserver;
>@@ -12,15 +25,6 @@
> import kaffe.util.Ptr;
> import kaffe.util.VectorSnapshot;
>
>-/**
>- * Copyright (c) 1998
>- * Transvirtual Technologies, Inc. All rights reserved.
>- *
>- * See the file "license.terms" for information on usage and redistribution
>- * of this file.
>- *
>- * @author P.C.Mehlitz
>- */
> public class Image
> {
> Ptr nativeData;
>@@ -268,7 +272,6 @@
> }
>
> public synchronized int getWidth ( ImageObserver observer ) {
>- System.err.println("getWidth()="+width + " producer="+producer);
> if ( (flags & ImageObserver.WIDTH) != 0 ) {
> return (width);
> }
>@@ -353,8 +356,6 @@
> ImageObserver obs;
>
> this.flags |= flags;
>-
>- System.err.println("producer="+producer + " flags="+this.flags);
>
> if (observers == null) {
> return;
>Index: kaffe/libraries/javalib/java/awt/NativeGraphics.java
>diff -u kaffe/libraries/javalib/java/awt/NativeGraphics.java:1.11 kaffe/libraries/javalib/java/awt/NativeGraphics.java:1.12
>--- kaffe/libraries/javalib/java/awt/NativeGraphics.java:1.11 Mon Mar 22 11:24:34 2004
>+++ kaffe/libraries/javalib/java/awt/NativeGraphics.java Wed Jul 7 12:58:46 2004
>@@ -1,10 +1,4 @@
>-package java.awt;
>-
>-import java.awt.image.ImageObserver;
>-
>-import kaffe.util.Ptr;
>-
>-/**
>+/*
> * NativeGraphics - concrete, hidden implementation of abstract Graphics
> *
> * The approach of using an abstract Graphics with a concrete NativeGraphics
>@@ -26,11 +20,20 @@
> * Copyright (c) 1998
> * Transvirtual Technologies, Inc. All rights reserved.
> *
>+ * Copyright (c) 2004
>+ * The Kaffe.org's developers. See ChangeLog for details.
>+ *
> * See the file "license.terms" for information on usage and redistribution
> * of this file.
> *
> * @author P.C.Mehlitz
> */
>+
>+package java.awt;
>+
>+import java.awt.image.ImageObserver;
>+import kaffe.util.Ptr;
>+
> class NativeGraphics
> extends Graphics
> {
>@@ -43,7 +46,9 @@
> int xClip;
> int yClip;
> int wClip;
>+ int wClipDefault;
> int hClip;
>+ int hClipDefault;
> Color xClr;
> /*
> * this field can be used to link a Graphics object to a non-native
>@@ -389,9 +394,13 @@
> return (getClipRect());
> }
>
>-public Rectangle getClipBounds() {
>- // Another return object which is modified by Swing, causing more garbage <sigh>
>- return (new Rectangle( xClip, yClip, wClip, hClip));
>+public Rectangle getClipBounds(Rectangle rect) {
>+ rect.x = xClip;
>+ rect.y = yClip;
>+ rect.width = wClip;
>+ rect.height = hClip;
>+
>+ return rect;
> }
>
> int getClipHeight () {
>@@ -545,7 +554,9 @@
> g.xClip = xClip;
> g.yClip = yClip;
> g.wClip = wClip;
>+ g.wClipDefault = wClip;
> g.hClip = hClip;
>+ g.hClipDefault = hClip;
> g.font = fnt;
> g.fgClr = fg;
> g.bgClr = bg;
>@@ -627,8 +638,14 @@
> }
>
> public void setClip ( Shape clip ){
>- Rectangle r = clip.getBounds();
>- setClip( r.x, r.y, r.width, r.height);
>+ if ( clip != null ) {
>+ Rectangle r = clip.getBounds();
>+ setClip( r.x, r.y, r.width, r.height);
>+ } else if ( target != null) {
>+ setClip( 0, 0, target.width, target.height );
>+ } else {
>+ setClip( 0, 0, wClipDefault, hClipDefault );
>+ }
> }
>
> public void setClip ( int x, int y, int width, int height ) {
>Index: kaffe/libraries/javalib/java/awt/PSGraphics.java
>diff -u kaffe/libraries/javalib/java/awt/PSGraphics.java:1.4 kaffe/libraries/javalib/java/awt/PSGraphics.java:1.5
>--- kaffe/libraries/javalib/java/awt/PSGraphics.java:1.4 Wed Feb 10 21:34:34 1999
>+++ kaffe/libraries/javalib/java/awt/PSGraphics.java Wed Jul 7 12:58:46 2004
>@@ -1,3 +1,18 @@
>+/*
>+ * class PSGraphics - a PrintGraphics PostScript implementation
>+ *
>+ * Copyright (c) 1998
>+ * Transvirtual Technologies, Inc. All rights reserved.
>+ *
>+ * Copyright (c) 2004
>+ * The Kaffe.org's developers. See ChangeLog for details.
>+ *
>+ * See the file "license.terms" for information on usage and redistribution
>+ * of this file.
>+ *
>+ * @author J.Mehlitz
>+ */
>+
> package java.awt;
>
> import java.awt.image.ColorModel;
>@@ -9,17 +24,6 @@
> import java.io.PrintStream;
> import java.util.Hashtable;
>
>-/**
>- * class PSGraphics - a PrintGraphics PostScript implementation
>- *
>- * Copyright (c) 1998
>- * Transvirtual Technologies, Inc. All rights reserved.
>- *
>- * See the file "license.terms" for information on usage and redistribution
>- * of this file.
>- *
>- * @author J.Mehlitz
>- */
> public class PSGraphics
> extends Graphics
> implements PrintGraphics
>@@ -276,7 +280,11 @@
> }
>
> public Rectangle getClipBounds() {
>- return null;
>+ return null;
>+}
>+
>+public Rectangle getClipBounds(Rectangle rect) {
>+ return rect;
> }
>
> public Color getColor() {
>Index: kaffe/libraries/javalib/java/awt/event/MouseEvent.java
>diff -u kaffe/libraries/javalib/java/awt/event/MouseEvent.java:1.9 kaffe/libraries/javalib/java/awt/event/MouseEvent.java:1.10
>--- kaffe/libraries/javalib/java/awt/event/MouseEvent.java:1.9 Sat May 17 17:28:02 2003
>+++ kaffe/libraries/javalib/java/awt/event/MouseEvent.java Wed Jul 7 12:58:46 2004
>@@ -1,19 +1,23 @@
>-package java.awt.event;
>-
>-import java.awt.Component;
>-import java.awt.Event;
>-import java.awt.Point;
>-
>-/**
>+/*
> *
> * Copyright (c) 1998
> * Transvirtual Technologies Inc. All rights reserved.
> *
>+ * Copyright (c) 2004
>+ * The Kaffe.org's developers. See ChangeLog for details.
>+ *
> * See the file "license.terms" for information on usage and redistribution
> * of this file.
> *
> * @author P.C.Mehlitz
> */
>+
>+package java.awt.event;
>+
>+import java.awt.Component;
>+import java.awt.Event;
>+import java.awt.Point;
>+
> public class MouseEvent
> extends InputEvent
> {
>@@ -21,6 +25,12 @@
> protected int y;
> protected int clickCount;
> protected boolean isPopupTrigger;
>+
>+ protected int button;
>+ final public static int BUTTON1 = 1;
>+ final public static int BUTTON2 = 2;
>+ final public static int BUTTON3 = 3;
>+ final public static int NOBUTTON = 0;
> final public static int MOUSE_FIRST = 500;
> final public static int MOUSE_LAST = 507;
> final public static int MOUSE_CLICKED = MOUSE_FIRST;
>@@ -55,6 +65,35 @@
> this.y = y;
> this.clickCount = clickCount;
> this.isPopupTrigger = isPopupTrigger;
>+
>+ if ( ( modifiers & BUTTON1_MASK ) > 0 )
>+ this.button = BUTTON1;
>+ else if ( ( modifiers & BUTTON2_MASK ) > 0 )
>+ this.button = BUTTON2;
>+ else if ( ( modifiers & BUTTON3_MASK) > 0 )
>+ this.button = BUTTON3;
>+ else
>+ this.button = NOBUTTON;
>+}
>+
>+public MouseEvent ( Component src, int evtId, long time, int modifiers,
>+ int x, int y, int clickCount, boolean isPopupTrigger,
>+ int button) {
>+ super( src, evtId);
>+
>+ this.when = time;
>+ this.modifiers = modifiers;
>+
>+ this.x = x;
>+ this.y = y;
>+ this.clickCount = clickCount;
>+ this.isPopupTrigger = isPopupTrigger;
>+
>+ this.button = button;
>+}
>+
>+public int getButton() {
>+ return button;
> }
>
> public int getClickCount() {
>
>_______________________________________________
>kaffe mailing list
>kaffe at kaffe.org
>http://kaffe.org/cgi-bin/mailman/listinfo/kaffe
>
>
>
>
Hello ,
This patch is really not good for my machine :
java.lang.NullPointerException
at java.awt.MouseEvt.getEvent (MouseEvt.java:288)
at java.awt.Toolkit.evtGetNextEvent (Toolkit.java)
at java.awt.EventQueue.getNextEvent (EventQueue.java:174)
at java.awt.EventDispatchThread.run (EventDispatchThread.java:34)
java.lang.ArrayIndexOutOfBoundsException
at java.awt.MouseEvt.getEvent (MouseEvt.java:283)
at java.awt.Toolkit.evtGetNextEvent (Toolkit.java)
at java.awt.EventQueue.getNextEvent (EventQueue.java:174)
at java.awt.EventDispatchThread.run (EventDispatchThread.java:34)
...
...
java.lang.ArrayIndexOutOfBoundsException
at java.awt.ComponentEvt.getEvent (ComponentEvt.java:98)
at java.awt.Toolkit.evtGetNextEvent (Toolkit.java)
at java.awt.EventQueue.getNextEvent (EventQueue.java:174)
at java.awt.EventDispatchThread.run (EventDispatchThread.java:34)
java.lang.ArrayIndexOutOfBoundsException
at java.awt.ComponentEvt.getEvent (ComponentEvt.java:98)
at java.awt.Toolkit.evtGetNextEvent (Toolkit.java)
at java.awt.EventQueue.getNextEvent (EventQueue.java:174)
at java.awt.EventDispatchThread.run (EventDispatchThread.java:34)
java.lang.ArrayIndexOutOfBoundsException
at java.awt.PaintEvt.getEvent (PaintEvt.java:63)
at java.awt.Toolkit.evtGetNextEvent (Toolkit.java)
at java.awt.EventQueue.getNextEvent (EventQueue.java:174)
at java.awt.EventDispatchThread.run (EventDispatchThread.java:34)
Cheers,
Fabien
More information about the kaffe
mailing list