RealDeal patch to Matchbox 0.50

"Raphael J. Schmid" <[email protected]>
Newsgroups gmane.comp.handhelds.matchbox
Message-ID <1051388433.3985.13.camel@proactivity>
Hi There,

somehow I had a change in my mind, being afraid I'd
have to -doh!- actually do some work again when the
next Matchbox version comes out. So I'll just try and
send you this patch which makes Matchbox usable with
my RealDeal thingy when using -DUSE_REALDEAL. There's
no ./configure option for it though.

In an evil attempt of a bribe, I've also corrected a
typo/spelling error in one of the error messages, and
got rid of all compiler warnings I was able to find.
Thanks to Mark Hymers for help with that.

Find the patch attached.

- Raphael

P.S.: Hopefully you don't mind the spaces instead of
tabs here and there? Some of the stuff was pasted...

_______________________________________________
Matchbox mailing list
[email protected]
https://handhelds.org/mailman/listinfo/matchbox
matchbox-0.5-realdeal-1.patch (text/x-patch, 8.9 KB)
diff -Naur matchbox-0.5/src/main.c rdwm/src/main.c
--- matchbox-0.5/src/main.c	2003-02-17 01:37:49.000000000 +0100
+++ rdwm/src/main.c	2003-04-26 21:07:24.000000000 +0200
@@ -26,17 +26,97 @@
 #include "wm.h"
 #include "misc.h"
 
+#ifdef USE_REALDEAL
+#include "rd.h"
+#endif
 
 #ifdef USE_XFT
 #include <X11/Xft/Xft.h>
 #endif
 
+#ifdef USE_REALDEAL
+int get_value(char *string)
+{
+  /* Thanks to ppl from irc.freenode.net#c for this one! */
+                                                                                                                                                                   
+  int   a;
+  char *s;
+                                                                                                                                                                   
+  if ( (s = strchr(string, '=') + 1) != NULL) {
+    a = atoi(s);
+                                                                                                                                                                   
+    if (a <= 0) {
+      /* I know you don't do this.
+       * Apparently, I do do it.
+       * Now waggle off, thanks.
+       */
+      goto error;
+    }
+  }
+  else { /* Weren't we handled a string with a proper number? */
+    error:
+    err("Improper viewport placement option(s)!\n" USAGE);
+    exit(3);
+  }
+                                                                                                                                                                   
+  return(a);
+}
+#endif
 
 int main(int argc, char **argv)
 {
    wm *w;
    struct sigaction act;
 
+#ifdef USE_REALDEAL
+   int i;
+
+   /* Initialize the Viewport structure */
+   vp = malloc(sizeof *vp);
+
+   /* Attention: due to my lazyness, I'm
+    * simply disabling the original MB
+    * commandline argument parser. It does
+    * not understand these arguments and
+    * bails out. */
+   if (argc < 4+1) {
+     err("Insufficient argument list.\n" USAGE);
+     exit(1);
+   } for (i = 1; i < argc; i++) {
+       if (strcmp(argv[i], "-version") == 0) {
+         printf("wm: Version " VERSION "\n");
+         exit(0);
+       }
+       if (strcmp(argv[i], "-help") == 0) {
+         printf(USAGE);
+         exit(0);
+       }
+                                                                                                                                                                   
+       /* we're being told where
+        * to place the viewport. */
+       if (strncmp(argv[i], "-pos-x=", strlen("-pos-x=")) == 0) {
+         vp->pos_x = get_value(argv[i]);
+         continue;
+       }
+       if (strncmp(argv[i], "-pos-y=", strlen("-pos-y=")) == 0) {
+         vp->pos_y = get_value(argv[i]);
+         continue;
+       }
+       if (strncmp(argv[i], "-sub-x=", strlen("-sub-x=")) == 0) {
+         vp->sub_x = get_value(argv[i]);
+         continue;
+       }
+       if (strncmp(argv[i], "-sub-y=", strlen("-sub-y=")) == 0) {
+         vp->sub_y = get_value(argv[i]);
+         continue;
+       }
+                                                                                                                                                                   
+       /* If we get here, it's got to be a bad option */
+       err("Unknown option: '%s'\n" USAGE, argv[i]);
+       exit(2);
+   }
+#endif
+
    act.sa_handler = sig_handler;
    act.sa_flags = 0;
    sigaction(SIGTERM, &act, NULL);
@@ -59,9 +139,3 @@
    
    return 1;
 }
-
-
-
-
-
-
diff -Naur matchbox-0.5/src/main_client.c rdwm/src/main_client.c
--- matchbox-0.5/src/main_client.c	2003-04-06 23:24:31.000000000 +0200
+++ rdwm/src/main_client.c	2003-04-26 21:01:45.000000000 +0200
@@ -19,6 +19,10 @@
 
 #include "main_client.h"
 
+#ifdef USE_REALDEAL
+#include "rd.h"
+#endif
+
 #define VBW(c) 5
 #define SBW(c) 5
 
@@ -140,7 +144,9 @@
     int offset_west  = theme_frame_defined_width_get(c->wm->mbtheme, 
 						     FRAME_MAIN_WEST );
     attr.override_redirect = True;
+#ifndef USE_REALDEAL
     attr.background_pixel  = BlackPixel(c->wm->dpy, c->wm->screen);
+#endif
     attr.event_mask        = ChildMask|ButtonMask|ExposureMask;
     
     c->frame =
@@ -156,7 +162,9 @@
 
    dbg("%s frame created : %i*%i+%i+%i\n", __func__, c->width, c->height + frm_size, c->x, c->y);
 
+#ifndef USE_REALDEAL
     attr.background_pixel = BlackPixel(c->wm->dpy, c->wm->screen);
+#endif
     
     c->title_frame =
        XCreateWindow(c->wm->dpy, c->frame, 0, 0, 
@@ -176,15 +184,34 @@
 void
 main_client_move_resize(Client *c)
 {
+#ifndef USE_REALDEAL
   int offset_south = theme_frame_defined_height_get(c->wm->mbtheme, 
 						    FRAME_MAIN_SOUTH);
   int offset_east  = theme_frame_defined_width_get(c->wm->mbtheme, 
 						   FRAME_MAIN_EAST );
   int offset_west  = theme_frame_defined_width_get(c->wm->mbtheme, 
 						   FRAME_MAIN_WEST );
+#endif
    base_client_move_resize(c);
    //XResizeWindow(c->wm->dpy, c->window, c->width, c->height);
 
+#ifdef USE_REALDEAL
+   XMoveResizeWindow(c->wm->dpy, c->window,
+        0,
+        0,
+        DisplayWidth(c->wm->dpy, c->wm->screen) - vp->sub_x,
+        DisplayHeight(c->wm->dpy, c->wm->screen) - vp->sub_y);
+
+   XResizeWindow(c->wm->dpy, c->title_frame,
+        0,
+        0);
+
+   XMoveResizeWindow(c->wm->dpy, c->frame,
+        vp->pos_x,
+        vp->pos_y,
+        DisplayWidth(c->wm->dpy, c->wm->screen) - vp->sub_x,
+        DisplayHeight(c->wm->dpy, c->wm->screen) - vp->sub_y);
+#else
    XMoveResizeWindow(c->wm->dpy, c->window, 
 		     offset_west, main_client_title_height(c), 
 		     c->width, c->height);
@@ -198,7 +225,7 @@
 		     c->y - main_client_title_height(c), 
 		     c->width + ( offset_east + offset_west),
 		     c->height + main_client_title_height(c) + offset_south);
-
+#endif
 }
 
 void
diff -Naur matchbox-0.5/src/misc.c rdwm/src/misc.c
--- matchbox-0.5/src/misc.c	2003-04-06 21:27:14.000000000 +0200
+++ rdwm/src/misc.c	2003-04-26 21:02:04.000000000 +0200
@@ -80,7 +80,7 @@
 {
     if (e->error_code == BadAccess &&
 	e->resourceid == RootWindow(dpy, DefaultScreen(dpy)) ) {
-        fprintf(stderr, "root window unavailible (maybe another wm is running?)\n");
+        fprintf(stderr, "root window unavailable (maybe another wm is running?)\n");
         exit(1);
     } else {
         char msg[255];
diff -Naur matchbox-0.5/src/rd.h rdwm/src/rd.h
--- matchbox-0.5/src/rd.h	1970-01-01 01:00:00.000000000 +0100
+++ rdwm/src/rd.h	2003-04-26 19:52:21.000000000 +0200
@@ -0,0 +1,21 @@
+#ifndef _RD_H_
+#define _RD_H_
+
+#define USAGE "Usage: wm -pos-x=<int> -pos-y=<int> -sub-x=<int> -sub-y=<int> [-help] [-version]\n"
+
+typedef struct Viewport viewport;
+
+/* These are used to determine where a viewport
+ * should be placed. I've given them some initial
+ * values that should be reasonble  In case something
+ * goes terribly wrong. */
+struct Viewport {
+  int pos_x;
+  int pos_y;
+  int sub_x;
+  int sub_y;
+};
+
+viewport *vp; /* I _know_ it myself. Now wiggle off, yes? -RJS */
+
+#endif
diff -Naur matchbox-0.5/src/select_client.c rdwm/src/select_client.c
--- matchbox-0.5/src/select_client.c	2003-03-14 20:15:08.000000000 +0100
+++ rdwm/src/select_client.c	2003-04-26 22:09:08.000000000 +0200
@@ -163,8 +163,12 @@
 	      select_client_highlight_entry( c, button, c->frame );
 	      break;
 
-	    case XK_Return:
-	    case XK_KP_Enter:
+            /* XXX: These don't do anything but cause
+             * a compiler warning. Maybe have a look
+             * at them or remove completely? -RJS  
+             */
+            /*case XK_Return:
+            case XK_KP_Enter:*/
 	    }
 	  break;
 	case ButtonRelease:
diff -Naur matchbox-0.5/src/wm.c rdwm/src/wm.c
--- matchbox-0.5/src/wm.c	2003-04-13 02:27:49.000000000 +0200
+++ rdwm/src/wm.c	2003-04-26 21:03:24.000000000 +0200
@@ -235,7 +235,9 @@
    rDB = XrmGetFileDatabase(CONFDEFAULTS);   
 
    XrmParseCommand(&cmdlnDB, opTable, opTableEntries, "matchbox", argc, argv); 
+#ifndef USE_REALDEAL
    if (*argc != 1) wm_usage(argv[0]);
+#endif
 
    XrmCombineDatabase(cmdlnDB, &rDB, True);
    
diff -Naur matchbox-0.5/util/mbmenu.c rdwm/util/mbmenu.c
--- matchbox-0.5/util/mbmenu.c	2003-04-05 01:23:37.000000000 +0200
+++ rdwm/util/mbmenu.c	2003-04-26 22:05:07.000000000 +0200
@@ -74,6 +74,14 @@
 
 #define MAX_DISPLAYS 10
 
+/* These are needed to get rid of some two
+ * wierd compiler warnings. Don't ask me why
+ * it doesn't work. I was told userspace should
+ * not include kernel space headers anyway.
+ * (Which is done above with linux/fcntl.h).
+ * -RJS */
+int fcntl(int fd, int cmd, long arg);
+int open(const char *pathname, int flags);
 
 typedef struct _app
 {
@@ -1136,5 +1144,3 @@
 
    return 1;
 }
-
-
diff -Naur matchbox-0.5/util/miniwave.xpm rdwm/util/miniwave.xpm
--- matchbox-0.5/util/miniwave.xpm	2002-08-27 18:00:20.000000000 +0200
+++ rdwm/util/miniwave.xpm	2003-04-26 21:37:06.000000000 +0200
@@ -18,4 +18,5 @@
 "      .   .     ",
 "                ",
 "                ",
-"                "};
\ No newline at end of file
+"                "};
+
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.