diff --git a/dat.h b/dat.h index 6db751f..3bbcff0 100644 --- a/dat.h +++ b/dat.h @@ -28,6 +28,7 @@ enum Maxclients = 64, Maxkouho = 32, Maxdisp = 9, + Wlkeymax = 0x300, Imgw = (Maxrunes + 3) * Fontsz, Imgh = (Maxdisp + 1) * Fontsz, @@ -43,6 +44,17 @@ struct Str int n; }; +typedef struct Wlstate Wlstate; +struct Wlstate +{ + uchar down[Wlkeymax]; + u32int repeatkey; + uvlong repeatat; + int rate; + int delay; + int repeating; +}; + typedef struct Emit Emit; struct Emit { diff --git a/fn.h b/fn.h index 68dc10f..5d56113 100644 --- a/fn.h +++ b/fn.h @@ -28,6 +28,8 @@ void dictthread(void*); void dictlookup(Dictreq*, Dictres*); void drawthread(void*); +int popupcells(Rune*, int); +void popupposition(Caret*, int, int, int, int, int, int, int*, int*); void imthread(void*); Emit transmap(Im*, Rune); Emit transko(Im*, Rune); @@ -41,6 +43,14 @@ int srvreadkey(int, Keyreq*); void srvthread(void*); void ibusthread(void*); void waylandthread(void*); +void wlstateinit(Wlstate*); +int wlstatepress(Wlstate*, u32int, int, int, uvlong); +int wlstaterelease(Wlstate*, u32int); +void wlstaterepeatinfo(Wlstate*, int, int); +void wlstatecancelrepeat(Wlstate*); +void wlstateclear(Wlstate*); +int wlstatetimeout(Wlstate*, uvlong); +int wlstaterepeat(Wlstate*, uvlong, u32int*); void* emalloc(ulong); void* erealloc(void*, ulong); diff --git a/popup_layout.c b/popup_layout.c index 7c85bdf..c4d6d4b 100644 --- a/popup_layout.c +++ b/popup_layout.c @@ -1,5 +1,5 @@ #include "dat.h" -#include "popup_layout.h" +#include "fn.h" int popupcells(Rune *r, int n) diff --git a/popup_layout.h b/popup_layout.h deleted file mode 100644 index c41e660..0000000 --- a/popup_layout.h +++ /dev/null @@ -1,7 +0,0 @@ -#ifndef STRANS_POPUP_LAYOUT_H -#define STRANS_POPUP_LAYOUT_H - -int popupcells(Rune*, int); -void popupposition(Caret*, int, int, int, int, int, int, int*, int*); - -#endif diff --git a/tests/popup_test.c b/tests/popup_test.c index 442d87d..a343dd0 100644 --- a/tests/popup_test.c +++ b/tests/popup_test.c @@ -1,5 +1,4 @@ #include "test.h" -#include "../popup_layout.h" void popup_layout(struct ct *t) diff --git a/tests/wayland_test.c b/tests/wayland_test.c index 35109cf..1e52299 100644 --- a/tests/wayland_test.c +++ b/tests/wayland_test.c @@ -1,5 +1,4 @@ #include "test.h" -#include "../wayland_state.h" void wayland_press_release_state(struct ct *t) diff --git a/tests/xim_test.c b/tests/xim_test.c index 17ea467..2fa8ce8 100644 --- a/tests/xim_test.c +++ b/tests/xim_test.c @@ -5,8 +5,10 @@ #include #include #include -#include "../xim/keymap.h" -#include "../xim/ximtext.h" + +uint32_t keymaplookup(const uint32_t*, int, uint16_t); +char *ximcompound(const char*, size_t, size_t*); +char *ximutf8compound(const char*, size_t, size_t*); enum { diff --git a/wayland.c b/wayland.c index 9cd5c4f..a29ac10 100644 --- a/wayland.c +++ b/wayland.c @@ -1,6 +1,5 @@ #include "dat.h" #include "fn.h" -#include "wayland_state.h" #include #include diff --git a/wayland_state.c b/wayland_state.c index 9849637..cc66308 100644 --- a/wayland_state.c +++ b/wayland_state.c @@ -1,4 +1,5 @@ -#include "wayland_state.h" +#include "dat.h" +#include "fn.h" #include #include @@ -39,10 +40,9 @@ wlstaterepeatinfo(Wlstate *s, int rate, int delay) } int -wlstatepress(Wlstate *s, uint32_t key, int eaten, int repeatable, - uint64_t now) +wlstatepress(Wlstate *s, u32int key, int eaten, int repeatable, uvlong now) { - uint64_t delay; + uvlong delay; if(key >= Wlkeymax) return 0; @@ -50,8 +50,8 @@ wlstatepress(Wlstate *s, uint32_t key, int eaten, int repeatable, wlstatecancelrepeat(s); if(eaten && repeatable && s->rate > 0){ delay = s->delay; - if(UINT64_MAX - now < delay) - s->repeatat = UINT64_MAX; + if(~(uvlong)0 - now < delay) + s->repeatat = ~(uvlong)0; else s->repeatat = now + delay; s->repeatkey = key; @@ -61,7 +61,7 @@ wlstatepress(Wlstate *s, uint32_t key, int eaten, int repeatable, } int -wlstaterelease(Wlstate *s, uint32_t key) +wlstaterelease(Wlstate *s, u32int key) { int forward; @@ -75,9 +75,9 @@ wlstaterelease(Wlstate *s, uint32_t key) } int -wlstatetimeout(Wlstate *s, uint64_t now) +wlstatetimeout(Wlstate *s, uvlong now) { - uint64_t d; + uvlong d; if(!s->repeating) return -1; @@ -88,9 +88,9 @@ wlstatetimeout(Wlstate *s, uint64_t now) } int -wlstaterepeat(Wlstate *s, uint64_t now, uint32_t *key) +wlstaterepeat(Wlstate *s, uvlong now, u32int *key) { - uint64_t step; + uvlong step; if(!s->repeating || now < s->repeatat) return 0; @@ -99,8 +99,8 @@ wlstaterepeat(Wlstate *s, uint64_t now, uint32_t *key) step = 1000 / s->rate; if(step == 0) step = 1; - if(UINT64_MAX - now < step) - s->repeatat = UINT64_MAX; + if(~(uvlong)0 - now < step) + s->repeatat = ~(uvlong)0; else s->repeatat = now + step; return 1; diff --git a/wayland_state.h b/wayland_state.h deleted file mode 100644 index 9102d06..0000000 --- a/wayland_state.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef WAYLAND_STATE_H -#define WAYLAND_STATE_H - -#include - -enum { - /* Wayland key codes are Linux input-event codes. */ - Wlkeymax = 0x300, -}; - -typedef struct Wlstate Wlstate; -struct Wlstate -{ - unsigned char down[Wlkeymax]; - uint32_t repeatkey; - uint64_t repeatat; - int rate; - int delay; - int repeating; -}; - -void wlstateinit(Wlstate*); -int wlstatepress(Wlstate*, uint32_t, int, int, uint64_t); -int wlstaterelease(Wlstate*, uint32_t); -void wlstaterepeatinfo(Wlstate*, int, int); -void wlstatecancelrepeat(Wlstate*); -void wlstateclear(Wlstate*); -int wlstatetimeout(Wlstate*, uint64_t); -int wlstaterepeat(Wlstate*, uint64_t, uint32_t*); - -#endif diff --git a/win.c b/win.c index 79d6a1c..f65ad38 100644 --- a/win.c +++ b/win.c @@ -1,7 +1,6 @@ #include #include "dat.h" #include "fn.h" -#include "popup_layout.h" enum { Asciitofull = 0xFEE0, diff --git a/xim/Makefile b/xim/Makefile index 953c337..9e25f9e 100644 --- a/xim/Makefile +++ b/xim/Makefile @@ -15,7 +15,7 @@ $(PROG): $(OBJS) ../ipc.c ../ipc.h $(OBJS): ../ipc.h -$(TEST): ../tests/xim_test.c keymap.c keymap.h ximtext.c ximtext.h +$(TEST): ../tests/xim_test.c keymap.c ximtext.c $(CC) $(CFLAGS) -o $@ ../tests/xim_test.c keymap.c ximtext.c $(XIM_LIBS) check: $(TEST) diff --git a/xim/keymap.c b/xim/keymap.c index c11894c..460b100 100644 --- a/xim/keymap.c +++ b/xim/keymap.c @@ -1,5 +1,5 @@ +#include #include -#include "keymap.h" enum { diff --git a/xim/keymap.h b/xim/keymap.h deleted file mode 100644 index 8633237..0000000 --- a/xim/keymap.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef STRANS_XIM_KEYMAP_H -#define STRANS_XIM_KEYMAP_H - -#include - -uint32_t keymaplookup(const uint32_t*, int, uint16_t); - -#endif diff --git a/xim/main.c b/xim/main.c index d6ddbd1..8b7c943 100644 --- a/xim/main.c +++ b/xim/main.c @@ -7,8 +7,9 @@ #include #include #include "ipc.h" -#include "keymap.h" -#include "ximtext.h" + +uint32_t keymaplookup(const uint32_t*, int, uint16_t); +char *ximcompound(const char*, size_t, size_t*); typedef struct Ic Ic; struct Ic diff --git a/xim/ximtext.c b/xim/ximtext.c index f6087b5..366cc78 100644 --- a/xim/ximtext.c +++ b/xim/ximtext.c @@ -2,7 +2,6 @@ #include #include #include -#include "ximtext.h" char* ximutf8compound(const char *s, size_t len, size_t *outlen) diff --git a/xim/ximtext.h b/xim/ximtext.h deleted file mode 100644 index 4f1ed4b..0000000 --- a/xim/ximtext.h +++ /dev/null @@ -1,4 +0,0 @@ -#include - -char *ximcompound(const char*, size_t, size_t*); -char *ximutf8compound(const char*, size_t, size_t*);