--- /dev/null
+// 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 {
+}
+// Copyright 2002 Adam Megacz, see the COPYING file for licensing [LGPL]
+
+// Inclusions /////////////////////////////////////////////////////////
+
+#include <gcj/cni.h>
+#include <gcj/array.h>
extern "C" {
#include <stdlib.h>
#include <stdio.h>
#include <setjmp.h>
#include "jpeglib.h"
}
-#include <gcj/cni.h>
-#include <gcj/array.h>
-
-#include <java/lang/RuntimeException.h>
+#include <org/xwt/util/JSObject.h>
+#include <org/xwt/plat/GCJ.h>
#include <java/io/InputStream.h>
+#include <java/io/ByteArrayInputStream.h>
+#include <java/lang/RuntimeException.h>
#include <org/xwt/plat/GCJ.h>
#include <org/xwt/plat/GCJ$JPEG.h>
+
+
+// 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 {
jpeg_destroy_decompress(&cinfo);
}
-
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); }
}
--- /dev/null
+// 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 {
+}
// 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 <stdio.h>
#include <stdlib.h>
#include <unistd.h>
+#include <sys/ipc.h>
+#include <sys/shm.h>
#include <sys/types.h>
-#include <gcj/cni.h>
#include <signal.h>
#include <java/lang/String.h>
#include <java/lang/System.h>
#include <java/io/PrintStream.h>
-#include "GCJ.cc"
-
jstring org::xwt::plat::POSIX::_getEnv(jstring key) {
int len = JvGetStringUTFLength(key);
char buf[len + 1];
#define INT32 WIN32_INT32
// this has to precede the others so we don't get collisions on min/max
+#include <org/xwt/util/JSObject.h>
#include <org/xwt/Box.h>
#include <stdint.h>
// Copyright 2002 Adam Megacz, see the COPYING file for licensing [LGPL]
// see below for copyright information on the second portion of this file
-#include <sys/ipc.h>
-#include <sys/shm.h>
+#include "POSIX.cc"
+
#include <X11/Xlib.h>
#include <X11/extensions/XShm.h>
#include <X11/keysymdef.h>
#include <X11/Xutil.h>
#include <X11/Xatom.h>
#include <X11/Xmu/StdCmap.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <gcj/cni.h>
-#include <signal.h>
#include <java/lang/String.h>
#include <org/xwt/Surface.h>
#include <org/xwt/Picture.h>
+#include <org/xwt/util/JSObject.h>
#include <org/xwt/Box.h>
#include <org/xwt/plat/X11.h>
#include <org/xwt/plat/X11$X11Surface.h>
#include <java/lang/System.h>
#include <java/io/PrintStream.h>
-#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;
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;