Back to index

im-sdk  12.3.91
Static Public Member Functions | Static Private Attributes
XFactory Class Reference

#include <Xfactory.hh>

Collaboration diagram for XFactory:
Collaboration graph
[legend]

List of all members.

Static Public Member Functions

static void remove_decoration (Display *, Window)
static void register_filter (Display *, Window, int, int, XIMFilter, XPointer)
static void unregister_filter (Display *, Window, XIMFilter, XPointer)
static XFontSet create_fontset (Display *, const char *)
static void free_fontset (Display *, XFontSet)
static void getLocationOnScreen (Display *, Window, int, int, XPoint *)
static Window getToplevelWindow (Display *, Window)
static Window getFrameWindow (Display *, Window)
static int xerror_handler (Display *, XErrorEvent *)

Static Private Attributes

static FsSet fs_list

Detailed Description

Definition at line 58 of file Xfactory.hh.


Member Function Documentation

XFontSet XFactory::create_fontset ( Display *  display,
const char *  name 
) [static]

Definition at line 125 of file Xfactory.cpp.

                                                           {
  CompoundString font_name(name);

  FsSet fsp = fs_list;
  while (fsp) {
    if (fsp->fs_name.length() == font_name.length() &&
       fsp->fs_name == font_name) {
      fsp->ref_count++;
      return(fsp->fs);
    }
    fsp = fsp->next;
  }
  // not found
  char **missing_list;
  int missing_count;
  char *def_string;
  int fallback_flag = 0;
  XFontSet font_set = XCreateFontSet(display, (char*)font_name,
                                 &missing_list, &missing_count,
                                 &def_string);
  if (font_set == 0) {
    fallback_flag = 1;
  }
  if (missing_count > 0) {
    int list_ret;
    XFontStruct **struct_list = NULL;
    char **name_list = NULL;
    const char *cur_str = NULL;
    int i;
    list_ret = XFontsOfFontSet(font_set,
                            &struct_list, &name_list);
    cur_str = name;
    for (i = 0; i < list_ret && cur_str != NULL; ++i) {
      char *tmp_str;
      if (strncmp(cur_str, (const char*)name_list[i],
                strlen(name_list[i])) != 0) {
       break;
      };
      tmp_str = (char *)strchr(cur_str, ',');
      if (tmp_str != NULL && strlen(tmp_str) > 1) {
       ++tmp_str;
      }
      else {
       tmp_str = NULL;
      }
      cur_str = (const char*)tmp_str;
    }
    if (i != list_ret || cur_str != NULL) {
#ifdef DEBUG
      fprintf(stderr, "Warning\n");
      fprintf(stderr, " - FontSet creation partically failed due to missing character sets\n");
#endif
      fallback_flag = 1;
    }
    XFreeStringList(missing_list);
  }
  if (fallback_flag == 1) {
    const char default_name[] = "-*-*-medium-r-normal-*-16-*-*-*-*-*-*-*";

    font_name = CompoundString(default_name);
    fsp = fs_list;
    while (fsp) {
      if (fsp->fs_name.length() == font_name.length() &&
         fsp->fs_name == font_name) {
       fsp->ref_count++;
       return(fsp->fs);
      }
      fsp = fsp->next;
    }
    font_set = XCreateFontSet(display, (char*)font_name,
                           &missing_list, &missing_count,
                           &def_string);
    if (font_set == 0) {
#ifdef DEBUG
    fprintf(stderr, "Error\n");
    fprintf(stderr, " - Fallback FontSet creation failes\n");
#endif
      return (XFontSet)0;
    }
    if (missing_count > 0) {
#ifdef DEBUG
      fprintf(stderr, "Warning\n");
      fprintf(stderr, " - FontSet creation partically failed due to missing character sets\n");
#endif
      XFreeStringList(missing_list);
    }
  }
  fsp = fs_list;
  while (fsp) {
    if (fsp->fs == 0 && fsp->ref_count == 0) break;
    fsp = fsp->next;
  }
  FsSet newfsp;
  if (fsp) {
    newfsp = fsp;    // found one
  } else {
    // create new list
    newfsp = new FsSetRec;
    if (!fs_list) {
      newfsp->next = (FsSet)0;
      fs_list = newfsp;
    } else {
      newfsp->next = fs_list;
      fs_list = newfsp;
    }
  }
  newfsp->fs = font_set;
  newfsp->fs_name = font_name;
  newfsp->ref_count = 1;

  return(newfsp->fs);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void XFactory::free_fontset ( Display *  display,
XFontSet  font_set 
) [static]

Definition at line 239 of file Xfactory.cpp.

                                                          {

  if (!fs_list) return;

  FsSet fsp = fs_list;
  while (fsp) {
    if (font_set == fsp->fs)
      break;
    fsp = fsp->next;
  }

  if (!fsp || fsp->ref_count == 0) return;

  if (--(fsp->ref_count) > 0)   /* somebody else is still using */
    return;

  if (fsp->fs) {
    XFreeFontSet(display, fsp->fs);
    fsp->fs = 0;     //
  }
  return;
}

Here is the caller graph for this function:

Window XFactory::getFrameWindow ( Display *  display,
Window  window 
) [static]

Definition at line 350 of file Xfactory.cpp.

                                                        {
  Window top_win;
  Window current_window = window;

  for (;;) {
    Window root_return, parent_return, *child_return = NULL;
    unsigned int nchild_return;
    top_win = current_window;
    if (XQueryTree(display, current_window,
                 &root_return, &parent_return,
                 &child_return, &nchild_return) == 0) {
      if (child_return) XFree(child_return);
      break;
    }
    if (child_return) XFree(child_return);
    current_window = parent_return;
    if (parent_return == root_return) break;
  }
  return top_win;
}
void XFactory::getLocationOnScreen ( Display *  display,
Window  window,
int  x,
int  y,
XPoint *  point 
) [static]

Definition at line 263 of file Xfactory.cpp.

                                                        {
  XWindowAttributes attr;
  Window child;
  int new_x, new_y;

  if (XGetWindowAttributes(display, window, &attr) > 0) {
    XTranslateCoordinates(display, window,
                       RootWindow(display,
                                 XScreenNumberOfScreen(attr.screen)),
                       x, y,
                       &new_x, &new_y, &child);

    point->x = new_x;
    point->y = new_y;
  }
  return;
}
Window XFactory::getToplevelWindow ( Display *  display,
Window  window 
) [static]

Definition at line 322 of file Xfactory.cpp.

                                                           {
  Window root_return, parent_return, *child_return = NULL, current_window;
  unsigned int nchild_return;

  if (GetWMState(display, window)) return window;

  current_window = window;
  for (;;) {
    if (XQueryTree(display, current_window,
                 &root_return, &parent_return,
                 &child_return, &nchild_return) == 0) {
      if (child_return) XFree(child_return);
      break;
    }
    if (child_return) XFree(child_return);
    if (GetWMState(display, parent_return)) {
      return parent_return;
    }
    if (parent_return == root_return) {
      return current_window;
    }
    current_window = parent_return;
  }
  /* error */
  return window;
}

Here is the call graph for this function:

void XFactory::register_filter ( Display *  display,
Window  window,
int  start_type,
int  end_type,
XIMFilter  filter,
XPointer  call_data 
) [static]

Definition at line 107 of file Xfactory.cpp.

                                                             {
  _XRegisterFilterByType(display, window, start_type,
                      end_type, filter, call_data);
  return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void XFactory::remove_decoration ( Display *  display,
Window  window 
) [static]

Definition at line 80 of file Xfactory.cpp.

                                                           {
  const int decoration = (1L << 1);       /* set border only */
  struct _mwmhints {
    unsigned long flags, func, deco;
    long    input_mode;
    unsigned long status;
  } mwm_del_hints;

  getAtoms(display);

  if (mwm_del_atom != None) {
    mwm_del_hints.flags = 1L << 1; /* flags for decoration */
    mwm_del_hints.deco = decoration;
    XChangeProperty(display, window,
                  mwm_del_atom, mwm_del_atom, 32,
                  PropModeReplace,
                  (unsigned char *)&mwm_del_hints, 5);
  }
  if (ol_del_atom != None) {
    XChangeProperty(display, window, ol_del_atom, XA_ATOM, 32,
                  PropModeReplace, (unsigned char*)ol_del_atom_list,
                  ol_atom_inx);
  }
  return;
}

Here is the call graph for this function:

void XFactory::unregister_filter ( Display *  display,
Window  window,
XIMFilter  filter,
XPointer  call_data 
) [static]

Definition at line 116 of file Xfactory.cpp.

                                                               {
  _XUnregisterFilter(display, window, filter, call_data);
  return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int XFactory::xerror_handler ( Display *  display,
XErrorEvent *  ev 
) [static]

Definition at line 372 of file Xfactory.cpp.

                                                          {
  char errmsg[80];
  Bool print_xerror = True;

  if (getenv("NOPRINT_XERROR")) print_xerror = False;

  if (print_xerror) {
    XGetErrorText(display, ev->error_code, errmsg, 80);
#ifdef DEBUG
    fprintf(stderr, "Warning (X Error) -  %s\n", errmsg);
#endif
  }
  return 0;
}

Here is the caller graph for this function:


Member Data Documentation

FsSet XFactory::fs_list [static, private]

Definition at line 71 of file Xfactory.hh.


The documentation for this class was generated from the following files: