2003/04/20 06:29:51
authormegacz <megacz@xwt.org>
Fri, 30 Jan 2004 06:58:59 +0000 (06:58 +0000)
committermegacz <megacz@xwt.org>
Fri, 30 Jan 2004 06:58:59 +0000 (06:58 +0000)
darcs-hash:20040130065859-2ba56-106a9b62f140e5e242e4b955e4469646429fcf17.gz

src/org/xwt/plat/Darwin.java [new file with mode: 0644]
src/org/xwt/plat/GCJ.cc
src/org/xwt/plat/GCJ.java
src/org/xwt/plat/Linux.java [new file with mode: 0644]
src/org/xwt/plat/POSIX.cc
src/org/xwt/plat/Win32.cc
src/org/xwt/plat/X11.cc

diff --git a/src/org/xwt/plat/Darwin.java b/src/org/xwt/plat/Darwin.java
new file mode 100644 (file)
index 0000000..cc755d1
--- /dev/null
@@ -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 {
+}
index bc8989e..9efbe82 100644 (file)
@@ -1,17 +1,40 @@
+// 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 {
@@ -99,4 +122,3 @@ void org::xwt::plat::GCJ$JPEG::nativeDecompress() {
     jpeg_destroy_decompress(&cinfo);
 }
 
-
index 4a6d23f..38d9ec9 100644 (file)
@@ -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 (file)
index 0000000..d56960d
--- /dev/null
@@ -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 {
+}
index a34d202..9155c80 100644 (file)
@@ -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 <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>
 
@@ -23,8 +26,6 @@
 #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];
index 6ba10bf..bd27721 100644 (file)
@@ -5,6 +5,7 @@
 #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>
index 684f3bb..90d1659 100644 (file)
@@ -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 <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;
@@ -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;