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