XGetWindowAttributes()XGetWindowAttributes()NameXGetWindowAttributes – obtain the current attributes of window.
Synopsis
Status XGetWindowAttributes(display, w, window_attributes_return)
Display *display;
Window w;
XWindowAttributes *window_attributes_return;
Arguments
display Specifies a connection to an X server; returned from XOpenDis‐
play().
w Specifies the window whose current attributes you want.
window_attributes_return
Returns a filled XWindowAttributes structure, containing the
current attributes for the specified window.
Returns
Zero on failure, non-zero on success.
DescriptionXGetWindowAttributes() returns the XWindowAttributes structure contain‐
ing the current window attributes.
XGetWindowAttributes() returns a Status of zero on failure, or non-zero
on success. However, it will only return zero if you have defined an
error handler that does not exit, using XSetErrorHandler(). The
default error handler exits, and therefore XGetWindowAttributes() never
gets a chance to return. (Such error handling is relevant only if you
are writing a window manager or other application that deals with win‐
dows that might have been destroyed.)
The following list briefly describes each member of the XWindowAt‐
tributes structure. For more information, see Volume One, Chapter 4,
Window Attributes.
x, y The current position of the upper-left pixel of the window's
border, relative to the origin of its parent.
width, height
The current dimensions in pixels of this window, not includ‐
ing the border.
border_width
The current border width of the window.
depth The number of bits per pixel in this window.
visual The visual structure.
root The root window ID of the screen containing the window.
class The window class. One of these constants: InputOutput or
InputOnly.
bit_gravity
The new position for existing contents after resize. One of
the constants ForgetGravity, StaticGravity, or CenterGrav‐
ity, or one of the compass constants (NorthWestGravity,
NorthGravity, etc.).
win_gravity
The new position for this window after its parent is
resized. One of the constants CenterGravity, UnmapGravity,
StaticGravity, or one of the compass constants.
backing_store
When to maintain contents of the window. One of these con‐
stants: NotUseful, WhenMapped, or Always.
backing_planes
The bit planes to be preserved in a backing store.
backing_pixel
The pixel value used when restoring planes from a partial
backing store.
save_under A boolean value, indicating whether saving bits under this
window would be useful.
colormap The colormap ID being used in this window, or None.
map_installed
A boolean value, indicating whether the colormap is cur‐
rently installed. If True, the window is being displayed in
its chosen colors.
map_state The window's map state. One of these constants: IsUnmapped,
IsUnviewable, or IsViewable. IsUnviewable indicates that
the specified window is mapped but some ancestor is
unmapped.
all_event_masks
The set of events any client have selected. This member is
the bitwise inclusive OR of all event masks selected on the
window by all clients.
your_event_mask
The bitwise inclusive OR of all event mask symbols selected
by the querying client.
do_not_propagate_mask
The bitwise inclusive OR of the event mask symbols that
specify the set of events that should not propagate. This
is global across all clients.
override_redirect
A boolean value, indicating whether this window will over‐
ride structure control facilities. This is usually only
used for temporary pop-up windows such as menus. Either
True or False.
screen A pointer to the Screen structure for the screen containing
this window.
Errors
BadDrawable
BadWindow
Structures
The XWindowAttributes structure contains:
typedef struct {
int x, y; /* location of window */
int width, height; /* width and height of window */
int border_width; /* border width of window */
int depth; /* depth of window */
Visual *visual; /* the associated visual structure */
Window root; /* root of screen containing window */
int class; /* InputOutput, InputOnly*/
int bit_gravity; /* one of bit gravity values */
int win_gravity; /* one of the window gravity values */
int backing_store; /* NotUseful, WhenMapped, Always */
unsigned long backing_planes; /* planes to be preserved if possible */
unsigned long backing_pixel; /* value to be used when restoring planes */
Bool save_under; /* boolean, should bits under be saved */
Colormap colormap; /* colormap to be associated with window */
Bool map_installed; /* boolean, is colormap currently
installed */
int map_state; /* IsUnmapped, IsUnviewable, IsViewable */
long all_event_masks; /* set of events all people have interest
in */
long your_event_mask; /* my event mask */
long do_not_propagate_mask; /* set of events that should not
propagate */
Bool override_redirect; /* boolean value for override-redirect */
Screen *screen; /* pointer to correct screen */
} XWindowAttributes;
See AlsoXChangeWindowAttributes(), XGetGeometry(), XSetWindowBackground(),
XSetWindowBackgroundPixmap(), XSetWindowBorder(), XSetWindowBorder‐
Pixmap().
Xlib - Window Attributes XGetWindowAttributes()