Yesterday I've got GNU Classpath 0.20 with Qtopia Core 4.1.1 (that's the new 
name for Qt/Embedded 4.1.x) snapshot 20060131 running on an industrial 
PDA-like device.

Qt/Embedded Applications need a so called QWS-Server. AFAIK this server is 
responsible for placing the windows, getting keyboard input etc. After all, 
Qt/Embedded run's directly in the Framebuffer and so there is no X-Windows 
Window Manager.

An application can either be called with -qws as command line option
or it can instantiate the QApplication() with a QApplication::GuiServer
argument.

The latter is done if the system property "qtoptions.qws" is set.

The patch would be less invasive if I wouldn't have followed the original 
qt-peer programming pattern, e.g. I could directly get the system properties 
in the native code. That way only one file would be needed to be patched, no 
Java class would need a "private boolean qws" variable etc. But this patch 
mimicks the code-path that qt-peer does with the doublebuffer variable.

Once applied and compiled, you can call Qt/Embedded apps like this:

jamvm \
        -Dawt.toolkit=gnu.java.awt.peer.qt.QtToolkit \
        -Dqtoptions.qws=true \
        -classpath /opt/java/examples.zip \
        gnu.classpath.examples.awt.Demo

If you have a separate QWS server running:

#include <QtGui/QApplication>

-----------------------------------------------
int main(int argc, char* argv[])
{
        QApplication app(argc, argv, QApplication::GuiServer);
        app.exec();
        return 0;
}
-----------------------------------------------

then you can simply omit the "-Dqtoptions.qws=something".
Qt/Embedded applications run without X11 directly on the framebuffer.
But some instance still needs to place the windows, that's the QWS server.
An Qt/E application can either be called with -qws as command line option
or it can instantiate the QApplication() with a QApplication::GuiServer
argument.

The latter is done if the system property "qtoptions.qws" is set.


--- c.orig/gnu/java/awt/peer/qt/MainQtThread.java
+++ c/gnu/java/awt/peer/qt/MainQtThread.java
@@ -51,11 +51,13 @@
   String theme;
   private boolean running;
   private boolean doublebuffer;
+  private boolean qws;
 
-  public MainQtThread( String theme, boolean doublebuffer )
+  public MainQtThread( String theme, boolean doublebuffer, boolean qws )
   {
     this.theme = theme;
     this.doublebuffer = doublebuffer;
+    this.qws = qws;
     running = false;
   }
 
@@ -67,7 +69,7 @@
   /**
    * Creates the QApplication
    */
-  public native long init(String theme, boolean doublebuffer);
+  public native long init(String theme, boolean doublebuffer, boolean qws);
 
   /**
    * Runs the QApplication (doesn't return.)
@@ -76,7 +78,7 @@
 
   public void run()
   {
-    QApplicationPointer = init(theme, doublebuffer);
+    QApplicationPointer = init(theme, doublebuffer, qws);
     running = true;
     exec(QApplicationPointer);
   }
--- c.orig/gnu/java/awt/peer/qt/QtToolkit.java
+++ c/gnu/java/awt/peer/qt/QtToolkit.java
@@ -167,7 +167,21 @@
       {
       }
 
-    guiThread = new MainQtThread( theme, doublebuffer );
+    boolean qws = false;
+    try
+      {
+	String s = System.getProperty("qtoptions.qws");
+	if(s != null)
+	  qws = true;
+      }
+    catch(SecurityException e)
+      {
+      }
+    catch(IllegalArgumentException e)
+      {
+      }
+
+    guiThread = new MainQtThread( theme, doublebuffer, qws );
     guiThread.start();
     repaintThread.start();
   }
--- c.orig/include/gnu_java_awt_peer_qt_MainQtThread.h
+++ c/include/gnu_java_awt_peer_qt_MainQtThread.h
@@ -10,7 +10,7 @@
 {
 #endif
 
-JNIEXPORT jlong JNICALL Java_gnu_java_awt_peer_qt_MainQtThread_init (JNIEnv *env, jobject, jstring, jboolean);
+JNIEXPORT jlong JNICALL Java_gnu_java_awt_peer_qt_MainQtThread_init (JNIEnv *env, jobject, jstring, jboolean, jboolean);
 JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_MainQtThread_exec (JNIEnv *env, jobject, jlong);
 
 #ifdef __cplusplus
--- c.orig/native/jni/qt-peer/mainqtthread.cpp
+++ c/native/jni/qt-peer/mainqtthread.cpp
@@ -50,7 +50,7 @@
  * Starts up a QApplication
  */
 JNIEXPORT jlong JNICALL Java_gnu_java_awt_peer_qt_MainQtThread_init
-(JNIEnv *env, jobject obj, jstring theme, jboolean doublebuffer)
+(JNIEnv *env, jobject obj, jstring theme, jboolean doublebuffer, jboolean qws)
 {
   int *argc;
   char **argv;
@@ -75,7 +75,7 @@
       argv[0] = (char *)malloc(10 * sizeof(char));
       strncpy(argv[0], " \0", 3);
     }
-  QApplication *qtApp = new QApplication( *argc, argv );
+  QApplication *qtApp = new QApplication( *argc, argv, qws ? QApplication::GuiServer : QApplication::GuiClient );
   assert( qtApp );
 
   qApplication = qtApp;

Reply via email to