build: install the GTK module predictably

This commit is contained in:
2026-08-12 15:57:18 +09:00
parent 1295480858
commit 1d8d711882
2 changed files with 18 additions and 10 deletions

View File

@@ -1,8 +1,9 @@
PROG = im-strans.so PROG = im-strans.so
CFLAGS = -Wall -O2 -I.. $(shell pkg-config --cflags gtk+-3.0) CFLAGS = -Wall -O2 -I.. $(shell pkg-config --cflags gtk+-3.0)
LDFLAGS = $(shell pkg-config --libs gtk+-3.0) LDFLAGS = $(shell pkg-config --libs gtk+-3.0)
DSTDIR ?= $(shell find /usr/lib* -type d \ GTK_LIBDIR ?= $(shell pkg-config --variable=libdir gtk+-3.0)
-path "*/gtk-3.0/*/immodules" 2>/dev/null | head -1) GTK_BINARY_VERSION ?= $(shell pkg-config --variable=gtk_binary_version gtk+-3.0)
GTK_MODULE_DIR ?= $(GTK_LIBDIR)/gtk-3.0/$(GTK_BINARY_VERSION)/immodules
all: $(PROG) all: $(PROG)
@@ -10,15 +11,17 @@ $(PROG): main.c ../ipc.c ../ipc.h
$(CC) -shared -fPIC $(CFLAGS) -o $@ main.c ../ipc.c $(LDFLAGS) $(CC) -shared -fPIC $(CFLAGS) -o $@ main.c ../ipc.c $(LDFLAGS)
install: $(PROG) install: $(PROG)
test -n "$(DSTDIR)" test -n "$(GTK_LIBDIR)"
mkdir -p "$(DSTDIR)" test -n "$(GTK_BINARY_VERSION)"
cp $(PROG) "$(DSTDIR)/" mkdir -p "$(DESTDIR)$(GTK_MODULE_DIR)"
gtk-query-immodules-3.0 --update-cache cp $(PROG) "$(DESTDIR)$(GTK_MODULE_DIR)/"
if test -z "$(DESTDIR)"; then gtk-query-immodules-3.0 --update-cache; fi
uninstall: uninstall:
test -n "$(DSTDIR)" test -n "$(GTK_LIBDIR)"
rm -f "$(DSTDIR)/$(PROG)" test -n "$(GTK_BINARY_VERSION)"
gtk-query-immodules-3.0 --update-cache rm -f "$(DESTDIR)$(GTK_MODULE_DIR)/$(PROG)"
if test -z "$(DESTDIR)"; then gtk-query-immodules-3.0 --update-cache; fi
clean: clean:
rm -f $(PROG) rm -f $(PROG)

View File

@@ -216,7 +216,12 @@ reset(GtkIMContext *ctx)
static void static void
focusout(GtkIMContext *ctx) focusout(GtkIMContext *ctx)
{ {
sendreset((Im*)ctx); Im *im;
im = (Im*)ctx;
sendreset(im);
/* Closing the context connection releases engine ownership. */
srvclose(im);
} }
static void static void