changeset: 53:8cf583724ae4
tag: tip
user: pancake <pancake_AT_nopcode.org>
date: Fri Jul 02 01:40:54 2010 +0200
files: config.def.h gi_sdl.c gi_x11.c swk.c t/test.c
description:
fix x11 keyboard input (backspace, return)
fix vertical align text in buttons in x11
clean warnings and remove deprecated code
diff -r 7be61cb4fddb -r 8cf583724ae4 config.def.h
--- a/config.def.h Thu Jul 01 21:53:23 2010 +0200
+++ b/config.def.h Fri Jul 02 01:40:54 2010 +0200
@@ -22,10 +22,12 @@
static SwkKeyBind keys[] = {
{ Ctrl, 'j', swk_focus_next },
{ Ctrl, 'k', swk_focus_prev },
+ { Ctrl, 'h' , swk_column_move_left },
+ { Ctrl, 'l', swk_column_move_right },
//{ Ctrl, 8 , swk_focus_first },
//{ Ctrl, 9 , swk_focus_prev },
{ Ctrl, 8 , swk_column_move_left },
- { Ctrl, 12 , swk_column_move_right },
+ { Ctrl, 12 , swk_column_move_right },
{ 0 , 9 , swk_focus_next },
{ Ctrl, 10 , swk_focus_next },
{ Ctrl, 11 , swk_focus_prev },
diff -r 7be61cb4fddb -r 8cf583724ae4 gi_sdl.c
--- a/gi_sdl.c Thu Jul 01 21:53:23 2010 +0200
+++ b/gi_sdl.c Fri Jul 02 01:40:54 2010 +0200
@@ -190,8 +190,8 @@
mousedowny = TOUCHSCREEN?-1:event.button.y;
break;
case SDL_KEYDOWN:
+ ret->type = EKey;
ret->data.key.modmask = 0;
- ret->type = EKey;
if(event.key.keysym.mod & KMOD_CTRL)
ret->data.key.modmask |= Ctrl;
if(event.key.keysym.mod & KMOD_SHIFT)
diff -r 7be61cb4fddb -r 8cf583724ae4 gi_x11.c
--- a/gi_x11.c Thu Jul 01 21:53:23 2010 +0200
+++ b/gi_x11.c Fri Jul 02 01:40:54 2010 +0200
@@ -1,6 +1,7 @@
/* See LICENSE file for copyright and license details. */
#define _BSD_SOURCE // strdup
#include <stdio.h>
+#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <locale.h>
@@ -12,13 +13,10 @@
#include "config.h"
#define FONTNAME "-*-*-medium-*-*-*-14-*-*-*-*-*-*-*"
-#define FONTFACTOR 2 /* XXX */
static Drawable drawable;
-static GC gc;
static int fs = FONTSIZE; // TODO: we need fsW and fsH
static Window window;
-static XFontSet set;
static int screen;
static Display *display = NULL;
static int has_event = 0;
@@ -38,7 +36,7 @@
if(first) {
first = 0;
display = XOpenDisplay(NULL);
- if (display == NULL) {
+ if(display == NULL) {
fprintf(stderr, "Cannot open display\n");
return 0;
}
@@ -48,7 +46,6 @@
10, 10, w->r.w, w->r.h, 1,
BlackPixel(display, screen),
WhitePixel(display, screen));
- gc = XCreateGC(display, window, 0, NULL);
drawable = XCreatePixmap(display, window, w->r.w, w->r.h, DefaultDepth(display, screen));
XSelectInput(display, window, EVENTMASK);
XMapWindow(display, window);
@@ -90,15 +87,11 @@
if(has_event);
switch(event.type) {
- default: ret = NULL; break;
case Expose:
ret->type = EExpose;
ret->data.expose.x = ret->data.expose.y = \
ret->data.expose.w = ret->data.expose.h = 0;
break;
- case VisibilityNotify:
- printf("visi\n");
- break;
case MotionNotify:
// TODO: move this stuff into swk.c.. shoudlnt be backend dependent
// fprintf(stderr, "event: motion (%d,%d)\n", event.motion.x,event.motion.y);
@@ -150,25 +143,35 @@
mousedowny = event.xbutton.y;
break;
case KeyPress:
- printf ("KEY PRESSED\n");
+ ret->type = EKey;
+ XLookupString(&event.xkey, NULL, 0, &ksym, NULL);
+ printf("ksym=%d\n", (int)ksym);
+ switch(ksym) {
+ case XK_BackSpace:
+ ret->data.key.keycode = 8;
+ break;
+ case XK_Return:
+ ret->data.key.keycode = '\n';
+ break;
+ default:
+ ret->data.key.keycode = ksym;
+ }
ret->data.key.modmask = 0;
- ret->type = EKey;
- //num = XLookupString(&event, buf, sizeof buf, &ksym, NULL);
- XLookupString(&event, NULL, 0, &ksym, NULL);
-printf("ksym=%d\n", ksym);
- ret->data.key.keycode = ksym;
if(event.xkey.state&ShiftMask)
ret->data.key.modmask |= Shift;
if(event.xkey.state&Mod1Mask)
ret->data.key.modmask |= Alt;
if(event.xkey.state&ControlMask)
ret->data.key.modmask |= Ctrl;
- fprintf(stderr, "event: key %d %d\n",
- ret->data.key.modmask, ret->data.key.keycode);
+ fprintf(stderr, "event: key %d %d (%c)\n",
+ ret->data.key.modmask, ret->data.key.keycode, ret->data.key.keycode);
break;
case 0://SDL_QUIT:
ret->type = EQuit;
break;
+ default:
+ ret = NULL;
+ break;
}
has_event = 0;
return ret;
@@ -225,7 +228,7 @@
swk_gi_text(Rect r, const char *text) {
if(!text||!*text)
return;
- XDrawString(display, window, DefaultGC(display, screen), r.x*fs, (1+r.y)*fs, text, strlen (text));
+ XDrawString(display, window, DefaultGC(display, screen), r.x*fs, ((1+r.y)*fs)-3, text, strlen (text));
}
void
diff -r 7be61cb4fddb -r 8cf583724ae4 swk.c
--- a/swk.c Thu Jul 01 21:53:23 2010 +0200
+++ b/swk.c Fri Jul 02 01:40:54 2010 +0200
@@ -235,14 +235,6 @@
break;
}
}
- /* XXX: this must be implemented in app? .. sure */
- if(e->data.key.keycode==27) {
- e->box = e->win->box;
- e->type = EQuit;
- swk_exit(e->win);
- break;
- }
- // send key to focused box
e->box = e->win->box;
if(e->win->box)
e->win->box->cb(e);
@@ -260,7 +252,7 @@
}
break;
case EClick:
- // TODO: do this needs to be in config.h?
+ // TODO: move click events in config.h
switch(e->data.click.button) {
case 4:
swk_scroll_up(e->win);
diff -r 7be61cb4fddb -r 8cf583724ae4 t/test.c
--- a/t/test.c Thu Jul 01 21:53:23 2010 +0200
+++ b/t/test.c Fri Jul 02 01:40:54 2010 +0200
@@ -78,7 +78,7 @@
}
swk_button(e);
}
-//---------
+
static SwkBox scrollwin[] = {
SWK_BOX_NEWLINE(0),
{ .cb=swk_label, .text="Scroll to change value", },
Received on Fri Jul 02 2010 - 01:45:49 CEST
This archive was generated by hypermail 2.2.0 : Fri Jul 02 2010 - 01:48:04 CEST