Index: gnu/java/awt/peer/gtk/GdkGraphics.java =================================================================== RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/gtk/GdkGraphics.java,v retrieving revision 1.33 diff -u -r1.33 GdkGraphics.java --- gnu/java/awt/peer/gtk/GdkGraphics.java 8 Oct 2004 22:49:27 -0000 1.33 +++ gnu/java/awt/peer/gtk/GdkGraphics.java 1 Dec 2004 16:21:49 -0000 @@ -127,15 +127,6 @@ return new GdkGraphics (this); } -// public Graphics create (int x, int y, int width, int height) -// { -// GdkGraphics g = new GdkGraphics (this); -// g.translate (x, y); -// g.clipRect (0, 0, width, height); - -// return g; -// } - native public void dispose (); native void copyPixmap (Graphics g, int x, int y, int width, int height); @@ -152,13 +143,20 @@ if (img instanceof GtkOffScreenImage) { + int width = img.getWidth (null); + int height = img.getHeight (null); copyPixmap (img.getGraphics (), - x, y, img.getWidth (null), img.getHeight (null)); + x, y, width, height); + // FIXME: need to differentiate between SOMEBITS and FRAMEBITS. + if (observer != null) + observer.imageUpdate (img, + ImageObserver.FRAMEBITS, + x, y, width, height); return true; } GtkImage image = (GtkImage) img; - new GtkImagePainter (image, this, x, y, -1, -1, bgcolor); + new GtkImagePainter (image, this, x, y, -1, -1, bgcolor, observer); return image.isLoaded (); } @@ -191,11 +189,16 @@ copyAndScalePixmap (img.getGraphics (), false, false, 0, 0, img.getWidth (null), img.getHeight (null), x, y, width, height); + // FIXME: need to differentiate between SOMEBITS and FRAMEBITS. + if (observer != null) + observer.imageUpdate (img, + ImageObserver.FRAMEBITS, + x, y, width, height); return true; } GtkImage image = (GtkImage) img; - new GtkImagePainter (image, this, x, y, width, height, bgcolor); + new GtkImagePainter (image, this, x, y, width, height, bgcolor, observer); return image.isLoaded (); } @@ -275,12 +278,18 @@ copyAndScalePixmap (img.getGraphics (), x_flip, y_flip, sx_start, sy_start, s_width, s_height, dx_start, dy_start, d_width, d_height); + + // FIXME: need to differentiate between SOMEBITS and FRAMEBITS. + if (observer != null) + observer.imageUpdate (img, + ImageObserver.FRAMEBITS, + dx_start, dy_start, d_width, d_height); return true; } GtkImage image = (GtkImage) img; new GtkImagePainter (image, this, dx1, dy1, dx2, dy2, - sx1, sy1, sx2, sy2, bgcolor); + sx1, sy1, sx2, sy2, bgcolor, observer); return image.isLoaded (); } Index: gnu/java/awt/peer/gtk/GtkComponentPeer.java =================================================================== RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/gtk/GtkComponentPeer.java,v retrieving revision 1.76 diff -u -r1.76 GtkComponentPeer.java --- gnu/java/awt/peer/gtk/GtkComponentPeer.java 5 Nov 2004 20:21:47 -0000 1.76 +++ gnu/java/awt/peer/gtk/GtkComponentPeer.java 1 Dec 2004 16:21:49 -0000 @@ -200,9 +200,11 @@ return i.checkImage (); } - public Image createImage (ImageProducer producer) + public Image createImage (ImageProducer producer) { - return new GtkImage (producer, null); + GtkImage image = new GtkImage (producer, null); + producer.startProduction (image); + return image; } public Image createImage (int width, int height) @@ -390,8 +392,8 @@ public void requestFocus () { - gtkWidgetRequestFocus (); - postFocusEvent (FocusEvent.FOCUS_GAINED, false); + gtkWidgetRequestFocus(); + postFocusEvent(FocusEvent.FOCUS_GAINED, false); } public void reshape (int x, int y, int width, int height) Index: gnu/java/awt/peer/gtk/GtkFramePeer.java =================================================================== RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/gtk/GtkFramePeer.java,v retrieving revision 1.31 diff -u -r1.31 GtkFramePeer.java --- gnu/java/awt/peer/gtk/GtkFramePeer.java 11 Nov 2004 17:22:52 -0000 1.31 +++ gnu/java/awt/peer/gtk/GtkFramePeer.java 1 Dec 2004 16:21:49 -0000 @@ -89,7 +89,8 @@ setMenuBarPeer (menuBar); int menuBarWidth = awtComponent.getWidth () - insets.left - insets.right; - setMenuBarWidth (menuBar, menuBarWidth); + if (menuBarWidth > 0) + setMenuBarWidth (menuBar, menuBarWidth); menuBarHeight = getMenuBarHeight (); insets.top += menuBarHeight; awtComponent.validate (); @@ -105,7 +106,8 @@ awtComponent.getWidth () - insets.left - insets.right; menuBar = (MenuBarPeer) ((MenuBar) bar).getPeer (); setMenuBarPeer (menuBar); - setMenuBarWidth (menuBar, menuBarWidth); + if (menuBarWidth > 0) + setMenuBarWidth (menuBar, menuBarWidth); menuBarHeight = getMenuBarHeight (); if (oldHeight != menuBarHeight) { @@ -118,8 +120,9 @@ public void setBounds (int x, int y, int width, int height) { - if (menuBar != null) - setMenuBarWidth (menuBar, width - insets.left - insets.right); + int menuBarWidth = width - insets.left - insets.right; + if (menuBar != null && menuBarWidth > 0) + setMenuBarWidth (menuBar, menuBarWidth); nativeSetBounds (x, y, width - insets.left - insets.right, @@ -225,7 +228,8 @@ || frame_width != awtComponent.getWidth() || frame_height != awtComponent.getHeight()) { - if (frame_width != awtComponent.getWidth() && menuBar != null) + if (frame_width != awtComponent.getWidth() && menuBar != null + && width > 0) setMenuBarWidth (menuBar, width); setBoundsCallback ((Window) awtComponent, Index: gnu/java/awt/peer/gtk/GtkImage.java =================================================================== RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/gtk/GtkImage.java,v retrieving revision 1.13 diff -u -r1.13 GtkImage.java --- gnu/java/awt/peer/gtk/GtkImage.java 8 Aug 2004 13:44:17 -0000 1.13 +++ gnu/java/awt/peer/gtk/GtkImage.java 1 Dec 2004 16:21:49 -0000 @@ -230,7 +230,7 @@ int offset, int scansize) { setPixels (x, y, width, height, cm, convertPixels (pixels), offset, - scansize); + scansize); if (observer != null) observer.imageUpdate (this, @@ -255,7 +255,8 @@ if (scansize == width && height == 1) { - System.arraycopy (pixels, offset, + // Copy contents of pixels array into pixel cache. + System.arraycopy (pixels, offset, pixelCache, y * this.width + x, pixels.length - offset); } @@ -274,7 +275,7 @@ if (status == ImageConsumer.STATICIMAGEDONE && isCacheable) isLoaded = true; - if (status == ImageConsumer.SINGLEFRAMEDONE) + if (status == ImageConsumer.SINGLEFRAME) isCacheable = false; if (observer != null) @@ -289,7 +290,7 @@ -1, -1, -1, -1); } - if (source != null) + if (source != null && status != ImageConsumer.SINGLEFRAME) source.removeConsumer (this); } Index: gnu/java/awt/peer/gtk/GtkImagePainter.java =================================================================== RCS file: /cvsroot/classpath/classpath/gnu/java/awt/peer/gtk/GtkImagePainter.java,v retrieving revision 1.11 diff -u -r1.11 GtkImagePainter.java --- gnu/java/awt/peer/gtk/GtkImagePainter.java 22 Sep 2004 11:03:09 -0000 1.11 +++ gnu/java/awt/peer/gtk/GtkImagePainter.java 1 Dec 2004 16:21:49 -0000 @@ -42,6 +42,7 @@ import java.awt.Rectangle; import java.awt.image.ColorModel; import java.awt.image.ImageConsumer; +import java.awt.image.ImageObserver; import java.util.Hashtable; public class GtkImagePainter implements Runnable, ImageConsumer @@ -57,10 +58,11 @@ boolean flipX, flipY; Rectangle clip; int s_width, s_height; + ImageObserver observer; public GtkImagePainter (GtkImage image, GdkGraphics gc, int x, int y, - int width, int height, Color bgcolor) + int width, int height, Color bgcolor, ImageObserver o) { this.image = image; this.gc = (GdkGraphics) gc.create (); @@ -74,6 +76,7 @@ flipX = flipY = false; s_width = s_height = 0; clip = null; + observer = o; run (); } @@ -82,7 +85,7 @@ GtkImagePainter (GtkImage image, GdkGraphics gc, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, - Color bgcolor) + Color bgcolor, ImageObserver o) { this.image = image; this.gc = (GdkGraphics) gc.create (); @@ -91,6 +94,7 @@ redBG = bgcolor.getRed (); greenBG = bgcolor.getGreen (); blueBG = bgcolor.getBlue (); + observer = o; this.width = Math.abs (dx2 - dx1); this.height = Math.abs (dy2 - dy1); @@ -126,7 +130,7 @@ if (model.equals (ColorModel.getRGBdefault ())) return pixels; - + int ret[] = new int[pixels.length]; for (int i = 0; i < pixels.length; i++) @@ -180,6 +184,11 @@ startX + x, startY + y, width, height, convertPixels (pixels, model), offset, scansize, affine); + + if (observer != null) + observer.imageUpdate (image, + ImageObserver.SOMEBITS, + x, y, width, height); } public void @@ -247,5 +256,17 @@ imageComplete (int status) { image.imageComplete(status); + + if (observer != null) + { + if (status == ImageConsumer.IMAGEERROR) + observer.imageUpdate (null, + ImageObserver.ERROR, + -1, -1, -1, -1); + else + observer.imageUpdate (null, + ImageObserver.ALLBITS, + -1, -1, -1, -1); + } } } Index: java/applet/Applet.java =================================================================== RCS file: /cvsroot/classpath/classpath/java/applet/Applet.java,v retrieving revision 1.10 diff -u -r1.10 Applet.java --- java/applet/Applet.java 21 Sep 2004 12:31:44 -0000 1.10 +++ java/applet/Applet.java 1 Dec 2004 16:21:49 -0000 @@ -78,6 +78,12 @@ /** The applet stub for this applet. */ private transient AppletStub stub; + /** Some applets call setSize in their constructors. In that case, + these fields are used to store width and height values until a + stub is set. */ + private transient int width; + private transient int height; + /** * The accessibility context for this applet. * @@ -107,6 +113,9 @@ public final void setStub(AppletStub stub) { this.stub = stub; + + if (width != 0 && height != 0) + stub.appletResize (width, height); } /** @@ -174,7 +183,13 @@ */ public void resize(int width, int height) { - stub.appletResize(width, height); + if (stub == null) + { + this.width = width; + this.height = height; + } + else + stub.appletResize(width, height); } /** Index: java/awt/Component.java =================================================================== RCS file: /cvsroot/classpath/classpath/java/awt/Component.java,v retrieving revision 1.48 diff -u -r1.48 Component.java --- java/awt/Component.java 23 Nov 2004 13:15:37 -0000 1.48 +++ java/awt/Component.java 1 Dec 2004 16:21:50 -0000 @@ -1380,7 +1380,7 @@ shouldRepaintSelf = parentBounds.intersects(newBounds); } - if (shouldRepaintParent) + if (shouldRepaintParent && parent != null) parent.repaint(oldx, oldy, oldwidth, oldheight); if (shouldRepaintSelf) repaint(); Index: java/awt/image/MemoryImageSource.java =================================================================== RCS file: /cvsroot/classpath/classpath/java/awt/image/MemoryImageSource.java,v retrieving revision 1.10 diff -u -r1.10 MemoryImageSource.java --- java/awt/image/MemoryImageSource.java 27 Sep 2004 15:11:47 -0000 1.10 +++ java/awt/image/MemoryImageSource.java 1 Dec 2004 16:21:50 -0000 @@ -52,8 +52,16 @@ private Vector consumers = new Vector(); /** - Constructs an ImageProducer from memory - */ + * Construct an image producer that reads image data from a byte + * array. + * + * @param w width of image + * @param h height of image + * @param cm the color model used to represent pixel values + * @param pix a byte array of pixel values + * @param off the offset into the array at which the first pixel is stored + * @param scan the number of array elements that represents a single pixel row + */ public MemoryImageSource(int w, int h, ColorModel cm, byte pix[], int off, int scan) { @@ -73,12 +81,19 @@ scansize = scan; this.props = props; int max = (( scansize > width ) ? scansize : width ); - pixelb = new byte[ max * height ]; - System.arraycopy( pix, 0, pixelb, 0, max * height ); + pixelb = pix; } /** - Constructs an ImageProducer from memory - */ + * Construct an image producer that reads image data from an + * integer array. + * + * @param w width of image + * @param h height of image + * @param cm the color model used to represent pixel values + * @param pix an integer array of pixel values + * @param off the offset into the array at which the first pixel is stored + * @param scan the number of array elements that represents a single pixel row + */ public MemoryImageSource(int w, int h, ColorModel cm, int pix[], int off, int scan) { @@ -99,8 +114,7 @@ scansize = scan; this.props = props; int max = (( scansize > width ) ? scansize : width ); - pixeli = new int[ max * height ]; - System.arraycopy( pix, 0, pixeli, 0, max * height ); + pixeli = pix; } /** Constructs an ImageProducer from memory using the default RGB ColorModel @@ -165,7 +179,10 @@ for(int i = 0; i < list.size(); i++) { ic = (ImageConsumer) list.elementAt(i); sendPicture( ic ); - ic.imageComplete( ImageConsumer.STATICIMAGEDONE ); + if (animated) + ic.imageComplete( ImageConsumer.SINGLEFRAME ); + else + ic.imageComplete( ImageConsumer.STATICIMAGEDONE ); } } @@ -215,7 +232,7 @@ ic = (ImageConsumer) list.elementAt(i); sendPicture( ic ); ic.imageComplete( ImageConsumer.SINGLEFRAME ); - } + } } } @@ -259,13 +276,14 @@ } if( pixeli != null ) { int[] pixelbuf = new int[w * h]; - for (int row = y; row < h; row++) - System.arraycopy(pixeli, row * scansize + x + offset, pixelbuf, row * w, w); + for (int row = y; row < y + h; row++) + System.arraycopy(pixeli, row * scansize + x + offset, pixelbuf, 0, w * h); ic.setPixels( x, y, w, h, cm, pixelbuf, 0, w ); } else { byte[] pixelbuf = new byte[w * h]; - for (int row = y; row < h; row++) - System.arraycopy(pixelb, row * scansize + x + offset, pixelbuf, row * w, w); + for (int row = y; row < y + h; row++) + System.arraycopy(pixelb, row * scansize + x + offset, pixelbuf, 0, w * h); + ic.setPixels( x, y, w, h, cm, pixelbuf, 0, w ); } ic.imageComplete( ImageConsumer.SINGLEFRAME ); @@ -304,13 +322,13 @@ } if( pixeli != null ) { int[] pixelbuf = new int[w * h]; - for (int row = y; row < h; row++) - System.arraycopy(pixeli, row * scansize + x + offset, pixelbuf, row * w, w); + for (int row = y; row < y + h; row++) + System.arraycopy(pixeli, row * scansize + x + offset, pixelbuf, 0, w * h); ic.setPixels( x, y, w, h, cm, pixelbuf, 0, w ); } else { byte[] pixelbuf = new byte[w * h]; - for (int row = y; row < h; row++) - System.arraycopy(pixelb, row * scansize + x + offset, pixelbuf, row * w, w); + for (int row = y; row < y + h; row++) + System.arraycopy(pixelb, row * scansize + x + offset, pixelbuf, 0, w * h); ic.setPixels( x, y, w, h, cm, pixelbuf, 0, w ); } if( framenotify == true ) Index: native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c =================================================================== RCS file: /cvsroot/classpath/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c,v retrieving revision 1.18 diff -u -r1.18 gnu_java_awt_peer_gtk_GdkGraphics.c --- native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c 28 Oct 2004 20:58:25 -0000 1.18 +++ native/jni/gtk-peer/gnu_java_awt_peer_gtk_GdkGraphics.c 1 Dec 2004 16:21:50 -0000 @@ -150,6 +150,7 @@ { struct graphics *g; + g = (struct graphics *) NSA_DEL_PTR (env, obj); if (!g) return; /* dispose has been called more than once */ @@ -222,7 +223,7 @@ pango_layout_iter_free (iter); pango_layout_set_text (pfont->layout, "", -1); - /* gdk_flush (); */ + gdk_flush (); gdk_threads_leave (); (*env)->ReleaseStringUTFChars (env, str, cstr); @@ -240,7 +241,7 @@ gdk_draw_line (g->drawable, g->gc, x + g->x_offset, y + g->y_offset, x2 + g->x_offset, y2 + g->y_offset); - /* gdk_flush (); */ + gdk_flush (); gdk_threads_leave (); } @@ -256,7 +257,7 @@ gdk_draw_rectangle (g->drawable, g->gc, TRUE, x + g->x_offset, y + g->y_offset, width, height); - /* gdk_flush (); */ + gdk_flush (); gdk_threads_leave (); } @@ -271,7 +272,7 @@ gdk_threads_enter (); gdk_draw_rectangle (g->drawable, g->gc, FALSE, x + g->x_offset, y + g->y_offset, width, height); - /* gdk_flush (); */ + gdk_flush (); gdk_threads_leave (); } @@ -291,7 +292,7 @@ (GdkWindow *)g->drawable, x + g->x_offset, y + g->y_offset, width, height); - /* gdk_flush (); */ + gdk_flush (); gdk_threads_leave (); } @@ -312,7 +313,7 @@ (GdkWindow *)g2->drawable, 0 + g2->x_offset, 0 + g2->y_offset, width, height); - /* gdk_flush (); */ + gdk_flush (); gdk_threads_leave (); } @@ -503,7 +504,7 @@ gdk_draw_arc (g->drawable, g->gc, FALSE, x + g->x_offset, y + g->y_offset, width, height, angle1 << 6, angle2 << 6); - /* gdk_flush (); */ + gdk_flush (); gdk_threads_leave (); } @@ -548,7 +549,7 @@ gdk_threads_enter (); gdk_draw_lines (g->drawable, g->gc, points, npoints); - /* gdk_flush (); */ + gdk_flush (); gdk_threads_leave (); g_free (points); @@ -573,7 +574,7 @@ gdk_threads_enter (); gdk_draw_lines (g->drawable, g->gc, points, npoints); - /* gdk_flush (); */ + gdk_flush (); gdk_threads_leave (); g_free (points); @@ -592,7 +593,7 @@ g->x_offset, g->y_offset); gdk_threads_enter (); gdk_draw_polygon (g->drawable, g->gc, TRUE, points, npoints); - /* gdk_flush (); */ + gdk_flush (); gdk_threads_leave (); g_free (points); @@ -611,7 +612,7 @@ gdk_draw_arc (g->drawable, g->gc, TRUE, x + g->x_offset, y + g->y_offset, width, height, angle1 << 6, angle2 << 6); - /* gdk_flush (); */ + gdk_flush (); gdk_threads_leave (); } @@ -627,7 +628,7 @@ gdk_draw_arc (g->drawable, g->gc, FALSE, x + g->x_offset, y + g->y_offset, width, height, 0, 23040); - /* gdk_flush (); */ + gdk_flush (); gdk_threads_leave (); } @@ -643,7 +644,7 @@ gdk_draw_arc (g->drawable, g->gc, TRUE, x + g->x_offset, y + g->y_offset, width, height, 0, 23040); - /* gdk_flush (); */ + gdk_flush (); gdk_threads_leave (); } Index: native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImagePainter.c =================================================================== RCS file: /cvsroot/classpath/classpath/native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImagePainter.c,v retrieving revision 1.9 diff -u -r1.9 gnu_java_awt_peer_gtk_GtkImagePainter.c --- native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImagePainter.c 28 Oct 2004 20:58:25 -0000 1.9 +++ native/jni/gtk-peer/gnu_java_awt_peer_gtk_GtkImagePainter.c 1 Dec 2004 16:21:50 -0000 @@ -148,6 +148,12 @@ gdk_threads_enter (); + if (!g || !GDK_IS_DRAWABLE (g->drawable)) + { + gdk_threads_leave (); + return; + } + gdk_draw_rgb_image (g->drawable, g->gc, x + g->x_offset,