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