Пример #1
0
/* sets a window background from a colorset
 * if width or height are zero the window size is queried
 */
void SetWindowBackgroundWithOffset(
	Display *dpy, Window win, int x_off, int y_off, int width, int height,
	colorset_struct *colorset, unsigned int depth, GC gc, Bool clear_area)
{
	Pixmap pixmap = None;
	Pixmap mask = None;
	XID junk;

	if (0 == width || 0 == height)
	{
		if (!XGetGeometry(
			    dpy, win, &junk, (int *)&junk, (int *)&junk,
			    (unsigned int *)&width, (unsigned int *)&height,
			    (unsigned int *)&junk, (unsigned int *)&junk))
		{
			return;
		}
	}

	if (FHaveShapeExtension && colorset->shape_mask)
	{
		mask = CreateBackgroundPixmap(
			dpy, 0, width, height, colorset, 1, None, True);
		if (mask != None)
		{
			FShapeCombineMask(
				dpy, win, FShapeBounding, 0, 0, mask,
				FShapeSet);
			XFreePixmap(dpy, mask);
		}
	}
	if (!colorset->pixmap)
	{
		/* use the bg pixel */
		XSetWindowBackground(dpy, win, colorset->bg);
		if (clear_area)
		{
			XClearArea(dpy, win, 0, 0, width, height, True);
		}
	}
	else
	{
		if (colorset->pixmap == ParentRelative)
		{
			pixmap = ParentRelative;
		}
		else
		{
			pixmap = CreateBackgroundPixmap(
				dpy, win, width, height, colorset, depth, gc,
				False);
		}
		if (x_off != 0 || y_off != 0)
		{
			Pixmap p2;

			p2 = ScrollPixmap(
				dpy, pixmap, gc, x_off, y_off, width, height,
				depth);
			if (p2 != None && p2 != ParentRelative && p2 != pixmap)
			{
				XFreePixmap(dpy, pixmap);
				pixmap = p2;
			}
		}
		if (pixmap)
		{
			XSetWindowBackgroundPixmap(dpy, win, pixmap);
			if (clear_area)
			{
				XClearArea(dpy, win, 0, 0, width, height, True);
			}
			if (colorset->pixmap != ParentRelative)
			{
				XFreePixmap(dpy, pixmap);
			}
		}
	}

	return;
}
Пример #2
0
/* sets a window background from a colorset
 * if width or height are zero the window size is queried
 */
void SetWindowBackgroundWithOffset(
	Display *dpy, Window win, int x_off, int y_off, unsigned int width, unsigned int height,
	colorset_t *colorset, unsigned int depth, GC gc, Bool clear_area)
{
	Pixmap pixmap = None;
	Pixmap mask = None;
	union {
		XID junk;
		unsigned int ui_junk;
		int i_junk;
	} XID_int;
	if (0 == width || 0 == height)
	{
		if (!XGetGeometry(
			    dpy, win, &XID_int.junk,
			    &XID_int.i_junk, &XID_int.i_junk,
			    (unsigned int *)&width,
			    (unsigned int *)&height,
			    &XID_int.ui_junk,
			    &XID_int.ui_junk))
		{
			return;
		}
	}

	if (FHaveShapeExtension && colorset->shape_mask)
	{
		mask = CreateBackgroundPixmap(
			dpy, None, width, height, colorset, 1, None, True);
		if (mask != None)
		{
			FShapeCombineMask(
				dpy, win, FShapeBounding, 0, 0, mask,
				FShapeSet);
			XFreePixmap(dpy, mask);
		}
	}
	if (!colorset->pixmap)
	{
		/* use the bg pixel */
		XSetWindowBackground(dpy, win, colorset->bg);
		if (clear_area)
		{
			XClearArea(dpy, win, 0, 0, width, height, True);
		}
	}
	else
	{

		pixmap = CreateOffsetBackgroundPixmap(
			dpy, win, x_off, y_off, width, height, colorset,
			depth, gc, False);
		if (pixmap)
		{
			XSetWindowBackgroundPixmap(dpy, win, pixmap);
			if (clear_area)
			{
				XClearArea(dpy, win, 0, 0, width, height, True);
			}
			if (pixmap != ParentRelative)
			{
				XFreePixmap(dpy, pixmap);
			}
		}
	}

	return;
}
Пример #3
0
Файл: icons.c Проект: att/uwin
/****************************************************************************
 *
 * Creates an Icon Window
 * Loads an icon file and combines icon shape masks after a resize
 * special thanks to Rich Neitzel <*****@*****.**>
 *    for his patch to handle icon windows
 *
 ****************************************************************************/
void CreateIconWindow(struct icon_info *item)
{
  unsigned long valuemask;		/* mask for create windows */
  XSetWindowAttributes attributes;	/* attributes for create windows */

  attributes.background_pixel = icon_back_pix;
  attributes.border_pixel = 0;
  attributes.colormap = Pcmap;
  attributes.event_mask = ExposureMask;
  valuemask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;

  /* ccreate the icon label */
  item->IconWin = XCreateWindow(dpy, icon_win, 0, 0, max_icon_width,
				max_icon_height + 10, 0, CopyFromParent,
				CopyFromParent, CopyFromParent, valuemask,
				&attributes);
  XSelectInput(dpy, item->IconWin, ICON_EVENTS);

  XSelectInput(dpy, item->id, PropertyChangeMask);
  item->wmhints = XGetWMHints(dpy, item->id);

  if (max_icon_height == 0)
    return;

  /* config specified icons have priority */
  if ((item->icon_file != NULL) && !(item->extra_flags & DEFAULTICON)) {
    /* monochrome bitmap */
    GetBitmapFile(item);

    /* color pixmap */
    if((item->icon_w == 0) && (item->icon_h == 0))
      GetXPMFile(item);
  }
  /* next come program specified icon windows and pixmaps*/
  if((item->icon_h == 0) && (item->icon_w == 0) && item->wmhints)
  {
    if (item->wmhints->flags & IconWindowHint)
      GetIconWindow(item);
    else if (item->wmhints->flags & IconPixmapHint)
      GetIconBitmap(item);
  }

  /* if that all fails get the default */
  if ((item->icon_file != NULL) && (item->icon_h == 0) && (item->icon_w == 0)) {
    /* monochrome bitmap */
    GetBitmapFile(item);

    /* color pixmap */
    if((item->icon_w == 0) && (item->icon_h == 0))
      GetXPMFile(item);
  }

  /* create the window to hold the pixmap */
  /* if using a non default visual client pixmaps must have a default visual
     window to be drawn into */
  if (IS_ICON_OURS(item)) {
    if (Pdefault | (item->icon_depth == 1) | IS_PIXMAP_OURS(item)){
      item->icon_pixmap_w = XCreateWindow(dpy, icon_win, 0, 0,
					  max(max_icon_width, item->icon_w),
					  max(max_icon_height, item->icon_h), 0,
					  CopyFromParent, CopyFromParent,
					  CopyFromParent, valuemask,
					  &attributes);
    } else {
      attributes.background_pixel = 0;
      attributes.colormap = DefaultColormap(dpy, screen);
      item->icon_pixmap_w = XCreateWindow(dpy, icon_win, 0, 0,
					  max(max_icon_width,item->icon_w),
					  max(max_icon_height,item->icon_h), 0,
					  DefaultDepth(dpy, screen),
					  InputOutput,
					  DefaultVisual(dpy, screen), valuemask,
					  &attributes);
    }
    XSelectInput(dpy, item->icon_pixmap_w, ICON_EVENTS);
  }

#ifdef XPM
  if (FShapesSupported && item->icon_maskPixmap != None) {
     int hr;
     hr = (Pdefault | (item->icon_depth == 1) | IS_PIXMAP_OURS(item)) ?
       icon_relief/2 : 0;
     FShapeCombineMask(
       dpy, item->icon_pixmap_w, FShapeBounding, hr, hr, item->icon_maskPixmap,
       FShapeSet);
  }
#endif

  if(item->icon_depth == -1 ) {
    Pixmap temp = item->iconPixmap;
    item->iconPixmap = XCreatePixmap(dpy, Root, item->icon_w, item->icon_h,
				     Pdepth);
    XCopyPlane(dpy, temp, item->iconPixmap, NormalGC, 0, 0, item->icon_w,
	       item->icon_h, 0, 0, 1);
  }
}