Tizen 2.1 base
[framework/uifw/xorg/lib/libx11.git] / specs / libX11 / CH14.xml
1 <?xml version="1.0" encoding="UTF-8" ?>
2 <!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
3           "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd">
4 <chapter id='Inter_Client_Communication_Functions'>
5 <title>Inter-Client Communication Functions</title>
6 <para>
7 The <citetitle>Inter-Client Communication Conventions Manual</citetitle>,
8 hereafter referred to as the <acronym>ICCCM</acronym>,
9 details the X Consortium approved conventions that govern inter-client communications. These
10 conventions ensure peer-to-peer client cooperation in the use of selections, cut buffers, and shared
11 resources as well as client cooperation with window and session managers. For further information,
12 see the <olink targetdoc='icccm' targetptr='icccm'><citetitle>Inter-Client Communication Conventions Manual</citetitle></olink>.
13 </para>
14 <para>
15 Xlib provides a number of standard properties and programming interfaces that are <acronym>ICCCM</acronym>
16 compliant. The predefined atoms for some of these properties are defined in the &lt;X11/Xatom.h&gt;
17 header file, where to avoid name conflicts with user symbols their #define name has an XA_ prefix.
18 For further information about atoms and properties,
19 see <link linkend="Properties_and_Atoms">section 4.3</link>.
20 </para>
21 <para>
22 Xlib’s selection and cut buffer mechanisms provide the primary programming interfaces by which
23 peer client applications communicate with each other
24 (see sections <link linkend="Selections">4.5</link> and
25 <link linkend="Using_Cut_Buffers">16.6</link>). The functions
26 discussed in this chapter provide the primary programming interfaces by which client applications
27 communicate with their window and session managers as well as share standard colormaps.
28 </para>
29 <para>
30 The standard properties that are of special interest for communicating with window and session
31 managers are:
32 </para>
33
34 <informaltable frame='topbot'>
35   <?dbfo keep-together="always" ?>
36   <tgroup cols='4' align='left' colsep='0' rowsep='0'>
37   <colspec colname='c1' colwidth='3.0*'/>
38   <colspec colname='c2' colwidth='2.3*'/>
39   <colspec colname='c3' colwidth='0.9*'/>
40   <colspec colname='c4' colwidth='2.7*'/>
41   <thead>
42     <row rowsep='1'>
43       <entry>Name</entry>
44       <entry>Type</entry>
45       <entry>Format</entry>
46       <entry>Description</entry>
47     </row>
48   </thead>
49   <tbody>
50     <row>
51       <entry><property>WM_CLASS</property></entry>
52       <entry>STRING</entry>
53       <entry>8</entry>
54       <entry>Set by application programs to allow
55       window and session managers to
56       obtain the application’s resources
57       from the resource database.
58       </entry>
59     </row>
60     <row>
61       <entry><property>WM_CLIENT_MACHINE</property></entry>
62       <entry>TEXT</entry>
63       <entry></entry>
64       <entry>The string name of the machine on
65       which the client application is running.
66       </entry>
67     </row>
68     <row>
69       <entry><property>WM_COLORMAP_WINDOWS</property></entry>
70       <entry>WINDOWS</entry>
71       <entry>32</entry>
72       <entry>The list of window IDs that may
73       need a different colormap from that
74       of their top-level window.
75       </entry>
76     </row>
77     <row>
78       <entry><property>WM_COMMAND</property></entry>
79       <entry>TEXT</entry>
80       <entry></entry>
81       <entry>The command and arguments, null
82       separated, used to invoke the application.
83       </entry>
84     </row>
85     <row>
86       <entry><property>WM_HINTS</property></entry>
87       <entry><property>WM_HINTS</property></entry>
88       <entry>32</entry>
89       <entry>Additional hints set by the client for
90       use by the window manager. The C
91       type of this property is XWMHints.
92       </entry> 
93     </row>
94     <row>
95       <entry><property>WM_ICON_NAME</property></entry>
96       <entry>TEXT</entry>
97       <entry></entry>
98       <entry>The name to be used in an icon.</entry>
99     </row>
100     <row>
101       <entry><property>WM_ICON_SIZE</property></entry>
102       <entry><property>WM_ICON_SIZE</property></entry>
103       <entry>32</entry>
104       <entry>The window manager may set this
105       property on the root window to
106       specify the icon sizes it supports.
107       The C type of this property is
108       XIconSize.
109       </entry>
110     </row>
111     <row>
112       <entry><property>WM_NAME</property></entry>
113       <entry>TEXT</entry>
114       <entry></entry>
115       <entry>The name of the application.</entry>
116     </row>
117     <row>
118       <entry><property>WM_NORMAL_HINTS</property></entry>
119       <entry><property>WM_NORMAL_HINTS</property></entry>
120       <entry>32</entry>
121       <entry>Size hints for a window in its
122       normal state. The C type of this
123       property is XSizeHints.
124       </entry>
125     </row>
126     <row>
127       <entry><property>WM_PROTOCOLS</property></entry>
128       <entry>ATOM</entry>
129       <entry>32</entry>
130       <entry>List of atoms that identify the 
131       communications protocols between the
132       client and window manager in
133       which the client is willing to participate.
134       </entry>
135     </row>
136     <row>
137       <entry><property>WM_STATE</property></entry>
138       <entry><property>WM_STATE</property></entry>
139       <entry>32</entry>
140       <entry>Intended for communication
141       between window and session managers only.
142       </entry>
143     </row>
144     <row>
145       <entry><property>WM_TRANSIENT_FOR</property></entry>
146       <entry>WINDOW</entry>
147       <entry>32</entry>
148       <entry>Set by application programs to 
149       indicate to the window manager that a
150       transient top-level window, such as a
151       dialog box.
152       </entry>
153     </row>
154   </tbody>
155   </tgroup>
156 </informaltable>
157
158 <para>
159 The remainder of this chapter discusses:
160 </para>
161
162 <itemizedlist>
163   <listitem><para>Client to window manager communication</para></listitem>
164   <listitem><para>Client to session manager communication</para></listitem>
165   <listitem><para>Standard colormaps</para></listitem>
166 </itemizedlist>
167
168 <sect1 id="Client_to_Window_Manager_Communication">
169 <title>Client to Window Manager Communication</title>
170 <!-- .XS -->
171 <!-- (SN Client to Window Manager Communication -->
172 <!-- .XE -->
173 <para>
174 <!-- .LP -->
175 This section discusses how to:
176 </para>
177 <itemizedlist>
178   <listitem>
179     <para>
180 Manipulate top-level windows
181     </para>
182   </listitem>
183   <listitem>
184     <para>
185 Convert string lists
186     </para>
187   </listitem>
188   <listitem>
189     <para>
190 Set and read text properties
191     </para>
192   </listitem>
193   <listitem>
194     <para>
195 Set and read the <property>WM_NAME</property> property
196     </para>
197   </listitem>
198   <listitem>
199     <para>
200 Set and read the <property>WM_ICON_NAME</property> property
201     </para>
202   </listitem>
203   <listitem>
204     <para>
205 Set and read the <property>WM_HINTS</property> property
206     </para>
207   </listitem>
208   <listitem>
209     <para>
210 Set and read the <property>WM_NORMAL_HINTS</property> property
211     </para>
212   </listitem>
213   <listitem>
214     <para>
215 Set and read the <property>WM_CLASS</property> property
216     </para>
217   </listitem>
218   <listitem>
219     <para>
220 Set and read the <property>WM_TRANSIENT_FOR</property> property
221     </para>
222   </listitem>
223   <listitem>
224     <para>
225 Set and read the <property>WM_PROTOCOLS</property> property
226     </para>
227   </listitem>
228   <listitem>
229     <para>
230 Set and read the <property>WM_COLORMAP_WINDOWS</property> property
231     </para>
232   </listitem>
233   <listitem>
234     <para>
235 Set and read the <property>WM_ICON_SIZE</property> property
236     </para>
237   </listitem>
238   <listitem>
239     <para>
240 Use window manager convenience functions
241     </para>
242   </listitem>
243 </itemizedlist>
244 <sect2 id="Manipulating_Top_Level_Windows">
245 <title>Manipulating Top-Level Windows</title>
246 <!-- .XS -->
247 <!-- (SN Manipulating Top-Level Windows -->
248 <!-- .XE -->
249 <para>
250 <!-- .LP -->
251 Xlib provides functions that you can use to change the visibility or size
252 of top-level windows (that is, those that were created as children 
253 of the root window).
254 Note that the subwindows that you create are ignored by window managers.
255 Therefore,
256 you should use the basic window functions described in
257 <link linkend='Window_Functions'>chapter 3</link>
258 to manipulate your application's subwindows.
259 </para>
260 <para>
261 <!-- .LP -->
262 To request that a top-level window be iconified, use
263 <xref linkend='XIconifyWindow' xrefstyle='select: title'/>.
264 </para>
265 <indexterm significance="preferred"><primary>XIconifyWindow</primary></indexterm>
266 <!-- .sM -->
267 <funcsynopsis id='XIconifyWindow'>
268 <funcprototype>
269   <funcdef>Status <function>XIconifyWindow</function></funcdef>
270   <paramdef>Display<parameter> *display</parameter></paramdef>
271   <paramdef>Window<parameter> w</parameter></paramdef>
272   <paramdef>int<parameter> screen_number</parameter></paramdef>
273 </funcprototype>
274 </funcsynopsis>
275 <!-- .FN -->
276 <variablelist>
277   <varlistentry>
278     <term>
279       <emphasis remap='I'>display</emphasis>
280     </term>
281     <listitem>
282       <para>
283 Specifies the connection to the X server.
284       </para>
285     </listitem>
286   </varlistentry>
287   <varlistentry>
288     <term>
289       <emphasis remap='I'>w</emphasis>
290     </term>
291     <listitem>
292       <para>
293 Specifies the window.
294       </para>
295     </listitem>
296   </varlistentry>
297   <varlistentry>
298     <term>
299       <emphasis remap='I'>screen_number</emphasis>
300     </term>
301     <listitem>
302       <para>
303 Specifies the appropriate screen number on the host server.
304     </para>
305   </listitem>
306   </varlistentry>
307 </variablelist>
308 <para>
309 <!-- .LP -->
310 <!-- .eM -->
311 The 
312 <xref linkend='XIconifyWindow' xrefstyle='select: title'/>
313 function sends a <property>WM_CHANGE_STATE</property> 
314 <symbol>ClientMessage</symbol>
315 event with a format of 32 and a first data element of 
316 <symbol>IconicState</symbol>
317 (as described in <olink targetdoc='icccm' targetptr='Changing_Window_State'
318 >section 4.1.4 of the
319 <citetitle>Inter-Client Communication Conventions Manual</citetitle></olink>)
320 and a window of w
321 to the root window of the specified screen
322 with an event mask set to
323 <symbol>SubstructureNotifyMask</symbol> |
324 <symbol>SubstructureRedirectMask</symbol>.
325 Window managers may elect to receive this message and
326 if the window is in its normal state, 
327 may treat it as a request to change the window's state from normal to iconic.
328 If the <property>WM_CHANGE_STATE</property> property cannot be interned, 
329 <xref linkend='XIconifyWindow' xrefstyle='select: title'/>
330 does not send a message and returns a zero status.
331 It returns a nonzero status if the client message is sent successfully;
332 otherwise, it returns a zero status.
333 <!-- .sp -->
334 </para>
335 <para>
336 <!-- .LP -->
337 To request that a top-level window be withdrawn, use
338 <xref linkend='XWithdrawWindow' xrefstyle='select: title'/>.
339 </para>
340 <indexterm significance="preferred"><primary>XWithdrawWindow</primary></indexterm>
341 <!-- .sM -->
342 <funcsynopsis id='XWithdrawWindow'>
343 <funcprototype>
344   <funcdef>Status <function>XWithdrawWindow</function></funcdef>
345   <paramdef>Display<parameter> *display</parameter></paramdef>
346   <paramdef>Window<parameter> w</parameter></paramdef>
347   <paramdef>int<parameter> screen_number</parameter></paramdef>
348 </funcprototype>
349 </funcsynopsis>
350 <!-- .FN -->
351 <variablelist>
352   <varlistentry>
353     <term>
354       <emphasis remap='I'>display</emphasis>
355     </term>
356     <listitem>
357       <para>
358 Specifies the connection to the X server.
359       </para>
360     </listitem>
361   </varlistentry>
362   <varlistentry>
363     <term>
364       <emphasis remap='I'>w</emphasis>
365     </term>
366     <listitem>
367       <para>
368 Specifies the window.
369       </para>
370     </listitem>
371   </varlistentry>
372   <varlistentry>
373     <term>
374       <emphasis remap='I'>screen_number</emphasis>
375     </term>
376     <listitem>
377       <para>
378 Specifies the appropriate screen number on the host server.
379     </para>
380   </listitem>
381   </varlistentry>
382 </variablelist>
383 <para>
384 <!-- .LP -->
385 <!-- .eM -->
386 The 
387 <xref linkend='XWithdrawWindow' xrefstyle='select: title'/>
388 function unmaps the specified window 
389 and sends a synthetic 
390 <symbol>UnmapNotify</symbol>
391 event to the root window of the specified screen.
392 Window managers may elect to receive this message 
393 and may treat it as a request to change the window's state to withdrawn.
394 When a window is in the withdrawn state, 
395 neither its normal nor its iconic representations is visible.
396 It returns a nonzero status if the 
397 <symbol>UnmapNotify</symbol>
398 event is successfully sent; 
399 otherwise, it returns a zero status.
400 </para>
401 <para>
402 <!-- .LP -->
403 <xref linkend='XWithdrawWindow' xrefstyle='select: title'/>
404 can generate a
405 <errorname>BadWindow</errorname>
406 error.
407 <!-- .sp -->
408 </para>
409 <para>
410 <!-- .LP -->
411 To request that a top-level window be reconfigured, use
412 <xref linkend='XReconfigureWMWindow' xrefstyle='select: title'/>.
413 </para>
414 <indexterm significance="preferred"><primary>XReconfigureWMWindow</primary></indexterm>
415 <!-- .sM -->
416 <funcsynopsis id='XReconfigureWMWindow'>
417 <funcprototype>
418   <funcdef>Status <function>XReconfigureWMWindow</function></funcdef>
419   <paramdef>Display<parameter> *display</parameter></paramdef>
420   <paramdef>Window<parameter> w</parameter></paramdef>
421   <paramdef>int<parameter> screen_number</parameter></paramdef>
422   <paramdef>unsignedint<parameter> value_mask</parameter></paramdef>
423   <paramdef>XWindowChanges<parameter> *values</parameter></paramdef>
424 </funcprototype>
425 </funcsynopsis>
426 <!-- .FN -->
427 <variablelist>
428   <varlistentry>
429     <term>
430       <emphasis remap='I'>display</emphasis>
431     </term>
432     <listitem>
433       <para>
434 Specifies the connection to the X server.
435       </para>
436     </listitem>
437   </varlistentry>
438   <varlistentry>
439     <term>
440       <emphasis remap='I'>w</emphasis>
441     </term>
442     <listitem>
443       <para>
444 Specifies the window.
445       </para>
446     </listitem>
447   </varlistentry>
448   <varlistentry>
449     <term>
450       <emphasis remap='I'>screen_number</emphasis>
451     </term>
452     <listitem>
453       <para>
454 Specifies the appropriate screen number on the host server.
455       </para>
456     </listitem>
457   </varlistentry>
458   <varlistentry>
459     <term>
460       <emphasis remap='I'>value_mask</emphasis>
461     </term>
462     <listitem>
463       <para>
464 Specifies which values are to be set using information in
465 the values structure.
466 This mask is the bitwise inclusive OR of the valid configure window values bits.
467       </para>
468     </listitem>
469   </varlistentry>
470   <varlistentry>
471     <term>
472       <emphasis remap='I'>values</emphasis>
473     </term>
474     <listitem>
475       <para>
476 Specifies the 
477 <structname>XWindowChanges</structname>
478 structure.
479     </para>
480   </listitem>
481   </varlistentry>
482 </variablelist>
483 <para>
484 <!-- .LP -->
485 <!-- .eM -->
486 The 
487 <xref linkend='XReconfigureWMWindow' xrefstyle='select: title'/>
488 function issues a 
489 <systemitem>ConfigureWindow</systemitem>
490 request on the specified top-level window.
491 If the stacking mode is changed and the request fails with a 
492 <errorname>BadMatch</errorname>
493 error, 
494 the error is trapped by Xlib and a synthetic 
495 <systemitem class="event">ConfigureRequestEvent</systemitem>
496 containing the same configuration parameters is sent to the root 
497 of the specified window.
498 Window managers may elect to receive this event 
499 and treat it as a request to reconfigure the indicated window.
500 It returns a nonzero status if the request or event is successfully sent;
501 otherwise, it returns a zero status.
502 </para>
503 <para>
504 <!-- .LP -->
505 <xref linkend='XReconfigureWMWindow' xrefstyle='select: title'/>
506 can generate
507 <errorname>BadValue</errorname>
508 and 
509 <errorname>BadWindow</errorname>
510 errors.
511 </para>
512 </sect2>
513 <sect2 id="Converting_String_Lists">
514 <title>Converting String Lists</title>
515 <!-- .XS -->
516 <!-- (SN Converting String Lists -->
517 <!-- .XE -->
518 <para>
519 <!-- .LP -->
520 Many of the text properties allow a variety of types and formats.
521 Because the data stored in these properties are not
522 simple null-terminated strings, an
523 <structname>XTextProperty</structname>
524 structure is used to describe the encoding, type, and length of the text 
525 as well as its value.
526 The
527 <structname>XTextProperty</structname>
528 structure contains:
529 <indexterm significance="preferred"><primary>XTextProperty</primary></indexterm>
530 <!-- .sM -->
531 <literallayout class="monospaced">
532 <!-- .TA .5i 2.5i -->
533 <!-- .ta .5i 2.5i -->
534 typedef struct {
535         unsigned char *value;   /* property data */
536         Atom encoding;  /* type of property */
537         int format;     /* 8, 16, or 32 */
538         unsigned long nitems;   /* number of items in value */
539 } XTextProperty;
540 </literallayout>
541 </para>
542 <para>
543 <!-- .LP -->
544 <!-- .eM -->
545 Xlib provides functions to convert localized text to or from encodings
546 that support the inter-client communication conventions for text.
547 In addition, functions are provided for converting between lists of pointers 
548 to character strings and text properties in the STRING encoding.
549 </para>
550 <para>
551 <!-- .LP -->
552 The functions for localized text return a signed integer error status 
553 that encodes 
554 <symbol>Success</symbol>
555 as zero, specific error conditions as negative numbers, and partial conversion
556 as a count of unconvertible characters.
557 </para>
558
559 <literallayout class="monospaced">
560
561 #define #XNoMemory           -1
562 #define #XLocaleNotSupported -2
563 #define #XConverterNotFound  -3
564
565 typedef enum {
566         XStringStyle,           /* STRING */
567         XCompoundTextStyle,     /* COMPOUND_TEXT */
568         XTextStyle,             /* text in owner's encoding (current locale) */
569         XStdICCTextStyle        /* STRING, else COMPOUND_TEXT */
570 } XICCEncodingStyle;
571 </literallayout>
572
573 <para>
574 <!-- .LP -->
575 <!-- .eM -->
576 <!-- .sp -->
577 </para>
578 <para>
579 <!-- .LP -->
580 To convert a list of text strings to an 
581 <structname>XTextProperty</structname>
582 structure, use
583 <xref linkend='XmbTextListToTextProperty' xrefstyle='select: title'/>
584 or
585 <xref linkend='XwcTextListToTextProperty' xrefstyle='select: title'/>.
586 </para>
587 <indexterm significance="preferred"><primary>XmbTextListToTextProperty</primary></indexterm>
588 <indexterm significance="preferred"><primary>XwcTextListToTextProperty</primary></indexterm>
589 <!-- .sM -->
590 <funcsynopsis id='XmbTextListToTextProperty'>
591 <funcprototype>
592   <funcdef>int <function>XmbTextListToTextProperty</function></funcdef>
593   <paramdef>Display<parameter> *display</parameter></paramdef>
594   <paramdef>char<parameter> **list</parameter></paramdef>
595   <paramdef>int<parameter> count</parameter></paramdef>
596   <paramdef>XICCEncodingStyle<parameter> style</parameter></paramdef>
597   <paramdef>XTextProperty<parameter> *text_prop_return</parameter></paramdef>
598 </funcprototype>
599 </funcsynopsis>
600 <!-- .FN -->
601 <funcsynopsis id='XwcTextListToTextProperty'>
602 <funcprototype>
603   <funcdef>int <function>XwcTextListToTextProperty</function></funcdef>
604   <paramdef>Display<parameter> *display</parameter></paramdef>
605   <paramdef>wchar_t<parameter> **list</parameter></paramdef>
606   <paramdef>int<parameter> count</parameter></paramdef>
607   <paramdef>XICCEncodingStyle<parameter> style</parameter></paramdef>
608   <paramdef>XTextProperty<parameter> *text_prop_return</parameter></paramdef>
609 </funcprototype>
610 </funcsynopsis>
611 <!-- .FN -->
612 <variablelist>
613   <varlistentry>
614     <term>
615       <emphasis remap='I'>display</emphasis>
616     </term>
617     <listitem>
618       <para>
619 Specifies the connection to the X server.
620       </para>
621     </listitem>
622   </varlistentry>
623   <varlistentry>
624     <term>
625       <emphasis remap='I'>list</emphasis>
626     </term>
627     <listitem>
628       <para>
629 Specifies a list of null-terminated character strings.
630       </para>
631     </listitem>
632   </varlistentry>
633   <varlistentry>
634     <term>
635       <emphasis remap='I'>count</emphasis>
636     </term>
637     <listitem>
638       <para>
639 Specifies the number of strings specified.
640       </para>
641     </listitem>
642   </varlistentry>
643   <varlistentry>
644     <term>
645       <emphasis remap='I'>style</emphasis>
646     </term>
647     <listitem>
648       <para>
649 Specifies the manner in which the property is encoded.
650       </para>
651     </listitem>
652   </varlistentry>
653   <varlistentry>
654     <term>
655       <emphasis remap='I'>text_prop_return</emphasis>
656     </term>
657     <listitem>
658       <para>
659 Returns the
660 <structname>XTextProperty</structname>
661 structure.
662     </para>
663   </listitem>
664   </varlistentry>
665 </variablelist>
666 <para>
667 <!-- .LP -->
668 <!-- .eM -->
669 The
670 <xref linkend='XmbTextListToTextProperty' xrefstyle='select: title'/>
671 and
672 <xref linkend='XwcTextListToTextProperty' xrefstyle='select: title'/>
673 functions set the specified 
674 <structname>XTextProperty</structname>
675 value to a set of null-separated elements representing the concatenation
676 of the specified list of null-terminated text strings.
677 A final terminating null is stored at the end of the value field 
678 of text_prop_return but is not included in the nitems member.
679 </para>
680 <para>
681 <!-- .LP -->
682 The functions set the encoding field of text_prop_return to an
683 <type>Atom</type>
684 for the specified display 
685 naming the encoding determined by the specified style
686 and convert the specified text list to this encoding for storage in
687 the text_prop_return value field.
688 If the style 
689 <constant>XStringStyle</constant>
690 or 
691 <constant>XCompoundTextStyle</constant>
692 is specified,
693 this encoding is ``STRING'' or ``COMPOUND_TEXT'', respectively.
694 If the style 
695 <constant>XTextStyle</constant>
696 is specified,
697 this encoding is the encoding of the current locale.
698 If the style 
699 <constant>XStdICCTextStyle</constant>
700 is specified,
701 this encoding is ``STRING'' if the text is fully convertible to STRING,
702 else ``COMPOUND_TEXT''.
703 </para>
704 <para>
705 <!-- .LP -->
706 If insufficient memory is available for the new value string,
707 the functions return 
708 <symbol>XNoMemory</symbol>.
709 If the current locale is not supported,
710 the functions return 
711 <symbol>XLocaleNotSupported</symbol>.
712 In both of these error cases,
713 the functions do not set text_prop_return.
714 </para>
715 <para>
716 <!-- .LP -->
717 To determine if the functions are guaranteed not to return
718 <symbol>XLocaleNotSupported</symbol>,
719 use
720 <function>XSupportsLocale</function>.
721 </para>
722 <para>
723 <!-- .LP -->
724 If the supplied text is not fully convertible to the specified encoding,
725 the functions return the number of unconvertible characters.
726 Each unconvertible character is converted to an implementation-defined and
727 encoding-specific default string.
728 Otherwise, the functions return 
729 <symbol>Success</symbol>.
730 Note that full convertibility to all styles except 
731 <constant>XStringStyle</constant>
732 is guaranteed.
733 </para>
734 <para>
735 <!-- .LP -->
736 To free the storage for the value field, use
737 <xref linkend='XFree' xrefstyle='select: title'/>.
738 <!-- .sp -->
739 </para>
740 <para>
741 <!-- .LP -->
742 To obtain a list of text strings from an 
743 <structname>XTextProperty</structname>
744 structure, use
745 <xref linkend='XmbTextPropertyToTextList' xrefstyle='select: title'/>
746 or
747 <xref linkend='XwcTextPropertyToTextList' xrefstyle='select: title'/>.
748 </para>
749 <indexterm significance="preferred"><primary>XmbTextPropertyToTextList</primary></indexterm>
750 <indexterm significance="preferred"><primary>XwcTextPropertyToTextList</primary></indexterm>
751 <!-- .sM -->
752 <funcsynopsis id='XmbTextPropertyToTextList'>
753 <funcprototype>
754   <funcdef>int <function>XmbTextPropertyToTextList</function></funcdef>
755   <paramdef>Display<parameter> *display</parameter></paramdef>
756   <paramdef>XTextProperty<parameter> *text_prop</parameter></paramdef>
757   <paramdef>char<parameter> ***list_return</parameter></paramdef>
758   <paramdef>int<parameter> *count_return</parameter></paramdef>
759 </funcprototype>
760 </funcsynopsis>
761 <!-- .FN -->
762 <funcsynopsis id='XwcTextPropertyToTextList'>
763 <funcprototype>
764   <funcdef>int <function>XwcTextPropertyToTextList</function></funcdef>
765   <paramdef>Display<parameter> *display</parameter></paramdef>
766   <paramdef>XTextProperty<parameter> *text_prop</parameter></paramdef>
767   <paramdef>wchar_t<parameter> ***list_return</parameter></paramdef>
768   <paramdef>int<parameter> *count_return</parameter></paramdef>
769 </funcprototype>
770 </funcsynopsis>
771 <!-- .FN -->
772 <variablelist>
773   <varlistentry>
774     <term>
775       <emphasis remap='I'>display</emphasis>
776     </term>
777     <listitem>
778       <para>
779 Specifies the connection to the X server.
780       </para>
781     </listitem>
782   </varlistentry>
783   <varlistentry>
784     <term>
785       <emphasis remap='I'>text_prop</emphasis>
786     </term>
787     <listitem>
788       <para>
789 Specifies the
790 <structname>XTextProperty</structname>
791 structure to be used.
792       </para>
793     </listitem>
794   </varlistentry>
795   <varlistentry>
796     <term>
797       <emphasis remap='I'>list_return</emphasis>
798     </term>
799     <listitem>
800       <para>
801 Returns a list of null-terminated character strings.
802 <!-- .ds Cn strings -->
803       </para>
804     </listitem>
805   </varlistentry>
806   <varlistentry>
807     <term>
808       <emphasis remap='I'>count_return</emphasis>
809     </term>
810     <listitem>
811       <para>
812 Returns the number of (Cn.
813     </para>
814   </listitem>
815   </varlistentry>
816 </variablelist>
817 <para>
818 <!-- .LP -->
819 <!-- .eM -->
820 The 
821 <xref linkend='XmbTextPropertyToTextList' xrefstyle='select: title'/>
822 and 
823 <xref linkend='XwcTextPropertyToTextList' xrefstyle='select: title'/>
824 functions return a list of text strings in the current locale representing the
825 null-separated elements of the specified
826 <structname>XTextProperty</structname>
827 structure.
828 The data in text_prop must be format 8.
829 </para>
830 <para>
831 <!-- .LP -->
832 Multiple elements of the property (for example, the strings in a disjoint
833 text selection) are separated by a null byte.
834 The contents of the property are not required to be null-terminated;
835 any terminating null should not be included in text_prop.nitems.
836 </para>
837 <para>
838 <!-- .LP -->
839 If insufficient memory is available for the list and its elements,
840 <xref linkend='XmbTextPropertyToTextList' xrefstyle='select: title'/>
841 and
842 <xref linkend='XwcTextPropertyToTextList' xrefstyle='select: title'/>
843 return 
844 <symbol>XNoMemory</symbol>.
845 If the current locale is not supported,
846 the functions return
847 <symbol>XLocaleNotSupported</symbol>.
848 Otherwise, if the encoding field of text_prop is not convertible 
849 to the encoding of the current locale,
850 the functions return
851 <symbol>XConverterNotFound</symbol>.
852 For supported locales,
853 existence of a converter from COMPOUND_TEXT, STRING
854 or the encoding of the current locale is guaranteed if
855 <function>XSupportsLocale</function>
856 returns 
857 <symbol>True</symbol>
858 for the current locale (but the actual text
859 may contain unconvertible characters).
860 Conversion of other encodings is implementation-dependent.
861 In all of these error cases,
862 the functions do not set any return values.
863 </para>
864 <para>
865 <!-- .LP -->
866 Otherwise, 
867 <xref linkend='XmbTextPropertyToTextList' xrefstyle='select: title'/>
868 and
869 <xref linkend='XwcTextPropertyToTextList' xrefstyle='select: title'/>
870 return the list of null-terminated text strings to list_return
871 and the number of text strings to count_return.
872 </para>
873 <para>
874 <!-- .LP -->
875 If the value field of text_prop is not fully convertible to the encoding of
876 the current locale,
877 the functions return the number of unconvertible characters.
878 Each unconvertible character is converted to a string in the
879 current locale that is specific to the current locale.
880 To obtain the value of this string, 
881 use
882 <function>XDefaultString</function>.
883 Otherwise,
884 <xref linkend='XmbTextPropertyToTextList' xrefstyle='select: title'/>
885 and
886 <xref linkend='XwcTextPropertyToTextList' xrefstyle='select: title'/>
887 return 
888 <symbol>Success</symbol>.
889 </para>
890 <para>
891 <!-- .LP -->
892 To free the storage for the list and its contents returned by
893 <xref linkend='XmbTextPropertyToTextList' xrefstyle='select: title'/>,
894 use
895 <xref linkend='XFreeStringList' xrefstyle='select: title'/>.
896 To free the storage for the list and its contents returned by
897 <xref linkend='XwcTextPropertyToTextList' xrefstyle='select: title'/>,
898 use
899 <xref linkend='XwcFreeStringList' xrefstyle='select: title'/>.
900 <!-- .sp -->
901 </para>
902 <para>
903 <!-- .LP -->
904 To free the in-memory data associated with the specified
905 wide character string list, use
906 <xref linkend='XwcFreeStringList' xrefstyle='select: title'/>.
907 </para>
908 <indexterm significance="preferred"><primary>XwcFreeStringList</primary></indexterm>
909 <!-- .sM -->
910 <funcsynopsis id='XwcFreeStringList'>
911 <funcprototype>
912   <funcdef>void <function>XwcFreeStringList</function></funcdef>
913   <paramdef>wchar_t<parameter> **list</parameter></paramdef>
914 </funcprototype>
915 </funcsynopsis>
916 <!-- .FN -->
917 <variablelist>
918   <varlistentry>
919     <term>
920       <emphasis remap='I'>list</emphasis>
921     </term>
922     <listitem>
923       <para>
924 Specifies the list of strings to be freed.
925     </para>
926   </listitem>
927   </varlistentry>
928 </variablelist>
929 <para>
930 <!-- .LP -->
931 <!-- .eM -->
932 The
933 <xref linkend='XwcFreeStringList' xrefstyle='select: title'/>
934 function frees memory allocated by
935 <xref linkend='XwcTextPropertyToTextList' xrefstyle='select: title'/>.
936 <!-- .sp -->
937 </para>
938 <para>
939 <!-- .LP -->
940 To obtain the default string for text conversion in the current locale,
941 use</para>
942
943 <para>char *XDefaultString()</para>
944
945 <para>
946 <!-- .LP -->
947 <!-- .eM -->
948 The
949 <function>XDefaultString</function>
950 function returns the default string used by Xlib for text conversion
951 (for example, in 
952 <xref linkend='XmbTextPropertyToTextList' xrefstyle='select: title'/>).
953 The default string is the string in the current locale that is output 
954 when an unconvertible character is found during text conversion.
955 If the string returned by
956 <function>XDefaultString</function>
957 is the empty string (""),
958 no character is output in the converted text.
959 <function>XDefaultString</function>
960 does not return NULL.
961 </para>
962 <para>
963 <!-- .LP -->
964 The string returned by 
965 <function>XDefaultString</function>
966 is independent of the default string for text drawing;
967 see 
968 <xref linkend='XCreateFontSet' xrefstyle='select: title'/>
969 to obtain the default string for an
970 <type>XFontSet</type>.
971 </para>
972 <para>
973 <!-- .LP -->
974 The behavior when an invalid codepoint is supplied to any Xlib function is
975 undefined.
976 </para>
977 <para>
978 <!-- .LP -->
979 The returned string is null-terminated.
980 It is owned by Xlib and should not be modified or freed by the client.
981 It may be freed after the current locale is changed.
982 Until freed, it will not be modified by Xlib.
983 <!-- .sp -->
984 </para>
985 <para>
986 <!-- .LP -->
987 To set the specified list of strings in the STRING encoding to a 
988 <structname>XTextProperty</structname>
989 structure, use
990 <xref linkend='XStringListToTextProperty' xrefstyle='select: title'/>.
991 </para>
992 <indexterm significance="preferred"><primary>XStringListToTextProperty</primary></indexterm>
993 <!-- .sM -->
994 <funcsynopsis id='XStringListToTextProperty'>
995 <funcprototype>
996   <funcdef>Status <function>XStringListToTextProperty</function></funcdef>
997   <paramdef>char<parameter> **list</parameter></paramdef>
998   <paramdef>int<parameter> count</parameter></paramdef>
999   <paramdef>XTextProperty<parameter> *text_prop_return</parameter></paramdef>
1000 </funcprototype>
1001 </funcsynopsis>
1002 <!-- .FN -->
1003 <variablelist>
1004   <varlistentry>
1005     <term>
1006       <emphasis remap='I'>list</emphasis>
1007     </term>
1008     <listitem>
1009       <para>
1010 Specifies a list of null-terminated character strings.
1011 <!-- .ds Cn strings -->
1012       </para>
1013     </listitem>
1014   </varlistentry>
1015   <varlistentry>
1016     <term>
1017       <emphasis remap='I'>count</emphasis>
1018     </term>
1019     <listitem>
1020       <para>
1021 Specifies the number of (Cn.
1022       </para>
1023     </listitem>
1024   </varlistentry>
1025   <varlistentry>
1026     <term>
1027       <emphasis remap='I'>text_prop_return</emphasis>
1028     </term>
1029     <listitem>
1030       <para>
1031 Returns the
1032 <structname>XTextProperty</structname>
1033 structure.
1034     </para>
1035   </listitem>
1036   </varlistentry>
1037 </variablelist>
1038 <para>
1039 <!-- .LP -->
1040 <!-- .eM -->
1041 The 
1042 <xref linkend='XStringListToTextProperty' xrefstyle='select: title'/>
1043 function sets the specified 
1044 <structname>XTextProperty</structname>
1045 to be of type STRING (format 8) with a value representing the
1046 concatenation of the specified list of null-separated character strings.
1047 An extra null byte (which is not included in the nitems member) 
1048 is stored at the end of the value field of text_prop_return.
1049 The strings are assumed (without verification) to be in the STRING encoding.
1050 If insufficient memory is available for the new value string, 
1051 <xref linkend='XStringListToTextProperty' xrefstyle='select: title'/>
1052 does not set any fields in the
1053 <structname>XTextProperty</structname>
1054 structure and returns a zero status.
1055 Otherwise, it returns a nonzero status.
1056 To free the storage for the value field, use 
1057 <xref linkend='XFree' xrefstyle='select: title'/>.
1058 <!-- .sp -->
1059 </para>
1060 <para>
1061 <!-- .LP -->
1062 To obtain a list of strings from a specified
1063 <structname>XTextProperty</structname>
1064 structure in the STRING encoding, use
1065 <xref linkend='XTextPropertyToStringList' xrefstyle='select: title'/>.
1066 </para>
1067 <indexterm significance="preferred"><primary>XTextPropertyToStringList</primary></indexterm>
1068 <!-- .sM -->
1069 <funcsynopsis id='XTextPropertyToStringList'>
1070 <funcprototype>
1071   <funcdef>Status <function>XTextPropertyToStringList</function></funcdef>
1072   <paramdef>XTextProperty<parameter> *text_prop</parameter></paramdef>
1073   <paramdef>char<parameter> ***list_return</parameter></paramdef>
1074   <paramdef>int<parameter> *count_return</parameter></paramdef>
1075 </funcprototype>
1076 </funcsynopsis>
1077 <!-- .FN -->
1078 <variablelist>
1079   <varlistentry>
1080     <term>
1081       <emphasis remap='I'>text_prop</emphasis>
1082     </term>
1083     <listitem>
1084       <para>
1085 Specifies the
1086 <structname>XTextProperty</structname>
1087 structure to be used.
1088       </para>
1089     </listitem>
1090   </varlistentry>
1091   <varlistentry>
1092     <term>
1093       <emphasis remap='I'>list_return</emphasis>
1094     </term>
1095     <listitem>
1096       <para>
1097 Returns a list of null-terminated character strings.
1098 <!-- .ds Cn strings -->
1099       </para>
1100     </listitem>
1101   </varlistentry>
1102   <varlistentry>
1103     <term>
1104       <emphasis remap='I'>count_return</emphasis>
1105     </term>
1106     <listitem>
1107       <para>
1108 Returns the number of (Cn.
1109     </para>
1110   </listitem>
1111   </varlistentry>
1112 </variablelist>
1113 <para>
1114 <!-- .LP -->
1115 <!-- .eM -->
1116 The 
1117 <xref linkend='XTextPropertyToStringList' xrefstyle='select: title'/>
1118 function returns a list of strings representing the null-separated elements 
1119 of the specified
1120 <structname>XTextProperty</structname>
1121 structure.
1122 The data in text_prop must be of type STRING and format 8. 
1123 Multiple elements of the property 
1124 (for example, the strings in a disjoint text selection) 
1125 are separated by NULL (encoding 0).
1126 The contents of the property are not null-terminated.
1127 If insufficient memory is available for the list and its elements, 
1128 <xref linkend='XTextPropertyToStringList' xrefstyle='select: title'/>
1129 sets no return values and returns a zero status.
1130 Otherwise, it returns a nonzero status.
1131 To free the storage for the list and its contents, use 
1132 <xref linkend='XFreeStringList' xrefstyle='select: title'/>.
1133 <!-- .sp -->
1134 </para>
1135 <para>
1136 <!-- .LP -->
1137 To free the in-memory data associated with the specified string list, use
1138 <xref linkend='XFreeStringList' xrefstyle='select: title'/>.
1139 </para>
1140 <indexterm significance="preferred"><primary>XFreeStringList</primary></indexterm>
1141 <!-- .sM -->
1142 <funcsynopsis id='XFreeStringList'>
1143 <funcprototype>
1144   <funcdef>void <function>XFreeStringList</function></funcdef>
1145   <paramdef>char<parameter> **list</parameter></paramdef>
1146 </funcprototype>
1147 </funcsynopsis>
1148 <!-- .FN -->
1149 <variablelist>
1150   <varlistentry>
1151     <term>
1152       <emphasis remap='I'>list</emphasis>
1153     </term>
1154     <listitem>
1155       <para>
1156 Specifies the list of strings to be freed.
1157     </para>
1158   </listitem>
1159   </varlistentry>
1160 </variablelist>
1161 <para>
1162 <!-- .LP -->
1163 <!-- .eM -->
1164 The 
1165 <xref linkend='XFreeStringList' xrefstyle='select: title'/>
1166 function releases memory allocated by 
1167 <xref linkend='XmbTextPropertyToTextList' xrefstyle='select: title'/>
1168 and
1169 <xref linkend='XTextPropertyToStringList' xrefstyle='select: title'/>
1170 and the missing charset list allocated by 
1171 <xref linkend='XCreateFontSet' xrefstyle='select: title'/>.
1172 </para>
1173 </sect2>
1174 <sect2 id="Setting_and_Reading_Text_Properties">
1175 <title>Setting and Reading Text Properties</title>
1176 <!-- .XS -->
1177 <!-- (SN Setting and Reading Text Properties -->
1178 <!-- .XE -->
1179 <para>
1180 <!-- .LP -->
1181 Xlib provides two functions that you can use to set and read
1182 the text properties for a given window.
1183 You can use these functions to set and read those properties of type TEXT
1184 (<property>WM_NAME</property>, <property>WM_ICON_NAME</property>, <property>WM_COMMAND</property>, and <property>WM_CLIENT_MACHINE</property>).
1185 In addition,
1186 Xlib provides separate convenience functions that you can use to set each 
1187 of these properties.
1188 For further information about these convenience functions,
1189 see sections
1190 <link linkend="Setting_and_Reading_the_WM_NAME_Property">14.1.4</link>,
1191 <link linkend="Setting_and_Reading_the_WM_ICON_NAME_Property">14.1.5</link>,
1192 <link linkend="Setting_and_Reading_the_WM_COMMAND_Property">14.2.1</link>, and
1193 <link linkend="Setting_and_Reading_the_WM_CLIENT_MACHINE_Property">14.2.2</link>,
1194 respectively.
1195 <!-- .sp -->
1196 </para>
1197 <para>
1198 <!-- .LP -->
1199 To set one of a window's text properties, use
1200 <xref linkend='XSetTextProperty' xrefstyle='select: title'/>.
1201 </para>
1202 <indexterm significance="preferred"><primary>XSetTextProperty</primary></indexterm>
1203 <!-- .sM -->
1204 <funcsynopsis id='XSetTextProperty'>
1205 <funcprototype>
1206   <funcdef>void <function>XSetTextProperty</function></funcdef>
1207   <paramdef>Display<parameter> *display</parameter></paramdef>
1208   <paramdef>Window<parameter> w</parameter></paramdef>
1209   <paramdef>XTextProperty<parameter> *text_prop</parameter></paramdef>
1210   <paramdef>Atom<parameter> property</parameter></paramdef>
1211 </funcprototype>
1212 </funcsynopsis>
1213 <!-- .FN -->
1214 <variablelist>
1215   <varlistentry>
1216     <term>
1217       <emphasis remap='I'>display</emphasis>
1218     </term>
1219     <listitem>
1220       <para>
1221 Specifies the connection to the X server.
1222       </para>
1223     </listitem>
1224   </varlistentry>
1225   <varlistentry>
1226     <term>
1227       <emphasis remap='I'>w</emphasis>
1228     </term>
1229     <listitem>
1230       <para>
1231 Specifies the window.
1232       </para>
1233     </listitem>
1234   </varlistentry>
1235   <varlistentry>
1236     <term>
1237       <emphasis remap='I'>text_prop</emphasis>
1238     </term>
1239     <listitem>
1240       <para>
1241 Specifies the
1242 <structname>XTextProperty</structname>
1243 structure to be used.
1244       </para>
1245     </listitem>
1246   </varlistentry>
1247   <varlistentry>
1248     <term>
1249       <emphasis remap='I'>property</emphasis>
1250     </term>
1251     <listitem>
1252       <para>
1253 Specifies the property name.
1254     </para>
1255   </listitem>
1256   </varlistentry>
1257 </variablelist>
1258 <para>
1259 <!-- .LP -->
1260 <!-- .eM -->
1261 The
1262 <xref linkend='XSetTextProperty' xrefstyle='select: title'/>
1263 function replaces the existing specified property for the named window 
1264 with the data, type, format, and number of items determined 
1265 by the value field, the encoding field, the format field, 
1266 and the nitems field, respectively, of the specified
1267 <structname>XTextProperty</structname>
1268 structure.
1269 If the property does not already exist,
1270 <xref linkend='XSetTextProperty' xrefstyle='select: title'/>
1271 sets it for the specified window.
1272 </para>
1273 <para>
1274 <!-- .LP -->
1275 <xref linkend='XSetTextProperty' xrefstyle='select: title'/>
1276 can generate
1277 <errorname>BadAlloc</errorname>,
1278 <errorname>BadAtom</errorname>,
1279 <errorname>BadValue</errorname>,
1280 and 
1281 <errorname>BadWindow</errorname>
1282 errors.
1283 <!-- .sp -->
1284 </para>
1285 <para>
1286 <!-- .LP -->
1287 To read one of a window's text properties, use
1288 <xref linkend='XGetTextProperty' xrefstyle='select: title'/>.
1289 </para>
1290 <indexterm significance="preferred"><primary>XGetTextProperty</primary></indexterm>
1291 <!-- .sM -->
1292 <funcsynopsis id='XGetTextProperty'>
1293 <funcprototype>
1294   <funcdef>Status <function>XGetTextProperty</function></funcdef>
1295   <paramdef>Display<parameter> *display</parameter></paramdef>
1296   <paramdef>Window<parameter> w</parameter></paramdef>
1297   <paramdef>XTextProperty<parameter> *text_prop_return</parameter></paramdef>
1298   <paramdef>Atom<parameter> property</parameter></paramdef>
1299 </funcprototype>
1300 </funcsynopsis>
1301 <!-- .FN -->
1302 <variablelist>
1303   <varlistentry>
1304     <term>
1305       <emphasis remap='I'>display</emphasis>
1306     </term>
1307     <listitem>
1308       <para>
1309 Specifies the connection to the X server.
1310       </para>
1311     </listitem>
1312   </varlistentry>
1313   <varlistentry>
1314     <term>
1315       <emphasis remap='I'>w</emphasis>
1316     </term>
1317     <listitem>
1318       <para>
1319 Specifies the window.
1320       </para>
1321     </listitem>
1322   </varlistentry>
1323   <varlistentry>
1324     <term>
1325       <emphasis remap='I'>text_prop_return</emphasis>
1326     </term>
1327     <listitem>
1328       <para>
1329 Returns the
1330 <structname>XTextProperty</structname>
1331 structure.
1332       </para>
1333     </listitem>
1334   </varlistentry>
1335   <varlistentry>
1336     <term>
1337       <emphasis remap='I'>property</emphasis>
1338     </term>
1339     <listitem>
1340       <para>
1341 Specifies the property name.
1342     </para>
1343   </listitem>
1344   </varlistentry>
1345 </variablelist>
1346 <para>
1347 <!-- .LP -->
1348 <!-- .eM -->
1349 The
1350 <xref linkend='XGetTextProperty' xrefstyle='select: title'/>
1351 function reads the specified property from the window
1352 and stores the data in the returned
1353 <structname>XTextProperty</structname>
1354 structure.
1355 It stores the data in the value field,
1356 the type of the data in the encoding field,
1357 the format of the data in the format field, 
1358 and the number of items of data in the nitems field.
1359 An extra byte containing null (which is not included in the nitems member) 
1360 is stored at the end of the value field of text_prop_return.
1361 The particular interpretation of the property's encoding 
1362 and data as text is left to the calling application.
1363 If the specified property does not exist on the window,
1364 <xref linkend='XGetTextProperty' xrefstyle='select: title'/>
1365 sets the value field to NULL, 
1366 the encoding field to
1367 <symbol>None</symbol>,
1368 the format field to zero, 
1369 and the nitems field to zero.
1370 </para>
1371 <para>
1372 <!-- .LP -->
1373 If it was able to read and store the data in the
1374 <structname>XTextProperty</structname>
1375 structure,
1376 <xref linkend='XGetTextProperty' xrefstyle='select: title'/>
1377 returns a nonzero status; 
1378 otherwise, it returns a zero status.
1379 </para>
1380 <para>
1381 <!-- .LP -->
1382 <xref linkend='XGetTextProperty' xrefstyle='select: title'/>
1383 can generate
1384 <errorname>BadAtom</errorname>
1385 and 
1386 <errorname>BadWindow</errorname>
1387 errors.
1388 </para>
1389 </sect2>
1390 <sect2 id="Setting_and_Reading_the_WM_NAME_Property">
1391 <title>Setting and Reading the WM_NAME Property</title>
1392 <!-- .XS -->
1393 <!-- (SN Setting and Reading the WM_NAME Property -->
1394 <!-- .XE -->
1395 <para>
1396 <!-- .LP -->
1397 Xlib provides convenience functions that you can use to set and read 
1398 the <property>WM_NAME</property> property for a given window.
1399 <!-- .sp -->
1400 </para>
1401 <para>
1402 <!-- .LP -->
1403 To set a window's <property>WM_NAME</property> property with the supplied convenience function, use
1404 <xref linkend='XSetWMName' xrefstyle='select: title'/>.
1405 </para>
1406 <indexterm significance="preferred"><primary>XSetWMName</primary></indexterm>
1407 <!-- .sM -->
1408 <funcsynopsis id='XSetWMName'>
1409 <funcprototype>
1410   <funcdef>void <function>XSetWMName</function></funcdef>
1411   <paramdef>Display<parameter> *display</parameter></paramdef>
1412   <paramdef>Window<parameter> w</parameter></paramdef>
1413   <paramdef>XTextProperty<parameter> *text_prop</parameter></paramdef>
1414 </funcprototype>
1415 </funcsynopsis>
1416 <!-- .FN -->
1417 <variablelist>
1418   <varlistentry>
1419     <term>
1420       <emphasis remap='I'>display</emphasis>
1421     </term>
1422     <listitem>
1423       <para>
1424 Specifies the connection to the X server.
1425       </para>
1426     </listitem>
1427   </varlistentry>
1428   <varlistentry>
1429     <term>
1430       <emphasis remap='I'>w</emphasis>
1431     </term>
1432     <listitem>
1433       <para>
1434 Specifies the window.
1435       </para>
1436     </listitem>
1437   </varlistentry>
1438   <varlistentry>
1439     <term>
1440       <emphasis remap='I'>text_prop</emphasis>
1441     </term>
1442     <listitem>
1443       <para>
1444 Specifies the
1445 <structname>XTextProperty</structname>
1446 structure to be used.
1447     </para>
1448   </listitem>
1449   </varlistentry>
1450 </variablelist>
1451 <para>
1452 <!-- .LP -->
1453 <!-- .eM -->
1454 The
1455 <xref linkend='XSetWMName' xrefstyle='select: title'/>
1456 convenience function calls
1457 <xref linkend='XSetTextProperty' xrefstyle='select: title'/>
1458 to set the <property>WM_NAME</property> property.
1459 <!-- .sp -->
1460 </para>
1461 <para>
1462 <!-- .LP -->
1463 To read a window's <property>WM_NAME</property> property with the supplied convenience function, use
1464 <xref linkend='XGetWMName' xrefstyle='select: title'/>.
1465 </para>
1466 <indexterm significance="preferred"><primary>XGetWMName</primary></indexterm>
1467 <!-- .sM -->
1468 <funcsynopsis id='XGetWMName'>
1469 <funcprototype>
1470   <funcdef>Status <function>XGetWMName</function></funcdef>
1471   <paramdef>Display<parameter> *display</parameter></paramdef>
1472   <paramdef>Window<parameter> w</parameter></paramdef>
1473   <paramdef>XTextProperty<parameter> *text_prop_return</parameter></paramdef>
1474 </funcprototype>
1475 </funcsynopsis>
1476 <!-- .FN -->
1477 <variablelist>
1478   <varlistentry>
1479     <term>
1480       <emphasis remap='I'>display</emphasis>
1481     </term>
1482     <listitem>
1483       <para>
1484 Specifies the connection to the X server.
1485       </para>
1486     </listitem>
1487   </varlistentry>
1488   <varlistentry>
1489     <term>
1490       <emphasis remap='I'>w</emphasis>
1491     </term>
1492     <listitem>
1493       <para>
1494 Specifies the window.
1495       </para>
1496     </listitem>
1497   </varlistentry>
1498   <varlistentry>
1499     <term>
1500       <emphasis remap='I'>text_prop_return</emphasis>
1501     </term>
1502     <listitem>
1503       <para>
1504 Returns the
1505 <structname>XTextProperty</structname>
1506 structure.
1507     </para>
1508   </listitem>
1509   </varlistentry>
1510 </variablelist>
1511 <para>
1512 <!-- .LP -->
1513 <!-- .eM -->
1514 The
1515 <xref linkend='XGetWMName' xrefstyle='select: title'/>
1516 convenience function calls
1517 <xref linkend='XGetTextProperty' xrefstyle='select: title'/>
1518 to obtain the <property>WM_NAME</property> property.
1519 It returns a nonzero status on success;
1520 otherwise, it returns a zero status.
1521 </para>
1522 <para>
1523 <!-- .LP -->
1524 The following two functions have been superseded by
1525 <xref linkend='XSetWMName' xrefstyle='select: title'/>
1526 and
1527 <xref linkend='XGetWMName' xrefstyle='select: title'/>,
1528 respectively. 
1529 You can use these additional convenience functions 
1530 for window names that are encoded as STRING properties.
1531 <!-- .sp -->
1532 </para>
1533 <para>
1534 <!-- .LP -->
1535 To assign a name to a window, use
1536 <xref linkend='XStoreName' xrefstyle='select: title'/>.
1537 </para>
1538 <indexterm><primary>Window</primary><secondary>name</secondary></indexterm>
1539 <indexterm significance="preferred"><primary>XStoreName</primary></indexterm>
1540 <!-- .sM -->
1541 <funcsynopsis id='XStoreName'>
1542 <funcprototype>
1543   <funcdef><function>XStoreName</function></funcdef>
1544   <paramdef>Display<parameter> *display</parameter></paramdef>
1545   <paramdef>Window<parameter> w</parameter></paramdef>
1546   <paramdef>char<parameter> *window_name</parameter></paramdef>
1547 </funcprototype>
1548 </funcsynopsis>
1549 <!-- .FN -->
1550 <variablelist>
1551   <varlistentry>
1552     <term>
1553       <emphasis remap='I'>display</emphasis>
1554     </term>
1555     <listitem>
1556       <para>
1557 Specifies the connection to the X server.
1558       </para>
1559     </listitem>
1560   </varlistentry>
1561   <varlistentry>
1562     <term>
1563       <emphasis remap='I'>w</emphasis>
1564     </term>
1565     <listitem>
1566       <para>
1567 Specifies the window.
1568       </para>
1569     </listitem>
1570   </varlistentry>
1571   <varlistentry>
1572     <term>
1573       <emphasis remap='I'>window_name</emphasis>
1574     </term>
1575     <listitem>
1576       <para>
1577 Specifies the window name,
1578 which should be a null-terminated string.
1579     </para>
1580   </listitem>
1581   </varlistentry>
1582 </variablelist>
1583 <para>
1584 <!-- .LP -->
1585 <!-- .eM -->
1586 The
1587 <xref linkend='XStoreName' xrefstyle='select: title'/>
1588 function assigns the name passed to window_name to the specified window.
1589 A window manager can display the window name in some prominent
1590 place, such as the title bar, to allow users to identify windows easily.
1591 Some window managers may display a window's name in the window's icon,
1592 although they are encouraged to use the window's icon name
1593 if one is provided by the application.
1594 If the string is not in the Host Portable Character Encoding,
1595 the result is implementation-dependent.
1596 </para>
1597 <para>
1598 <!-- .LP -->
1599 <xref linkend='XStoreName' xrefstyle='select: title'/>
1600 can generate
1601 <errorname>BadAlloc</errorname>
1602 and
1603 <errorname>BadWindow</errorname>
1604 errors.
1605 </para>
1606 <para>
1607 <!-- .LP -->
1608 <!-- .sp -->
1609 To get the name of a window, use
1610 <xref linkend='XFetchName' xrefstyle='select: title'/>.
1611 </para>
1612 <indexterm significance="preferred"><primary>XFetchName</primary></indexterm>
1613 <!-- .sM -->
1614 <funcsynopsis id='XFetchName'>
1615 <funcprototype>
1616   <funcdef>Status <function>XFetchName</function></funcdef>
1617   <paramdef>Display<parameter> *display</parameter></paramdef>
1618   <paramdef>Window<parameter> w</parameter></paramdef>
1619   <paramdef>char<parameter> **window_name_return</parameter></paramdef>
1620 </funcprototype>
1621 </funcsynopsis>
1622 <!-- .FN -->
1623 <variablelist>
1624   <varlistentry>
1625     <term>
1626       <emphasis remap='I'>display</emphasis>
1627     </term>
1628     <listitem>
1629       <para>
1630 Specifies the connection to the X server.
1631       </para>
1632     </listitem>
1633   </varlistentry>
1634   <varlistentry>
1635     <term>
1636       <emphasis remap='I'>w</emphasis>
1637     </term>
1638     <listitem>
1639       <para>
1640 Specifies the window.
1641       </para>
1642     </listitem>
1643   </varlistentry>
1644   <varlistentry>
1645     <term>
1646       <emphasis remap='I'>window_name_return</emphasis>
1647     </term>
1648     <listitem>
1649       <para>
1650 Returns the window name, which is a null-terminated string.
1651     </para>
1652   </listitem>
1653   </varlistentry>
1654 </variablelist>
1655 <para>
1656 <!-- .LP -->
1657 <!-- .eM -->
1658 The
1659 <xref linkend='XFetchName' xrefstyle='select: title'/>
1660 function returns the name of the specified window.
1661 If it succeeds,
1662 it returns a nonzero status; 
1663 otherwise, no name has been set for the window,
1664 and it returns zero.
1665 If the <property>WM_NAME</property> property has not been set for this window,
1666 <xref linkend='XFetchName' xrefstyle='select: title'/>
1667 sets window_name_return to NULL.
1668 If the data returned by the server is in the Latin Portable Character Encoding,
1669 then the returned string is in the Host Portable Character Encoding.
1670 Otherwise, the result is implementation-dependent.
1671 When finished with it, a client must free
1672 the window name string using
1673 <xref linkend='XFree' xrefstyle='select: title'/>.
1674 </para>
1675 <para>
1676 <!-- .LP -->
1677 <xref linkend='XFetchName' xrefstyle='select: title'/>
1678 can generate a
1679 <errorname>BadWindow</errorname>
1680 error.
1681 </para>
1682 </sect2>
1683 <sect2 id="Setting_and_Reading_the_WM_ICON_NAME_Property">
1684 <title>Setting and Reading the WM_ICON_NAME Property</title>
1685 <!-- .XS -->
1686 <!-- (SN Setting and Reading the WM_ICON_NAME Property -->
1687 <!-- .XE -->
1688 <para>
1689 <!-- .LP -->
1690 Xlib provides convenience functions that you can use to set and read 
1691 the <property>WM_ICON_NAME</property> property for a given window.
1692 </para>
1693 <para>
1694 <!-- .LP -->
1695 <!-- .sp -->
1696 To set a window's <property>WM_ICON_NAME</property> property,
1697 use
1698 <xref linkend='XSetWMIconName' xrefstyle='select: title'/>.
1699 </para>
1700 <indexterm significance="preferred"><primary>XSetWMIconName</primary></indexterm>
1701 <!-- .sM -->
1702 <funcsynopsis id='XSetWMIconName'>
1703 <funcprototype>
1704   <funcdef>void <function>XSetWMIconName</function></funcdef>
1705   <paramdef>Display<parameter> *display</parameter></paramdef>
1706   <paramdef>Window<parameter> w</parameter></paramdef>
1707   <paramdef>XTextProperty<parameter> *text_prop</parameter></paramdef>
1708 </funcprototype>
1709 </funcsynopsis>
1710 <!-- .FN -->
1711 <variablelist>
1712   <varlistentry>
1713     <term>
1714       <emphasis remap='I'>display</emphasis>
1715     </term>
1716     <listitem>
1717       <para>
1718 Specifies the connection to the X server.
1719       </para>
1720     </listitem>
1721   </varlistentry>
1722   <varlistentry>
1723     <term>
1724       <emphasis remap='I'>w</emphasis>
1725     </term>
1726     <listitem>
1727       <para>
1728 Specifies the window.
1729       </para>
1730     </listitem>
1731   </varlistentry>
1732   <varlistentry>
1733     <term>
1734       <emphasis remap='I'>text_prop</emphasis>
1735     </term>
1736     <listitem>
1737       <para>
1738 Specifies the
1739 <structname>XTextProperty</structname>
1740 structure to be used.
1741     </para>
1742   </listitem>
1743   </varlistentry>
1744 </variablelist>
1745 <para>
1746 <!-- .LP -->
1747 <!-- .eM -->
1748 The
1749 <xref linkend='XSetWMIconName' xrefstyle='select: title'/>
1750 convenience function calls
1751 <xref linkend='XSetTextProperty' xrefstyle='select: title'/>
1752 to set the <property>WM_ICON_NAME</property> property.
1753 <!-- .sp -->
1754 </para>
1755 <para>
1756 <!-- .LP -->
1757 To read a window's <property>WM_ICON_NAME</property> property,
1758 use
1759 <xref linkend='XGetWMIconName' xrefstyle='select: title'/>.
1760 </para>
1761 <indexterm significance="preferred"><primary>XGetWMIconName</primary></indexterm>
1762 <!-- .sM -->
1763 <funcsynopsis id='XGetWMIconName'>
1764 <funcprototype>
1765   <funcdef>Status <function>XGetWMIconName</function></funcdef>
1766   <paramdef>Display<parameter> *display</parameter></paramdef>
1767   <paramdef>Window<parameter> w</parameter></paramdef>
1768   <paramdef>XTextProperty<parameter> *text_prop_return</parameter></paramdef>
1769 </funcprototype>
1770 </funcsynopsis>
1771 <!-- .FN -->
1772 <variablelist>
1773   <varlistentry>
1774     <term>
1775       <emphasis remap='I'>display</emphasis>
1776     </term>
1777     <listitem>
1778       <para>
1779 Specifies the connection to the X server.
1780       </para>
1781     </listitem>
1782   </varlistentry>
1783   <varlistentry>
1784     <term>
1785       <emphasis remap='I'>w</emphasis>
1786     </term>
1787     <listitem>
1788       <para>
1789 Specifies the window.
1790       </para>
1791     </listitem>
1792   </varlistentry>
1793   <varlistentry>
1794     <term>
1795       <emphasis remap='I'>text_prop_return</emphasis>
1796     </term>
1797     <listitem>
1798       <para>
1799 Returns the
1800 <structname>XTextProperty</structname>
1801 structure.
1802     </para>
1803   </listitem>
1804   </varlistentry>
1805 </variablelist>
1806 <para>
1807 <!-- .LP -->
1808 <!-- .eM -->
1809 The 
1810 <xref linkend='XGetWMIconName' xrefstyle='select: title'/>
1811 convenience function calls
1812 <xref linkend='XGetTextProperty' xrefstyle='select: title'/>
1813 to obtain the <property>WM_ICON_NAME</property> property.
1814 It returns a nonzero status on success;
1815 otherwise, it returns a zero status.
1816 </para>
1817 <para>
1818 <!-- .LP -->
1819 The next two functions have been superseded by
1820 <xref linkend='XSetWMIconName' xrefstyle='select: title'/>
1821 and
1822 <xref linkend='XGetWMIconName' xrefstyle='select: title'/>,
1823 respectively.
1824 You can use these additional convenience functions 
1825 for window names that are encoded as STRING properties.
1826 <!-- .sp -->
1827 </para>
1828 <para>
1829 <!-- .LP -->
1830 <!-- .sp -->
1831 To set the name to be displayed in a window's icon, use
1832 <xref linkend='XSetIconName' xrefstyle='select: title'/>.
1833 </para>
1834 <indexterm><primary>Window</primary><secondary>icon name</secondary></indexterm>
1835 <indexterm significance="preferred"><primary>XSetIconName</primary></indexterm>
1836 <!-- .sM -->
1837 <funcsynopsis id='XSetIconName'>
1838 <funcprototype>
1839   <funcdef><function>XSetIconName</function></funcdef>
1840   <paramdef>Display<parameter> *display</parameter></paramdef>
1841   <paramdef>Window<parameter> w</parameter></paramdef>
1842   <paramdef>char<parameter> *icon_name</parameter></paramdef>
1843 </funcprototype>
1844 </funcsynopsis>
1845 <!-- .FN -->
1846 <variablelist>
1847   <varlistentry>
1848     <term>
1849       <emphasis remap='I'>display</emphasis>
1850     </term>
1851     <listitem>
1852       <para>
1853 Specifies the connection to the X server.
1854       </para>
1855     </listitem>
1856   </varlistentry>
1857   <varlistentry>
1858     <term>
1859       <emphasis remap='I'>w</emphasis>
1860     </term>
1861     <listitem>
1862       <para>
1863 Specifies the window.
1864       </para>
1865     </listitem>
1866   </varlistentry>
1867   <varlistentry>
1868     <term>
1869       <emphasis remap='I'>icon_name</emphasis>
1870     </term>
1871     <listitem>
1872       <para>
1873 Specifies the icon name,
1874 which should be a null-terminated string.
1875     </para>
1876   </listitem>
1877   </varlistentry>
1878 </variablelist>
1879 <para>
1880 <!-- .LP -->
1881 <!-- .eM -->
1882 If the string is not in the Host Portable Character Encoding,
1883 the result is implementation-dependent.
1884 <xref linkend='XSetIconName' xrefstyle='select: title'/>
1885 can generate
1886 <errorname>BadAlloc</errorname>
1887 and
1888 <errorname>BadWindow</errorname>
1889 errors.
1890 </para>
1891 <para>
1892 <!-- .LP -->
1893 <!-- .sp -->
1894 To get the name a window wants displayed in its icon, use
1895 <xref linkend='XGetIconName' xrefstyle='select: title'/>.
1896 </para>
1897 <indexterm significance="preferred"><primary>XGetIconName</primary></indexterm>
1898 <!-- .sM -->
1899 <funcsynopsis id='XGetIconName'>
1900 <funcprototype>
1901   <funcdef>Status <function>XGetIconName</function></funcdef>
1902   <paramdef>Display<parameter> *display</parameter></paramdef>
1903   <paramdef>Window<parameter> w</parameter></paramdef>
1904   <paramdef>char<parameter> **icon_name_return</parameter></paramdef>
1905 </funcprototype>
1906 </funcsynopsis>
1907 <!-- .FN -->
1908 <variablelist>
1909   <varlistentry>
1910     <term>
1911       <emphasis remap='I'>display</emphasis>
1912     </term>
1913     <listitem>
1914       <para>
1915 Specifies the connection to the X server.
1916       </para>
1917     </listitem>
1918   </varlistentry>
1919   <varlistentry>
1920     <term>
1921       <emphasis remap='I'>w</emphasis>
1922     </term>
1923     <listitem>
1924       <para>
1925 Specifies the window.
1926       </para>
1927     </listitem>
1928   </varlistentry>
1929   <varlistentry>
1930     <term>
1931       <emphasis remap='I'>icon_name_return</emphasis>
1932     </term>
1933     <listitem>
1934       <para>
1935 Returns the window's icon name,
1936 which is a null-terminated string.
1937     </para>
1938   </listitem>
1939   </varlistentry>
1940 </variablelist>
1941 <para>
1942 <!-- .LP -->
1943 <!-- .eM -->
1944 The
1945 <xref linkend='XGetIconName' xrefstyle='select: title'/>
1946 function returns the name to be displayed in the specified window's icon.
1947 If it succeeds, it returns a nonzero status; otherwise, 
1948 if no icon name has been set for the window,
1949 it returns zero.
1950 If you never assigned a name to the window,
1951 <xref linkend='XGetIconName' xrefstyle='select: title'/>
1952 sets icon_name_return to NULL.
1953 If the data returned by the server is in the Latin Portable Character Encoding,
1954 then the returned string is in the Host Portable Character Encoding.
1955 Otherwise, the result is implementation-dependent.
1956 When finished with it, a client must free
1957 the icon name string using
1958 <xref linkend='XFree' xrefstyle='select: title'/>.
1959 </para>
1960 <para>
1961 <!-- .LP -->
1962 <xref linkend='XGetIconName' xrefstyle='select: title'/>
1963 can generate a
1964 <errorname>BadWindow</errorname>
1965 error.
1966 </para>
1967 </sect2>
1968 <sect2 id="Setting_and_Reading_the_WM_HINTS_Property">
1969 <title>Setting and Reading the WM_HINTS Property</title>
1970 <!-- .XS -->
1971 <!-- (SN Setting and Reading the WM_HINTS Property -->
1972 <!-- .XE -->
1973 <para>
1974 <!-- .LP -->
1975 Xlib provides functions that you can use to set and read 
1976 the <property>WM_HINTS</property> property for a given window.
1977 These functions use the flags and the
1978 <structname>XWMHints</structname>
1979 structure, as defined in the
1980 <filename class="headerfile">&lt;X11/Xutil.h&gt;</filename>
1981 <indexterm type="file"><primary><filename class="headerfile">X11/Xutil.h</filename></primary></indexterm>
1982 <indexterm><primary>Files</primary><secondary><filename class="headerfile">&lt;X11/Xutil.h&gt;</filename></secondary></indexterm>
1983 <indexterm><primary>Headers</primary><secondary><filename class="headerfile">&lt;X11/Xutil.h&gt;</filename></secondary></indexterm>
1984 header file.
1985 <!-- .sp -->
1986 </para>
1987 <para>
1988 <!-- .LP -->
1989 To allocate an
1990 <structname>XWMHints</structname>
1991 structure, use
1992 <function>XAllocWMHints</function>.
1993 </para>
1994
1995 <para>
1996   XWMHints *XAllocWMHints()
1997 </para>
1998
1999 <para>
2000 <!-- .LP -->
2001 <!-- .eM -->
2002 The
2003 <function>XAllocWMHints</function>
2004 function allocates and returns a pointer to an
2005 <structname>XWMHints</structname>
2006 structure.
2007 Note that all fields in the
2008 <structname>XWMHints</structname>
2009 structure are initially set to zero.
2010 If insufficient memory is available, 
2011 <function>XAllocWMHints</function>
2012 returns NULL.
2013 To free the memory allocated to this structure,
2014 use
2015 <xref linkend='XFree' xrefstyle='select: title'/>.
2016 </para>
2017 <para>
2018 <!-- .LP -->
2019 The
2020 <structname>XWMHints</structname>
2021 structure contains:
2022 </para>
2023
2024 <literallayout class="monospaced">
2025 /* Window manager hints mask bits */
2026
2027 #define         InputHint             (1L&lt;&lt;0)
2028 #define         StateHint             (1L&lt;&lt;1)
2029 #define         IconPixmapHint        (1L&lt;&lt;2)
2030 #define         IconWindowHint        (1L&lt;&lt;3)
2031 #define         IconPositionHint      (1L&lt;&lt;4)
2032 #define         IconMaskHint          (1L&lt;&lt;5)
2033 #define         WindowGroupHint       (1L&lt;&lt;6)
2034 #define         UrgencyHint           (1L&lt;&lt;8)
2035 #define         AllHints              (InputHint|StateHint|IconPixmapHint|
2036                                        IconWIndowHint|IconPositionHint|
2037                                        IconMaskHint|WindowGroupHint)
2038
2039
2040 /* Values */
2041
2042 typedef struct {
2043         long flags;             /* marks which fields in this structure are defined */
2044         Bool input;             /* does this application rely on the window manager to
2045                                    get keyboard input? */
2046         int initial_state;      /* see below */
2047         Pixmap icon_pixmap;     /* pixmap to be used as icon */
2048         Window icon_window;     /* window to be used as icon */
2049         int icon_x, icon_y;     /* initial position of icon */
2050         Pixmap icon_mask;       /* pixmap to be used as mask for icon_pixmap */
2051         XID window_group;       /* id of related window group */
2052         /* this structure may be extended in the future */
2053 } XWMHints;
2054 </literallayout>
2055 <para>
2056 <!-- .LP -->
2057 <!-- .eM -->
2058 The input member is used to communicate to the window manager the input focus
2059 model used by the application.
2060 Applications that expect input but never explicitly set focus to any 
2061 of their subwindows (that is, use the push model of focus management), 
2062 such as X Version 10 style applications that use real-estate
2063 driven focus, should set this member to 
2064 <symbol>True</symbol>.
2065 Similarly, applications
2066 that set input focus to their subwindows only when it is given to their
2067 top-level window by a window manager should also set this member to 
2068 <symbol>True</symbol>.
2069 Applications that manage their own input focus by explicitly setting
2070 focus to one of their subwindows whenever they want keyboard input 
2071 (that is, use the pull model of focus management) should set this member to 
2072 <symbol>False</symbol>.
2073 Applications that never expect any keyboard input also should set this member
2074 to 
2075 <symbol>False</symbol>.
2076 </para>
2077 <para>
2078 <!-- .LP -->
2079 Pull model window managers should make it possible for push model
2080 applications to get input by setting input focus to the top-level windows of
2081 applications whose input member is 
2082 <symbol>True</symbol>.
2083 Push model window managers should
2084 make sure that pull model applications do not break them 
2085 by resetting input focus to 
2086 <symbol>PointerRoot</symbol>
2087 when it is appropriate (for example, whenever an application whose
2088 input member is 
2089 <symbol>False</symbol>
2090 sets input focus to one of its subwindows).
2091 </para>
2092 <para>
2093 <!-- .LP -->
2094 The definitions for the initial_state flag are:
2095 </para>
2096
2097 <literallayout class="monospaced">
2098 #define      WithdrawnState 0
2099 #define      NormalState    1   /* most applications start this way */
2100 #define      IconicState    2   /* application wants to start as an icon */
2101
2102 </literallayout>
2103 <para>
2104 The icon_mask specifies which pixels of the icon_pixmap should be used as the
2105 icon.  
2106 This allows for nonrectangular icons.
2107 Both icon_pixmap and icon_mask must be bitmaps.
2108 The icon_window lets an application provide a window for use as an icon
2109 for window managers that support such use.
2110 The window_group lets you specify that this window belongs to a group
2111 of other windows.
2112 For example, if a single application manipulates multiple 
2113 top-level windows, this allows you to provide enough
2114 information that a window manager can iconify all of the windows
2115 rather than just the one window.
2116 </para>
2117 <para>
2118 <!-- .LP -->
2119 The
2120 <symbol>UrgencyHint</symbol>
2121 flag, if set in the flags field, indicates that the client deems the window
2122 contents to be urgent, requiring the timely response of the user.  The
2123 window manager will make some effort to draw the user's attention to this
2124 window while this flag is set.  The client must provide some means by which the
2125 user can cause the urgency flag to be cleared (either mitigating
2126 the condition that made the window urgent or merely shutting off the alarm)
2127 or the window to be withdrawn.
2128 </para>
2129 <para>
2130 <!-- .LP -->
2131 <!-- .sp -->
2132 To set a window's <property>WM_HINTS</property> property, use
2133 <xref linkend='XSetWMHints' xrefstyle='select: title'/>.
2134 </para>
2135 <indexterm significance="preferred"><primary>XSetWMHints</primary></indexterm>
2136 <!-- .sM -->
2137 <funcsynopsis id='XSetWMHints'>
2138 <funcprototype>
2139   <funcdef><function>XSetWMHints</function></funcdef>
2140   <paramdef>Display<parameter> *display</parameter></paramdef>
2141   <paramdef>Window<parameter> w</parameter></paramdef>
2142   <paramdef>XWMHints<parameter> *wmhints</parameter></paramdef>
2143 </funcprototype>
2144 </funcsynopsis>
2145 <!-- .FN -->
2146 <variablelist>
2147   <varlistentry>
2148     <term>
2149       <emphasis remap='I'>display</emphasis>
2150     </term>
2151     <listitem>
2152       <para>
2153 Specifies the connection to the X server.
2154       </para>
2155     </listitem>
2156   </varlistentry>
2157   <varlistentry>
2158     <term>
2159       <emphasis remap='I'>w</emphasis>
2160     </term>
2161     <listitem>
2162       <para>
2163 Specifies the window.
2164       </para>
2165     </listitem>
2166   </varlistentry>
2167   <varlistentry>
2168     <term>
2169       <emphasis remap='I'>wmhints</emphasis>
2170     </term>
2171     <listitem>
2172       <para>
2173 Specifies the 
2174 <structname>XWMHints</structname>
2175 structure to be used.
2176     </para>
2177   </listitem>
2178   </varlistentry>
2179 </variablelist>
2180 <para>
2181 <!-- .LP -->
2182 <!-- .eM -->
2183 The
2184 <xref linkend='XSetWMHints' xrefstyle='select: title'/>
2185 function sets the window manager hints that include icon information and location,
2186 the initial state of the window, and whether the application relies on the
2187 window manager to get keyboard input.
2188 </para>
2189 <para>
2190 <!-- .LP -->
2191 <xref linkend='XSetWMHints' xrefstyle='select: title'/>
2192 can generate
2193 <errorname>BadAlloc</errorname>
2194 and
2195 <errorname>BadWindow</errorname>
2196 errors.
2197 </para>
2198 <para>
2199 <!-- .LP -->
2200 <!-- .sp -->
2201 To read a window's <property>WM_HINTS</property> property, use
2202 <xref linkend='XGetWMHints' xrefstyle='select: title'/>.
2203 </para>
2204 <indexterm significance="preferred"><primary>XGetWMHints</primary></indexterm>
2205 <!-- .sM -->
2206 <funcsynopsis id='XGetWMHints'>
2207 <funcprototype>
2208   <funcdef>XWMHints *<function>XGetWMHints</function></funcdef>
2209   <paramdef>Display<parameter> *display</parameter></paramdef>
2210   <paramdef>Window<parameter> w</parameter></paramdef>
2211 </funcprototype>
2212 </funcsynopsis>
2213 <!-- .FN -->
2214 <variablelist>
2215   <varlistentry>
2216     <term>
2217       <emphasis remap='I'>display</emphasis>
2218     </term>
2219     <listitem>
2220       <para>
2221 Specifies the connection to the X server.
2222       </para>
2223     </listitem>
2224   </varlistentry>
2225   <varlistentry>
2226     <term>
2227       <emphasis remap='I'>w</emphasis>
2228     </term>
2229     <listitem>
2230       <para>
2231 Specifies the window.
2232     </para>
2233   </listitem>
2234   </varlistentry>
2235 </variablelist>
2236 <para>
2237 <!-- .LP -->
2238 <!-- .eM -->
2239 The
2240 <xref linkend='XGetWMHints' xrefstyle='select: title'/>
2241 function reads the window manager hints and 
2242 returns NULL if no <property>WM_HINTS</property> property was set on the window 
2243 or returns a pointer to an 
2244 <structname>XWMHints</structname>
2245 structure if it succeeds.
2246 When finished with the data,
2247 free the space used for it by calling
2248 <xref linkend='XFree' xrefstyle='select: title'/>.
2249 </para>
2250 <para>
2251 <!-- .LP -->
2252 <xref linkend='XGetWMHints' xrefstyle='select: title'/>
2253 can generate a
2254 <errorname>BadWindow</errorname>
2255 error.
2256 </para>
2257 </sect2>
2258 <sect2 id="Setting_and_Reading_the_WM_NORMAL_HINTS_Property">
2259 <title>Setting and Reading the WM_NORMAL_HINTS Property</title>
2260 <!-- .XS -->
2261 <!-- (SN Setting and Reading the WM_NORMAL_HINTS Property -->
2262 <!-- .XE -->
2263 <para>
2264 <!-- .LP -->
2265 Xlib provides functions that you can use to set or read 
2266 the <property>WM_NORMAL_HINTS</property> property for a given window.
2267 The functions use the flags and the
2268 <structname>XSizeHints</structname>
2269 structure, as defined in the
2270 <filename class="headerfile">&lt;X11/Xutil.h&gt;</filename>
2271 <indexterm type="file"><primary><filename class="headerfile">X11/Xutil.h</filename></primary></indexterm>
2272 <indexterm><primary>Files</primary><secondary><filename class="headerfile">&lt;X11/Xutil.h&gt;</filename></secondary></indexterm>
2273 <indexterm><primary>Headers</primary><secondary><filename class="headerfile">&lt;X11/Xutil.h&gt;</filename></secondary></indexterm>
2274 header file.
2275 </para>
2276 <para>
2277 <!-- .LP -->
2278 The size of the
2279 <structname>XSizeHints</structname>
2280 structure may grow in future releases, as new components are
2281 added to support new <acronym>ICCCM</acronym> features.
2282 Passing statically allocated instances of this structure into
2283 Xlib may result in memory corruption when running against a
2284 future release of the library.
2285 As such, it is recommended that only dynamically allocated
2286 instances of the structure be used.
2287 <!-- .sp -->
2288 </para>
2289 <para>
2290 <!-- .LP -->
2291 To allocate an
2292 <structname>XSizeHints</structname>
2293 structure, use
2294 <function>XAllocSizeHints</function>.
2295 </para>
2296
2297 <para>
2298 XSizeHints *XAllocSizeHints()
2299 </para>
2300 <para>
2301 <!-- .LP -->
2302 <!-- .eM -->
2303 The
2304 <function>XAllocSizeHints</function>
2305 function allocates and returns a pointer to an
2306 <structname>XSizeHints</structname>
2307 structure.
2308 Note that all fields in the
2309 <structname>XSizeHints</structname>
2310 structure are initially set to zero.
2311 If insufficient memory is available, 
2312 <function>XAllocSizeHints</function>
2313 returns NULL.
2314 To free the memory allocated to this structure,
2315 use
2316 <xref linkend='XFree' xrefstyle='select: title'/>.
2317 </para>
2318 <para>
2319 <!-- .LP -->
2320 The
2321 <structname>XSizeHints</structname>
2322 structure contains:
2323 </para>
2324
2325
2326 <literallayout class="monospaced">
2327 /* Size hints mask bits */
2328
2329 #define           USPosition         (1L&lt;&lt;0)  /* user specified x,y */
2330 #define           USSize             (1L&lt;&lt;1)  /* user specified width,height */
2331 #define           PPosition          (1L&lt;&lt;2)  /* program specified posistion */
2332 #define           PSize              (1L&lt;&lt;3)  /* program specified size */
2333 #define           PMinSize           (1L&lt;&lt;4)  /* program specified minimum size */
2334 #define           PMaxSize           (1L&lt;&lt;5)  /* program specified maximum size */
2335 #define           PResizeInc         (1L&lt;&lt;5)  /* program specified resize increments */
2336 #define           PAspect            (1L&lt;&lt;6)  /* program specified min and max aspect ratios */
2337 #define           PBaseSize          (1L&lt;&lt;8)
2338 #define           PWinGravity        (1L&lt;&lt;9)
2339 #define           PAllHints          (PPosition|Psize|
2340                                       PMinSize|PMaxSize|
2341                                       PResizeInc|PAspect)
2342
2343
2344 /* Values */
2345
2346 typedef struct {
2347         long flags;             /* marks which fields in this structure are defined */
2348         int x, y;               /* Obsolete */
2349         int width, height;      /* Obsolete */
2350         int min_width, min_height;
2351         int max_width, max_height;
2352         int width_inc, height_inc;
2353         struct {
2354                int x;           /* numerator */
2355                int y;           /* denominator */
2356         } min_aspect, max_aspect;
2357         int base_width, base_height;
2358         int win_gravity;
2359         /* this structure may be extended in the future */
2360 } XSizeHints;
2361 </literallayout>
2362
2363 <para>
2364 <!-- .LP -->
2365 <!-- .eM -->
2366 The x, y, width, and height members are now obsolete
2367 and are left solely for compatibility reasons.
2368 The min_width and min_height members specify the
2369 minimum window size that still allows the application to be useful.
2370 The max_width and max_height members specify the maximum window size.
2371 The width_inc and height_inc members define an arithmetic progression of
2372 sizes (minimum to maximum) into which the window prefers to be resized.
2373 The min_aspect and max_aspect members are expressed
2374 as ratios of x and y, 
2375 and they allow an application to specify the range of aspect
2376 ratios it prefers.
2377 The base_width and base_height members define the desired size of the window.
2378 The window manager will interpret the position of the window 
2379 and its border width to position the point of the outer rectangle 
2380 of the overall window specified by the win_gravity member.
2381 The outer rectangle of the window includes any borders or decorations
2382 supplied by the window manager.
2383 In other words,
2384 if the window manager decides to place the window where the client asked,
2385 the position on the parent window's border named by the win_gravity 
2386 will be placed where the client window would have been placed 
2387 in the absence of a window manager.
2388 </para>
2389 <para>
2390 <!-- .LP -->
2391 Note that use of the
2392 <symbol>PAllHints</symbol>
2393 macro is highly discouraged.
2394 <!-- .sp -->
2395 </para>
2396 <para>
2397 <!-- .LP -->
2398 To set a window's <property>WM_NORMAL_HINTS</property> property, use
2399 <xref linkend='XSetWMNormalHints' xrefstyle='select: title'/>.
2400 </para>
2401 <indexterm significance="preferred"><primary>XSetWMNormalHints</primary></indexterm>
2402 <!-- .sM -->
2403 <funcsynopsis id='XSetWMNormalHints'>
2404 <funcprototype>
2405   <funcdef>void <function>XSetWMNormalHints</function></funcdef>
2406   <paramdef>Display<parameter> *display</parameter></paramdef>
2407   <paramdef>Window<parameter> w</parameter></paramdef>
2408   <paramdef>XSizeHints<parameter> *hints</parameter></paramdef>
2409 </funcprototype>
2410 </funcsynopsis>
2411 <!-- .FN -->
2412 <variablelist>
2413   <varlistentry>
2414     <term>
2415       <emphasis remap='I'>display</emphasis>
2416     </term>
2417     <listitem>
2418       <para>
2419 Specifies the connection to the X server.
2420       </para>
2421     </listitem>
2422   </varlistentry>
2423   <varlistentry>
2424     <term>
2425       <emphasis remap='I'>w</emphasis>
2426     </term>
2427     <listitem>
2428       <para>
2429 Specifies the window.
2430       </para>
2431     </listitem>
2432   </varlistentry>
2433   <varlistentry>
2434     <term>
2435       <emphasis remap='I'>hints</emphasis>
2436     </term>
2437     <listitem>
2438       <para>
2439 Specifies the size hints for the window in its normal state.
2440     </para>
2441   </listitem>
2442   </varlistentry>
2443 </variablelist>
2444 <para>
2445 <!-- .LP -->
2446 <!-- .eM -->
2447 The 
2448 <xref linkend='XSetWMNormalHints' xrefstyle='select: title'/>
2449 function replaces the size hints for the <property>WM_NORMAL_HINTS</property> property 
2450 on the specified window.
2451 If the property does not already exist,
2452 <xref linkend='XSetWMNormalHints' xrefstyle='select: title'/>
2453 sets the size hints for the <property>WM_NORMAL_HINTS</property> property on the specified window.
2454 The property is stored with a type of <property>WM_SIZE_HINTS</property> and a format of 32.
2455 </para>
2456 <para>
2457 <!-- .LP -->
2458 <xref linkend='XSetWMNormalHints' xrefstyle='select: title'/>
2459 can generate
2460 <errorname>BadAlloc</errorname>
2461 and
2462 <errorname>BadWindow</errorname>
2463 errors.
2464 <!-- .sp -->
2465 </para>
2466 <para>
2467 <!-- .LP -->
2468 To read a window's <property>WM_NORMAL_HINTS</property> property, use
2469 <xref linkend='XGetWMNormalHints' xrefstyle='select: title'/>.
2470 </para>
2471 <indexterm significance="preferred"><primary>XGetWMNormalHints</primary></indexterm>
2472 <!-- .sM -->
2473 <funcsynopsis id='XGetWMNormalHints'>
2474 <funcprototype>
2475   <funcdef>Status <function>XGetWMNormalHints</function></funcdef>
2476   <paramdef>Display<parameter> *display</parameter></paramdef>
2477   <paramdef>Window<parameter> w</parameter></paramdef>
2478   <paramdef>XSizeHints<parameter> *hints_return</parameter></paramdef>
2479   <paramdef>long<parameter> *supplied_return</parameter></paramdef>
2480 </funcprototype>
2481 </funcsynopsis>
2482 <!-- .FN -->
2483 <variablelist>
2484   <varlistentry>
2485     <term>
2486       <emphasis remap='I'>display</emphasis>
2487     </term>
2488     <listitem>
2489       <para>
2490 Specifies the connection to the X server.
2491       </para>
2492     </listitem>
2493   </varlistentry>
2494   <varlistentry>
2495     <term>
2496       <emphasis remap='I'>w</emphasis>
2497     </term>
2498     <listitem>
2499       <para>
2500 Specifies the window.
2501       </para>
2502     </listitem>
2503   </varlistentry>
2504   <varlistentry>
2505     <term>
2506       <emphasis remap='I'>hints_return</emphasis>
2507     </term>
2508     <listitem>
2509       <para>
2510 Returns the size hints for the window in its normal state.
2511       </para>
2512     </listitem>
2513   </varlistentry>
2514   <varlistentry>
2515     <term>
2516       <emphasis remap='I'>supplied_return</emphasis>
2517     </term>
2518     <listitem>
2519       <para>
2520 Returns the hints that were supplied by the user.
2521     </para>
2522   </listitem>
2523   </varlistentry>
2524 </variablelist>
2525 <para>
2526 <!-- .LP -->
2527 <!-- .eM -->
2528 The 
2529 <xref linkend='XGetWMNormalHints' xrefstyle='select: title'/>
2530 function returns the size hints stored in the <property>WM_NORMAL_HINTS</property> property 
2531 on the specified window.
2532 If the property is of type <property>WM_SIZE_HINTS</property>, is of format 32,
2533 and is long enough to contain either an old (pre-<acronym>ICCCM</acronym>) 
2534 or new size hints structure, 
2535 <xref linkend='XGetWMNormalHints' xrefstyle='select: title'/>
2536 sets the various fields of the 
2537 <structname>XSizeHints</structname>
2538 structure, sets the supplied_return argument to the list of fields 
2539 that were supplied by the user (whether or not they contained defined values),
2540 and returns a nonzero status.
2541 Otherwise, it returns a zero status.
2542 </para>
2543 <para>
2544 <!-- .LP -->
2545 If 
2546 <xref linkend='XGetWMNormalHints' xrefstyle='select: title'/>
2547 returns successfully and a pre-<acronym>ICCCM</acronym> size hints property is read, 
2548 the supplied_return argument will contain the following bits:
2549 </para>
2550 <para>
2551 <!-- .LP -->
2552 <literallayout class="monospaced">
2553 (USPosition|USSize|PPosition|PSize|PMinSize|
2554  PMaxSize|PResizeInc|PAspect)
2555 </literallayout>
2556 </para>
2557 <para>
2558 <!-- .LP -->
2559 If the property is large enough to contain the base size 
2560 and window gravity fields as well, 
2561 the supplied_return argument will also contain the following bits:
2562 </para>
2563 <para>
2564 <!-- .LP -->
2565 <literallayout class="monospaced">
2566 PBaseSize|PWinGravity
2567 </literallayout>
2568 </para>
2569 <para>
2570 <!-- .LP -->
2571 <xref linkend='XGetWMNormalHints' xrefstyle='select: title'/>
2572 can generate a
2573 <errorname>BadWindow</errorname>
2574 error.
2575 <!-- .sp -->
2576 </para>
2577 <para>
2578 <!-- .LP -->
2579 To set a window's <property>WM_SIZE_HINTS</property> property, use
2580 <xref linkend='XSetWMSizeHints' xrefstyle='select: title'/>.
2581 </para>
2582 <indexterm significance="preferred"><primary>XSetWMSizeHints</primary></indexterm>
2583 <!-- .sM -->
2584 <funcsynopsis id='XSetWMSizeHints'>
2585 <funcprototype>
2586   <funcdef>void <function>XSetWMSizeHints</function></funcdef>
2587   <paramdef>Display<parameter> *display</parameter></paramdef>
2588   <paramdef>Window<parameter> w</parameter></paramdef>
2589   <paramdef>XSizeHints<parameter> *hints</parameter></paramdef>
2590   <paramdef>Atom<parameter> property</parameter></paramdef>
2591 </funcprototype>
2592 </funcsynopsis>
2593 <!-- .FN -->
2594 <variablelist>
2595   <varlistentry>
2596     <term>
2597       <emphasis remap='I'>display</emphasis>
2598     </term>
2599     <listitem>
2600       <para>
2601 Specifies the connection to the X server.
2602       </para>
2603     </listitem>
2604   </varlistentry>
2605   <varlistentry>
2606     <term>
2607       <emphasis remap='I'>w</emphasis>
2608     </term>
2609     <listitem>
2610       <para>
2611 Specifies the window.
2612       </para>
2613     </listitem>
2614   </varlistentry>
2615   <varlistentry>
2616     <term>
2617       <emphasis remap='I'>hints</emphasis>
2618     </term>
2619     <listitem>
2620       <para>
2621 Specifies the
2622 <structname>XSizeHints</structname>
2623 structure to be used.
2624       </para>
2625     </listitem>
2626   </varlistentry>
2627   <varlistentry>
2628     <term>
2629       <emphasis remap='I'>property</emphasis>
2630     </term>
2631     <listitem>
2632       <para>
2633 Specifies the property name.
2634     </para>
2635   </listitem>
2636   </varlistentry>
2637 </variablelist>
2638 <para>
2639 <!-- .LP -->
2640 <!-- .eM -->
2641 The 
2642 <xref linkend='XSetWMSizeHints' xrefstyle='select: title'/>
2643 function replaces the size hints for the specified property 
2644 on the named window.
2645 If the specified property does not already exist,
2646 <xref linkend='XSetWMSizeHints' xrefstyle='select: title'/>
2647 sets the size hints for the specified property
2648 on the named window.
2649 The property is stored with a type of <property>WM_SIZE_HINTS</property> and a format of 32.
2650 To set a window's normal size hints, 
2651 you can use the 
2652 <xref linkend='XSetWMNormalHints' xrefstyle='select: title'/>
2653 function.
2654 </para>
2655 <para>
2656 <!-- .LP -->
2657 <xref linkend='XSetWMSizeHints' xrefstyle='select: title'/>
2658 can generate
2659 <errorname>BadAlloc</errorname>,
2660 <errorname>BadAtom</errorname>,
2661 and 
2662 <errorname>BadWindow</errorname>
2663 errors.
2664 <!-- .sp -->
2665 </para>
2666 <para>
2667 <!-- .LP -->
2668 To read a window's <property>WM_SIZE_HINTS</property> property, use
2669 <xref linkend='XGetWMSizeHints' xrefstyle='select: title'/>.
2670 </para>
2671 <indexterm significance="preferred"><primary>XGetWMSizeHints</primary></indexterm>
2672 <!-- .sM -->
2673 <funcsynopsis id='XGetWMSizeHints'>
2674 <funcprototype>
2675   <funcdef>Status <function>XGetWMSizeHints</function></funcdef>
2676   <paramdef>Display<parameter> *display</parameter></paramdef>
2677   <paramdef>Window<parameter> w</parameter></paramdef>
2678   <paramdef>XSizeHints<parameter> *hints_return</parameter></paramdef>
2679   <paramdef>long<parameter> *supplied_return</parameter></paramdef>
2680   <paramdef>Atom<parameter> property</parameter></paramdef>
2681 </funcprototype>
2682 </funcsynopsis>
2683 <!-- .FN -->
2684 <variablelist>
2685   <varlistentry>
2686     <term>
2687       <emphasis remap='I'>display</emphasis>
2688     </term>
2689     <listitem>
2690       <para>
2691 Specifies the connection to the X server.
2692       </para>
2693     </listitem>
2694   </varlistentry>
2695   <varlistentry>
2696     <term>
2697       <emphasis remap='I'>w</emphasis>
2698     </term>
2699     <listitem>
2700       <para>
2701 Specifies the window.
2702       </para>
2703     </listitem>
2704   </varlistentry>
2705   <varlistentry>
2706     <term>
2707       <emphasis remap='I'>hints_return</emphasis>
2708     </term>
2709     <listitem>
2710       <para>
2711 Returns the
2712 <structname>XSizeHints</structname>
2713 structure.
2714       </para>
2715     </listitem>
2716   </varlistentry>
2717   <varlistentry>
2718     <term>
2719       <emphasis remap='I'>supplied_return</emphasis>
2720     </term>
2721     <listitem>
2722       <para>
2723 Returns the hints that were supplied by the user.
2724       </para>
2725     </listitem>
2726   </varlistentry>
2727   <varlistentry>
2728     <term>
2729       <emphasis remap='I'>property</emphasis>
2730     </term>
2731     <listitem>
2732       <para>
2733 Specifies the property name.
2734     </para>
2735   </listitem>
2736   </varlistentry>
2737 </variablelist>
2738 <para>
2739 <!-- .LP -->
2740 <!-- .eM -->
2741 The 
2742 <xref linkend='XGetWMSizeHints' xrefstyle='select: title'/>
2743 function returns the size hints stored in the specified property 
2744 on the named window.
2745 If the property is of type <property>WM_SIZE_HINTS</property>, is of format 32, 
2746 and is long enough to contain either an old (pre-<acronym>ICCCM</acronym>) 
2747 or new size hints structure, 
2748 <xref linkend='XGetWMSizeHints' xrefstyle='select: title'/>
2749 sets the various fields of the 
2750 <structname>XSizeHints</structname>
2751 structure, sets the supplied_return argument to the
2752 list of fields that were supplied by the user 
2753 (whether or not they contained defined values), 
2754 and returns a nonzero status.
2755 Otherwise, it returns a zero status.
2756 To get a window's normal size hints, 
2757 you can use the 
2758 <xref linkend='XGetWMNormalHints' xrefstyle='select: title'/>
2759 function.
2760 </para>
2761 <para>
2762 <!-- .LP -->
2763 If 
2764 <xref linkend='XGetWMSizeHints' xrefstyle='select: title'/>
2765 returns successfully and a pre-<acronym>ICCCM</acronym> size hints property is read, 
2766 the supplied_return argument will contain the following bits:
2767 </para>
2768 <para>
2769 <!-- .LP -->
2770 <literallayout class="monospaced">
2771 (USPosition|USSize|PPosition|PSize|PMinSize|
2772  PMaxSize|PResizeInc|PAspect)
2773 </literallayout>
2774 </para>
2775 <para>
2776 <!-- .LP -->
2777 If the property is large enough to contain the base size 
2778 and window gravity fields as well, 
2779 the supplied_return argument will also contain the following bits:
2780 </para>
2781 <para>
2782 <!-- .LP -->
2783 <literallayout class="monospaced">
2784 PBaseSize|PWinGravity
2785 </literallayout>
2786 </para>
2787 <para>
2788 <!-- .LP -->
2789 <xref linkend='XGetWMSizeHints' xrefstyle='select: title'/>
2790 can generate
2791 <errorname>BadAtom</errorname>
2792 and 
2793 <errorname>BadWindow</errorname>
2794 errors.
2795 </para>
2796 </sect2>
2797 <sect2 id="Setting_and_Reading_the_WM_CLASS_Property">
2798 <title>Setting and Reading the WM_CLASS Property</title>
2799 <!-- .XS -->
2800 <!-- (SN Setting and Reading the WM_CLASS Property -->
2801 <!-- .XE -->
2802 <para>
2803 <!-- .LP -->
2804 Xlib provides functions that you can use to set and get 
2805 the <property>WM_CLASS</property> property for a given window.
2806 These functions use the
2807 <structname>XClassHint</structname>
2808 structure, which is defined in the
2809 <filename class="headerfile">&lt;X11/Xutil.h&gt;</filename>
2810 <indexterm type="file"><primary><filename class="headerfile">X11/Xutil.h</filename></primary></indexterm>
2811 <indexterm><primary>Files</primary><secondary><filename class="headerfile">&lt;X11/Xutil.h&gt;</filename></secondary></indexterm>
2812 <indexterm><primary>Headers</primary><secondary><filename class="headerfile">&lt;X11/Xutil.h&gt;</filename></secondary></indexterm>
2813 header file.
2814 <!-- .sp -->
2815 </para>
2816 <para>
2817 <!-- .LP -->
2818 To allocate an
2819 <structname>XClassHint</structname>
2820 structure, use
2821 <function>XAllocClassHint</function>.
2822 <indexterm significance="preferred"><primary>XAllocClassHint</primary></indexterm>
2823 <!-- .sM -->
2824 </para>
2825 <para>
2826
2827   XClassHint *XAllocClassHint()
2828 </para>
2829
2830 <para>
2831 <!-- .LP -->
2832 <!-- .eM -->
2833 The
2834 <function>XAllocClassHint</function>
2835 function allocates and returns a pointer to an
2836 <structname>XClassHint</structname>
2837 structure.
2838 Note that the pointer fields in the
2839 <structname>XClassHint</structname>
2840 structure are initially set to NULL.
2841 If insufficient memory is available, 
2842 <function>XAllocClassHint</function>
2843 returns NULL.
2844 To free the memory allocated to this structure,
2845 use
2846 <xref linkend='XFree' xrefstyle='select: title'/>.
2847 </para>
2848 <para>
2849 <!-- .LP -->
2850 The
2851 <structname>XClassHint</structname>
2852 contains:
2853 </para>
2854 <para>
2855 <!-- .LP -->
2856 <!-- .sM -->
2857 <indexterm significance="preferred"><primary>XClassHint</primary></indexterm>
2858 <literallayout class="monospaced">
2859 <!-- .TA .5i -->
2860 <!-- .ta .5i -->
2861 typedef struct {
2862         char *res_name;
2863         char *res_class;
2864 } XClassHint;
2865 </literallayout>
2866 </para>
2867 <para>
2868 <!-- .LP -->
2869 <!-- .eM -->
2870 The res_name member contains the application name, 
2871 and the res_class member contains the application class. 
2872 Note that the name set in this property may differ from the name set as <property>WM_NAME</property>.
2873 That is, <property>WM_NAME</property> specifies what should be displayed in the title bar and,
2874 therefore, can contain temporal information (for example, the name of
2875 a file currently in an editor's buffer).
2876 On the other hand, 
2877 the name specified as part of <property>WM_CLASS</property> is the formal name of the application
2878 that should be used when retrieving the application's resources from the 
2879 resource database.
2880 </para>
2881 <para>
2882 <!-- .LP -->
2883 <!-- .sp -->
2884 To set a window's <property>WM_CLASS</property> property, use
2885 <xref linkend='XSetClassHint' xrefstyle='select: title'/>.
2886 </para>
2887 <indexterm significance="preferred"><primary>XSetClassHint</primary></indexterm>
2888 <!-- .sM -->
2889 <funcsynopsis id='XSetClassHint'>
2890 <funcprototype>
2891   <funcdef><function>XSetClassHint</function></funcdef>
2892   <paramdef>Display<parameter> *display</parameter></paramdef>
2893   <paramdef>Window<parameter> w</parameter></paramdef>
2894   <paramdef>XClassHint<parameter> *class_hints</parameter></paramdef>
2895 </funcprototype>
2896 </funcsynopsis>
2897 <!-- .FN -->
2898 <variablelist>
2899   <varlistentry>
2900     <term>
2901       <emphasis remap='I'>display</emphasis>
2902     </term>
2903     <listitem>
2904       <para>
2905 Specifies the connection to the X server.
2906       </para>
2907     </listitem>
2908   </varlistentry>
2909   <varlistentry>
2910     <term>
2911       <emphasis remap='I'>w</emphasis>
2912     </term>
2913     <listitem>
2914       <para>
2915 Specifies the window.
2916       </para>
2917     </listitem>
2918   </varlistentry>
2919   <varlistentry>
2920     <term>
2921       <emphasis remap='I'>class_hints</emphasis>
2922     </term>
2923     <listitem>
2924       <para>
2925 Specifies the
2926 <structname>XClassHint</structname>
2927 structure that is to be used.
2928     </para>
2929   </listitem>
2930   </varlistentry>
2931 </variablelist>
2932 <para>
2933 <!-- .LP -->
2934 <!-- .eM -->
2935 The
2936 <xref linkend='XSetClassHint' xrefstyle='select: title'/>
2937 function sets the class hint for the specified window.
2938 If the strings are not in the Host Portable Character Encoding,
2939 the result is implementation-dependent.
2940 </para>
2941 <para>
2942 <!-- .LP -->
2943 <xref linkend='XSetClassHint' xrefstyle='select: title'/>
2944 can generate
2945 <errorname>BadAlloc</errorname>
2946 and
2947 <errorname>BadWindow</errorname>
2948 errors. 
2949 </para>
2950 <para>
2951 <!-- .LP -->
2952 <!-- .sp -->
2953 To read a window's <property>WM_CLASS</property> property, use
2954 <xref linkend='XGetClassHint' xrefstyle='select: title'/>.
2955 </para>
2956 <indexterm significance="preferred"><primary>XGetClassHint</primary></indexterm>
2957 <!-- .sM -->
2958 <funcsynopsis id='XGetClassHint'>
2959 <funcprototype>
2960   <funcdef>Status <function>XGetClassHint</function></funcdef>
2961   <paramdef>Display<parameter> *display</parameter></paramdef>
2962   <paramdef>Window<parameter> w</parameter></paramdef>
2963   <paramdef>XClassHint<parameter> *class_hints_return</parameter></paramdef>
2964 </funcprototype>
2965 </funcsynopsis>
2966 <!-- .FN -->
2967 <variablelist>
2968   <varlistentry>
2969     <term>
2970       <emphasis remap='I'>display</emphasis>
2971     </term>
2972     <listitem>
2973       <para>
2974 Specifies the connection to the X server.
2975       </para>
2976     </listitem>
2977   </varlistentry>
2978   <varlistentry>
2979     <term>
2980       <emphasis remap='I'>w</emphasis>
2981     </term>
2982     <listitem>
2983       <para>
2984 Specifies the window.
2985       </para>
2986     </listitem>
2987   </varlistentry>
2988   <varlistentry>
2989     <term>
2990       <emphasis remap='I'>class_hints_return</emphasis>
2991     </term>
2992     <listitem>
2993       <para>
2994 Returns the 
2995 <structname>XClassHint</structname>
2996 structure.
2997     </para>
2998   </listitem>
2999   </varlistentry>
3000 </variablelist>
3001 <para>
3002 <!-- .LP -->
3003 <!-- .eM -->
3004 The
3005 <xref linkend='XGetClassHint' xrefstyle='select: title'/>
3006 function returns the class hint of the specified window to the members
3007 of the supplied structure.
3008 If the data returned by the server is in the Latin Portable Character Encoding,
3009 then the returned strings are in the Host Portable Character Encoding.
3010 Otherwise, the result is implementation-dependent.
3011 It returns a nonzero status on success;
3012 otherwise, it returns a zero status.
3013 To free res_name and res_class when finished with the strings,
3014 use
3015 <xref linkend='XFree' xrefstyle='select: title'/>
3016 on each individually.
3017 </para>
3018 <para>
3019 <!-- .LP -->
3020 <xref linkend='XGetClassHint' xrefstyle='select: title'/>
3021 can generate a
3022 <errorname>BadWindow</errorname>
3023 error.
3024 </para>
3025 </sect2>
3026 <sect2 id="Setting_and_Reading_the_WM_TRANSIENT_FOR_Property">
3027 <title>Setting and Reading the WM_TRANSIENT_FOR Property</title>
3028 <!-- .XS -->
3029 <!-- (SN Setting and Reading the WM_TRANSIENT_FOR Property -->
3030 <!-- .XE -->
3031 <para>
3032 <!-- .LP -->
3033 Xlib provides functions that you can use to set and read
3034 the <property>WM_TRANSIENT_FOR</property> property for a given window.
3035 </para>
3036 <para>
3037 <!-- .LP -->
3038 <!-- .sp -->
3039 To set a window's <property>WM_TRANSIENT_FOR</property> property, use
3040 <xref linkend='XSetTransientForHint' xrefstyle='select: title'/>.
3041 </para>
3042 <indexterm significance="preferred"><primary>XSetTransientForHint</primary></indexterm>
3043 <!-- .sM -->
3044 <funcsynopsis id='XSetTransientForHint'>
3045 <funcprototype>
3046   <funcdef><function>XSetTransientForHint</function></funcdef>
3047   <paramdef>Display<parameter> *display</parameter></paramdef>
3048   <paramdef>Window<parameter> w</parameter></paramdef>
3049   <paramdef>Window<parameter> prop_window</parameter></paramdef>
3050 </funcprototype>
3051 </funcsynopsis>
3052 <!-- .FN -->
3053 <variablelist>
3054   <varlistentry>
3055     <term>
3056       <emphasis remap='I'>display</emphasis>
3057     </term>
3058     <listitem>
3059       <para>
3060 Specifies the connection to the X server.
3061       </para>
3062     </listitem>
3063   </varlistentry>
3064   <varlistentry>
3065     <term>
3066       <emphasis remap='I'>w</emphasis>
3067     </term>
3068     <listitem>
3069       <para>
3070 Specifies the window.
3071       </para>
3072     </listitem>
3073   </varlistentry>
3074   <varlistentry>
3075     <term>
3076       <emphasis remap='I'>prop_window</emphasis>
3077     </term>
3078     <listitem>
3079       <para>
3080 Specifies the window that the <property>WM_TRANSIENT_FOR</property> property is to be set to.
3081     </para>
3082   </listitem>
3083   </varlistentry>
3084 </variablelist>
3085 <para>
3086 <!-- .LP -->
3087 <!-- .eM -->
3088 The
3089 <xref linkend='XSetTransientForHint' xrefstyle='select: title'/>
3090 function sets the <property>WM_TRANSIENT_FOR</property> property of the specified window to the 
3091 specified prop_window.
3092 </para>
3093 <para>
3094 <!-- .LP -->
3095 <xref linkend='XSetTransientForHint' xrefstyle='select: title'/>
3096 can generate
3097 <errorname>BadAlloc</errorname>
3098 and
3099 <errorname>BadWindow</errorname>
3100 errors.
3101 </para>
3102 <para>
3103 <!-- .LP -->
3104 <!-- .sp -->
3105 To read a window's <property>WM_TRANSIENT_FOR</property> property, use
3106 <xref linkend='XGetTransientForHint' xrefstyle='select: title'/>.
3107 </para>
3108 <indexterm significance="preferred"><primary>XGetTransientForHint</primary></indexterm>
3109 <!-- .sM -->
3110 <funcsynopsis id='XGetTransientForHint'>
3111 <funcprototype>
3112   <funcdef>Status <function>XGetTransientForHint</function></funcdef>
3113   <paramdef>Display<parameter> *display</parameter></paramdef>
3114   <paramdef>Window<parameter> w</parameter></paramdef>
3115   <paramdef>Window<parameter> *prop_window_return</parameter></paramdef>
3116 </funcprototype>
3117 </funcsynopsis>
3118 <!-- .FN -->
3119 <variablelist>
3120   <varlistentry>
3121     <term>
3122       <emphasis remap='I'>display</emphasis>
3123     </term>
3124     <listitem>
3125       <para>
3126 Specifies the connection to the X server.
3127       </para>
3128     </listitem>
3129   </varlistentry>
3130   <varlistentry>
3131     <term>
3132       <emphasis remap='I'>w</emphasis>
3133     </term>
3134     <listitem>
3135       <para>
3136 Specifies the window.
3137       </para>
3138     </listitem>
3139   </varlistentry>
3140   <varlistentry>
3141     <term>
3142       <emphasis remap='I'>prop_window_return</emphasis>
3143     </term>
3144     <listitem>
3145       <para>
3146 Returns the <property>WM_TRANSIENT_FOR</property> property of the specified window.
3147     </para>
3148   </listitem>
3149   </varlistentry>
3150 </variablelist>
3151 <para>
3152 <!-- .LP -->
3153 <!-- .eM -->
3154 The
3155 <xref linkend='XGetTransientForHint' xrefstyle='select: title'/>
3156 function returns the <property>WM_TRANSIENT_FOR</property> property for the specified window.
3157 It returns a nonzero status on success;
3158 otherwise, it returns a zero status.
3159 </para>
3160 <para>
3161 <!-- .LP -->
3162 <xref linkend='XGetTransientForHint' xrefstyle='select: title'/>
3163 can generate a
3164 <errorname>BadWindow</errorname>
3165 error.
3166 </para>
3167 </sect2>
3168 <sect2 id="Setting_and_Reading_the_WM_PROTOCOLS_Property">
3169 <title>Setting and Reading the WM_PROTOCOLS Property</title>
3170 <!-- .XS -->
3171 <!-- (SN Setting and Reading the WM_PROTOCOLS Property -->
3172 <!-- .XE -->
3173 <para>
3174 <!-- .LP -->
3175 Xlib provides functions that you can use to set and read
3176 the <property>WM_PROTOCOLS</property> property for a given window.
3177 </para>
3178 <para>
3179 <!-- .LP -->
3180 <!-- .sp -->
3181 To set a window's <property>WM_PROTOCOLS</property> property, use
3182 <xref linkend='XSetWMProtocols' xrefstyle='select: title'/>.
3183 </para>
3184 <indexterm significance="preferred"><primary>XSetWMProtocols</primary></indexterm>
3185 <!-- .sM -->
3186 <funcsynopsis id='XSetWMProtocols'>
3187 <funcprototype>
3188   <funcdef>Status <function>XSetWMProtocols</function></funcdef>
3189   <paramdef>Display<parameter> *display</parameter></paramdef>
3190   <paramdef>Window<parameter> w</parameter></paramdef>
3191   <paramdef>Atom<parameter> *protocols</parameter></paramdef>
3192   <paramdef>int<parameter> count</parameter></paramdef>
3193 </funcprototype>
3194 </funcsynopsis>
3195 <!-- .FN -->
3196 <variablelist>
3197   <varlistentry>
3198     <term>
3199       <emphasis remap='I'>display</emphasis>
3200     </term>
3201     <listitem>
3202       <para>
3203 Specifies the connection to the X server.
3204       </para>
3205     </listitem>
3206   </varlistentry>
3207   <varlistentry>
3208     <term>
3209       <emphasis remap='I'>w</emphasis>
3210     </term>
3211     <listitem>
3212       <para>
3213 Specifies the window.
3214       </para>
3215     </listitem>
3216   </varlistentry>
3217   <varlistentry>
3218     <term>
3219       <emphasis remap='I'>protocols</emphasis>
3220     </term>
3221     <listitem>
3222       <para>
3223 Specifies the list of protocols.
3224 <!-- .ds Cn protocols in the list -->
3225       </para>
3226     </listitem>
3227   </varlistentry>
3228   <varlistentry>
3229     <term>
3230       <emphasis remap='I'>count</emphasis>
3231     </term>
3232     <listitem>
3233       <para>
3234 Specifies the number of (Cn.
3235     </para>
3236   </listitem>
3237   </varlistentry>
3238 </variablelist>
3239 <para>
3240 <!-- .LP -->
3241 <!-- .eM -->
3242 The 
3243 <xref linkend='XSetWMProtocols' xrefstyle='select: title'/>
3244 function replaces the <property>WM_PROTOCOLS</property> property on the specified window 
3245 with the list of atoms specified by the protocols argument.
3246 If the property does not already exist,
3247 <xref linkend='XSetWMProtocols' xrefstyle='select: title'/>
3248 sets the <property>WM_PROTOCOLS</property> property on the specified window
3249 to the list of atoms specified by the protocols argument.
3250 The property is stored with a type of ATOM and a format of 32.
3251 If it cannot intern the <property>WM_PROTOCOLS</property> atom, 
3252 <xref linkend='XSetWMProtocols' xrefstyle='select: title'/>
3253 returns a zero status.
3254 Otherwise, it returns a nonzero status.
3255 </para>
3256 <para>
3257 <!-- .LP -->
3258 <xref linkend='XSetWMProtocols' xrefstyle='select: title'/>
3259 can generate
3260 <errorname>BadAlloc</errorname>
3261 and
3262 <errorname>BadWindow</errorname>
3263 errors.
3264 <!-- .sp -->
3265 </para>
3266 <para>
3267 <!-- .LP -->
3268 To read a window's <property>WM_PROTOCOLS</property> property, use
3269 <xref linkend='XGetWMProtocols' xrefstyle='select: title'/>.
3270 </para>
3271 <indexterm significance="preferred"><primary>XGetWMProtocols</primary></indexterm>
3272 <!-- .sM -->
3273 <funcsynopsis id='XGetWMProtocols'>
3274 <funcprototype>
3275   <funcdef>Status <function>XGetWMProtocols</function></funcdef>
3276   <paramdef>Display<parameter> *display</parameter></paramdef>
3277   <paramdef>Window<parameter> w</parameter></paramdef>
3278   <paramdef>Atom<parameter> **protocols_return</parameter></paramdef>
3279   <paramdef>int<parameter> *count_return</parameter></paramdef>
3280 </funcprototype>
3281 </funcsynopsis>
3282 <!-- .FN -->
3283 <variablelist>
3284   <varlistentry>
3285     <term>
3286       <emphasis remap='I'>display</emphasis>
3287     </term>
3288     <listitem>
3289       <para>
3290 Specifies the connection to the X server.
3291       </para>
3292     </listitem>
3293   </varlistentry>
3294   <varlistentry>
3295     <term>
3296       <emphasis remap='I'>w</emphasis>
3297     </term>
3298     <listitem>
3299       <para>
3300 Specifies the window.
3301       </para>
3302     </listitem>
3303   </varlistentry>
3304   <varlistentry>
3305     <term>
3306       <emphasis remap='I'>protocols_return</emphasis>
3307     </term>
3308     <listitem>
3309       <para>
3310 Returns the list of protocols.
3311 <!-- .ds Cn protocols in the list -->
3312       </para>
3313     </listitem>
3314   </varlistentry>
3315   <varlistentry>
3316     <term>
3317       <emphasis remap='I'>count_return</emphasis>
3318     </term>
3319     <listitem>
3320       <para>
3321 Returns the number of (Cn.
3322     </para>
3323   </listitem>
3324   </varlistentry>
3325 </variablelist>
3326 <para>
3327 <!-- .LP -->
3328 <!-- .eM -->
3329 The 
3330 <xref linkend='XGetWMProtocols' xrefstyle='select: title'/>
3331 function returns the list of atoms stored in the <property>WM_PROTOCOLS</property> property 
3332 on the specified window.
3333 These atoms describe window manager protocols in which the owner 
3334 of this window is willing to participate.
3335 If the property exists, is of type ATOM, is of format 32, 
3336 and the atom <property>WM_PROTOCOLS</property> can be interned, 
3337 <xref linkend='XGetWMProtocols' xrefstyle='select: title'/>
3338 sets the protocols_return argument to a list of atoms, 
3339 sets the count_return argument to the number of elements in the list, 
3340 and returns a nonzero status.
3341 Otherwise, it sets neither of the return arguments
3342 and returns a zero status.
3343 To release the list of atoms, use
3344 <xref linkend='XFree' xrefstyle='select: title'/>.
3345 </para>
3346 <para>
3347 <!-- .LP -->
3348 <xref linkend='XGetWMProtocols' xrefstyle='select: title'/>
3349 can generate a
3350 <errorname>BadWindow</errorname>
3351 error.
3352 </para>
3353 </sect2>
3354 <sect2 id="Setting_and_Reading_the_WM_COLORMAP_WINDOWS_Property">
3355 <title>Setting and Reading the WM_COLORMAP_WINDOWS Property</title>
3356 <!-- .XS -->
3357 <!-- (SN Setting and Reading the WM_COLORMAP_WINDOWS Property -->
3358 <!-- .XE -->
3359 <para>
3360 <!-- .LP -->
3361 Xlib provides functions that you can use to set and read
3362 the <property>WM_COLORMAP_WINDOWS</property> property for a given window.
3363 <!-- .sp -->
3364 </para>
3365 <para>
3366 <!-- .LP -->
3367 To set a window's <property>WM_COLORMAP_WINDOWS</property> property, use
3368 <xref linkend='XSetWMColormapWindows' xrefstyle='select: title'/>.
3369 </para>
3370 <indexterm significance="preferred"><primary>XSetWMColormapWindows</primary></indexterm>
3371 <!-- .sM -->
3372 <funcsynopsis id='XSetWMColormapWindows'>
3373 <funcprototype>
3374   <funcdef>Status <function>XSetWMColormapWindows</function></funcdef>
3375   <paramdef>Display<parameter> *display</parameter></paramdef>
3376   <paramdef>Window<parameter> w</parameter></paramdef>
3377   <paramdef>Window<parameter> *colormap_windows</parameter></paramdef>
3378   <paramdef>int<parameter> count</parameter></paramdef>
3379 </funcprototype>
3380 </funcsynopsis>
3381 <!-- .FN -->
3382 <variablelist>
3383   <varlistentry>
3384     <term>
3385       <emphasis remap='I'>display</emphasis>
3386     </term>
3387     <listitem>
3388       <para>
3389 Specifies the connection to the X server.
3390       </para>
3391     </listitem>
3392   </varlistentry>
3393   <varlistentry>
3394     <term>
3395       <emphasis remap='I'>w</emphasis>
3396     </term>
3397     <listitem>
3398       <para>
3399 Specifies the window.
3400       </para>
3401     </listitem>
3402   </varlistentry>
3403   <varlistentry>
3404     <term>
3405       <emphasis remap='I'>colormap_windows</emphasis>
3406     </term>
3407     <listitem>
3408       <para>
3409 Specifies the list of windows.
3410 <!-- .ds Cn windows in the list -->
3411       </para>
3412     </listitem>
3413   </varlistentry>
3414   <varlistentry>
3415     <term>
3416       <emphasis remap='I'>count</emphasis>
3417     </term>
3418     <listitem>
3419       <para>
3420 Specifies the number of (Cn.
3421     </para>
3422   </listitem>
3423   </varlistentry>
3424 </variablelist>
3425 <para>
3426 <!-- .LP -->
3427 <!-- .eM -->
3428 The 
3429 <xref linkend='XSetWMColormapWindows' xrefstyle='select: title'/>
3430 function replaces the <property>WM_COLORMAP_WINDOWS</property> property on the specified
3431 window with the list of windows specified by the colormap_windows argument.
3432 If the property does not already exist,
3433 <xref linkend='XSetWMColormapWindows' xrefstyle='select: title'/>
3434 sets the <property>WM_COLORMAP_WINDOWS</property> property on the specified
3435 window to the list of windows specified by the colormap_windows argument.
3436 The property is stored with a type of WINDOW and a format of 32.
3437 If it cannot intern the <property>WM_COLORMAP_WINDOWS</property> atom,
3438 <xref linkend='XSetWMColormapWindows' xrefstyle='select: title'/>
3439 returns a zero status.
3440 Otherwise, it returns a nonzero status.
3441 </para>
3442 <para>
3443 <!-- .LP -->
3444 <xref linkend='XSetWMColormapWindows' xrefstyle='select: title'/>
3445 can generate
3446 <errorname>BadAlloc</errorname>
3447 and
3448 <errorname>BadWindow</errorname>
3449 errors.
3450 <!-- .sp -->
3451 </para>
3452 <para>
3453 <!-- .LP -->
3454 To read a window's <property>WM_COLORMAP_WINDOWS</property> property, use
3455 <xref linkend='XGetWMColormapWindows' xrefstyle='select: title'/>.
3456 </para>
3457 <indexterm significance="preferred"><primary>XGetWMColormapWindows</primary></indexterm>
3458 <!-- .sM -->
3459 <funcsynopsis id='XGetWMColormapWindows'>
3460 <funcprototype>
3461   <funcdef>Status <function>XGetWMColormapWindows</function></funcdef>
3462   <paramdef>Display<parameter> *display</parameter></paramdef>
3463   <paramdef>Window<parameter> w</parameter></paramdef>
3464   <paramdef>Window<parameter> **colormap_windows_return</parameter></paramdef>
3465   <paramdef>int<parameter> *count_return</parameter></paramdef>
3466 </funcprototype>
3467 </funcsynopsis>
3468 <!-- .FN -->
3469 <variablelist>
3470   <varlistentry>
3471     <term>
3472       <emphasis remap='I'>display</emphasis>
3473     </term>
3474     <listitem>
3475       <para>
3476 Specifies the connection to the X server.
3477       </para>
3478     </listitem>
3479   </varlistentry>
3480   <varlistentry>
3481     <term>
3482       <emphasis remap='I'>w</emphasis>
3483     </term>
3484     <listitem>
3485       <para>
3486 Specifies the window.
3487       </para>
3488     </listitem>
3489   </varlistentry>
3490   <varlistentry>
3491     <term>
3492       <emphasis remap='I'>colormap_windows_return</emphasis>
3493     </term>
3494     <listitem>
3495       <para>
3496 Returns the list of windows.
3497 <!-- .ds Cn windows in the list -->
3498       </para>
3499     </listitem>
3500   </varlistentry>
3501   <varlistentry>
3502     <term>
3503       <emphasis remap='I'>count_return</emphasis>
3504     </term>
3505     <listitem>
3506       <para>
3507 Returns the number of (Cn.
3508     </para>
3509   </listitem>
3510   </varlistentry>
3511 </variablelist>
3512 <para>
3513 <!-- .LP -->
3514 <!-- .eM -->
3515 The 
3516 <xref linkend='XGetWMColormapWindows' xrefstyle='select: title'/>
3517 function returns the list of window identifiers stored 
3518 in the <property>WM_COLORMAP_WINDOWS</property> property on the specified window.
3519 These identifiers indicate the colormaps that the window manager
3520 may need to install for this window.
3521 If the property exists, is of type WINDOW, is of format 32, 
3522 and the atom <property>WM_COLORMAP_WINDOWS</property> can be interned, 
3523 <xref linkend='XGetWMColormapWindows' xrefstyle='select: title'/>
3524 sets the windows_return argument to a list of window identifiers, 
3525 sets the count_return argument to the number of elements in the list, 
3526 and returns a nonzero status.
3527 Otherwise, it sets neither of the return arguments
3528 and returns a zero status.
3529 To release the list of window identifiers, use
3530 <xref linkend='XFree' xrefstyle='select: title'/>.
3531 </para>
3532 <para>
3533 <!-- .LP -->
3534 <xref linkend='XGetWMColormapWindows' xrefstyle='select: title'/>
3535 can generate a
3536 <errorname>BadWindow</errorname>
3537 error.
3538 </para>
3539 </sect2>
3540 <sect2 id="Setting_and_Reading_the_WM_ICON_SIZE_Property">
3541 <title>Setting and Reading the WM_ICON_SIZE Property</title>
3542 <!-- .XS -->
3543 <!-- (SN Setting and Reading the WM_ICON_SIZE Property -->
3544 <!-- .XE -->
3545 <para>
3546 <!-- .LP -->
3547 Xlib provides functions that you can use to set and read 
3548 the <property>WM_ICON_SIZE</property> property for a given window.
3549 These functions use the 
3550 <structname>XIconSize</structname>
3551 <indexterm><primary>XIconSize</primary></indexterm>
3552 structure, which is defined in the
3553 <filename class="headerfile">&lt;X11/Xutil.h&gt;</filename>
3554 <indexterm type="file"><primary><filename class="headerfile">X11/Xutil.h</filename></primary></indexterm>
3555 <indexterm><primary>Files</primary><secondary><filename class="headerfile">&lt;X11/Xutil.h&gt;</filename></secondary></indexterm>
3556 <indexterm><primary>Headers</primary><secondary><filename class="headerfile">&lt;X11/Xutil.h&gt;</filename></secondary></indexterm>
3557 header file.
3558 <!-- .sp -->
3559 </para>
3560 <para>
3561 <!-- .LP -->
3562 To allocate an
3563 <structname>XIconSize</structname>
3564 structure, use
3565 <function>XAllocIconSize</function>.
3566 </para>
3567
3568 <para>
3569   XIconSize *XAllocIconSize()
3570 </para>
3571
3572 <para>
3573 <!-- .LP -->
3574 <!-- .eM -->
3575 The
3576 <function>XAllocIconSize</function>
3577 function allocates and returns a pointer to an
3578 <structname>XIconSize</structname>
3579 structure.
3580 Note that all fields in the
3581 <structname>XIconSize</structname>
3582 structure are initially set to zero.
3583 If insufficient memory is available, 
3584 <function>XAllocIconSize</function>
3585 returns NULL.
3586 To free the memory allocated to this structure,
3587 use
3588 <xref linkend='XFree' xrefstyle='select: title'/>.
3589 </para>
3590 <para>
3591 <!-- .LP -->
3592 The
3593 <structname>XIconSize</structname>
3594 structure contains:
3595 </para>
3596 <para>
3597 <!-- .LP -->
3598 <!-- .sM -->
3599 <indexterm significance="preferred"><primary>XIconSize</primary></indexterm>
3600 <literallayout class="monospaced">
3601 <!-- .TA .5i 2.5i -->
3602 <!-- .ta .5i 2.5i -->
3603 typedef struct {
3604         int min_width, min_height;
3605         int max_width, max_height;
3606         int width_inc, height_inc;
3607 } XIconSize;
3608 </literallayout>
3609 </para>
3610 <para>
3611 <!-- .LP -->
3612 <!-- .eM -->
3613 The width_inc and height_inc members define an arithmetic progression of
3614 sizes (minimum to maximum) that represent the supported icon sizes.
3615 </para>
3616 <para>
3617 <!-- .LP -->
3618 <!-- .sp -->
3619 To set a window's <property>WM_ICON_SIZE</property> property, use
3620 <xref linkend='XSetIconSizes' xrefstyle='select: title'/>.
3621 </para>
3622 <indexterm significance="preferred"><primary>XSetIconSizes</primary></indexterm>
3623 <!-- .sM -->
3624 <funcsynopsis id='XSetIconSizes'>
3625 <funcprototype>
3626   <funcdef><function>XSetIconSizes</function></funcdef>
3627   <paramdef>Display<parameter> *display</parameter></paramdef>
3628   <paramdef>Window<parameter> w</parameter></paramdef>
3629   <paramdef>XIconSize<parameter> *size_list</parameter></paramdef>
3630   <paramdef>int<parameter> count</parameter></paramdef>
3631 </funcprototype>
3632 </funcsynopsis>
3633 <!-- .FN -->
3634 <variablelist>
3635   <varlistentry>
3636     <term>
3637       <emphasis remap='I'>display</emphasis>
3638     </term>
3639     <listitem>
3640       <para>
3641 Specifies the connection to the X server.
3642       </para>
3643     </listitem>
3644   </varlistentry>
3645   <varlistentry>
3646     <term>
3647       <emphasis remap='I'>w</emphasis>
3648     </term>
3649     <listitem>
3650       <para>
3651 Specifies the window.
3652       </para>
3653     </listitem>
3654   </varlistentry>
3655   <varlistentry>
3656     <term>
3657       <emphasis remap='I'>size_list</emphasis>
3658     </term>
3659     <listitem>
3660       <para>
3661 Specifies the size list.
3662       </para>
3663     </listitem>
3664   </varlistentry>
3665   <varlistentry>
3666     <term>
3667       <emphasis remap='I'>count</emphasis>
3668     </term>
3669     <listitem>
3670       <para>
3671 Specifies the number of items in the size list.
3672     </para>
3673   </listitem>
3674   </varlistentry>
3675 </variablelist>
3676 <para>
3677 <!-- .LP -->
3678 <!-- .eM -->
3679 The
3680 <xref linkend='XSetIconSizes' xrefstyle='select: title'/>
3681 function is used only by window managers to set the supported icon sizes.
3682 </para>
3683 <para>
3684 <!-- .LP -->
3685 <xref linkend='XSetIconSizes' xrefstyle='select: title'/>
3686 can generate
3687 <errorname>BadAlloc</errorname>
3688 and
3689 <errorname>BadWindow</errorname>
3690 errors.
3691 </para>
3692 <para>
3693 <!-- .LP -->
3694 <!-- .sp -->
3695 To read a window's <property>WM_ICON_SIZE</property> property, use
3696 <xref linkend='XGetIconSizes' xrefstyle='select: title'/>.
3697 </para>
3698 <indexterm significance="preferred"><primary>XGetIconSizes</primary></indexterm>
3699 <!-- .sM -->
3700 <funcsynopsis id='XGetIconSizes'>
3701 <funcprototype>
3702   <funcdef>Status <function>XGetIconSizes</function></funcdef>
3703   <paramdef>Display<parameter> *display</parameter></paramdef>
3704   <paramdef>Window<parameter> w</parameter></paramdef>
3705   <paramdef>XIconSize<parameter> **size_list_return</parameter></paramdef>
3706   <paramdef>int<parameter> *count_return</parameter></paramdef>
3707 </funcprototype>
3708 </funcsynopsis>
3709 <!-- .FN -->
3710 <variablelist>
3711   <varlistentry>
3712     <term>
3713       <emphasis remap='I'>display</emphasis>
3714     </term>
3715     <listitem>
3716       <para>
3717 Specifies the connection to the X server.
3718       </para>
3719     </listitem>
3720   </varlistentry>
3721   <varlistentry>
3722     <term>
3723       <emphasis remap='I'>w</emphasis>
3724     </term>
3725     <listitem>
3726       <para>
3727 Specifies the window.
3728       </para>
3729     </listitem>
3730   </varlistentry>
3731   <varlistentry>
3732     <term>
3733       <emphasis remap='I'>size_list_return</emphasis>
3734     </term>
3735     <listitem>
3736       <para>
3737 Returns the size list.
3738       </para>
3739     </listitem>
3740   </varlistentry>
3741   <varlistentry>
3742     <term>
3743       <emphasis remap='I'>count_return</emphasis>
3744     </term>
3745     <listitem>
3746       <para>
3747 Returns the number of items in the size list.
3748     </para>
3749   </listitem>
3750   </varlistentry>
3751 </variablelist>
3752 <para>
3753 <!-- .LP -->
3754 <!-- .eM -->
3755 The
3756 <xref linkend='XGetIconSizes' xrefstyle='select: title'/>
3757 function returns zero if a window manager has not set icon sizes;
3758 otherwise, it returns nonzero.
3759 <xref linkend='XGetIconSizes' xrefstyle='select: title'/>
3760 should be called by an application that
3761 wants to find out what icon sizes would be most appreciated by the
3762 window manager under which the application is running.
3763 The application
3764 should then use
3765 <xref linkend='XSetWMHints' xrefstyle='select: title'/>
3766 to supply the window manager with an icon pixmap or window in one of the
3767 supported sizes.
3768 To free the data allocated in size_list_return, use
3769 <xref linkend='XFree' xrefstyle='select: title'/>.
3770 </para>
3771 <para>
3772 <!-- .LP -->
3773 <xref linkend='XGetIconSizes' xrefstyle='select: title'/>
3774 can generate a
3775 <errorname>BadWindow</errorname>
3776 error.
3777 </para>
3778 </sect2>
3779 <sect2 id="Using_Window_Manager_Convenience_Functions">
3780 <title>Using Window Manager Convenience Functions</title>
3781 <!-- .XS -->
3782 <!-- (SN Using Window Manager Convenience Functions -->
3783 <!-- .XE -->
3784 <para>
3785 <!-- .LP -->
3786 The 
3787 <xref linkend='XmbSetWMProperties' xrefstyle='select: title'/>
3788 function stores the standard set of window manager properties,
3789 with text properties in standard encodings
3790 for internationalized text communication.
3791 The standard window manager properties for a given window are
3792 <property>WM_NAME</property>, <property>WM_ICON_NAME</property>, <property>WM_HINTS</property>, <property>WM_NORMAL_HINTS</property>, <property>WM_CLASS</property>,
3793 <property>WM_COMMAND</property>, <property>WM_CLIENT_MACHINE</property>, and <property>WM_LOCALE_NAME</property>.
3794 </para>
3795 <indexterm significance="preferred"><primary>XmbSetWMProperties</primary></indexterm>
3796 <!-- .sM -->
3797 <funcsynopsis id='XmbSetWMProperties'>
3798 <funcprototype>
3799   <funcdef>void <function>XmbSetWMProperties</function></funcdef>
3800   <paramdef>Display<parameter> *display</parameter></paramdef>
3801   <paramdef>Window<parameter> w</parameter></paramdef>
3802   <paramdef>char<parameter> *window_name</parameter></paramdef>
3803   <paramdef>char<parameter> *icon_name</parameter></paramdef>
3804   <paramdef>char<parameter> *argv[]</parameter></paramdef>
3805   <paramdef>int<parameter> argc</parameter></paramdef>
3806   <paramdef>XSizeHints<parameter> *normal_hints</parameter></paramdef>
3807   <paramdef>XWMHints<parameter> *wm_hints</parameter></paramdef>
3808   <paramdef>XClassHint<parameter> *class_hints</parameter></paramdef>
3809 </funcprototype>
3810 </funcsynopsis>
3811 <!-- .FN -->
3812 <variablelist>
3813   <varlistentry>
3814     <term>
3815       <emphasis remap='I'>display</emphasis>
3816     </term>
3817     <listitem>
3818       <para>
3819 Specifies the connection to the X server.
3820       </para>
3821     </listitem>
3822   </varlistentry>
3823   <varlistentry>
3824     <term>
3825       <emphasis remap='I'>w</emphasis>
3826     </term>
3827     <listitem>
3828       <para>
3829 Specifies the window.
3830       </para>
3831     </listitem>
3832   </varlistentry>
3833   <varlistentry>
3834     <term>
3835       <emphasis remap='I'>window_name</emphasis>
3836     </term>
3837     <listitem>
3838       <para>
3839 Specifies the window name,
3840 which should be a null-terminated string.
3841       </para>
3842     </listitem>
3843   </varlistentry>
3844   <varlistentry>
3845     <term>
3846       <emphasis remap='I'>icon_name</emphasis>
3847     </term>
3848     <listitem>
3849       <para>
3850 Specifies the icon name,
3851 which should be a null-terminated string.
3852       </para>
3853     </listitem>
3854   </varlistentry>
3855   <varlistentry>
3856     <term>
3857       <emphasis remap='I'>argv</emphasis>
3858     </term>
3859     <listitem>
3860       <para>
3861 Specifies the application's argument list.
3862       </para>
3863     </listitem>
3864   </varlistentry>
3865   <varlistentry>
3866     <term>
3867       <emphasis remap='I'>argc</emphasis>
3868     </term>
3869     <listitem>
3870       <para>
3871 Specifies the number of arguments.
3872       </para>
3873     </listitem>
3874   </varlistentry>
3875   <varlistentry>
3876     <term>
3877       <emphasis remap='I'>hints</emphasis>
3878     </term>
3879     <listitem>
3880       <para>
3881 Specifies the size hints for the window in its normal state.
3882       </para>
3883     </listitem>
3884   </varlistentry>
3885   <varlistentry>
3886     <term>
3887       <emphasis remap='I'>wm_hints</emphasis>
3888     </term>
3889     <listitem>
3890       <para>
3891 Specifies the
3892 <structname>XWMHints</structname>
3893 structure to be used.
3894       </para>
3895     </listitem>
3896   </varlistentry>
3897   <varlistentry>
3898     <term>
3899       <emphasis remap='I'>class_hints</emphasis>
3900     </term>
3901     <listitem>
3902       <para>
3903 Specifies the
3904 <structname>XClassHint</structname>
3905 structure to be used.
3906     </para>
3907   </listitem>
3908   </varlistentry>
3909 </variablelist>
3910 <para>
3911 <!-- .LP -->
3912 <!-- .eM -->
3913 The
3914 <xref linkend='XmbSetWMProperties' xrefstyle='select: title'/>
3915 convenience function provides a simple programming interface 
3916 for setting those essential window properties that are used 
3917 for communicating with other clients
3918 (particularly window and session managers).
3919 </para>
3920 <para>
3921 <!-- .LP -->
3922 If the window_name argument is non-NULL,
3923 <xref linkend='XmbSetWMProperties' xrefstyle='select: title'/>
3924 sets the <property>WM_NAME</property> property.
3925 If the icon_name argument is non-NULL,
3926 <xref linkend='XmbSetWMProperties' xrefstyle='select: title'/>
3927 sets the <property>WM_ICON_NAME</property> property.
3928 The window_name and icon_name arguments are null-terminated strings
3929 in the encoding of the current locale.
3930 If the arguments can be fully converted to the STRING encoding,
3931 the properties are created with type ``STRING''; 
3932 otherwise, the arguments are converted to Compound Text, 
3933 and the properties are created with type ``COMPOUND_TEXT''.
3934 </para>
3935 <para>
3936 <!-- .LP -->
3937 If the normal_hints argument is non-NULL,
3938 <xref linkend='XmbSetWMProperties' xrefstyle='select: title'/>
3939 calls
3940 <xref linkend='XSetWMNormalHints' xrefstyle='select: title'/>,
3941 which sets the <property>WM_NORMAL_HINTS</property> property
3942 (see <link linkend="Setting_and_Reading_the_WM_NORMAL_HINTS_Property">section 14.1.7</link>).
3943 If the wm_hints argument is non-NULL, 
3944 <xref linkend='XmbSetWMProperties' xrefstyle='select: title'/>
3945 calls
3946 <xref linkend='XSetWMHints' xrefstyle='select: title'/>,
3947 which sets the <property>WM_HINTS</property> property
3948 (see <link linkend="Setting_and_Reading_the_WM_HINTS_Property">section 14.1.6</link>).
3949 </para>
3950 <para>
3951 <!-- .LP -->
3952 If the argv argument is non-NULL,
3953 <xref linkend='XmbSetWMProperties' xrefstyle='select: title'/>
3954 sets the <property>WM_COMMAND</property> property from argv and argc.
3955 An argc of zero indicates a zero-length command.
3956 </para>
3957 <para>
3958 <!-- .LP -->
3959 The hostname of the machine is stored using 
3960 <xref linkend='XSetWMClientMachine' xrefstyle='select: title'/>
3961 (see <link linkend="Setting_and_Reading_the_WM_CLIENT_MACHINE_Property">section 14.2.2</link>).
3962 </para>
3963 <para>
3964 <!-- .LP -->
3965 If the class_hints argument is non-NULL,
3966 <xref linkend='XmbSetWMProperties' xrefstyle='select: title'/>
3967 sets the <property>WM_CLASS</property> property.
3968 If the res_name member in the 
3969 <structname>XClassHint</structname>
3970 structure is set to the NULL pointer and the RESOURCE_NAME
3971 environment variable is set,
3972 the value of the environment variable is substituted for res_name.
3973 If the res_name member is NULL,
3974 the environment variable is not set, and argv and argv[0] are set,
3975 then the value of argv[0], stripped of any directory prefixes,
3976 is substituted for res_name.
3977 </para>
3978 <para>
3979 <!-- .LP -->
3980 It is assumed that the supplied class_hints.res_name and argv,
3981 the RESOURCE_NAME environment variable, and the hostname of the machine
3982 are in the encoding of the locale announced for the LC_CTYPE category
3983 (on <acronym>POSIX</acronym>-compliant systems, the LC_CTYPE, else LANG environment variable).
3984 The corresponding <property>WM_CLASS</property>, <property>WM_COMMAND</property>, and <property>WM_CLIENT_MACHINE</property> properties
3985 are typed according to the local host locale announcer.
3986 No encoding conversion is performed prior to storage in the properties.
3987 </para>
3988 <para>
3989 <!-- .LP -->
3990 For clients that need to process the property text in a locale,
3991 <xref linkend='XmbSetWMProperties' xrefstyle='select: title'/>
3992 sets the <property>WM_LOCALE_NAME</property> property to be the name of the current locale.
3993 The name is assumed to be in the Host Portable Character Encoding
3994 and is converted to STRING for storage in the property.
3995 </para>
3996 <para>
3997 <!-- .LP -->
3998 <xref linkend='XmbSetWMProperties' xrefstyle='select: title'/>
3999 can generate
4000 <errorname>BadAlloc</errorname>
4001 and
4002 <errorname>BadWindow</errorname>
4003 errors.
4004 <!-- .sp -->
4005 </para>
4006 <para>
4007 <!-- .LP -->
4008 To set a window's standard window manager properties
4009 with strings in client-specified encodings, use
4010 <xref linkend='XSetWMProperties' xrefstyle='select: title'/>.
4011 The standard window manager properties for a given window are
4012 <property>WM_NAME</property>, <property>WM_ICON_NAME</property>, <property>WM_HINTS</property>, <property>WM_NORMAL_HINTS</property>, <property>WM_CLASS</property>,
4013 <property>WM_COMMAND</property>, and <property>WM_CLIENT_MACHINE</property>.
4014 </para>
4015 <indexterm significance="preferred"><primary>XSetWMProperties</primary></indexterm>
4016 <!-- .sM -->
4017 <funcsynopsis id='XSetWMProperties'>
4018 <funcprototype>
4019   <funcdef>void <function>XSetWMProperties</function></funcdef>
4020   <paramdef>Display<parameter> *display</parameter></paramdef>
4021   <paramdef>Window<parameter> w</parameter></paramdef>
4022   <paramdef>XTextProperty<parameter> *window_name</parameter></paramdef>
4023   <paramdef>XTextProperty<parameter> *icon_name</parameter></paramdef>
4024   <paramdef>char<parameter> **argv</parameter></paramdef>
4025   <paramdef>int<parameter> argc</parameter></paramdef>
4026   <paramdef>XSizeHints<parameter> *normal_hints</parameter></paramdef>
4027   <paramdef>XWMHints<parameter> *wm_hints</parameter></paramdef>
4028   <paramdef>XClassHint<parameter> *class_hints</parameter></paramdef>
4029 </funcprototype>
4030 </funcsynopsis>
4031 <!-- .FN -->
4032 <variablelist>
4033   <varlistentry>
4034     <term>
4035       <emphasis remap='I'>display</emphasis>
4036     </term>
4037     <listitem>
4038       <para>
4039 Specifies the connection to the X server.
4040       </para>
4041     </listitem>
4042   </varlistentry>
4043   <varlistentry>
4044     <term>
4045       <emphasis remap='I'>w</emphasis>
4046     </term>
4047     <listitem>
4048       <para>
4049 Specifies the window.
4050       </para>
4051     </listitem>
4052   </varlistentry>
4053   <varlistentry>
4054     <term>
4055       <emphasis remap='I'>window_name</emphasis>
4056     </term>
4057     <listitem>
4058       <para>
4059 Specifies the window name,
4060 which should be a null-terminated string.
4061       </para>
4062     </listitem>
4063   </varlistentry>
4064   <varlistentry>
4065     <term>
4066       <emphasis remap='I'>icon_name</emphasis>
4067     </term>
4068     <listitem>
4069       <para>
4070 Specifies the icon name,
4071 which should be a null-terminated string.
4072       </para>
4073     </listitem>
4074   </varlistentry>
4075   <varlistentry>
4076     <term>
4077       <emphasis remap='I'>argv</emphasis>
4078     </term>
4079     <listitem>
4080       <para>
4081 Specifies the application's argument list.
4082       </para>
4083     </listitem>
4084   </varlistentry>
4085   <varlistentry>
4086     <term>
4087       <emphasis remap='I'>argc</emphasis>
4088     </term>
4089     <listitem>
4090       <para>
4091 Specifies the number of arguments.
4092       </para>
4093     </listitem>
4094   </varlistentry>
4095   <varlistentry>
4096     <term>
4097       <emphasis remap='I'>normal_hints</emphasis>
4098     </term>
4099     <listitem>
4100       <para>
4101 Specifies the size hints for the window in its normal state.
4102       </para>
4103     </listitem>
4104   </varlistentry>
4105   <varlistentry>
4106     <term>
4107       <emphasis remap='I'>wm_hints</emphasis>
4108     </term>
4109     <listitem>
4110       <para>
4111 Specifies the
4112 <structname>XWMHints</structname>
4113 structure to be used.
4114       </para>
4115     </listitem>
4116   </varlistentry>
4117   <varlistentry>
4118     <term>
4119       <emphasis remap='I'>class_hints</emphasis>
4120     </term>
4121     <listitem>
4122       <para>
4123 Specifies the
4124 <structname>XClassHint</structname>
4125 structure to be used.
4126     </para>
4127   </listitem>
4128   </varlistentry>
4129 </variablelist>
4130 <para>
4131 <!-- .LP -->
4132 <!-- .eM -->
4133 The 
4134 <xref linkend='XSetWMProperties' xrefstyle='select: title'/>
4135 convenience function provides a single programming interface 
4136 for setting those essential window properties that are used 
4137 for communicating with other clients (particularly window and session
4138 managers).
4139 </para>
4140 <para>
4141 <!-- .LP -->
4142 If the window_name argument is non-NULL, 
4143 <xref linkend='XSetWMProperties' xrefstyle='select: title'/>
4144 calls
4145 <xref linkend='XSetWMName' xrefstyle='select: title'/>,
4146 which, in turn, sets the <property>WM_NAME</property> property
4147 (see <link linkend="Setting_and_Reading_the_WM_NAME_Property">section 14.1.4</link>).
4148 If the icon_name argument is non-NULL,
4149 <xref linkend='XSetWMProperties' xrefstyle='select: title'/>
4150 calls
4151 <xref linkend='XSetWMIconName' xrefstyle='select: title'/>,
4152 which sets the <property>WM_ICON_NAME</property> property
4153 (see <link linkend="Setting_and_Reading_the_WM_ICON_NAME_Property">section 14.1.5</link>).
4154 If the argv argument is non-NULL, 
4155 <xref linkend='XSetWMProperties' xrefstyle='select: title'/>
4156 calls
4157 <xref linkend='XSetCommand' xrefstyle='select: title'/>,
4158 which sets the <property>WM_COMMAND</property> property
4159 (see <link linkend="Setting_and_Reading_the_WM_COMMAND_Property">section 14.2.1</link>).
4160 Note that an argc of zero is allowed to indicate a zero-length command.
4161 Note also that the hostname of this machine is stored using
4162 <xref linkend='XSetWMClientMachine' xrefstyle='select: title'/>
4163 (see <link linkend="Setting_and_Reading_the_WM_CLIENT_MACHINE_Property">section 14.2.2</link>).
4164 </para>
4165 <para>
4166 <!-- .LP -->
4167 If the normal_hints argument is non-NULL, 
4168 <xref linkend='XSetWMProperties' xrefstyle='select: title'/>
4169 calls
4170 <xref linkend='XSetWMNormalHints' xrefstyle='select: title'/>,
4171 which sets the <property>WM_NORMAL_HINTS</property> property
4172 (see <link linkend="Setting_and_Reading_the_WM_NORMAL_HINTS_Property">section 14.1.7</link>).
4173 If the wm_hints argument is non-NULL, 
4174 <xref linkend='XSetWMProperties' xrefstyle='select: title'/>
4175 calls
4176 <xref linkend='XSetWMHints' xrefstyle='select: title'/>,
4177 which sets the <property>WM_HINTS</property> property
4178 (see <link linkend="Setting_and_Reading_the_WM_HINTS_Property">section 14.1.6</link>).
4179 </para>
4180 <para>
4181 <!-- .LP -->
4182 If the class_hints argument is non-NULL, 
4183 <xref linkend='XSetWMProperties' xrefstyle='select: title'/>
4184 calls
4185 <xref linkend='XSetClassHint' xrefstyle='select: title'/>,
4186 which sets the <property>WM_CLASS</property> property
4187 (see <link linkend="Setting_and_Reading_the_WM_CLASS_Property">section 14.1.8</link>).
4188 If the res_name member in the
4189 <structname>XClassHint</structname>
4190 structure is set to the NULL pointer and the RESOURCE_NAME environment 
4191 variable is set, 
4192 then the value of the environment variable is substituted for res_name.
4193 If the res_name member is NULL, 
4194 the environment variable is not set, 
4195 and argv and argv[0] are set, 
4196 then the value of argv[0], stripped of
4197 any directory prefixes, is substituted for res_name.
4198 </para>
4199 <para>
4200 <!-- .LP -->
4201 <xref linkend='XSetWMProperties' xrefstyle='select: title'/>
4202 can generate
4203 <errorname>BadAlloc</errorname>
4204 and
4205 <errorname>BadWindow</errorname>
4206 errors.
4207 </para>
4208 </sect2>
4209 </sect1>
4210 <sect1 id="Client_to_Session_Manager_Communication">
4211 <title>Client to Session Manager Communication</title>
4212 <!-- .XS -->
4213 <!-- (SN Client to Session Manager Communication -->
4214 <!-- .XE -->
4215 <para>
4216 <!-- .LP -->
4217 This section discusses how to:
4218 </para>
4219 <itemizedlist>
4220   <listitem>
4221     <para>
4222 Set and read the <property>WM_COMMAND</property> property
4223     </para>
4224   </listitem>
4225   <listitem>
4226     <para>
4227 Set and read the <property>WM_CLIENT_MACHINE</property> property
4228     </para>
4229   </listitem>
4230 </itemizedlist>
4231 <sect2 id="Setting_and_Reading_the_WM_COMMAND_Property">
4232 <title>Setting and Reading the WM_COMMAND Property</title>
4233 <!-- .XS -->
4234 <!-- (SN Setting and Reading the WM_COMMAND Property -->
4235 <!-- .XE -->
4236 <para>
4237 <!-- .LP -->
4238 Xlib provides functions that you can use to set and read
4239 the <property>WM_COMMAND</property> property for a given window.
4240 <!-- .sp -->
4241 </para>
4242 <para>
4243 <!-- .LP -->
4244 To set a window's <property>WM_COMMAND</property> property, use
4245 <xref linkend='XSetCommand' xrefstyle='select: title'/>.
4246 </para>
4247 <indexterm significance="preferred"><primary>XSetCommand</primary></indexterm>
4248 <!-- .sM -->
4249 <funcsynopsis id='XSetCommand'>
4250 <funcprototype>
4251   <funcdef><function>XSetCommand</function></funcdef>
4252   <paramdef>Display<parameter> *display</parameter></paramdef>
4253   <paramdef>Window<parameter> w</parameter></paramdef>
4254   <paramdef>char<parameter> **argv</parameter></paramdef>
4255   <paramdef>int<parameter> argc</parameter></paramdef>
4256 </funcprototype>
4257 </funcsynopsis>
4258 <!-- .FN -->
4259 <variablelist>
4260   <varlistentry>
4261     <term>
4262       <emphasis remap='I'>display</emphasis>
4263     </term>
4264     <listitem>
4265       <para>
4266 Specifies the connection to the X server.
4267       </para>
4268     </listitem>
4269   </varlistentry>
4270   <varlistentry>
4271     <term>
4272       <emphasis remap='I'>w</emphasis>
4273     </term>
4274     <listitem>
4275       <para>
4276 Specifies the window.
4277       </para>
4278     </listitem>
4279   </varlistentry>
4280   <varlistentry>
4281     <term>
4282       <emphasis remap='I'>argv</emphasis>
4283     </term>
4284     <listitem>
4285       <para>
4286 Specifies the application's argument list.
4287       </para>
4288     </listitem>
4289   </varlistentry>
4290   <varlistentry>
4291     <term>
4292       <emphasis remap='I'>argc</emphasis>
4293     </term>
4294     <listitem>
4295       <para>
4296 Specifies the number of arguments.
4297     </para>
4298   </listitem>
4299   </varlistentry>
4300 </variablelist>
4301 <para>
4302 <!-- .LP -->
4303 <!-- .eM -->
4304 The
4305 <xref linkend='XSetCommand' xrefstyle='select: title'/>
4306 function sets the command and arguments used to invoke the
4307 application.
4308 (Typically, argv is the argv array of your main program.)
4309 If the strings are not in the Host Portable Character Encoding,
4310 the result is implementation-dependent.
4311 </para>
4312 <para>
4313 <!-- .LP -->
4314 <xref linkend='XSetCommand' xrefstyle='select: title'/>
4315 can generate
4316 <errorname>BadAlloc</errorname>
4317 and
4318 <errorname>BadWindow</errorname>
4319 errors.
4320 <!-- .sp -->
4321 </para>
4322 <para>
4323 <!-- .LP -->
4324 To read a window's <property>WM_COMMAND</property> property, use
4325 <xref linkend='XGetCommand' xrefstyle='select: title'/>.
4326 </para>
4327 <indexterm significance="preferred"><primary>XGetCommand</primary></indexterm>
4328 <!-- .sM -->
4329 <funcsynopsis id='XGetCommand'>
4330 <funcprototype>
4331   <funcdef>Status <function>XGetCommand</function></funcdef>
4332   <paramdef>Display<parameter> *display</parameter></paramdef>
4333   <paramdef>Window<parameter> w</parameter></paramdef>
4334   <paramdef>char<parameter> ***argv_return</parameter></paramdef>
4335   <paramdef>int<parameter> *argc_return</parameter></paramdef>
4336 </funcprototype>
4337 </funcsynopsis>
4338 <!-- .FN -->
4339 <variablelist>
4340   <varlistentry>
4341     <term>
4342       <emphasis remap='I'>display</emphasis>
4343     </term>
4344     <listitem>
4345       <para>
4346 Specifies the connection to the X server.
4347       </para>
4348     </listitem>
4349   </varlistentry>
4350   <varlistentry>
4351     <term>
4352       <emphasis remap='I'>w</emphasis>
4353     </term>
4354     <listitem>
4355       <para>
4356 Specifies the window.
4357       </para>
4358     </listitem>
4359   </varlistentry>
4360   <varlistentry>
4361     <term>
4362       <emphasis remap='I'>argv_return</emphasis>
4363     </term>
4364     <listitem>
4365       <para>
4366 Returns the application's argument list.
4367       </para>
4368     </listitem>
4369   </varlistentry>
4370   <varlistentry>
4371     <term>
4372       <emphasis remap='I'>argc_return</emphasis>
4373     </term>
4374     <listitem>
4375       <para>
4376 Returns the number of arguments returned.
4377     </para>
4378   </listitem>
4379   </varlistentry>
4380 </variablelist>
4381 <para>
4382 <!-- .LP -->
4383 <!-- .eM -->
4384 The 
4385 <xref linkend='XGetCommand' xrefstyle='select: title'/>
4386 function reads the <property>WM_COMMAND</property> property from the specified window 
4387 and returns a string list.
4388 If the <property>WM_COMMAND</property> property exists, 
4389 it is of type STRING and format 8.
4390 If sufficient memory can be allocated to contain the string list, 
4391 <xref linkend='XGetCommand' xrefstyle='select: title'/>
4392 fills in the argv_return and argc_return arguments
4393 and returns a nonzero status.
4394 Otherwise, it returns a zero status.
4395 If the data returned by the server is in the Latin Portable Character Encoding,
4396 then the returned strings are in the Host Portable Character Encoding.
4397 Otherwise, the result is implementation-dependent.
4398 To free the memory allocated to the string list, use
4399 <xref linkend='XFreeStringList' xrefstyle='select: title'/>.
4400 </para>
4401 </sect2>
4402 <sect2 id="Setting_and_Reading_the_WM_CLIENT_MACHINE_Property">
4403 <title>Setting and Reading the WM_CLIENT_MACHINE Property</title>
4404 <!-- .XS -->
4405 <!-- (SN Setting and Reading the WM_CLIENT_MACHINE Property -->
4406 <!-- .XE -->
4407 <para>
4408 <!-- .LP -->
4409 Xlib provides functions that you can use to set and read 
4410 the <property>WM_CLIENT_MACHINE</property> property for a given window.
4411 <!-- .sp -->
4412 </para>
4413 <para>
4414 <!-- .LP -->
4415 To set a window's <property>WM_CLIENT_MACHINE</property> property, use
4416 <xref linkend='XSetWMClientMachine' xrefstyle='select: title'/>.
4417 </para>
4418 <indexterm significance="preferred"><primary>XSetWMClientMachine</primary></indexterm>
4419 <!-- .sM -->
4420 <funcsynopsis id='XSetWMClientMachine'>
4421 <funcprototype>
4422   <funcdef>void <function>XSetWMClientMachine</function></funcdef>
4423   <paramdef>Display<parameter> *display</parameter></paramdef>
4424   <paramdef>Window<parameter> w</parameter></paramdef>
4425   <paramdef>XTextProperty<parameter> *text_prop</parameter></paramdef>
4426 </funcprototype>
4427 </funcsynopsis>
4428 <!-- .FN -->
4429 <variablelist>
4430   <varlistentry>
4431     <term>
4432       <emphasis remap='I'>display</emphasis>
4433     </term>
4434     <listitem>
4435       <para>
4436 Specifies the connection to the X server.
4437       </para>
4438     </listitem>
4439   </varlistentry>
4440   <varlistentry>
4441     <term>
4442       <emphasis remap='I'>w</emphasis>
4443     </term>
4444     <listitem>
4445       <para>
4446 Specifies the window.
4447       </para>
4448     </listitem>
4449   </varlistentry>
4450   <varlistentry>
4451     <term>
4452       <emphasis remap='I'>text_prop</emphasis>
4453     </term>
4454     <listitem>
4455       <para>
4456 Specifies the
4457 <structname>XTextProperty</structname>
4458 structure to be used.
4459     </para>
4460   </listitem>
4461   </varlistentry>
4462 </variablelist>
4463 <para>
4464 <!-- .LP -->
4465 <!-- .eM -->
4466 The
4467 <xref linkend='XSetWMClientMachine' xrefstyle='select: title'/>
4468 convenience function calls
4469 <xref linkend='XSetTextProperty' xrefstyle='select: title'/>
4470 to set the <property>WM_CLIENT_MACHINE</property> property.
4471 <!-- .sp -->
4472 </para>
4473 <para>
4474 <!-- .LP -->
4475 To read a window's <property>WM_CLIENT_MACHINE</property> property, use
4476 <xref linkend='XGetWMClientMachine' xrefstyle='select: title'/>.
4477 </para>
4478 <indexterm significance="preferred"><primary>XGetWMClientMachine</primary></indexterm>
4479 <!-- .sM -->
4480 <funcsynopsis id='XGetWMClientMachine'>
4481 <funcprototype>
4482   <funcdef>Status <function>XGetWMClientMachine</function></funcdef>
4483   <paramdef>Display<parameter> *display</parameter></paramdef>
4484   <paramdef>Window<parameter> w</parameter></paramdef>
4485   <paramdef>XTextProperty<parameter> *text_prop_return</parameter></paramdef>
4486 </funcprototype>
4487 </funcsynopsis>
4488 <!-- .FN -->
4489 <variablelist>
4490   <varlistentry>
4491     <term>
4492       <emphasis remap='I'>display</emphasis>
4493     </term>
4494     <listitem>
4495       <para>
4496 Specifies the connection to the X server.
4497       </para>
4498     </listitem>
4499   </varlistentry>
4500   <varlistentry>
4501     <term>
4502       <emphasis remap='I'>w</emphasis>
4503     </term>
4504     <listitem>
4505       <para>
4506 Specifies the window.
4507       </para>
4508     </listitem>
4509   </varlistentry>
4510   <varlistentry>
4511     <term>
4512       <emphasis remap='I'>text_prop_return</emphasis>
4513     </term>
4514     <listitem>
4515       <para>
4516 Returns the
4517 <structname>XTextProperty</structname>
4518 structure.
4519     </para>
4520   </listitem>
4521   </varlistentry>
4522 </variablelist>
4523 <para>
4524 <!-- .LP -->
4525 <!-- .eM -->
4526 The
4527 <xref linkend='XGetWMClientMachine' xrefstyle='select: title'/>
4528 convenience function performs an 
4529 <xref linkend='XGetTextProperty' xrefstyle='select: title'/>
4530 on the <property>WM_CLIENT_MACHINE</property> property.
4531 It returns a nonzero status on success;
4532 otherwise, it returns a zero status.
4533 </para>
4534 </sect2>
4535 </sect1>
4536 <sect1 id="Standard_Colormaps">
4537 <title>Standard Colormaps</title>
4538 <!-- .XS -->
4539 <!-- (SN Standard Colormaps  -->
4540 <!-- .XE -->
4541 <para>
4542 <!-- .LP -->
4543 Applications with color palettes, smooth-shaded drawings, or digitized
4544 images demand large numbers of colors.  
4545 In addition, these applications often require an efficient mapping 
4546 from color triples to pixel values that display the appropriate colors.
4547 </para>
4548 <para>
4549 <!-- .LP -->
4550 As an example, consider a three-dimensional display program that wants 
4551 to draw a smoothly shaded sphere.  
4552 At each pixel in the image of the sphere, 
4553 the program computes the intensity and color of light
4554 reflected back to the viewer.  
4555 The result of each computation is a triple of red, green, and blue (<acronym>RGB</acronym>)
4556 coefficients in the range 0.0 to 1.0.  
4557 To draw the sphere, the program needs a colormap that provides a
4558 large range of uniformly distributed colors.  
4559 The colormap should be arranged so that the program can
4560 convert its <acronym>RGB</acronym> triples into pixel values very quickly,
4561 because drawing the entire sphere requires many such
4562 conversions.
4563 </para>
4564 <para>
4565 <!-- .LP -->
4566 On many current workstations,
4567 the display is limited to 256 or fewer colors.  
4568 Applications must allocate colors carefully, 
4569 not only to make sure they cover the entire range they need 
4570 but also to make use of as many of the available colors as possible.
4571 On a typical X display, 
4572 many applications are active at once.
4573 Most workstations have only one hardware look-up table for colors,
4574 so only one application colormap can be installed at a given time.
4575 The application using the installed colormap is displayed correctly, 
4576 and the other applications go technicolor and are
4577 displayed with false colors.
4578 </para>
4579 <para>
4580 <!-- .LP -->
4581 As another example, consider a user who is running an 
4582 image processing program to display earth-resources data.  
4583 The image processing program needs a colormap set up with 8 reds, 
4584 8 greens, and 4 blues, for a total of 256 colors.
4585 Because some colors are already in use in the default colormap, 
4586 the image processing program allocates and installs a new colormap.
4587 </para>
4588 <para>
4589 <!-- .LP -->
4590 The user decides to alter some of the colors in the image
4591 by invoking a color palette program to mix and choose colors.
4592 The color palette program also needs a
4593 colormap with eight reds, eight greens, and four blues, so just like
4594 the image processing program, it must allocate and
4595 install a new colormap.
4596 </para>
4597 <para>
4598 <!-- .LP -->
4599 Because only one colormap can be installed at a time,
4600 the color palette may be displayed incorrectly
4601 whenever the image processing program is active.
4602 Conversely, whenever the palette program is active, 
4603 the image may be displayed incorrectly.  
4604 The user can never match or compare colors in the palette and image.
4605 Contention for colormap resources can be reduced if applications
4606 with similar color needs share colormaps.
4607 </para>
4608 <para>
4609 <!-- .LP -->
4610 The image processing program and the color palette program 
4611 could share the same colormap if there existed a convention that described
4612 how the colormap was set up.  
4613 Whenever either program was active, 
4614 both would be displayed correctly.
4615 </para>
4616 <para>
4617 <!-- .LP -->
4618 The standard colormap properties define a set of commonly used
4619 colormaps.  
4620 Applications that share these colormaps and conventions display 
4621 true colors more often and provide a better interface to the user.
4622 </para>
4623 <para>
4624 <!-- .LP -->
4625 Standard colormaps allow applications to share commonly used color
4626 resources.  
4627 This allows many applications to be displayed in true colors
4628 simultaneously, even when each application needs an entirely filled
4629 colormap.
4630 </para>
4631 <para>
4632 <!-- .LP -->
4633 Several standard colormaps are described in this section.
4634 Usually, a window manager creates these colormaps.
4635 Applications should use the standard colormaps if they already exist.
4636 <!-- .sp -->
4637 </para>
4638 <para>
4639 <!-- .LP -->
4640 To allocate an
4641 <structname>XStandardColormap</structname>
4642 structure, use
4643 <function>XAllocStandardColormap</function>.
4644 </para>
4645
4646 <para>
4647 XStandardColormap *XAllocStandardColormap()
4648 </para>
4649 <para>
4650 <!-- .LP -->
4651 <!-- .eM -->
4652 The
4653 <function>XAllocStandardColormap</function>
4654 function allocates and returns a pointer to an
4655 <structname>XStandardColormap</structname>
4656 structure.
4657 Note that all fields in the
4658 <structname>XStandardColormap</structname>
4659 structure are initially set to zero.
4660 If insufficient memory is available, 
4661 <function>XAllocStandardColormap</function>
4662 returns NULL.
4663 To free the memory allocated to this structure,
4664 use
4665 <xref linkend='XFree' xrefstyle='select: title'/>.
4666 </para>
4667 <para>
4668 <!-- .LP -->
4669 The 
4670 <structname>XStandardColormap</structname>
4671 structure contains:
4672 </para>
4673 <literallayout class="monospaced">
4674 /* Hints */
4675
4676 #define       ReeaseByFreeingColormap  ((XID)1L)
4677
4678 /* Values */
4679
4680 typedef struct {
4681         Colormap colormap;
4682         unsigned long red_max;
4683         unsigned long red_mult;
4684         unsigned long green_max;
4685         unsigned long green_mult;
4686         unsigned long blue_max;
4687         unsigned long blue_mult;
4688         unsigned long base_pixel;
4689         VisualID visualid;
4690         XID killid;
4691 } XStandardColormap;
4692 </literallayout>
4693
4694 <para>
4695 <!-- .LP -->
4696 <!-- .eM -->
4697 The colormap member is the colormap created by the
4698 <xref linkend='XCreateColormap' xrefstyle='select: title'/>
4699 function.
4700 The red_max, green_max, and blue_max members give the maximum
4701 red, green, and blue values, respectively.  
4702 Each color coefficient ranges from zero to its max, inclusive.  
4703 For example,
4704 a common colormap allocation is 3/3/2 (3 planes for red, 3
4705 planes for green, and 2 planes for blue).  
4706 This colormap would have red_max = 7, green_max = 7, 
4707 and blue_max = 3.  
4708 An alternate allocation that uses only 216 colors is red_max = 5, 
4709 green_max = 5, and blue_max = 5.
4710 </para>
4711 <para>
4712 <!-- .LP -->
4713 The red_mult, green_mult, and blue_mult members give the
4714 scale factors used to compose a full pixel value. 
4715 (See the discussion of the base_pixel members for further information.)
4716 For a 3/3/2 allocation, red_mult might be 32,
4717 green_mult might be 4, and blue_mult might be 1.  
4718 For a 6-colors-each allocation, red_mult might be 36, 
4719 green_mult might be 6, and blue_mult might be 1.
4720 </para>
4721 <para>
4722 <!-- .LP -->
4723 The base_pixel member gives the base pixel value used to
4724 compose a full pixel value.  
4725 Usually, the base_pixel is obtained from a call to the 
4726 <xref linkend='XAllocColorPlanes' xrefstyle='select: title'/>
4727 function.  
4728 Given integer red, green, and blue coefficients in their appropriate 
4729 ranges, one then can compute a corresponding pixel value by
4730 using the following expression:
4731 </para>
4732 <para>
4733 <!-- .LP -->
4734 <literallayout class="monospaced">
4735 <!-- .TA .5i 1.5i -->
4736 <!-- .ta .5i 1.5i -->
4737 (r * red_mult + g * green_mult + b * blue_mult + base_pixel) &amp; 0xFFFFFFFF
4738 </literallayout>
4739 </para>
4740 <para>
4741 <!-- .LP -->
4742 For 
4743 <symbol>GrayScale</symbol>
4744 colormaps, 
4745 only the colormap, red_max, red_mult, 
4746 and base_pixel members are defined. 
4747 The other members are ignored.  
4748 To compute a 
4749 <symbol>GrayScale</symbol>
4750 pixel value, use the following expression:
4751 </para>
4752 <para>
4753 <!-- .LP -->
4754 <literallayout class="monospaced">
4755 <!-- .TA .5i 1.5i -->
4756 <!-- .ta .5i 1.5i -->
4757 (gray * red_mult + base_pixel) &amp; 0xFFFFFFFF
4758 </literallayout>
4759 </para>
4760 <para>
4761 <!-- .LP -->
4762 Negative multipliers can be represented by converting the 2's
4763 complement representation of the multiplier into an unsigned long and
4764 storing the result in the appropriate _mult field.
4765 The step of masking by 0xFFFFFFFF effectively converts the resulting
4766 positive multiplier into a negative one.
4767 The masking step will take place automatically on many machine architectures,
4768 depending on the size of the integer type used to do the computation.
4769 </para>
4770 <para>
4771 <!-- .LP -->
4772 The visualid member gives the ID number of the visual from which the
4773 colormap was created.
4774 The killid member gives a resource ID that indicates whether
4775 the cells held by this standard colormap are to be released 
4776 by freeing the colormap ID or by calling the
4777 <xref linkend='XKillClient' xrefstyle='select: title'/>
4778 function on the indicated resource.
4779 (Note that this method is necessary for allocating out of an existing colormap.)
4780 </para>
4781 <para>
4782 <!-- .LP -->
4783 The properties containing the 
4784 <structname>XStandardColormap</structname>
4785 information have 
4786 the type RGB_COLOR_MAP.
4787 </para>
4788 <para>
4789 <!-- .LP -->
4790 The remainder of this section discusses standard colormap properties and atoms
4791 as well as how to manipulate standard colormaps.
4792 </para>
4793 <sect2 id="Standard_Colormap_Properties_and_Atoms">
4794 <title>Standard Colormap Properties and Atoms</title>
4795 <!-- .XS -->
4796 <!-- (SN Standard Colormap Properties and Atoms  -->
4797 <!-- .XE -->
4798 <para>
4799 <!-- .LP -->
4800 <indexterm><primary>Standard Colormaps</primary></indexterm>
4801 <indexterm><primary>Colormaps</primary><secondary>standard</secondary></indexterm>
4802 Several standard colormaps are available.  
4803 Each standard colormap is defined by a property, 
4804 and each such property is identified by an atom.  
4805 The following list names the atoms and describes the colormap
4806 associated with each one.
4807 The
4808 <filename class="headerfile">&lt;X11/Xatom.h&gt;</filename>
4809 <indexterm type="file"><primary><filename class="headerfile">X11/Xatom.h</filename></primary></indexterm>
4810 <indexterm><primary>Files</primary><secondary><filename class="headerfile">&lt;X11/Xatom.h&gt;</filename></secondary></indexterm>
4811 <indexterm><primary>Headers</primary><secondary><filename class="headerfile">&lt;X11/Xatom.h&gt;</filename></secondary></indexterm>
4812 header file contains the definitions for each of the following atoms,
4813 which are prefixed with XA_.
4814 </para>
4815
4816
4817
4818 <variablelist>
4819   <varlistentry>
4820     <term>RGB_DEFAULT_MAP</term>
4821     <listitem>
4822       <para>
4823 This atom names a property.
4824 The value of the property is an array of
4825 <structname>XStandardColormap</structname>
4826 structures.
4827 Each entry in the array describes an <acronym>RGB</acronym> subset of the default color
4828 map for the Visual specified by visual_id.
4829       </para>
4830       <para>
4831 Some applications only need a few <acronym>RGB</acronym> colors and
4832 may be able to allocate them from the system default colormap.
4833 This is the ideal situation because the fewer colormaps that are
4834 active in the system the more applications are displayed
4835 with correct colors at all times.
4836       </para>
4837       <para>
4838 A typical allocation for the RGB_DEFAULT_MAP on 8-plane displays
4839 is 6 reds, 6 greens, and 6 blues.  
4840 This gives 216 uniformly distributed colors 
4841 (6 intensities of 36 different hues) and still leaves 40 elements 
4842 of a 256-element colormap available for special-purpose colors 
4843 for text, borders, and so on.
4844       </para>
4845     </listitem>
4846   </varlistentry>
4847   <varlistentry>
4848     <term>RGB_BEST_MAP</term>
4849     <listitem>
4850       <para>
4851 This atom names a property.  The value of the property is an 
4852 <structname>XStandardColormap</structname>.
4853       </para>
4854       <para>
4855 The property defines the best <acronym>RGB</acronym> colormap available on
4856 the screen.
4857 (Of course, this is a subjective evaluation.)
4858 Many image processing and three-dimensional applications need to
4859 use all available colormap cells and to distribute as many
4860 perceptually distinct colors as possible over those cells.
4861 This implies that there may be more green values available than
4862 red, as well as more green or red than blue.
4863       </para>
4864       <para>
4865 For an 8-plane 
4866 <symbol>PseudoColor</symbol>
4867 visual, 
4868 RGB_BEST_MAP is likely to be a 3/3/2 allocation.  
4869 For a 24-plane 
4870 <symbol>DirectColor</symbol>
4871 visual, 
4872 RGB_BEST_MAP is normally an 8/8/8 allocation.  
4873       </para>
4874     </listitem>
4875   </varlistentry>
4876   <varlistentry>
4877     <term>RGB_RED_MAP,RGB_GREEN_MAP,RGB_BLUE_MAP</term>
4878     <listitem>
4879       <para>
4880 These atoms name properties.
4881 The value of each property is an
4882 <structname>XStandardColormap</structname>.
4883       </para>
4884       <para>
4885 The properties define all-red, all-green, and all-blue
4886 colormaps, respectively.  
4887 These maps are used by applications that want to make color-separated 
4888 images.  
4889 For example, a user might generate a full-color image 
4890 on an 8-plane display both by rendering an image three times 
4891 (once with high color resolution in red, once with green, 
4892 and once with blue) and by multiply exposing a single frame in a camera.
4893       </para>
4894     </listitem>
4895   </varlistentry>
4896   <varlistentry> 
4897     <term>RGB_GRAY_MAP</term>
4898     <listitem>
4899       <para>
4900 This atom names a property.
4901 The value of the property is an 
4902 <structname>XStandardColormap</structname>.
4903       </para>
4904       <para>
4905 The property describes the best 
4906 <symbol>GrayScale</symbol>
4907 colormap available on the screen.  
4908 As previously mentioned, 
4909 only the colormap, red_max, red_mult, and base_pixel members of the
4910 <structname>XStandardColormap</structname>
4911 structure are used for 
4912 <symbol>GrayScale</symbol>
4913 colormaps.
4914       </para>
4915     </listitem>
4916   </varlistentry>
4917 </variablelist>
4918
4919 </sect2>
4920
4921 <sect2 id="Setting_and_Obtaining_Standard_Colormaps">
4922 <title>Setting and Obtaining Standard Colormaps</title>
4923 <!-- .XS -->
4924 <!-- (SN Setting and Obtaining Standard Colormaps -->
4925 <!-- .XE -->
4926 <para>
4927 <!-- .LP -->
4928 Xlib provides functions that you can use to set and obtain an
4929 <structname>XStandardColormap</structname>
4930 structure.
4931 <!-- .sp -->
4932 </para>
4933 <para>
4934 <!-- .LP -->
4935 To set an
4936 <structname>XStandardColormap</structname>
4937 structure, use
4938 <xref linkend='XSetRGBColormaps' xrefstyle='select: title'/>.
4939 </para>
4940 <indexterm significance="preferred"><primary>XSetRGBColormaps</primary></indexterm>
4941 <!-- .sM -->
4942 <funcsynopsis id='XSetRGBColormaps'>
4943 <funcprototype>
4944   <funcdef>void <function>XSetRGBColormaps</function></funcdef>
4945   <paramdef>Display<parameter> *display</parameter></paramdef>
4946   <paramdef>Window<parameter> w</parameter></paramdef>
4947   <paramdef>XStandardColormap<parameter> *std_colormap</parameter></paramdef>
4948   <paramdef>int<parameter> count</parameter></paramdef>
4949   <paramdef>Atom<parameter> property</parameter></paramdef>
4950 </funcprototype>
4951 </funcsynopsis>
4952 <!-- .FN -->
4953 <variablelist>
4954   <varlistentry>
4955     <term>
4956       <emphasis remap='I'>display</emphasis>
4957     </term>
4958     <listitem>
4959       <para>
4960 Specifies the connection to the X server.
4961       </para>
4962     </listitem>
4963   </varlistentry>
4964   <varlistentry>
4965     <term>
4966       <emphasis remap='I'>w</emphasis>
4967     </term>
4968     <listitem>
4969       <para>
4970 Specifies the window.
4971       </para>
4972     </listitem>
4973   </varlistentry>
4974   <varlistentry>
4975     <term>
4976       <emphasis remap='I'>std_colormap</emphasis>
4977     </term>
4978     <listitem>
4979       <para>
4980 Specifies the
4981 <structname>XStandardColormap</structname>
4982 structure to be used.
4983 <!-- .ds Cn colormaps -->
4984       </para>
4985     </listitem>
4986   </varlistentry>
4987   <varlistentry>
4988     <term>
4989       <emphasis remap='I'>count</emphasis>
4990     </term>
4991     <listitem>
4992       <para>
4993 Specifies the number of (Cn.
4994       </para>
4995     </listitem>
4996   </varlistentry>
4997   <varlistentry>
4998     <term>
4999       <emphasis remap='I'>property</emphasis>
5000     </term>
5001     <listitem>
5002       <para>
5003 Specifies the property name.
5004     </para>
5005   </listitem>
5006   </varlistentry>
5007 </variablelist>
5008 <para>
5009 <!-- .LP -->
5010 <!-- .eM -->
5011 The 
5012 <xref linkend='XSetRGBColormaps' xrefstyle='select: title'/>
5013 function replaces the <acronym>RGB</acronym> colormap definition in the specified property 
5014 on the named window.
5015 If the property does not already exist,
5016 <xref linkend='XSetRGBColormaps' xrefstyle='select: title'/>
5017 sets the <acronym>RGB</acronym> colormap definition in the specified property
5018 on the named window.
5019 The property is stored with a type of RGB_COLOR_MAP and a format of 32.
5020 Note that it is the caller's responsibility to honor the <acronym>ICCCM</acronym>
5021 restriction that only RGB_DEFAULT_MAP contain more than one definition.
5022 </para>
5023 <para>
5024 <!-- .LP -->
5025 The
5026 <xref linkend='XSetRGBColormaps' xrefstyle='select: title'/>
5027 function usually is only used by window or session managers.
5028 To create a standard colormap, 
5029 follow this procedure:
5030 </para>
5031 <itemizedlist>
5032   <listitem>
5033     <para>
5034 Open a new connection to the same server.
5035     </para>
5036   </listitem>
5037   <listitem>
5038     <para>
5039 Grab the server.
5040     </para>
5041   </listitem>
5042   <listitem>
5043     <para>
5044 See if the property is on the property list of the root window for the screen.
5045     </para>
5046   </listitem>
5047   <listitem>
5048     <para>
5049 If the desired property is not present:
5050 <!-- .RS -->
5051     </para>
5052   </listitem>
5053   <listitem>
5054     <para>
5055 Create a colormap (unless you are using the default colormap of the screen).
5056     </para>
5057   </listitem>
5058   <listitem>
5059     <para>
5060 Determine the color characteristics of the visual.
5061     </para>
5062   </listitem>
5063   <listitem>
5064     <para>
5065 Allocate cells in the colormap (or create it with
5066 <symbol>AllocAll</symbol>).
5067     </para>
5068   </listitem>
5069   <listitem>
5070     <para>
5071 Call 
5072 <xref linkend='XStoreColors' xrefstyle='select: title'/>
5073 to store appropriate color values in the colormap.
5074     </para>
5075   </listitem>
5076   <listitem>
5077     <para>
5078 Fill in the descriptive members in the 
5079 <structname>XStandardColormap</structname>
5080 structure.
5081     </para>
5082   </listitem>
5083   <listitem>
5084     <para>
5085 Attach the property to the root window.
5086     </para>
5087   </listitem>
5088   <listitem>
5089     <para>
5090 Use
5091 <xref linkend='XSetCloseDownMode' xrefstyle='select: title'/>
5092 to make the resource permanent.
5093 <!-- .RE -->
5094     </para>
5095   </listitem>
5096   <listitem>
5097     <para>
5098 Ungrab the server.
5099     </para>
5100   </listitem>
5101 </itemizedlist>
5102 <para>
5103 <!-- .LP -->
5104 <xref linkend='XSetRGBColormaps' xrefstyle='select: title'/>
5105 can generate
5106 <errorname>BadAlloc</errorname>,
5107 <errorname>BadAtom</errorname>,
5108 and
5109 <errorname>BadWindow</errorname>
5110 errors.
5111 <!-- .sp -->
5112 </para>
5113 <para>
5114 <!-- .LP -->
5115 To obtain the 
5116 <structname>XStandardColormap</structname>
5117 structure associated with the specified property, use
5118 <xref linkend='XGetRGBColormaps' xrefstyle='select: title'/>.
5119 </para>
5120 <indexterm significance="preferred"><primary>XGetRGBColormaps</primary></indexterm>
5121 <!-- .sM -->
5122 <funcsynopsis id='XGetRGBColormaps'>
5123 <funcprototype>
5124   <funcdef>Status <function>XGetRGBColormaps</function></funcdef>
5125   <paramdef>Display<parameter> *display</parameter></paramdef>
5126   <paramdef>Window<parameter> w</parameter></paramdef>
5127   <paramdef>XStandardColormap<parameter> **std_colormap_return</parameter></paramdef>
5128   <paramdef>int<parameter> *count_return</parameter></paramdef>
5129   <paramdef>Atom<parameter> property</parameter></paramdef>
5130 </funcprototype>
5131 </funcsynopsis>
5132 <!-- .FN -->
5133 <variablelist>
5134   <varlistentry>
5135     <term>
5136       <emphasis remap='I'>display</emphasis>
5137     </term>
5138     <listitem>
5139       <para>
5140 Specifies the connection to the X server.
5141       </para>
5142     </listitem>
5143   </varlistentry>
5144   <varlistentry>
5145     <term>
5146       <emphasis remap='I'>w</emphasis>
5147     </term>
5148     <listitem>
5149       <para>
5150 Specifies the window.
5151       </para>
5152     </listitem>
5153   </varlistentry>
5154   <varlistentry>
5155     <term>
5156       <emphasis remap='I'>std_colormap_return</emphasis>
5157     </term>
5158     <listitem>
5159       <para>
5160 Returns the
5161 <structname>XStandardColormap</structname>
5162 structure.
5163 <!-- .ds Cn colormaps -->
5164       </para>
5165     </listitem>
5166   </varlistentry>
5167   <varlistentry>
5168     <term>
5169       <emphasis remap='I'>count_return</emphasis>
5170     </term>
5171     <listitem>
5172       <para>
5173 Returns the number of (Cn.
5174       </para>
5175     </listitem>
5176   </varlistentry>
5177   <varlistentry>
5178     <term>
5179       <emphasis remap='I'>property</emphasis>
5180     </term>
5181     <listitem>
5182       <para>
5183 Specifies the property name.
5184     </para>
5185   </listitem>
5186   </varlistentry>
5187 </variablelist>
5188 <para>
5189 <!-- .LP -->
5190 <!-- .eM -->
5191 The 
5192 <xref linkend='XGetRGBColormaps' xrefstyle='select: title'/>
5193 function returns the <acronym>RGB</acronym> colormap definitions stored 
5194 in the specified property on the named window.
5195 If the property exists, is of type RGB_COLOR_MAP, is of format 32, 
5196 and is long enough to contain a colormap definition,
5197 <xref linkend='XGetRGBColormaps' xrefstyle='select: title'/>
5198 allocates and fills in space for the returned colormaps
5199 and returns a nonzero status.
5200 If the visualid is not present, 
5201 <xref linkend='XGetRGBColormaps' xrefstyle='select: title'/>
5202 assumes the default visual for the screen on which the window is located; 
5203 if the killid is not present, 
5204 <symbol>None</symbol>
5205 is assumed, which indicates that the resources cannot be released.
5206 Otherwise, 
5207 none of the fields are set, and 
5208 <xref linkend='XGetRGBColormaps' xrefstyle='select: title'/>
5209 returns a zero status.
5210 Note that it is the caller's responsibility to honor the <acronym>ICCCM</acronym>
5211 restriction that only RGB_DEFAULT_MAP contain more than one definition.
5212 </para>
5213 <para>
5214 <!-- .LP -->
5215 <xref linkend='XGetRGBColormaps' xrefstyle='select: title'/>
5216 can generate
5217 <errorname>BadAtom</errorname>
5218 and
5219 <errorname>BadWindow</errorname>
5220 errors.
5221 <!-- .bp -->
5222
5223 </para>
5224 </sect2>
5225 </sect1>
5226 </chapter>