XGetWindowAttributes(3X) XGetWindowAttributes(3X)NAME XGetWindowAttributes, XGetGeometry - get current window attributes and geometry and manipulate the XWindowAttributes structure SYNOPSIS Status XGetWindowAttributes (display, w, window-attributes-return) Display *display; Window w; XWindowAttributes *window-attributes-return; Status XGetGeometry (display, d, root-return, x-return, y-return, width-return, height-return, border-width-return, depth-return) Display *display; Drawable d; Window *root-return; int *x-return, *y-return; unsigned int *width-return, *height-return; unsigned int *border-width-return; unsigned int *depth-return; DESCRIPTION The XGetWindowAttributes function returns the current attri- butes for the specified window to an XWindowAttributes structure. The XGetGeometry function returns the background (root) win- dow ID and the current geometry of the drawable. The geometry of the drawable includes the x and y coordinates, width and height, border width, and depth. It is legal to pass to this function a window whose class is InputOnly. Arguments These functions accept the following arguments: border-width-return Returns the border width in pixels. d Specifies the drawable, which can be a window or a pixel map. depth-return Returns the depth of the drawable (bits per pixel for the object). display Specifies the connection to the X server. root-return Returns the root window ID for the specified window. November, 1990 1
XGetWindowAttributes(3X) XGetWindowAttributes(3X)w Specifies the window ID whose current attributes you want to obtain. width-return, height-return Return the drawable's width and height dimensions. window-attributes-return Returns the specified window's attributes in the XWindowAttributes structure. x-return, y-return Return the x and y coordinates of the drawable. These coordinates define the location of the draw- able. For a window, these coordinates specify the upper-left outer corner relative to its parent's origin. For pixel maps, these coordinates are al- ways zero. Structures The XWindowAttributes structure is defined as follows. 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 the 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 pre- */ /* served 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 asso- */ /* ciated with window */ Bool map_installed;/* boolean, is */ /* colormap currently */ /* installed */ 2 November, 1990
XGetWindowAttributes(3X) XGetWindowAttributes(3X)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; /* back pointer to */ /* correct screen */ } XWindowAttributes; The x and y members are set to the upper-left outer corner relative to the parent window's origin. The width and height members are set to the inside size of the window, not including the border. The border_width member is set to the window's border width in pixels. The depth member is set to the depth of the window (that is, bits per pixel for the ob- ject). The visual member is a pointer to the screen's asso- ciated Visual structure. The root member is set to the root window of the screen containing the window. The class member is set to the window's class and can be either Inpu- tOutput or InputOnly. The bit_gravity member is set to the window's bit gravity and can be one of the following: CenterGravity SouthEastGravity EastGravity SouthGravity ForgetGravity SouthWestGravity NorthEastGravity StaticGravity NorthGravity WestGravity NorthWestGravity The win_gravity member is set to the window's window gravity and can be one of the following: CenterGravity SouthGravity EastGravity SoutWestGravity NorthEastGravity StaticGravity NorthGravity UnmapGravity NorthWestGravity WestGravity SouthEastGravity For additional information on gravity, see Section 3.3 of Xlib - C Language Interface. November, 1990 3
XGetWindowAttributes(3X) XGetWindowAttributes(3X)The backing_store member is set to indicate how the X server should maintain the contents of a window and can be When- Mapped, Always, or NotUseful. The backing_planes member is set to indicate (with bits set to 1) which bit planes of the window hold dynamic data that must be preserved in backing stores and during save unders. The backing_pixel member is set to indicate what values to use for planes not set in backing planes. The save_under member is set to TRUE or FALSE. The colormap member is set to the colormap for the specified window and can be a colormap ID or None. The map_installed member is set to indicate whether the colormap is currently installed and can be TRUE or FALSE. The map_state member is set to indicate the state of the window and can be IsUnmapped, IsUnviewable, or IsViewable. IsUnviewable is used if the window is mapped but some ances- tor is unmapped. The all_event_masks member is set to the bitwise inclusive OR of all event masks selected on the window by all clients. The your_event_mask member is set to the bitwise inclusive OR of all event masks selected by the querying client. The do_not_propagate_mask member is set to the bitwise inclusive OR of the set of events that should not propagate. The override_redirect member is set to indicate whether this window overrides structure control facilities and can be TRUE or FALSE. Window manager clients should ignore the window if this member is TRUE. The screen member is set to a screen pointer that gives you a back pointer to the correct screen. This makes it easier to obtain the screen information without having to loop over the root window members to see which member matches. ERRORS BadDrawable A value for a Drawable argument does not name a de- fined window or pixel map. BadWindow A value for a Window argument does not name a de- fined window. The XGetWindowAttributes can generate BadDrawable and BadWindow errors. The XGetGeometry function can generate a BadDrawable error. 4 November, 1990
XGetWindowAttributes(3X) XGetWindowAttributes(3X)SEE ALSO XQueryPointer(3X), XQueryTree(3X)Xlib - C Language InterfaceNovember, 1990 5