[hackers] [swk] added specific config.h for n900 (landscape/portrait) || pancake

From: <hg_AT_suckless.org>
Date: Thu, 6 May 2010 23:16:46 +0000 (UTC)

changeset: 35:5e6ee70ffcd5
tag: tip
user: pancake <pancake_AT_nopcode.org>
date: Fri May 07 01:10:33 2010 +0200
files: config.def.h config.n900.h gi_sdl.c test.c
description:
added specific config.h for n900 (landscape/portrait)
workaround for touchscreens (report wrong click x,y)
small performance trick for scrolling
fix keyboard input in n900
remove the ugly performance trick
fix layout of 'about' panel in test program

diff -r c6a17f2bc350 -r 5e6ee70ffcd5 config.def.h
--- a/config.def.h Fri May 07 00:59:57 2010 +0200
+++ b/config.def.h Fri May 07 01:10:33 2010 +0200
@@ -5,6 +5,7 @@
 #define FONTBOLD 0
 #define WINWIDTH 640
 #define WINHEIGHT 480
+#define TOUCHSCREEN 0
 // SDL
 #define SWK_COLOR(r,g,b) 0x##r,0x##g,0x##b
 // X11
diff -r c6a17f2bc350 -r 5e6ee70ffcd5 config.n900.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/config.n900.h Fri May 07 01:10:33 2010 +0200
@@ -0,0 +1,48 @@
+#define PORTRAIT 0
+
+#define FONTBOLD 1
+#define FONTSIZE 32
+#define TOUCHSCREEN 1
+
+#if PORTRAIT
+//#define WINWIDTH 480
+//#define WINHEIGHT 750
+#else
+// LANDSCAPE
+#define WINWIDTH 800
+#define WINHEIGHT 400
+#endif
+
+/* appearance */
+// SDL
+#define SWK_COLOR(r,g,b) 0x##r,0x##g,0x##b
+// X11
+//#define SWK_COLOR(r,g,b) r##g##b
+
+#define HICOLOR SWK_COLOR(0,66,ff)
+#define FGCOLOR SWK_COLOR(e0,e0,e0)
+#define BGCOLOR SWK_COLOR(00,00,00)
+#define TFCOLOR SWK_COLOR(cc,cc,cc)
+
+/* key bindings */
+static SwkKeyBind keys[] = {
+ { Ctrl, 'j', swk_focus_next },
+ { Ctrl, 'k', swk_focus_prev },
+ { Ctrl, 8 , swk_focus_first },
+ { Ctrl, 9 , swk_focus_prev },
+ { 0 , 9 , swk_focus_next },
+ { Ctrl, 10 , swk_focus_next },
+ { Ctrl, 11 , swk_focus_prev },
+ { Ctrl, 12 , swk_focus_activate },
+ { 0, 225, swk_focus_activate }, // n900 enter
+ { 0 , KUp, swk_focus_prev },
+ { 0 , KDown, swk_focus_next },
+ { 0 , 13 , swk_focus_activate },
+ { Ctrl, 12 , swk_focus_activate },
+ { Ctrl|Shift, 10, swk_scroll_down },
+ { Ctrl|Shift, 11, swk_scroll_up },
+ { Ctrl, '+', swk_fontsize_increase },
+ { Ctrl, '-', swk_fontsize_decrease },
+ { 0 }
+};
+
diff -r c6a17f2bc350 -r 5e6ee70ffcd5 gi_sdl.c
--- a/gi_sdl.c Fri May 07 00:59:57 2010 +0200
+++ b/gi_sdl.c Fri May 07 01:10:33 2010 +0200
@@ -132,7 +132,10 @@
                 ret->data.expose.w = ret->data.expose.h = 0;
                 break;
         case SDL_MOUSEMOTION:
+ //fprintf(stderr, "event: motion (%d,%d)\n", event.motion.x,event.motion.y);
                 if(mousedown) {
+ if(mousedowny==-1) // touchscreen trick
+ mousedowny = event.motion.y;
                         if(event.motion.y>mousedowny+fs) {
                                 mousedowny = event.motion.y;
                                 swk_scroll_up(w);
@@ -153,9 +156,10 @@
                 }
                 break;
         case SDL_MOUSEBUTTONUP:
+ //fprintf(stderr, "event: up %d (%d,%d)\n", event.button.button,event.button.x,event.button.y);
+
                 mousedown = 0;
                 if(!mousemoved) {
- fprintf(stderr, "event: click %d\n", event.button.button);
                         ret->type = EClick;
                         ret->data.click.button = event.button.button;
                         ret->data.click.point.x = event.button.x / fs;
@@ -163,9 +167,10 @@
                 }
                 break;
         case SDL_MOUSEBUTTONDOWN:
+ //fprintf(stderr, "event: down %d (%d,%d)\n", event.button.button,event.button.x,event.button.y);
                 mousemoved = 0;
                 mousedown = 1;
- mousedowny = event.button.y;
+ mousedowny = TOUCHSCREEN?-1:event.button.y;
                 break;
         case SDL_KEYDOWN:
                 ret->data.key.modmask = 0;
@@ -178,10 +183,10 @@
                         ret->data.key.modmask |= Alt;
                 if(event.key.keysym.mod & KMOD_META)
                         ret->data.key.modmask |= Meta;
+ fprintf(stderr, "event: key %d %d\n",
+ ret->data.key.modmask, ret->data.key.keycode);
                 if(ret->data.key.keycode != 0 && event.key.keysym.unicode != 0) {
                         ret->data.key.keycode = event.key.keysym.unicode;
- fprintf(stderr, "event: key %d %d\n",
- ret->data.key.modmask, ret->data.key.keycode);
                 } else {
                         // TODO key aliases defined in config.h
                         switch((int)event.key.keysym.sym) {
@@ -194,7 +199,7 @@
                                 ret->data.key.keycode = KDown;
                                 break;
                         default:
- ret->type = -1;
+ ret->data.key.keycode = event.key.keysym.sym;
                                 break;
                         }
                 }
diff -r c6a17f2bc350 -r 5e6ee70ffcd5 test.c
--- a/test.c Fri May 07 00:59:57 2010 +0200
+++ b/test.c Fri May 07 01:10:33 2010 +0200
@@ -44,7 +44,8 @@
         { .cb=swk_label, .text="About this program...", },
         SWK_BOX_NEWLINE(1),
         { .cb=swk_separator },
- SWK_BOX_NEWLINE(2),
+ SWK_BOX_NEWLINE(-1),
+ //SWK_BOX_NEWLINE(2),
         { .cb=swk_label, .text="This is a test program for swk" },
         SWK_BOX_NEWLINE(1),
         { .cb=swk_label, .text=" ... a simple widget kit " },
@@ -52,11 +53,10 @@
         { .cb=swk_label, .text=" ... from the suckless.org project" },
         SWK_BOX_NEWLINE(2),
         { .cb=swk_progress, .text="0%", },
- SWK_BOX_NEWLINE(1),
+ SWK_BOX_NEWLINE(2),
         { .cb=swk_filler },
         { .cb=myprogressbutton, .text="next", },
         { .cb=swk_filler },
- SWK_BOX_NEWLINE(-1),
         //SWK_BOX_NEWLINE(3),
         { .cb=swk_filler },
         { .cb=mybutton_about_ok, .text="Ok" },
Received on Thu May 06 2010 - 23:16:46 UTC

This archive was generated by hypermail 2.2.0 : Thu May 06 2010 - 23:24:03 UTC