summaryrefslogtreecommitdiffstats
path: root/libjava/gnu/gcj/xlib
diff options
context:
space:
mode:
authorrolfwr <rolfwr@138bc75d-0d04-0410-961f-82ee72b054a4>2000-10-22 17:46:09 +0000
committerrolfwr <rolfwr@138bc75d-0d04-0410-961f-82ee72b054a4>2000-10-22 17:46:09 +0000
commite2d342dffa63aea98643515fd3b8c782ee8bd15e (patch)
tree1165199489e8bc851f2bb5c11ff0228f3667453e /libjava/gnu/gcj/xlib
parentcfed8d62a245d6113c86f79ffb2e4f09b2becc8d (diff)
downloadppe42-gcc-e2d342dffa63aea98643515fd3b8c782ee8bd15e.tar.gz
ppe42-gcc-e2d342dffa63aea98643515fd3b8c782ee8bd15e.zip
* Makefile.am: Added rules for libgcjx library.
* Makefile.in: Rebuilt. * configure.in: Added check for X. * configure: Rebuilt. * gnu/awt/LightweightRedirector.java: New file. * gnu/awt/j2d/AbstractGraphicsState.java: New file. * gnu/awt/j2d/DirectRasterGraphics.java: New file. * gnu/awt/j2d/Graphics2DImpl.java: New file. * gnu/awt/j2d/IntegerGraphicsState.java: New file. * gnu/awt/j2d/MappedRaster.java: New file. * gnu/awt/xlib/XCanvasPeer.java: New file. * gnu/awt/xlib/XEventLoop.java: New file. * gnu/awt/xlib/XEventQueue.java: New file. * gnu/awt/xlib/XFontMetrics.java: New file. * gnu/awt/xlib/XFramePeer.java: New file. * gnu/awt/xlib/XGraphics.java: New file. * gnu/awt/xlib/XGraphicsConfiguration.java: New file. * gnu/awt/xlib/XPanelPeer.java: New file. * gnu/awt/xlib/XToolkit.java: New file. * gnu/gcj/xlib/Clip.java: New file. * gnu/gcj/xlib/Colormap.java: New file. * gnu/gcj/xlib/Display.java: New file. * gnu/gcj/xlib/Drawable.java: New file. * gnu/gcj/xlib/Font.java: New file. * gnu/gcj/xlib/GC.java: New file. * gnu/gcj/xlib/Pixmap.java: New file. * gnu/gcj/xlib/Screen.java: New file. * gnu/gcj/xlib/Visual.java: New file. * gnu/gcj/xlib/WMSizeHints.java: New file. * gnu/gcj/xlib/Window.java: New file. * gnu/gcj/xlib/WindowAttributes.java: New file. * gnu/gcj/xlib/XAnyEvent.java: New file. * gnu/gcj/xlib/XButtonEvent.java: New file. * gnu/gcj/xlib/XColor.java: New file. * gnu/gcj/xlib/XConfigureEvent.java: New file. * gnu/gcj/xlib/XConnectException.java: New file. * gnu/gcj/xlib/XEvent.java: New file. * gnu/gcj/xlib/XException.java: New file. * gnu/gcj/xlib/XExposeEvent.java: New file. * gnu/gcj/xlib/XID.java: New file. * gnu/gcj/xlib/XImage.java: New file. * gnu/gcj/xlib/XUnmapEvent.java: New file. * gnu/gcj/xlib/natClip.cc: New file. * gnu/gcj/xlib/natColormap.cc: New file. * gnu/gcj/xlib/natDisplay.cc: New file. * gnu/gcj/xlib/natDrawable.cc: New file. * gnu/gcj/xlib/natFont.cc: New file. * gnu/gcj/xlib/natGC.cc: New file. * gnu/gcj/xlib/natPixmap.cc: New file. * gnu/gcj/xlib/natScreen.cc: New file. * gnu/gcj/xlib/natVisual.cc: New file. * gnu/gcj/xlib/natWMSizeHints.cc: New file. * gnu/gcj/xlib/natWindow.cc: New file. * gnu/gcj/xlib/natWindowAttributes.cc: New file. * gnu/gcj/xlib/natXAnyEvent.cc: New file. * gnu/gcj/xlib/natXButtonEvent.cc: New file. * gnu/gcj/xlib/natXColor.cc: New file. * gnu/gcj/xlib/natXConfigureEvent.cc: New file. * gnu/gcj/xlib/natXException.cc: New file. * gnu/gcj/xlib/natXExposeEvent.cc: New file. * gnu/gcj/xlib/natXImage.cc: New file. * gnu/gcj/xlib/natXUnmapEvent.cc: New file. * java/awt/EventDispatchThread.java: Start thead on creation. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@37005 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/gnu/gcj/xlib')
-rw-r--r--libjava/gnu/gcj/xlib/Clip.java35
-rw-r--r--libjava/gnu/gcj/xlib/Colormap.java84
-rw-r--r--libjava/gnu/gcj/xlib/Display.java105
-rw-r--r--libjava/gnu/gcj/xlib/Drawable.java82
-rw-r--r--libjava/gnu/gcj/xlib/Font.java51
-rw-r--r--libjava/gnu/gcj/xlib/GC.java113
-rw-r--r--libjava/gnu/gcj/xlib/Pixmap.java43
-rw-r--r--libjava/gnu/gcj/xlib/Screen.java86
-rw-r--r--libjava/gnu/gcj/xlib/Visual.java152
-rw-r--r--libjava/gnu/gcj/xlib/WMSizeHints.java44
-rw-r--r--libjava/gnu/gcj/xlib/Window.java104
-rw-r--r--libjava/gnu/gcj/xlib/WindowAttributes.java106
-rw-r--r--libjava/gnu/gcj/xlib/XAnyEvent.java75
-rw-r--r--libjava/gnu/gcj/xlib/XButtonEvent.java53
-rw-r--r--libjava/gnu/gcj/xlib/XColor.java42
-rw-r--r--libjava/gnu/gcj/xlib/XConfigureEvent.java32
-rw-r--r--libjava/gnu/gcj/xlib/XConnectException.java30
-rw-r--r--libjava/gnu/gcj/xlib/XEvent.java45
-rw-r--r--libjava/gnu/gcj/xlib/XException.java27
-rw-r--r--libjava/gnu/gcj/xlib/XExposeEvent.java33
-rw-r--r--libjava/gnu/gcj/xlib/XID.java58
-rw-r--r--libjava/gnu/gcj/xlib/XImage.java226
-rw-r--r--libjava/gnu/gcj/xlib/XUnmapEvent.java33
-rw-r--r--libjava/gnu/gcj/xlib/natClip.cc52
-rw-r--r--libjava/gnu/gcj/xlib/natColormap.cc147
-rw-r--r--libjava/gnu/gcj/xlib/natDisplay.cc132
-rw-r--r--libjava/gnu/gcj/xlib/natDrawable.cc79
-rw-r--r--libjava/gnu/gcj/xlib/natFont.cc95
-rw-r--r--libjava/gnu/gcj/xlib/natGC.cc207
-rw-r--r--libjava/gnu/gcj/xlib/natPixmap.cc39
-rw-r--r--libjava/gnu/gcj/xlib/natScreen.cc53
-rw-r--r--libjava/gnu/gcj/xlib/natVisual.cc146
-rw-r--r--libjava/gnu/gcj/xlib/natWMSizeHints.cc75
-rw-r--r--libjava/gnu/gcj/xlib/natWindow.cc171
-rw-r--r--libjava/gnu/gcj/xlib/natWindowAttributes.cc109
-rw-r--r--libjava/gnu/gcj/xlib/natXAnyEvent.cc99
-rw-r--r--libjava/gnu/gcj/xlib/natXButtonEvent.cc30
-rw-r--r--libjava/gnu/gcj/xlib/natXColor.cc61
-rw-r--r--libjava/gnu/gcj/xlib/natXConfigureEvent.cc31
-rw-r--r--libjava/gnu/gcj/xlib/natXException.cc24
-rw-r--r--libjava/gnu/gcj/xlib/natXExposeEvent.cc31
-rw-r--r--libjava/gnu/gcj/xlib/natXImage.cc220
-rw-r--r--libjava/gnu/gcj/xlib/natXUnmapEvent.cc32
43 files changed, 3492 insertions, 0 deletions
diff --git a/libjava/gnu/gcj/xlib/Clip.java b/libjava/gnu/gcj/xlib/Clip.java
new file mode 100644
index 00000000000..28bb02a8e21
--- /dev/null
+++ b/libjava/gnu/gcj/xlib/Clip.java
@@ -0,0 +1,35 @@
+/* Copyright (C) 2000 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.gcj.xlib;
+
+import gnu.gcj.RawData;
+import java.awt.Rectangle;
+
+/**
+ * Describes a clip that is used to constrain drawing using a GC
+ * within a specific region. Currently it supports clip regions
+ * consisting of the union of multiple rectangles. Other clip forms
+ * may be implented later. This class is used internally by the GC
+ * class, and wraps a native XRectVector[].
+ *
+ * @author Rolf W. Rasmussen <rolfwr@ii.uib.no>
+ */
+final class Clip
+{
+ public Clip(Rectangle[] rects)
+ {
+ init(rects);
+ }
+
+ private native void init(Rectangle[] rects);
+
+ public native void finalize();
+
+ RawData xrects;
+}
diff --git a/libjava/gnu/gcj/xlib/Colormap.java b/libjava/gnu/gcj/xlib/Colormap.java
new file mode 100644
index 00000000000..538782e7e76
--- /dev/null
+++ b/libjava/gnu/gcj/xlib/Colormap.java
@@ -0,0 +1,84 @@
+/* Copyright (C) 2000 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.gcj.xlib;
+
+import gnu.gcj.RawData;
+
+/**
+ * An X11 color map resource.
+ *
+ * @author Rolf W. Rasmussen <rolfwr@ii.uib.no>
+ */
+public final class Colormap extends XID
+{
+ Screen screen;
+
+ public static final byte FLAG_SHARED = 1;
+ public static final byte FLAG_NOT_SHARED = 2;
+
+ public Colormap(Screen screen, int xid)
+ {
+ super(screen.getDisplay(), xid);
+ this.screen = screen;
+ }
+
+ /**
+ * Allocate color pixel.
+ *
+ * @param color The color to be allocated. If allocation is
+ * successful, this object will be modified to reflect the actual
+ * color that was allocated.
+ *
+ * @return the pixel value of the allocated color.
+ */
+ public native long allocateColorPixel(XColor color);
+
+ /**
+ * Allocate a color consisting of the given RGB-triplet.
+ *
+ * @return a color object describing the allocated color.
+ */
+ public XColor allocateColor(int r, int g, int b)
+ {
+ XColor color = new XColor(r, g, b);
+ allocateColorPixel(color);
+
+ return color;
+ }
+
+ /**
+ * Get an array of all colors that currently resides in shared (read
+ * only) color-cells in this color map.
+ */
+ public native XColor[] getSharedColors();
+
+
+ /**
+ * Get all colors currently residing in this color map. Colors that
+ * are shared (read only) are marked as such by the color flags.
+ * The indexes of the returned array will correspond to the
+ * colorcells of the color map. Given a color <code>XColor
+ * color</code> from a given color-cell, the expression
+ * <code>color.getFlags() == Colormap.FLAG_SHARED</code> will check
+ * whether the color-cell is shared.
+ */
+ public native XColor[] getXColors();
+
+ /**
+ * Convenience method used by native code to create fully
+ * initialized arrays of XColor objects.
+ */
+ private XColor[] newXColorArray(int n)
+ {
+ XColor[] array = new XColor[n];
+ for (int i=0; i<n; i++)
+ array[i] = new XColor();
+ return array;
+ }
+}
diff --git a/libjava/gnu/gcj/xlib/Display.java b/libjava/gnu/gcj/xlib/Display.java
new file mode 100644
index 00000000000..50ff1291b71
--- /dev/null
+++ b/libjava/gnu/gcj/xlib/Display.java
@@ -0,0 +1,105 @@
+/* Copyright (C) 1999, 2000 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.gcj.xlib;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.Vector;
+import java.util.Enumeration;
+
+import gnu.gcj.RawData;
+
+/**
+ * A connection to an X11 display.
+ *
+ * @author Rolf W. Rasmussen <rolfwr@ii.uib.no>
+ */
+
+public class Display
+{
+ static
+ {
+ staticInit();
+ }
+
+ public Display()
+ {
+ init();
+ }
+
+ private static native void staticInit();
+ private native void init();
+ protected native void finalize();
+
+ RawData display = null;
+
+ /* TODO?: Rather than storing such data here, we might consider
+ using the context manager facilities provided by Xlib... */
+ private Dictionary xids = new Hashtable();
+
+ protected final void addXID(int xid, XID window)
+ {
+ xids.put(new Integer(xid), window);
+ }
+
+ protected final void removeXID(int xid)
+ {
+ xids.remove(new Integer(xid));
+ }
+
+ public final Window getDefaultRootWindow()
+ {
+ int rootXID = getDefaultRootWindowXID();
+ return getWindow(rootXID);
+ }
+
+ public final XID getXID(int xid)
+ {
+ return (XID) xids.get(new Integer(xid));
+ }
+
+ public final Window getWindow(int xid)
+ {
+ Window window = (Window) getXID(xid);
+ if (window == null)
+ {
+ window = new Window(this, xid);
+ addXID(xid, window);
+ }
+ return window;
+ }
+
+ public final Screen getDefaultScreen()
+ {
+ /* Screens objects are not cached since they are lightweight.
+ We just create a new object when requested. */
+ return new Screen(this, getDefaultScreenNumber());
+ }
+
+ public final native int getDefaultScreenNumber();
+
+ private final native int getDefaultRootWindowXID();
+
+ private Dictionary atoms = new Hashtable();
+
+ public final int getAtom(String name)
+ {
+ Integer atomInt = (Integer) atoms.get(name);
+ if (atomInt == null)
+ return internAtom(name);
+ return atomInt.intValue();
+ }
+
+ // TODO?: cache reverse lookup too?
+ public final native String getAtomName(int atom);
+
+ private final native int internAtom(String name);
+
+ public native void flush();
+}
diff --git a/libjava/gnu/gcj/xlib/Drawable.java b/libjava/gnu/gcj/xlib/Drawable.java
new file mode 100644
index 00000000000..56527927b1b
--- /dev/null
+++ b/libjava/gnu/gcj/xlib/Drawable.java
@@ -0,0 +1,82 @@
+/* Copyright (C) 1999, 2000 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.gcj.xlib;
+
+import java.awt.Rectangle;
+
+/** An X11 drawable.
+ *
+ * @author Rolf W. Rasmussen <rolfwr@ii.uib.no>
+ */
+public class Drawable extends XID
+{
+ public Drawable(Display display, int xid)
+ {
+ super(display, xid);
+ }
+
+ /**
+ * Gets as much as possible of the image data within the requested
+ * region. Data from obscured parts of windows may not be
+ * retrievable.
+ *
+ * @param dest where to place the image data.
+ *
+ * @return the actual region of image data that was retrieved.
+ */
+ public Rectangle copyIntoXImage(XImage dest, Rectangle bounds,
+ int destX, int destY)
+ {
+ Rectangle newBounds = null;
+ int tries = 5;
+ while (!bounds.isEmpty())
+ {
+ if (copyIntoXImageImpl(dest, bounds.x, bounds.y,
+ bounds.width, bounds.height,
+ destX, destY))
+ return bounds;
+
+ // failed, likely due to wrong bounds...
+
+ newBounds = getBounds(newBounds);
+
+ bounds = newBounds.intersection(bounds);
+
+ tries--;
+
+ if (tries < 0)
+ throw new RuntimeException("copyIntoXImage is buggy");
+
+ }
+
+ return bounds; // always empty
+ }
+
+
+
+ /**
+ * Performs an XGetSubImage. This method will fail if the X server
+ * does not possess the requested image data. This might occur when
+ * requesting the image date of a window that is partially obscured.
+ *
+ * @param desitantionImage where to place the image data
+ *
+ * @return false if method was unable to read the requested region.
+ */
+ private native boolean copyIntoXImageImpl(XImage destinationImage,
+ int x, int y,
+ int width, int height,
+ int destX, int destY);
+
+ public native Rectangle getBounds(Rectangle rv);
+
+ private static final String MSG_XGETSUBIMAGE_FAILED =
+ "XGetSubImage() failed.";
+
+}
diff --git a/libjava/gnu/gcj/xlib/Font.java b/libjava/gnu/gcj/xlib/Font.java
new file mode 100644
index 00000000000..cd2fff9630d
--- /dev/null
+++ b/libjava/gnu/gcj/xlib/Font.java
@@ -0,0 +1,51 @@
+/* Copyright (C) 2000 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.gcj.xlib;
+
+import gnu.gcj.RawData;
+
+/**
+ * An X11 Font, implemented as a wrapper around an X11 Font XID and
+ * the associated Xlib XFontStruct structure.
+ *
+ * @author Rolf W. Rasmussen <rolfwr@ii.uib.no>
+ */
+public final class Font extends XID
+{
+
+ /**
+ * @param lfdNamePattern a font name pattern following the
+ * <em>X Logical Font Description Conventions</em>.
+ */
+ public Font(Display display, String lfdNamePattern)
+ {
+ this(display, loadFont(display, lfdNamePattern));
+ }
+
+ Font(Display display, RawData struct)
+ {
+ super(display, getXIDFromStruct(struct));
+ structure = struct;
+ }
+
+ static native RawData loadFont(Display display, String lfdNamePattern);
+
+ static native int getXIDFromStruct(RawData structure);
+
+ public native int getAscent();
+ public native int getDescent();
+ public native int getMaxAscent();
+ public native int getMaxDescent();
+
+ public native int getStringWidth(String str);
+
+ protected native void finalize();
+
+ RawData structure;
+}
diff --git a/libjava/gnu/gcj/xlib/GC.java b/libjava/gnu/gcj/xlib/GC.java
new file mode 100644
index 00000000000..6b33715cf6c
--- /dev/null
+++ b/libjava/gnu/gcj/xlib/GC.java
@@ -0,0 +1,113 @@
+/* Copyright (C) 2000 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.gcj.xlib;
+
+import gnu.gcj.RawData;
+import java.awt.Rectangle;
+
+/**
+ * An X11 graphics context. Unlike a traditional X11 graphics
+ * context, the target drawable is part of the GC state.
+ *
+ * Implementation notes: There is no need to do coalescing of changes
+ * since Xlib will do this for us. The implementation relies on the
+ * Xlib GC cache and will not try to be clever.
+ *
+ * @author Rolf W. Rasmussen <rolfwr@ii.uib.no>
+ */
+public class GC implements Cloneable
+{
+
+ public GC(Drawable target)
+ {
+ this.target = target;
+ initStructure(null);
+ }
+
+ public Object clone()
+ {
+ GC gcClone = (GC) super.clone();
+ gcClone.structure = null;
+ gcClone.initStructure(this);
+ gcClone.updateClip();
+ return gcClone;
+ }
+
+ private native void initStructure(GC copyFrom);
+
+ public GC create()
+ {
+ return (GC) clone();
+ }
+
+ public void finalize()
+ {
+ disposeImpl();
+ }
+
+ public void dispose()
+ {
+ disposeImpl();
+ }
+
+ public synchronized native void disposeImpl();
+
+ public native void setForeground(long pixel);
+ public native void setFont(gnu.gcj.xlib.Font font);
+
+ /**
+ * Set the clip region for the graphics operations performed by the
+ * GC.
+ *
+ * This is one of the few costly operations of this class. It is
+ * suggested that the clip is only set or changed if really
+ * necessary. Higher level APIs can make such optimizations
+ * transparent.
+ *
+ * @param rectangles the union of these rectangles describe the clip
+ * region.
+ */
+ public void setClipRectangles(Rectangle[] rectangles)
+ {
+ clip = new Clip(rectangles);
+ updateClip();
+ }
+
+ public native void drawString(String text, int x, int y);
+ public native void drawLine(int x1, int y1, int x2, int y2);
+ public native void drawRectangle(int x, int y, int w, int h);
+
+ public native void fillRectangle(int x, int y, int w, int h);
+
+ /**
+ *
+ * Clear area using the background pixel or pixmap of the drawable.
+ * Note that this operation does not adhere to the current clip.
+ */
+ public native void clearArea(int x, int y, int w, int h,
+ boolean exposures);
+
+
+ public native void putImage(XImage image,
+ int srcX, int srcY,
+ int destX, int destY,
+ int width, int height);
+
+ public Drawable getDrawable()
+ {
+ return target;
+ }
+
+ private native void updateClip();
+
+ private Drawable target;
+ private RawData structure;
+ private Clip clip;
+}
+
diff --git a/libjava/gnu/gcj/xlib/Pixmap.java b/libjava/gnu/gcj/xlib/Pixmap.java
new file mode 100644
index 00000000000..a81f55c8761
--- /dev/null
+++ b/libjava/gnu/gcj/xlib/Pixmap.java
@@ -0,0 +1,43 @@
+/* Copyright (C) 2000 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.gcj.xlib;
+
+/**
+ * An X11 Pixmap. A pixmap is an offscreen drawable that resides on
+ * the X server. A pixmap is bound to the screen it was created for.
+ *
+ * @author Rolf W. Rasmussen <rolfwr@ii.uib.no>
+ */
+public class Pixmap extends Drawable
+{
+ public Pixmap(XImage image, Screen screen)
+ {
+ this(screen.getRootWindow(),
+ image.getWidth(), image.getHeight(),
+ image.getDepth());
+
+ /* FIXME: don't create a new GC all the time. This might actually
+ not be as bad as initially believed. The GC cache of Xlib makes
+ this opertation less costly. */
+ GC gc = new GC(this);
+
+ gc.putImage(image, 0, 0, 0, 0, image.getWidth(), image.getHeight());
+ }
+
+ public Pixmap(Drawable sameScreenAs, int width, int height, int depth)
+ {
+ super(sameScreenAs.getDisplay(),
+ createXID(sameScreenAs, width, height, depth));
+ }
+
+ protected static native int createXID(Drawable sameScreenAs,
+ int width, int height, int depth);
+
+ protected native void finalize();
+}
diff --git a/libjava/gnu/gcj/xlib/Screen.java b/libjava/gnu/gcj/xlib/Screen.java
new file mode 100644
index 00000000000..675ed1b9bd0
--- /dev/null
+++ b/libjava/gnu/gcj/xlib/Screen.java
@@ -0,0 +1,86 @@
+/* Copyright (C) 2000 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.gcj.xlib;
+
+import gnu.gcj.RawData;
+
+/**
+ * A flyweight class that denotes an X11 screen. Display and screen
+ * number is the only data kept by this class. The real screen
+ * structure is stored in the display. There may exist several
+ * objects denoting the same screen.
+ *
+ * @author Rolf W. Rasmussen <rolfwr@ii.uib.no>
+ */
+public final class Screen
+{
+ static final int UNKNOWN = -1;
+
+ Display display;
+ int screenNumber = UNKNOWN;
+ RawData structure;
+
+ Screen(Display display, RawData screenStructure)
+ {
+ structure = screenStructure;
+ this.display = display;
+ }
+
+ public Screen(Display display)
+ {
+ this(display, display.getDefaultScreenNumber());
+ }
+
+ public Screen(Display display, int screenNumber)
+ {
+ this.display = display;
+ this.screenNumber = screenNumber;
+ initStructure();
+ }
+
+ public final Display getDisplay()
+ {
+ return display;
+ }
+
+ public Window getRootWindow()
+ {
+ int rootXID = getRootWindowXID();
+ return display.getWindow(rootXID);
+ }
+
+ public Visual getRootVisual()
+ {
+ RawData visualStructure = getRootVisualStructure();
+ int depth = getRootDepth();
+ return new Visual(visualStructure, this, depth);
+ }
+
+ private native RawData getRootVisualStructure();
+
+ public native int getRootDepth();
+ public native int getRootWindowXID();
+ public native int getDefaultColormapXID();
+
+ native void initStructure();
+
+ public Colormap getDefaultColormap()
+ {
+ return new Colormap(this, getDefaultColormapXID());
+ }
+
+ public final int getScreenNumber()
+ {
+ if (screenNumber == UNKNOWN)
+ screenNumber = findScreenNumber();
+ return screenNumber;
+ }
+
+ public native int findScreenNumber();
+}
diff --git a/libjava/gnu/gcj/xlib/Visual.java b/libjava/gnu/gcj/xlib/Visual.java
new file mode 100644
index 00000000000..46fd3ee9936
--- /dev/null
+++ b/libjava/gnu/gcj/xlib/Visual.java
@@ -0,0 +1,152 @@
+/* Copyright (C) 2000 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.gcj.xlib;
+
+import gnu.gcj.RawData;
+
+/**
+ * A visual determines how a color is encoded into a pixel/bitfield
+ * value. It does not determine how the pixel/bitfield value is
+ * encoded into the image data.
+ *
+ * <p>This class encapsulates all three Xlib representations of a
+ * visual.
+ *
+ * <ul>
+ *
+ * <li>int: visual id.
+ *
+ * <li>Visual: opaque data structure used by a lot of Xlib functions.
+ *
+ * <li>VisualInfo: transparent data structure that binds the visual to
+ * a certain screen and depth.
+ *
+ * </ul>
+ *
+ * <p>Implementation note: This class does not examine nor manipulate
+ * the Visual structure, since the X manual says the structure is
+ * opaque, and that XVisualInfo should be used instead.</p>
+ *
+ * @author Rolf W. Rasmussen <rolfwr@ii.uib.no>
+ */
+public final class Visual
+{
+ public static final int VC_STATIC_GRAY = 0,
+ VC_GRAY_SCALE = 1,
+ VC_STATIC_COLOR = 2,
+ VC_PSEUDO_COLOR = 3,
+ VC_TRUE_COLOR = 4,
+ VC_DIRECT_COLOR = 5;
+
+ protected static final int MASK_ID = 1 << 0,
+ MASK_SCREEN = 1 << 1,
+ MASK_DEPTH = 1 << 2,
+ MASK_CLASS = 1 << 3,
+ MASK_RED = 1 << 4,
+ MASK_GREEN = 1 << 5,
+ MASK_BLUE = 1 << 6,
+ MASK_COLORMAP_SIZE = 1 << 7,
+ MASK_BITS_PER_RGB = 1 << 8;
+
+ protected static final int MASK_ALL = MASK_ID
+ | MASK_SCREEN
+ | MASK_DEPTH
+ | MASK_CLASS
+ | MASK_RED
+ | MASK_GREEN
+ | MASK_BLUE
+ | MASK_COLORMAP_SIZE
+ | MASK_BITS_PER_RGB;
+
+ private static final int MASK_VISUAL_STRUCTURE = 1 << 31;
+
+ Display display;
+ RawData xVisualInfo;
+ int infoMask;
+ Screen screen;
+
+ Visual(RawData structure, Screen screen, int depth )
+ {
+ this.display = screen.getDisplay();
+ this.screen = screen;
+ init(structure, depth);
+ }
+
+ Visual(Display display, RawData structure, int depth )
+ {
+ this.display = display;
+ init(structure, depth);
+ }
+
+ protected native void init(RawData structure, int depth);
+
+ protected native void finalize();
+
+ /**
+ *
+ * Returns the a reference to the visual structure. This method has
+ * package accessibility since the data visual structure is only
+ * useful for direct Xlib calls.
+ *
+ * @return a pointer to the visual structure.
+ */
+ native RawData getVisualStructure();
+
+
+ // These methods only make sense if the visual is decomposed:
+
+ public native int getRedMask();
+ public native int getGreenMask();
+ public native int getBlueMask();
+
+ public native int getScreenNumber();
+ public native int getDepth();
+
+ public Screen getScreen()
+ {
+ if (screen == null)
+ screen = new Screen(display, getScreenNumber());
+ return screen;
+ }
+
+ public native int getVisualClass();
+
+ public boolean hasRGBSubfields()
+ {
+ switch (getVisualClass())
+ {
+ case VC_TRUE_COLOR:
+ case VC_DIRECT_COLOR:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ protected native void ensureXVisualInfo(int requiredMask);
+
+
+ public String toString()
+ {
+ int missingInfo = ~infoMask;
+ boolean hasSubfieldInfo =
+ (missingInfo & (MASK_CLASS|MASK_RED|MASK_GREEN|MASK_BLUE)) == 0;
+
+ boolean hasDepth = (missingInfo & MASK_DEPTH) == 0;
+
+ return getClass().getName() + "[" +
+ (hasDepth ? "depth=" + getDepth() : "") +
+ (hasRGBSubfields() ?
+ (", redMask=" + Integer.toHexString(getRedMask()) +
+ ", greenMask=" + Integer.toHexString(getGreenMask()) +
+ ", blueMask=" + Integer.toHexString(getBlueMask())) :
+ ", no-subfields") + ", class=" + getVisualClass() +
+ "]";
+ }
+}
diff --git a/libjava/gnu/gcj/xlib/WMSizeHints.java b/libjava/gnu/gcj/xlib/WMSizeHints.java
new file mode 100644
index 00000000000..29344eee1eb
--- /dev/null
+++ b/libjava/gnu/gcj/xlib/WMSizeHints.java
@@ -0,0 +1,44 @@
+/* Copyright (C) 2000 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.gcj.xlib;
+
+import gnu.gcj.RawData;
+
+/**
+ * Size hints for an X11 window in its normal state. This class wraps
+ * the Xlib XSizeHints stucture.
+ *
+ * @author Rolf W. Rasmussen <rolfwr@ii.uib.no>
+ */
+public class WMSizeHints implements Cloneable
+{
+ public WMSizeHints()
+ {
+ init(null);
+ }
+
+ private native void init(WMSizeHints copyFrom);
+ protected native void finalize();
+
+ public Object clone() {
+ WMSizeHints hints = (WMSizeHints) super.clone();
+ // In case of an exception before the stucture is copied.
+ hints.structure = null;
+
+ hints.init(this);
+ return hints;
+ }
+
+ public native void applyNormalHints(Window window);
+
+ public native void setMinSize(int width, int height);
+ public native void setMaxSize(int width, int height);
+
+ RawData structure;
+}
diff --git a/libjava/gnu/gcj/xlib/Window.java b/libjava/gnu/gcj/xlib/Window.java
new file mode 100644
index 00000000000..ae3dbfd688b
--- /dev/null
+++ b/libjava/gnu/gcj/xlib/Window.java
@@ -0,0 +1,104 @@
+/* Copyright (C) 2000 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.gcj.xlib;
+
+import gnu.gcj.RawData;
+import java.awt.Rectangle;
+
+/**
+ * An X11 window.
+ *
+ * @author Rolf W. Rasmussen <rolfwr@ii.uib.no>
+ */
+public class Window extends Drawable
+{
+ // Must correspond with X.h definitions:
+ public static final int COPY_FROM_PARENT = 0;
+ public static final int INPUT_OUTPUT = 1;
+ public static final int INPUT_ONLY = 2;
+
+ public Window(Window parent, Rectangle bounds,
+ WindowAttributes attributes)
+ {
+ this(parent, bounds, attributes, null);
+ }
+
+ public Window(Window parent, Rectangle bounds,
+ WindowAttributes attributes, Visual visual)
+ {
+ this(parent, bounds, 0, attributes, COPY_FROM_PARENT, visual);
+ }
+
+ public Window(Window parent, Rectangle bounds, int borderWidth,
+ WindowAttributes attributes, int windowIOClass,
+ Visual visual)
+ {
+ this(parent.display,
+ parent.createChildXID(bounds, borderWidth, attributes,
+ windowIOClass, visual));
+ this.owned = true;
+ }
+
+ protected Window(Display display, int xid)
+ {
+ super(display, xid);
+ display.addXID(xid, this);
+ }
+
+ protected void finalize()
+ {
+ display.removeXID(xid);
+ if (owned)
+ {
+ destroy();
+ owned = false;
+ }
+ }
+
+ protected native void destroy();
+
+ protected native int createChildXID(Rectangle bounds,
+ int borderWidth,
+ WindowAttributes attributes,
+ int windowIOClass,
+ Visual visual);
+
+ public native void setAttributes(WindowAttributes attributes);
+
+ public native void map();
+ public native void unmap();
+
+ protected boolean owned = false;
+
+ public native void setProperty(int nameAtom, int typeAtom, byte[] data);
+
+ public void setProperty(int nameAtom, int typeAtom, String data)
+ {
+ int length = data.length();
+ byte[] byteData = new byte[length];
+
+ for (int i=0; i<length; i++)
+ byteData[i] = (byte) data.charAt(i);
+
+ setProperty(nameAtom, typeAtom, byteData);
+ }
+
+ public native void setWMProtocols(int[] atoms);
+ public native int[] getWMProtocols();
+
+ public void setProperty(String nameAtom, String typeAtom, String data)
+ {
+ int xaName = display.getAtom(nameAtom);
+ int xaType = display.getAtom(typeAtom);
+
+ setProperty(xaName, xaType, data);
+ }
+
+ public native void setBounds(int x, int y, int width, int height);
+}
diff --git a/libjava/gnu/gcj/xlib/WindowAttributes.java b/libjava/gnu/gcj/xlib/WindowAttributes.java
new file mode 100644
index 00000000000..72a3bb87de8
--- /dev/null
+++ b/libjava/gnu/gcj/xlib/WindowAttributes.java
@@ -0,0 +1,106 @@
+/* Copyright (C) 2000 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.gcj.xlib;
+import gnu.gcj.RawData;
+
+/**
+ *
+ * Collection of attributes that can be applied to or read from an
+ * X11 window.
+ *
+ * <p>TODO: Split this class into two classes. One for the structure
+ * XSetWindowAttributes and one for the XWindowAttributes. However
+ * they should still share this common base class.
+ *
+ * @author Rolf W. Rasmussen <rolfwr@ii.uib.no> */
+public class WindowAttributes
+{
+ // Must match definitions in X.h:
+ public final static long MASK_BUTTON_PRESS = 1L<< 2,
+ MASK_BUTTON_RELEASE = 1L<< 3,
+ MASK_EXPOSURE = 1L<<15,
+ MASK_STRUCTURE_NOTIFY = 1L<<17;
+
+ public WindowAttributes()
+ {
+ init(null);
+ }
+
+ public WindowAttributes(Window from)
+ {
+ initFromWindow(from);
+ }
+
+ private native void initFromWindow(Window from);
+ private native void init(WindowAttributes copyFrom);
+ protected native void finalize();
+
+ public Object clone()
+ {
+ WindowAttributes attributes = (WindowAttributes) super.clone();
+ // In case of an exception before the stucture is copied.
+ attributes.in = 0;
+ attributes.out = 0;
+
+ // FIXME: do anything else?
+
+ attributes.init(this);
+ return attributes;
+ }
+
+ public native void setBackground(long pixel);
+ public native void setBackground(Pixmap pixmap);
+ public native void setEventMask(long eventMask);
+
+ public void setVisual(Visual visual)
+ {
+ this.visual = visual;
+ }
+
+ /**
+ * Retrieve the visual.
+ *
+ * @return the visual that is or should be used by a window. null
+ * means CopyFormParent.
+ */
+ public native Visual getVisual();
+
+ Display display;
+
+ /**
+ * Reference to XWindowAttribute structure containing attributes
+ * read from a window.
+ */
+ RawData in = 0;
+
+ /**
+ * Reference to XSetWindowAttribute structure containing attributes
+ * to be applied to a window.
+ */
+ RawData out = 0;
+
+ long mask;
+
+ /** null means CopyFromParent during window creation. */
+ Visual visual = null;
+
+ public native void apply(Window window);
+
+ final RawData getXSetWindowAttributesStructure()
+ {
+ if (out == null)
+ initOut();
+ return out;
+ }
+
+ void initOut()
+ {
+ throw new UnsupportedOperationException("not implemented yet");
+ }
+}
diff --git a/libjava/gnu/gcj/xlib/XAnyEvent.java b/libjava/gnu/gcj/xlib/XAnyEvent.java
new file mode 100644
index 00000000000..e7a4a02b987
--- /dev/null
+++ b/libjava/gnu/gcj/xlib/XAnyEvent.java
@@ -0,0 +1,75 @@
+/* Copyright (C) 2000 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.gcj.xlib;
+
+import gnu.gcj.RawData;
+
+/**
+ * Mutable event structure that can contain any data from any event
+ * type. Events can be constructed or loaded from the event queue.
+ *
+ * @author Rolf W. Rasmussen <rolfwr@ii.uib.no>
+ */
+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;
+
+ // Must match the definitions in X.h:
+ public final static long MASK_SUBSTRUCTURE_NOTIFY = 1L<<19,
+ MASK_SUBSTRUCTURE_REDIRECT = 1L<<20;
+
+ XAnyEvent(Display display)
+ {
+ this.display = display;
+ init();
+ }
+
+ private native void init();
+ protected native void finalize();
+
+ /**
+ * Load next event into the event structure.
+ */
+ public native void loadNext();
+
+ public native int getType();
+ public native void setType(int type);
+
+ public native Window getWindow();
+ public native void setWindow(Window window);
+
+ /**
+ * @returns the number of the last request processed by the server.
+ */
+ public native long getSerial();
+
+ public native void send(Window destination, boolean propagate,
+ long mask);
+
+ RawData structure;
+ Display display;
+
+ public String toString()
+ {
+ if (structure == null)
+ return getClass().getName() + "[no-structure]";
+
+ return getClass().getName() +
+ "[type=" + getType() +
+ ",window=" + getWindow() + "]";
+ }
+}
diff --git a/libjava/gnu/gcj/xlib/XButtonEvent.java b/libjava/gnu/gcj/xlib/XButtonEvent.java
new file mode 100644
index 00000000000..032830b2c59
--- /dev/null
+++ b/libjava/gnu/gcj/xlib/XButtonEvent.java
@@ -0,0 +1,53 @@
+/* Copyright (C) 2000 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.gcj.xlib;
+
+/**
+ * Interprets data from an Xlib XButtonEvent into members of java
+ * primitive types.
+ *
+ * @author Rolf W. Rasmussen <rolfwr@ii.uib.no>
+ */
+public class XButtonEvent extends XEvent
+{
+
+ // Must match the definition in X.h:
+ public static final int MASK_SHIFT = 1<<0,
+ MASK_LOCK = 1<<1,
+ MASK_CONTROL = 1<<2,
+ MASK_MOD1 = 1<<3,
+ MASK_MOD2 = 1<<4,
+ MASK_MOD3 = 1<<5,
+ MASK_MOD4 = 1<<6,
+ MASK_MOD5 = 1<<7;
+
+ public XButtonEvent(XAnyEvent event)
+ {
+ super(event);
+
+ // FIXME: Avoid double checking?
+ if ((event.getType() != XAnyEvent.TYPE_BUTTON_PRESS) &&
+ (event.getType() != XAnyEvent.TYPE_BUTTON_RELEASE))
+ {
+ throw new IllegalArgumentException("Wrong event type");
+ }
+ init();
+ }
+
+ native void init();
+
+ public long time;
+ public int x;
+ public int y;
+ public int state;
+ public int button;
+}
+
+
+
diff --git a/libjava/gnu/gcj/xlib/XColor.java b/libjava/gnu/gcj/xlib/XColor.java
new file mode 100644
index 00000000000..7abcc1713f1
--- /dev/null
+++ b/libjava/gnu/gcj/xlib/XColor.java
@@ -0,0 +1,42 @@
+/* Copyright (C) 2000 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.gcj.xlib;
+
+import gnu.gcj.RawData;
+
+/**
+ * A color or color-cell on the X server.
+ *
+ * @author Rolf W. Rasmussen <rolfwr@ii.uib.no>
+ */
+public final class XColor
+{
+ public XColor(int r, int g, int b)
+ {
+ this();
+ setRGB(r, g, b);
+ }
+
+ public XColor()
+ {
+ init();
+ }
+
+ private native void init();
+ protected native void finalize();
+
+ public final native void setRGB(int r, int g, int b);
+ public final native int getRed();
+ public final native int getGreen();
+ public final native int getBlue();
+ public final native byte getFlags();
+ public final native long getPixelValue();
+
+ RawData structure = 0;
+}
diff --git a/libjava/gnu/gcj/xlib/XConfigureEvent.java b/libjava/gnu/gcj/xlib/XConfigureEvent.java
new file mode 100644
index 00000000000..0d069ea03db
--- /dev/null
+++ b/libjava/gnu/gcj/xlib/XConfigureEvent.java
@@ -0,0 +1,32 @@
+/* Copyright (C) 2000 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.gcj.xlib;
+
+import java.awt.Rectangle;
+
+/**
+ * Interprets and retrieves data from an Xlib XConfigureEvent.
+ *
+ * @author Rolf W. Rasmussen <rolfwr@ii.uib.no>
+ */
+public class XConfigureEvent extends XEvent
+{
+ public XConfigureEvent(XAnyEvent event)
+ {
+ super(event);
+ // FIXME: Avoid double checking?
+ if (event.getType() != XAnyEvent.TYPE_CONFIGURE_NOTIFY)
+ throw new IllegalArgumentException("Wrong event type");
+ }
+
+ public native Rectangle getBounds();
+}
+
+
+
diff --git a/libjava/gnu/gcj/xlib/XConnectException.java b/libjava/gnu/gcj/xlib/XConnectException.java
new file mode 100644
index 00000000000..829da660c1d
--- /dev/null
+++ b/libjava/gnu/gcj/xlib/XConnectException.java
@@ -0,0 +1,30 @@
+/* Copyright (C) 2000 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.gcj.xlib;
+
+import java.io.IOException;
+
+/**
+ * Indicates that something went wrong with the connection to an X11
+ * display.
+ *
+ * @author Rolf W. Rasmussen <rolfwr@ii.uib.no>
+ */
+public class XConnectException extends IOException
+{
+ public XConnectException()
+ {
+ super();
+ }
+
+ public XConnectException(String message)
+ {
+ super(message);
+ }
+}
diff --git a/libjava/gnu/gcj/xlib/XEvent.java b/libjava/gnu/gcj/xlib/XEvent.java
new file mode 100644
index 00000000000..75f602a82d2
--- /dev/null
+++ b/libjava/gnu/gcj/xlib/XEvent.java
@@ -0,0 +1,45 @@
+/* Copyright (C) 2000 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.gcj.xlib;
+
+import gnu.gcj.RawData;
+
+/**
+ * Base class for interpreters of specific X event types. For methods
+ * concerning all X events, see XAnyEvent.
+ *
+ * @author Rolf W. Rasmussen <rolfwr@ii.uib.no>
+ */
+public class XEvent
+{
+ public XEvent(XAnyEvent event)
+ {
+ this.event = event;
+ }
+
+ public XEvent(int type, Display display)
+ {
+ this(new XAnyEvent(display));
+ event.setType(type);
+ }
+
+ XAnyEvent event;
+
+ public XAnyEvent getXAnyEvent()
+ {
+ return event;
+ }
+
+ public String toString()
+ {
+ if (event == null)
+ return super.toString();
+ return event.toString();
+ }
+}
diff --git a/libjava/gnu/gcj/xlib/XException.java b/libjava/gnu/gcj/xlib/XException.java
new file mode 100644
index 00000000000..73b10a1c631
--- /dev/null
+++ b/libjava/gnu/gcj/xlib/XException.java
@@ -0,0 +1,27 @@
+/* Copyright (C) 2000 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.gcj.xlib;
+
+/**
+ * Runtime exception that occured during an Xlib opertation.
+ *
+ * @author Rolf W. Rasmussen <rolfwr@ii.uib.no>
+ */
+public class XException extends RuntimeException
+{
+ public XException() {}
+ public XException(String msg) { super(msg); }
+
+ public XException(Display display, int status)
+ {
+ super(toString(display, status));
+ }
+
+ static native String toString(Display display, int status);
+}
diff --git a/libjava/gnu/gcj/xlib/XExposeEvent.java b/libjava/gnu/gcj/xlib/XExposeEvent.java
new file mode 100644
index 00000000000..2c29cf131e3
--- /dev/null
+++ b/libjava/gnu/gcj/xlib/XExposeEvent.java
@@ -0,0 +1,33 @@
+/* Copyright (C) 2000 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.gcj.xlib;
+
+import java.awt.Rectangle;
+
+/**
+ * Interprets data from an Xlib XExposeEvent.
+ *
+ * @author Rolf W. Rasmussen <rolfwr@ii.uib.no>
+ */
+public class XExposeEvent extends XEvent
+{
+ public XExposeEvent(XAnyEvent event)
+ {
+ super(event);
+
+ // FIXME: Avoid double checking?
+ if (event.getType() != XAnyEvent.TYPE_EXPOSE)
+ throw new IllegalArgumentException("Wrong event type");
+ }
+
+ public native Rectangle getBounds();
+}
+
+
+
diff --git a/libjava/gnu/gcj/xlib/XID.java b/libjava/gnu/gcj/xlib/XID.java
new file mode 100644
index 00000000000..f7bb9cfc994
--- /dev/null
+++ b/libjava/gnu/gcj/xlib/XID.java
@@ -0,0 +1,58 @@
+/* Copyright (C) 2000 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.gcj.xlib;
+
+/**
+ * Common base class for all resources that are stored on the server
+ * and refered to on the client side using XIDs.
+ *
+ * @author Rolf W. Rasmussen <rolfwr@ii.uib.no>
+ */
+public class XID
+{
+ public XID(Display display, int xid)
+ {
+ this.display = display;
+ this.xid = xid;
+ }
+
+ public final int getXID()
+ {
+ return xid;
+ }
+
+ public final Display getDisplay()
+ {
+ return display;
+ }
+
+ protected Display display;
+ protected int xid;
+
+ private Object clientData;
+ public final Object getClientData()
+ {
+ return clientData;
+ }
+ public final void setClientData(Object clientData)
+ {
+ this.clientData = clientData;
+ }
+
+ protected String params()
+ {
+ return "display=" + display + ",xid=" + Integer.toHexString(xid);
+ }
+
+ public String toString()
+ {
+ return getClass().getName() +
+ "[" + params() + "]";
+ }
+}
diff --git a/libjava/gnu/gcj/xlib/XImage.java b/libjava/gnu/gcj/xlib/XImage.java
new file mode 100644
index 00000000000..25a80059a09
--- /dev/null
+++ b/libjava/gnu/gcj/xlib/XImage.java
@@ -0,0 +1,226 @@
+/* Copyright (C) 2000 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.gcj.xlib;
+
+import gnu.gcj.RawData;
+
+/**
+ * Structure containing image data that resides on the client side.
+ * The format, depth and offset attributes of an XImage determines how
+ * bitfields are encoded in a raster image. However, it does not
+ * determine how a color is encoded into a bitfield. I.e. the XImage
+ * pixel values in a specific structure, but does not determine what
+ * colors that will be used to represent these pixel values on the
+ * screen.
+ *
+ * @author Rolf W. Rasmussen <rolfwr@ii.uib.no>
+ */
+public class XImage
+{
+ /** This object reference points to the data, hindering garbage
+ collection of the data. */
+ Object dataRef;
+
+ // Must match definitions in X.h:
+ public static final int XYBITMAP_FORMAT = 0,
+ XYPIXMAP_FORMAT = 1,
+ ZPIXMAP_FORMAT = 2;
+
+ // Must match definitions in X.h:
+ public static final int LEAST_SIGNIFICANT_B_FIRST_ORDER = 0,
+ MOST_SIGNIFICANT_B_FIRST_ORDER = 1;
+
+ public XImage(Visual visual, int depth, int format, int xoffset,
+ int width, int height, int bitmapPad,
+ int bytesPerLine)
+ {
+ this(visual, depth, format, xoffset, width, height, bitmapPad,
+ bytesPerLine,
+ 0 // bitsPerPixel
+ );
+ }
+
+ public XImage(Visual visual, int depth, int format, int xoffset,
+ int width, int height, int bitmapPad,
+ int bytesPerLine, int bitsPerPixel)
+ {
+ if (visual == null) throw new
+ NullPointerException("a visual must be specified");
+
+ init(visual, depth, format, xoffset, width, height,
+ bitmapPad, bytesPerLine, bitsPerPixel);
+ }
+
+ public native void init(Visual visual, int depth, int format, int xoffset,
+ int width, int height, int bitmapPad,
+ int bytesPerLine, int bitsPerPixel);
+
+ private native void init(Visual visual, int width, int height);
+
+
+ public XImage(Visual visual, int width, int height)
+ {
+ this(visual, width, height,
+ true // Automatically allocate memory
+ );
+ }
+
+ /**
+ * Create a new XImage.
+ *
+ * @param allocate specifies whether to automatically allocate
+ * memory for the image. It is possible to create the data array
+ * elsewhere, so that we can for instance use a DataBufferUShort as
+ * data. Ie. not limit ourself to byte arrays. This is done by
+ * passing false and calling a setData() method manually after
+ * creation.
+ */
+ public XImage(Visual visual, int width, int height, boolean allocate)
+ {
+ if (visual == null)
+ throw new NullPointerException("a visual must be specified");
+
+ init(visual, width, height);
+
+ if (allocate)
+ {
+ /* Now that Xlib has figured out the appropriate bytes per
+ line, we can allocate memory for the image. */
+ // FIXME: What about formats with several layers/bands?
+ byte[] data = new byte[getBytesPerLine()*height];
+
+ setData(data, 0);
+ }
+ }
+
+ /**
+ * Attach image data to this XImage.
+ *
+ * @param offset the index of the first actual data element in the array.
+ */
+ public void setData(byte[] data, int offset)
+ {
+ dataRef = data;
+ internalSetData(data, offset);
+ }
+
+ /**
+ * Attach image data to this XImage.
+ *
+ * @param offset the index of the first actual data element in the
+ * array. Note: this is short offset, not a byte offset.
+ */
+ public void setData(short[] data, int offset)
+ {
+ dataRef = data;
+ internalSetData(data, offset);
+ }
+
+ /**
+ * Attach image data to this XImage
+ *
+ * @param offset the index of the first actual data element in the array.
+ * Note: this is not a byte offset.
+ */
+ public void setData(int[] data, int offset)
+ {
+ dataRef = data;
+ internalSetData(data, offset);
+ }
+
+ private native void internalSetData(byte[] data, int offset);
+ private native void internalSetData(short[] data, int offset);
+ private native void internalSetData(int[] data, int offset);
+
+ protected native void finalize();
+
+ boolean ownsData = false;
+ RawData structure = 0;
+
+ public final native int getWidth();
+ public final native int getHeight();
+ public final native int getDepth();
+ public final native int getFormat();
+
+ public final boolean isZPixmapFormat()
+ {
+ return getFormat() == ZPIXMAP_FORMAT;
+ }
+
+
+ /**
+ * Get the xoffset. The xoffset avoids the need of shifting the
+ * scanlines into place.
+ */
+ public final native int getXOffset();
+
+ public native final int getBytesPerLine();
+ public native final int getBitsPerPixel();
+
+ public native final int getImageByteOrder();
+ public native final int getBitmapBitOrder();
+ public native final int getBitmapUnit();
+ public native final int getBitmapPad();
+
+
+ // True/Direct Color specific:
+ public native int getRedMask();
+ public native int getGreenMask();
+ public native int getBlueMask();
+
+
+ /**
+ * Set a pixel value at a given position in the image. This method
+ * is slow. Don't use it, except as a fall-back.
+ */
+ public native final void setPixel(int x, int y, int pixel);
+
+ public String toString()
+ {
+ String format;
+ switch(getFormat())
+ {
+ case ZPIXMAP_FORMAT:
+ format = "ZPixmapFormat";
+ }
+
+ String imageByteOrder;
+ switch(getImageByteOrder())
+ {
+ case LEAST_SIGNIFICANT_B_FIRST_ORDER:
+ imageByteOrder = "leastSignificantByteFirst";
+ break;
+ case MOST_SIGNIFICANT_B_FIRST_ORDER:
+ imageByteOrder = "mostSignificantByteFirst";
+ }
+
+ String bitmapBitOrder;
+ switch(getBitmapBitOrder())
+ {
+ case LEAST_SIGNIFICANT_B_FIRST_ORDER:
+ bitmapBitOrder = "leastSignificantBitFirst";
+ break;
+ case MOST_SIGNIFICANT_B_FIRST_ORDER:
+ bitmapBitOrder = "mostSignificantBitFirst";
+ }
+
+ return getClass().getName() + "[" + format +
+ ", width=" + getWidth() +
+ ", height=" + getHeight() +
+ ", bytesPerLine=" + getBytesPerLine() +
+ ", xoffset=" + getXOffset() +
+ ", depth=" + getDepth() +
+ ", bitsPerPixel=" + getBitsPerPixel() +
+ ", bitmapUnit=" + getBitmapUnit() +
+ ", bitmapPad=" + getBitmapPad() +
+ ", byteOrder=" + imageByteOrder +
+ ", bitOrder=" + bitmapBitOrder +
+ "]";
+ }
+}
diff --git a/libjava/gnu/gcj/xlib/XUnmapEvent.java b/libjava/gnu/gcj/xlib/XUnmapEvent.java
new file mode 100644
index 00000000000..803bdba775a
--- /dev/null
+++ b/libjava/gnu/gcj/xlib/XUnmapEvent.java
@@ -0,0 +1,33 @@
+/* Copyright (C) 2000 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.gcj.xlib;
+
+/**
+ * Interprets data from an Xlib XUnmapEvent.
+ *
+ * @author Rolf W. Rasmussen <rolfwr@ii.uib.no>
+ */
+public class XUnmapEvent extends XEvent
+{
+ public XUnmapEvent(Display display, Window eventWindow,
+ Window unmappedWindow,
+ boolean fromConfigure)
+ {
+ super(XAnyEvent.TYPE_UNMAP_NOTIFY, display);
+ getXAnyEvent().setWindow(eventWindow);
+ setUnmappedWindow(unmappedWindow);
+ setFromConfigure(fromConfigure);
+ }
+
+ public native void setUnmappedWindow(Window unmappedWindow);
+ public native void setFromConfigure(boolean fromConfigure);
+}
+
+
+
diff --git a/libjava/gnu/gcj/xlib/natClip.cc b/libjava/gnu/gcj/xlib/natClip.cc
new file mode 100644
index 00000000000..51426c83297
--- /dev/null
+++ b/libjava/gnu/gcj/xlib/natClip.cc
@@ -0,0 +1,52 @@
+/* Copyright (C) 2000 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. */
+
+// Needed to avoid linking in libstdc++
+#ifndef __STL_USE_EXCEPTIONS
+# include <java/lang/OutOfMemoryError.h>
+# define __THROW_BAD_ALLOC throw new java::lang::OutOfMemoryError()
+#endif
+
+#include <vector>
+
+#include <X11/Xlib.h>
+#include <gcj/cni.h>
+#include <gnu/gcj/RawData.h>
+#include <java/awt/Rectangle.h>
+
+#include "gnu/gcj/xlib/Clip.h"
+
+typedef java::awt::Rectangle AWTRect;
+typedef JArray<AWTRect*> AWTRectArray;
+typedef std::vector<XRectangle> XRectVector;
+
+void gnu::gcj::xlib::Clip::init(AWTRectArray* rectangles)
+{
+ // Prepare rectangles:
+
+ int numRect = JvGetArrayLength(rectangles);
+ XRectVector* xrectvector = new XRectVector(numRect);
+
+ for (int i=0; i<numRect; i++)
+ {
+ AWTRect* awtrect = elements(rectangles)[i];
+ XRectangle& xrect = (*xrectvector)[i];
+
+ xrect.x = awtrect->x;
+ xrect.y = awtrect->y;
+ xrect.width = awtrect->width;
+ xrect.height = awtrect->height;
+ }
+
+ xrects = reinterpret_cast<gnu::gcj::RawData*>(xrectvector);
+}
+
+void gnu::gcj::xlib::Clip::finalize()
+{
+ delete xrects; xrects = 0;
+}
diff --git a/libjava/gnu/gcj/xlib/natColormap.cc b/libjava/gnu/gcj/xlib/natColormap.cc
new file mode 100644
index 00000000000..83c897e8a17
--- /dev/null
+++ b/libjava/gnu/gcj/xlib/natColormap.cc
@@ -0,0 +1,147 @@
+/* Copyright (C) 2000 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. */
+
+// Needed to avoid linking in libstdc++
+#ifndef __STL_USE_EXCEPTIONS
+# include <java/lang/OutOfMemoryError.h>
+# define __THROW_BAD_ALLOC throw new java::lang::OutOfMemoryError()
+#endif
+
+#include <vector>
+
+#include <X11/Xlib.h>
+
+#include <gcj/cni.h>
+#include <java/lang/RuntimeException.h>
+#include <gnu/gcj/xlib/Display.h>
+#include <gnu/gcj/xlib/Screen.h>
+#include <gnu/gcj/xlib/Colormap.h>
+#include <gnu/gcj/xlib/XColor.h>
+#include <gnu/gcj/RawData.h>
+
+jlong gnu::gcj::xlib::Colormap::allocateColorPixel(XColor* color)
+{
+ ::Display* dpy = (::Display*) (screen->getDisplay()->display);
+ ::XColor* col = (::XColor*) (color->structure);
+ Status result = XAllocColor(dpy, xid, col);
+ if (result == 0)
+ throw new java::lang::RuntimeException(
+ JvNewStringLatin1("Unable to allocate color pixel."));
+
+ return col->pixel;
+}
+
+typedef JArray<gnu::gcj::xlib::XColor*>* xcolorarray;
+
+xcolorarray gnu::gcj::xlib::Colormap::getSharedColors()
+{
+ ::Display* dpy = (::Display*) (screen->getDisplay()->display);
+ unsigned int nCells = CellsOfScreen(ScreenOfDisplay(dpy, screen->screenNumber));
+
+ typedef ::XColor xcolor;
+ std::vector<xcolor> colors(nCells);
+ for (unsigned int i=0; i<nCells; i++)
+ colors[i].pixel = i;
+ ::XColor* cols = colors.get_allocator().address(colors.front());
+ XQueryColors(dpy, xid, cols,
+ nCells);
+
+ int nShared = 0;
+ for (unsigned int i=0; i<nCells; i++)
+ {
+ ::XColor color = colors[i];
+
+ if (!XAllocColor(dpy, xid, &color))
+ continue;
+
+ /* FIXME: In some cases this algorithm may identify a free
+ color cell as a shared one. */
+ if (color.pixel != i)
+ {
+ // Oops, the color wasn't shared. Free it.
+ XFreeColors(dpy, xid, &(color.pixel), 1, 0);
+ colors[i].flags = FLAG_NOT_SHARED;
+ continue;
+ }
+
+ // FIXME: Shared or free?
+
+ nShared++;
+ colors[i].flags = FLAG_SHARED;
+ }
+
+ JArray<XColor*>* shared = newXColorArray(nShared);
+ int si=0;
+ for (unsigned int i=0; i<nCells; i++)
+ {
+ if (colors[i].flags != FLAG_SHARED)
+ continue;
+
+ XColor* col = elements(shared)[si++];
+ gnu::gcj::RawData* colorData = col->structure;
+ ::XColor* colStruct = reinterpret_cast<xcolor*>(colorData);
+ *colStruct = colors[i];
+ }
+
+ return shared;
+}
+
+xcolorarray gnu::gcj::xlib::Colormap::getXColors()
+{
+ ::Display* dpy = (::Display*) (screen->getDisplay()->display);
+ unsigned int nCells =
+ CellsOfScreen(ScreenOfDisplay(dpy, screen->screenNumber));
+
+ typedef ::XColor xcolor;
+ std::vector<xcolor> colors(nCells);
+
+ JArray<XColor*>* colArray = newXColorArray(nCells);
+
+ for (unsigned int i=0; i<nCells; i++)
+ colors[i].pixel = i;
+
+ XQueryColors(dpy, xid, &(colors.front()), nCells);
+
+ /* TODO: The current problem with this code is that it relies on
+ (color.pixel == i) as an indicator that the color is
+ shared. However, (color.pixel == i), may also occur simply
+ because color cell i simply was the next free in the list of
+ unallocated color cells. IDEA: run through the list both
+ backwards and forwards, and only pick out the colorcells that
+ have been identified as shared during both passes. Reversing the
+ traversal direction might prevent i from corresponding to the
+ next free colorcell, atleast in one of the passes. */
+ for (unsigned int i=0; i<nCells; i++)
+ {
+ ::XColor color = colors[i];
+
+ char flag = FLAG_NOT_SHARED;
+ if (XAllocColor(dpy, xid, &color))
+ {
+ if (color.pixel == i)
+ {
+ flag = FLAG_SHARED;
+ }
+ else
+ {
+ // Oops, the color wasn't shared. Free it.
+ XFreeColors(dpy, xid, &(color.pixel), 1, 0);
+ }
+ }
+
+ // Copy color data into object in array
+ XColor* col = elements(colArray)[i];
+ gnu::gcj::RawData* colorData = col->structure;
+ ::XColor* colStruct = reinterpret_cast<xcolor*>(colorData);
+ *colStruct = colors[i];
+ colStruct->flags = flag;
+ }
+
+ return colArray;
+}
+
diff --git a/libjava/gnu/gcj/xlib/natDisplay.cc b/libjava/gnu/gcj/xlib/natDisplay.cc
new file mode 100644
index 00000000000..fadf4fb2696
--- /dev/null
+++ b/libjava/gnu/gcj/xlib/natDisplay.cc
@@ -0,0 +1,132 @@
+/* Copyright (C) 1999, 2000 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. */
+
+#include <X11/Xproto.h>
+#include <X11/Xlib.h>
+#include <stdio.h>
+
+#include <java/lang/System.h>
+#include <java/lang/RuntimeException.h>
+#include <java/io/PrintStream.h>
+#include <gcj/cni.h>
+
+#include <gnu/gcj/xlib/Display.h>
+#include <gnu/gcj/xlib/XConnectException.h>
+#include <gnu/gcj/xlib/XException.h>
+
+void gnu::gcj::xlib::Display::init()
+{
+ ::Display* openedDisplay = XOpenDisplay(0); // default display
+
+ if (openedDisplay == 0) {
+ jstring msg = JvNewStringLatin1("Unable to open display");
+ throw new gnu::gcj::xlib::XConnectException(msg);
+ }
+
+ display = reinterpret_cast<gnu::gcj::RawData*>(openedDisplay);
+}
+
+void gnu::gcj::xlib::Display::finalize()
+{
+ if (display == 0) return;
+ ::Display* dpy = (::Display*) display;
+ XCloseDisplay(dpy);
+}
+
+jint gnu::gcj::xlib::Display::getDefaultScreenNumber()
+{
+ ::Display* dpy = (::Display*) display;
+ return DefaultScreen(dpy);
+}
+
+jint gnu::gcj::xlib::Display::getDefaultRootWindowXID()
+{
+ ::Display* dpy = (::Display*) display;
+ return DefaultRootWindow(dpy);
+}
+
+jint gnu::gcj::xlib::Display::internAtom(jstring name)
+{
+ ::Display* dpy = (::Display*) display;
+ int len = JvGetStringUTFLength(name);
+ char cName[len+1];
+ JvGetStringUTFRegion(name, 0, name->length(), cName);
+ cName[len] = '\0';
+ bool onlyIfExists = false;
+ return XInternAtom(dpy, cName, onlyIfExists);
+}
+
+jstring gnu::gcj::xlib::Display::getAtomName(jint atom)
+{
+ ::Display* dpy = (::Display*) display;
+ char* cName = XGetAtomName(dpy, atom);
+ jstring name = JvNewStringLatin1(cName);
+ XFree(cName);
+ return name;
+}
+
+static int handleXError(Display* dpy, XErrorEvent* xee)
+{
+ const int ERROR_TEXT_LENGTH = 256;
+ char errorText[ERROR_TEXT_LENGTH];
+ XGetErrorText(dpy, xee->error_code, errorText, ERROR_TEXT_LENGTH);
+ int requestCode = xee->request_code;
+
+ if (requestCode == X_GetImage)
+ {
+ /* The current implementation of Drawable.copyIntoXImage()
+ will generate harmless X_GetImage errors if the initially
+ requested area is not completly within the drawable. Until
+ we find a better solution, simply ignore these errors. */
+ return 0;
+ }
+
+ java::lang::System::err->print(JvNewStringLatin1("X error: "));
+ java::lang::System::err->print(JvNewStringLatin1(errorText));
+ java::lang::System::err->print(JvNewStringLatin1(", serial="));
+ java::lang::System::err->print((jlong) xee->serial);
+ java::lang::System::err->print(JvNewStringLatin1(", requestCode="));
+ java::lang::System::err->print((jint) requestCode);
+
+ if (requestCode < 128)
+ {
+ char number[8];
+ snprintf(number, 8, "%d", requestCode);
+ number[7] = '\0';
+
+ XGetErrorDatabaseText(dpy, "XRequest", number,
+ "", errorText, ERROR_TEXT_LENGTH);
+ java::lang::System::err->print(JvNewStringLatin1(" ("));
+ java::lang::System::err->print(JvNewStringLatin1(errorText));
+ java::lang::System::err->print(JvNewStringLatin1(")"));
+ }
+
+ java::lang::System::err->print(JvNewStringLatin1(", minorCode="));
+ java::lang::System::err->print((jint) xee->minor_code);
+ java::lang::System::err->print(JvNewStringLatin1(", XID="));
+ java::lang::System::err->println((jlong) xee->resourceid);
+
+ return 0;
+}
+
+void gnu::gcj::xlib::Display::staticInit()
+{
+ if (XInitThreads() == 0)
+ {
+ char msg[] = "threads is not supported on this platform";
+ throw new java::lang::RuntimeException(JvNewStringLatin1(msg));
+ }
+
+ XSetErrorHandler(&handleXError);
+}
+
+void gnu::gcj::xlib::Display::flush()
+{
+ ::Display* dpy = (::Display*) display;
+ XFlush(dpy);
+}
diff --git a/libjava/gnu/gcj/xlib/natDrawable.cc b/libjava/gnu/gcj/xlib/natDrawable.cc
new file mode 100644
index 00000000000..c6e253a549b
--- /dev/null
+++ b/libjava/gnu/gcj/xlib/natDrawable.cc
@@ -0,0 +1,79 @@
+/* Copyright (C) 2000 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. */
+
+#include <X11/Xlib.h>
+
+#include <gcj/cni.h>
+#include <gnu/gcj/RawData.h>
+
+#include <gnu/gcj/xlib/XException.h>
+#include <gnu/gcj/xlib/Display.h>
+#include <gnu/gcj/xlib/Drawable.h>
+#include <gnu/gcj/xlib/XImage.h>
+
+#include <java/awt/Rectangle.h>
+
+jboolean gnu::gcj::xlib::Drawable::copyIntoXImageImpl(XImage* image,
+ jint x, jint y,
+ jint width, jint height,
+ jint destX, jint destY)
+{
+ ::Display* dpy = (::Display*) (getDisplay()->display);
+ ::XImage* ximage = (::XImage*) image->structure;
+ int format = image->getFormat();
+ int xid = getXID();
+
+ ::XImage* result = XGetSubImage(dpy, xid,
+ x, y, width, height,
+ ~0, // plane mask
+ format,
+ ximage,
+ destX, destY);
+ if (result == 0)
+ return false;
+
+ if (result != ximage)
+ throw new XException(MSG_XGETSUBIMAGE_FAILED);
+
+ return true;
+}
+
+java::awt::Rectangle*
+gnu::gcj::xlib::Drawable::getBounds(java::awt::Rectangle* rv)
+{
+ ::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:
+ JvThrow(new XException(display, status));
+ default:
+ ; // All OK, NOP.
+ }
+
+ if (rv == 0)
+ {
+ rv = new java::awt::Rectangle(x, y, w, h);
+ }
+ else
+ {
+ rv->x = x;
+ rv->y = y;
+ rv->width = w;
+ rv->height = h;
+ }
+ return rv;
+}
diff --git a/libjava/gnu/gcj/xlib/natFont.cc b/libjava/gnu/gcj/xlib/natFont.cc
new file mode 100644
index 00000000000..7e6b3f709c3
--- /dev/null
+++ b/libjava/gnu/gcj/xlib/natFont.cc
@@ -0,0 +1,95 @@
+/* Copyright (C) 2000 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. */
+
+#include <X11/Xlib.h>
+
+#include <gcj/cni.h>
+#include <gnu/gcj/RawData.h>
+#include <java/lang/String.h>
+
+#include <gnu/gcj/xlib/Display.h>
+#include <gnu/gcj/xlib/Font.h>
+#include <gnu/gcj/xlib/XException.h>
+
+gnu::gcj::RawData* gnu::gcj::xlib::Font::loadFont(Display* display,
+ jstring lfdNamePattern)
+{
+ ::Display* dpy = (::Display*) display->display;
+ int len = JvGetStringUTFLength(lfdNamePattern);
+ char cName[len+1];
+ JvGetStringUTFRegion(lfdNamePattern, 0, lfdNamePattern->length(),
+ cName);
+ cName[len] = '\0';
+
+ XFontStruct* fontStruct = XLoadQueryFont(dpy, cName);
+ if (fontStruct == 0)
+ {
+ JvThrow(new XException(JvNewStringLatin1("font not found")));
+ }
+
+ return reinterpret_cast<gnu::gcj::RawData*>(fontStruct);
+}
+
+jint gnu::gcj::xlib::Font::getXIDFromStruct(gnu::gcj::RawData* structure)
+{
+ XFontStruct* fontStruct = (XFontStruct*) structure;
+ return fontStruct->fid;
+}
+
+jint gnu::gcj::xlib::Font::getMaxAscent()
+{
+ XFontStruct* fontStruct = (XFontStruct*) structure;
+ return fontStruct->max_bounds.ascent;
+}
+
+jint gnu::gcj::xlib::Font::getMaxDescent()
+{
+ XFontStruct* fontStruct = (XFontStruct*) structure;
+ return fontStruct->max_bounds.descent;
+}
+
+jint gnu::gcj::xlib::Font::getAscent()
+{
+ XFontStruct* fontStruct = (XFontStruct*) structure;
+ return fontStruct->ascent;
+}
+
+jint gnu::gcj::xlib::Font::getDescent()
+{
+ XFontStruct* fontStruct = (XFontStruct*) structure;
+ return fontStruct->ascent;
+}
+
+jint gnu::gcj::xlib::Font::getStringWidth(java::lang::String* text)
+{
+ XFontStruct* fontStruct = (XFontStruct*) structure;
+
+ // FIXME: make proper unicode conversion
+ int len = JvGetStringUTFLength(text);
+ char ctxt[len+1];
+ JvGetStringUTFRegion(text, 0, text->length(), ctxt);
+ ctxt[len] = '\0';
+ int width = XTextWidth(fontStruct, ctxt, len);
+ return width;
+}
+
+void gnu::gcj::xlib::Font::finalize()
+{
+ if (structure != 0)
+ {
+ ::Display* dpy = (::Display*) display->display;
+ XFontStruct* fontStruct = (XFontStruct*) structure;
+ int result = XFreeFont(dpy, fontStruct);
+
+ if (result == BadFont)
+ throw new XException(display, result);
+
+ structure = 0; xid = 0;
+ }
+}
+
diff --git a/libjava/gnu/gcj/xlib/natGC.cc b/libjava/gnu/gcj/xlib/natGC.cc
new file mode 100644
index 00000000000..66de35f868b
--- /dev/null
+++ b/libjava/gnu/gcj/xlib/natGC.cc
@@ -0,0 +1,207 @@
+/* Copyright (C) 2000 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. */
+
+#include <vector>
+
+#include <X11/Xlib.h>
+
+#include <gcj/cni.h>
+#include <gnu/gcj/RawData.h>
+#include <java/lang/String.h>
+#include <java/awt/Rectangle.h>
+
+#include <gnu/gcj/xlib/Display.h>
+#include <gnu/gcj/xlib/XID.h>
+#include <gnu/gcj/xlib/Drawable.h>
+#include <gnu/gcj/xlib/Font.h>
+#include <gnu/gcj/xlib/XImage.h>
+#include <gnu/gcj/xlib/XException.h>
+#include <gnu/gcj/xlib/Clip.h>
+#include <gnu/gcj/xlib/GC.h>
+#include <gnu/gcj/xlib/XException.h>
+
+typedef java::awt::Rectangle AWTRect;
+typedef JArray<AWTRect*> AWTRectArray;
+typedef std::vector<XRectangle> XRectVector;
+
+void gnu::gcj::xlib::GC::initStructure(GC* copyFrom)
+{
+ Display* display = target->getDisplay();
+ ::Display* dpy = (::Display*) (display->display);
+ ::Drawable drawableXID = target->getXID();
+
+ ::GC gc = XCreateGC(dpy, drawableXID, 0, 0);
+
+ if (gc == 0)
+ throw new XException(JvNewStringLatin1("GC creation failed"));
+
+ if (copyFrom != 0)
+ {
+ ::GC fromGC = (::GC) copyFrom->structure;
+ XCopyGC(dpy, fromGC, ~0, gc);
+ // no fast fail
+ }
+
+ structure = reinterpret_cast<gnu::gcj::RawData*>(gc);
+}
+
+void gnu::gcj::xlib::GC::disposeImpl()
+{
+ gnu::gcj::RawData* lStructure = structure;
+ Drawable* lTargetType = target;
+
+ if ((lStructure == 0) || (lTargetType == 0))
+ return;
+
+ structure = 0;
+ target = 0;
+
+ Display* display = lTargetType->getDisplay();
+ ::Display* dpy = (::Display*) (display->display);
+ ::GC gc = (::GC) lStructure;
+
+ XFreeGC(dpy, gc);
+ // no fast fail
+}
+
+void gnu::gcj::xlib::GC::setForeground(jlong pixel)
+{
+ Display* display = target->getDisplay();
+ ::Display* dpy = (::Display*) (display->display);
+ ::GC gc = (::GC) structure;
+ XSetForeground(dpy, gc, pixel);
+ // no fast fail
+}
+
+void gnu::gcj::xlib::GC::setFont(Font* font)
+{
+ Display* display = target->getDisplay();
+ ::Display* dpy = (::Display*) (display->display);
+ ::GC gc = (::GC) structure;
+ XSetFont(dpy, gc, font->getXID());
+ // no fast fail
+}
+
+void gnu::gcj::xlib::GC::drawString(jstring text, jint x, jint y)
+{
+ Display* display = target->getDisplay();
+ ::Display* dpy = (::Display*) (display->display);
+ ::Drawable drawableXID = target->getXID();
+ ::GC gc = (::GC) structure;
+
+ /*
+ FIXME: do something along the lines of the following instead:
+
+ jint length = text->length();
+ jchar* txt = JvGetStringChars(text);
+
+ XChar2b xwchars[length];
+
+ // FIXME: Add convertion and caching
+
+ for (int i=0; i<length; i++)
+ {
+ XChar2b* xc = &(xwchars[i]);
+ jchar jc = txt[i];
+ xc->byte1 = jc & 0xff;
+ xc->byte2 = jc >> 8;
+ }
+
+ XDrawString16(dpy, drawableXID, gc, x, y, xwchars, length);
+ */
+
+ // FIXME, temporary code:
+ int len = JvGetStringUTFLength(text);
+ char ctxt[len+1];
+ JvGetStringUTFRegion(text, 0, text->length(), ctxt);
+ ctxt[len] = '\0';
+ XDrawString(dpy, drawableXID, gc, x, y, ctxt, len);
+ // no fast fail
+}
+
+void gnu::gcj::xlib::GC::drawLine(jint x1, jint y1, jint x2, jint y2)
+{
+ Display* display = target->getDisplay();
+ ::Display* dpy = (::Display*) (display->display);
+ ::Drawable drawableXID = target->getXID();
+ ::GC gc = (::GC) structure;
+ XDrawLine(dpy, drawableXID, gc, x1, y1, x2, y2);
+ // no fast fail
+}
+
+void gnu::gcj::xlib::GC::drawRectangle(jint x, jint y, jint w, jint h)
+{
+ Display* display = target->getDisplay();
+ ::Display* dpy = (::Display*) (display->display);
+ ::Drawable drawableXID = target->getXID();
+ ::GC gc = (::GC) structure;
+ XDrawRectangle(dpy, drawableXID, gc, x, y, w, h);
+ // no fast fail
+}
+
+void gnu::gcj::xlib::GC::fillRectangle(jint x, jint y, jint w, jint h)
+{
+ Display* display = target->getDisplay();
+ ::Display* dpy = (::Display*) (display->display);
+ ::Drawable drawableXID = target->getXID();
+ ::GC gc = (::GC) structure;
+ XFillRectangle(dpy, drawableXID, gc, x, y, w, h);
+ // no fast fail
+}
+
+void gnu::gcj::xlib::GC::clearArea(jint x, jint y, jint w, jint h,
+ jboolean exposures)
+{
+ Display* display = target->getDisplay();
+ ::Display* dpy = (::Display*) (display->display);
+ ::Drawable drawableXID = target->getXID();
+
+ XClearArea(dpy, drawableXID, x, y, w, h,
+ exposures ? True : False);
+ // no fast fail
+}
+
+
+void gnu::gcj::xlib::GC::putImage(XImage* image,
+ 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;
+ ::XImage* ximage = (::XImage*) (image->structure);
+
+ XPutImage(dpy, drawableXID, gc, ximage,
+ srcX, srcY,
+ destX, destY,
+ width, height);
+ // no fast fail
+}
+
+void gnu::gcj::xlib::GC::updateClip()
+{
+ if (clip == 0)
+ return;
+
+ Display* display = target->getDisplay();
+ ::Display* dpy = (::Display*) (display->display);
+ ::GC gc = (::GC) structure;
+
+ XRectVector* xrectvector = (XRectVector*) (clip->xrects);
+ int numRect = xrectvector->size();
+
+ int originX = 0;
+ int originY = 0;
+ int ordering = Unsorted;
+ XSetClipRectangles(dpy, gc, originX, originY,
+ &(xrectvector->front()), numRect,
+ ordering);
+ // no fast fail
+}
diff --git a/libjava/gnu/gcj/xlib/natPixmap.cc b/libjava/gnu/gcj/xlib/natPixmap.cc
new file mode 100644
index 00000000000..459f5bf3b28
--- /dev/null
+++ b/libjava/gnu/gcj/xlib/natPixmap.cc
@@ -0,0 +1,39 @@
+/* Copyright (C) 2000 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. */
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+
+#include <gcj/cni.h>
+#include <gnu/gcj/RawData.h>
+
+#include <java/lang/OutOfMemoryError.h>
+
+#include <gnu/gcj/xlib/Display.h>
+#include <gnu/gcj/xlib/Screen.h>
+#include <gnu/gcj/xlib/Visual.h>
+#include <gnu/gcj/xlib/Drawable.h>
+#include <gnu/gcj/xlib/XImage.h>
+#include <gnu/gcj/xlib/Pixmap.h>
+
+jint gnu::gcj::xlib::Pixmap::createXID(Drawable* drawable,
+ jint width, jint height,
+ jint depth)
+{
+ Display* display = drawable->getDisplay();
+ ::Display* dpy = (::Display*) (display->display);
+ jint xid = drawable->getXID();
+
+ return XCreatePixmap(dpy, xid, width, height, depth);
+}
+
+void gnu::gcj::xlib::Pixmap::finalize()
+{
+ ::Display* dpy = (::Display*) (getDisplay()->display);
+ XFreePixmap(dpy, getXID());
+}
diff --git a/libjava/gnu/gcj/xlib/natScreen.cc b/libjava/gnu/gcj/xlib/natScreen.cc
new file mode 100644
index 00000000000..9459c1f42ec
--- /dev/null
+++ b/libjava/gnu/gcj/xlib/natScreen.cc
@@ -0,0 +1,53 @@
+/* Copyright (C) 2000 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. */
+
+#include <X11/Xlib.h>
+
+#include <gcj/cni.h>
+#include <gnu/gcj/xlib/Display.h>
+#include <gnu/gcj/xlib/Screen.h>
+
+void gnu::gcj::xlib::Screen::initStructure()
+{
+ ::Display* dpy = (::Display*) (display->display);
+ ::Screen* screen = ScreenOfDisplay(dpy, screenNumber);
+
+ structure = reinterpret_cast<gnu::gcj::RawData*>(screen);
+}
+
+
+jint gnu::gcj::xlib::Screen::getRootDepth()
+{
+ ::Screen* screen = (::Screen*) structure;
+ return screen->root_depth;
+}
+
+jint gnu::gcj::xlib::Screen::getRootWindowXID()
+{
+ ::Screen* screen = (::Screen*) structure;
+ return RootWindowOfScreen(screen);
+}
+
+jint gnu::gcj::xlib::Screen::getDefaultColormapXID()
+{
+ ::Screen* screen = (::Screen*) structure;
+ return DefaultColormapOfScreen(screen);
+}
+
+jint gnu::gcj::xlib::Screen::findScreenNumber()
+{
+ ::Screen* screen = (::Screen*) structure;
+ return XScreenNumberOfScreen(screen);
+}
+
+gnu::gcj::RawData* gnu::gcj::xlib::Screen::getRootVisualStructure()
+{
+ ::Screen* screen = (::Screen*) structure;
+ ::Visual* visual = DefaultVisualOfScreen(screen);
+ return reinterpret_cast<gnu::gcj::RawData*>(visual);
+}
diff --git a/libjava/gnu/gcj/xlib/natVisual.cc b/libjava/gnu/gcj/xlib/natVisual.cc
new file mode 100644
index 00000000000..56e03b5abc9
--- /dev/null
+++ b/libjava/gnu/gcj/xlib/natVisual.cc
@@ -0,0 +1,146 @@
+/* Copyright (C) 2000 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. */
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+
+#include <gcj/cni.h>
+#include <gnu/gcj/xlib/Visual.h>
+#include <gnu/gcj/xlib/Screen.h>
+#include <gnu/gcj/xlib/Display.h>
+#include <gnu/gcj/xlib/XException.h>
+#include <gnu/gcj/RawData.h>
+
+using namespace gnu::gcj;
+
+void gnu::gcj::xlib::Visual::init(RawData* visual, jint depth)
+{
+ XVisualInfo* info = new XVisualInfo;
+ xVisualInfo = reinterpret_cast<gnu::gcj::RawData*>(info);
+ infoMask = 0;
+
+ if (visual != 0)
+ {
+ ::Visual* visualStructure = (::Visual*) visual;
+ info->visual = visualStructure;
+ info->visualid = XVisualIDFromVisual(visualStructure);
+ infoMask |= MASK_ID | MASK_VISUAL_STRUCTURE;
+ }
+
+ if (depth != 0)
+ {
+ info->depth = depth;
+ infoMask |= MASK_DEPTH;
+ }
+}
+
+void gnu::gcj::xlib::Visual::finalize()
+{
+ if (xVisualInfo != 0)
+ {
+ delete xVisualInfo;
+ xVisualInfo = 0;
+ }
+}
+
+RawData* gnu::gcj::xlib::Visual::getVisualStructure()
+{
+ ensureXVisualInfo(MASK_ALL); // Make sure structure is set
+ XVisualInfo* info = (XVisualInfo*) xVisualInfo;
+ return reinterpret_cast<gnu::gcj::RawData*>(info->visual);
+}
+
+jint gnu::gcj::xlib::Visual::getRedMask()
+{
+ ensureXVisualInfo(MASK_RED);
+ XVisualInfo* info = (XVisualInfo*) xVisualInfo;
+ return info->red_mask;
+}
+
+jint gnu::gcj::xlib::Visual::getGreenMask()
+{
+ ensureXVisualInfo(MASK_GREEN);
+ XVisualInfo* info = (XVisualInfo*) xVisualInfo;
+ return info->green_mask;
+}
+
+jint gnu::gcj::xlib::Visual::getBlueMask()
+{
+ ensureXVisualInfo(MASK_BLUE);
+ XVisualInfo* info = (XVisualInfo*) xVisualInfo;
+ return info->blue_mask;
+}
+
+jint gnu::gcj::xlib::Visual::getScreenNumber()
+{
+ if (screen != 0)
+ return screen->getScreenNumber();
+
+ ensureXVisualInfo(MASK_SCREEN);
+ XVisualInfo* info = (XVisualInfo*) xVisualInfo;
+ return info->screen;
+}
+
+jint gnu::gcj::xlib::Visual::getDepth()
+{
+ ensureXVisualInfo(MASK_DEPTH);
+
+ XVisualInfo* info = (XVisualInfo*) xVisualInfo;
+ return info->depth;
+}
+
+jint gnu::gcj::xlib::Visual::getVisualClass()
+{
+ ensureXVisualInfo(MASK_CLASS);
+ ::XVisualInfo* info = (::XVisualInfo*) xVisualInfo;
+ return info->c_class;
+}
+
+void gnu::gcj::xlib::Visual::ensureXVisualInfo(jint requiredMask)
+{
+ int missingInformation = ~infoMask;
+ if ((missingInformation & requiredMask) == 0)
+ return;
+
+ // We need more info...
+
+ XVisualInfo* info = (XVisualInfo*) xVisualInfo;
+
+ // Store everything we know into template
+ if (screen != 0)
+ {
+ info->screen = screen->getScreenNumber();
+ infoMask |= MASK_SCREEN;
+ }
+
+ // Aquire info using the current info as template for matching
+ ::Display* dpy = (::Display*) display->display;
+ int visualInfoCount;
+
+ long mask = infoMask & MASK_ALL & (~MASK_VISUAL_STRUCTURE);
+ XVisualInfo* matches = XGetVisualInfo(dpy, mask,
+ info, &visualInfoCount);
+ if (matches != 0)
+ {
+ (*info) = matches[0];
+
+ // redundant?
+ xVisualInfo = reinterpret_cast<gnu::gcj::RawData*>(info);
+
+ infoMask = ~0; // ALL
+ XFree(matches);
+ }
+ else
+ {
+ char msg[] =
+ "XGetVisualInfo failed to find any matching visuals. The template "
+ "describes a combination of properties that does not exist on "
+ "this X server.";
+ throw new XException(JvNewStringLatin1(msg));
+ }
+}
diff --git a/libjava/gnu/gcj/xlib/natWMSizeHints.cc b/libjava/gnu/gcj/xlib/natWMSizeHints.cc
new file mode 100644
index 00000000000..f38ea387fa3
--- /dev/null
+++ b/libjava/gnu/gcj/xlib/natWMSizeHints.cc
@@ -0,0 +1,75 @@
+/* Copyright (C) 2000 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. */
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+
+#include <gcj/cni.h>
+#include <gnu/gcj/RawData.h>
+#include <java/lang/OutOfMemoryError.h>
+
+#include <gnu/gcj/xlib/Window.h>
+#include <gnu/gcj/xlib/Display.h>
+#include <gnu/gcj/xlib/WMSizeHints.h>
+
+void gnu::gcj::xlib::WMSizeHints::init(WMSizeHints* copyFrom)
+{
+ XSizeHints* hints = XAllocSizeHints();
+ if (hints == 0)
+ {
+ jstring errorMessage = JvNewStringLatin1("XAllocSizeHints failed");
+ JvThrow(new java::lang::OutOfMemoryError(errorMessage));
+ }
+
+ if (copyFrom != 0)
+ {
+ XSizeHints* from = (XSizeHints*) copyFrom->structure;
+ (*hints) = (*from);
+ }
+ else
+ {
+ // Is this necessary?
+ hints->flags = 0;
+ }
+ structure = reinterpret_cast<gnu::gcj::RawData*>(hints);
+}
+
+void gnu::gcj::xlib::WMSizeHints::finalize()
+{
+ delete structure;
+}
+
+void gnu::gcj::xlib::WMSizeHints::applyNormalHints(gnu::gcj::xlib::Window* window)
+{
+ Display* display = window->display;
+ ::Display* dpy = (::Display*) display->display;
+ ::Window win = window->getXID();
+ XSizeHints* hints = (XSizeHints*) structure;
+
+ XSetWMNormalHints(dpy, win, hints);
+ /* FIXME, alternative?
+ // X11 source reports XSetWMNormalHints() as an old routine. (?)
+ XSetWMSizeHints(dpy, win, hints, display->getAtom("WM_NORMAL_HINTS"));
+ */
+}
+
+void gnu::gcj::xlib::WMSizeHints::setMinSize(jint width, jint height)
+{
+ XSizeHints* hints = (XSizeHints*) structure;
+ hints->min_width = width;
+ hints->min_height = height;
+ hints->flags = hints->flags | PMinSize;
+}
+
+void gnu::gcj::xlib::WMSizeHints::setMaxSize(jint width, jint height)
+{
+ XSizeHints* hints = (XSizeHints*) structure;
+ hints->max_width = width;
+ hints->max_height = height;
+ hints->flags = hints->flags | PMaxSize;
+}
diff --git a/libjava/gnu/gcj/xlib/natWindow.cc b/libjava/gnu/gcj/xlib/natWindow.cc
new file mode 100644
index 00000000000..6600795574f
--- /dev/null
+++ b/libjava/gnu/gcj/xlib/natWindow.cc
@@ -0,0 +1,171 @@
+/* Copyright (C) 2000 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. */
+
+// Needed to avoid linking in libstdc++
+#ifndef __STL_USE_EXCEPTIONS
+# include <java/lang/OutOfMemoryError.h>
+# define __THROW_BAD_ALLOC throw new java::lang::OutOfMemoryError()
+#endif
+
+#include <vector>
+
+#include <X11/Xlib.h>
+#include <gcj/cni.h>
+#include <java/awt/Rectangle.h>
+#include <gnu/gcj/xlib/Display.h>
+#include <gnu/gcj/xlib/Window.h>
+#include <gnu/gcj/xlib/WindowAttributes.h>
+#include <gnu/gcj/xlib/Visual.h>
+#include <gnu/gcj/xlib/XException.h>
+
+jint gnu::gcj::xlib::Window::createChildXID(java::awt::Rectangle* bounds,
+ jint borderWidth,
+ WindowAttributes* attributes,
+ jint windowIOClass,
+ Visual* visual)
+{
+ ::Window parentXID = xid;
+
+ int x = bounds->x;
+ int y = bounds->y;
+ int width = bounds->width;
+ int height = bounds->height;
+
+ long mask = attributes->mask;
+ XSetWindowAttributes* attr = (XSetWindowAttributes*)
+ attributes->getXSetWindowAttributesStructure();
+
+ ::Visual* vis = CopyFromParent;
+ int depth = CopyFromParent;
+ if (visual != 0)
+ {
+ vis = (::Visual*) visual->getVisualStructure();
+ depth = visual->getDepth();
+ }
+
+ ::Window childXID = XCreateWindow((::Display*) (display->display),
+ parentXID,
+ x, y, width, height,
+ borderWidth, depth, windowIOClass,
+ vis,
+ mask, attr);
+ // no fast fail
+ return childXID;
+}
+
+void gnu::gcj::xlib::Window::destroy()
+{
+ ::Display* dpy = (::Display*) (display->display);
+ ::Window window = xid;
+ XDestroyWindow(dpy, window);
+ // no fast fail
+}
+
+void gnu::gcj::xlib::Window::setAttributes(WindowAttributes* attributes)
+{
+ ::Display* dpy = (::Display*) (display->display);
+ ::Window window = xid;
+ ::XSetWindowAttributes* attr = (::XSetWindowAttributes*)
+ attributes->getXSetWindowAttributesStructure();
+
+ XChangeWindowAttributes(dpy, window, attributes->mask, attr);
+ // no fast fail
+}
+
+void gnu::gcj::xlib::Window::map()
+{
+ ::Display* dpy = (::Display*) (display->display);
+ ::Window window = xid;
+ XMapWindow(dpy, window);
+ // no fast fail
+}
+
+void gnu::gcj::xlib::Window::unmap()
+{
+ ::Display* dpy = (::Display*) (display->display);
+ ::Window window = xid;
+ XUnmapWindow(dpy, window);
+ // no fast fail
+}
+
+void gnu::gcj::xlib::Window::setProperty(jint nameAtom, jint typeAtom,
+ jbyteArray data)
+{
+ ::Display* dpy = (::Display*) (display->display);
+ int format = 8;
+ int mode = PropModeReplace;
+ unsigned char* pData = (unsigned char*) elements(data);
+ int len = data->length;
+
+ XChangeProperty(dpy, xid, nameAtom, typeAtom, format, mode,
+ pData, len);
+ // no fast fail
+}
+
+void gnu::gcj::xlib::Window::setWMProtocols(jintArray atoms)
+{
+ ::Display* dpy = (::Display*) (display->display);
+
+ size_t length = atoms->length;
+ jint* atomsBegin = elements(atoms);
+ jint* atomsEnd = atomsBegin + length;
+
+ // Avoid confusion between Xlib.h and Atom.java "Atom" types.
+ typedef ::Atom XLibAtom;
+
+ std::vector<XLibAtom> atomVector(atomsBegin, atomsEnd);
+ XLibAtom* atomsArray = &(atomVector.front());
+
+ XSetWMProtocols(dpy, xid, atomsArray, length);
+ // no fail fast
+}
+
+jintArray gnu::gcj::xlib::Window::getWMProtocols()
+{
+ ::Display* dpy = (::Display*) (display->display);
+
+ ::Atom* protocolsReturn;
+ int countReturn;
+
+ Status success = XGetWMProtocols(dpy, xid, &protocolsReturn,
+ &countReturn);
+
+ if (!success)
+ throw new XException(JvNewStringLatin1("cannot get "
+ "WM protocols "));
+
+ jintArray atoms;
+ try
+ {
+ ::Atom* protocolsBegin = protocolsReturn;
+ ::Atom* protocolsEnd = protocolsBegin + countReturn;
+
+ atoms = JvNewIntArray(countReturn);
+ jint* atomsBegin = elements(atoms);
+
+ std::copy(protocolsBegin, protocolsEnd, atomsBegin);
+
+ }
+ catch (...)
+ {
+ XFree(protocolsReturn);
+ throw;
+ }
+ XFree(protocolsReturn);
+
+ return atoms;
+}
+
+void gnu::gcj::xlib::Window::setBounds(jint x, jint y,
+ jint width, jint height)
+{
+ ::Display* dpy = (::Display*) (display->display);
+
+ XMoveResizeWindow(dpy, xid, x, y, width, height);
+ // no fast fail
+}
diff --git a/libjava/gnu/gcj/xlib/natWindowAttributes.cc b/libjava/gnu/gcj/xlib/natWindowAttributes.cc
new file mode 100644
index 00000000000..5281acbab52
--- /dev/null
+++ b/libjava/gnu/gcj/xlib/natWindowAttributes.cc
@@ -0,0 +1,109 @@
+/* Copyright (C) 2000 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. */
+
+#include <X11/Xlib.h>
+
+#include <gcj/cni.h>
+#include <gnu/gcj/RawData.h>
+
+#include <gnu/gcj/xlib/Display.h>
+#include <gnu/gcj/xlib/Window.h>
+#include <gnu/gcj/xlib/WindowAttributes.h>
+#include <gnu/gcj/xlib/Pixmap.h>
+#include <gnu/gcj/xlib/XException.h>
+#include <gnu/gcj/xlib/Screen.h>
+#include <gnu/gcj/xlib/Visual.h>
+
+
+void gnu::gcj::xlib::WindowAttributes::initFromWindow(Window* from)
+{
+ display = from->getDisplay();
+ ::Display* dpy = (::Display*) display->display;
+ ::Window win = from->getXID();
+
+ XWindowAttributes* attributesIn = new XWindowAttributes;
+ in = reinterpret_cast<gnu::gcj::RawData*>(attributesIn);
+
+ Status status = XGetWindowAttributes(dpy, win, attributesIn);
+ if ((status == BadDrawable) | (status == BadWindow))
+ JvThrow(new XException(display, status));
+}
+
+
+void gnu::gcj::xlib::WindowAttributes::init(WindowAttributes* copyFrom)
+{
+ XSetWindowAttributes* attributes = new XSetWindowAttributes;
+
+ if (copyFrom != 0)
+ {
+ XSetWindowAttributes* from =
+ (XSetWindowAttributes*) copyFrom->out;
+ (*attributes) = (*from);
+ }
+
+ out = reinterpret_cast<gnu::gcj::RawData*>(attributes);
+}
+
+void gnu::gcj::xlib::WindowAttributes::finalize()
+{
+ delete in; in = 0;
+ delete out; out = 0;
+}
+
+void gnu::gcj::xlib::WindowAttributes::setBackground(jlong pixel)
+{
+ XSetWindowAttributes* attributes = (XSetWindowAttributes*) out;
+
+ attributes->background_pixel = pixel;
+ mask = mask | CWBackPixel;
+}
+
+void gnu::gcj::xlib::WindowAttributes::setBackground(Pixmap* pixmap)
+{
+ XSetWindowAttributes* attributes = (XSetWindowAttributes*) out;
+
+ attributes->background_pixmap = pixmap->getXID();
+ mask = mask | CWBackPixmap;
+}
+
+void gnu::gcj::xlib::WindowAttributes::setEventMask(jlong eventMask)
+{
+ XSetWindowAttributes* attributes = (XSetWindowAttributes*) out;
+
+ attributes->event_mask = eventMask;
+ mask = mask | CWEventMask;
+}
+
+gnu::gcj::xlib::Visual* gnu::gcj::xlib::WindowAttributes::getVisual()
+{
+ if (in == 0)
+ return 0;
+
+ XWindowAttributes* attributesIn = (XWindowAttributes*) in;
+
+ gnu::gcj::RawData* screenRef =
+ reinterpret_cast<gnu::gcj::RawData*>(attributesIn->screen);
+
+ Screen* screen = new Screen(display, screenRef);
+
+ gnu::gcj::RawData* visualRef =
+ reinterpret_cast<gnu::gcj::RawData*>(attributesIn->visual);
+
+ return new gnu::gcj::xlib::Visual(visualRef, screen, attributesIn->depth);
+}
+
+
+void gnu::gcj::xlib::WindowAttributes::apply(Window* window)
+{
+ ::Display* dpy = (::Display*) window->getDisplay()->display;
+ ::Window win = window->getXID();
+ XSetWindowAttributes* attributes = (XSetWindowAttributes*) out;
+
+ XChangeWindowAttributes(dpy, win, mask, attributes);
+}
+
diff --git a/libjava/gnu/gcj/xlib/natXAnyEvent.cc b/libjava/gnu/gcj/xlib/natXAnyEvent.cc
new file mode 100644
index 00000000000..439f204b373
--- /dev/null
+++ b/libjava/gnu/gcj/xlib/natXAnyEvent.cc
@@ -0,0 +1,99 @@
+/* Copyright (C) 2000 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. */
+
+#include <X11/Xlib.h>
+
+#include <gcj/cni.h>
+#include <gnu/gcj/RawData.h>
+
+#include <java/lang/RuntimeException.h>
+
+#include <java/lang/System.h>
+#include <java/io/PrintStream.h>
+
+#include <gnu/gcj/xlib/Display.h>
+#include <gnu/gcj/xlib/Window.h>
+#include <gnu/gcj/xlib/XAnyEvent.h>
+#include <gnu/gcj/xlib/XExposeEvent.h>
+#include <gnu/gcj/xlib/XException.h>
+
+void gnu::gcj::xlib::XAnyEvent::init()
+{
+ ::XEvent* event = new ::XEvent;
+ structure = reinterpret_cast<gnu::gcj::RawData*>(event);
+}
+
+void gnu::gcj::xlib::XAnyEvent::finalize()
+{
+ delete structure;
+ structure = 0;
+}
+
+void gnu::gcj::xlib::XAnyEvent::loadNext()
+{
+ ::Display* dpy = (::Display*) display->display;
+ ::XEvent* evt = (::XEvent*) structure;
+ XNextEvent(dpy, evt);
+ // What does XNextEvent return?
+}
+
+jint gnu::gcj::xlib::XAnyEvent::getType()
+{
+ ::XEvent* event = (::XEvent*) structure;
+ return event->type;
+}
+
+void gnu::gcj::xlib::XAnyEvent::setType(jint type)
+{
+ ::XEvent* event = (::XEvent*) structure;
+ event->type = type;
+}
+
+gnu::gcj::xlib::Window* gnu::gcj::xlib::XAnyEvent::getWindow()
+{
+ ::XEvent* event = (::XEvent*) structure;
+ return display->getWindow(event->xany.window);
+}
+
+void gnu::gcj::xlib::XAnyEvent::setWindow(gnu::gcj::xlib::Window* window)
+{
+ ::XEvent* event = (::XEvent*) structure;
+ event->xany.window = window->getXID();
+}
+
+jlong gnu::gcj::xlib::XAnyEvent::getSerial()
+{
+ ::XEvent* event = (::XEvent*) structure;
+ return event->xany.serial;
+}
+
+void gnu::gcj::xlib::XAnyEvent::send(gnu::gcj::xlib::Window* destination,
+ jboolean propagate, jlong mask)
+{
+ ::Display* dpy = (::Display*) display->display;
+ ::XEvent* event = (::XEvent*) structure;
+
+ Status status =
+ XSendEvent(dpy, destination->getXID(), propagate ? True : False,
+ mask, event);
+
+ switch (status)
+ {
+ case 0:
+ throw new XException(JvNewStringLatin1("conversion to wire "
+ "protocol failed"));
+ case BadWindow:
+ case BadValue:
+ throw new XException(display, status);
+
+ default:
+ /* All other return values indicate success. Ie. (status ==
+ 1) indicates success, not BadRequest. */
+ ; // NOP
+ }
+}
diff --git a/libjava/gnu/gcj/xlib/natXButtonEvent.cc b/libjava/gnu/gcj/xlib/natXButtonEvent.cc
new file mode 100644
index 00000000000..fa02df833d0
--- /dev/null
+++ b/libjava/gnu/gcj/xlib/natXButtonEvent.cc
@@ -0,0 +1,30 @@
+/* Copyright (C) 2000 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. */
+
+#include <X11/Xlib.h>
+
+#include <gcj/cni.h>
+#include <gnu/gcj/RawData.h>
+
+#include <gnu/gcj/xlib/Display.h>
+#include <gnu/gcj/xlib/Window.h>
+#include <gnu/gcj/xlib/XAnyEvent.h>
+#include <gnu/gcj/xlib/XEvent.h>
+#include <gnu/gcj/xlib/XButtonEvent.h>
+
+void gnu::gcj::xlib::XButtonEvent::init()
+{
+ ::XButtonEvent* evt = (::XButtonEvent*) event->structure;
+
+ time = evt->time;
+ x = evt->x;
+ y = evt->y;
+ state = evt->state;
+ button = evt->button;
+}
+
diff --git a/libjava/gnu/gcj/xlib/natXColor.cc b/libjava/gnu/gcj/xlib/natXColor.cc
new file mode 100644
index 00000000000..4e76cf91f58
--- /dev/null
+++ b/libjava/gnu/gcj/xlib/natXColor.cc
@@ -0,0 +1,61 @@
+/* Copyright (C) 2000 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. */
+
+#include <X11/Xlib.h>
+
+#include <gcj/cni.h>
+#include <gnu/gcj/RawData.h>
+#include <gnu/gcj/xlib/XColor.h>
+
+void gnu::gcj::xlib::XColor::init()
+{
+ structure = reinterpret_cast<gnu::gcj::RawData*>(new ::XColor);
+}
+
+void gnu::gcj::xlib::XColor::finalize()
+{
+ delete structure;
+}
+
+void gnu::gcj::xlib::XColor::setRGB(jint r, jint g, jint b)
+{
+ ::XColor* color = (::XColor*) structure;
+ color->red = r;
+ color->green = g;
+ color->blue = b;
+}
+
+jint gnu::gcj::xlib::XColor::getRed()
+{
+ ::XColor* color = (::XColor*) structure;
+ return color->red;
+}
+
+jint gnu::gcj::xlib::XColor::getGreen()
+{
+ ::XColor* color = (::XColor*) structure;
+ return color->green;
+}
+
+jint gnu::gcj::xlib::XColor::getBlue()
+{
+ ::XColor* color = (::XColor*) structure;
+ return color->blue;
+}
+
+jbyte gnu::gcj::xlib::XColor::getFlags()
+{
+ ::XColor* color = (::XColor*) structure;
+ return color->flags;
+}
+
+jlong gnu::gcj::xlib::XColor::getPixelValue()
+{
+ ::XColor* color = (::XColor*) structure;
+ return color->pixel;
+}
diff --git a/libjava/gnu/gcj/xlib/natXConfigureEvent.cc b/libjava/gnu/gcj/xlib/natXConfigureEvent.cc
new file mode 100644
index 00000000000..a65c0b35134
--- /dev/null
+++ b/libjava/gnu/gcj/xlib/natXConfigureEvent.cc
@@ -0,0 +1,31 @@
+/* Copyright (C) 2000 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. */
+
+#include <X11/Xlib.h>
+
+#include <gcj/cni.h>
+#include <gnu/gcj/RawData.h>
+
+#include <gnu/gcj/xlib/Display.h>
+#include <gnu/gcj/xlib/Window.h>
+#include <gnu/gcj/xlib/XAnyEvent.h>
+#include <gnu/gcj/xlib/XEvent.h>
+#include <gnu/gcj/xlib/XConfigureEvent.h>
+#include <java/awt/Rectangle.h>
+
+using java::awt::Rectangle;
+
+java::awt::Rectangle* gnu::gcj::xlib::XConfigureEvent::getBounds()
+{
+ ::XConfigureEvent* evt = (::XConfigureEvent*) event->structure;
+ Rectangle* rectangle = new Rectangle(evt->x, evt->y,
+ evt->width, evt->height);
+
+ return rectangle;
+}
+
diff --git a/libjava/gnu/gcj/xlib/natXException.cc b/libjava/gnu/gcj/xlib/natXException.cc
new file mode 100644
index 00000000000..4bf7197fb8a
--- /dev/null
+++ b/libjava/gnu/gcj/xlib/natXException.cc
@@ -0,0 +1,24 @@
+/* Copyright (C) 2000 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. */
+
+#include <X11/Xlib.h>
+
+#include <gcj/cni.h>
+#include <gnu/gcj/xlib/Display.h>
+#include <gnu/gcj/xlib/XException.h>
+
+jstring gnu::gcj::xlib::XException::toString(Display* display, jint status)
+{
+ ::Display* dpy = (::Display*) (display->display);
+
+ const int ERROR_TEXT_LENGTH = 256;
+ char errorText[ERROR_TEXT_LENGTH];
+
+ XGetErrorText(dpy, status, errorText, ERROR_TEXT_LENGTH);
+ return JvNewStringLatin1(errorText);
+}
diff --git a/libjava/gnu/gcj/xlib/natXExposeEvent.cc b/libjava/gnu/gcj/xlib/natXExposeEvent.cc
new file mode 100644
index 00000000000..6dad170e432
--- /dev/null
+++ b/libjava/gnu/gcj/xlib/natXExposeEvent.cc
@@ -0,0 +1,31 @@
+/* Copyright (C) 2000 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. */
+
+#include <X11/Xlib.h>
+
+#include <gcj/cni.h>
+#include <gnu/gcj/RawData.h>
+
+#include <gnu/gcj/xlib/Display.h>
+#include <gnu/gcj/xlib/Window.h>
+#include <gnu/gcj/xlib/XAnyEvent.h>
+#include <gnu/gcj/xlib/XEvent.h>
+#include <gnu/gcj/xlib/XExposeEvent.h>
+#include <java/awt/Rectangle.h>
+
+using java::awt::Rectangle;
+
+java::awt::Rectangle* gnu::gcj::xlib::XExposeEvent::getBounds()
+{
+ ::XExposeEvent* evt = (::XExposeEvent*) event->structure;
+ Rectangle* rectangle = new Rectangle(evt->x, evt->y,
+ evt->width, evt->height);
+
+ return rectangle;
+}
+
diff --git a/libjava/gnu/gcj/xlib/natXImage.cc b/libjava/gnu/gcj/xlib/natXImage.cc
new file mode 100644
index 00000000000..a527e8e665b
--- /dev/null
+++ b/libjava/gnu/gcj/xlib/natXImage.cc
@@ -0,0 +1,220 @@
+/* Copyright (C) 2000 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. */
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+
+#include <gcj/cni.h>
+#include <gnu/gcj/RawData.h>
+
+#include <java/lang/OutOfMemoryError.h>
+
+#include <gnu/gcj/xlib/Display.h>
+#include <gnu/gcj/xlib/Screen.h>
+#include <gnu/gcj/xlib/Visual.h>
+#include <gnu/gcj/xlib/XImage.h>
+#include <java/lang/System.h>
+#include <java/io/PrintStream.h>
+
+void gnu::gcj::xlib::XImage::init(Visual* visual, jint depth,
+ jint format, jint xoffset,
+ jint width, jint height,
+ jint bitmapPad, jint bytesPerLine,
+ jint bitsPerPixel)
+{
+ ::Display* dpy = (::Display*) visual->display->display;
+ ::Visual* vis = (::Visual*) visual->getVisualStructure();
+
+ char* data = 0; // no preallocated data
+ ::XImage* ximage = XCreateImage(dpy, vis, depth, format, xoffset,
+ data,
+ width, height,
+ bitmapPad,
+ bytesPerLine
+ );
+ if (ximage == 0)
+ {
+ jstring errorMessage = JvNewStringLatin1("XCreateImage failed");
+ JvThrow(new java::lang::OutOfMemoryError(errorMessage));
+ }
+
+ bool reinitialize = false;
+
+ if ((bitsPerPixel != 0) && (ximage->bits_per_pixel != bitsPerPixel))
+ {
+ ximage->bits_per_pixel = bitsPerPixel;
+ reinitialize = true;
+ }
+
+ // FIXME: make autoconf test?
+ jshort endianTestShort[] = { 1 };
+ jbyte* endianTestByte = reinterpret_cast<jbyte*>(endianTestShort);
+
+ jint byteOrder;
+ if (endianTestByte[0] == 1)
+ {
+ // little endian machine
+ byteOrder = LEAST_SIGNIFICANT_B_FIRST_ORDER;
+ }
+ else
+ {
+ // big endian machine
+ byteOrder = MOST_SIGNIFICANT_B_FIRST_ORDER;
+ }
+ /* NB: This doesn't consider those weird machines out there with
+ middle-endian byte order. */
+
+ if (byteOrder != ximage->byte_order)
+ {
+ ximage->byte_order = byteOrder;
+ reinitialize = true;
+ }
+
+ if (reinitialize)
+ XInitImage(ximage);
+
+ structure = reinterpret_cast<gnu::gcj::RawData*>(ximage);
+ // Notice that no image data has been allocated at this point
+}
+
+void gnu::gcj::xlib::XImage::init(Visual* visual,
+ jint width,
+ jint height)
+{
+ int depth = visual->getDepth();
+
+ int format = ZPixmap; // Chunky, not planar.
+ int offset = 0;
+ int bitmapPad = 32; // FIXME, don't hardcode this
+ int bytesPerLine = 0; // Let the server figure it out
+
+ init(visual, depth, format, offset, width, height, bitmapPad,
+ bytesPerLine, 0);
+}
+
+void gnu::gcj::xlib::XImage::internalSetData(jbyteArray data, jint offset)
+{
+ ::XImage* ximage = (::XImage*) structure;
+ ximage->data = reinterpret_cast<char*>(elements(data)+offset);
+}
+
+void gnu::gcj::xlib::XImage::internalSetData(jshortArray data, jint offset)
+{
+ ::XImage* ximage = (::XImage*) structure;
+ ximage->data = reinterpret_cast<char*>(elements(data)+offset);
+}
+
+void gnu::gcj::xlib::XImage::internalSetData(jintArray data, jint offset)
+{
+ ::XImage* ximage = (::XImage*) structure;
+ ximage->data = reinterpret_cast<char*>(elements(data)+offset);
+}
+
+void gnu::gcj::xlib::XImage::finalize()
+{
+ ::XImage* ximage = (::XImage*) structure;
+ if (ownsData)
+ delete ximage->data;
+
+ ximage->data = 0; // Never allow XLib to free the data allocation.
+ dataRef = 0;
+ XDestroyImage(ximage);
+}
+
+jint gnu::gcj::xlib::XImage::getWidth()
+{
+ ::XImage* ximage = (::XImage*) structure;
+ return ximage->width;
+}
+
+jint gnu::gcj::xlib::XImage::getHeight()
+{
+ ::XImage* ximage = (::XImage*) structure;
+ return ximage->height;
+}
+
+jint gnu::gcj::xlib::XImage::getDepth()
+{
+ ::XImage* ximage = (::XImage*) structure;
+ return ximage->depth;
+}
+
+jint gnu::gcj::xlib::XImage::getFormat()
+{
+ ::XImage* ximage = (::XImage*) structure;
+ return ximage->format;
+}
+
+jint gnu::gcj::xlib::XImage::getXOffset()
+{
+ ::XImage* ximage = (::XImage*) structure;
+ return ximage->xoffset;
+}
+
+jint gnu::gcj::xlib::XImage::getImageByteOrder()
+{
+ ::XImage* ximage = (::XImage*) structure;
+ return ximage->byte_order;
+}
+
+jint gnu::gcj::xlib::XImage::getBitmapBitOrder()
+{
+ ::XImage* ximage = (::XImage*) structure;
+ return ximage->bitmap_bit_order;
+}
+
+jint gnu::gcj::xlib::XImage::getBitmapUnit()
+{
+ ::XImage* ximage = (::XImage*) structure;
+ return ximage->bitmap_unit;
+}
+
+jint gnu::gcj::xlib::XImage::getBitmapPad()
+{
+ ::XImage* ximage = (::XImage*) structure;
+ return ximage->bitmap_pad;
+}
+
+jint gnu::gcj::xlib::XImage::getBytesPerLine()
+{
+ ::XImage* ximage = (::XImage*) structure;
+ return ximage->bytes_per_line;
+}
+
+jint gnu::gcj::xlib::XImage::getBitsPerPixel()
+{
+ ::XImage* ximage = (::XImage*) structure;
+ return ximage->bits_per_pixel;
+}
+
+
+// True/Direct Color specific:
+
+jint gnu::gcj::xlib::XImage::getRedMask()
+{
+ ::XImage* ximage = (::XImage*) structure;
+ return ximage->red_mask;
+}
+
+jint gnu::gcj::xlib::XImage::getGreenMask()
+{
+ ::XImage* ximage = (::XImage*) structure;
+ return ximage->green_mask;
+}
+
+jint gnu::gcj::xlib::XImage::getBlueMask()
+{
+ ::XImage* ximage = (::XImage*) structure;
+ return ximage->blue_mask;
+}
+
+void gnu::gcj::xlib::XImage::setPixel(jint x, jint y, jint pixel)
+{
+ ::XImage* ximage = (::XImage*) structure;
+ XPutPixel(ximage, x, y, pixel);
+}
diff --git a/libjava/gnu/gcj/xlib/natXUnmapEvent.cc b/libjava/gnu/gcj/xlib/natXUnmapEvent.cc
new file mode 100644
index 00000000000..d91a7787283
--- /dev/null
+++ b/libjava/gnu/gcj/xlib/natXUnmapEvent.cc
@@ -0,0 +1,32 @@
+/* Copyright (C) 2000 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. */
+
+#include <X11/Xlib.h>
+
+#include <gcj/cni.h>
+#include <gnu/gcj/RawData.h>
+
+#include <gnu/gcj/xlib/Display.h>
+#include <gnu/gcj/xlib/Window.h>
+#include <gnu/gcj/xlib/XAnyEvent.h>
+#include <gnu/gcj/xlib/XEvent.h>
+#include <gnu/gcj/xlib/XUnmapEvent.h>
+
+void gnu::gcj::xlib::XUnmapEvent::setUnmappedWindow(gnu::gcj::xlib::Window*
+ unmappedWindow)
+{
+ ::XUnmapEvent* evt = (::XUnmapEvent*) event->structure;
+ evt->window = unmappedWindow->getXID();
+}
+
+void gnu::gcj::xlib::XUnmapEvent::setFromConfigure(jboolean fromConfigure)
+{
+ ::XUnmapEvent* evt = (::XUnmapEvent*) event->structure;
+ evt->from_configure = fromConfigure ? True : False;
+}
+
OpenPOWER on IntegriCloud