shapelib.xml revision af9a7ee5
1<?xml version="1.0" encoding="UTF-8" ?>
2<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
3                   "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd"
4[
5<!ENTITY % defs SYSTEM "defs.ent"> %defs;
6]>
7
8<!-- lifted from troff+ms+XMan by doclifter -->
9<book id="shapelib">
10
11<bookinfo>
12   <title>X Nonrectangular Window Shape Extension Library</title>
13   <subtitle>X Consortium Standard</subtitle>
14   <releaseinfo>X Version 11, Release &fullrelvers;</releaseinfo>
15   <releaseinfo>Version 1.0</releaseinfo>
16   <authorgroup>
17      <author>
18         <firstname>Keith</firstname><surname>Packard</surname>
19         <affiliation><orgname>MIT X Consortium</orgname></affiliation>
20      </author>
21   </authorgroup>
22   <copyright><year>1989</year><holder>X Consortium</holder></copyright>
23
24<legalnotice>
25
26<para>
27Permission is hereby granted, free of charge, to any person obtaining a copy
28of this software and associated documentation files
29(the &ldquo;Software&rdquo;), to deal in the Software without restriction,
30including without limitation the rights to use, copy, modify, merge,
31publish, distribute, sublicense, and/or sell copies of the Software, and
32to permit persons to whom the Software is furnished to do so, subject to
33the following conditions:
34</para>
35
36<para>
37The above copyright notice and this permission notice shall be included in
38all copies or substantial portions of the Software.
39</para>
40
41<para>
42THE SOFTWARE IS PROVIDED &ldquo;AS IS&rdquo;, WITHOUT WARRANTY OF ANY
43KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
44OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
45IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
46OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
47ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
48OTHER DEALINGS IN THE SOFTWARE.
49</para>
50
51<para>
52Except as contained in this notice, the name of the X Consortium shall not be
53used in advertising or otherwise to promote the sale, use or other dealings
54in this Software without prior written authorization from the X Consortium.
55</para>
56<para>X Window System is a trademark of The OpenGroup.</para>
57</legalnotice>
58</bookinfo>
59
60<chapter id='overview'>
61<title>Overview</title>
62
63<para>This extension provides arbitrary window and border shapes within
64the X11 protocol.
65</para>
66
67<para>
68The restriction of rectangular windows within the X protocol is a significant
69limitation in the implementation of many styles of user interface.  For
70example, many transient windows would like to display a
71&ldquo;drop shadow&rdquo; to give the illusion of 3 dimensions.  As
72another example, some user interface style guides call for buttons with
73rounded corners; the full simulation of a nonrectangular shape,
74particularly with respect to event distribution and cursor shape, is not
75possible within the core X protocol.  As a final example, round clocks
76and nonrectangular icons are desirable visual addition to the desktop.
77</para>
78
79<para>
80This extension provides mechanisms for changing the visible shape of a
81window to an arbitrary, possibly disjoint, nonrectangular form.  The intent
82of the extension is to supplement the existing semantics, not replace them.
83In particular, it is desirable for clients that are unaware of the
84extension to still be able to cope reasonably with shaped windows.  For
85example, window managers should still be able to negotiate screen
86real estate in rectangular pieces.  Toward this end, any shape specified for
87a window is clipped by the bounding rectangle for the window as specified by
88the window's geometry in the core protocol.  An expected convention would be
89that client programs expand their shape to fill the area offered by the
90window manager.
91</para>
92</chapter>
93
94<chapter id='description'>
95<title>Description</title>
96
97<para>
98Each window (even with no shapes specified) is defined by two regions:  the
99<olink targetdoc='shapelib' targetptr='bounding_region'>bounding region</olink>
100and the
101<olink targetdoc='shapelib' targetptr='clip_region'>clip region</olink>.
102The bounding region is the
103area of the parent window that the window will occupy (including border).
104The clip region is the subset of the bounding region that is available for
105subwindows and graphics.  The area between the bounding region and the
106clip region is defined to be the border of the window.
107</para>
108
109<para>
110A nonshaped window will have a bounding region that is a rectangle spanning
111the window, including its border; the clip region will be a rectangle
112filling the inside dimensions (not including the border).  In this document,
113these areas are referred to as the
114<olink targetdoc='shapelib' targetptr='default_bounding_region'>
115default bounding region</olink> and the
116<olink targetdoc='shapelib' targetptr='default_clip_region'>
117default clip region</olink>.  For a window with
118inside size of <emphasis remap='I'>width</emphasis> by
119<emphasis remap='I'>height</emphasis> and border width
120<emphasis remap='I'>bwidth</emphasis>, the default bounding and clip
121regions are the rectangles (relative to the window origin):
122</para>
123
124<literallayout remap='Ds'>
125bounding.x = -<emphasis remap='I'>bwidth</emphasis>
126bounding.y = -<emphasis remap='I'>bwidth</emphasis>
127bounding.width = <emphasis remap='I'>width</emphasis> + 2 * <emphasis remap='I'>bwidth</emphasis>
128bounding.height = <emphasis remap='I'>height</emphasis> + 2 * <emphasis remap='I'>bwidth</emphasis>
129
130clip.x = 0
131clip.y = 0
132clip.width = <emphasis remap='I'>width</emphasis>
133clip.height = <emphasis remap='I'>height</emphasis>
134</literallayout>
135
136<para>
137This extension allows a client to modify either or both of the bounding or
138clip regions by specifying new regions that combine with the default
139regions.  These new regions are called the
140<olink targetdoc='shapelib' targetptr='client_bounding_region'>
141client bounding region</olink> and the
142<olink targetdoc='shapelib' targetptr='client_clip_region'>
143client clip region</olink>.  They are specified
144relative to the origin of the window and are always defined by offsets
145relative to the window origin (that is, region adjustments are not
146required when the window is moved).  Three mechanisms for specifying
147regions are provided:  a list of rectangles, a bitmap, and an existing
148bounding or clip region from a window.  This is modeled on the specification
149of regions in graphics contexts in the core protocol and allows a variety
150of different uses of the extension.
151</para>
152
153<para>
154When using an existing window shape as an operand in specifying a new shape,
155the client region is used, unless none has been set, in which case the
156default region is used instead.
157</para>
158
159<para>
160The <olink targetdoc='shapelib' targetptr='effective_bounding_region'>
161effective bounding region</olink> of a window is
162defined to be the intersection of the client bounding region with the default
163bounding region.  Any portion of the client bounding region that is not
164included in the default bounding region will not be included in the
165effective bounding region on the screen.  This means that window managers
166(or other geometry managers) used to dealing with rectangular client windows
167will be able to constrain the client to a rectangular area of the screen.
168</para>
169
170<para>
171Construction of the effective bounding region is dynamic; the client bounding
172region is not mutated to obtain the effective bounding region.  If a client
173bounding region is specified that extends beyond the current default bounding
174region, and the window is later enlarged, the effective bounding region will
175be enlarged to include more of the client bounding region.
176</para>
177
178<para>
179The <olink targetdoc='shapelib' targetptr='effective_clip_region'>
180effective clip region</olink> of a window is
181defined to be the intersection of the client clip region with both the
182default clip region and the client bounding region.  Any portion of the
183client clip region that is not included in both the default clip region
184and the client bounding region will not be included in the effective clip
185region on the screen.
186</para>
187
188<para>
189Construction of the effective clip region is dynamic; the client clip region is
190not mutated to obtain the effective clip region.  If a client clip region is
191specified that extends beyond the current default clip region and the
192window or its bounding region is later enlarged, the effective clip region will
193be enlarged to include more of the client clip region if it is included in
194the effective bounding region.
195</para>
196
197<para>
198The border of a window is defined to be the difference between the effective
199bounding region and the effective clip region.  If this region is empty, no
200border is displayed.  If this region is nonempty, the border is filled
201using the border-tile or border-pixel of the window as specified in the core
202protocol.  Note that a window with a nonzero border width will never be able
203to draw beyond the default clip region of the window.  Also note that a zero
204border width does not prevent a window from having a border, since the clip
205shape can still be made smaller than the bounding shape.
206</para>
207
208<para>
209All output to the window and visible regions of any subwindows will be
210clipped to the effective clip region.  The server must not retain window
211contents beyond the effective bounding region with backing store.  The window's
212origin (for graphics operations, background tiling, and subwindow placement)
213is not affected by the existence of a bounding region or clip region.
214</para>
215
216<para>
217Areas that are inside the default bounding region but outside the effective
218bounding region are not part of the window; these areas of the screen will
219be occupied by other windows.  Input events that occur within the default
220bounding region but outside the effective bounding region will be delivered as
221if the window was not occluding the event position.  Events that occur in
222a nonrectangular border of a window will be delivered to that window, just
223as for events that occur in a normal rectangular border.
224</para>
225
226<para>An
227<olink targetdoc='libX11' targetptr='glossary:InputOnly_window'>
228InputOnly</olink>
229window can have its bounding region set, but it is a
230<olink targetdoc='libX11' targetptr='BadMatch'>Match</olink>
231error to attempt to set a clip region on an
232<olink targetdoc='libX11' targetptr='glossary:InputOnly_window'>InputOnly</olink>
233window or to specify its clip region as a source to a request
234in this extension.
235</para>
236
237<para>
238The server must accept changes to the clip region of a root window, but
239the server is permitted to ignore requested changes to the bounding region
240of a root window.  If the server accepts bounding region changes, the contents
241of the screen outside the bounding region are implementation dependent.
242</para>
243</chapter>
244
245<chapter id='c_language_binding'>
246<title>C Language Binding</title>
247
248<para>
249The C functions provide direct access to the protocol and add no additional
250semantics.
251</para>
252
253<para>The include file for this extension is
254&lt;<symbol role='Pn'>X11/extensions/shape.h</symbol>&gt;.
255The defined shape kinds are
256<function>ShapeBounding</function>
257and
258<function>ShapeClip</function>
259The defined region operations are
260<function>ShapeSet</function>
261<function>ShapeUnion</function>
262<function>ShapeIntersect</function>
263<function>ShapeSubtract</function>
264and
265<function>ShapeInvert</function>.</para>
266
267<funcsynopsis id='xshapequeryextension'>
268<funcprototype>
269<funcdef>Bool<function> XShapeQueryExtension</function></funcdef>
270<paramdef>Display <parameter>*display</parameter></paramdef>
271<paramdef>int <parameter>*event_base</parameter></paramdef>
272<paramdef>int <parameter>*error_base</parameter></paramdef>
273</funcprototype>
274</funcsynopsis>
275
276<para>
277<function>XShapeQueryExtension</function>
278returns
279<function>True</function>
280if the specified display supports the SHAPE extension else
281<function>False</function>
282If the extension is supported, *event_base is set to the event number for
283<function>ShapeNotify</function>
284events and *error_base would be set to the error number for the first error for
285this extension.  Because no errors are defined for this version of
286the extension, the value returned here is not defined (nor useful).
287</para>
288
289<funcsynopsis id='xshapequeryversion'>
290<funcprototype>
291<funcdef>Status<function> XShapeQueryVersion</function></funcdef>
292<paramdef>Display<parameter> *display</parameter></paramdef>
293<paramdef>int<parameter> *major_version</parameter></paramdef>
294<paramdef>int<parameter> *minor_version</parameter></paramdef>
295</funcprototype>
296</funcsynopsis>
297
298<para>
299If the extension is supported,
300<function>XShapeQueryVersion</function>
301sets the major and minor version numbers of the
302extension supported by the display and returns a nonzero value.
303Otherwise, the arguments are not set and zero is returned.
304</para>
305
306<funcsynopsis id='xshapecombineregion'>
307<funcprototype>
308<funcdef><function>XShapeCombineRegion</function></funcdef>
309<paramdef>Display<parameter> *display</parameter></paramdef>
310<paramdef>Window<parameter> dest</parameter></paramdef>
311<paramdef>int<parameter> dest_kind</parameter></paramdef>
312<paramdef>int<parameter> x_off</parameter></paramdef>
313<paramdef>int<parameter> y_off</parameter></paramdef>
314<paramdef>int<parameter> region</parameter></paramdef>
315<paramdef>int<parameter> op</parameter></paramdef>
316<paramdef>REGION<parameter> *region</parameter></paramdef>
317</funcprototype>
318</funcsynopsis>
319
320<para>
321<function>XShapeCombineRegion</function>
322converts the specified region into a list of rectangles and calls
323<function>XShapeCombineRectangles</function>
324</para>
325
326<funcsynopsis id='xshapecombinerectangles'>
327<funcprototype>
328<funcdef><function>XShapeCombineRectangles</function></funcdef>
329<paramdef>Display<parameter> *display</parameter></paramdef>
330<paramdef>Window<parameter> dest</parameter></paramdef>
331<paramdef>int<parameter> dest_kind</parameter></paramdef>
332<paramdef>int<parameter> x_off</parameter></paramdef>
333<paramdef>int<parameter> y_off</parameter></paramdef>
334<paramdef>XRectangle<parameter> *rectangles</parameter></paramdef>
335<paramdef>int<parameter> n_rects</parameter></paramdef>
336<paramdef>int<parameter> op</parameter></paramdef>
337<paramdef>int<parameter> ordering</parameter></paramdef>
338</funcprototype>
339</funcsynopsis>
340
341<para>
342If the extension is supported,
343<function>XShapeCombineRectangles</function>
344performs a
345<function>ShapeRectangles</function>
346operation; otherwise, the request is ignored.
347</para>
348
349<funcsynopsis id='xshapecombinemask'>
350<funcprototype>
351<funcdef><function>XShapeCombineMask</function></funcdef>
352<paramdef>Display<parameter> *display</parameter></paramdef>
353<paramdef>int<parameter> dest</parameter></paramdef>
354<paramdef>int<parameter> dest_kind</parameter></paramdef>
355<paramdef>int<parameter> x_off</parameter></paramdef>
356<paramdef>int<parameter> y_off</parameter></paramdef>
357<paramdef>Pixmap<parameter> src</parameter></paramdef>
358<paramdef>int<parameter> op</parameter></paramdef>
359</funcprototype>
360</funcsynopsis>
361
362<para>
363If the extension is supported,
364<function>XShapeCombineMask</function>
365performs a
366<function>ShapeMask</function>
367operation; otherwise, the request is ignored.
368</para>
369
370<funcsynopsis id='xshapecombineshape'>
371<funcprototype>
372<funcdef><function>XShapeCombineShape</function></funcdef>
373<paramdef>Display<parameter> *display</parameter></paramdef>
374<paramdef>Window<parameter> dest</parameter></paramdef>
375<paramdef>int<parameter> dest_kind</parameter></paramdef>
376<paramdef>int<parameter> x_off</parameter></paramdef>
377<paramdef>int<parameter> y_off</parameter></paramdef>
378<paramdef>Window<parameter> src</parameter></paramdef>
379<paramdef>int<parameter> src_kind</parameter></paramdef>
380<paramdef>int<parameter> op</parameter></paramdef>
381</funcprototype>
382</funcsynopsis>
383
384<para>
385If the extension is supported,
386<function>XShapeCombineShape</function>
387performs a
388<function>ShapeCombine</function>
389operation; otherwise, the request is ignored.
390</para>
391
392<funcsynopsis id='xshapeoffsetshape'>
393<funcprototype>
394<funcdef><function>XShapeOffsetShape</function></funcdef>
395<paramdef><parameter>display</parameter></paramdef>
396<paramdef><parameter>dest</parameter></paramdef>
397<paramdef><parameter>dest_kind</parameter></paramdef>
398<paramdef><parameter>x_off</parameter></paramdef>
399<paramdef><parameter>y_off</parameter></paramdef>
400</funcprototype>
401</funcsynopsis>
402
403<para>
404If the extension is supported,
405<function>XShapeOffsetShape</function>
406performs a
407<function>ShapeOffset</function>
408operation; otherwise, the request is ignored.
409</para>
410
411<funcsynopsis id='xshapequeryextents'>
412<funcprototype>
413<funcdef>Status <function>XShapeQueryExtents</function></funcdef>
414<paramdef>Display<parameter> *display</parameter></paramdef>
415<paramdef>Window<parameter> window</parameter></paramdef>
416<paramdef>Bool<parameter> *bounding_shaped</parameter></paramdef>
417<paramdef>int<parameter> *x_bounding</parameter></paramdef>
418<paramdef>int<parameter> *y_bounding</parameter></paramdef>
419<paramdef>unsigned int<parameter> *w_bounding</parameter></paramdef>
420<paramdef>unsigned int<parameter> *h_bounding</parameter></paramdef>
421<paramdef>Bool<parameter> *clip_shaped</parameter></paramdef>
422<paramdef>int<parameter> *x_clip</parameter></paramdef>
423<paramdef>int<parameter> *y_clip</parameter></paramdef>
424<paramdef>unsigned int<parameter> *w_clip</parameter></paramdef>
425<paramdef>unsigned int<parameter> *h_clip</parameter></paramdef>
426</funcprototype>
427</funcsynopsis>
428
429<para>
430If the extension is supported,
431<function>XShapeQueryExtents</function>
432sets x_bounding, y_bounding, w_bounding, h_bounding to the extents of the
433bounding shape and sets x_clip, y_clip, w_clip, h_clip to the extents of
434the clip shape.  For unspecified client regions, the extents of the
435corresponding default region are used.
436</para>
437
438<para>
439If the extension is supported, a nonzero value is returned; otherwise,
440zero is returned.
441</para>
442
443<funcsynopsis id='xshapeselectinput'>
444<funcprototype>
445<funcdef><function>XShapeSelectInput</function></funcdef>
446<paramdef>Display<parameter> *display</parameter></paramdef>
447<paramdef>Window<parameter> window</parameter></paramdef>
448<paramdef>unsigned long<parameter> mask</parameter></paramdef>
449</funcprototype>
450</funcsynopsis>
451
452<para>
453To make this extension more compatible with other interfaces, although
454only one event type can be selected via the extension,
455<function>XShapeSelectInput</function>
456provides a general mechanism similar to the standard Xlib binding for
457window events.  A mask value has been defined,
458<function>ShapeNotifyMask</function>
459that is the only valid bit in mask that may be specified.
460The structure for this event is defined as follows:
461</para>
462
463<literallayout remap='Ds'>
464typedef struct {
465    int type;     /* of event */
466    unsigned long serial;     /* # of last request processed by server */
467    Bool send_event;     /* true if this came frome a SendEvent request */
468    Display *display;     /* Display the event was read from */
469    Window window;     /* window of event */
470    int kind;     /* ShapeBounding or ShapeClip */
471    int x, y;     /* extents of new region */
472    unsigned width, height;
473    Time time;     /* server timestamp when region changed */
474    Bool shaped;     /* true if the region exists */
475} XShapeEvent;
476</literallayout>
477
478<funcsynopsis id='xshapeinputselected'>
479<funcprototype>
480<funcdef>unsigned long <function>XShapeInputSelected</function></funcdef>
481<paramdef>Display<parameter> *display</parameter></paramdef>
482<paramdef>Window<parameter> window</parameter></paramdef>
483</funcprototype>
484</funcsynopsis>
485
486<para>
487<function>XShapeInputSelected</function>
488returns the current input mask for extension events on the specified
489window; the value returned if
490<function>ShapeNotify</function>
491is selected for is
492<function>ShapeNotifyMask</function>
493otherwise, it returns zero.
494If the extension is not supported, it returns zero.
495</para>
496
497<funcsynopsis id='xshapegetrectangles'>
498<funcprototype>
499<funcdef>XRectangle<function> *XShapeGetRectangles</function></funcdef>
500<paramdef>Display<parameter> *display</parameter></paramdef>
501<paramdef>Window<parameter> window</parameter></paramdef>
502<paramdef>int<parameter> kind</parameter></paramdef>
503<paramdef>int<parameter> *count</parameter></paramdef>
504<paramdef>int<parameter> *ordering</parameter></paramdef>
505</funcprototype>
506</funcsynopsis>
507
508<para>
509If the extension is not supported,
510<function>XShapeGetRectangles</function>
511returns NULL.  Otherwise, it returns a list of rectangles that describe the
512region specified by kind.
513</para>
514</chapter>
515
516<glossary id='glossary'>
517
518<glossentry id='bounding_region'>
519  <glossterm>bounding region</glossterm>
520  <glossdef><para>The area of the parent window that this window will occupy.
521This area is divided into two parts:  the border and the interior.</para>
522  </glossdef>
523</glossentry>
524
525<glossentry id='clip_region'>
526  <glossterm>clip region</glossterm>
527  <glossdef><para>The interior of the window, as a subset of the bounding
528region.  This region describes the area that will be painted with the
529window background when the window is cleared, will contain all graphics
530output to the window, and will clip any subwindows.</para></glossdef>
531</glossentry>
532
533<glossentry id='default_bounding_region'>
534  <glossterm>default bounding region</glossterm>
535  <glossdef><para>The rectangular area, as described by the core protocol
536window size, that covers the interior of the window and its border.</para>
537  </glossdef>
538</glossentry>
539
540<glossentry id='default_clip_region'>
541  <glossterm>default clip region</glossterm>
542  <glossdef><para>The rectangular area, as described by the core protocol
543window size, that covers the interior of the window and excludes the border.
544  </para></glossdef>
545</glossentry>
546
547<glossentry id='client_bounding_region'>
548  <glossterm>client bounding region</glossterm>
549  <glossdef><para>The region associated with a window that is directly
550modified via this extension when specified by
551<function>ShapeBounding</function>
552This region is used in conjunction with the default bounding region
553to produce the effective bounding region.</para></glossdef>
554</glossentry>
555
556<glossentry id='client_clip_region'>
557  <glossterm>client clip region</glossterm>
558  <glossdef><para>The region associated with a window that is directly
559modified via this extension when specified by
560<function>ShapeClip</function>
561This region is used in conjunction with the default clip region
562and the client bounding region to produce the effective clip region.</para>
563  </glossdef>
564</glossentry>
565
566<glossentry id='effective_bounding_region'>
567  <glossterm>effective bounding region</glossterm>
568  <glossdef><para>The actual shape of the window on the screen, including
569border and interior (but excluding the effects of overlapping windows).
570When a window has a client bounding region, the effective bounding region
571is the intersection of the default bounding region and the client bounding
572region.  Otherwise, the effective bounding region is the same as the
573default bounding region.</para>
574  </glossdef>
575</glossentry>
576
577<glossentry id='effective_clip_region'>
578  <glossterm>effective clip region</glossterm>
579  <glossdef><para>The actual shape of the interior of the window on the
580screen (excluding the effects of overlapping windows).  When a window
581has a client clip region or a client bounding region, the effective
582clip region is the intersection of the default clip region, the client
583clip region (if any) and the client bounding region (if any).  Otherwise,
584the effective clip region is the same as the default clip region.</para>
585  </glossdef>
586</glossentry>
587</glossary>
588</book>
589