home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 August - Disc 2 / chip_20018102_hu.iso / linux / X-4.1.0 / doc / tog-cup.txt < prev    next >
Text File  |  2001-06-27  |  11KB  |  595 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13.  
  14.  
  15.  
  16.  
  17.  
  18.      Colormap Utilization Policy and Extension
  19.  
  20.  
  21.  
  22.             Version 1.0
  23.           X Project Team Standard
  24.          X Version 11, Release 6.4
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.              Kaleb S. KEITHLEY
  32.                The Open Group
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42. Copyright (C) 1986-1997   The Open Group    All Rights
  43. Reserved
  44.  
  45. Permission is hereby granted, free of charge, to any person
  46. obtaining a copy of this software and associated documenta-
  47. tion files (the Software), to use the Software without
  48. restriction, including, without limitation, the rights to
  49. copy, modify, merge, publish, distribute and sublicense the
  50. Software, to make, have made, license and distribute deriva-
  51. tive works thereof, and to permit persons to whom the Soft-
  52. ware is furnished to do so, subject to the following condi-
  53. tions:
  54.  
  55. The above copyright notice and the following permission
  56. notice shall be included in all copies of the Software:
  57.  
  58. THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY
  59. KIND, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
  60. WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73. PURPOSE AND NON- INFRINGEMENT.    IN NO EVENT SHALL THE OPEN
  74. GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  75. WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  76. FROM, OUT OF, OR IN CONNNECTION WITH THE SOFTWARE OR THE USE
  77. OF OTHER DEALINGS IN THE SOFTWARE.
  78.  
  79. Except as contained in this notice, the name of The Open
  80. Group shall not be used in advertising or otherwise to pro-
  81. mote the use or other dealings in this Software without
  82. prior written authorization from The Open Group.
  83.  
  84. X Window System is a trademark of The Open Group.
  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 has three purposes: a) to provide mechanism
  142. for a special application (a colormap manager) to discover
  143. any special colormap requirements, e.g. the colormap entries
  144. that are nominally reserved for desktop colors in the MS-
  145. Windows environment and initialize the default colormap so
  146. that it can be more easily shared; and b) to encourage col-
  147. ormap sharing and reduce colormap flashing on low-end 8-bit
  148. frame buffers by providing a policy for sharing; and c) when
  149. colormaps aren't shared, define a behavior in the X server
  150. color allocation scheme to reduce colormap flashing.
  151.  
  152. To encourage colormap sharing and accomodate special col-
  153. ormap requirements two new protocols are defined: the first
  154. provides a way to query the server for a list of reserved
  155. colormap entries, and the second is a way to initialize
  156. read-only (shareable) colormap entries at specific locations
  157. in a colormap.
  158.  
  159. To minimize colormap flashing when the root window's default
  160. visual is one of GrayScale, PseudoColor, or DirectColor, and
  161. a private colormap for the default visual is being used, a
  162. minor (but compatible) change to the server implementation
  163. of the AllocColor and AllocNamedColor requests is required.
  164. Where the core protocol says nothing about the pixel values
  165. returned, when this extension is in effect, the AllocColor
  166. and AllocNamedColor requests will first look for a matching
  167. color in the default colormap, and, if a match is found and
  168. the same cell in the private colormap has not already been
  169. allocated, the color will be allocated in the private col-
  170. ormap at the same locaton as in the default colormap
  171. (instead of in the first available location.)
  172.  
  173. 2.  Requests
  174.  
  175. __
  176. |    QueryVersion
  177.  
  178.      client_major_version: CARD16
  179.      client_minor_version: CARD16
  180.  
  181.   =>
  182.  
  183.      server_major_version: CARD16
  184.      server_minor_version: CARD16
  185. |__
  186.  
  187. If supplied, the client_major_version and client_minor_ver-
  188. sion indicate what version of the protocol the client wants
  189. the server to implement.  The server version numbers
  190. returned indicate the protocol this extension actually sup-
  191. ports. This might not equal the version sent by the client.
  192. An implementation can (but need not) support more than one
  193.  
  194.  
  195.  
  196.                   1
  197.  
  198.  
  199.  
  200.  
  201.  
  202.     X11 Colormap Utilization Policy and Extension
  203.  
  204.  
  205. version simultaneously. The server_major_version and the
  206. server_minor_version are a mechanism to support future revi-
  207. sions of the TOG-CUP protocol that may be necessary. In gen-
  208. eral, the major version would increment for incompatible
  209. changes, and the minor version would increment for small
  210. upward-compatible changes. Servers that support the protocol
  211. defined in this document will return a server_major_version
  212. of one (1), and a server_minor_version of zero (0).
  213.  
  214. __
  215. |    GetReservedColormapEntries
  216.  
  217.      screen: CARD32
  218.  
  219.   =>
  220.  
  221.      entries: LISTofCOLORITEM
  222. |__
  223.  
  224. This request returns a list of colormap entries (pixels)
  225. that are reserved by the system, e.g. MS-Windows reserved
  226. desktop colors. This list will, at a minimum, contain
  227. entries for the BlackPixel and WhitePixel of the specified
  228. screen. The do-red, do-green, and do-blue elements of the
  229. COLORITEMs are unused in this reply.
  230.  
  231. Rationale: There are colormap entries (pixels) that, e.g.,
  232. MS-Windows desktop reserves as desktop colors, that should
  233. not be altered. If they are altered then X programs will
  234. cause colormap flashing between X and MS-Windows applica-
  235. tions running/displaying on the same desktop.
  236.  
  237. __
  238. |    StoreColors
  239.  
  240.      cmap: COLORMAP
  241.      items: LISTofCOLORITEM
  242.  
  243.   =>
  244.  
  245.      items: LISTofCOLORITEM
  246. |__
  247.  
  248. This request changes the colormap entries of the specified
  249. pixels. The colormap entries are allocated as if by an
  250. AllocColor request. The do-red, do-green, and do-blue ele-
  251. ments of the COLORITEMs are unused in this request.  A
  252. boolean alloc-ok element (a bit) is returned indicating
  253. whether the particular pixel was successfully allocated or
  254. not. If successfully allocated the RGB and pixel are
  255. returned.
  256.  
  257. A Value error is generated if a pixel is not a valid index
  258. into cmap. A BadMatch error is generated if if cmap does not
  259.  
  260.  
  261.  
  262.                   2
  263.  
  264.  
  265.  
  266.  
  267.  
  268.     X11 Colormap Utilization Policy and Extension
  269.  
  270.  
  271. belong to a GrayScale, PseudoColor, or DirectColor visual.
  272.  
  273.  
  274. 3.  Events and Errors
  275.  
  276. No new events or errors are defined by this extension.
  277.  
  278.  
  279. 4.  Changes to existing protocol.
  280.  
  281. None.
  282.  
  283.  
  284. 5.  Encoding
  285.  
  286. The name of this extension is "TOG-CUP".
  287.  
  288. The conventions used here are the same as those for the core
  289. X11 Protocol Encoding.
  290.  
  291.  
  292. QueryVersion
  293.   1  CARD8         opcode
  294.   1  0             TOG-CUP opcode
  295.   2  2             request length
  296.   2  CARD16         client_major_version
  297.   2  CARD16         client_minor_version
  298.  
  299.  
  300.  =>
  301.   1  1             reply
  302.   1             unused
  303.   2  CARD16         sequence number
  304.   4  0             length
  305.   2  CARD16         server_major_version
  306.   2  CARD16         server_minor_number
  307.   20             unused
  308.  
  309.  
  310.  
  311. GetReservedColormapEntries
  312.   1  CARD8         opcode
  313.   1  1             TOG-CUP opcode
  314.   2  2             request length
  315.   4  CARD32         screen
  316.  
  317.  
  318.  =>
  319.   1  1             reply
  320.   1             unused
  321.   2  CARD16         sequence number
  322.   4  3n          length
  323.   24             unused
  324.   12n           LISTofCOLORITEMitems
  325.  
  326.  
  327.  
  328.                   3
  329.  
  330.  
  331.  
  332.  
  333.  
  334.     X11 Colormap Utilization Policy and Extension
  335.  
  336.  
  337. StoreColors
  338.   1  CARD8         opcode
  339.   1  2             TOG-CUP opcode
  340.   2  2+3n         request length
  341.   4  COLORMAP         cmap
  342.   12n           LISTofCOLORITEMitems
  343.  
  344.  
  345.  =>
  346.   1  1             reply
  347.   1             unused
  348.   2  CARD16         sequence number
  349.   4  3n          length
  350.   24             unused
  351.   12n LISTofCOLORITEM     items
  352.  
  353.  
  354. (The definition of COLORITEM here is only for the purpose of
  355. defining the additional alloc-ok member in the CUPStoreCol-
  356. ors reply.)
  357.  
  358.   COLORITEM
  359.   4  CARD32         pixel
  360.   2  CARD16         red
  361.   2  CARD16         green
  362.   2  CARD16         blue
  363.   1             alloc-ok
  364.      #x07      unused
  365.      #x08      alloc-ok (1 is True, 0 is False)
  366.      #xF0      unused
  367.   1             unused
  368.  
  369.  
  370.  
  371. 6.  C Language Binding
  372.  
  373. The C functions provide direct access to the protocol and
  374. add no additional semantics.  For complete details on the
  375. effects of these functions, refer to the appropriate proto-
  376. col request, which can be derived by deleting XCup at the
  377. start of the function. All functions that have return type
  378. Status will return nonzero for success and zero for failure.
  379.  
  380. The include file for this extension is
  381. <X11/extensions/Xcup.h>.
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.                   4
  395.  
  396.  
  397.  
  398.  
  399.  
  400.     X11 Colormap Utilization Policy and Extension
  401.  
  402. __
  403. |
  404. StatusXCupQueryVersion(
  405.     Display* display,
  406.     int* major_version_return,
  407.     int* minor_version_return)
  408.  
  409. |__
  410.  
  411.  
  412. display   Specifies the connection to the X server.
  413.  
  414. major_version_return
  415.       Returns the major version supported by the server.
  416.  
  417. minor_version_return
  418.       Returns the minor version supported by the server.
  419.  
  420. XCupQueryVersions sets major_version_return and minor_ver-
  421. sion_return to the major and minor TOG-CUP protocol version
  422. supported by the server.  If the TOG-CUP library is compati-
  423. ble with the version returned by the server, it returns
  424. nonzero.  If dpy does not support the TOG-CUP extension, or
  425. if there was an error during communication with the server,
  426. or if the server and library protocol versions are incompat-
  427. ible, it returns zero.    No other XCup functions may be
  428. called before this function. If a client violates this rule,
  429. the effects of all subsequent XCup calls that it makes are
  430. undefined.
  431.  
  432. To get the list of reserved colormap entries, use XCupGetRe-
  433. servedColormapEntries.
  434.  
  435. __
  436. |
  437. StatusXCupGetReservedColormapEntries(
  438.     Display* display,
  439.     int screen,
  440.     XColor** colors_out,
  441.     int* ncolors)
  442.  
  443. |__
  444.  
  445.  
  446. display   Specifies the connection to the X server.
  447.  
  448. colors_out
  449.       Returns the values reserved by the server.
  450.  
  451. ncolors   Returns the number of items in colors_out.
  452.  
  453. The XCupGetReservedColormapEntries function gets system spe-
  454. cific colormap entries. E.g. the MS-Windows desktop uses N
  455. colormap entries at the beginning (0..N) and end
  456. (256-N..255) of the colormap. Use XFree to free colors_out.
  457.  
  458.  
  459.  
  460.                   5
  461.  
  462.  
  463.  
  464.  
  465.  
  466.     X11 Colormap Utilization Policy and Extension
  467.  
  468.  
  469. To allocate one or more read-only color cells with RGB val-
  470. ues, use XCupStoreColors.
  471.  
  472. __
  473. |
  474. StatusXCupStoreColors(
  475.     Display* display,
  476.     Colormap colormap,
  477.     XColor* colors_in_out,
  478.     int ncolors)
  479.  
  480. |__
  481.  
  482.  
  483. display   Specifies the connection to the X server.
  484.  
  485. colormap  Specifies the colormap.
  486.  
  487. colors_in_out
  488.       Specifies and returns the values actually used in
  489.       the colormap.
  490.  
  491. ncolors   Specifies the number of items in colors_in_out.
  492.  
  493. The XCupStoreColors function changes the colormap entries of
  494. the pixel values specified in the pixel members of the
  495. XColor structures. The colormap entries are allocated as if
  496. an AllocColor had been used instead, i.e. the colors are
  497. read-only (shareable). XCupStoreColors returns the number of
  498. colors that were successfully allocated in the colormap.
  499.  
  500.  
  501. 7.  Using the TOG-CUP extension and Colormap Utilization
  502. Policy
  503.  
  504. The X server preallocates any hardware or desktop special
  505. colors in the default colormap; e.g. UNIX X servers preallo-
  506. cate Black and White pixels.  PC X servers should also pre-
  507. allocate the MS-Windows desktop colors. (Note to implemen-
  508. tors: in the Sample Implementation special colors are allo-
  509. cated in the default colormap in cfbCreateDefColormap for
  510. dumb memory framebuffers.)
  511.  
  512. To minimize colormap flash an application which installs its
  513. own private colormap should query the special colors by
  514. calling XCupGetReservedColormapEntries, and can then store
  515. those entries (in the proper location) in its private col-
  516. ormap using XCupStoreColors.
  517.  
  518. Applications which allocate many colors in a screen's
  519. default colormap, e.g.    a color-cube or a gray-ramp, should
  520. allocate them with XCupStoreColors. By using XCupStoreColors
  521. the colors will be allocated sharable (read-only) and any
  522. other application which allocates the same color will share
  523.  
  524.  
  525.  
  526.                   6
  527.  
  528.  
  529.  
  530.  
  531.  
  532.     X11 Colormap Utilization Policy and Extension
  533.  
  534.  
  535. that color cell.
  536.  
  537.  
  538.  
  539.  
  540.  
  541.  
  542.  
  543.  
  544.  
  545.  
  546.  
  547.  
  548.  
  549.  
  550.  
  551.  
  552.  
  553.  
  554.  
  555.  
  556.  
  557.  
  558.  
  559.  
  560.  
  561.  
  562.  
  563.  
  564.  
  565.  
  566.  
  567.  
  568.  
  569.  
  570.  
  571.  
  572.  
  573.  
  574.  
  575.  
  576.  
  577.  
  578.  
  579.  
  580.  
  581.  
  582.  
  583.  
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590.  
  591.  
  592.                   7
  593.  
  594.  
  595.