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
147 lines
3.4 KiB
C++
147 lines
3.4 KiB
C++
/* 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));
|
|
}
|
|
}
|