Back to index

im-sdk  12.3.91
Classes | Defines | Functions
imswitcher.c File Reference
#include <gdk/gdkx.h>
#include <gtk/gtk.h>
#include <stdlib.h>
#include <string.h>
#include "iiimcf.h"
#include "gtkimcontextiiim.h"
#include "imswitcher.h"
#include "IIIMGdkEventKey.h"
#include <gtk/gtkinvisible.h>
#include <gdk/gdkproperty.h>
#include <gdk/gdkselection.h>

Go to the source code of this file.

Classes

struct  _SwitcherInfo
struct  _SwitcherContext

Defines

#define DEBUG_DO(x)

Functions

static GdkFilterReturn switcher_owner_filter (GdkXEvent *xev, GdkEvent *event, gpointer data)
static gboolean filter_destroy_event (Display *d, Window w, XEvent *ev, gpointer data)
gboolean im_info_switcher_new (GtkIIIMInfo *info)
static void destroy_switcher_window (GtkWidget *widget, GtkIMContextIIIM *context_iiim)
static void property_notify_switcher_window (GtkWidget *widget, GdkEventProperty *ev, GtkIMContextIIIM *context_iiim)
void im_context_switcher_set_status_text (GtkIMContextIIIM *context_iiim, gchar *utf8)
void im_context_switcher_set_conversion_mode (GtkIMContextIIIM *context_iiim)
void im_context_switcher_set_hotkey (GtkIMContextIIIM *context_iiim, char *hotkey)
void im_context_switcher_set_input_language (GtkIMContextIIIM *context_iiim, gchar *input_lang)
void im_context_switcher_set_language_engine_list (GtkIMContextIIIM *context_iiim, gchar *le_list)
void im_context_switcher_set_language_list (GtkIMContextIIIM *context_iiim, IIIMCF_language *lang_list, int n_lang)
void im_context_switcher_new (GtkIMContextIIIM *context_iiim)
gboolean im_info_switcher_active (GtkIIIMInfo *info)
void im_context_switcher_set_focus (GtkIMContextIIIM *context_iiim)
void im_info_switcher_shutdown (GtkIIIMInfo *info)
void im_context_switcher_finalize (GtkIMContextIIIM *context_iiim)
gchar * im_context_switcher_get_hotkey_with_type (char *string, char *type)
gchar * im_context_switcher_get_hotkey (GtkIMContextIIIM *context_iiim)
static void change_hotkey_with_type (GtkIMContextIIIM *context_iiim, char *type, int num_keys, IIIMCF_keyevent *keys)
static void convert_hotkey_to_IIIMCF_keyevent (gchar *triggerkey, int *num_keys, IIIMCF_keyevent **keys)
void im_context_switcher_change_hotkey_with_type (GtkIMContextIIIM *context_iiim, gchar *type, gchar *string)
char * im_context_switcher_get_hotkey_with_atom (GtkIMContextIIIM *context_iiim)

Class Documentation

struct _SwitcherInfo

Definition at line 44 of file imswitcher.c.

Class Members
GdkAtom selection_atom
Atom selection_atom
GdkAtom set_conversion_mode_atom
Atom set_conversion_mode_atom
GdkAtom set_current_client_atom
Atom set_current_client_atom
GdkAtom set_current_input_language_atom
Atom set_current_input_language_atom
GdkAtom set_hotkey_atom
Atom set_hotkey_atom
GdkAtom set_input_language_list_atom
Atom set_input_language_list_atom
GdkAtom set_language_engine_list_atom
GdkAtom set_status_text_atom
Atom set_status_text_atom
GdkWindow * switcher
Window switcher_window
Window switcher_x_window
struct _SwitcherContext

Definition at line 64 of file imswitcher.c.

Class Members
gulong destroy_handler_id
GtkWidget * invisible
Window invisible
gulong property_handler_id

Define Documentation

#define DEBUG_DO (   x)

Definition at line 41 of file imswitcher.c.


Function Documentation

static void change_hotkey_with_type ( GtkIMContextIIIM *  context_iiim,
char *  type,
int  num_keys,
IIIMCF_keyevent keys 
) [static]

Definition at line 715 of file imswitcher.c.

{
  int num_hotkey = 0, i;
  IIIMCF_hotkey *hotkeys = NULL;
  IIIMCF_handle handle = im_info_get_handle (context_iiim->iiim_info);

  iiimcf_get_hotkeys (context_iiim->context, &num_hotkey, &hotkeys);

  if (num_hotkey == 0) return;

  for (i = 0; i < num_hotkey; ++i)
    {
      if (!strcasecmp (type, hotkeys[i].hotkey_label))
       {
         if (hotkeys[i].nkeys < num_keys)
           {
             g_free (hotkeys[i].keys);
             hotkeys[i].keys = g_new0 (IIIMCF_keyevent, num_keys);
           }

         hotkeys[i].nkeys = num_keys;
         memcpy (hotkeys[i].keys, keys, sizeof (IIIMCF_keyevent) * num_keys);
       }
    }

  /* change the onkeys and offkeys if the target type is TRIGGER_KEY_LABEL */
  if ( handle && !strcasecmp (type, TRIGGER_KEY_LABEL))
    {
      int num_on_keys = 0, num_off_keys = 0;
      static int initial_num_on_keys = 0, initial_num_off_keys = 0;
      IIIMCF_keyevent *onkeys, *offkeys;

      iiimcf_get_trigger_keys (handle, &num_on_keys, &onkeys,
                            &num_off_keys, &offkeys);

      if (!initial_num_on_keys && !initial_num_off_keys) 
       {
         initial_num_on_keys = num_on_keys;
         initial_num_off_keys = num_off_keys;
       }
      
      num_keys = initial_num_on_keys < num_keys ? initial_num_on_keys : num_keys;
      memcpy (onkeys, keys, sizeof (IIIMCF_keyevent) * num_keys);
      memset (onkeys + num_keys, 0, sizeof (IIIMCF_keyevent) * (initial_num_on_keys - num_keys));

      num_keys = initial_num_off_keys < num_keys ? initial_num_off_keys : num_keys;
      memcpy (offkeys, keys, sizeof (IIIMCF_keyevent) * num_keys);
      memset (offkeys + num_keys, 0, sizeof (IIIMCF_keyevent) * (initial_num_off_keys - num_keys));
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void convert_hotkey_to_IIIMCF_keyevent ( gchar *  triggerkey,
int *  num_keys,
IIIMCF_keyevent **  keys 
) [static]

Definition at line 774 of file imswitcher.c.

{
  char *key_delimiter = ",";
  char **hotkeys = g_strsplit (triggerkey, key_delimiter, -1);
  int i;

  if (hotkeys == NULL) return;

  // *num_keys = g_strv_length (hotkeys);
  *num_keys = 0;
  while (hotkeys[*num_keys]) ++ *num_keys;

  *keys = g_new0 (IIIMCF_keyevent, *num_keys);

  for (i=0; i < *num_keys; ++i)
    {
      char *key_separator = "+";
      gchar **k, **keys_text = g_strsplit (hotkeys[i], key_separator, -1);

      k = keys_text;
      for (; *k; ++k)
       {
         if (!strcasecmp (*k, "Ctrl"))
           (*keys)[i].modifier |= IIIMF_CONTROL_MODIFIER;
         else if (!strcasecmp (*k, "Shift"))
           (*keys)[i].modifier |= IIIMF_SHIFT_MODIFIER;
         else if (!strcasecmp (*k, "Alt"))
           (*keys)[i].modifier |= IIIMF_ALT_MODIFIER;
         else
           {
             guint keyval = gdk_keyval_from_name (*k);
             gint keycode = g2icode (keyval);

             if (keycode < 0)
              {
                (*keys)[i].keychar = 0;
                (*keys)[i].keycode = -keycode;
              }
             else
              {
                (*keys)[i].keychar = gdk_keyval_to_unicode (keyval);
                (*keys)[i].keycode = keycode;
              }
           }
       }

      g_strfreev (keys_text);
    }

  g_strfreev (hotkeys);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void destroy_switcher_window ( GtkWidget *  widget,
GtkIMContextIIIM *  context_iiim 
) [static]

Definition at line 162 of file imswitcher.c.

{
  SwitcherContext *w = context_iiim->switcher_context;
  if (!w)
    return;
  gtk_widget_destroy (w->invisible);
  g_free (w);
  context_iiim->switcher_context = NULL;
  return;
}

Here is the caller graph for this function:

static gboolean filter_destroy_event ( Display *  d,
Window  w,
XEvent *  ev,
gpointer  data 
) [static]

Definition at line 572 of file imswitcher.c.

{
  GtkIIIMInfo *info = data;
  SwitcherInfo *sw_info = im_info_get_switcher_info (info);

  if (sw_info && sw_info->switcher_x_window == w)
    {
      sw_info->switcher = NULL;
      sw_info->switcher_x_window = None;
      g_free (sw_info);
      im_info_set_switcher_info (info, NULL);
      return TRUE;
    }
  return FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void im_context_switcher_change_hotkey_with_type ( GtkIMContextIIIM *  context_iiim,
gchar *  type,
gchar *  string 
)

Definition at line 829 of file imswitcher.c.

{
  int num_keys;
  IIIMCF_keyevent *keys;

  convert_hotkey_to_IIIMCF_keyevent (string, &num_keys, &keys);
  
  change_hotkey_with_type (context_iiim, type, num_keys, keys);

  g_free (keys);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void im_context_switcher_finalize ( GtkIMContextIIIM *  context_iiim)

Definition at line 610 of file imswitcher.c.

{
  SwitcherContext *w = context_iiim->switcher_context;

  if (w == NULL)
    return;
  g_signal_handler_disconnect (G_OBJECT (w->invisible), w->destroy_handler_id);
  g_signal_handler_disconnect (G_OBJECT (w->invisible), w->property_handler_id);
  gtk_widget_destroy (w->invisible);
  g_free (w);
  context_iiim->switcher_context = NULL;
  return;
}

Here is the caller graph for this function:

gchar* im_context_switcher_get_hotkey ( GtkIMContextIIIM *  context_iiim)

Definition at line 652 of file imswitcher.c.

{
  int num_hotkey = 0, i;
  IIIMCF_hotkey *hotkeys;
  char s[512], *p = s;

  memset (s, 0, 512);

  iiimcf_get_hotkeys (context_iiim->context, &num_hotkey, &hotkeys);

  if (num_hotkey == 0) return NULL;

  for (i = 0; i < num_hotkey; ++i)
    {
      char label_delimiter = ':';
      char key_delimiter = ',';
      int k;

      strcpy (p, hotkeys[i].hotkey_label);
      p += strlen (hotkeys[i].hotkey_label);
      *p++ = label_delimiter;

      for (k = 0; k < hotkeys[i].nkeys; ++k)
       {
         IIIMCF_keyevent *key = hotkeys[i].keys + k;
         GdkEventKey event;
         char *keyname;

         if (k) *p++ = key_delimiter;

         if (key->modifier & IIIMF_CONTROL_MODIFIER)
           {
             strcpy (p, "Ctrl+");
             p += strlen ("Ctrl+");
           }
         if (key->modifier & IIIMF_SHIFT_MODIFIER)
           {
             strcpy (p, "Shift+");
             p += strlen ("Shift+");
           }
         if (key->modifier & IIIMF_ALT_MODIFIER)
           {
             strcpy (p, "Alt+");
             p += strlen ("Alt+");
           }

         convert_IIIMCF_keyevent_to_GdkEventKey (key, &event);
         keyname = gdk_keyval_name (event.keyval);

         if (keyname)
           {
             strcpy (p, keyname);
             p += strlen (keyname);
           }
       }

      if (i < num_hotkey - 1) *p++ = label_delimiter;
    }

  return strdup (s);
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* im_context_switcher_get_hotkey_with_atom ( GtkIMContextIIIM *  context_iiim)

Definition at line 844 of file imswitcher.c.

{
  SwitcherInfo *sw_info = im_info_get_switcher_info (context_iiim->iiim_info);
  GdkScreen *screen;
  GdkDisplay *display;
  Atom x_atom;
  int format;
  unsigned long length, nitem;
  unsigned char *data = NULL;
  Atom type;

  if (!im_info_switcher_active (context_iiim->iiim_info))
    return NULL;

  screen = im_info_get_screen (context_iiim->iiim_info);
  display = gdk_screen_get_display (screen);
  x_atom = gdk_x11_atom_to_xatom_for_display (display, sw_info->set_hotkey_atom);

  XGetWindowProperty (GDK_DISPLAY_XDISPLAY (display),
                    sw_info->switcher_x_window,
                    x_atom,
                    0, INT_MAX, False, x_atom,
                    &type, &format, &nitem, &length, &data);

  return data;
}

Here is the call graph for this function:

Here is the caller graph for this function:

gchar* im_context_switcher_get_hotkey_with_type ( char *  string,
char *  type 
)

Definition at line 625 of file imswitcher.c.

{
  char *label_delimiter = ":";
  char **hotkeys = g_strsplit (string, label_delimiter, -1);
  int num_hotkeys = 0, i;
  char *keys = NULL;

  // num_hotkeys = g_strv_length (hotkeys) / 2;
  while (hotkeys [num_hotkeys]) ++num_hotkeys;
  num_hotkeys /= 2;

  for (i = 0; i < num_hotkeys; ++i)
    {
      if (!strcasecmp (hotkeys[i * 2], type))
       {
         keys = strdup (hotkeys[i * 2 + 1]);
         break;
       }
    }

  g_strfreev (hotkeys);

  return keys;
}

Here is the caller graph for this function:

void im_context_switcher_new ( GtkIMContextIIIM *  context_iiim)

Definition at line 486 of file imswitcher.c.

{
  SwitcherContext *w = g_new0 (SwitcherContext, 1);

  g_return_if_fail (context_iiim != NULL);
  g_return_if_fail (context_iiim->iiim_info != NULL);

  w->invisible = gtk_invisible_new ();
  gtk_widget_realize (w->invisible);

  gtk_widget_add_events (w->invisible,
                      GDK_PROPERTY_CHANGE_MASK | GDK_STRUCTURE_MASK);

  w->destroy_handler_id =
    g_signal_connect (G_OBJECT (w->invisible), "destroy",      
                    G_CALLBACK (destroy_switcher_window),
                    context_iiim);

  w->property_handler_id = 
    g_signal_connect (G_OBJECT (w->invisible), "property-notify-event",
                    G_CALLBACK (property_notify_switcher_window),
                    context_iiim);
  context_iiim->switcher_context = w;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void im_context_switcher_set_conversion_mode ( GtkIMContextIIIM *  context_iiim)

Definition at line 246 of file imswitcher.c.

{
  GtkIIIMInfo *info = context_iiim->iiim_info;
  SwitcherInfo *sw_info = im_info_get_switcher_info (info);
  IIIMF_status st;
  gint conversion_mode = FALSE;

  if (sw_info == NULL)
    return;

  st = iiimcf_get_current_conversion_mode (context_iiim->context,
                                      &conversion_mode);

  if (sw_info->switcher)
    {
      gdk_property_change (sw_info->switcher, 
                        sw_info->set_conversion_mode_atom,
                        sw_info->set_conversion_mode_atom,
                        32,
                        GDK_PROP_MODE_REPLACE,
                        (unsigned char*)&conversion_mode,
                        1);
    }
  else if (sw_info->switcher_x_window)
    {
      GdkScreen *screen = im_info_get_screen (info);
      GdkDisplay *display = gdk_screen_get_display (screen);
      Atom x_atom = gdk_x11_atom_to_xatom_for_display (display,
                            sw_info->set_conversion_mode_atom);

      XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
                     sw_info->switcher_x_window,
                     x_atom,
                     x_atom,
                     32,
                     PropModeReplace,
                     (guchar *)&conversion_mode,
                     1);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void im_context_switcher_set_focus ( GtkIMContextIIIM *  context_iiim)

Definition at line 519 of file imswitcher.c.

{
  SwitcherContext *w;
  GtkIIIMInfo *info = context_iiim->iiim_info;
  SwitcherInfo *sw_info;

  if (!im_info_switcher_active (info))
    {
      im_info_switcher_new (info);
      if (!im_info_switcher_active (info))
       return;
    }

  if (context_iiim->switcher_context == NULL)
    im_context_switcher_new (context_iiim);

  w = context_iiim->switcher_context;
  sw_info = im_info_get_switcher_info (info);
  if (w && w->invisible)
    gdk_selection_convert (w->invisible->window,
                        sw_info->selection_atom,
                        sw_info->set_current_client_atom,
                        gtk_get_current_event_time ());
}

Here is the call graph for this function:

Here is the caller graph for this function:

void im_context_switcher_set_hotkey ( GtkIMContextIIIM *  context_iiim,
char *  hotkey 
)

Definition at line 289 of file imswitcher.c.

{
  GtkIIIMInfo *info = context_iiim->iiim_info;
  SwitcherInfo *sw_info = im_info_get_switcher_info (info);

  if (sw_info == NULL || hotkey == NULL)
    return;

  if (sw_info->switcher)
    {
      gdk_property_change (sw_info->switcher,
                           sw_info->set_hotkey_atom,
                           sw_info->set_hotkey_atom,
                           8,
                           GDK_PROP_MODE_REPLACE,
                           (unsigned char*)hotkey,
                           strlen (hotkey));
    }
  else if (sw_info->switcher_x_window)
    {
      GdkScreen *screen = im_info_get_screen (info);
      GdkDisplay *display = gdk_screen_get_display (screen);
      Atom x_atom = gdk_x11_atom_to_xatom_for_display (display,
                               sw_info->set_hotkey_atom);

      XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
                       sw_info->switcher_x_window,
                       x_atom,
                       x_atom,
                       8,
                       PropModeReplace,
                       (guchar *)hotkey,
                       strlen (hotkey));
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void im_context_switcher_set_input_language ( GtkIMContextIIIM *  context_iiim,
gchar *  input_lang 
)

Definition at line 327 of file imswitcher.c.

{
  GtkIIIMInfo *info = context_iiim->iiim_info;
  SwitcherInfo *sw_info = im_info_get_switcher_info (info);

  if (sw_info == NULL)
    return;

  if (input_lang == NULL)
    input_lang = context_iiim->current_language;
  if (sw_info->switcher && input_lang)
    {
      gdk_property_change (sw_info->switcher, 
                        sw_info->set_current_input_language_atom,
                        sw_info->set_current_input_language_atom,
                        8,
                        GDK_PROP_MODE_REPLACE,
                        (unsigned char*)input_lang,
                        strlen (input_lang));
    }
  else if (sw_info->switcher_x_window && input_lang)
    {
      GdkScreen *screen = im_info_get_screen (info);
      GdkDisplay *display = gdk_screen_get_display (screen);
      Atom x_atom = gdk_x11_atom_to_xatom_for_display (display,
                            sw_info->set_current_input_language_atom);

      XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
                     sw_info->switcher_x_window,
                     x_atom,
                     x_atom,
                     8,
                     PropModeReplace,
                     (guchar *)input_lang,
                     strlen (input_lang));
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void im_context_switcher_set_language_engine_list ( GtkIMContextIIIM *  context_iiim,
gchar *  le_list 
)

Definition at line 367 of file imswitcher.c.

{
  GtkIIIMInfo *info = context_iiim->iiim_info;
  SwitcherInfo *sw_info = im_info_get_switcher_info (info);
  gsize len;

  if (sw_info == NULL)
    return;

  len = strlen (le_list);

  if (len == 0)
    return;

  if (sw_info->switcher)
    gdk_property_change (sw_info->switcher, 
                      sw_info->set_language_engine_list_atom,
                      sw_info->set_language_engine_list_atom,
                      8,
                      GDK_PROP_MODE_REPLACE,
                      (guchar*)le_list, len);
  else if (sw_info->switcher_x_window)
    {
      GdkScreen *screen = im_info_get_screen (info);
      GdkDisplay *display = gdk_screen_get_display (screen);
      Atom x_atom = gdk_x11_atom_to_xatom_for_display (display,
                                                 sw_info->set_language_engine_list_atom);
      XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
                     sw_info->switcher_x_window,
                     x_atom,
                     x_atom,
                     8,
                     PropModeReplace,
                     (guchar *)le_list, len);
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void im_context_switcher_set_language_list ( GtkIMContextIIIM *  context_iiim,
IIIMCF_language lang_list,
int  n_lang 
)

Definition at line 406 of file imswitcher.c.

{
  GtkIIIMInfo *info = context_iiim->iiim_info;
  SwitcherInfo *sw_info = im_info_get_switcher_info (info);
  gchar *languages;
  gchar *ptr;
  IIIMF_status st;
  char *langid;
  gint i;
  gsize len;
  const char *separator = ";";
  gsize separator_len;

  if (sw_info == NULL)
    return;

  if (lang_list == NULL || n_lang == 0)
    return;

  /* First part, getting length */
  st = iiimcf_get_language_id (lang_list[0],
                            (const char **) &langid);
  if (st != IIIMF_STATUS_SUCCESS)
    return;

  separator_len = strlen (separator);
  len = strlen (langid);
  for (i = 1; i < n_lang; i++)
    {
      st = iiimcf_get_language_id (lang_list[i],
                               (const char **) &langid);
      if (st != IIIMF_STATUS_SUCCESS)
       continue;
      len += strlen (langid);
    }
  len += separator_len * (i - 1);

  /* Second part, building string */
  languages = g_new (gchar, len + 1);

  st = iiimcf_get_language_id (lang_list[0],
                            (const char **) &langid);
  ptr = g_stpcpy (languages, langid);
  for (i = 1; i < n_lang; i++)
    {
      ptr = g_stpcpy (ptr, separator);
      st = iiimcf_get_language_id (lang_list[i],
                               (const char **) &langid);
      if (st != IIIMF_STATUS_SUCCESS)
       continue;
      ptr = g_stpcpy (ptr, langid);
    }

  if (sw_info->switcher)
    gdk_property_change (sw_info->switcher, 
                      sw_info->set_input_language_list_atom,
                      sw_info->set_input_language_list_atom,
                      8,
                      GDK_PROP_MODE_REPLACE,
                      (guchar*)languages, len);
  else if (sw_info->switcher_x_window)
    {
      GdkScreen *screen = im_info_get_screen (info);
      GdkDisplay *display = gdk_screen_get_display (screen);
      Atom x_atom = gdk_x11_atom_to_xatom_for_display (display,
                                                 sw_info->set_input_language_list_atom);
      XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
                     sw_info->switcher_x_window,
                     x_atom,
                     x_atom,
                     8,
                     PropModeReplace,
                     (guchar *)languages, len);
    }
  g_free (languages);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void im_context_switcher_set_status_text ( GtkIMContextIIIM *  context_iiim,
gchar *  utf8 
)

Definition at line 208 of file imswitcher.c.

{
  GtkIIIMInfo *info = context_iiim->iiim_info;
  SwitcherInfo *sw_info = im_info_get_switcher_info (info);

  if (sw_info == NULL)
    return;

  if (sw_info->switcher)
    {
      gdk_property_change (sw_info->switcher, 
                        sw_info->set_status_text_atom,
                        sw_info->set_status_text_atom,
                        8,
                        GDK_PROP_MODE_REPLACE,
                        (unsigned char*)utf8,
                        strlen (utf8));
    }
  else if (sw_info->switcher_x_window)
    {
      GdkScreen *screen = im_info_get_screen (info);
      GdkDisplay *display = gdk_screen_get_display (screen);
      Atom x_atom = gdk_x11_atom_to_xatom_for_display (display,
                               sw_info->set_status_text_atom);

      XChangeProperty (GDK_DISPLAY_XDISPLAY (display),
                     sw_info->switcher_x_window,
                     x_atom,
                     x_atom,
                     8,
                     PropModeReplace,
                     (guchar *)utf8,
                     strlen (utf8));
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

gboolean im_info_switcher_active ( GtkIIIMInfo *  info)

Definition at line 512 of file imswitcher.c.

{
  SwitcherInfo *sw_info = im_info_get_switcher_info (info);
  return (sw_info && (sw_info->switcher || sw_info->switcher_x_window));
}

Here is the call graph for this function:

Here is the caller graph for this function:

gboolean im_info_switcher_new ( GtkIIIMInfo *  info)

Definition at line 79 of file imswitcher.c.

{
  GdkAtom selection = GDK_NONE;
  SwitcherInfo *sw_info;

  if (info == NULL)
    return FALSE;

  selection = gdk_atom_intern ("_IIIM_SWITCHER", FALSE);

  sw_info = im_info_get_switcher_info (info);
  if (sw_info == NULL)
    {
      sw_info = g_new0 (SwitcherInfo, 1);
      im_info_set_switcher_info (info, sw_info);
    }

  if (selection != GDK_NONE)
    sw_info->switcher = gdk_selection_owner_get (selection);

  sw_info->selection_atom = selection;

  if (sw_info->switcher)
    gdk_window_add_filter (sw_info->switcher,
                        switcher_owner_filter, info);
  else
    {
      /*
       this could be due to bugzilla 126375, hence try to
       do Xlib directly.
      */
      GdkScreen *screen;
      GdkDisplay *display;
      Atom x_atom;
      Window xwindow;

      screen = im_info_get_screen (info);
      if (screen == None)
         return FALSE;

      display = gdk_screen_get_display (screen);
      x_atom = gdk_x11_atom_to_xatom_for_display (display, 
                                            selection);
      xwindow = XGetSelectionOwner (GDK_DISPLAY_XDISPLAY (display),
                                x_atom);
      if (xwindow == None)
       {
         DEBUG_DO (g_message ("Unable to find input method switcher"));
         return FALSE;
       }
      sw_info->switcher_x_window = xwindow;

      _XRegisterFilterByType (GDK_DISPLAY_XDISPLAY (display), xwindow,
                           DestroyNotify, DestroyNotify,
                           filter_destroy_event, info);
      XSelectInput (GDK_DISPLAY_XDISPLAY (display), xwindow, StructureNotifyMask);
    }

  sw_info->set_current_input_language_atom
    = gdk_atom_intern ("_IIIM_SWITCHER_CURRENT_INPUT_LANGUAGE", FALSE);

  sw_info->set_current_client_atom =
    gdk_atom_intern ("_IIIM_SWITCHER_CURRENT_CLIENT", FALSE);

  sw_info->set_status_text_atom
    = gdk_atom_intern ("_IIIM_SWITCHER_STATUS_TEXT", FALSE);

  sw_info->set_input_language_list_atom =
    gdk_atom_intern ("_IIIM_SWITCHER_INPUT_LANGUAGE_LIST", FALSE);

  sw_info->set_language_engine_list_atom
    = gdk_atom_intern ("_IIIM_SWITCHER_LANGUAGE_ENGINE_LIST", FALSE);

  sw_info->set_conversion_mode_atom = 
    gdk_atom_intern ("_IIIM_SWITCHER_SET_CONVERSION_MODE", FALSE);

  sw_info->set_hotkey_atom =
    gdk_atom_intern ("_IIIM_SWITCHER_SET_HOTKEY", FALSE);

  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void im_info_switcher_shutdown ( GtkIIIMInfo *  info)

Definition at line 589 of file imswitcher.c.

{
  SwitcherInfo *sw_info = im_info_get_switcher_info (info);
  if (sw_info)
    {
      if (sw_info->switcher)
       gdk_window_remove_filter (sw_info->switcher,
                              switcher_owner_filter, info);
      else if (sw_info->switcher_x_window)
       {
         GdkScreen *screen = im_info_get_screen (info);
         GdkDisplay *display = gdk_screen_get_display (screen);

         _XUnregisterFilter (GDK_DISPLAY_XDISPLAY (display), 
                           sw_info->switcher_x_window,
                           filter_destroy_event, info);
       }
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void property_notify_switcher_window ( GtkWidget *  widget,
GdkEventProperty *  ev,
GtkIMContextIIIM *  context_iiim 
) [static]

Definition at line 174 of file imswitcher.c.

{
  GdkAtom  type;
  guchar   *data = NULL;
  gint     format;
  gint     length;
  SwitcherInfo *sw_info = im_info_get_switcher_info (context_iiim->iiim_info);

  if (context_iiim->context == NULL)
    return;

  if (ev->atom == sw_info->set_current_input_language_atom)
    {
      gdk_property_get (widget->window, ev->atom, ev->atom,
                     0, INT_MAX, FALSE,
                     &type, &format, &length, &data);
      im_context_initialize_with_input_language (context_iiim,
                                           data);
      g_free (data);
    }
  if (ev->atom == sw_info->set_conversion_mode_atom)
    {
      gdk_property_get (widget->window, ev->atom, ev->atom,
                     0, INT_MAX, FALSE,
                     &type, &format, &length, &data);
      im_context_change_conversion_mode (context_iiim,
                                    data);
      g_free (data);
    }
  return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static GdkFilterReturn switcher_owner_filter ( GdkXEvent *  xev,
GdkEvent *  event,
gpointer  data 
) [static]

Definition at line 548 of file imswitcher.c.

{
  XEvent *xevent = (GdkXEvent *)xev;
  GtkIIIMInfo *info = data;
  SwitcherInfo *sw_info = im_info_get_switcher_info (info);

  if (sw_info != NULL)
    {
      switch (event->type)
       {
       case SelectionClear:
         sw_info->switcher = NULL;
         sw_info->switcher_x_window = None;
         g_free (sw_info);
         im_info_set_switcher_info (info, NULL);
         break;
       default:
         break;
       }
    }
  return GDK_FILTER_CONTINUE;
}

Here is the call graph for this function:

Here is the caller graph for this function: