今天逛論壇,發現 cjacker 君提供了一個解決的方法, 測試了一下, 輸入法終於能夠正常運行了, 不敢獨享, 貼過來給你們看看 php
cjacker 經過 LD_PRELOAD 實現了 gtk_im_context_set_client_window 的 加載, 使得輸入法可以得到焦點#include <gtk/gtkimcontext.h> void gtk_im_context_set_client_window (GtkIMContext *context, GdkWindow *window) { GtkIMContextClass *klass; g_return_if_fail (GTK_IS_IM_CONTEXT (context)); klass = GTK_IM_CONTEXT_GET_CLASS (context); if (klass->set_client_window) klass->set_client_window (context, window); g_object_set_data(G_OBJECT(context),"window",window); if(!GDK_IS_WINDOW (window)) return; int width = gdk_window_get_width(window); int height = gdk_window_get_height(window); if(width != 0 && height !=0) gtk_im_context_focus_in(context); }
2. 編譯成共享庫 css
gcc -shared -o libsublime-imfix.so sublime_imfix.c `pkg-config --libs --cflags gtk+-2.0` -fPIC
3. 運行 linux
LD_PRELOAD=./libsublime-imfix.so sublime_text
BIN=/opt/sublime-text/sublime_text替換爲
exec 'LD_PRELOAD=/opt/sublime-text/libsublime-imfix.so /opt/sublime-text/sublime_text'
附:解決方法原地址:http://www.sublimetext.com/forum/viewtopic.php?f=3&t=7006&start=10#p41343 shell