1mX Nonrectangular Window0m

		  1mShape Extension Library0m



			Version 1.0
		   X Consortium Standard
		 X Version 11, Release 6.4






		       Keith Packard
		      MIT X Consortium









Copyright © 1989 X Consortium

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documenta-
tion files (the ``Software''), to deal in the Software with-
out restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to
whom the Software is furnished to do so, subject to the fol-
lowing conditions:

The above copyright notice and this permission notice shall
be included in all copies or substantial portions of the
Software.

THE SOFTWARE IS PROVIDED ``AS IS'', WITHOUT WARRANTY OF ANY
KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PUR-
POSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE X












CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABIL-
ITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Except as contained in this notice, the name of the X Con-
sortium shall not be used in advertising or otherwise to
promote the sale, use or other dealings in this Software
without prior written authorization from the X Consortium.

























































1m1.  Overview0m

This extension provides arbitrary window and border shapes
within the X11 protocol.

The restriction of rectangular windows within the X protocol
is a significant limitation in the implementation of many
styles of user interface.  For example, many transient win-
dows would like to display a ``drop shadow'' to give the
illusion of 3 dimensions.  As another example, some user
interface style guides call for buttons with rounded cor-
ners; the full simulation of a nonrectangular shape, partic-
ularly with respect to event distribution and cursor shape,
is not possible within the core X protocol.  As a final
example, round clocks and nonrectangular icons are desirable
visual addition to the desktop.

This extension provides mechanisms for changing the visible
shape of a window to an arbitrary, possibly disjoint, non-
rectangular form.  The intent of the extension is to supple-
ment the existing semantics, not replace them.	In particu-
lar, it is desirable for clients that are unaware of the
extension to still be able to cope reasonably with shaped
windows.  For example, window managers should still be able
to negotiate screen real estate in rectangular pieces.
Toward this end, any shape specified for a window is clipped
by the bounding rectangle for the window as specified by the
window's geometry in the core protocol.	 An expected conven-
tion would be that client programs expand their shape to
fill the area offered by the window manager.

1m2.  Description0m

Each window (even with no shapes specified) is defined by
two regions:  the 4mbounding24m 4mregion24m and the 4mclip24m 4mregion24m.  The
bounding region is the area of the parent window that the
window will occupy (including border). The clip region is
the subset of the bounding region that is available for sub-
windows and graphics.  The area between the bounding region
and the clip region is defined to be the border of the win-
dow.

A nonshaped window will have a bounding region that is a
rectangle spanning the window, including its border; the
clip region will be a rectangle filling the inside dimen-
sions (not including the border).  In this document, these
areas are referred to as the 4mdefault24m 4mbounding24m 4mregion24m and the
4mdefault24m 4mclip24m 4mregion24m.  For a window with inside size of 4mwidth0m
by 4mheight24m and border width 4mbwidth24m, the default bounding and
clip regions are the rectangles (relative to the window ori-
gin):






			      1m10m





       X Nonrectangular Window Shape Extension Library

__
|
bounding.x = -4mbwidth0m
bounding.y = -4mbwidth0m
bounding.width = 4mwidth24m + 2 * 4mbwidth0m
bounding.height = 4mheight24m + 2 * 4mbwidth0m

clip.x = 0
clip.y = 0
clip.width = 4mwidth0m
clip.height = 4mheight0m

|__

This extension allows a client to modify either or both of
the bounding or clip regions by specifying new regions that
combine with the default regions.  These new regions are
called the 4mclient24m 4mbounding24m 4mregion24m and the 4mclient24m 4mclip0m
4mregion24m.  They are specified relative to the origin of the
window and are always defined by offsets relative to the
window origin (that is, region adjustments are not required
when the window is moved).  Three mechanisms for specifying
regions are provided:  a list of rectangles, a bitmap, and
an existing bounding or clip region from a window.  This is
modeled on the specification of regions in graphics contexts
in the core protocol and allows a variety of different uses
of the extension.

When using an existing window shape as an operand in speci-
fying a new shape, the client region is used, unless none
has been set, in which case the default region is used
instead.

The 4meffective24m 4mbounding24m 4mregion24m of a window is defined to be
the intersection of the client bounding region with the
default bounding region.  Any portion of the client bounding
region that is not included in the default bounding region
will not be included in the effective bounding region on the
screen.	 This means that window managers (or other geometry
managers) used to dealing with rectangular client windows
will be able to constrain the client to a rectangular area
of the screen.

Construction of the effective bounding region is dynamic;
the client bounding region is not mutated to obtain the
effective bounding region.  If a client bounding region is
specified that extends beyond the current default bounding
region, and the window is later enlarged, the effective
bounding region will be enlarged to include more of the
client bounding region.

The 4meffective24m 4mclip24m 4mregion24m of a window is defined to be the
intersection of the client clip region with both the default
clip region and the client bounding region.  Any portion of
the client clip region that is not included in both the



			      1m20m





       X Nonrectangular Window Shape Extension Library


default clip region and the client bounding region will not
be included in the effective clip region on the screen.

Construction of the effective clip region is dynamic; the
client clip region is not mutated to obtain the effective
clip region.  If a client clip region is specified that
extends beyond the current default clip region and the win-
dow or its bounding region is later enlarged, the effective
clip region will be enlarged to include more of the client
clip region if it is included in the effective bounding
region.

The border of a window is defined to be the difference
between the effective bounding region and the effective clip
region.	 If this region is empty, no border is displayed.
If this region is nonempty, the border is filled using the
border-tile or border-pixel of the window as specified in
the core protocol.  Note that a window with a nonzero border
width will never be able to draw beyond the default clip
region of the window.  Also note that a zero border width
does not prevent a window from having a border, since the
clip shape can still be made smaller than the bounding
shape.

All output to the window and visible regions of any subwin-
dows will be clipped to the effective clip region.  The
server must not retain window contents beyond the effective
bounding region with backing store.  The window's origin
(for graphics operations, background tiling, and subwindow
placement) is not affected by the existence of a bounding
region or clip region.

Areas that are inside the default bounding region but out-
side the effective bounding region are not part of the win-
dow; these areas of the screen will be occupied by other
windows.  Input events that occur within the default bound-
ing region but outside the effective bounding region will be
delivered as if the window was not occluding the event posi-
tion.  Events that occur in a nonrectangular border of a
window will be delivered to that window, just as for events
that occur in a normal rectangular border.

An 4mInputOnly24m window can have its bounding region set, but it
is a 4mMatch24m error to attempt to set a clip region on an 4mInpu-0m
4mtOnly24m window or to specify its clip region as a source to a
request in this extension.

The server must accept changes to the clip region of a root
window, but the server is permitted to ignore requested
changes to the bounding region of a root window.  If the
server accepts bounding region changes, the contents of the
screen outside the bounding region are implementation depen-
dent.




			      1m30m





       X Nonrectangular Window Shape Extension Library


1m3.  C Language Binding0m

The C functions provide direct access to the protocol and
add no additional semantics.

The include file for this extension is <4mX11/exten-0m
4msions/shape.h24m>.  The defined shape kinds are 4mShapeBounding0m
and 4mShapeClip24m.  The defined region operations are 4mShapeSet24m,
4mShapeUnion24m, 4mShapeIntersect24m, 4mShapeSubtract24m, and 4mShapeInvert24m.
__
|
Bool
XShapeQueryExtension(4mdisplay24m, 4mevent_base24m, 4merror_base24m)
     Display *4mdisplay24m;
     int *4mevent_base24m; /* RETURN */
     int *4merror_base24m; /* RETURN */

|__

4mXShapeQueryExtension24m returns 4mTrue24m if the specified display
supports the SHAPE extension else 4mFalse24m.  If the extension
is supported, *event_base is set to the event number for
4mShapeNotify24m events and *error_base would be set to the error
number for the first error for this extension.	Because no
errors are defined for this version of the extension, the
value returned here is not defined (nor useful).


__
|
Status
XShapeQueryVersion(4mdisplay24m, 4mmajor_version24m, 4mminor_version24m)
     Display *4mdisplay24m;
     int *4mmajor_version24m, *4mminor_version24m;  /* RETURN */

|__

If the extension is supported, 4mXShapeQueryVersion24m sets the
major and minor version numbers of the extension supported
by the display and returns a nonzero value.  Otherwise, the
arguments are not set and zero is returned.


__
|
XShapeCombineRegion(4mdisplay24m, 4mdest24m, 4mdest_kind24m, 4mx_off24m, 4my_off24m, 4mregion24m, 4mop24m)
      Display *4mdisplay24m;
      Window 4mdest24m;
      int 4mdest_kind24m, 4mop24m, 4mx_off24m, 4my_off24m;
      REGION *4mregion24m;

|__

4mXShapeCombineRegion24m converts the specified region into a



			      1m40m





       X Nonrectangular Window Shape Extension Library


list of rectangles and calls 4mXShapeCombineRectangles24m.


__
|
XShapeCombineRectangles(4mdisplay24m, 4mdest24m, 4mdest_kind24m, 4mx_off24m, 4my_off24m, 4mrectangles24m, 4mn_rects24m, 4mop24m, 4mordering24m)
      Display *4mdisplay24m;
      Window 4mdest24m;
      int 4mdest_kind24m, 4mn_rects24m, 4mop24m, 4mx_off24m, 4my_off24m, 4mordering24m;
      XRectangle *4mrectangles24m;

|__

If the extension is supported, 4mXShapeCombineRectangles24m per-
forms a 4mShapeRectangles24m operation; otherwise, the request is
ignored.


__
|
XShapeCombineMask(4mdisplay24m, 4mdest24m, 4mdest_kind24m, 4mx_off24m, 4my_off24m, 4msrc24m, 4mop24m)
      Display *4mdisplay24m;
      Window 4mdest24m;
      int 4mdest_kind24m, 4mop24m, 4mx_off24m, 4my_off24m;
      Pixmap 4msrc24m;

|__

If the extension is supported, 4mXShapeCombineMask24m performs a
4mShapeMask24m operation; otherwise, the request is ignored.


__
|
XShapeCombineShape(4mdisplay24m, 4mdest24m, 4mdest_kind24m, 4mx_off24m, 4my_off24m, 4msrc24m, 4msrc_kind24m, 4mop24m)
      Display *4mdisplay24m;
      Window 4mdest24m, 4msrc24m;
      int 4mdest_kind24m, 4msrc_kind24m, 4mop24m, 4mx_off24m, 4my_off24m;

|__

If the extension is supported, 4mXShapeCombineShape24m performs a
4mShapeCombine24m operation; otherwise, the request is ignored.














			      1m50m





       X Nonrectangular Window Shape Extension Library

__
|
XShapeOffsetShape(4mdisplay24m, 4mdest24m, 4mdest_kind24m, 4mx_off24m, 4my_off24m)
      Display *4mdisplay24m;
      Window 4mdest24m;
      int 4mdest_kind24m, fIx_off4m,24m 4my_off;0m

|__

If the extension is supported, 4mXShapeOffsetShape24m performs a
4mShapeOffset24m operation; otherwise, the request is ignored.


__
|
Status XShapeQueryExtents(4mdisplay24m, 4mwindow24m, 4mbounding_shaped24m, 4mx_bounding24m, 4my_bounding24m,
      4mw_bounding24m,	4mh_bounding24m, 4mclip_shaped24m, 4mx_clip24m, 4my_clip24m, 4mw_clip24m, 4mh_clip24m)
      Display *4mdisplay24m;
      Window 4mwindow24m;
      Bool *4mbounding_shaped24m, *4mclip_shaped24m; /* RETURN */
      int *4mx_bounding24m, *4my_bounding24m, *4mx_clip24m, *4my_clip24m; /* RETURN */
      unsigned int *4mw_bounding24m, *4mh_bounding24m, *4mw_clip24m, * 4mh_clip24m; /* RETURN */

|__

If the extension is supported, 4mXShapeQueryExtents24m sets
x_bounding, y_bounding, w_bounding, h_bounding to the
extents of the bounding shape and sets x_clip, y_clip,
w_clip, h_clip to the extents of the clip shape.  For
unspecified client regions, the extents of the corresponding
default region are used.

If the extension is supported, a nonzero value is returned;
otherwise, zero is returned.


__
|
XShapeSelectInput(4mdisplay24m, 4mwindow24m, 4mmask24m)
     Display *4mdisplay24m;
     Window 4mwindow24m;
     unsigned long 4mmask24m;

|__

To make this extension more compatible with other inter-
faces, although only one event type can be selected via the
extension, 4mXShapeSelectInput24m provides a general mechanism
similar to the standard Xlib binding for window events.	 A
mask value has been defined, 4mShapeNotifyMask24m that is the
only valid bit in mask that may be specified.  The structure
for this event is defined as follows:






			      1m60m





       X Nonrectangular Window Shape Extension Library

__
|
typedef struct {
    int type;  /* of event */
    unsigned long serial;/* # of last request processed by server */
    Bool send_event;/* true if this came frome a SendEvent request */
    Display *display;/* Display the event was read from */
    Window window;/* window of event */
    int kind;  /* ShapeBounding or ShapeClip */
    int x, y;  /* extents of new region */
    unsigned width, height;
    Time time; /* server timestamp when region changed */
    Bool shaped;/* true if the region exists */
} XShapeEvent;

|__


__
|
unsigned long
XShapeInputSelected(4mdisplay24m, 4mwindow24m)
     Display *4mdisplay24m;
     Window 4mwindow24m;

|__

4mXShapeInputSelected24m returns the current input mask for
extension events on the specified window; the value returned
if 4mShapeNotify24m is selected for is 4mShapeNotifyMask24m; other-
wise, it returns zero.	If the extension is not supported,
it returns zero.


__
|
XRectangle *
XShapeGetRectangles(4mdisplay24m, 4mwindow24m, 4mkind24m, 4mcount24m, 4mordering24m)
      Display *4mdisplay24m;
      Window 4mwindow24m;
      int 4mkind24m;
      int *4mcount24m; /* RETURN */
      int *4mordering24m; /* RETURN */

|__

If the extension is not supported, 4mXShapeGetRectangles0m
returns NULL.  Otherwise, it returns a list of rectangles
that describe the region specified by kind.

1m4.  Glossary0m







			      1m70m





       X Nonrectangular Window Shape Extension Library


1mbounding region0m

     The area of the parent window that this window will
     occupy.  This area is divided into two parts:  the bor-
     der and the interior.

1mclip region0m

     The interior of the window, as a subset of the bounding
     region.  This region describes the area that will be
     painted with the window background when the window is
     cleared, will contain all graphics output to the win-
     dow, and will clip any subwindows.

1mdefault bounding region0m

     The rectangular area, as described by the core protocol
     window size, that covers the interior of the window and
     its border.

1mdefault clip region0m

     The rectangular area, as described by the core protocol
     window size, that covers the interior of the window and
     excludes the border.

1mclient bounding region0m

     The region associated with a window that is directly
     modified via this extension when specified by 4mShape-0m
     4mBounding24m.  This region is used in conjunction with the
     default bounding region to produce the effective bound-
     ing region.

1mclient clip region0m

     The region associated with a window that is directly
     modified via this extension when specified by
     4mShapeClip24m.  This region is used in conjunction with the
     default clip region and the client bounding region to
     produce the effective clip region.

1meffective bounding region0m

     The actual shape of the window on the screen, including
     border and interior (but excluding the effects of over-
     lapping windows).	When a window has a client bounding
     region, the effective bounding region is the intersec-
     tion of the default bounding region and the client
     bounding region.  Otherwise, the effective bounding
     region is the same as the default bounding region.






			      1m80m





       X Nonrectangular Window Shape Extension Library


1meffective clip region0m

     The actual shape of the interior of the window on the
     screen (excluding the effects of overlapping windows).
     When a window has a client clip region or a client
     bounding region, the effective clip region is the
     intersection of the default clip region, the client
     clip region (if any) and the client bounding region (if
     any).  Otherwise, the effective clip region is the same
     as the default clip region.















































			      1m90m