summaryrefslogtreecommitdiff
path: root/specs/tog-cup.xml
blob: a35ff8c5e1d1a50f3d97d68414b19ab13404c384 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
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
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
                   "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd"
[
<!ENTITY % defs SYSTEM "defs.ent"> %defs;
]>


<book id="tog-cup">

<bookinfo>
   <title>Colormap Utilization Policy and Extension</title>
   <subtitle>X Project Team Standard</subtitle>
   <releaseinfo>X Version 11, Release &fullrelvers;</releaseinfo>
   <releaseinfo>Version 1.0</releaseinfo>
   <authorgroup>
      <author>
         <firstname>Kaleb</firstname>
         <othername>S.</othername>
         <surname>Keithley</surname>
         <affiliation><orgname>The Open Group</orgname></affiliation>
      </author>
   </authorgroup>
   <copyright><year>1986-1997</year><holder>The Open Group</holder></copyright>

<legalnotice>

<para>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this
software and associated documentation files (the Software), to use the
Software
without restriction, including, without limitation, the rights to copy,
modify, merge,
publish, distribute and sublicense the Software, to make, have made,
license and
distribute derivative works thereof, and to permit persons to whom the
Software is
furnished to do so, subject to the following conditions:
</para>
<para>
The above copyright notice and the following permission notice shall be
included in all copies of the Software:
</para>
<para>
THE SOFTWARE IS PROVIDED &ldquo;AS IS&rdquo;, WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-
INFRINGEMENT.  IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN
CONNNECTION WITH THE SOFTWARE OR THE USE OF OTHER DEALINGS IN
THE SOFTWARE.
</para>
<para>
Except as contained in this notice, the name of The Open Group shall not be
used in
advertising or otherwise to promote the use or other dealings in this
Software without prior written authorization from The Open Group.
</para>
<para>
X Window System is a trademark of The Open Group.
</para>

</legalnotice>
</bookinfo>

<chapter id="Overview">
<title>Overview</title>
<para>
This extension has three purposes: a) to provide mechanism for a special
application (a colormap manager) to discover any special colormap
requirements, e.g. the colormap entries that are nominally reserved for
desktop colors in the MS-Windows environment and initialize the default
colormap so that it can be more easily shared; and b) to encourage colormap
sharing and reduce colormap flashing on low-end 8-bit frame buffers by
providing a policy for sharing; and c) when colormaps aren't shared,
define a behavior in the X server color allocation scheme to reduce
colormap flashing.
</para>

<para>
To encourage colormap sharing and accomodate special colormap requirements
two new protocols are defined: the first provides a way to query the
server for a list of reserved colormap entries, and the second is a way
to initialize read-only (shareable) colormap entries at specific locations
in a colormap.
</para>

<para>
To minimize colormap flashing when the root window's default visual is one
of GrayScale, PseudoColor, or DirectColor, and a private colormap for the
default visual is being used, a minor (but compatible) change to the
server implementation of the AllocColor and AllocNamedColor requests is
required. Where the core protocol says nothing about the pixel values
returned, when this extension is in effect, the AllocColor and AllocNamedColor
requests will first look for a matching color in the default colormap, and,
if a match is found and the same cell in the private colormap has not
already been allocated, the color will be allocated in the private colormap
at the same locaton as in the default colormap (instead of in the first
available location.)
</para>
</chapter>

<chapter id="Requests">
<title>Requests</title>
<para>
<function>QueryVersion</function>
</para>

<informaltable frame="none">
  <?dbfo keep-together="always" ?>
  <tgroup cols='1' align='left' colsep='0' rowsep='0'>
  <colspec colname='c1' colwidth="1.0*"/>
  <tbody>
    <row>
      <entry>
client_major_version: CARD16
      </entry>
    </row>
    <row>
      <entry>
client_minor_version: CARD16
      </entry>
    </row>
    <row>
      <entry>
=&gt;
      </entry>
    </row>
    <row>
      <entry>
server_major_version: CARD16
      </entry>
    </row>
    <row>
      <entry>
server_minor_version: CARD16
      </entry>
    </row>
  </tbody>
  </tgroup>
</informaltable>

<para>
If supplied, the client_major_version and client_minor_version indicate
what version of the protocol the client wants the server to implement.
The server version numbers returned indicate the protocol this extension
actually supports. This might not equal the version sent by the client.
An implementation can (but need not) support more than one version
simultaneously. The server_major_version and the server_minor_version
are a mechanism to support future revisions of the TOG-CUP protocol that
may be necessary. In general, the major version would increment for
incompatible changes, and the minor version would increment for small
upward-compatible changes. Servers that support the protocol defined in
this document will return a server_major_version of one (1), and a
server_minor_version of zero (0).
</para>

<para>
<function>GetReservedColormapEntries</function>
</para>

<informaltable frame="none">
  <?dbfo keep-together="always" ?>
  <tgroup cols='1' align='left' colsep='0' rowsep='0'>
  <colspec colname='c1' colwidth="1.0*"/>
  <tbody>
    <row>
      <entry>
screen: CARD32
      </entry>
    </row>
    <row>
      <entry>
=&gt;
      </entry>
    </row>
    <row>
      <entry>
entries: LISTofCOLORITEM
      </entry>
    </row>
  </tbody>
  </tgroup>
</informaltable>

<para>
This request returns a list of colormap entries (pixels) that are reserved
by the system, e.g. MS-Windows reserved desktop colors. This list will, at a
minimum, contain entries for the BlackPixel and WhitePixel of the specified
screen. The do-red, do-green, and do-blue elements of the COLORITEMs are
unused in this reply.
</para>

<para>
Rationale: There are colormap entries (pixels) that, e.g., MS-Windows
desktop reserves as desktop colors, that should not be altered. If they
are altered then X programs will cause colormap flashing between X and
MS-Windows applications running/displaying on the same desktop.
</para>

<para>
<function>StoreColors</function>
</para>

<informaltable frame="none">
  <?dbfo keep-together="always" ?>
  <tgroup cols='1' align='left' colsep='0' rowsep='0'>
  <colspec colname='c1' colwidth="1.0*"/>
  <tbody>
    <row>
      <entry>
cmap: COLORMAP
      </entry>
    </row>
    <row>
      <entry>
items: LISTofCOLORITEM
      </entry>
    </row>
    <row>
      <entry>
=&gt;
      </entry>
    </row>
    <row>
      <entry>
items: LISTofCOLORITEM
      </entry>
    </row>
  </tbody>
  </tgroup>
</informaltable>

<para>
This request changes the colormap entries of the specified pixels. The
colormap entries are allocated as if by an AllocColor request. The do-red,
do-green, and do-blue elements of the COLORITEMs are unused in this request.
A boolean alloc-ok element (a bit) is returned indicating whether the
particular pixel was successfully allocated or not. If successfully
allocated the RGB and pixel are returned.
</para>

<para>
A Value error is generated if a pixel is not a valid index into cmap. A
BadMatch error is generated if if cmap does not belong to a GrayScale,
PseudoColor, or DirectColor visual.
</para>

</chapter>

<chapter id="Events_and_Errors">
<title>Events and Errors</title>
<para>
No new events or errors are defined by this extension.
</para>

</chapter>
<chapter id='Changes_to_existing_protocol'>
<title>Changes to existing protocol.</title>
<para>
None.
</para>
</chapter>

<chapter id="Encoding">
<title>Encoding</title>
<para>
The name of this extension is "TOG-CUP".
</para>

<para>
The conventions used here are the same as those for the core X11
Protocol Encoding.
</para>

<literallayout class="monospaced">
<function>QueryVersion</function>
     1     CARD8               opcode
     1     0                   TOG-CUP opcode
     2     2                   request length
     2     CARD16              client_major_version
     2     CARD16              client_minor_version
=&gt;
     1     1                   reply
     1                         unused
     2     CARD16              sequence number
     4     0                   length
     2     CARD16              server_major_version
     2     CARD16              server_minor_number
     20                        unused
</literallayout>

<literallayout class="monospaced">
<function>GetReservedColormapEntries</function>
     1     CARD8               opcode
     1     1                   TOG-CUP opcode
     2     2                   request length
     4     CARD32              screen
=&gt;
     1     1                   reply
     1                         unused
     2     CARD16              sequence number
     4     3n                  length
     24                        unused
     12n   LISTofCOLORITEM     items
</literallayout>

<literallayout class="monospaced">
<function>StoreColors</function>
     1     CARD8               opcode
     1     2                   TOG-CUP opcode
     2     2+3n                request length
     4     COLORMAP            cmap
     12n   LISTofCOLORITEM     items
=&gt;
     1     1                   reply
     1                         unused
     2     CARD16              sequence number
     4     3n                  length
     24                        unused
     12n   LISTofCOLORITEM     items
</literallayout>

<para>
(The definition of COLORITEM here is only for the purpose of defining the
additional alloc-ok member in the CUPStoreColors reply.)
</para>

<literallayout class="monospaced">
  COLORITEM
     4     CARD32              pixel
     2     CARD16              red
     2     CARD16              green
     2     CARD16              blue
     1                         alloc-ok
           #x07                unused
           #x08                alloc-ok (1 is True, 0 is False)
           #xF0                unused
     1                         unused
</literallayout>
</chapter>

<chapter id="C_Language_Binding">
<title>C Language Binding</title>

<para>
The C functions provide direct access to the protocol and add no additional
semantics.  For complete details on the effects of these functions, refer
to the appropriate protocol request, which can be derived by deleting XCup
at the start of the function. All functions that have return type Status
will return nonzero for success and zero for failure.
</para>

<para>
The include file for this extension is
<function>&lt;X11/extensions/Xcup.h&gt;</function>.
</para>

<funcsynopsis id='XCupQueryVersion'>
<funcprototype>
  <funcdef>Status <function> XCupQueryVersion</function></funcdef>
  <paramdef>Display*<parameter> display</parameter></paramdef>
  <paramdef>int*<parameter> major_version_return</parameter></paramdef>
  <paramdef>int*<parameter> minor_version_return</parameter></paramdef>
</funcprototype>
</funcsynopsis>

<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>display</emphasis>
    </term>
    <listitem>
      <para>
Specifies the connection to the X server.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>major_version_return</emphasis>
    </term>
    <listitem>
      <para>
Returns the major version supported by the server.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>minor_version_return</emphasis>
    </term>
    <listitem>
      <para>
Returns the minor version supported by the server.
    </para>
  </listitem>
  </varlistentry>
</variablelist>


<para>
XCupQueryVersions sets major_version_return and minor_version_return to
the major and minor TOG-CUP protocol version supported by the server.  If
the TOG-CUP library is compatible with the version returned by the server,
it returns nonzero.  If dpy does not support the TOG-CUP extension, or if
there was an error during communication with the server, or if the server
and library protocol versions are incompatible, it returns zero.  No other
XCup functions may be called before this function. If a client violates
this rule, the effects of all subsequent XCup calls that it makes are
undefined.
</para>

<para>
To get the list of reserved colormap entries, use
XCupGetReservedColormapEntries.
</para>

<funcsynopsis id='XCupGetReservedColormapEntries'>
<funcprototype>
  <funcdef>Status <function> XCupGetReservedColormapEntries</function></funcdef>
  <paramdef>Display*<parameter> display</parameter></paramdef>
  <paramdef>int<parameter> screen</parameter></paramdef>
  <paramdef>XColor**<parameter> colors_out</parameter></paramdef>
  <paramdef>int*<parameter> ncolors</parameter></paramdef>
</funcprototype>
</funcsynopsis>

<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>display</emphasis>
    </term>
    <listitem>
      <para>
Specifies the connection to the X server.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>colors_out</emphasis>
    </term>
    <listitem>
      <para>
Returns the values reserved by the server.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>ncolors</emphasis>
    </term>
    <listitem>
      <para>
Returns the number of items in colors_out.
    </para>
  </listitem>
  </varlistentry>
</variablelist>

<para>
The XCupGetReservedColormapEntries function gets system specific colormap
entries. E.g. the MS-Windows desktop uses N colormap entries at the beginning
(0..N) and end (256-N..255) of the colormap. Use XFree to free colors_out.
</para>

<para>
To allocate one or more read-only color cells with RGB values, use
XCupStoreColors.
</para>

<funcsynopsis id='XCupStoreColors'>
<funcprototype>
  <funcdef>Status <function> XCupStoreColors</function></funcdef>
  <paramdef>Display*<parameter> display</parameter></paramdef>
  <paramdef>Colormap<parameter> colormap</parameter></paramdef>
  <paramdef>XColor*<parameter> colors_in_out</parameter></paramdef>
  <paramdef>int<parameter> ncolors</parameter></paramdef>
</funcprototype>
</funcsynopsis>

<variablelist>
  <varlistentry>
    <term>
      <emphasis remap='I'>display</emphasis>
    </term>
    <listitem>
      <para>
Specifies the connection to the X server.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>colormap</emphasis>
    </term>
    <listitem>
      <para>
Specifies the colormap.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>colors_in_out</emphasis>
    </term>
    <listitem>
      <para>
Specifies and returns the values actually used in the colormap.
      </para>
    </listitem>
  </varlistentry>
  <varlistentry>
    <term>
      <emphasis remap='I'>ncolors</emphasis>
    </term>
    <listitem>
      <para>
Specifies the number of items in colors_in_out.
    </para>
  </listitem>
  </varlistentry>
</variablelist>

<para>
The XCupStoreColors function changes the colormap entries of the pixel
values specified in the pixel members of the XColor structures. The colormap
entries are allocated as if an AllocColor had been used instead, i.e. the
colors are read-only (shareable). XCupStoreColors returns the number of
colors that were successfully allocated in the colormap.
</para>

</chapter>

<chapter id="Using_the_TOG_CUP_extension_and_Colormap_Utilization_Policy">
<title>Using the TOG-CUP extension and Colormap Utilization Policy</title>
<para>
The X server preallocates any hardware or desktop special colors in the
default colormap; e.g. UNIX X servers preallocate Black and White pixels.
PC X servers should also preallocate the MS-Windows desktop colors. (Note
to implementors: in the Sample Implementation special colors are allocated
in the default colormap in cfbCreateDefColormap for dumb memory framebuffers.)
</para>

<para>
To minimize colormap flash an application which installs its own private
colormap should query the special colors by calling
XCupGetReservedColormapEntries, and can then store those entries (in the
proper location) in its private colormap using XCupStoreColors.
</para>

<para>
Applications which allocate many colors in a screen's default colormap, e.g.
a color-cube or a gray-ramp, should allocate them with XCupStoreColors. By
using XCupStoreColors the colors will be allocated sharable (read-only) and
any other application which allocates the same color will share that color
cell.
</para>
</chapter>

</book>