Beispiel #1
0
Datei: icons.c Projekt: att/uwin
/***************************************************************************
*
 *
 * Looks for an application supplied icon window
 *
 ***************************************************************************
*/
void GetIconWindow(struct icon_info *item)
{
  int x, y;
  unsigned int bw;
  Window Junkroot;

  if(!XGetGeometry(dpy, item->wmhints->icon_window, &Junkroot,
                  &x, &y, (unsigned int *)&item->icon_w,
		   (unsigned int *)&item->icon_h,
		   &bw, (unsigned int *)&item->icon_depth))
  {
    /* disable the icon window hint */
    item->wmhints->icon_window = None;
    item->wmhints->flags &= ~IconWindowHint;
    return;
  }

  item->icon_pixmap_w = item->wmhints->icon_window;

  if (FShapesSupported && (item->wmhints->flags & IconMaskHint))
  {
    SET_ICON_SHAPED(item, True);
    item->icon_maskPixmap = item->wmhints->icon_mask;
  }

  item->icon_w = min(max_icon_width + icon_relief,  item->icon_w);
  item->icon_h = min(max_icon_height + icon_relief, item->icon_h);

  XReparentWindow(dpy, item->icon_pixmap_w, icon_win, 0, 0);
  XSetWindowBorderWidth(dpy, item->icon_pixmap_w, 0);
  SET_ICON_OURS(item, False);
  SET_PIXMAP_OURS(item, False);
}
Beispiel #2
0
Datei: icons.c Projekt: att/uwin
/***************************************************************************
*
 *
 * Looks for an application supplied bitmap or pixmap
 *
 ***************************************************************************
*/
void GetIconBitmap(struct icon_info *item)
{
  int x, y;
  unsigned int bw, depth;
  Window Junkroot;
  GC gc;

  item->icon_file = NULL;
  item->icon_maskPixmap = None;
  item->iconPixmap = None;
  item->icon_w = 0;
  item->icon_h = 0;
  if (!XGetGeometry(dpy, item->wmhints->icon_pixmap, &Junkroot, &x, &y,
               (unsigned int *)&item->icon_w,
               (unsigned int *)&item->icon_h, &bw, &depth))
  {
    /* disable icon pixmap hint */
    item->wmhints->icon_pixmap = None;
    item->wmhints->flags &= ~IconPixmapHint;
    return;
  }
  /* sanity check the pixmap depth, it must be the same as the root or 1 */
  if (depth != 1 && depth != DefaultDepth(dpy, screen))
  {
    /* disable icon pixmap hint */
    item->wmhints->icon_pixmap = None;
    item->wmhints->flags &= ~IconPixmapHint;
    return;
  }
  item->icon_depth = depth;

  if (FShapesSupported && (item->wmhints->flags & IconMaskHint))
  {
    SET_ICON_SHAPED(item, True);
    item->icon_maskPixmap = item->wmhints->icon_mask;
  }

  item->icon_w = min(max_icon_width, item->icon_w);
  item->icon_h = min(max_icon_height, item->icon_h);
  if (item->icon_w <= 0 || item->icon_h <= 0)
  {
    item->icon_w = 0;
    item->icon_h = 0;
    return;
  }

  item->iconPixmap = XCreatePixmap(dpy, Root, item->icon_w,
                                   item->icon_h, depth);
  gc = fvwmlib_XCreateGC(dpy, item->iconPixmap, 0, NULL);
  XCopyArea(dpy, item->wmhints->icon_pixmap, item->iconPixmap,
               gc, 0, 0, item->icon_w, item->icon_h, 0, 0);
  XFreeGC(dpy, gc);
  SET_PIXMAP_OURS(item, False);
}
Beispiel #3
0
/*
 *
 * Looks for an application supplied icon window
 *
 */
void GetIconWindow(struct icon_info *item)
{
	int x, y;
	unsigned int bw;
	Window Junkroot;

	if (!XGetGeometry(
		dpy, item->wmhints->icon_window, &Junkroot, &x, &y,
		(unsigned int *)&item->icon_w, (unsigned int *)&item->icon_h,
		&bw, (unsigned int *)&item->icon_depth))
	{
#if 0
		fprintf(stderr, "[%s][GetIconWindow] WARN -- '%s' has an "
			"invalid icon window hint\n", MyName, item->name);
#endif
		/* disable the icon window hint */
		item->icon_w = 0;
		item->icon_h = 0;
		item->wmhints->icon_window = None;
		item->wmhints->flags &= ~IconWindowHint;
		return;
	}

	item->icon_pixmap_w = item->wmhints->icon_window;

	if (FShapesSupported && (item->wmhints->flags & IconMaskHint))
	{
		SET_ICON_SHAPED(item, True);
		item->icon_maskPixmap = item->wmhints->icon_mask;
	}

	item->icon_w = min(max_icon_width + icon_relief,  item->icon_w);
	item->icon_h = min(max_icon_height + icon_relief, item->icon_h);

	MyXGrabServer(dpy);
	do_allow_bad_access = True;
	XReparentWindow(dpy, item->icon_pixmap_w, icon_win, 0, 0);
	XSetWindowBorderWidth(dpy, item->icon_pixmap_w, 0);
	XSelectInput(dpy, item->icon_pixmap_w, ICON_EVENTS);
	XSync(dpy, 0);
	do_allow_bad_access = False;
	if (was_bad_access)
	{
		/* give up */
#if 0
		fprintf(stderr, "[%s][GetIconWindow] WARN -- BadAcces when "
			"reparenting %s icon window\n", MyName, item->name);
#endif
		XSelectInput(dpy, item->icon_pixmap_w, NoEventMask);
		XUnmapWindow(dpy, item->icon_pixmap_w);
		XReparentWindow(dpy, item->icon_pixmap_w, Root, 0, 0);
		XUnmapWindow(dpy, item->icon_pixmap_w);
		MyXUngrabServer(dpy);
		item->icon_pixmap_w = item->wmhints->icon_window = None;
		item->wmhints->flags &= ~IconWindowHint;
		item->icon_maskPixmap = None;
		item->icon_w = 0;
		item->icon_h = 0;
		was_bad_access = False;
		return;
	}
	MyXUngrabServer(dpy);
	SET_ICON_OURS(item, False);
	SET_PIXMAP_OURS(item, False);
}