From 1d8d711882e9d77c91296ff06742c5f9a135469e Mon Sep 17 00:00:00 2001 From: Hojun-Cho Date: Wed, 12 Aug 2026 15:57:18 +0900 Subject: [PATCH] build: install the GTK module predictably --- gtk/Makefile | 21 ++++++++++++--------- gtk/main.c | 7 ++++++- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/gtk/Makefile b/gtk/Makefile index 0cd4d8e..1634753 100644 --- a/gtk/Makefile +++ b/gtk/Makefile @@ -1,8 +1,9 @@ PROG = im-strans.so CFLAGS = -Wall -O2 -I.. $(shell pkg-config --cflags gtk+-3.0) LDFLAGS = $(shell pkg-config --libs gtk+-3.0) -DSTDIR ?= $(shell find /usr/lib* -type d \ - -path "*/gtk-3.0/*/immodules" 2>/dev/null | head -1) +GTK_LIBDIR ?= $(shell pkg-config --variable=libdir gtk+-3.0) +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) @@ -10,15 +11,17 @@ $(PROG): main.c ../ipc.c ../ipc.h $(CC) -shared -fPIC $(CFLAGS) -o $@ main.c ../ipc.c $(LDFLAGS) install: $(PROG) - test -n "$(DSTDIR)" - mkdir -p "$(DSTDIR)" - cp $(PROG) "$(DSTDIR)/" - gtk-query-immodules-3.0 --update-cache + test -n "$(GTK_LIBDIR)" + test -n "$(GTK_BINARY_VERSION)" + mkdir -p "$(DESTDIR)$(GTK_MODULE_DIR)" + cp $(PROG) "$(DESTDIR)$(GTK_MODULE_DIR)/" + if test -z "$(DESTDIR)"; then gtk-query-immodules-3.0 --update-cache; fi uninstall: - test -n "$(DSTDIR)" - rm -f "$(DSTDIR)/$(PROG)" - gtk-query-immodules-3.0 --update-cache + test -n "$(GTK_LIBDIR)" + test -n "$(GTK_BINARY_VERSION)" + rm -f "$(DESTDIR)$(GTK_MODULE_DIR)/$(PROG)" + if test -z "$(DESTDIR)"; then gtk-query-immodules-3.0 --update-cache; fi clean: rm -f $(PROG) diff --git a/gtk/main.c b/gtk/main.c index e7dc40b..2f7ef43 100644 --- a/gtk/main.c +++ b/gtk/main.c @@ -216,7 +216,12 @@ reset(GtkIMContext *ctx) static void focusout(GtkIMContext *ctx) { - sendreset((Im*)ctx); + Im *im; + + im = (Im*)ctx; + sendreset(im); + /* Closing the context connection releases engine ownership. */ + srvclose(im); } static void