From 798082a9cf2856f50f91483da37b5d9661355f00 Mon Sep 17 00:00:00 2001 From: megacz Date: Fri, 30 Jan 2004 06:58:59 +0000 Subject: [PATCH] 2003/04/20 06:29:51 darcs-hash:20040130065859-2ba56-106a9b62f140e5e242e4b955e4469646429fcf17.gz --- src/org/xwt/plat/Darwin.java | 8 ++++++++ src/org/xwt/plat/GCJ.cc | 32 +++++++++++++++++++++++++++----- src/org/xwt/plat/GCJ.java | 2 ++ src/org/xwt/plat/Linux.java | 8 ++++++++ src/org/xwt/plat/POSIX.cc | 7 ++++--- src/org/xwt/plat/Win32.cc | 1 + src/org/xwt/plat/X11.cc | 26 +++++++++++++------------- 7 files changed, 63 insertions(+), 21 deletions(-) create mode 100644 src/org/xwt/plat/Darwin.java create mode 100644 src/org/xwt/plat/Linux.java diff --git a/src/org/xwt/plat/Darwin.java b/src/org/xwt/plat/Darwin.java new file mode 100644 index 0000000..cc755d1 --- /dev/null +++ b/src/org/xwt/plat/Darwin.java @@ -0,0 +1,8 @@ +// Copyright 2002 Adam Megacz, see the COPYING file for licensing [GPL] +package org.xwt.plat; + +import org.xwt.*; + +/** All Darwin-derived operating systems (Mac OS X, OpenDarwin) */ +public abstract class Darwin extends X11 { +} diff --git a/src/org/xwt/plat/GCJ.cc b/src/org/xwt/plat/GCJ.cc index bc8989e..9efbe82 100644 --- a/src/org/xwt/plat/GCJ.cc +++ b/src/org/xwt/plat/GCJ.cc @@ -1,17 +1,40 @@ +// Copyright 2002 Adam Megacz, see the COPYING file for licensing [LGPL] + +// Inclusions ///////////////////////////////////////////////////////// + +#include +#include extern "C" { #include #include #include #include "jpeglib.h" } -#include -#include - -#include +#include +#include #include +#include +#include #include #include + + +// builtin.xwar ///////////////////////////////////////////////////////// + +extern unsigned char builtin_xwar[]; +extern int builtin_xwar_length; + +java::io::InputStream* org::xwt::plat::GCJ::_getBuiltinInputStream() { + jbyteArray ret = JvNewByteArray(builtin_xwar_length); + memcpy(elements(ret), builtin_xwar, builtin_xwar_length); + return new java::io::ByteArrayInputStream(ret); +} + + + +// JPEG //////////////////////////////////////////////////////////////// + #define INPUT_BUF_SIZE (1024 * 16) typedef struct { @@ -99,4 +122,3 @@ void org::xwt::plat::GCJ$JPEG::nativeDecompress() { jpeg_destroy_decompress(&cinfo); } - diff --git a/src/org/xwt/plat/GCJ.java b/src/org/xwt/plat/GCJ.java index 4a6d23f..38d9ec9 100644 --- a/src/org/xwt/plat/GCJ.java +++ b/src/org/xwt/plat/GCJ.java @@ -18,6 +18,8 @@ public abstract class GCJ extends Platform { private static Class c7 = gnu.gcj.convert.Output_ASCII.class; protected org.xwt.Weak _getWeak(Object o) { return new Java2Weak(o); } + protected native InputStream _getBuiltinInputStream(); + private static class Java2Weak extends java.lang.ref.WeakReference implements org.xwt.Weak { public Java2Weak(Object o) { super(o); } } diff --git a/src/org/xwt/plat/Linux.java b/src/org/xwt/plat/Linux.java new file mode 100644 index 0000000..d56960d --- /dev/null +++ b/src/org/xwt/plat/Linux.java @@ -0,0 +1,8 @@ +// Copyright 2002 Adam Megacz, see the COPYING file for licensing [GPL] +package org.xwt.plat; + +import org.xwt.*; + +/** Linux with an X11 display */ +public abstract class Linux extends X11 { +} diff --git a/src/org/xwt/plat/POSIX.cc b/src/org/xwt/plat/POSIX.cc index a34d202..9155c80 100644 --- a/src/org/xwt/plat/POSIX.cc +++ b/src/org/xwt/plat/POSIX.cc @@ -1,11 +1,14 @@ // Copyright 2002 Adam Megacz, see the COPYING file for licensing [LGPL] // see below for copyright information on the second portion of this file +#include "GCJ.cc" + #include #include #include +#include +#include #include -#include #include #include @@ -23,8 +26,6 @@ #include #include -#include "GCJ.cc" - jstring org::xwt::plat::POSIX::_getEnv(jstring key) { int len = JvGetStringUTFLength(key); char buf[len + 1]; diff --git a/src/org/xwt/plat/Win32.cc b/src/org/xwt/plat/Win32.cc index 6ba10bf..bd27721 100644 --- a/src/org/xwt/plat/Win32.cc +++ b/src/org/xwt/plat/Win32.cc @@ -5,6 +5,7 @@ #define INT32 WIN32_INT32 // this has to precede the others so we don't get collisions on min/max +#include #include #include diff --git a/src/org/xwt/plat/X11.cc b/src/org/xwt/plat/X11.cc index 684f3bb..90d1659 100644 --- a/src/org/xwt/plat/X11.cc +++ b/src/org/xwt/plat/X11.cc @@ -1,8 +1,8 @@ // Copyright 2002 Adam Megacz, see the COPYING file for licensing [LGPL] // see below for copyright information on the second portion of this file -#include -#include +#include "POSIX.cc" + #include #include #include @@ -11,16 +11,11 @@ #include #include #include -#include -#include -#include -#include -#include -#include #include #include #include +#include #include #include #include @@ -35,15 +30,13 @@ #include #include -#include "POSIX.cc" - // static (per-xserver) data static Visual* visual; static Colormap s_colormap; static XStandardColormap* colormap_info; static XShmSegmentInfo shm_info; static Window selectionWindow; -static int shm_supported; +static int shm_supported = 0; static int shm_pixmaps_supported; static int screen_num; static int colorDepth = 0; @@ -708,12 +701,19 @@ void org::xwt::plat::X11::natInit() { if (!XInitThreads()) org::xwt::Platform::criticalAbort(JvNewStringLatin1("Your X11 libraries do not support multithreaded programs")); - display = XOpenDisplay(NULL); + char* DISPLAY = getenv("DISPLAY"); + if (DISPLAY == NULL || strlen(DISPLAY) == 0) DISPLAY = ":0.0"; + display = XOpenDisplay(DISPLAY); + + if (display == 0) + org::xwt::Platform::criticalAbort(JvNewStringLatin1("Unable to connect to X11 display server")); + screen_num = XDefaultScreen(display); colorDepth = (jint)(DefaultDepth(((Display*)display), 0)); shm_info.shmaddr = NULL; - shm_supported = (XShmQueryExtension(display) == True); + // FIXME: SHM doesn't work on Darwin + //shm_supported = (XShmQueryExtension(display) == True); if (shm_supported) { X11ErrorHandler* oldHandler = XSetErrorHandler(errorHandler); XShmSegmentInfo sinfo; -- 1.7.10.4