Back to index

im-sdk  12.3.91
Functions
iiimpSwitcher.h File Reference
#include "iiimpIM.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

Bool im_switcher_active (XimCommon im)
Bool im_switcher_new (XimCommon im)
void im_switcher_shutdown (XimCommon im)
void ic_switcher_new (XicCommon ic)
void ic_switcher_finalize (XicCommon ic)
void ic_switcher_set_language_list (XicCommon ic, IIIMCF_language *lang_list, int n_lang)
void ic_switcher_set_status_text (XicCommon ic, char *utf8)
void ic_switcher_set_focus (XicCommon ic)
void ic_switcher_set_input_language (XicCommon ic, char *input_lang)
void ic_switcher_set_conversion_mode (XicCommon ic)
void ic_switcher_set_hotkey (XicCommon, char *)
char * ic_switcher_get_hotkey_with_type (char *, char *)
char * ic_switcher_get_hotkey (XicCommon)
void ic_switcher_change_hotkey_with_type (XicCommon, char *, char *)
char * ic_switcher_get_hotkey_with_atom (XicCommon)

Function Documentation

void ic_switcher_change_hotkey_with_type ( XicCommon  ,
char *  ,
char *   
)

Definition at line 782 of file iiimpSwitcher.c.

{
  int num_keys;
  IIIMCF_keyevent *keys;

  convert_hotkey_to_IIIMCF_keyevent (string, &num_keys, &keys);

  change_hotkey_with_type (ic, type, num_keys, keys);

  free (keys);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 296 of file iiimpSwitcher.c.

{
  SwitcherContext *w = ic->switcher_context;
  XimCommon im = (XimCommon)ic->core.im;
  Display *display = im->core.display;

  if (w == NULL)
    return;

  _XUnregisterFilter(display, w->invisible,
                   property_notify_switcher_window, (XPointer)ic);
  _XUnregisterFilter(display, w->invisible,
                   destroy_switcher_window, (XPointer)ic);

  XDestroyWindow (display, w->invisible);

  Xfree (w);
  ic->switcher_context = NULL;
  return;

}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 608 of file iiimpSwitcher.c.

{
  IIIMCF_context context = XIC_IIIMP (ic, context);
  int num_hotkey = 0, i;
  IIIMCF_hotkey *hotkeys = NULL;
  char s[512], *p = s;

  iiimcf_get_hotkeys (context, &num_hotkey, &hotkeys);

  if (num_hotkey == 0) return NULL;

  memset (s, 0, 512);

  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;
         unsigned int keyval;
         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+");
           }

         keyval = i2gcode (key->keycode);
         keyname = x11_keyval_name (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:

Definition at line 797 of file iiimpSwitcher.c.

{
  Display *display = ic->core.im->core.display;
  XimCommon im = (XimCommon)ic->core.im;
  SwitcherInfo *sw_info = im->switcher_info;
  int format;
  unsigned long length, nitem;
  unsigned char *data = NULL;
  Atom type;
   
  if (!im_switcher_active (im))
    return NULL;

  XGetWindowProperty (display,
                    sw_info->switcher_window,
                    sw_info->set_hotkey_atom,
                    0L, 1000000L, False,
                    sw_info->set_hotkey_atom,
                    &type, &format, &nitem, &length, &data);

  return data;
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* ic_switcher_get_hotkey_with_type ( char *  ,
char *   
)

Definition at line 583 of file iiimpSwitcher.c.

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

  num_hotkeys = my_strv_length (hotkeys) / 2;

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

  my_strfreev (hotkeys);

  return keys;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void ic_switcher_new ( XicCommon  ic)

Definition at line 270 of file iiimpSwitcher.c.

{
  SwitcherContext *w = Xmalloc(sizeof(SwitcherContext));
  XimCommon im = (XimCommon)ic->core.im;
  Display *display = im->core.display;

  if (w == NULL)
    return;

  memset(w, 0, sizeof(SwitcherContext));

  w->invisible = XCreateSimpleWindow(display, DefaultRootWindow(display),
                                 0, 0, 1, 1, 0, 0, 0);
  XSelectInput(display, w->invisible,
              PropertyChangeMask| StructureNotifyMask);

  _XRegisterFilterByType(display, w->invisible,
                      PropertyNotify, PropertyNotify,
                      property_notify_switcher_window, (XPointer)ic);
  _XRegisterFilterByType(display, w->invisible,
                      DestroyNotify, DestroyNotify,
                      destroy_switcher_window, (XPointer)ic);
  ic->switcher_context = w;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 487 of file iiimpSwitcher.c.

{
  Display *display = ic->core.im->core.display;
  XimCommon im = (XimCommon)ic->core.im;
  SwitcherInfo *sw_info = im->switcher_info;
  IIIMF_status st;
  int conversion_mode = CONV_OFF;

  if (sw_info == NULL || sw_info->switcher_window == None)
    return;

  st = iiimcf_get_current_conversion_mode (XIC_IIIMP(ic, context),
                                      &conversion_mode);
  XChangeProperty (display,
                 sw_info->switcher_window,
                 sw_info->set_conversion_mode_atom,
                 sw_info->set_conversion_mode_atom,
                 32,
                 PropModeReplace,
                 (unsigned char *)&conversion_mode,
                 1);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 412 of file iiimpSwitcher.c.

{
  Display *display = ic->core.im->core.display;
  XimCommon im = (XimCommon)ic->core.im;
  SwitcherInfo *sw_info;
  SwitcherContext *w;

  if (!im_switcher_active (im))
    {
      im_switcher_new (im);
      if (!im_switcher_active (im))
       return;
    }

  if (ic->switcher_context == NULL)
    ic_switcher_new (ic);

  w = ic->switcher_context;
  sw_info = im->switcher_info;

  if (w && w->invisible)
    XConvertSelection (display,
                     sw_info->selection_atom,
                     sw_info->set_current_client_atom,
                     sw_info->set_current_client_atom,
                     w->invisible,
                     CurrentTime);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void ic_switcher_set_hotkey ( XicCommon  ,
char *   
)

Definition at line 442 of file iiimpSwitcher.c.

{
  Display *display = ic->core.im->core.display;
  XimCommon im = (XimCommon)ic->core.im;
  SwitcherInfo *sw_info = im->switcher_info;

  if (!sw_info || !hotkey) return;

  XChangeProperty (display,
                 sw_info->switcher_window,
                 sw_info->set_hotkey_atom,
                 sw_info->set_hotkey_atom,
                 8,
                 PropModeReplace,
                 (unsigned char *)hotkey,
                 strlen (hotkey));
}

Here is the caller graph for this function:

void ic_switcher_set_input_language ( XicCommon  ic,
char *  input_lang 
)

Definition at line 461 of file iiimpSwitcher.c.

{
  Display *display = ic->core.im->core.display;
  XimCommon im = (XimCommon)ic->core.im;
  SwitcherInfo *sw_info = im->switcher_info;

  if (sw_info == NULL)
    return;

  if (input_lang == NULL)
    input_lang = ic->current_language;

  if (input_lang == NULL)
    return;

  XChangeProperty (display,
                 sw_info->switcher_window,
                 sw_info->set_current_input_language_atom,
                 sw_info->set_current_input_language_atom,
                 8,
                 PropModeReplace,
                 (unsigned char *)input_lang,
                 strlen (input_lang));
}

Here is the caller graph for this function:

void ic_switcher_set_language_list ( XicCommon  ic,
IIIMCF_language lang_list,
int  n_lang 
)

Definition at line 319 of file iiimpSwitcher.c.

{
  Display *display = ic->core.im->core.display;
  XimCommon im = (XimCommon)ic->core.im;
  SwitcherInfo *sw_info = im->switcher_info;
  char *languages;
  char *ptr;
  IIIMF_status st;
  char *langid;
  int i;
  size_t len;
  const char *separator = ";";
  size_t separator_len;

  if (sw_info == NULL)
    return;

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

  if (sw_info->switcher_window == None)
    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 = Xmalloc (sizeof(char) * (len + 1));
  if (languages == NULL)
    return;
  memset(languages, 0, sizeof(char) * (len + 1));

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

  XChangeProperty (display, sw_info->switcher_window,
                 sw_info->set_input_language_list_atom,
                 sw_info->set_input_language_list_atom,
                 8,
                 PropModeReplace,
                 (unsigned char*)languages, len);
  Xfree (languages);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void ic_switcher_set_status_text ( XicCommon  ic,
char *  utf8 
)

Definition at line 391 of file iiimpSwitcher.c.

{
  Display *display = ic->core.im->core.display;
  XimCommon im = (XimCommon)ic->core.im;
  SwitcherInfo *sw_info = im->switcher_info;

  if (sw_info == NULL || sw_info->switcher_window == None ||
      utf8 == NULL)
    return;

  XChangeProperty (display,
                 sw_info->switcher_window,
                 sw_info->set_status_text_atom,
                 sw_info->set_status_text_atom,
                 8,
                 PropModeReplace,
                 (unsigned char *)utf8,
                 strlen (utf8));
}

Here is the caller graph for this function:

Definition at line 131 of file iiimpSwitcher.c.

{
  SwitcherInfo *sw_info = im->switcher_info;

  return (sw_info && (sw_info->switcher_window));
}

Here is the caller graph for this function:

Definition at line 156 of file iiimpSwitcher.c.

{
  Display *display = im->core.display;
  SwitcherInfo *sw_info = im->switcher_info;
  Window owner = None;

  if (sw_info == NULL)
    {
      sw_info = Xmalloc (sizeof(SwitcherInfo));
      if (sw_info == NULL)
       return False;
      memset(sw_info, 0, sizeof(SwitcherInfo));
      im->switcher_info = sw_info;
    }

  if (selection == None)
    selection  = XInternAtom (display, "_IIIM_SWITCHER", False);

  sw_info->selection_atom = selection;

  owner = XGetSelectionOwner (display, selection);
  if (owner == None)
    return False;

  sw_info->switcher_window = owner;

  _XRegisterFilterByType (display, owner,
                       DestroyNotify, DestroyNotify,
                       filter_destroy_event, (XPointer)im);

  XSelectInput (display, owner, StructureNotifyMask);

  sw_info->set_current_input_language_atom
    = XInternAtom (display, "_IIIM_SWITCHER_CURRENT_INPUT_LANGUAGE", False);

  sw_info->set_current_client_atom =
    XInternAtom (display, "_IIIM_SWITCHER_CURRENT_CLIENT", False);

  sw_info->set_status_text_atom =
    XInternAtom (display, "_IIIM_SWITCHER_STATUS_TEXT", False);

  sw_info->set_input_language_list_atom =
    XInternAtom (display, "_IIIM_SWITCHER_INPUT_LANGUAGE_LIST", False);

  sw_info->set_conversion_mode_atom = 
    XInternAtom (display, "_IIIM_SWITCHER_SET_CONVERSION_MODE", False);

  sw_info->set_hotkey_atom =
    XInternAtom (display, "_IIIM_SWITCHER_SET_HOTKEY", False);

  return True;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 210 of file iiimpSwitcher.c.

{
  SwitcherInfo *sw_info = im->switcher_info;
  Display *display = im->core.display;

  if (sw_info && sw_info->switcher_window)
    _XUnregisterFilter (display, sw_info->switcher_window,
                     filter_destroy_event, (XPointer)im);
}

Here is the call graph for this function:

Here is the caller graph for this function: