swk

static widget kit
git clone git://git.suckless.org/swk
Log | Files | Refs | README | LICENSE

commit 335a9d46c2a40e6c0376446a579a4c0b397088e7
parent 9dd2455fa092b57b1b5033c8289686f607b434d4
Author: pancake <pancake@nopcode.org>
Date:   Tue, 20 Apr 2010 10:32:00 +0200

do not handle modifier-only keycodes
fix key modifier enum
Diffstat:
gi_sdl.c | 32+++++++++++++++++---------------
swk.h | 2+-
2 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/gi_sdl.c b/gi_sdl.c @@ -67,21 +67,23 @@ swk_gi_event(int dowait) { fprintf(stderr, "event: click %d\n", event.button.button); break; case SDL_KEYDOWN: - ret = &ev; - ev.type = EKey; - ev.data.key.keycode = event.key.keysym.unicode; - ev.data.key.modmask = 0; - if(event.key.keysym.mod & KMOD_LCTRL || - event.key.keysym.mod & KMOD_RCTRL) - ev.data.key.modmask |= Ctrl; - if(event.key.keysym.mod & KMOD_LSHIFT|| - event.key.keysym.mod & KMOD_RSHIFT) - ev.data.key.modmask |= Shift; - if(event.key.keysym.mod & KMOD_LMETA || - event.key.keysym.mod & KMOD_RMETA) - ev.data.key.modmask |= Meta; - fprintf(stderr, "event: key %d %d\n", - ev.data.key.modmask, ev.data.key.keycode); + if (ev.data.key.keycode != 0 && event.key.keysym.unicode != 0) { + ret = &ev; + ev.type = EKey; + ev.data.key.keycode = event.key.keysym.unicode; + ev.data.key.modmask = 0; + if(event.key.keysym.mod & KMOD_LCTRL || + event.key.keysym.mod & KMOD_RCTRL) + ev.data.key.modmask |= Ctrl; + if(event.key.keysym.mod & KMOD_LSHIFT|| + event.key.keysym.mod & KMOD_RSHIFT) + ev.data.key.modmask |= Shift; + if(event.key.keysym.mod & KMOD_LMETA || + event.key.keysym.mod & KMOD_RMETA) + ev.data.key.modmask |= Meta; + fprintf(stderr, "event: key %d %d\n", + ev.data.key.modmask, ev.data.key.keycode); + } break; case SDL_QUIT: fprintf(stderr, "event: quit\n"); diff --git a/swk.h b/swk.h @@ -2,7 +2,7 @@ #define SWK_NEWLINE .h=-1, .w=-1 typedef enum { EVoid, EClick, EMotion, EKey, EExpose, EQuit, ELast } SwkEventType; -typedef enum { Ctrl=1, Meta=2, Shift=4 } SwkKeyMod; +typedef enum { Shift=1, Ctrl=2, Meta=4 } SwkKeyMod; typedef struct SwkBox SwkBox;