Hello comrades,

since we all know, that hg is crap, here the global merged patch
as one single blob.

I thought about the make system. Instead of having the ugly pre-
processor directive does svkbd now cp the layouts to layout.h
and compile using the new content.


Sincerely,

Christoph Lohmann
# HG changeset patch
# User Christoph Lohmann <[email protected]>
# Date 1300996930 -3600
# Node ID b49d35af54a97c663bec7971f5a0335ba0c34e8a
# Parent  58847cd1416dc95e4564c0100645452955a0e38a
Multiple changes for making svkbd more touch friendly.

diff -r 58847cd1416d -r b49d35af54a9 Makefile
--- a/Makefile  Tue Feb 01 20:04:02 2011 +0100
+++ b/Makefile  Thu Mar 24 21:02:10 2011 +0100
@@ -6,17 +6,18 @@
 SRC = svkbd.c
 OBJ = ${SRC:.c=.o}
 
-all: options svkbd
+all: options layout.h svkbd-${LAYOUT}
 
 options:
        @echo svkbd build options:
        @echo "CFLAGS   = ${CFLAGS}"
        @echo "LDFLAGS  = ${LDFLAGS}"
        @echo "CC       = ${CC}"
+       @echo "LAYOUT   = ${LAYOUT}"
 
 .c.o:
        @echo CC $<
-       @${CC} -c ${CFLAGS} $<
+       @${CC} ${CPPFLAGS} -c ${CFLAGS} $<
 
 ${OBJ}: config.h config.mk
 
@@ -24,19 +25,23 @@
        @echo creating $@ from config.def.h
        @cp config.def.h $@
 
-svkbd: ${OBJ}
+layout.h:
+       @echo creating $@ from ${LAYOUT} layout in layouts folder.
+       @cp layouts/${LAYOUT}.h layout.h
+
+svkbd-${LAYOUT}: ${OBJ}
        @echo CC -o $@
        @${CC} -o $@ ${OBJ} ${LDFLAGS}
 
 clean:
        @echo cleaning
-       @rm -f svkbd ${OBJ} svkbd-${VERSION}.tar.gz
+       @rm -f svkbd-* *.o svkbd-${VERSION}.tar.gz
 
 dist: clean
        @echo creating dist tarball
        @mkdir -p svkbd-${VERSION}
        @cp -R LICENSE Makefile README config.def.h config.mk \
-               ${SRC} svkbd-${VERSION}
+               ${SRC} layouts layout.h svkbd-${VERSION}
        @tar -cf svkbd-${VERSION}.tar svkbd-${VERSION}
        @gzip svkbd-${VERSION}.tar
        @rm -rf svkbd-${VERSION}
@@ -44,8 +49,8 @@
 install: all
        @echo installing executable file to ${DESTDIR}${PREFIX}/bin
        @mkdir -p ${DESTDIR}${PREFIX}/bin
-       @cp -f svkbd ${DESTDIR}${PREFIX}/bin
-       @chmod 755 ${DESTDIR}${PREFIX}/bin/svkbd
+       @cp -f svkbd-* ${DESTDIR}${PREFIX}/bin
+       @chmod 755 ${DESTDIR}${PREFIX}/bin/svkbd-*
        @echo installing manual page to ${DESTDIR}${MANPREFIX}/man1
        @mkdir -p ${DESTDIR}${MANPREFIX}/man1
 #      @sed "s/VERSION/${VERSION}/g" < svkbd.1 > 
${DESTDIR}${MANPREFIX}/man1/svkbd.1
@@ -53,8 +58,8 @@
 
 uninstall:
        @echo removing executable file from ${DESTDIR}${PREFIX}/bin
-       @rm -f ${DESTDIR}${PREFIX}/bin/svkbd
+       @rm -f ${DESTDIR}${PREFIX}/bin/svkbd-*
 #      @echo removing manual page from ${DESTDIR}${MANPREFIX}/man1
 #      @rm -f ${DESTDIR}${MANPREFIX}/man1/svkbd.1
 
-.PHONY: all options clean dist install uninstall
+.PHONY: all options clean dist install uninstall layout.h
diff -r 58847cd1416d -r b49d35af54a9 config.def.h
--- a/config.def.h      Tue Feb 01 20:04:02 2011 +0100
+++ b/config.def.h      Thu Mar 24 21:02:10 2011 +0100
@@ -6,71 +6,5 @@
 static const char pressbgcolor[]    = "#0000cc";
 static const char pressfgcolor[]    = "#ffffff";
 
-static Key keys[] = {
-       { "1!", XK_1, 1 },
-       { "2@", XK_2, 1 },
-       { "3#", XK_3, 1 },
-       { "4$", XK_4, 1 },
-       { "5%", XK_5, 1 },
-       { "6^", XK_6, 1 },
-       { "7&", XK_7, 1 },
-       { "8*", XK_8, 1 },
-       { "9(", XK_9, 1 },
-       { "0)", XK_0, 1 },
-       { "-_", XK_minus, 1 },
-       { "=+", XK_plus, 1 },
-       { "<-", XK_BackSpace, 2 },
-       { 0 }, /* New row */
-       { "->|", XK_Tab, 1 },
-       { 0, XK_q, 1 },
-       { 0, XK_w, 1 },
-       { 0, XK_e, 1 },
-       { 0, XK_r, 1 },
-       { 0, XK_t, 1 },
-       { 0, XK_y, 1 },
-       { 0, XK_u, 1 },
-       { 0, XK_i, 1 },
-       { 0, XK_o, 1 },
-       { 0, XK_p, 1 },
-       { "[", XK_bracketleft, 1 },
-       { "]", XK_bracketright, 1 },
-       { "Return", XK_Return, 3 },
-       { 0 }, /* New row */
-       { 0, XK_Caps_Lock, 2 },
-       { 0, XK_a, 1 },
-       { 0, XK_s, 1 },
-       { 0, XK_d, 1 },
-       { 0, XK_f, 1 },
-       { 0, XK_g, 1 },
-       { 0, XK_h, 1 },
-       { 0, XK_j, 1 },
-       { 0, XK_k, 1 },
-       { 0, XK_l, 1 },
-       { ":;", XK_semicolon, 1 },
-       { "'\"", XK_exclam, 1 },
-       { "\\|", XK_backslash, 1 },
-       { 0 }, /* New row */
-       { 0, XK_Shift_L, 3 },
-       { 0, XK_z, 1 },
-       { 0, XK_x, 1 },
-       { 0, XK_c, 1 },
-       { 0, XK_v, 1 },
-       { 0, XK_b, 1 },
-       { 0, XK_n, 1 },
-       { 0, XK_m, 1 },
-       { ",", XK_colon, 1 },
-       { ".", XK_period, 1 },
-       { "/?", XK_slash, 1 },
-       { 0, XK_Shift_R, 2 },
-       { 0 }, /* New row */
-       { "Ctrl", XK_Control_L, 2 },
-       { "Alt", XK_Alt_L, 2 },
-       { "", XK_space, 5 },
-       { "Alt", XK_Alt_R, 2 },
-       { "Ctrl", XK_Control_R, 2 },
-};
+#include "layout.h"
 
-Buttonmod buttonmods[] = {
-       { XK_Shift_L, Button2 },
-       { XK_Alt_L, Button3 },
-};
diff -r 58847cd1416d -r b49d35af54a9 config.mk
--- a/config.mk Tue Feb 01 20:04:02 2011 +0100
+++ b/config.mk Thu Mar 24 21:02:10 2011 +0100
@@ -1,10 +1,12 @@
 # svkbd version
 VERSION = 0.1
 
+LAYOUT ?= default
+
 # Customize below to fit your system
 
 # paths
-PREFIX = /usr/local
+PREFIX ?= /usr/local
 MANPREFIX = ${PREFIX}/share/man
 
 X11INC = /usr/X11R6/include
@@ -15,7 +17,8 @@
 LIBS = -L/usr/lib -lc -L${X11LIB} -lX11 -lXtst
 
 # flags
-CPPFLAGS = -DVERSION=\"${VERSION}\" ${XINERAMAFLAGS}
+CPPFLAGS = -DVERSION=\"${VERSION}\" \
+          ${XINERAMAFLAGS}
 CFLAGS = -g -std=c99 -pedantic -Wall -Os ${INCS} ${CPPFLAGS}
 LDFLAGS = -g ${LIBS}
 
@@ -25,3 +28,4 @@
 
 # compiler and linker
 CC = cc
+
diff -r 58847cd1416d -r b49d35af54a9 layout.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/layout.h  Thu Mar 24 21:02:10 2011 +0100
@@ -0,0 +1,74 @@
+static int wh = 200;
+static int ww = 0;
+static int wx = 0;
+static int wy = -200;
+
+static Key keys[] = {
+       { "1!", XK_1, 1 },
+       { "2@", XK_2, 1 },
+       { "3#", XK_3, 1 },
+       { "4$", XK_4, 1 },
+       { "5%", XK_5, 1 },
+       { "6^", XK_6, 1 },
+       { "7&", XK_7, 1 },
+       { "8*", XK_8, 1 },
+       { "9(", XK_9, 1 },
+       { "0)", XK_0, 1 },
+       { "-_", XK_minus, 1 },
+       { "=+", XK_plus, 1 },
+       { "<-", XK_BackSpace, 2 },
+       { 0 }, /* New row */
+       { "->|", XK_Tab, 1 },
+       { 0, XK_q, 1 },
+       { 0, XK_w, 1 },
+       { 0, XK_e, 1 },
+       { 0, XK_r, 1 },
+       { 0, XK_t, 1 },
+       { 0, XK_y, 1 },
+       { 0, XK_u, 1 },
+       { 0, XK_i, 1 },
+       { 0, XK_o, 1 },
+       { 0, XK_p, 1 },
+       { "[", XK_bracketleft, 1 },
+       { "]", XK_bracketright, 1 },
+       { "Return", XK_Return, 3 },
+       { 0 }, /* New row */
+       { 0, XK_Caps_Lock, 2 },
+       { 0, XK_a, 1 },
+       { 0, XK_s, 1 },
+       { 0, XK_d, 1 },
+       { 0, XK_f, 1 },
+       { 0, XK_g, 1 },
+       { 0, XK_h, 1 },
+       { 0, XK_j, 1 },
+       { 0, XK_k, 1 },
+       { 0, XK_l, 1 },
+       { ":;", XK_semicolon, 1 },
+       { "'\"", XK_exclam, 1 },
+       { "\\|", XK_backslash, 1 },
+       { 0 }, /* New row */
+       { 0, XK_Shift_L, 3 },
+       { 0, XK_z, 1 },
+       { 0, XK_x, 1 },
+       { 0, XK_c, 1 },
+       { 0, XK_v, 1 },
+       { 0, XK_b, 1 },
+       { 0, XK_n, 1 },
+       { 0, XK_m, 1 },
+       { ",", XK_colon, 1 },
+       { ".", XK_period, 1 },
+       { "/?", XK_slash, 1 },
+       { 0, XK_Shift_R, 2 },
+       { 0 }, /* New row */
+       { "Ctrl", XK_Control_L, 2 },
+       { "Alt", XK_Alt_L, 2 },
+       { "", XK_space, 5 },
+       { "Alt", XK_Alt_R, 2 },
+       { "Ctrl", XK_Control_R, 2 },
+};
+
+Buttonmod buttonmods[] = {
+       { XK_Shift_L, Button2 },
+       { XK_Alt_L, Button3 },
+};
+
diff -r 58847cd1416d -r b49d35af54a9 layouts/arrows.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/layouts/arrows.h  Thu Mar 24 21:02:10 2011 +0100
@@ -0,0 +1,20 @@
+
+static int wh = 30;
+static int ww = 0;
+static int wx = 0;
+static int wy = -30;
+
+static Key keys[] = {
+       { 0, XK_Shift_L, 2 },
+       { "←", XK_Left, 1 },
+       { "↓", XK_Down, 1 },
+       { "↑", XK_Up, 1 },
+       { "→", XK_Right, 1},
+       { "Alt", XK_Alt_L, 2 },
+};
+
+Buttonmod buttonmods[] = {
+       { XK_Shift_L, Button2 },
+       { XK_Alt_L, Button3 },
+};
+
diff -r 58847cd1416d -r b49d35af54a9 layouts/de.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/layouts/de.h      Thu Mar 24 21:02:10 2011 +0100
@@ -0,0 +1,78 @@
+static int wh = 200;
+static int ww = 0;
+static int wx = 0;
+static int wy = -200;
+
+static Key keys[] = {
+       { "^°′", XK_dead_circumflex, 1},
+       { "1!¹", XK_1, 1 },
+       { "2\"²", XK_2, 1 },
+       { "3§³", XK_3, 1 },
+       { "4$¼", XK_4, 1 },
+       { "5%½", XK_5, 1 },
+       { "6&¬", XK_6, 1 },
+       { "7/{", XK_7, 1 },
+       { "8([", XK_8, 1 },
+       { "9)]", XK_9, 1 },
+       { "0=}", XK_0, 1 },
+       { "ß?\\", XK_ssharp, 1 },
+       { "´`¸", XK_dead_acute, 1 },
+       { "<-", XK_BackSpace, 2 },
+       { 0 }, /* New row */
+       { "->|", XK_Tab, 1 },
+       { "qQ@", XK_q, 1 },
+       { "wWł", XK_w, 1 },
+       { "eE€", XK_e, 1 },
+       { "rR¶", XK_r, 1 },
+       { "tTŧ", XK_t, 1 },
+       { "zZ←", XK_z, 1 },
+       { "uU↓", XK_u, 1 },
+       { "iI→", XK_i, 1 },
+       { "oOø", XK_o, 1 },
+       { "pPþ", XK_p, 1 },
+       { "üܨ", 0xfc, 1 },
+       { "+*~", XK_plus, 1 },
+       { "Return", XK_Return, 3 },
+       { 0 }, /* New row */
+       { 0, XK_Caps_Lock, 2 },
+       { "aAæ", XK_a, 1 },
+       { "sSÅ¿", XK_s, 1 },
+       { "dDð", XK_d, 1 },
+       { "fFđ", XK_f, 1 },
+       { "gGŋ", XK_g, 1 },
+       { "hHħ", XK_h, 1 },
+       { "jJ̣̣", XK_j, 1 },
+       { "kKĸ", XK_k, 1 },
+       { "lLł", XK_l, 1 },
+       { "öÖ˝", 0xf6, 1 },
+       { "äÄ^", 0xe4, 1 },
+       { "#'’", XK_numbersign, 1 },
+       { 0 }, /* New row */
+       { 0, XK_Shift_L, 2 },
+       { "<>|", XK_less, 1 },
+       { "yY»", XK_y, 1 },
+       { "xX«", XK_x, 1 },
+       { "cC¢", XK_c, 1 },
+       { "vV„", XK_v, 1 },
+       { "bB“", XK_b, 1 },
+       { "nN”", XK_n, 1 },
+       { "mMµ", XK_m, 1 },
+       { ",;·", XK_comma, 1 },
+       { ".:…", XK_period, 1 },
+       { "-_–", XK_minus, 1 },
+       { 0, XK_Shift_R, 2 },
+       { 0 }, /* New row */
+       { "Ctrl", XK_Control_L, 2 },
+       { "Win", XK_Super_L, 2 },
+       { "Alt", XK_Alt_L, 2 },
+       { "", XK_space, 5 },
+       { "Alt Gr", XK_ISO_Level3_Shift, 2 },
+       { "Menu", XK_Menu, 2 },
+       { "Ctrl", XK_Control_R, 2 },
+};
+
+Buttonmod buttonmods[] = {
+       { XK_Shift_L, Button2 },
+       { XK_Alt_L, Button3 },
+};
+
diff -r 58847cd1416d -r b49d35af54a9 layouts/default.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/layouts/default.h Thu Mar 24 21:02:10 2011 +0100
@@ -0,0 +1,74 @@
+static int wh = 200;
+static int ww = 0;
+static int wx = 0;
+static int wy = -200;
+
+static Key keys[] = {
+       { "1!", XK_1, 1 },
+       { "2@", XK_2, 1 },
+       { "3#", XK_3, 1 },
+       { "4$", XK_4, 1 },
+       { "5%", XK_5, 1 },
+       { "6^", XK_6, 1 },
+       { "7&", XK_7, 1 },
+       { "8*", XK_8, 1 },
+       { "9(", XK_9, 1 },
+       { "0)", XK_0, 1 },
+       { "-_", XK_minus, 1 },
+       { "=+", XK_plus, 1 },
+       { "<-", XK_BackSpace, 2 },
+       { 0 }, /* New row */
+       { "->|", XK_Tab, 1 },
+       { 0, XK_q, 1 },
+       { 0, XK_w, 1 },
+       { 0, XK_e, 1 },
+       { 0, XK_r, 1 },
+       { 0, XK_t, 1 },
+       { 0, XK_y, 1 },
+       { 0, XK_u, 1 },
+       { 0, XK_i, 1 },
+       { 0, XK_o, 1 },
+       { 0, XK_p, 1 },
+       { "[", XK_bracketleft, 1 },
+       { "]", XK_bracketright, 1 },
+       { "Return", XK_Return, 3 },
+       { 0 }, /* New row */
+       { 0, XK_Caps_Lock, 2 },
+       { 0, XK_a, 1 },
+       { 0, XK_s, 1 },
+       { 0, XK_d, 1 },
+       { 0, XK_f, 1 },
+       { 0, XK_g, 1 },
+       { 0, XK_h, 1 },
+       { 0, XK_j, 1 },
+       { 0, XK_k, 1 },
+       { 0, XK_l, 1 },
+       { ":;", XK_semicolon, 1 },
+       { "'\"", XK_exclam, 1 },
+       { "\\|", XK_backslash, 1 },
+       { 0 }, /* New row */
+       { 0, XK_Shift_L, 3 },
+       { 0, XK_z, 1 },
+       { 0, XK_x, 1 },
+       { 0, XK_c, 1 },
+       { 0, XK_v, 1 },
+       { 0, XK_b, 1 },
+       { 0, XK_n, 1 },
+       { 0, XK_m, 1 },
+       { ",", XK_colon, 1 },
+       { ".", XK_period, 1 },
+       { "/?", XK_slash, 1 },
+       { 0, XK_Shift_R, 2 },
+       { 0 }, /* New row */
+       { "Ctrl", XK_Control_L, 2 },
+       { "Alt", XK_Alt_L, 2 },
+       { "", XK_space, 5 },
+       { "Alt", XK_Alt_R, 2 },
+       { "Ctrl", XK_Control_R, 2 },
+};
+
+Buttonmod buttonmods[] = {
+       { XK_Shift_L, Button2 },
+       { XK_Alt_L, Button3 },
+};
+
diff -r 58847cd1416d -r b49d35af54a9 svkbd.c
--- a/svkbd.c   Tue Feb 01 20:04:02 2011 +0100
+++ b/svkbd.c   Thu Mar 24 21:02:10 2011 +0100
@@ -75,7 +75,6 @@
 
 /* variables */
 static int screen;
-static int wx, wy, ww, wh;
 static void (*handler[LASTEvent]) (XEvent *) = {
        [ButtonPress] = buttonpress,
        [ButtonRelease] = buttonrelease,
@@ -178,6 +177,8 @@
        XSetForeground(dpy, dc.gc, col[ColBG]);
        XFillRectangles(dpy, dc.drawable, dc.gc, &r, 1);
        XSetForeground(dpy, dc.gc, dc.norm[ColFG]);
+       r.height -= 1;
+       r.width -= 1;
        XDrawRectangles(dpy, dc.drawable, dc.gc, &r, 1);
        XSetForeground(dpy, dc.gc, col[ColFG]);
        if(k->label)
@@ -211,7 +212,7 @@
 Key *
 findkey(int x, int y) {
        int i;
-       
+
        for(i = 0; i < LENGTH(keys); i++)
                if(keys[i].keysym && x > keys[i].x &&
                                x < keys[i].x + keys[i].w &&
@@ -317,10 +318,20 @@
        initfont(font);
 
        /* init appearance */
-       ww = DisplayWidth(dpy, screen);
-       wh = 200;
-       wx = 0;
-       wy = DisplayHeight(dpy, screen) - wh;
+       if (!ww)
+               ww = DisplayWidth(dpy, screen);
+       if (ww < 0)
+               ww = DisplayWidth(dpy, screen) / (ww * -1);
+
+       if (wh < 0)
+               wh = DisplayHeight(dpy, screen) / (wh * -1); 
+
+       if (wy < 0)
+               wy = DisplayHeight(dpy, screen) + wy;
+
+       if (wx < 0)
+               wx = DisplayWidth(dpy, screen) + wx;
+
        dc.norm[ColBG] = getcolor(normbgcolor);
        dc.norm[ColFG] = getcolor(normfgcolor);
        dc.press[ColBG] = getcolor(pressbgcolor);
@@ -401,25 +412,59 @@
                for(x = 0; i < LENGTH(keys) && keys[i].keysym != 0; i++) {
                        keys[i].x = x;
                        keys[i].y = y;
-                       keys[i].w = keys[i].width * (ww - 1) / base;
+                       keys[i].w = keys[i].width * ww / base;
                        if(rows != 1)
                                keys[i].h = h;
                        else
-                               keys[i].h = (wh - 1) - y;
+                               keys[i].h = wh - y;
                        x += keys[i].w;
                }
                if(base != 0)
-                       keys[i - 1].w = (ww - 1) - keys[i - 1].x;
+                       keys[i - 1].w = ww - keys[i - 1].x;
                y += h;
        }
 }
 
+void
+usage(char *argv0) {
+       fprintf(stderr, "usage: %s [-hv] [-wh height] [-ww width] "
+                       "[-wx x position] [-wy y position]\n", argv0);
+       exit(1);
+}
+
 int
 main(int argc, char *argv[]) {
-       if(argc == 2 && !strcmp("-v", argv[1]))
-               die("svkbd-"VERSION", © 2006-2010 svkbd engineers, see LICENSE 
for details\n");
-       else if(argc != 1)
-               die("usage: svkbd [-v]\n");
+       int i;
+
+       for (i = 1; argv[i]; i++) {
+               if(!strcmp(argv[i], "-v")) {
+                       die("svkbd-"VERSION", © 2006-2010 svkbd engineers,"
+                                      " see LICENSE for details\n");
+               }
+               if(!strcmp(argv[i], "-wh")) {
+                       wh = atoi(argv[i+1]);
+                       i++;
+                       continue;
+               }
+               if(!strcmp(argv[i], "-ww")) {
+                       ww = atoi(argv[i+1]);
+                       i++;
+                       continue;
+               }
+               if(!strcmp(argv[i], "-wx")) {
+                       wx = atoi(argv[i+1]);
+                       i++;
+                       continue;
+               }
+               if(!strcmp(argv[i], "-wy")) {
+                       wy = atoi(argv[i+1]);
+                       i++;
+                       continue;
+               }
+               if(!strcmp(argv[i], "-h"))
+                       usage(argv[0]);
+       }
+
        if(!setlocale(LC_CTYPE, "") || !XSupportsLocale())
                fprintf(stderr, "warning: no locale support\n");
        if(!(dpy = XOpenDisplay(0)))

Reply via email to