[kaffe] pending patches from Benja Fallenstein

jserv at linux2.cc.ntu.edu.tw jserv at linux2.cc.ntu.edu.tw
Tue Jul 6 19:50:01 PDT 2004


Hello all,

  Benja Fallenstein <b.fallenstein at gmx.de> has done many AWT
fixing to Kaffe's original AWT implementation, and I suggest
to merge into cvs head. The attachment is my adaption of his
excellent patch.

cheers,
Jim Huang
-------------- next part --------------
Index: libraries/javalib/java/awt/Graphics.java
===================================================================
RCS file: /cvs/kaffe/kaffe/libraries/javalib/java/awt/Graphics.java,v
retrieving revision 1.7
diff -u -r1.7 Graphics.java
--- libraries/javalib/java/awt/Graphics.java	10 Feb 1999 21:34:31 -0000	1.7
+++ libraries/javalib/java/awt/Graphics.java	7 Jul 2004 02:19:16 -0000
@@ -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: libraries/javalib/java/awt/Image.java
===================================================================
RCS file: /cvs/kaffe/kaffe/libraries/javalib/java/awt/Image.java,v
retrieving revision 1.17
diff -u -r1.17 Image.java
--- libraries/javalib/java/awt/Image.java	9 Jun 2004 17:40:16 -0000	1.17
+++ libraries/javalib/java/awt/Image.java	7 Jul 2004 02:19:16 -0000
@@ -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: libraries/javalib/java/awt/NativeGraphics.java
===================================================================
RCS file: /cvs/kaffe/kaffe/libraries/javalib/java/awt/NativeGraphics.java,v
retrieving revision 1.11
diff -u -r1.11 NativeGraphics.java
--- libraries/javalib/java/awt/NativeGraphics.java	22 Mar 2004 11:24:34 -0000	1.11
+++ libraries/javalib/java/awt/NativeGraphics.java	7 Jul 2004 02:19:17 -0000
@@ -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: libraries/javalib/java/awt/PSGraphics.java
===================================================================
RCS file: /cvs/kaffe/kaffe/libraries/javalib/java/awt/PSGraphics.java,v
retrieving revision 1.4
diff -u -r1.4 PSGraphics.java
--- libraries/javalib/java/awt/PSGraphics.java	10 Feb 1999 21:34:34 -0000	1.4
+++ libraries/javalib/java/awt/PSGraphics.java	7 Jul 2004 02:19:17 -0000
@@ -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: libraries/javalib/java/awt/event/MouseEvent.java
===================================================================
RCS file: /cvs/kaffe/kaffe/libraries/javalib/java/awt/event/MouseEvent.java,v
retrieving revision 1.9
diff -u -r1.9 MouseEvent.java
--- libraries/javalib/java/awt/event/MouseEvent.java	17 May 2003 17:28:02 -0000	1.9
+++ libraries/javalib/java/awt/event/MouseEvent.java	7 Jul 2004 02:19:17 -0000
@@ -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() {
Index: ChangeLog
===================================================================
RCS file: /cvs/kaffe/kaffe/ChangeLog,v
retrieving revision 1.2466
diff -u -r1.2466 ChangeLog
--- ChangeLog	6 Jul 2004 20:48:32 -0000	1.2466
+++ ChangeLog	7 Jul 2004 02:38:04 -0000
@@ -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-06  Dalibor Topic  <robilad at kaffe.org>
 
         * config/x86_64/linux/sigcontextinfo.h: Cleaned up.


More information about the kaffe mailing list