commit 92b771ba8ef7f036f0e584cf6269508fd2a31cc6
parent 1d3f6757a67d88853336ab72bf0fa711698d744a
Author: pancake <pancake@nopcode.org>
Date: Fri, 7 May 2010 01:10:33 +0200
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
Diffstat:
4 files changed, 62 insertions(+), 8 deletions(-)
diff --git a/config.def.h b/config.def.h
@@ -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 --git a/config.n900.h b/config.n900.h
@@ -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 --git a/gi_sdl.c b/gi_sdl.c
@@ -132,7 +132,10 @@ swk_gi_event(SwkWindow *w, int dowait) {
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 @@ swk_gi_event(SwkWindow *w, int dowait) {
}
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 @@ swk_gi_event(SwkWindow *w, int dowait) {
}
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 @@ swk_gi_event(SwkWindow *w, int dowait) {
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 @@ swk_gi_event(SwkWindow *w, int dowait) {
ret->data.key.keycode = KDown;
break;
default:
- ret->type = -1;
+ ret->data.key.keycode = event.key.keysym.sym;
break;
}
}
diff --git a/test.c b/test.c
@@ -44,7 +44,8 @@ static SwkBox about[] = {
{ .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 @@ static SwkBox about[] = {
{ .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" },