2622c79d2d
* 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. From-SVN: r37005
133 lines
3.7 KiB
C++
133 lines
3.7 KiB
C++
/* 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);
|
|
}
|