注:
只测试了了fcitx,没有测试ibus copy下列代码,保存为sublime_fix.c
代码如下:
#include <gtk/gtk.h> #include <gdk/gdkx.h> typedef GdkSegment GdkRegionBox; struct _GdkRegion { long size; long numRects; GdkRegionBox *rects; GdkRegionBox extents; }; GtkIMContext *local_context; voidgdk_region_get_clipbox (const GdkRegion *region , GdkRectangle *rectangle) { g_return_if_fail (region != NULL); g_return_if_fail (rectangle != NULL); rectangle->x = region->extents.x1; rectangle->y = region->extents.y1; rectangle->width = region->extents.x2 - region->extents.x1; rectangle->height = region->extents.y2 - region->extents.y1; GdkRectangle rect; rect.x = rectangle->x; rect.y = rectangle->y; rect.width = 0; rect.height = rectangle->height; if(rectangle->width == 2 && GTK_IS_IM_CONTEXT(local_context)) { gtk_im_context_set_cursor_location(local_context, rectangle); } }
static GdkFilterReturn event_filter (GdkXEvent *xevent, GdkEvent *event, gpointer im_context)
使用下列命令编译它
代码如下:
gcc -shared -o libsublime-imfix.so sublime_fix.c `pkg-config --libs --cflags gtk+-2.0/` -fPIC
添加运行权限给libsublime-imfix.so
代码如下:
chmod +x libsublime-imfix.so
将编译后的文件libsublime-imfix.so复制到sublime的文件夹下面
代码如下:
#!/bin/bash SUBLIME_HOME="~/software" #你的sublime安装目录 LD_LIB="$SUBLIME_HOME/libsublime-imfix.so" sh -c "LD_PRELOAD=$LD_LIB $SUBLIME_HOME/sublime $@"
你已经可以通过teminal启动sublime了,运行./sublime_sh.sh即可 |