refactor: remove guarded helper headers
This commit is contained in:
12
dat.h
12
dat.h
@@ -28,6 +28,7 @@ enum
|
|||||||
Maxclients = 64,
|
Maxclients = 64,
|
||||||
Maxkouho = 32,
|
Maxkouho = 32,
|
||||||
Maxdisp = 9,
|
Maxdisp = 9,
|
||||||
|
Wlkeymax = 0x300,
|
||||||
Imgw = (Maxrunes + 3) * Fontsz,
|
Imgw = (Maxrunes + 3) * Fontsz,
|
||||||
Imgh = (Maxdisp + 1) * Fontsz,
|
Imgh = (Maxdisp + 1) * Fontsz,
|
||||||
|
|
||||||
@@ -43,6 +44,17 @@ struct Str
|
|||||||
int n;
|
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;
|
typedef struct Emit Emit;
|
||||||
struct Emit
|
struct Emit
|
||||||
{
|
{
|
||||||
|
|||||||
10
fn.h
10
fn.h
@@ -28,6 +28,8 @@ void dictthread(void*);
|
|||||||
void dictlookup(Dictreq*, Dictres*);
|
void dictlookup(Dictreq*, Dictres*);
|
||||||
|
|
||||||
void drawthread(void*);
|
void drawthread(void*);
|
||||||
|
int popupcells(Rune*, int);
|
||||||
|
void popupposition(Caret*, int, int, int, int, int, int, int*, int*);
|
||||||
void imthread(void*);
|
void imthread(void*);
|
||||||
Emit transmap(Im*, Rune);
|
Emit transmap(Im*, Rune);
|
||||||
Emit transko(Im*, Rune);
|
Emit transko(Im*, Rune);
|
||||||
@@ -41,6 +43,14 @@ int srvreadkey(int, Keyreq*);
|
|||||||
void srvthread(void*);
|
void srvthread(void*);
|
||||||
void ibusthread(void*);
|
void ibusthread(void*);
|
||||||
void waylandthread(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* emalloc(ulong);
|
||||||
void* erealloc(void*, ulong);
|
void* erealloc(void*, ulong);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#include "dat.h"
|
#include "dat.h"
|
||||||
#include "popup_layout.h"
|
#include "fn.h"
|
||||||
|
|
||||||
int
|
int
|
||||||
popupcells(Rune *r, int n)
|
popupcells(Rune *r, int n)
|
||||||
|
|||||||
@@ -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
|
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
#include "test.h"
|
#include "test.h"
|
||||||
#include "../popup_layout.h"
|
|
||||||
|
|
||||||
void
|
void
|
||||||
popup_layout(struct ct *t)
|
popup_layout(struct ct *t)
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
#include "test.h"
|
#include "test.h"
|
||||||
#include "../wayland_state.h"
|
|
||||||
|
|
||||||
void
|
void
|
||||||
wayland_press_release_state(struct ct *t)
|
wayland_press_release_state(struct ct *t)
|
||||||
|
|||||||
@@ -5,8 +5,10 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <xcb-imdkit/encoding.h>
|
#include <xcb-imdkit/encoding.h>
|
||||||
#include <xkbcommon/xkbcommon-keysyms.h>
|
#include <xkbcommon/xkbcommon-keysyms.h>
|
||||||
#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
|
enum
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
#include "dat.h"
|
#include "dat.h"
|
||||||
#include "fn.h"
|
#include "fn.h"
|
||||||
#include "wayland_state.h"
|
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <poll.h>
|
#include <poll.h>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#include "wayland_state.h"
|
#include "dat.h"
|
||||||
|
#include "fn.h"
|
||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -39,10 +40,9 @@ wlstaterepeatinfo(Wlstate *s, int rate, int delay)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
wlstatepress(Wlstate *s, uint32_t key, int eaten, int repeatable,
|
wlstatepress(Wlstate *s, u32int key, int eaten, int repeatable, uvlong now)
|
||||||
uint64_t now)
|
|
||||||
{
|
{
|
||||||
uint64_t delay;
|
uvlong delay;
|
||||||
|
|
||||||
if(key >= Wlkeymax)
|
if(key >= Wlkeymax)
|
||||||
return 0;
|
return 0;
|
||||||
@@ -50,8 +50,8 @@ wlstatepress(Wlstate *s, uint32_t key, int eaten, int repeatable,
|
|||||||
wlstatecancelrepeat(s);
|
wlstatecancelrepeat(s);
|
||||||
if(eaten && repeatable && s->rate > 0){
|
if(eaten && repeatable && s->rate > 0){
|
||||||
delay = s->delay;
|
delay = s->delay;
|
||||||
if(UINT64_MAX - now < delay)
|
if(~(uvlong)0 - now < delay)
|
||||||
s->repeatat = UINT64_MAX;
|
s->repeatat = ~(uvlong)0;
|
||||||
else
|
else
|
||||||
s->repeatat = now + delay;
|
s->repeatat = now + delay;
|
||||||
s->repeatkey = key;
|
s->repeatkey = key;
|
||||||
@@ -61,7 +61,7 @@ wlstatepress(Wlstate *s, uint32_t key, int eaten, int repeatable,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
wlstaterelease(Wlstate *s, uint32_t key)
|
wlstaterelease(Wlstate *s, u32int key)
|
||||||
{
|
{
|
||||||
int forward;
|
int forward;
|
||||||
|
|
||||||
@@ -75,9 +75,9 @@ wlstaterelease(Wlstate *s, uint32_t key)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
wlstatetimeout(Wlstate *s, uint64_t now)
|
wlstatetimeout(Wlstate *s, uvlong now)
|
||||||
{
|
{
|
||||||
uint64_t d;
|
uvlong d;
|
||||||
|
|
||||||
if(!s->repeating)
|
if(!s->repeating)
|
||||||
return -1;
|
return -1;
|
||||||
@@ -88,9 +88,9 @@ wlstatetimeout(Wlstate *s, uint64_t now)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int
|
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)
|
if(!s->repeating || now < s->repeatat)
|
||||||
return 0;
|
return 0;
|
||||||
@@ -99,8 +99,8 @@ wlstaterepeat(Wlstate *s, uint64_t now, uint32_t *key)
|
|||||||
step = 1000 / s->rate;
|
step = 1000 / s->rate;
|
||||||
if(step == 0)
|
if(step == 0)
|
||||||
step = 1;
|
step = 1;
|
||||||
if(UINT64_MAX - now < step)
|
if(~(uvlong)0 - now < step)
|
||||||
s->repeatat = UINT64_MAX;
|
s->repeatat = ~(uvlong)0;
|
||||||
else
|
else
|
||||||
s->repeatat = now + step;
|
s->repeatat = now + step;
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
@@ -1,31 +0,0 @@
|
|||||||
#ifndef WAYLAND_STATE_H
|
|
||||||
#define WAYLAND_STATE_H
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
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
|
|
||||||
1
win.c
1
win.c
@@ -1,7 +1,6 @@
|
|||||||
#include <xcb/xcb.h>
|
#include <xcb/xcb.h>
|
||||||
#include "dat.h"
|
#include "dat.h"
|
||||||
#include "fn.h"
|
#include "fn.h"
|
||||||
#include "popup_layout.h"
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
Asciitofull = 0xFEE0,
|
Asciitofull = 0xFEE0,
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ $(PROG): $(OBJS) ../ipc.c ../ipc.h
|
|||||||
|
|
||||||
$(OBJS): ../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)
|
$(CC) $(CFLAGS) -o $@ ../tests/xim_test.c keymap.c ximtext.c $(XIM_LIBS)
|
||||||
|
|
||||||
check: $(TEST)
|
check: $(TEST)
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
#include <stdint.h>
|
||||||
#include <xkbcommon/xkbcommon.h>
|
#include <xkbcommon/xkbcommon.h>
|
||||||
#include "keymap.h"
|
|
||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
#ifndef STRANS_XIM_KEYMAP_H
|
|
||||||
#define STRANS_XIM_KEYMAP_H
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
uint32_t keymaplookup(const uint32_t*, int, uint16_t);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@@ -7,8 +7,9 @@
|
|||||||
#include <xcb-imdkit/imdkit.h>
|
#include <xcb-imdkit/imdkit.h>
|
||||||
#include <xcb-imdkit/encoding.h>
|
#include <xcb-imdkit/encoding.h>
|
||||||
#include "ipc.h"
|
#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;
|
typedef struct Ic Ic;
|
||||||
struct Ic
|
struct Ic
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <xcb-imdkit/encoding.h>
|
#include <xcb-imdkit/encoding.h>
|
||||||
#include "ximtext.h"
|
|
||||||
|
|
||||||
char*
|
char*
|
||||||
ximutf8compound(const char *s, size_t len, size_t *outlen)
|
ximutf8compound(const char *s, size_t len, size_t *outlen)
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
#include <stddef.h>
|
|
||||||
|
|
||||||
char *ximcompound(const char*, size_t, size_t*);
|
|
||||||
char *ximutf8compound(const char*, size_t, size_t*);
|
|
||||||
Reference in New Issue
Block a user