sublime 中文输入【求助】
Tofloor
poster avatar
mamy920
deepin
2015-12-17 05:15
Author
百度上sublime中文输入,在ubuntu 、linux mint编译都过去了。但是在deepin上编译报错,源码如下:
  1. /*
  2. sublime-imfix.c
  3. Use LD_PRELOAD to interpose some function to fix sublime input method support for linux.
  4. By Cjacker Huang

  5. gcc -shared -o libsublime-imfix.so sublime_imfix.c  `pkg-config --libs --cflags gtk+-2.0` -fPIC
  6. LD_PRELOAD=./libsublime-imfix.so sublime_text
  7. */
  8. #include
  9. #include
  10. typedef GdkSegment GdkRegionBox;

  11. struct _GdkRegion
  12. {
  13.   long size;
  14.   long numRects;
  15.   GdkRegionBox *rects;
  16.   GdkRegionBox extents;
  17. };

  18. GtkIMContext *local_context;

  19. void
  20. gdk_region_get_clipbox (const GdkRegion *region,
  21.             GdkRectangle    *rectangle)
  22. {
  23.   g_return_if_fail (region != NULL);
  24.   g_return_if_fail (rectangle != NULL);

  25.   rectangle->x = region->extents.x1;
  26.   rectangle->y = region->extents.y1;
  27.   rectangle->width = region->extents.x2 - region->extents.x1;
  28.   rectangle->height = region->extents.y2 - region->extents.y1;
  29.   GdkRectangle rect;
  30.   rect.x = rectangle->x;
  31.   rect.y = rectangle->y;
  32.   rect.width = 0;
  33.   rect.height = rectangle->height;
  34.   //The caret width is 2;
  35.   //Maybe sometimes we will make a mistake, but for most of the time, it should be the caret.
  36.   if(rectangle->width == 2 && GTK_IS_IM_CONTEXT(local_context)) {
  37.         gtk_im_context_set_cursor_location(local_context, rectangle);
  38.   }
  39. }

  40. //this is needed, for example, if you input something in file dialog and return back the edit area
  41. //context will lost, so here we set it again.

  42. static GdkFilterReturn event_filter (GdkXEvent *xevent, GdkEvent *event, gpointer im_context)
  43. {
  44.     XEvent *xev = (XEvent *)xevent;
  45.     if(xev->type == KeyRelease && GTK_IS_IM_CONTEXT(im_context)) {
  46.        GdkWindow * win = g_object_get_data(G_OBJECT(im_context),"window");
  47.        if(GDK_IS_WINDOW(win))
  48.          gtk_im_context_set_client_window(im_context, win);
  49.     }
  50.     return GDK_FILTER_CONTINUE;
  51. }

  52. void gtk_im_context_set_client_window (GtkIMContext *context,
  53.           GdkWindow    *window)
  54. {
  55.   GtkIMContextClass *klass;
  56.   g_return_if_fail (GTK_IS_IM_CONTEXT (context));
  57.   klass = GTK_IM_CONTEXT_GET_CLASS (context);
  58.   if (klass->set_client_window)
  59.     klass->set_client_window (context, window);

  60.   if(!GDK_IS_WINDOW (window))
  61.     return;
  62.   g_object_set_data(G_OBJECT(context),"window",window);
  63.   int width = gdk_window_get_width(window);
  64.   int height = gdk_window_get_height(window);
  65.   if(width != 0 && height !=0) {
  66.     gtk_im_context_focus_in(context);
  67.     local_context = context;
  68.   }
  69.   gdk_window_add_filter (window, event_filter, context);
  70. }
Copy the Code



编译命令:gcc -shared -o libsublime-imfix.so sublime_imfix.c  `pkg-config --libs --cflags gtk+-2.0` -fPIC
依赖包:libgtk2.0-dev
编码报错如下:
  1. meyer@Meyer-pc:~$ gcc -shared -o libsublime-imfix.so sublime_imfix.c  `pkg-config --libs --cflags gtk+-2.0` -fPIC
  2. /usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libfreetype.a(ftinit.o): relocation R_X86_64_32 against `tt_driver_class' can not be used when making a shared object; recompile with -fPIC
  3. /usr/lib/gcc/x86_64-linux-gnu/5/../../../x86_64-linux-gnu/libfreetype.a: 无法添加符号: 错误的值
  4. collect2: error: ld returned 1 exit status
Copy the Code

求大神帮忙,是不是缺少什么包

Reply Favorite View the author
All Replies
2 / 2
To page
mamy920
deepin
2015-12-24 07:16
#21
https://bbs.deepin.org/post/34133
好的,我发给开发者来判断问题吧

我找到问题所在了,缺少fcitx-config-gtk2这个,安装他就可以切换输入法了。
Reply View the author
cxbii
deepin
2015-12-24 18:03
#22
https://bbs.deepin.org/post/34133
我找到问题所在了,缺少fcitx-config-gtk2这个,安装他就可以切换输入法了。

已经通知开发者了
Reply View the author
2 / 2
To page