Files
strans/Makefile
Hojun-Cho 4ac0625c6b wl: the input-method frontend
zwp_input_method_v2 over one connection, in one process: activate,
deactivate and content type applied at done, whose count is the serial a
commit must carry.  The keyboard is grabbed at every activate and
released at every deactivate, because sway hands keys to the grab holder
without asking whether the input method is active, and a grab held while
inactive would take every key in the session.  Keys come as evdev codes,
go through xkb and the Compose table the other frontends already share,
and reach the engine as an ipckeysym and a modifier mask; the grab's
modifiers go on to the virtual keyboard as well, since wlroots derives no
state from a virtual keyboard's own keys.  A key the engine does not eat
goes back as a key, not as text, and whatever is still down is released
when the context goes.  A password or a PIN purpose never reaches the
engine at all.

No popup yet: the X11 one still owns drawc, and with no Keycaret from us
it follows the pointer.

Checked by hand under headless sway 1.12 with a GTK3 entry driven by
wtype: ascii passes through, Ctrl+s selects Korean, rk shows the preedit
and Enter commits 가 and lets the Return on, Ctrl+c arrives with its
modifier, focus moving between two clients re-grabs and keeps typing, a
password entry types literally, a second strans says so and stops, and
WAYLAND_DISPLAY without a compositor falls back to XIM.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-17 19:17:27 +09:00

119 lines
3.6 KiB
Makefile

CC = 9c
LD = 9l
PKG_CONFIG ?= pkg-config
SCANNER ?= wayland-scanner
CFLAGS ?= -O2 -g
WARN_CFLAGS = -Wall -Wextra
IBUS_CFLAGS = $(shell $(PKG_CONFIG) --cflags dbus-1 xkbcommon)
IBUS_LIBS = $(shell $(PKG_CONFIG) --libs dbus-1 xkbcommon)
XIM_CFLAGS = $(shell $(PKG_CONFIG) --cflags xcb-imdkit xcb-aux xcb-xkb xkbcommon-x11)
XIM_LIBS = $(shell $(PKG_CONFIG) --libs xcb-imdkit xcb-aux xcb-xkb xkbcommon-x11)
TEXT_CFLAGS = $(shell $(PKG_CONFIG) --cflags pangocairo cairo fontconfig)
TEXT_LIBS = $(shell $(PKG_CONFIG) --libs pangocairo cairo fontconfig)
POPUP_CFLAGS = $(shell $(PKG_CONFIG) --cflags xcb-aux xcb-randr)
POPUP_LIBS = $(shell $(PKG_CONFIG) --libs xcb-aux xcb-randr)
WL_CFLAGS = $(shell $(PKG_CONFIG) --cflags wayland-client xkbcommon)
WL_LIBS = $(shell $(PKG_CONFIG) --libs wayland-client xkbcommon)
PROJECT_CPPFLAGS =
PROJECT_LDLIBS = -lthread -lbio -lxcb $(IBUS_LIBS) $(TEXT_LIBS) \
$(XIM_LIBS) $(POPUP_LIBS) $(WL_LIBS)
PROG = strans
DOCKER_IMAGE = strans-build
DOCKER_RUN = docker run --rm --user "$$(id -u):$$(id -g)" \
-v "$(CURDIR):/src" $(DOCKER_IMAGE)
SRCS = compose.c dict.c font.c ibus.c ipc.c ko.c main.c popup_layout.c \
srv.c str.c strans.c trie.c vi.c win.c wl.c xim.c
OBJS = $(SRCS:.c=.o)
# wayland-scanner writes these from the XML in proto/; only the XML is tracked.
PROTO = imv2.c imv2.h vkv1.c vkv1.h
PROTOOBJ = imv2.o vkv1.o
all: $(PROG) gtk
$(PROG): $(OBJS) $(PROTOOBJ)
$(LD) $(LDFLAGS) -o $@ $(OBJS) $(PROTOOBJ) $(PROJECT_LDLIBS) $(LDLIBS)
$(OBJS): dat.h fn.h ipc.h
wl.o: imv2.h vkv1.h
compose.o ibus.o: PROJECT_CPPFLAGS += $(IBUS_CFLAGS)
font.o: PROJECT_CPPFLAGS += $(TEXT_CFLAGS)
win.o: PROJECT_CPPFLAGS += $(POPUP_CFLAGS)
wl.o $(PROTOOBJ): PROJECT_CPPFLAGS += $(WL_CFLAGS)
xim.o: PROJECT_CPPFLAGS += $(XIM_CFLAGS)
%.o: %.c
$(CC) $(CPPFLAGS) $(PROJECT_CPPFLAGS) $(WARN_CFLAGS) $(CFLAGS) -c -o $@ $<
imv2.h: proto/input-method-unstable-v2.xml
$(SCANNER) client-header $< $@
imv2.c: proto/input-method-unstable-v2.xml
$(SCANNER) private-code $< $@
vkv1.h: proto/virtual-keyboard-unstable-v1.xml
$(SCANNER) client-header $< $@
vkv1.c: proto/virtual-keyboard-unstable-v1.xml
$(SCANNER) private-code $< $@
clean:
rm -f $(OBJS) $(PROG) $(PROTO) $(PROTOOBJ)
$(MAKE) -C tests clean
$(MAKE) -C gtk/ clean
$(MAKE) -C bench/ clean
gtk:
$(MAKE) -C gtk/
bench:
$(MAKE) -C bench/
docker-image: Dockerfile
docker build -t $(DOCKER_IMAGE) - < Dockerfile
docker-build:
$(DOCKER_RUN) sh -c 'make clean && make all'
docker-check:
$(DOCKER_RUN) sh -c 'make clean && \
make check check-live check-stress UNITARGS="$(UNITARGS)"'
docker-check-live:
$(DOCKER_RUN) sh -c 'make clean && make check-live'
docker-check-stress:
$(DOCKER_RUN) sh -c 'make clean && make check-stress'
docker-bench:
$(DOCKER_RUN) sh -c 'make clean && make bench'
docker-valgrind:
$(DOCKER_RUN) sh -c 'make clean && make -C tests unit_test && \
cd tests && valgrind -q --error-exitcode=1 ./unit_test $(UNITARGS)'
docker: docker-image
$(MAKE) docker-build
check: verify-map
$(MAKE) -C tests check UNITARGS="$(UNITARGS)"
check-live: $(PROG) gtk
$(MAKE) -C tests check-live
check-stress: $(PROG)
$(MAKE) -C tests check-stress
test: check
verify-map:
test "$$(cut -f1 map/hira.map)" = "$$(cut -f1 map/kata.map)"
python3 map/mktelex.py | cmp - map/telex.map
python3 map/mkemoji | cmp - map/emoji.dict
python3 map/mkhanja | cmp - map/hanja.dict
python3 map/verifymap.py map/*.map map/*.dict
python3 tests/mkemoji_test.py
python3 tests/mkhanja_test.py
python3 tests/skk2ktrans_test.py
.PHONY: all check check-live check-stress test verify-map clean gtk bench \
docker docker-image docker-build docker-check docker-check-live \
docker-check-stress docker-bench docker-valgrind