Back to index

im-sdk  12.3.91
Functions | Variables
guiIMPrePos.c File Reference
#include "xiiimp.h"
#include "guiIMPre.h"
#include "XimpIm.h"
#include "trace_message.h"

Go to the source code of this file.

Functions

static void create (XicCommon ic, XPointer call_data)
static int preedit_line_num (unsigned short *wcstr_width, int len, int area_width, int first_line_x_offset)
static int preedit_line_num_rev (unsigned short *wcstr_width, int len, int area_width)
static Bool PreeditWindowChanged (XicCommon ic, PreeditArea preedit_area)
static void ConfigurePreeditWindow (XicCommon ic, PreeditArea preedit_area, int x, int y, int width, int height)
static int set_window_forward (XicCommon ic, int len, int area_width, int area_x, int first_line_x_offset, int spot_loc_x, int spot_loc_y, int line_spacing)
static int set_window_backward (XicCommon ic, int len, int area_width, int area_height, int area_x, int area_y, int spot_loc_y, int line_spacing, int line_num)
static int set_window_full (XicCommon ic, int len, int area_width, int area_x, int spot_loc_x, int spot_loc_y, int line_spacing)
static void set_window (XicCommon ic, XPointer call_data)
static void move (XicCommon ic, XPointer call_data)
void ChangePreeditPosition (XIC xic, PreeditAttr reason, XPointer call_data)

Variables

static PreeditCB preedit_pos_methods []

Function Documentation

void ChangePreeditPosition ( XIC  xic,
PreeditAttr  reason,
XPointer  call_data 
)

Definition at line 846 of file guiIMPrePos.c.

                                                                       {
  XicCommon ic = (XicCommon)xic;
  if (reason > PREEDIT_DESTROY) return;
  preedit_pos_methods[reason](ic, call_data);
  return;
}

Here is the caller graph for this function:

static void ConfigurePreeditWindow ( XicCommon  ic,
PreeditArea  preedit_area,
int  x,
int  y,
int  width,
int  height 
) [static]

Definition at line 243 of file guiIMPrePos.c.

                                                          {
  XWindowChanges changes;
  int  mask;
  mask = None;

  if (preedit_area->win_config.x != x) {
    mask |= CWX;
    changes.x = x;
    preedit_area->win_config.x = x;
  }
  if (preedit_area->win_config.y != y) {
    mask |= CWY;
    changes.y = y;
    preedit_area->win_config.y = y;
  }
  if (preedit_area->win_config.height != height) {
    mask |= CWHeight;
    changes.height = height;
    if (preedit_area->win_config.height < height) {
      XIC_GUI(ic, preedit)->discard_expose_event = True;
    }
    preedit_area->win_config.height = height;
  }
  if (preedit_area->win_config.width != width) {
    mask |= CWWidth;
    changes.width = width;
    if (preedit_area->win_config.width < width) {
      XIC_GUI(ic, preedit)->discard_expose_event = True;
    }
    preedit_area->win_config.width = width;
  }
  if (None != mask) {
    XConfigureWindow(ic->core.im->core.display, preedit_area->window,
                   mask, &changes);
    preedit_area->configured = True;
  } else if (True == PreeditWindowChanged(ic, preedit_area)) {
    /* force UpdatePreedit() to update preedit */
    preedit_area->configured = True;
  }

  return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void create ( XicCommon  ic,
XPointer  call_data 
) [static]

Definition at line 79 of file guiIMPrePos.c.

                                         {
  PreeditWin preedit = (PreeditWin)ic->gui_icpart->preedit;

  TRACE_MESSAGE('p', ("iiimpPrePos:create\n"));
  if (!preedit) {
    SetupPreeditExt(ic);
    preedit = (PreeditWin)ic->gui_icpart->preedit;
  }

  if (!XIMP_CHK_FOCUSWINMASK(ic)) return;

  if (preedit->parent == ic->core.focus_window &&
      preedit->preedit_areas) {
    /* same parent window */
    return;
  }

  SetupPreeditWindow(ic, ic->core.focus_window);
#if 0 /* 4281121: htt_xbe dumps core in DestroyFilter() at client is exiting */
  /* register destroy filter for focus_window */
  _XRegisterFilterByType(ic->core.im->core.display, ic->core.focus_window,
                      DestroyNotify, DestroyNotify,
                      DestroyFilter, (XPointer)ic);
#endif /* 0 */
  return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void move ( XicCommon  ic,
XPointer  call_data 
) [static]

Definition at line 823 of file guiIMPrePos.c.

                                       {
  set_window(ic, NULL);
  if (NULL != XIC_GUI(ic, preedit)) {
    XIC_GUI(ic, preedit)->discard_expose_event = False;
  }
  return;
}

Here is the call graph for this function:

static int preedit_line_num ( unsigned short *  wcstr_width,
int  len,
int  area_width,
int  first_line_x_offset 
) [static]

Definition at line 109 of file guiIMPrePos.c.

                                                        {
  int i;
  int max_line_width;
  int line_width;
  int line_width_new;
  int line_num;

  for (i = 0, line_num = 0; i < len; line_num++) {
    if (0 == line_num) {
      max_line_width = (area_width - first_line_x_offset);
    } else {
      max_line_width = area_width;
    }
    line_width = 0;
    for (; i < len; i++) {
      line_width_new = (line_width + *(wcstr_width + i));
      if (max_line_width < line_width_new) {
       if ((0 == line_width) && (area_width < line_width_new)) {
         /* If the width of a character is wider than area_width,
          * it consists one line.
          */
         i += 1;
       }
       break;
      }
      line_width = line_width_new;
    }
  }

  return line_num;
}

Here is the caller graph for this function:

static int preedit_line_num_rev ( unsigned short *  wcstr_width,
int  len,
int  area_width 
) [static]

Definition at line 143 of file guiIMPrePos.c.

                                                                            {
  int i;
  int line_width;
  int line_width_new;
  int line_num;

  for (i = (len - 1), line_num = 0; 0 <= i; line_num++) {
    line_width = 0;
    for (; 0 <= i; --i) {
      line_width_new = (line_width + *(wcstr_width + i));
      if (area_width < line_width_new) {
       if (0 == line_width) {
         /* If the width of a character is wider than area_width,
          * it consists one line.
          */
         i -= 1;
       }
       break;
      }
      line_width = line_width_new;
    }
  }

  return line_num;
}

Here is the caller graph for this function:

static Bool PreeditWindowChanged ( XicCommon  ic,
PreeditArea  preedit_area 
) [static]

Definition at line 170 of file guiIMPrePos.c.

                                                             {
    int char_offset;
    int char_len;
    int char_offset_backup;
    int char_len_backup;
    int i;
    int j;
    PreeditWin preedit;
    PreeditChars preedit_chars;
    PreeditChars preedit_chars_backup;
    wchar_t * wc;
    wchar_t * wc_backup;
    IMFeedbackList *fbl;
    IMFeedbackList *fbl_backup;
    IMFeedback  *fb;
    IMFeedback  *fb_backup;
    XIMFeedback *xfb;
    XIMFeedback *xfb_backup;

    preedit = ic->gui_icpart->preedit;
    preedit_chars = &(preedit->preedit_chars);
    preedit_chars_backup = &(preedit->preedit_chars_backup);

    if (((NULL == preedit_chars->feedback) &&
        (NULL != preedit_chars_backup->feedback)) ||
       ((NULL != preedit_chars->feedback) &&
        (NULL == preedit_chars_backup->feedback))) {
      return True;
    }

    char_offset = preedit_area->char_offset;
    char_len = preedit_area->char_len;

    char_offset_backup = preedit_area->char_offset_backup;
    char_len_backup = preedit_area->char_len_backup;

    wc = (preedit_chars->wchar + char_offset);
    wc_backup = (preedit_chars_backup->wchar + char_offset_backup);

    fbl = (preedit_chars->feedback_list + char_offset);
    fbl_backup = (preedit_chars_backup->feedback_list + char_offset_backup);

    xfb = (preedit_chars->feedback + char_offset);
    xfb_backup = (preedit_chars_backup->feedback + char_offset_backup);

    for (i = 0; i < preedit_area->char_len; i++) {
      if (*(wc + i) != *(wc_backup + i)) {
       return True;
      }

      if (*(xfb + i) != *(xfb_backup + i)) {
       return True;
      }

      if (fbl->count_feedbacks != fbl_backup->count_feedbacks) {
       return True;
      }

      fb = fbl->feedbacks;
      fb_backup = fbl_backup->feedbacks;

      for (j = 0; j < fbl->count_feedbacks; j++) {
       if (((fb + j)->type != (fb_backup + j)->type) ||
           ((fb + j)->value != (fb_backup + j)->value)) {
         return True;
       }
      }
    }

    return False;
}

Here is the caller graph for this function:

static void set_window ( XicCommon  ic,
XPointer  call_data 
) [static]

Definition at line 464 of file guiIMPrePos.c.

                                             {
  PreeditWin preedit;
  PreeditArea preedit_area;
  PreeditChars preedit_chars;
  XPoint * spot_location;
  XRectangle * preedit_attr_area;
  XFontSetExtents *fse;
  int line_spacing;
  int font_logical_height;
  int x, y, height = 0;
  int area_width;
  int area_height;
  int first_line_x_offset;
  int len;
  wchar_t *wcstr;
  unsigned short *wcstr_width;
  int line_num;

  if (!XIMP_CHK_FOCUSWINMASK(ic)) return;

  preedit = (PreeditWin)ic->gui_icpart->preedit;

  if (NULL == preedit) {
    create(ic, NULL);
    preedit = (PreeditWin)ic->gui_icpart->preedit;
    if (NULL == preedit) return;
  }

  preedit_area = preedit->preedit_areas;
  preedit_chars = &(preedit->preedit_chars);

  if (preedit_chars->wchar_len == 0) return;

  if (NULL == preedit->fontset) {
    SetPreeditFont(ic, NULL);
    if (NULL == preedit->fontset) return;
  }

  spot_location = &(ic->core.preedit_attr.spot_location);
  preedit_attr_area = &(ic->core.preedit_attr.area);

  height = 0;

  fse = preedit->fse;
  font_logical_height = fse->max_logical_extent.height;
  height = font_logical_height;
  height += (fse->max_ink_extent.height + fse->max_ink_extent.y);

  if (spot_location->x > preedit_attr_area->x) {
    x = spot_location->x;
  } else {
    x = preedit_attr_area->x;
  }
  y = (spot_location->y - font_logical_height);

  /* calculate area width */
  if (XIMP_CHK_PREAREAMASK(ic)) {
    area_width = preedit_attr_area->width;
    area_height = preedit_attr_area->height;
    first_line_x_offset = (spot_location->x - preedit_attr_area->x);

  } else {
    area_width = XIC_GUI(ic, preedit)->client_window_width;
    area_height = XIC_GUI(ic, preedit)->client_window_height;
    first_line_x_offset = spot_location->x;
  }

  TRACE_MESSAGE('p', ("set_window: width=%d height=%d\n",
              area_width, area_height));

  if (XIMP_CHK_PRELINESPMASK(ic)) {
    line_spacing = ic->core.preedit_attr.line_spacing;
    if (line_spacing > area_height)
      /* line_spacing is too large */
      line_spacing = font_logical_height;
  } else {
    line_spacing = font_logical_height;
  }

  len = preedit_chars->wchar_len;
  wcstr = preedit_chars->wchar;
  wcstr_width = preedit_chars->wchar_width;

  line_num = preedit_line_num(wcstr_width, preedit_chars->wchar_len,
                           area_width, first_line_x_offset);

  if ((line_spacing * line_num) <=
      ((area_height + preedit_attr_area->y) -
       (spot_location->y - font_logical_height))) {
    set_window_forward(ic, len, area_width, preedit_attr_area->x,
                     first_line_x_offset, 
                     spot_location->x, spot_location->y, line_spacing);
  } else {
    line_num = preedit_line_num_rev(wcstr_width, len, area_width);
    if ((line_spacing * line_num) <= area_height) {
      set_window_backward(ic, len, area_width, area_height,
                       preedit_attr_area->x, preedit_attr_area->y,
                       spot_location->y, line_spacing, line_num);
    } else {
      set_window_full(ic, len, area_width,
                    preedit_attr_area->x,
                    spot_location->x, spot_location->y, line_spacing);
    }
  }
  preedit->active_areas = line_num;

  return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int set_window_backward ( XicCommon  ic,
int  len,
int  area_width,
int  area_height,
int  area_x,
int  area_y,
int  spot_loc_y,
int  line_spacing,
int  line_num 
) [static]

Definition at line 369 of file guiIMPrePos.c.

                                                                  {
  PreeditWin preedit;
  PreeditArea preedit_area;
  PreeditChars preedit_chars;
  unsigned short * wcstr_width;
  int i;
  int line_width;
  int line_width_new;
  int line_height;
  int area_height_low;
  XFontSetExtents *fse;
  int font_logical_height;
  int char_tail;
  int x;
  int y;
  int num;

  preedit = ic->gui_icpart->preedit;
  preedit_chars = &(preedit->preedit_chars);
  wcstr_width = preedit_chars->wchar_width;
  fse = preedit->fse;
  font_logical_height = (-fse->max_ink_extent.y);
  line_height = (fse->max_logical_extent.height + 1);

  x = area_x;

  while (preedit->alloc_areas <= line_num) {
    if (False == NewPreeditWindow(ic)) return 0;
  }
  preedit_area = preedit->preedit_areas;

  area_height_low = ((area_height + area_y) -
                   (spot_loc_y - (-fse->max_logical_extent.y)));
  area_height_low = (line_spacing * (area_height_low / line_spacing));
  y = (spot_loc_y + area_height_low - font_logical_height);

  for (i = (len - 1), num = (line_num - 1); (0 <= i) && (0 <= num); --num) {
    char_tail = i;

    y -= line_spacing;

    line_width = 0;
    for (; 0 <= i; --i) {
      line_width_new = (line_width + *(wcstr_width + i));
      if (area_width < line_width_new) {
       if (0 == line_width) {
         /* If the width of a character is wider than area_width,
          * it consists one line.
          */
         i -= 1;
         line_width = area_width;
       }
       break;
      }
      line_width = line_width_new;
    }

    x = (area_x + area_width - line_width);

    preedit_area[num].x = 0;
    preedit_area[num].y = font_logical_height;
    preedit_area[num].char_offset_backup = preedit_area[num].char_offset;
    preedit_area[num].char_len_backup = preedit_area[num].char_len;
    preedit_area[num].char_offset = (i + 1);
    preedit_area[num].char_len = (char_tail - i);

    if ((0 == line_width) || (0 == line_height)) {
      UnmapPreeditWindow(ic, preedit_area + num);
    } else {
      ConfigurePreeditWindow(ic, preedit_area + num,
                          x, y, line_width, line_height);
    }
  }

  return line_num;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int set_window_forward ( XicCommon  ic,
int  len,
int  area_width,
int  area_x,
int  first_line_x_offset,
int  spot_loc_x,
int  spot_loc_y,
int  line_spacing 
) [static]

Definition at line 288 of file guiIMPrePos.c.

                                   {
  PreeditWin preedit;
  PreeditArea preedit_area;
  PreeditChars preedit_chars;
  unsigned short * wcstr_width;
  int i;
  int max_line_width;
  int line_width;
  int line_width_new;
  int line_height;
  int line_num;
  XFontSetExtents *fse;
  int font_logical_height;
  int char_offset;
  int x;
  int y;

  preedit = ic->gui_icpart->preedit;
  preedit_area = preedit->preedit_areas;
  preedit_chars = &(preedit->preedit_chars);
  wcstr_width = preedit_chars->wchar_width;
  fse = preedit->fse;
  font_logical_height = (-fse->max_ink_extent.y);
  line_height = (fse->max_logical_extent.height + 1);

  for (i = 0, line_num = 0; i < len; line_num++) {
    char_offset = i;

    if (0 == line_num) {
      max_line_width = (area_width - first_line_x_offset);
      x = spot_loc_x;
    } else {
      max_line_width = area_width;
      x = area_x;
    }
    y = spot_loc_y - font_logical_height + (line_spacing * line_num);

    line_width = 0;
    for (; i < len; i++) {
      line_width_new = (line_width + *(wcstr_width + i));
      if (max_line_width < line_width_new) {
       if ((0 == line_width) && (area_width < line_width_new)) {
         /* If the width of a character is wider than area_width,
          * it consists one line.
          */
         i += 1;
         line_width = max_line_width;
       }
       break;
      }
      line_width = line_width_new;
    }

    if (preedit->alloc_areas <= line_num) {
      if (False == NewPreeditWindow(ic)) return line_num;
      preedit_area = preedit->preedit_areas;
    }

    preedit_area[line_num].x = 0;
    preedit_area[line_num].y = font_logical_height;
    preedit_area[line_num].char_offset_backup =
           preedit_area[line_num].char_offset;
    preedit_area[line_num].char_len_backup = preedit_area[line_num].char_len;
    preedit_area[line_num].char_offset = char_offset;
    preedit_area[line_num].char_len = (i - char_offset);

    if ((0 == line_width) || (0 == line_height)) {
      UnmapPreeditWindow(ic, preedit_area + line_num);
    } else {
      ConfigurePreeditWindow(ic, preedit_area + line_num,
                          x, y, line_width, line_height);
    }
  }

  return line_num;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int set_window_full ( XicCommon  ic,
int  len,
int  area_width,
int  area_x,
int  spot_loc_x,
int  spot_loc_y,
int  line_spacing 
) [static]

Definition at line 449 of file guiIMPrePos.c.

                                {
  int line_num;

  spot_loc_y = (spot_loc_y - (line_spacing * (spot_loc_y / line_spacing)));

  line_num = set_window_forward(ic, len, area_width, area_x, area_x,
                            area_x, spot_loc_y, line_spacing);

  return line_num;
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation