From 81f7282f978588f883d8363e8cd5e69d090bc331 Mon Sep 17 00:00:00 2001 From: Scott Gilbertson Date: Mon, 25 Aug 2003 19:02:29 +0000 Subject: [PATCH] Makefile.am: added gnu/awt/xlib/XOffScreenImage.java. * Makefile.am: added gnu/awt/xlib/XOffScreenImage.java. * Makefile.in: re-generated. * gnu/awt/j2d/IntegerGraphicsState.java (ScreenCoupledImage): new interface. (drawImage): detect ScreenCoupledImage instances. * gnu/awt/xlib/XCanvasPeer.java (createImage) implemented. * gnu/awt/xlib/XEventLoop.java (createEvent): re-formatted, and rearranged to avoid null pointer. * gnu/awt/xlib/XGraphics.java (drawImage): added XOffScreenImage handling. * gnu/awt/xlib/XOffScreenImage.java: new file. * gnu/gcj/xlib/Drawable.java (getDepth): new native method. * gnu/gcj/xlib/GC.java (copyArea): new native method. * gnu/gcj/xlib/XAnyEvent.java (TYPE_KEY_PRESS): new constant. (TYPE_KEY_RELEASE): new constant. (TYPE_MOTION_NOTIFY): new constant. (TYPE_ENTER_NOTIFY): new constant. (TYPE_LEAVE_NOTIFY): new constant. (TYPE_FOCUS_IN): new constant. (TYPE_FOCUS_OUT): new constant. (TYPE_KEYMAP_NOTIFY): new constant. (TYPE_GRAPHICS_EXPOSE): new constant. (TYPE_NO_EXPOSE): new constant. (TYPE_VISIBILITY_NOTIFY): new constant. (TYPE_CREATE_NOTIFY): new constant. (TYPE_DESTROY_NOTIFY): new constant. (TYPE_MAP_REQUEST): new constant. (TYPE_CONFIGURE_REQUEST): new constant. (TYPE_GRAVITY_NOTIFY): new constant. (TYPE_RESIZE_REQUEST): new constant. (TYPE_CIRCULATE_NOTIFY): new constant. (TYPE_CIRCULATE_REQUEST): new constant. (TYPE_PROPERTY_NOTIFY): new constant. (TYPE_SELECTION_CLEAR): new constant. (TYPE_SELECTION_REQUEST): new constant. (TYPE_SELECTION_NOTIFY): new constant. (TYPE_COLORMAP_NOTIFY): new constant. (TYPE_MAPPING_NOTIFY): new constant. * gnu/gcj/xlib/natDrawable.cc (getDepth): new method. * gnu/gcj/xlib/natGC.cc (copyArea): new method * java/awt/Component.java (createImage): changed to use peer method. From-SVN: r70776 --- libjava/ChangeLog | 44 +++++ libjava/Makefile.am | 1 + libjava/Makefile.in | 10 +- libjava/gnu/awt/j2d/IntegerGraphicsState.java | 133 +++++++------ libjava/gnu/awt/xlib/XCanvasPeer.java | 2 +- libjava/gnu/awt/xlib/XEventLoop.java | 75 ++++---- libjava/gnu/awt/xlib/XGraphics.java | 11 ++ libjava/gnu/awt/xlib/XOffScreenImage.java | 175 ++++++++++++++++++ libjava/gnu/gcj/xlib/Drawable.java | 2 + libjava/gnu/gcj/xlib/GC.java | 5 + libjava/gnu/gcj/xlib/XAnyEvent.java | 42 ++++- libjava/gnu/gcj/xlib/natDrawable.cc | 20 ++ libjava/gnu/gcj/xlib/natGC.cc | 15 ++ libjava/java/awt/Component.java | 15 +- 14 files changed, 442 insertions(+), 108 deletions(-) create mode 100644 libjava/gnu/awt/xlib/XOffScreenImage.java diff --git a/libjava/ChangeLog b/libjava/ChangeLog index bc0066d3f0e..17b2fe54845 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,47 @@ +2003-08-25 Scott Gilbertson + * Makefile.am: added gnu/awt/xlib/XOffScreenImage.java. + * Makefile.in: re-generated. + * gnu/awt/j2d/IntegerGraphicsState.java + (ScreenCoupledImage): new interface. + (drawImage): detect ScreenCoupledImage instances. + * gnu/awt/xlib/XCanvasPeer.java (createImage) implemented. + * gnu/awt/xlib/XEventLoop.java + (createEvent): re-formatted, and rearranged to avoid null pointer. + * gnu/awt/xlib/XGraphics.java + (drawImage): added XOffScreenImage handling. + * gnu/awt/xlib/XOffScreenImage.java: new file. + * gnu/gcj/xlib/Drawable.java (getDepth): new native method. + * gnu/gcj/xlib/GC.java (copyArea): new native method. + * gnu/gcj/xlib/XAnyEvent.java + (TYPE_KEY_PRESS): new constant. + (TYPE_KEY_RELEASE): new constant. + (TYPE_MOTION_NOTIFY): new constant. + (TYPE_ENTER_NOTIFY): new constant. + (TYPE_LEAVE_NOTIFY): new constant. + (TYPE_FOCUS_IN): new constant. + (TYPE_FOCUS_OUT): new constant. + (TYPE_KEYMAP_NOTIFY): new constant. + (TYPE_GRAPHICS_EXPOSE): new constant. + (TYPE_NO_EXPOSE): new constant. + (TYPE_VISIBILITY_NOTIFY): new constant. + (TYPE_CREATE_NOTIFY): new constant. + (TYPE_DESTROY_NOTIFY): new constant. + (TYPE_MAP_REQUEST): new constant. + (TYPE_CONFIGURE_REQUEST): new constant. + (TYPE_GRAVITY_NOTIFY): new constant. + (TYPE_RESIZE_REQUEST): new constant. + (TYPE_CIRCULATE_NOTIFY): new constant. + (TYPE_CIRCULATE_REQUEST): new constant. + (TYPE_PROPERTY_NOTIFY): new constant. + (TYPE_SELECTION_CLEAR): new constant. + (TYPE_SELECTION_REQUEST): new constant. + (TYPE_SELECTION_NOTIFY): new constant. + (TYPE_COLORMAP_NOTIFY): new constant. + (TYPE_MAPPING_NOTIFY): new constant. + * gnu/gcj/xlib/natDrawable.cc (getDepth): new method. + * gnu/gcj/xlib/natGC.cc (copyArea): new method + * java/awt/Component.java (createImage): changed to use peer method. + 2003-08-22 Thomas Fitzsimmons * gnu/java/awt/peer/gtk/GdkGraphics.java (drawString): Pass font diff --git a/libjava/Makefile.am b/libjava/Makefile.am index 7869df021f3..8dfc5ab33a0 100644 --- a/libjava/Makefile.am +++ b/libjava/Makefile.am @@ -2651,6 +2651,7 @@ gnu/awt/xlib/XFontMetrics.java \ gnu/awt/xlib/XFramePeer.java \ gnu/awt/xlib/XGraphics.java \ gnu/awt/xlib/XGraphicsConfiguration.java \ +gnu/awt/xlib/XOffScreenImage.java \ gnu/awt/xlib/XPanelPeer.java \ gnu/awt/xlib/XToolkit.java diff --git a/libjava/Makefile.in b/libjava/Makefile.in index b98f5208d99..344bd757c38 100644 --- a/libjava/Makefile.in +++ b/libjava/Makefile.in @@ -2416,6 +2416,7 @@ gnu/awt/xlib/XFontMetrics.java \ gnu/awt/xlib/XFramePeer.java \ gnu/awt/xlib/XGraphics.java \ gnu/awt/xlib/XGraphicsConfiguration.java \ +gnu/awt/xlib/XOffScreenImage.java \ gnu/awt/xlib/XPanelPeer.java \ gnu/awt/xlib/XToolkit.java @@ -2710,10 +2711,11 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \ .deps/gnu/awt/xlib/XFontMetrics.P .deps/gnu/awt/xlib/XFramePeer.P \ .deps/gnu/awt/xlib/XGraphics.P \ .deps/gnu/awt/xlib/XGraphicsConfiguration.P \ -.deps/gnu/awt/xlib/XPanelPeer.P .deps/gnu/awt/xlib/XToolkit.P \ -.deps/gnu/classpath/Configuration.P .deps/gnu/gcj/Core.P \ -.deps/gnu/gcj/RawData.P .deps/gnu/gcj/convert/BytesToUnicode.P \ -.deps/gnu/gcj/convert/Convert.P .deps/gnu/gcj/convert/IOConverter.P \ +.deps/gnu/awt/xlib/XOffScreenImage.P .deps/gnu/awt/xlib/XPanelPeer.P \ +.deps/gnu/awt/xlib/XToolkit.P .deps/gnu/classpath/Configuration.P \ +.deps/gnu/gcj/Core.P .deps/gnu/gcj/RawData.P \ +.deps/gnu/gcj/convert/BytesToUnicode.P .deps/gnu/gcj/convert/Convert.P \ +.deps/gnu/gcj/convert/IOConverter.P \ .deps/gnu/gcj/convert/Input_8859_1.P \ .deps/gnu/gcj/convert/Input_ASCII.P \ .deps/gnu/gcj/convert/Input_EUCJIS.P \ diff --git a/libjava/gnu/awt/j2d/IntegerGraphicsState.java b/libjava/gnu/awt/j2d/IntegerGraphicsState.java index 3befcb41707..4eb4c6182b1 100644 --- a/libjava/gnu/awt/j2d/IntegerGraphicsState.java +++ b/libjava/gnu/awt/j2d/IntegerGraphicsState.java @@ -44,6 +44,19 @@ public class IntegerGraphicsState extends AbstractGraphicsState DirectRasterGraphics directGfx; Shape clip; + /** Interface for images which are coupled to a GraphicsConfiguration, + * as is typically the case for an off-screen buffer used in + * double-buffering. Any image which implements this interface is + * rendered directly by DirectRasterGraphics (i.e. by directGfx.drawImage) + */ + public interface ScreenCoupledImage + { + /** Get the GraphicsConfiguration to which this image is coupled + * @return the GraphicsConfiguration + */ + GraphicsConfiguration getGraphicsConfiguration (); + } + public IntegerGraphicsState(DirectRasterGraphics directGfx) { this.directGfx = directGfx; @@ -245,66 +258,72 @@ public class IntegerGraphicsState extends AbstractGraphicsState x += tx; y += ty; + if (image instanceof ScreenCoupledImage) + { + GraphicsConfiguration config + = ((ScreenCoupledImage)image).getGraphicsConfiguration (); + if (config == frontend.config) + return directGfx.drawImage (image, x, y, observer); + } if (image instanceof BufferedImage) + { + BufferedImage bImage = (BufferedImage) image; + // FIXME: eliminate? ScreenCoupledImage is probably more efficient + Object config = bImage.getProperty ("java.awt.GraphicsConfiguration"); + if (config == frontend.config) + return directGfx.drawImage (image, x, y, observer); + + int width = image.getWidth (null); + int height = image.getHeight (null); + + Rectangle bounds = new Rectangle (x, y, width, height); + + MappedRaster mr = directGfx.mapRaster (bounds); + + // manipulate raster here... + ColorModel colorModel = mr.getColorModel (); + WritableRaster raster = mr.getRaster (); + + int xEnd = x + width; + int yEnd = y + height; + + // FIXME: Use the following code only as a fallback. It's SLOW! + + Object rgbElem = null; + for (int yy=0; yy>> 24) & 0xff) + 1; - int sr = ((srgb >>> 16) & 0xff) + 1; - int sg = ((srgb >>> 8) & 0xff) + 1; - int sb = (srgb & 0xff) + 1; - - rgbElem = raster.getDataElements(xx+x, yy+y, rgbElem); - int drgb = colorModel.getRGB(rgbElem); - int dr = ((drgb >>> 16) & 0xff) + 1; - int dg = ((drgb >>> 8) & 0xff) + 1; - int db = (drgb & 0xff) + 1; - int da = 256 - sa; - - dr = ((sr*sa + dr*da) >>> 8) - 1; - dg = ((sg*sa + dg*da) >>> 8) - 1; - db = ((sb*sa + db*da) >>> 8) - 1; - - drgb = (dr<<16) | (dg<<8) | db; - - rgbElem = colorModel.getDataElements(drgb, rgbElem); - - raster.setDataElements(xx+x, yy+y, rgbElem); - } - } - directGfx.unmapRaster(mr); - return true; - + for (int xx=0; xx>> 24) & 0xff) + 1; + int sr = ((srgb >>> 16) & 0xff) + 1; + int sg = ((srgb >>> 8) & 0xff) + 1; + int sb = (srgb & 0xff) + 1; + + rgbElem = raster.getDataElements (xx+x, yy+y, rgbElem); + int drgb = colorModel.getRGB (rgbElem); + int dr = ((drgb >>> 16) & 0xff) + 1; + int dg = ((drgb >>> 8) & 0xff) + 1; + int db = (drgb & 0xff) + 1; + int da = 256 - sa; + + dr = ((sr*sa + dr*da) >>> 8) - 1; + dg = ((sg*sa + dg*da) >>> 8) - 1; + db = ((sb*sa + db*da) >>> 8) - 1; + + drgb = (dr<<16) | (dg<<8) | db; + + rgbElem = colorModel.getDataElements (drgb, rgbElem); + + raster.setDataElements (xx+x, yy+y, rgbElem); + } } - throw new UnsupportedOperationException("drawing image " + image + - "not implemented"); + directGfx.unmapRaster (mr); + return true; + + } + throw new UnsupportedOperationException ("drawing image " + image + + "not implemented"); } diff --git a/libjava/gnu/awt/xlib/XCanvasPeer.java b/libjava/gnu/awt/xlib/XCanvasPeer.java index 4c141a4c0d8..6ecf7bf3296 100644 --- a/libjava/gnu/awt/xlib/XCanvasPeer.java +++ b/libjava/gnu/awt/xlib/XCanvasPeer.java @@ -214,7 +214,7 @@ public class XCanvasPeer implements CanvasPeer } public Image createImage(int width, int height) { - throw new UnsupportedOperationException("FIXME, not implemented"); + return new XOffScreenImage (config, window, width, height); } public void dispose() { diff --git a/libjava/gnu/awt/xlib/XEventLoop.java b/libjava/gnu/awt/xlib/XEventLoop.java index ad5e963437a..5f5026b0cdb 100644 --- a/libjava/gnu/awt/xlib/XEventLoop.java +++ b/libjava/gnu/awt/xlib/XEventLoop.java @@ -118,57 +118,66 @@ public class XEventLoop implements Runnable * AWT event. */ - AWTEvent createEvent() + AWTEvent createEvent () { + int type = anyEvent.getType (); + // Ignore some events without further processing + switch (type) + { + // ignore "no expose" events, which are generated whenever a pixmap + // is copied to copied to a window which is entirely unobscured + case XAnyEvent.TYPE_NO_EXPOSE: + case XAnyEvent.TYPE_UNMAP_NOTIFY: // ignore for now + case XAnyEvent.TYPE_MAP_NOTIFY: // ignore for now + case XAnyEvent.TYPE_REPARENT_NOTIFY: // ignore for now + return null; + default: + break; // continue processing events not in ignore list + } /* avoid attempting to get client data before client data has been set. */ Object peer; synchronized (this) - { - peer = anyEvent.getWindow().getClientData(); - } - + { + peer = anyEvent.getWindow ().getClientData (); + } + Component source = null; - + // Try to identify source component - + if (peer instanceof XCanvasPeer) - { - source = ((XCanvasPeer) peer).getComponent(); - } - + { + source = ((XCanvasPeer) peer).getComponent (); + } + if (source == null) - { - String msg = "unable to locate source for event (" + - anyEvent + ")"; - throw new RuntimeException(msg); - } - + { + String msg = "unable to locate source for event (" + + anyEvent + "): peer=" + peer; + throw new RuntimeException (msg); + } + /* if a mapping from anyEvent to AWTEvent is possible, construct a new AWTEvent and return it. */ - - int type = anyEvent.getType(); + switch (type) - { + { case XAnyEvent.TYPE_EXPOSE: - return createPaintEvent(source); + return createPaintEvent (source); case XAnyEvent.TYPE_BUTTON_PRESS: case XAnyEvent.TYPE_BUTTON_RELEASE: - return createMouseEvent(type, source); - case XAnyEvent.TYPE_UNMAP_NOTIFY: - case XAnyEvent.TYPE_MAP_NOTIFY: - case XAnyEvent.TYPE_REPARENT_NOTIFY: - return null; // ignore for now + return createMouseEvent (type, source); case XAnyEvent.TYPE_CONFIGURE_NOTIFY: - configureNotify(peer); - return null; - + configureNotify (peer); + return null; + default: - String msg = "Do no know how to handle event (" + anyEvent + ")"; - throw new RuntimeException(msg); - } + String msg = "Do no know how to handle event (" + anyEvent + ")"; + throw new RuntimeException (msg); + } } - + AWTEvent createPaintEvent(Component src) { XExposeEvent expose = new XExposeEvent(anyEvent); diff --git a/libjava/gnu/awt/xlib/XGraphics.java b/libjava/gnu/awt/xlib/XGraphics.java index b8614023377..e27b0a18e8b 100644 --- a/libjava/gnu/awt/xlib/XGraphics.java +++ b/libjava/gnu/awt/xlib/XGraphics.java @@ -20,6 +20,7 @@ import gnu.gcj.xlib.XImage; import gnu.gcj.xlib.Drawable; import gnu.gcj.xlib.Window; import gnu.gcj.xlib.Drawable; +import gnu.gcj.xlib.Pixmap; import gnu.gcj.xlib.Visual; import gnu.awt.j2d.DirectRasterGraphics; import gnu.awt.j2d.MappedRaster; @@ -199,6 +200,16 @@ public class XGraphics implements Cloneable, DirectRasterGraphics public boolean drawImage(Image img, int x, int y, ImageObserver observer) { + if (img instanceof XOffScreenImage) + { + // FIXME: have to enforce clip, or is it OK as-is? + XGraphicsConfiguration.XOffScreenImage offScreenImage + = ((XGraphicsConfiguration.XOffScreenImage)img); + Pixmap pixmap = offScreenImage.getPixmap (); + context.copyArea (pixmap, 0, 0, x, y, + offScreenImage.getWidth (), offScreenImage.getHeight ()); + return true; + } if (clipBounds == null) return false; // ***FIXME*** diff --git a/libjava/gnu/awt/xlib/XOffScreenImage.java b/libjava/gnu/awt/xlib/XOffScreenImage.java new file mode 100644 index 00000000000..71791c1be5f --- /dev/null +++ b/libjava/gnu/awt/xlib/XOffScreenImage.java @@ -0,0 +1,175 @@ +/* Copyright (C) 2000, 2003 Free Software Foundation + + This file is part of libgcj. + +This software is copyrighted work licensed under the terms of the +Libgcj License. Please consult the file "LIBGCJ_LICENSE" for +details. */ + +package gnu.awt.xlib; + +import java.awt.Image; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.GraphicsConfiguration; +import java.awt.image.ColorModel; +import java.awt.image.ImageObserver; +import java.awt.image.ImageProducer; +import java.util.Hashtable; +import gnu.awt.j2d.DirectRasterGraphics; +import gnu.awt.j2d.Graphics2DImpl; +import gnu.awt.j2d.IntegerGraphicsState; +import gnu.gcj.xlib.Drawable; +import gnu.gcj.xlib.Pixmap; +import gnu.gcj.xlib.Screen; +import gnu.gcj.xlib.Visual; + +/** Image class for xlib off-screen buffers. + * The image is stored in a server-side pixmap for best performance. + * This class supports getGraphics, so you can draw on the pixmap, and is + * specially handled when doing drawImage, so that the image copy is done + * entirely in the X server. + * This class does not support rasterization, for which you'd need an XImage. + * + * @author scott gilbertson + */ +public class XOffScreenImage extends Image + implements IntegerGraphicsState.ScreenCoupledImage +{ + private Pixmap pixmap; + private XGraphicsConfiguration config; + private int width; + private int height; + + /** Create a new XOffScreenImage + * @param config Graphics configuration, to compare against on-screen + * components and to create the appropriate Graphics + * @param drawable The drawable with which the image is compatible + * @param width The width of the image + * @param height The height of the image + */ + XOffScreenImage (XGraphicsConfiguration config, Drawable drawable, int width, int height) + { + this.config = config; + this.width = width; + this.height = height; + pixmap = new Pixmap (drawable, width, height, drawable.getDepth ()); + } + + /** Get the pixmap which contains this image + * @return The pixmap + */ + public Pixmap getPixmap () + { + return pixmap; + } + + /** Flushes (that is, destroys) any resources used for this image. This + * includes the actual image data. + */ + public void flush () + { + // FIXME: should dispose pixmap + pixmap = null; + } + + /** Returns a graphics context object for drawing an off-screen object. + * This method is only valid for off-screen objects. + * + * @return a graphics context object for an off-screen object + * @see Graphics#createImage(int, int) + */ + public Graphics getGraphics () + { + DirectRasterGraphics gfxDevice = new XGraphics (pixmap, config); + IntegerGraphicsState igState = new IntegerGraphicsState (gfxDevice); + Graphics2DImpl gfx2d = new Graphics2DImpl (config); + gfx2d.setState (igState); + return gfx2d; + } + + /** Returns the height of the image, or -1 if it is unknown. If the + * image height is unknown, the observer object will be notified when + * the value is known. + * + * @param observer the image observer for this object + * @return the height in pixels + * @see #getWidth(ImageObserver) + */ + public int getHeight (ImageObserver observer) + { + return height; + } + + /** Returns the height of the image, or -1 if it is unknown. If the + * image height is unknown, the observer object will be notified when + * the value is known. + * + * @return the height in pixels + * @see #getWidth() + */ + public int getHeight () + { + return height; + } + + /** Returns the image producer object for this object. The producer is the + * object which generates pixels for this image. + * + * @return the image producer for this object + */ + public ImageProducer getSource () + { + throw new UnsupportedOperationException ("getSource not supported"); + } + + /** Returns the width of the image, or -1 if it is unknown. If the + * image width is unknown, the observer object will be notified when + * the value is known. + * + * @param observer the image observer for this object + * @return the width in pixels + * @see #getHeight(ImageObserver) + */ + public int getWidth (ImageObserver observer) + { + return width; + } + + /** Returns the width of the image, or -1 if it is unknown. If the + * image width is unknown, the observer object will be notified when + * the value is known. + * + * @return the width in pixels + * @see #getHeight() + */ + public int getWidth () + { + return width; + } + + /** This method requests a named property for an object. The value of the + * property is returned. The value UndefinedProperty is + * returned if there is no property with the specified name. The value + * null is returned if the properties for the object are + * not yet known. In this case, the specified image observer is notified + * when the properties are known. + * + * @param name the requested property name + * @param observer the image observer for this object + * @return the named property, if available + * @see #UndefinedProperty + */ + public Object getProperty (String name, ImageObserver observer) + { + return null; + } + + /** Get the GraphicsConfiguration to which this image is coupled + * @return the GraphicsConfiguration + */ + public GraphicsConfiguration getGraphicsConfiguration () + { + return config; + } +} diff --git a/libjava/gnu/gcj/xlib/Drawable.java b/libjava/gnu/gcj/xlib/Drawable.java index 551aca84c18..fa12ba2b3fe 100644 --- a/libjava/gnu/gcj/xlib/Drawable.java +++ b/libjava/gnu/gcj/xlib/Drawable.java @@ -79,6 +79,8 @@ public class Drawable extends XID public native Rectangle getBounds(Rectangle rv); + public native int getDepth (); + private static final String MSG_XGETSUBIMAGE_FAILED = "XGetSubImage() failed."; diff --git a/libjava/gnu/gcj/xlib/GC.java b/libjava/gnu/gcj/xlib/GC.java index b7eb0b682f4..24cd3bd1f53 100644 --- a/libjava/gnu/gcj/xlib/GC.java +++ b/libjava/gnu/gcj/xlib/GC.java @@ -138,6 +138,11 @@ public class GC implements Cloneable int destX, int destY, int width, int height); + public native void copyArea (Drawable source, + int srcX, int srcY, + int destX, int destY, + int width, int height); + public Drawable getDrawable() { return target; diff --git a/libjava/gnu/gcj/xlib/XAnyEvent.java b/libjava/gnu/gcj/xlib/XAnyEvent.java index e7a4a02b987..df1ad782d79 100644 --- a/libjava/gnu/gcj/xlib/XAnyEvent.java +++ b/libjava/gnu/gcj/xlib/XAnyEvent.java @@ -19,14 +19,40 @@ import gnu.gcj.RawData; public final class XAnyEvent { // Must match the definitions in X.h: - public static final int TYPE_BUTTON_PRESS = 4, - TYPE_BUTTON_RELEASE = 5, - TYPE_EXPOSE = 12, - TYPE_UNMAP_NOTIFY = 18, - TYPE_MAP_NOTIFY = 19, - TYPE_REPARENT_NOTIFY = 21, - TYPE_CONFIGURE_NOTIFY = 22, - TYPE_CLIENT_MESSAGE = 33; + public static final int + TYPE_KEY_PRESS = 2, + TYPE_KEY_RELEASE = 3, + TYPE_BUTTON_PRESS = 4, + TYPE_BUTTON_RELEASE = 5, + TYPE_MOTION_NOTIFY = 6, + TYPE_ENTER_NOTIFY = 7, + TYPE_LEAVE_NOTIFY = 8, + TYPE_FOCUS_IN = 9, + TYPE_FOCUS_OUT = 10, + TYPE_KEYMAP_NOTIFY = 11, + TYPE_EXPOSE = 12, + TYPE_GRAPHICS_EXPOSE = 13, + TYPE_NO_EXPOSE = 14, + TYPE_VISIBILITY_NOTIFY = 15, + TYPE_CREATE_NOTIFY = 16, + TYPE_DESTROY_NOTIFY = 17, + TYPE_UNMAP_NOTIFY = 18, + TYPE_MAP_NOTIFY = 19, + TYPE_MAP_REQUEST = 20, + TYPE_REPARENT_NOTIFY = 21, + TYPE_CONFIGURE_NOTIFY = 22, + TYPE_CONFIGURE_REQUEST = 23, + TYPE_GRAVITY_NOTIFY = 24, + TYPE_RESIZE_REQUEST = 25, + TYPE_CIRCULATE_NOTIFY = 26, + TYPE_CIRCULATE_REQUEST = 27, + TYPE_PROPERTY_NOTIFY = 28, + TYPE_SELECTION_CLEAR = 29, + TYPE_SELECTION_REQUEST = 30, + TYPE_SELECTION_NOTIFY = 31, + TYPE_COLORMAP_NOTIFY = 32, + TYPE_CLIENT_MESSAGE = 33, + TYPE_MAPPING_NOTIFY = 34; // Must match the definitions in X.h: public final static long MASK_SUBSTRUCTURE_NOTIFY = 1L<<19, diff --git a/libjava/gnu/gcj/xlib/natDrawable.cc b/libjava/gnu/gcj/xlib/natDrawable.cc index 6cca3b74901..87c9d3572b2 100644 --- a/libjava/gnu/gcj/xlib/natDrawable.cc +++ b/libjava/gnu/gcj/xlib/natDrawable.cc @@ -43,6 +43,26 @@ jboolean gnu::gcj::xlib::Drawable::copyIntoXImageImpl(XImage* image, return true; } +jint gnu::gcj::xlib::Drawable::getDepth () +{ + ::Display* dpy = (::Display*) (getDisplay ()->display); + ::Window root; + int x, y; + unsigned int w, h, bw, depth; + + Status status = XGetGeometry (dpy, getXID(), &root, + &x, &y, &w, &h, + &bw, &depth); + switch (status) + { + case BadDrawable: + throw new XException (display, status); + default: + ; // All OK, NOP. + } + return (jint)depth; +} + java::awt::Rectangle* gnu::gcj::xlib::Drawable::getBounds(java::awt::Rectangle* rv) { diff --git a/libjava/gnu/gcj/xlib/natGC.cc b/libjava/gnu/gcj/xlib/natGC.cc index fd9fca84564..17bcbe67b5a 100644 --- a/libjava/gnu/gcj/xlib/natGC.cc +++ b/libjava/gnu/gcj/xlib/natGC.cc @@ -237,3 +237,18 @@ void gnu::gcj::xlib::GC::updateClip() ordering); // no fast fail } + +void gnu::gcj::xlib::GC::copyArea (gnu::gcj::xlib::Drawable * source, + jint srcX, jint srcY, + jint destX, jint destY, + jint width, jint height) +{ + Display* display = target->getDisplay (); + ::Display* dpy = (::Display*) (display->display); + ::Drawable drawableXID = target->getXID (); + ::GC gc = (::GC) structure; + ::Drawable srcXID = source->getXID (); + + XCopyArea (dpy, srcXID, drawableXID, gc, srcX, srcY, width, height, + destX, destY); +} diff --git a/libjava/java/awt/Component.java b/libjava/java/awt/Component.java index 98511ef7c6e..11663a7d122 100644 --- a/libjava/java/awt/Component.java +++ b/libjava/java/awt/Component.java @@ -1866,12 +1866,17 @@ public abstract class Component * @param height the height of the image * @return the requested image, or null if it is not supported */ - public Image createImage(int width, int height) + public Image createImage (int width, int height) { - if (GraphicsEnvironment.isHeadless()) - return null; - GraphicsConfiguration config = getGraphicsConfiguration(); - return config == null ? null : config.createCompatibleImage(width, height); + Image returnValue = null; + if (!GraphicsEnvironment.isHeadless ()) + { + if (isLightweight () && parent != null) + returnValue = parent.createImage (width, height); + else if (peer != null) + returnValue = peer.createImage (width, height); + } + return returnValue; } /** -- 2.30.2