[comp.windows.x] Shaping windows in Xlib

harkcom@potato.pa.Yokogawa.CO.JP (Alton Harkcom) (09/11/90)

   I am trying to shape a window in X11R4 using Xlib. I want to make
it a round-rect. Anybody know how to do this?
--
--
  $@2#2OEE5!3t<02q<R(J PA$@#15;#22](J
  TEL 0422-52-5748  FAX 0422-55-1728
  E-mail harkcom@pa.yokogawa.co.jp

mouse@LARRY.MCRCIM.MCGILL.EDU (09/12/90)

> I am trying to shape a window in X11R4 using Xlib.  I want to make it
> a round-rect.  Anybody know how to do this?

I'm not sure what you mean by "a round-rect", but it doesn't make much
difference.

Strictly speaking, this is not possible within Xlib.  However, the
SHAPE extension looks and feels (:-) like part of Xlib.  Assuming you
accept it as such....

You use XShapeCombineRegion, XShapeCombineRectangles,
XShapeCombineMask, XShapeCombineShape, and/or XShapeOffsetShape to
manipulate window shapes.  (There are other routines as well; see the
documentation.)  In your case, I would guess that you probably want to
use XShapeCombineMask.

					der Mouse

			old: mcgill-vision!mouse
			new: mouse@larry.mcrcim.mcgill.edu

rws@EXPO.LCS.MIT.EDU (Bob Scheifler) (09/12/90)

Take a look at mit/lib/Xmu/ShapeWidg.c, particularly the internal function
ShapeEllipseorRoundedRectangle.  Even if you don't know Xt, you should be
able to figure it out.

harkcom@potato.pa.Yokogawa.Co.jp (Alton Harkcom) (09/14/90)

In article <HARKCOM.90Sep10190140@potato.pa.Yokogawa.CO.JP> I write:

 =}   I am trying to shape a window in X11R4 using Xlib. I want to make
 =}it a round-rect. Anybody know how to do this?

   And I got some good answers. please email me if you would like to
know also :-)

            harkcom@pa.yokogawa.co.jp

--
--
  $@2#2OEE5!3t<02q<R(J PA$@#15;#22](J
  TEL 0422-52-5748  FAX 0422-55-1728
  E-mail harkcom@pa.yokogawa.co.jp

harkcom@potato.pa.Yokogawa.Co.jp (Alton Harkcom) (09/14/90)

   I got so many requests for the info that I decided to post a summary :-)

The first reply I got was from:

 =}	rws@expo.lcs.mit.edu (Bob Scheifler)
 =}
 =}	Take a look at mit/lib/Xmu/ShapeWidg.c, particularly the
 =}	internal function ShapeEllipseorRoundedRectangle.  Even
 =}	if you don't know Xt, you should be able to figure it out.

I took a look and found many things that are useful to me. Gave me a lot
of new toys to play with :-)

The next came from:

 =}	der Mouse  <mouse@Larry.McRCIM.McGill.EDU>
 =}
 =}	Strictly speaking, this is not possible within Xlib.
 =}	However, the SHAPE extension looks and feels (:-) like
 =}	part of Xlib.  Assuming you accept it as such....
 =}
 =}	You use XShapeCombineRegion, XShapeCombineRectangles,
 =}	XShapeCombineMask, XShapeCombineShape, and/or
 =}	XShapeOffsetShape to manipulate window shapes. (There
 =}	are other routines as well; see the documentation.) In
 =}	your case, I would guess that you probably want to
 =}	use XShapeCombineMask.

Which gave me even more toys to play with :-)

And from:

 =}	janssen@parc.xerox.com
 =}
 =}	You will need to use the Shape extension.
 =}	Here's a simple example program:

[edited to be as small as I could make it... Al]

#include <Xlib.h>
#include <extensions/shape.h>	/* include file for X extensions */

#define N	100

main (ac, av)
int ac;
char **av;
{
	Display	*d;
	Window	w;
	Pixmap	bmp;
	long	junk;

	d = XOpenDisplay("");
	w = XCreateSimpleWindow(d, DefaultRootWindow(d), N, N, N, N, 0, 0, 3);
	XReadBitmapFile (d, w, av[1], &junk, &junk, &bmp, &junk, &junk);
	XShapeCombineMask(d, w, ShapeBounding, 0, 0, bmp, ShapeSet);
	XMapWindow (d, w);
	XFlush(d);
	sleep(60);
	XCloseDisplay(d);
}

I appreciate all of the help, thank you :-)

--
--
  $@2#2OEE5!3t<02q<R(J PA$@#15;#22](J
  TEL 0422-52-5748  FAX 0422-55-1728
  E-mail harkcom@pa.yokogawa.co.jp