]> git.webhop.me Git - lcd4linux.git/commitdiff
special commandline parameters for X11
authorvolker <volker@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Fri, 20 Nov 2009 14:49:34 +0000 (14:49 +0000)
committervolker <volker@3ae390bd-cb1e-0410-b409-cd5a39f66f1f>
Fri, 20 Nov 2009 14:49:34 +0000 (14:49 +0000)
git-svn-id: https://ssl.bulix.org/svn/lcd4linux/trunk@1067 3ae390bd-cb1e-0410-b409-cd5a39f66f1f

drv.h
drv_X11.c
lcd4linux.c
svn_version.h

diff --git a/drv.h b/drv.h
index db2d1ddb960f932fa2d8d4036c2cc18e02b56cb4..2780206ad5191962b0b975cd49f5a4541035ef8a 100644 (file)
--- a/drv.h
+++ b/drv.h
@@ -41,6 +41,14 @@ typedef struct DRIVER {
  */
 extern char *output;
 
+#ifdef WITH_X11
+/* function to handle special X11 command line parameters
+ * has to be defined here because it's referenced
+ * in main before dealing with normal parameters.
+ */
+void drv_X11_parseArgs(int *argc, char *arvg[]);
+#endif
+
 int drv_list(void);
 int drv_init(const char *section, const char *driver, const int quiet);
 int drv_quit(const int quiet);
index 6ff17df6bf2d50dee00d8254b20b9488d064c817..41e2f77ee24c31841a0ae96ee1dd19794a3aecf4 100644 (file)
--- a/drv_X11.c
+++ b/drv_X11.c
@@ -49,6 +49,7 @@
 #include <signal.h>
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>
+#include <X11/Xresource.h>
 
 #include "debug.h"
 #include "cfg.h"
@@ -93,6 +94,14 @@ static GC gc;
 static Colormap cm;
 static Pixmap pm;
 
+static char myDisplayName[256] = "";
+static int opTableEntries = 2;
+static XrmOptionDescRec opTable[] = {
+    {"-display", ".display", XrmoptionSepArg, NULL},
+    {"-synchronous", "*synchronous", XrmoptionNoArg, "on"},
+};
+static XrmDatabase commandlineDB;
+
 
 /****************************************/
 /***  hardware dependant functions    ***/
@@ -413,6 +422,8 @@ static int drv_X11_start(const char *section)
 {
     int i;
     char *s;
+    XrmValue value;
+    char *str_type[20];
     XSetWindowAttributes wa;
     XSizeHints sh;
     XEvent ev;
@@ -489,11 +500,21 @@ static int drv_X11_start(const char *section)
        drv_X11_FB[i] = NO_COL;
     }
 
-    if ((dp = XOpenDisplay(NULL)) == NULL) {
-       error("%s: can't open display", Name);
+    if (XrmGetResource(commandlineDB, "lcd4linux.display", "Lcd4linux.Display", str_type, &value)) {
+       strncpy(myDisplayName, value.addr, value.size);
+       debug("%s: X11 display name from command line: %s", Name, myDisplayName);
+    }
+
+    if ((dp = XOpenDisplay(strlen(myDisplayName) > 0 ? myDisplayName : NULL)) == NULL) {
+       error("%s: can't open display %s", Name, XDisplayName(strlen(myDisplayName) > 0 ? myDisplayName : NULL));
        return -1;
     }
 
+    if (XrmGetResource(commandlineDB, "lcd4linux*synchronous", "Lcd4linux*Synchronous", str_type, &value)) {
+       debug("%s: X synchronize on", Name);
+       XSynchronize(dp, 1 /* true */ );
+    }
+
     sc = DefaultScreen(dp);
     gc = DefaultGC(dp, sc);
     vi = DefaultVisual(dp, sc);
@@ -595,6 +616,15 @@ int drv_X11_list(void)
 }
 
 
+/* read X11 specific command line arguments */
+/* it is defined in drv.h */
+void drv_X11_parseArgs(int *argc, char *argv[])
+{
+    XrmInitialize();
+    XrmParseCommand(&commandlineDB, opTable, opTableEntries, "lcd4linux", argc, argv);
+}
+
+
 /* initialize driver & display */
 int drv_X11_init(const char *section, const int quiet)
 {
index bf17f5e8af426f99be721bd65aed41795daaa5ae..7a48c7c2d3d4415cd5cce6b010c4e11286c5ac12 100644 (file)
@@ -91,6 +91,14 @@ static void usage(void)
     printf("  -F               do not fork and detach (run in foreground)\n");
     printf("  -o <output-file> write picture to file (raster driver only)\n");
     printf("  -q               suppress startup and exit splash screen\n");
+#ifdef WITH_X11
+    printf("special X11 options:\n");
+    printf("  -display <X11 display name>  preceeds X connection given in $DISPLAY\n");
+    printf("  -synchronous                 use synchronized communication with X server (for debugging)\n");
+    printf("\n");
+    printf("\n");
+    printf("\n");
+#endif
 }
 
 static void interactive_mode(void)
@@ -222,6 +230,13 @@ int main(int argc, char *argv[])
     running_foreground = 0;
     running_background = 0;
 
+#ifdef WITH_X11
+    drv_X11_parseArgs(&argc, argv);
+    if (argc != thread_argc) {
+       /* info() will not work here because verbose level is not known */
+       printf("recognized special X11 parameters\n");
+    }
+#endif
     while ((c = getopt(argc, argv, "c:Ff:hilo:qvp:")) != EOF) {
 
        switch (c) {
index 73131b428b2d638c45bfe911d8df20ec412fd72e..090b8c8b9d664b586d83e27ca04c3790fbe29e2e 100644 (file)
@@ -1 +1 @@
-#define SVN_VERSION "1048"
+#define SVN_VERSION "1066M"