Back to index

im-sdk  12.3.91
Classes | Typedefs | Functions
guiIMSts.h File Reference
#include "guiIM.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _StatusWinRec

Typedefs

typedef void(* StatusCB )(XicCommon, XPointer)
typedef struct _StatusWinRec StatusWinRec

Functions

Bool SetupStatusExt (XicCommon)
Bool SetupStatusWindow (XicCommon, Window)
void SetStatusForeground (XicCommon, XPointer)
void SetStatusBackground (XicCommon, XPointer)
void SetStatusFont (XicCommon, XPointer)
void StatusStart (XicCommon, XPointer)
void StatusDrawText (XicCommon, XPointer)
void StatusDone (XicCommon, XPointer)
void DestroyStatus (XicCommon, XPointer)

Class Documentation

struct _StatusWinRec

Definition at line 49 of file guiIMSts.h.

Collaboration diagram for _StatusWinRec:
Class Members
IMFeedbackList * feedback
XFontSet fontset
GC gc
int len
Bool need_free_fontset
Window parent
CacheRec status_cache
char * status_string
XIMText text
Window window
int x
int y

Typedef Documentation

typedef void(* StatusCB)(XicCommon, XPointer)

Definition at line 47 of file guiIMSts.h.

typedef struct _StatusWinRec StatusWinRec

Function Documentation

void DestroyStatus ( XicCommon  ,
XPointer   
)

Definition at line 600 of file guiIMSts.c.

                                                {
  StatusWin status = (StatusWin)(ic->gui_icpart->status);

  if (!status) return;

  if (status->fontset && status->need_free_fontset) {
    XFactoryFreeDefaultFontSet (ic->core.im->core.display);
    status->need_free_fontset = False;
  }
  _XUnregisterFilter(ic->core.im->core.display, status->window,
                   RepaintStatus, (XPointer)ic);
#if defined(USE_FILTER_KEY_PRESS_IN_STATUS)
  _XUnregisterFilter(ic->core.im->core.display, status->window,
                   FilterKeyPress, (XPointer)ic);
#endif /* USE_FILTER_KEY_PRESS_IN_STATUS */
  if (status->window) {
    if (IMCheckIMWindow(ic, status->window)) {
      XDestroyWindow(ic->core.im->core.display, status->window);
    }
    status->window = 0;
  }

  if (status->gc) XFreeGC(ic->core.im->core.display, status->gc);
#ifdef USE_STATUS_FEEDBACK
  if (status->rgc) XFreeGC(ic->core.im->core.display, status->rgc);
#endif
  if (status->text.string.multi_byte) {
    Xfree(status->text.string.multi_byte);
  }
  FreeFeedbackList(status->feedback, status->text.length);
  status->feedback = NULL;
  
  Xfree(status->status_string);
  Xfree(status);
  ic->gui_icpart->status = (StatusWin)NULL;
  return;
}

Here is the call graph for this function:

Definition at line 442 of file guiIMSts.c.

                                                      { 
  StatusWin status = (StatusWin)(ic->gui_icpart->status);
  CacheRec *status_cache;

  if (!status) return;  /* Let's do it later */

  status_cache = (CacheRec*)&(status->status_cache);

  if (status_cache->background == ic->core.status_attr.background) {
    return;
  }
  if (status->gc) {
    XGCValues val;
    unsigned long mask;
    val.background = ic->core.status_attr.background;
    mask = GCBackground;
    XChangeGC(ic->core.im->core.display,
             status->gc,
             mask,
             &val);
  }
#ifdef USE_STATUS_FEEDBACK
  if (status->rgc) {
    XGCValues val;
    unsigned long mask;
    val.foreground = ic->core.status_attr.background;
    mask = GCForeground;
    XChangeGC(ic->core.im->core.display,
             status->rgc,
             mask,
             &val);
  }
#endif
  status_cache->background = ic->core.status_attr.background;

  if (status->window) {
    XSetWindowBackground(ic->core.im->core.display, status->window,
                      ic->core.status_attr.background);
  }
  return;
}
void SetStatusFont ( XicCommon  ,
XPointer   
)

Definition at line 485 of file guiIMSts.c.

                                                {
  StatusWin status = (StatusWin)(ic->gui_icpart->status);

  if (!status) return;  /* Let's do it later */

  if (ic->core.status_attr.fontset) {
    if (status->fontset && status->need_free_fontset) {
      XFactoryFreeDefaultFontSet (ic->core.im->core.display);
      status->need_free_fontset = False;
    }
    /* need to clear status cache */
    status->fontset = ic->core.status_attr.fontset;
    status->len = 0;
    status->status_string = NULL;
  } else if (status->fontset == NULL) {
    status->fontset = XFactoryCreateDefaultFontSet(ic->core.im->core.display,
                                             XIM_IIIMP (ic->core.im, default_font_name));
    status->need_free_fontset = True;
  }
  return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 404 of file guiIMSts.c.

                                                      {
  StatusWin status = (StatusWin)(ic->gui_icpart->status);
  CacheRec *status_cache;

  if (!status) return;  /* Let's do it later */

  status_cache = (CacheRec*)&(status->status_cache);

  if (status_cache->foreground == ic->core.status_attr.foreground) {
    return;
  }
  if (status->gc) {
    XGCValues val;
    unsigned long mask;
    val.foreground = ic->core.status_attr.foreground;
    mask = GCForeground;
    XChangeGC(ic->core.im->core.display,
             status->gc,
             mask,
             &val);
  }
#ifdef USE_STATUS_FEEDBACK
  if (status->rgc) {
    XGCValues val;
    unsigned long mask;
    val.background = ic->core.status_attr.foreground;
    mask = GCBackground;
    XChangeGC(ic->core.im->core.display,
             status->rgc,
             mask,
             &val);
  }
#endif
  status_cache->foreground = ic->core.status_attr.foreground;
  return;
}

Definition at line 167 of file guiIMSts.c.

                             {
  StatusWin status = (StatusWin)Xmalloc(sizeof(StatusWinRec));

  if (!status) return True;
  memset((char *)status, 0, sizeof(StatusWinRec));

  memset(&status->status_cache, 0, sizeof(CacheRec));

  status->need_free_fontset = False;

  ic->gui_icpart->status = (void *)status;
  return True;
}

Here is the caller graph for this function:

Bool SetupStatusWindow ( XicCommon  ,
Window   
)

Definition at line 273 of file guiIMSts.c.

                                               {
  Window win;
  StatusWin status = (StatusWin)(ic->gui_icpart->status);
  int x, y;
  unsigned int width, height;
  unsigned long fg, bg;
  XWindowAttributes attr;
  Display *display = ic->core.im->core.display;
  XIMFilterRec filters[4];
  int n;
  unsigned int event_mask;
  extern Bool popup_button_press(Display *d, Window w, XEvent *ev,
                             XPointer client_data);

  if (XIMP_CHK_STSAREAMASK(ic)) {
    x = ic->core.status_attr.area.x;
    y = ic->core.status_attr.area.y;
    width   = ic->core.status_attr.area.width;
    height  = ic->core.status_attr.area.height;
  } else {
    x  = y = 0;
    width = height = 1;
  }
  if (width == 0 || height == 0) return False;

  if (!XIMP_CHK_STSBGMASK(ic) || !XIMP_CHK_STSFGMASK(ic)) 
    XGetWindowAttributes(display, 
                      ic->core.client_window,
                      &attr);

  if (XIMP_CHK_STSBGMASK(ic)) 
    bg = ic->core.status_attr.background;
  else if (XIMP_CHK_PREBGMASK(ic))
    bg = ic->core.preedit_attr.background;
  else
    bg = WhitePixel(display, XScreenNumberOfScreen(attr.screen));

  if (XIMP_CHK_STSFGMASK(ic))
    fg = ic->core.status_attr.foreground;
  else if (XIMP_CHK_PREFGMASK(ic))
    /* Motif does not set ic value for white status foreground color,
       so this is workaround. (#4290814)
    */
    fg = ic->core.preedit_attr.foreground;
  else
    fg = BlackPixel(display, XScreenNumberOfScreen(attr.screen));

  /* A new parent window is the same as the previous, nothing to do. */
  if (parent == 0 || status->parent == parent) return False;

  status->parent = parent;

  event_mask = None;

  n = 0;
#if defined(USE_FILTER_KEY_PRESS_IN_STATUS)
  filters[n].type = KeyPress;
  filters[n].filter = FilterKeyPress;
  filters[n].client_data = (XPointer)ic;
  n++;
  event_mask |= KeyPressMask;
#endif /* USE_FILTER_KEY_PRESS_IN_STATUS */
  filters[n].type = Expose;
  filters[n].filter = RepaintStatus;
  filters[n].client_data = (XPointer)ic;
  n++;
  event_mask |= ExposureMask;

  if (XIM_IS_SWITCH(ic->core.im) || XIM_IS_COMPOSE(ic->core.im)) {
    filters[n].type = ButtonPress;
    filters[n].filter = popup_button_press;
    filters[n].client_data = (XPointer)(ic);
    n++;
    event_mask |= ButtonPressMask;
    filters[n].type = ButtonRelease;
    filters[n].filter = popup_button_press;
    filters[n].client_data = (XPointer)(ic);
    n++;
    event_mask |= ButtonReleaseMask;
    event_mask |= PointerMotionMask;
  }
  if (!status->window) {
    XClassHint class_hint;
    win = XFactoryCreateIMWindow(display, parent, ic->core.client_window,
                             x, y, width, height, bg,
                             event_mask,
                             filters, n);

    if (!win) return False;

    /* remove all of the window decoration */
    XFactoryRemoveAllDecoration(display, win);

    if (ic->core.input_style & XIMStatusArea) {
      /* set override-redirect to true */
      XSetWindowAttributes attributes;
      int cmask = 0;
      cmask |= CWOverrideRedirect;
      attributes.override_redirect = True;
      XChangeWindowAttributes(ic->core.im->core.display, win,
                           cmask, &attributes);
    }

    XStoreName(display, win, "iiimx IM Status");

    class_hint.res_name = "iiimx-im-status";
    class_hint.res_class = "IiimxImStatus";
    XSetClassHint(display, win, &class_hint);

    status->window = win;
  }
#if 0
 {
   unsigned long val_mask;
   XGCValues gcval;
   val_mask = GCForeground | GCBackground;
   gcval.foreground = fg;
   gcval.background = bg;
   status->gc = XCreateGC(display, win, val_mask, &gcval);
 }
#ifdef USE_STATUS_FEEDBACK
  gcval.foreground = bg;
  gcval.background = fg;
  status->rgc = XCreateGC(display, win, val_mask, &gcval);
#endif
#endif

  return True;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void StatusDone ( XicCommon  ,
XPointer   
)

Definition at line 594 of file guiIMSts.c.

                                             {
  /* do nothing */
  
}
void StatusDrawText ( XicCommon  ,
XPointer   
)

Definition at line 513 of file guiIMSts.c.

                                                 {
  StatusWin status = (StatusWin)(ic->gui_icpart->status);
  XIMDrawTextStruct *status_draw = (XIMDrawTextStruct*)call_data;
  XIMText *text = (XIMText*)status_draw->call_data;
  IMFeedbackList *feedback_list = status_draw->feedback_list;

  if (text == (XIMText*)NULL || text->length == 0 ||
      text->string.multi_byte == NULL) {
    /* unmap the status window if no valid status */
    Display *display = ic->core.im->core.display;

    if (status->window)
      XUnmapWindow(display, status->window);

    return;
  }

  if (!status) {
    XIC_GUI(ic, change_status)((XIC)ic, STATUS_CREATE, NULL);
    status = (StatusWin)(ic->gui_icpart->status);
    if (!status) return;
  }
  if (status->text.string.multi_byte) {
    Xfree(status->text.string.multi_byte);
  }

  if (feedback_list) {
    /* copy feedback_list */
    if (status->feedback) {
      IMFeedbackList *p;
      for (p = status->feedback; p < &status->feedback[status->text.length]; p++) {
       if (p->feedbacks) Xfree(p->feedbacks);
      }
      Xfree(status->feedback);
      status->feedback = 0;
    }
    status->feedback = Xmalloc(sizeof(IMFeedbackList) * text->length);
    if (status->feedback) {
      IMFeedbackList *from, *to;
      for (to = status->feedback, from = feedback_list;
          to < &status->feedback[text->length];
          to++, from++) {
       to->count_feedbacks = from->count_feedbacks;
       to->feedbacks = Xmalloc(sizeof(IMFeedback) * to->count_feedbacks);
       if (to->feedbacks) {
         IMFeedback *p, *q;
         for (p = to->feedbacks, q = from->feedbacks;
              p < &to->feedbacks[to->count_feedbacks];
              p++, q++) {
           p->type = q->type;
           p->value = q->value;
         }
       } else {
         /* error */
         Xfree(status->feedback);
         return;
       }
      }
    } else {
      /* error */
      return;
    }
  } else {
    if (NULL != status->feedback) {
      FreeFeedbackList(status->feedback, status->text.length);
      status->feedback = NULL;
    }
  }
  memmove(&(status->text), text, sizeof(XIMText));
  if (text->string.multi_byte == NULL) {
    status->text.string.multi_byte = NULL;
  } else {
    status->text.string.multi_byte = (char*)strdup(text->string.multi_byte);
  }
  XIC_GUI(ic, change_status)((XIC)ic, STATUS_WIN, NULL);

  UpdateStatus(ic, True);
  return;
}

Here is the call graph for this function:

void StatusStart ( XicCommon  ,
XPointer   
)

Definition at line 508 of file guiIMSts.c.

                                              {
  return;
}