Skip to content

Instantly share code, notes, and snippets.

@hyer
Last active January 2, 2018 14:52
Show Gist options
  • Save hyer/bd5cba3de494c1e499241f865c94c2ac to your computer and use it in GitHub Desktop.
Save hyer/bd5cba3de494c1e499241f865c94c2ac to your computer and use it in GitHub Desktop.
#include <gtk/gtkimcontext.h>
/*
(1) COMPILE:
cd ~
gcc -shared -o libsublime-imfix.so sublime_imfix.c `pkg-config --libs --cflags gtk+-2.0` -fPIC
sudo mv libsublime-imfix.so /opt/sublime_text/
(2) CHANGE:
sudo gedit /usr/bin/subl
#!/bin/sh
exec /opt/sublime_text/sublime_text "$@"
TO
#!/bin/sh
LD_PRELOAD=/opt/sublime_text/libsublime-imfix.so exec /opt/sublime_text/sublime_text "$@"
(3) REPLACE THE FILE AT '/usr/share/applications/sublime-text.desktop' WITH
"https://gist.github.com/e165900a6aa2f0f2938dc9babbcb4170.git"
*/
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);
}
// restart terminal and type subl to launch Sublime-text or launch from START menu.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment