---
name: "XGetWindowAttributes"
section: "3x"
platform: "linux"
package: "libx11-dev"
version: "4.3.0.dfsg.1-14sarge7"
release: "Debian 3.1 (Sarge)"
platforms: ["linux"]
url: "https://new.carta.tech/XGetWindowAttributes/3x"
---

# XGetWindowAttributes(3x)

get current window attribute or geometry and current window attributes structure

## NAME

XGetWindowAttributes, XGetGeometry, XWindowAttributes - get current window attribute or geometry and current window attributes structure

## SYNTAX

Status XGetWindowAttributes(Display \**display*, Window *w*, XWindowAttributes \**window\_attributes\_return*);

Status XGetGeometry(Display \**display*, Drawable *d*, Window \**root\_return*, int \**x\_return*, int \**y\_return*, unsigned int \**width\_return*, unsigned int \**height\_return*, unsigned int \**border\_width\_return*, unsigned int \**depth\_return*);

## ARGUMENTS

- *border\_width\_return*

  Returns the border width in pixels.

- *d*

  Specifies the drawable, which can be a window or a pixmap.

- *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.

- *w*

  Specifies the window whose current attributes you want to obtain.

- *width\_return*

  - *height\_return*

  Return the drawable's dimensions (width and height).

- *window\_attributes\_return*

  Returns the specified window's attributes in the *XWindowAttributes* structure.

- *x\_return*

  - *y\_return*

  Return the x and y coordinates that define the location of the drawable. For a window,  these coordinates specify the upper-left outer corner relative to its parent's origin. For pixmaps, these coordinates are always zero.

## DESCRIPTION

The *XGetWindowAttributes* function returns the current attributes for the specified window to an *XWindowAttributes* structure.

*XGetWindowAttributes* can generate *BadDrawable* and *BadWindow* errors.

The *XGetGeometry* function returns the root window 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. These are described in the argument list. It is legal to pass to this function a window whose class is *InputOnly*.

## STRUCTURES

The *XWindowAttributes* structure contains:

```
typedef struct {
	int x, y;
	int width, height;
	int border_width;
	int depth;
	Visual *visual;
	Window root;
	int class;
	int bit_gravity;
	int win_gravity;
	int backing_store;
	unsigned long backing_planes;
	unsigned long backing_pixel;
	Bool save_under;
	Colormap colormap;
	Bool map_installed;
	int map_state;
	long all_event_masks;
	long your_event_mask;
	long do_not_propagate_mask;
	Bool override_redirect;
	Screen *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 object). The visual member is a pointer to the screen's associated *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 *InputOutput* or *InputOnly*.

The bit\_gravity member is set to the window's bit gravity and can be one of the following:

| | |
| --- | --- |
|  |  |
|  |  |
|  |  |
|  |  |
|  |  |

The win\_gravity member is set to the window's window gravity and can be one of the following:

| | |
| --- | --- |
|  |  |
|  |  |
|  |  |
|  |  |
|  |  |

For additional information on gravity, see section 3.3.

The backing\_store member is set to indicate how the X server should maintain the contents of a window  and can be  *WhenMapped*, *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 ancestor 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 fields to see which field matches.

## DIAGNOSTICS

- *BadDrawable*

  A value for a Drawable argument does not name a defined Window or Pixmap.

- *BadWindow*

  A value for a Window argument does not name a defined Window.

## SEE ALSO

XQueryPointer(3X11), XQueryTree(3X11)\
 *Xlib - C Language X Interface*
