home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 45 / cda45.iso / Linux / XFree86-4.0 / doc / shapelib.TXT < prev    next >
Encoding:
Text File  |  2000-03-09  |  16.6 KB  |  727 lines

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