Back to index

im-sdk  12.3.91
Functions | Variables
commonIM.c File Reference
#include <stdio.h>
#include "commonIM.h"
#include "guiIM.h"
#include "iiimpDL.h"
#include "popupIM.h"
#include "XimpIm.h"
#include "ximp40.h"
#include "trace_message.h"

Go to the source code of this file.

Functions

static int CommonIM_Error_Handler (Display *dpy, XErrorEvent *event)
Status CommonOpenIM (XIM xim, XLCd lcd, Display *dpy, XrmDatabase rdb, char *res_name, char *res_class)
Status CommonCloseIM (XIM xim)
Status CommonCreateIC (XIC xic, XIMArg *arg)
Status CommonDestroyIC (XIC xic)

Variables

static XErrorHandler appl_error_handler = (XErrorHandler)NULL

Function Documentation

Status CommonCloseIM ( XIM  xim)

Definition at line 187 of file commonIM.c.

{
    XimCommon im = (XimCommon)xim;

#if 0
    XIC ic;
    for (ic = xim->core.ic_chain; ic; ic = ic->core.next)
       XDestroyIC(ic);
#endif

    if (im->mtow_conv)
       _XlcCloseConverter(im->mtow_conv);

    if (im->wtom_conv)
       _XlcCloseConverter(im->wtom_conv);

    if (im->ximp_impart) {
       Ximp_CloseIM(im->ximp_impart);
    }

    if (im->popup_impart) ClosePopupIM(im);

    if (im->dl_impart) {
       CloseDynamicObject(im->dl_impart);
    }
    if (im->core.res_name) Xfree(im->core.res_name);
    if (im->core.res_class) Xfree(im->core.res_class);

    return True;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Status CommonCreateIC ( XIC  xic,
XIMArg arg 
)

Definition at line 221 of file commonIM.c.

{
    XicCommon ic = (XicCommon)xic;

    /* ximp icpart */
    if (!ic->ximp_icpart) {
       ic->ximp_icpart = (XICXimp)Xmalloc(sizeof(XICXimpRec));
       if (!ic->ximp_icpart) goto Error;;
       memset(ic->ximp_icpart, 0, sizeof(XICXimpRec));
    }
    if (!ic->gui_icpart) {
       if (!(ic->gui_icpart = CreateGUI(ic, arg))) goto Error;
    }
    return True;
Error:
    CommonDestroyIC((XIC)ic);
    return False;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Status CommonDestroyIC ( XIC  xic)

Definition at line 244 of file commonIM.c.

{
    XicCommon ic = (XicCommon)xic;
    if (ic->ximp_icpart) Xfree(ic->ximp_icpart);
    ic->ximp_icpart = 0;
    if (ic->gui_icpart) DestroyGUI(ic); /* destroy gui */
    ic->gui_icpart = 0;
    return True;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int CommonIM_Error_Handler ( Display *  dpy,
XErrorEvent *  event 
) [static]

Definition at line 70 of file commonIM.c.

{
    extern int _XDefaultError();

    if (appl_error_handler &&
       appl_error_handler != _XDefaultError) {
       return appl_error_handler(dpy, event);
    } else {
       char buffer[BUFSIZE];
       char number[32];

       if (event->request_code < 128) {
           if (event->error_code == BadDrawable || event->error_code == BadWindow) {
              snprintf(number, sizeof(number), "%d", event->request_code);
              XGetErrorDatabaseText(dpy, "XRequest", number,
                                  "", buffer, BUFSIZE);
           }
           /* 4378199: Linux Htt: can not operate after WMDoc client is
              closed on VineLinux2.0
              Need to check client_window is valid or not before creating
              status, preedit and lookup

              XFactoryCheckIMWindow() uses XGetGeometry() for checking.
              XGetGeometry() may generate BadDrawable or BadDrawable
           */
           if (event->error_code == BadDrawable) {
              if (!strcmp(buffer, "X_GetGeometry"))
                  return 0;
           } else if (event->error_code == BadWindow) {
              return 0;
#if 0
              if (!strcmp(buffer, "X_SendEvent"))
                  return 0;
              if (!strcmp(buffer, "X_GetGeometry"))
                  return 0;
              if (!strcmp(buffer, "X_GetWindowAttributes"))
                  return 0;
              if (!strcmp(buffer, "X_ChangeWindowAttributes"))
                  return 0;
              if (!strcmp(buffer, "X_ClearArea"))
                  return 0;
              if (!strcmp(buffer, "X_DestroyWindow"))
                  return 0;
              if (!strcmp(buffer, "X_GetProperty"))
                  return 0;
#endif
           }
       }
    }

    return _XDefaultError(dpy, event);
}

Here is the caller graph for this function:

Status CommonOpenIM ( XIM  xim,
XLCd  lcd,
Display *  dpy,
XrmDatabase  rdb,
char *  res_name,
char *  res_class 
)

Definition at line 127 of file commonIM.c.

{
    XimCommon im = (XimCommon)xim;

    TRACE_MESSAGE_INIT(NULL);

    /* Open mbs->wcs and wcs->mbs converters */
    if (!(im->wtom_conv = _XlcOpenConverter(lcd, XlcNWideChar,
                                       lcd, XlcNMultiByte))) {
       goto Set_Error;
    }
    if (!(im->mtow_conv = _XlcOpenConverter(lcd, XlcNMultiByte,
                                       lcd, XlcNWideChar))) {
       goto Set_Error;
    }
    im->core.lcd       = lcd;
    im->core.ic_chain  = (XIC)NULL;
    im->core.display   = dpy;
    im->core.rdb       = rdb;
    im->core.res_name  = NULL;
    im->core.res_class = NULL;
    im->core.im_name   = NULL;

    if ((res_name != NULL) && (*res_name != '\0')){
       im->core.res_name  = (char *)Xmalloc(strlen(res_name)+1);
       strcpy(im->core.res_name,res_name);
    }
    if ((res_class != NULL) && (*res_class != '\0')){
       im->core.res_class = (char *)Xmalloc(strlen(res_class)+1);
       strcpy(im->core.res_class,res_class);
    }

    /* set XIMP-dependent data */
    im->ximp_impart = (XIMXimp)Ximp_OpenIM(lcd);

    /* set dynamic loadble object data */
    im->dl_impart = OpenDynamicObject(lcd);

#if 1
    /* set error handler only once */
    if (appl_error_handler == (XErrorHandler)NULL)
       appl_error_handler = XSetErrorHandler(CommonIM_Error_Handler);
#endif

    return True;

Set_Error:
    if (im)
       CommonCloseIM((XIM)im);
    return False;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

XErrorHandler appl_error_handler = (XErrorHandler)NULL [static]

Definition at line 68 of file commonIM.c.