<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
                   "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
<!-- lifted from troff+man by doclifter -->
<refentry id='xgetwpropman'>
<!--  Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium -->

<!--  Permission is hereby granted, free of charge, to any person obtaining -->
<!--  a copy of this software and associated documentation files (the -->
<!--  "Software"), to deal in the Software without restriction, including -->
<!--  without limitation the rights to use, copy, modify, merge, publish, -->
<!--  distribute, sublicense, and/or sell copies of the Software, and to -->
<!--  permit persons to whom the Software is furnished to do so, subject to -->
<!--  the following conditions: -->

<!--  The above copyright notice and this permission notice shall be included -->
<!--  in all copies or substantial portions of the Software. -->

<!--  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -->
<!--  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -->
<!--  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -->
<!--  IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR -->
<!--  OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -->
<!--  ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -->
<!--  OTHER DEALINGS IN THE SOFTWARE. -->

<!--  Except as contained in this notice, the name of the X Consortium shall -->
<!--  not be used in advertising or otherwise to promote the sale, use or -->
<!--  other dealings in this Software without prior written authorization -->
<!--  from the X Consortium. -->

<!--  Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by -->
<!--  Digital Equipment Corporation -->

<!--  Portions Copyright \(co 1990, 1991 by -->
<!--  Tektronix, Inc. -->

<!--  Permission to use, copy, modify and distribute this documentation for -->
<!--  any purpose and without fee is hereby granted, provided that the above -->
<!--  copyright notice appears in all copies and that both that copyright notice -->
<!--  and this permission notice appear in all copies, and that the names of -->
<!--  Digital and Tektronix not be used in in advertising or publicity pertaining -->
<!--  to this documentation without specific, written prior permission. -->
<!--  Digital and Tektronix makes no representations about the suitability -->
<!--  of this documentation for any purpose. -->
<!--  It is provided ``as is'' without express or implied warranty. -->
<!--   -->
<!--  $XFree86: xc/doc/man/X11/XGetWProp.man,v 1.3 2003/04/28 22:17:55 herrb Exp $ -->

<!-- .na -->
<!-- Ds listing suppressed (not used) -->
<!-- De listing suppressed (not used) -->
<!-- FD listing suppressed (not used) -->
<!-- FN listing suppressed (not used) -->
<!-- IN listing suppressed (not used) -->
<!-- C{ listing suppressed (not used) -->
<!-- C} listing suppressed (not used) -->
<!-- Pn listing suppressed (not used) -->
<!-- hN listing suppressed (not used) -->
<!-- NT listing suppressed (not used) -->
<!-- .		\" Note End \-\- doug kraft 3/85 -->
<!-- NE listing suppressed (not used) -->
<!-- .ny0 -->
<refmeta>
<refentrytitle>XGetWindowProperty</refentrytitle>
<manvolnum>3X11</manvolnum>
<refmiscinfo class='date'>__xorgversion__</refmiscinfo>
<refmiscinfo class='source'>XLIB FUNCTIONS</refmiscinfo>
</refmeta>
<refnamediv id='name'>
<refname>XGetWindowProperty</refname>
<refname>XListProperties</refname>
<refname>XChangeProperty</refname>
<refname>XRotateWindowProperties</refname>
<refname>XDeleteProperty</refname>
<refpurpose>obtain and change window properties</refpurpose>
</refnamediv>
<!-- body begins here -->

<refsect1 id='syntax'><title>SYNTAX</title>

<para>int XGetWindowProperty&hairsp;(&hairsp;Display *<emphasis remap='I'>display</emphasis>&hairsp;, Window <emphasis remap='I'>w</emphasis>&hairsp;, Atom
<emphasis remap='I'>property</emphasis>&hairsp;, long <emphasis remap='I'>long_offset</emphasis>&hairsp;, long <emphasis remap='I'>long_length</emphasis>&hairsp;, Bool
<emphasis remap='I'>delete</emphasis>&hairsp;, Atom <emphasis remap='I'>req_type</emphasis>&hairsp;, Atom *<emphasis remap='I'>actual_type_return</emphasis>&hairsp;, int
*<emphasis remap='I'>actual_format_return</emphasis>&hairsp;, unsigned long *<emphasis remap='I'>nitems_return</emphasis>&hairsp;, unsigned
long *<emphasis remap='I'>bytes_after_return</emphasis>&hairsp;, unsigned char **<emphasis remap='I'>prop_return</emphasis>&hairsp;);</para> 

<para>Atom *XListProperties&hairsp;(&hairsp;Display *<emphasis remap='I'>display</emphasis>&hairsp;, Window <emphasis remap='I'>w</emphasis>&hairsp;, int
*<emphasis remap='I'>num_prop_return</emphasis>&hairsp;); 
int XChangeProperty&hairsp;(&hairsp;Display *<emphasis remap='I'>display</emphasis>&hairsp;, Window <emphasis remap='I'>w</emphasis>&hairsp;, Atom
<emphasis remap='I'>property</emphasis>&hairsp;, Atom <emphasis remap='I'>type</emphasis>&hairsp;, int <emphasis remap='I'>format</emphasis>&hairsp;, int <emphasis remap='I'>mode</emphasis>&hairsp;,
unsigned char *<emphasis remap='I'>data</emphasis>&hairsp;, int <emphasis remap='I'>nelements</emphasis>&hairsp;);</para> 

<para>int XRotateWindowProperties&hairsp;(&hairsp;Display *<emphasis remap='I'>display</emphasis>&hairsp;, Window <emphasis remap='I'>w</emphasis>&hairsp;,
Atom <emphasis remap='I'>properties</emphasis>&hairsp;[]&hairsp;, int <emphasis remap='I'>num_prop</emphasis>&hairsp;, int <emphasis remap='I'>npositions</emphasis>&hairsp;);</para> 

<para>int XDeleteProperty&hairsp;(&hairsp;Display *<emphasis remap='I'>display</emphasis>&hairsp;, Window <emphasis remap='I'>w</emphasis>&hairsp;, Atom
<emphasis remap='I'>property</emphasis>&hairsp;);</para> 
</refsect1>

<refsect1 id='arguments'><title>ARGUMENTS</title>
<variablelist remap='IP'>
  <varlistentry>
  <term><emphasis remap='I'>actual_format_return</emphasis></term>
  <listitem>
<para>Returns the actual format of the property.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>actual_type_return</emphasis></term>
  <listitem>
<para>Returns the atom identifier  that defines the actual type of the property.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>bytes_after_return</emphasis></term>
  <listitem>
<para>Returns the number of bytes remaining to be read in the property if 
a partial read was performed.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>data</emphasis></term>
  <listitem>
<para>Specifies the property data.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>delete</emphasis></term>
  <listitem>
<para>Specifies a Boolean value that determines whether the property is deleted.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>display</emphasis></term>
  <listitem>
<para>Specifies the connection to the X server.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>format</emphasis></term>
  <listitem>
<para>Specifies whether the data should be viewed as a list
of 8-bit, 16-bit, or 32-bit quantities.
Possible values are 8, 16, and 32.
This information allows the X server to correctly perform
byte-swap operations as necessary.
If the format is 16-bit or 32-bit,
you must explicitly cast your data pointer to an (unsigned char *) in the call
to 
<emphasis remap='I'>&hairsp;XChangeProperty&hairsp;</emphasis>.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>long_length</emphasis></term>
  <listitem>
<para>Specifies the length in 32-bit multiples of the data to be retrieved.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>long_offset</emphasis></term>
  <listitem>
<para>Specifies the offset in the specified property (in 32-bit quantities) 
where the data is to be retrieved.</para>
<!--  Changed name of this file to prop_mode.a on 1/13/87 -->
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>mode</emphasis></term>
  <listitem>
<para>Specifies the mode of the operation.
You can pass
<emphasis remap='I'>&hairsp;PropModeReplace&hairsp;</emphasis>,
<emphasis remap='I'>&hairsp;PropModePrepend&hairsp;</emphasis>,
or
<emphasis remap='I'>&hairsp;PropModeAppend&hairsp;</emphasis>.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>nelements</emphasis></term>
  <listitem>
<para>Specifies the number of elements of the specified data format.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>nitems_return</emphasis></term>
  <listitem>
<para>Returns the actual number of 8-bit, 16-bit, or 32-bit items 
stored in the prop_return data.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>num_prop</emphasis></term>
  <listitem>
<para>Specifies the length of the properties array.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>num_prop_return</emphasis></term>
  <listitem>
<para>Returns the length of the properties array.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>npositions</emphasis></term>
  <listitem>
<para>Specifies the rotation amount.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>prop_return</emphasis></term>
  <listitem>
<para>Returns the data in the specified format.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>property</emphasis></term>
  <listitem>
<para>Specifies the property name.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>properties</emphasis></term>
  <listitem>
<para>Specifies the array of properties that are to be rotated.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>req_type</emphasis></term>
  <listitem>
<para>Specifies the atom identifier associated with the property type or
<emphasis remap='I'>&hairsp;AnyPropertyType&hairsp;</emphasis>.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>type</emphasis></term>
  <listitem>
<para>Specifies the type of the property.
The X server does not interpret the type but simply
passes it back to an application that later calls 
<emphasis remap='I'>&hairsp;XGetWindowProperty&hairsp;</emphasis>.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>w</emphasis></term>
  <listitem>
<para>Specifies the window whose property you want to obtain, change, rotate or delete.</para>
  </listitem>
  </varlistentry>
</variablelist>
</refsect1>

<refsect1 id='description'><title>DESCRIPTION</title>
<para>The
<emphasis remap='I'>&hairsp;XGetWindowProperty&hairsp;</emphasis>
function returns the actual type of the property; the actual format of the property;
the number of 8-bit, 16-bit, or 32-bit items transferred; the number of bytes remaining
to be read in the property; and a pointer to the data actually returned.
<emphasis remap='I'>&hairsp;XGetWindowProperty&hairsp;</emphasis>
sets the return arguments as follows:</para>
<itemizedlist remap='IP+bullet'>
  <listitem override='bullet'>
<para>If the specified property does not exist for the specified window,
<emphasis remap='I'>&hairsp;XGetWindowProperty&hairsp;</emphasis>
returns 
<emphasis remap='I'>&hairsp;None&hairsp;</emphasis>
to actual_type_return and the value zero to 
actual_format_return and bytes_after_return.
The nitems_return argument is empty.
In this case, the delete argument is ignored.</para>
  </listitem>
</itemizedlist>
<itemizedlist remap='IP+bullet'>
  <listitem override='bullet'>
<para>If the specified property exists 
but its type does not match the specified type,
<emphasis remap='I'>&hairsp;XGetWindowProperty&hairsp;</emphasis>
returns the actual property type to actual_type_return, 
the actual property format (never zero) to actual_format_return, 
and the property length in bytes
(even if the actual_format_return is 16 or 32) 
to bytes_after_return.
It also ignores the delete argument.
The nitems_return argument is empty.</para>
  </listitem>
</itemizedlist>
<itemizedlist remap='IP+bullet'>
  <listitem override='bullet'>
<para>If the specified property exists and either you assign 
<emphasis remap='I'>&hairsp;AnyPropertyType&hairsp;</emphasis>
to the req_type argument or the specified type matches the actual property type,
<emphasis remap='I'>&hairsp;XGetWindowProperty&hairsp;</emphasis>
returns the actual property type to actual_type_return and the actual
property format (never zero) to actual_format_return. 
It also returns a value to bytes_after_return and nitems_return, by 
defining the following
values:</para>
  </listitem>
</itemizedlist>

<literallayout remap='.nf'>
	N = actual length of the stored property in bytes
	     (even if the format is 16 or 32)
	I = 4 * long_offset
	T = N - I
	L = MINIMUM(T, 4 * long_length)
	A = N - (I + L)
</literallayout> <!-- .fi -->

<para>The returned value starts at byte index I in the property (indexing
from zero), and its length in bytes is L.
If the value for long_offset causes L to be negative,
a
<emphasis remap='I'>&hairsp;BadValue&hairsp;</emphasis>
error results. 
The value of bytes_after_return is A, 
giving the number of trailing unread bytes in the stored property.</para>

<para>If the returned format is 8, the returned data is represented as a
<emphasis remap='I'>&hairsp;char&hairsp;</emphasis>
array.
If the returned format is 16, the returned data is represented as a
<emphasis remap='I'>&hairsp;short&hairsp;</emphasis>
array and should be cast to that type to obtain the elements.
If the returned format is 32, the returned data is represented as a
<emphasis remap='I'>&hairsp;long&hairsp;</emphasis>
array and should be cast to that type to obtain the elements.</para>

<para><emphasis remap='I'>&hairsp;XGetWindowProperty&hairsp;</emphasis>
always allocates one extra byte in prop_return 
(even if the property is zero length) 
and sets it to zero so that simple properties consisting of characters
do not have to be copied into yet another string before use.</para>

<para>If delete is 
<emphasis remap='I'>&hairsp;True&hairsp;</emphasis>
and bytes_after_return is zero, 
<emphasis remap='I'>&hairsp;XGetWindowProperty&hairsp;</emphasis>
deletes the property 
from the window and generates a 
<emphasis remap='I'>&hairsp;PropertyNotify&hairsp;</emphasis>
event on the window.</para>

<para>The function returns
<emphasis remap='I'>&hairsp;Success&hairsp;</emphasis>
if it executes successfully.
To free the resulting data,
use
<emphasis remap='I'>&hairsp;XFree&hairsp;</emphasis>.</para>

<para><emphasis remap='I'>&hairsp;XGetWindowProperty&hairsp;</emphasis>
can generate
<emphasis remap='I'>&hairsp;BadAtom&hairsp;</emphasis>,
<emphasis remap='I'>&hairsp;BadValue&hairsp;</emphasis>,
and
<emphasis remap='I'>&hairsp;BadWindow&hairsp;</emphasis>
errors.</para>

<para>The
<emphasis remap='I'>&hairsp;XListProperties&hairsp;</emphasis>
function returns a pointer to an array of atom properties that are defined for 
the specified window or returns NULL if no properties were found.
To free the memory allocated by this function, use
<emphasis remap='I'>&hairsp;XFree&hairsp;</emphasis>.</para>

<para><emphasis remap='I'>&hairsp;XListProperties&hairsp;</emphasis>
can generate a
<emphasis remap='I'>&hairsp;BadWindow&hairsp;</emphasis>
error.</para>

<para>The
<emphasis remap='I'>&hairsp;XChangeProperty&hairsp;</emphasis>
function alters the property for the specified window and
causes the X server to generate a
<emphasis remap='I'>&hairsp;PropertyNotify&hairsp;</emphasis>
event on that window.
<emphasis remap='I'>&hairsp;XChangeProperty&hairsp;</emphasis>
performs the following:</para>
<itemizedlist remap='IP+bullet'>
  <listitem override='bullet'>
<para>If mode is
<emphasis remap='I'>&hairsp;PropModeReplace&hairsp;</emphasis>,
<emphasis remap='I'>&hairsp;XChangeProperty&hairsp;</emphasis>
discards the previous property value and stores the new data.</para>
  </listitem>
</itemizedlist>
<itemizedlist remap='IP+bullet'>
  <listitem override='bullet'>
<para>If mode is
<emphasis remap='I'>&hairsp;PropModePrepend&hairsp;</emphasis>
or
<emphasis remap='I'>&hairsp;PropModeAppend&hairsp;</emphasis>,
<emphasis remap='I'>&hairsp;XChangeProperty&hairsp;</emphasis>
inserts the specified data before the beginning of the existing data
or onto the end of the existing data, respectively.
The type and format must match the existing property value,
or a
<emphasis remap='I'>&hairsp;BadMatch&hairsp;</emphasis>
error results.
If the property is undefined, 
it is treated as defined with the correct type and
format with zero-length data.</para>
  </listitem>
</itemizedlist>

<para>If the specified format is 8, the property data must be a
<emphasis remap='I'>&hairsp;char&hairsp;</emphasis>
array.
If the specified format is 16, the property data must be a
<emphasis remap='I'>&hairsp;short&hairsp;</emphasis>
array.
If the specified format is 32, the property data must be a
<emphasis remap='I'>&hairsp;long&hairsp;</emphasis>
array.</para>

<para>The lifetime of a property is not tied to the storing client.
Properties remain until explicitly deleted, until the window is destroyed,
or until the server resets.
For a discussion of what happens when the connection to the X server is closed,
see section 2.6. 
The maximum size of a property is server dependent and can vary dynamically
depending on the amount of memory the server has available.
(If there is insufficient space, a
<emphasis remap='I'>&hairsp;BadAlloc&hairsp;</emphasis>
error results.)</para>

<para><emphasis remap='I'>&hairsp;XChangeProperty&hairsp;</emphasis>
can generate
<emphasis remap='I'>&hairsp;BadAlloc&hairsp;</emphasis>,
<emphasis remap='I'>&hairsp;BadAtom&hairsp;</emphasis>,
<emphasis remap='I'>&hairsp;BadMatch&hairsp;</emphasis>,
<emphasis remap='I'>&hairsp;BadValue&hairsp;</emphasis>,
and
<emphasis remap='I'>&hairsp;BadWindow&hairsp;</emphasis>
errors.</para>

<para>The
<emphasis remap='I'>&hairsp;XRotateWindowProperties&hairsp;</emphasis>
function allows you to rotate properties on a window and causes
the X server to generate
<emphasis remap='I'>&hairsp;PropertyNotify&hairsp;</emphasis>
events.
If the property names in the properties array are viewed as being numbered 
starting from zero and if there are num_prop property names in the list,
then the value associated with property name I becomes the value associated 
with property name (I + npositions) mod N for all I from zero to N - 1.
The effect is to rotate the states by npositions places around the virtual ring
of property names (right for positive npositions, 
left for negative npositions).
If npositions mod N is nonzero,
the X server generates a
<emphasis remap='I'>&hairsp;PropertyNotify&hairsp;</emphasis>
event for each property in the order that they are listed in the array.
If an atom occurs more than once in the list or no property with that 
name is defined for the window,
a 
<emphasis remap='I'>&hairsp;BadMatch&hairsp;</emphasis>
error results.
If a 
<emphasis remap='I'>&hairsp;BadAtom&hairsp;</emphasis>
or 
<emphasis remap='I'>&hairsp;BadMatch&hairsp;</emphasis>
error results,
no properties are changed.</para>

<para><emphasis remap='I'>&hairsp;XRotateWindowProperties&hairsp;</emphasis>
can generate
<emphasis remap='I'>&hairsp;BadAtom&hairsp;</emphasis>,
<emphasis remap='I'>&hairsp;BadMatch&hairsp;</emphasis>,
and
<emphasis remap='I'>&hairsp;BadWindow&hairsp;</emphasis>
errors.</para>

<para>The
<emphasis remap='I'>&hairsp;XDeleteProperty&hairsp;</emphasis>
function deletes the specified property only if the
property was defined on the specified window
and causes the X server to generate a
<emphasis remap='I'>&hairsp;PropertyNotify&hairsp;</emphasis>
event on the window unless the property does not exist.</para>

<para><emphasis remap='I'>&hairsp;XDeleteProperty&hairsp;</emphasis>
can generate
<emphasis remap='I'>&hairsp;BadAtom&hairsp;</emphasis>
and
<emphasis remap='I'>&hairsp;BadWindow&hairsp;</emphasis>
errors.</para>
</refsect1>

<refsect1 id='diagnostics'><title>DIAGNOSTICS</title>
<variablelist remap='TP'>
  <varlistentry>
  <term><emphasis remap='I'>&hairsp;BadAlloc&hairsp;</emphasis></term>
  <listitem>
<para>The server failed to allocate the requested resource or server memory.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>&hairsp;BadAtom&hairsp;</emphasis></term>
  <listitem>
<para>A value for an Atom argument does not name a defined Atom.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>&hairsp;BadValue&hairsp;</emphasis></term>
  <listitem>
<para>Some numeric value falls outside the range of values accepted by the request.
Unless a specific range is specified for an argument, the full range defined
by the argument's type is accepted.  Any argument defined as a set of
alternatives can generate this error.</para>
  </listitem>
  </varlistentry>
  <varlistentry>
  <term><emphasis remap='I'>&hairsp;BadWindow&hairsp;</emphasis></term>
  <listitem>
<para>A value for a Window argument does not name a defined Window.</para>
  </listitem>
  </varlistentry>
</variablelist>
</refsect1>

<refsect1 id='see_also'><title>SEE ALSO</title>
<para>XFree(3X11),
XInternAtom(3X11)
<!-- .br -->
<userinput>Xlib - C Language X Interface</userinput></para>
</refsect1>
</refentry>

