Gdk.Window

g GObject.Object GObject.Object Gdk.Window Gdk.Window GObject.Object->Gdk.Window

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

at_pointer ()

class

constrain_size (geometry, flags, width, height)

class

new (parent, attributes, attributes_mask)

class

process_all_updates ()

class

set_debug_updates (setting)

beep ()

begin_draw_frame (region)

begin_move_drag (button, root_x, root_y, timestamp)

begin_move_drag_for_device (device, button, root_x, root_y, timestamp)

begin_paint_rect (rectangle)

begin_paint_region (region)

begin_resize_drag (edge, button, root_x, root_y, timestamp)

begin_resize_drag_for_device (edge, device, button, root_x, root_y, timestamp)

cairo_create ()

configure_finished ()

coords_from_parent (parent_x, parent_y)

coords_to_parent (x, y)

create_gl_context ()

create_similar_image_surface (format, width, height, scale)

create_similar_surface (content, width, height)

deiconify ()

destroy ()

destroy_notify ()

enable_synchronized_configure ()

end_draw_frame (context)

end_paint ()

ensure_native ()

flush ()

focus (timestamp)

freeze_toplevel_updates_libgtk_only ()

freeze_updates ()

fullscreen ()

fullscreen_on_monitor (monitor)

geometry_changed ()

get_accept_focus ()

get_background_pattern ()

get_children ()

get_children_with_user_data (user_data)

get_clip_region ()

get_composited ()

get_cursor ()

get_decorations ()

get_device_cursor (device)

get_device_events (device)

get_device_position (device)

get_device_position_double (device)

get_display ()

get_drag_protocol ()

get_effective_parent ()

get_effective_toplevel ()

get_event_compression ()

get_events ()

get_focus_on_map ()

get_frame_clock ()

get_frame_extents ()

get_fullscreen_mode ()

get_geometry ()

get_group ()

get_height ()

get_modal_hint ()

get_origin ()

get_parent ()

get_pass_through ()

get_pointer ()

get_position ()

get_root_coords (x, y)

get_root_origin ()

get_scale_factor ()

get_screen ()

get_source_events (source)

get_state ()

get_support_multidevice ()

get_toplevel ()

get_type_hint ()

get_update_area ()

get_user_data ()

get_visible_region ()

get_visual ()

get_width ()

get_window_type ()

has_native ()

hide ()

iconify ()

input_shape_combine_region (shape_region, offset_x, offset_y)

invalidate_maybe_recurse (region, child_func, *user_data)

invalidate_rect (rect, invalidate_children)

invalidate_region (region, invalidate_children)

is_destroyed ()

is_input_only ()

is_shaped ()

is_viewable ()

is_visible ()

lower ()

mark_paint_from_clip (cr)

maximize ()

merge_child_input_shapes ()

merge_child_shapes ()

move (x, y)

move_region (region, dx, dy)

move_resize (x, y, width, height)

move_to_rect (rect, rect_anchor, window_anchor, anchor_hints, rect_anchor_dx, rect_anchor_dy)

peek_children ()

process_updates (update_children)

raise_ ()

register_dnd ()

reparent (new_parent, x, y)

resize (width, height)

restack (sibling, above)

scroll (dx, dy)

set_accept_focus (accept_focus)

set_background (color)

set_background_pattern (pattern)

set_background_rgba (rgba)

set_child_input_shapes ()

set_child_shapes ()

set_composited (composited)

set_cursor (cursor)

set_decorations (decorations)

set_device_cursor (device, cursor)

set_device_events (device, event_mask)

set_event_compression (event_compression)

set_events (event_mask)

set_focus_on_map (focus_on_map)

set_fullscreen_mode (mode)

set_functions (functions)

set_geometry_hints (geometry, geom_mask)

set_group (leader)

set_icon_list (pixbufs)

set_icon_name (name)

set_keep_above (setting)

set_keep_below (setting)

set_modal_hint (modal)

set_opacity (opacity)

set_opaque_region (region)

set_override_redirect (override_redirect)

set_pass_through (pass_through)

set_role (role)

set_shadow_width (left, right, top, bottom)

set_skip_pager_hint (skips_pager)

set_skip_taskbar_hint (skips_taskbar)

set_source_events (source, event_mask)

set_startup_id (startup_id)

set_static_gravities (use_static)

set_support_multidevice (support_multidevice)

set_title (title)

set_transient_for (parent)

set_type_hint (hint)

set_urgency_hint (urgent)

set_user_data (user_data)

shape_combine_region (shape_region, offset_x, offset_y)

show ()

show_unraised ()

show_window_menu (event)

stick ()

thaw_toplevel_updates_libgtk_only ()

thaw_updates ()

unfullscreen ()

unmaximize ()

unstick ()

withdraw ()

Virtual Methods

Inherited:

GObject.Object (7)

do_create_surface (width, height)

do_from_embedder (embedder_x, embedder_y, offscreen_x, offscreen_y)

do_to_embedder (offscreen_x, offscreen_y, embedder_x, embedder_y)

Properties

Name

Type

Flags

Short Description

cursor

Gdk.Cursor

r/w

Cursor

Signals

Inherited:

GObject.Object (1)

Name

Short Description

create-surface

The ::create-surface signal is emitted when an offscreen window needs its surface (re)created, which happens either when the window is first drawn to, or when the window is being resized.

from-embedder

The ::from-embedder signal is emitted to translate coordinates in the embedder of an offscreen window to the offscreen window.

moved-to-rect

Emitted when the position of window is finalized after being moved to a destination rectangle.

pick-embedded-child

The ::pick-embedded-child signal is emitted to find an embedded child at the given position.

to-embedder

The ::to-embedder signal is emitted to translate coordinates in an offscreen window to its embedder.

Fields

Inherited:

GObject.Object (1)

Class Details

class Gdk.Window(parent, attributes, attributes_mask)
Bases:

GObject.Object

Abstract:

Yes

Structure:

Gdk.WindowClass

classmethod at_pointer()[source]
Returns:

window under the mouse pointer

win_x:

return location for origin of the window under the pointer

win_y:

return location for origin of the window under the pointer

Return type:

(Gdk.Window, win_x: int, win_y: int)

Obtains the window underneath the mouse pointer, returning the location of that window in win_x, win_y. Returns None if the window under the mouse pointer is not known to GDK (if the window belongs to another application and a Gdk.Window hasn’t been created for it with gdk_window_foreign_new())

NOTE: For multihead-aware widgets or applications use Gdk.Display.get_window_at_pointer() instead.

Deprecated since version 3.0: Use Gdk.Device.get_window_at_position() instead.

classmethod constrain_size(geometry, flags, width, height)[source]
Parameters:
Returns:

new_width:

location to store resulting width

new_height:

location to store resulting height

Return type:

(new_width: int, new_height: int)

Constrains a desired width and height according to a set of geometry hints (such as minimum and maximum size).

classmethod new(parent, attributes, attributes_mask)[source]
Parameters:
Returns:

the new Gdk.Window

Return type:

Gdk.Window

Creates a new Gdk.Window using the attributes from attributes. See Gdk.WindowAttr and Gdk.WindowAttributesType for more details. Note: to use this on displays other than the default display, parent must be specified.

classmethod process_all_updates()[source]

Calls Gdk.Window.process_updates() for all windows (see Gdk.Window) in the application.

Deprecated since version 3.22.

classmethod set_debug_updates(setting)[source]
Parameters:

setting (bool) – True to turn on update debugging

With update debugging enabled, calls to Gdk.Window.invalidate_region() clear the invalidated region of the screen to a noticeable color, and GDK pauses for a short time before sending exposes to windows during Gdk.Window.process_updates(). The net effect is that you can see the invalid region for each window and watch redraws as they occur. This allows you to diagnose inefficiencies in your application.

In essence, because the GDK rendering model prevents all flicker, if you are redrawing the same region 400 times you may never notice, aside from noticing a speed problem. Enabling update debugging causes GTK to flicker slowly and noticeably, so you can see exactly what’s being redrawn when, in what order.

The –gtk-debug=updates command line option passed to GTK+ programs enables this debug option at application startup time. That’s usually more useful than calling Gdk.Window.set_debug_updates() yourself, though you might want to use this function to enable updates sometime after application startup time.

Deprecated since version 3.22.

beep()[source]

Emits a short beep associated to self in the appropriate display, if supported. Otherwise, emits a short beep on the display just as Gdk.Display.beep().

New in version 2.12.

begin_draw_frame(region)[source]
Parameters:

region (cairo.Region) – a Cairo region

Returns:

a Gdk.DrawingContext context that should be used to draw the contents of the window; the returned context is owned by GDK.

Return type:

Gdk.DrawingContext

Indicates that you are beginning the process of redrawing region on self, and provides you with a Gdk.DrawingContext.

If self is a top level Gdk.Window, backed by a native window implementation, a backing store (offscreen buffer) large enough to contain region will be created. The backing store will be initialized with the background color or background surface for self. Then, all drawing operations performed on self will be diverted to the backing store. When you call gdk_window_end_frame(), the contents of the backing store will be copied to self, making it visible on screen. Only the part of self contained in region will be modified; that is, drawing operations are clipped to region.

The net result of all this is to remove flicker, because the user sees the finished product appear all at once when you call Gdk.Window.end_draw_frame(). If you draw to self directly without calling Gdk.Window.begin_draw_frame(), the user may see flicker as individual drawing operations are performed in sequence.

When using GTK+, the widget system automatically places calls to Gdk.Window.begin_draw_frame() and Gdk.Window.end_draw_frame() around emissions of the GtkWidget::draw signal. That is, if you’re drawing the contents of the widget yourself, you can assume that the widget has a cleared background, is already set as the clip region, and already has a backing store. Therefore in most cases, application code in GTK does not need to call Gdk.Window.begin_draw_frame() explicitly.

New in version 3.22.

begin_move_drag(button, root_x, root_y, timestamp)[source]
Parameters:
  • button (int) – the button being used to drag, or 0 for a keyboard-initiated drag

  • root_x (int) – root window X coordinate of mouse click that began the drag

  • root_y (int) – root window Y coordinate of mouse click that began the drag

  • timestamp (int) – timestamp of mouse click that began the drag

Begins a window move operation (for a toplevel window).

This function assumes that the drag is controlled by the client pointer device, use Gdk.Window.begin_move_drag_for_device() to begin a drag with a different device.

begin_move_drag_for_device(device, button, root_x, root_y, timestamp)[source]
Parameters:
  • device (Gdk.Device) – the device used for the operation

  • button (int) – the button being used to drag, or 0 for a keyboard-initiated drag

  • root_x (int) – root window X coordinate of mouse click that began the drag

  • root_y (int) – root window Y coordinate of mouse click that began the drag

  • timestamp (int) – timestamp of mouse click that began the drag

Begins a window move operation (for a toplevel window). You might use this function to implement a “window move grip,” for example. The function works best with window managers that support the Extended Window Manager Hints but has a fallback implementation for other window managers.

New in version 3.4.

begin_paint_rect(rectangle)[source]
Parameters:

rectangle (Gdk.Rectangle) – rectangle you intend to draw to

A convenience wrapper around Gdk.Window.begin_paint_region() which creates a rectangular region for you. See Gdk.Window.begin_paint_region() for details.

Deprecated since version 3.22: Use Gdk.Window.begin_draw_frame() instead

begin_paint_region(region)[source]
Parameters:

region (cairo.Region) – region you intend to draw to

Indicates that you are beginning the process of redrawing region. A backing store (offscreen buffer) large enough to contain region will be created. The backing store will be initialized with the background color or background surface for self. Then, all drawing operations performed on self will be diverted to the backing store. When you call Gdk.Window.end_paint(), the backing store will be copied to self, making it visible onscreen. Only the part of self contained in region will be modified; that is, drawing operations are clipped to region.

The net result of all this is to remove flicker, because the user sees the finished product appear all at once when you call Gdk.Window.end_paint(). If you draw to self directly without calling Gdk.Window.begin_paint_region(), the user may see flicker as individual drawing operations are performed in sequence. The clipping and background-initializing features of Gdk.Window.begin_paint_region() are conveniences for the programmer, so you can avoid doing that work yourself.

When using GTK+, the widget system automatically places calls to Gdk.Window.begin_paint_region() and Gdk.Window.end_paint() around emissions of the expose_event signal. That is, if you’re writing an expose event handler, you can assume that the exposed area in Gdk.EventExpose has already been cleared to the window background, is already set as the clip region, and already has a backing store. Therefore in most cases, application code need not call Gdk.Window.begin_paint_region(). (You can disable the automatic calls around expose events on a widget-by-widget basis by calling gtk_widget_set_double_buffered().)

If you call this function multiple times before calling the matching Gdk.Window.end_paint(), the backing stores are pushed onto a stack. Gdk.Window.end_paint() copies the topmost backing store onscreen, subtracts the topmost region from all other regions in the stack, and pops the stack. All drawing operations affect only the topmost backing store in the stack. One matching call to Gdk.Window.end_paint() is required for each call to Gdk.Window.begin_paint_region().

Deprecated since version 3.22: Use Gdk.Window.begin_draw_frame() instead

begin_resize_drag(edge, button, root_x, root_y, timestamp)[source]
Parameters:
  • edge (Gdk.WindowEdge) – the edge or corner from which the drag is started

  • button (int) – the button being used to drag, or 0 for a keyboard-initiated drag

  • root_x (int) – root window X coordinate of mouse click that began the drag

  • root_y (int) – root window Y coordinate of mouse click that began the drag

  • timestamp (int) – timestamp of mouse click that began the drag (use Gdk.Event.get_time())

Begins a window resize operation (for a toplevel window).

This function assumes that the drag is controlled by the client pointer device, use Gdk.Window.begin_resize_drag_for_device() to begin a drag with a different device.

begin_resize_drag_for_device(edge, device, button, root_x, root_y, timestamp)[source]
Parameters:
  • edge (Gdk.WindowEdge) – the edge or corner from which the drag is started

  • device (Gdk.Device) – the device used for the operation

  • button (int) – the button being used to drag, or 0 for a keyboard-initiated drag

  • root_x (int) – root window X coordinate of mouse click that began the drag

  • root_y (int) – root window Y coordinate of mouse click that began the drag

  • timestamp (int) – timestamp of mouse click that began the drag (use Gdk.Event.get_time())

Begins a window resize operation (for a toplevel window). You might use this function to implement a “window resize grip,” for example; in fact #GtkStatusbar uses it. The function works best with window managers that support the Extended Window Manager Hints but has a fallback implementation for other window managers.

New in version 3.4.

cairo_create()
configure_finished()[source]

Does nothing, present only for compatiblity.

New in version 2.6.

Deprecated since version 3.8: this function is no longer needed

coords_from_parent(parent_x, parent_y)[source]
Parameters:
  • parent_x (float) – X coordinate in parent’s coordinate system

  • parent_y (float) – Y coordinate in parent’s coordinate system

Returns:

x:

return location for X coordinate in child’s coordinate system

y:

return location for Y coordinate in child’s coordinate system

Return type:

(x: float, y: float)

Transforms window coordinates from a parent window to a child window, where the parent window is the normal parent as returned by Gdk.Window.get_parent() for normal windows, and the window’s embedder as returned by Gdk.offscreen_window_get_embedder() for offscreen windows.

For normal windows, calling this function is equivalent to subtracting the return values of Gdk.Window.get_position() from the parent coordinates. For offscreen windows however (which can be arbitrarily transformed), this function calls the Gdk.Window ::from-embedder: signal to translate the coordinates.

You should always use this function when writing generic code that walks down a window hierarchy.

See also: Gdk.Window.coords_to_parent()

New in version 2.22.

coords_to_parent(x, y)[source]
Parameters:
  • x (float) – X coordinate in child’s coordinate system

  • y (float) – Y coordinate in child’s coordinate system

Returns:

parent_x:

return location for X coordinate in parent’s coordinate system, or None

parent_y:

return location for Y coordinate in parent’s coordinate system, or None

Return type:

(parent_x: float, parent_y: float)

Transforms window coordinates from a child window to its parent window, where the parent window is the normal parent as returned by Gdk.Window.get_parent() for normal windows, and the window’s embedder as returned by Gdk.offscreen_window_get_embedder() for offscreen windows.

For normal windows, calling this function is equivalent to adding the return values of Gdk.Window.get_position() to the child coordinates. For offscreen windows however (which can be arbitrarily transformed), this function calls the Gdk.Window ::to-embedder: signal to translate the coordinates.

You should always use this function when writing generic code that walks up a window hierarchy.

See also: Gdk.Window.coords_from_parent()

New in version 2.22.

create_gl_context()[source]
Raises:

GLib.Error

Returns:

the newly created Gdk.GLContext, or None on error

Return type:

Gdk.GLContext

Creates a new Gdk.GLContext matching the framebuffer format to the visual of the Gdk.Window. The context is disconnected from any particular window or surface.

If the creation of the Gdk.GLContext failed, error will be set.

Before using the returned Gdk.GLContext, you will need to call Gdk.GLContext.make_current() or Gdk.GLContext.realize().

New in version 3.16.

create_similar_image_surface(format, width, height, scale)[source]
Parameters:
  • format (cairo.Format) – the format for the new surface

  • width (int) – width of the new surface

  • height (int) – height of the new surface

  • scale (int) – the scale of the new surface, or 0 to use same as self

Returns:

a pointer to the newly allocated surface. The caller owns the surface and should call cairo_surface_destroy() when done with it.

This function always returns a valid pointer, but it will return a pointer to a “nil” surface if other is already in an error state or any other error occurs.

Return type:

cairo.Surface

Create a new image surface that is efficient to draw on the given self.

Initially the surface contents are all 0 (transparent if contents have transparency, black otherwise.)

The width and height of the new surface are not affected by the scaling factor of the self, or by the scale argument; they are the size of the surface in device pixels. If you wish to create an image surface capable of holding the contents of self you can use:

int scale = gdk_window_get_scale_factor (window);
int width = gdk_window_get_width (window) * scale;
int height = gdk_window_get_height (window) * scale;

// format is set elsewhere
cairo_surface_t *surface =
  gdk_window_create_similar_image_surface (window,
                                           format,
                                           width, height,
                                           scale);

Note that unlike cairo.Surface.create_similar_image(), the new surface’s device scale is set to scale, or to the scale factor of self if scale is 0.

New in version 3.10.

create_similar_surface(content, width, height)[source]
Parameters:
  • content (cairo.Content) – the content for the new surface

  • width (int) – width of the new surface

  • height (int) – height of the new surface

Returns:

a pointer to the newly allocated surface. The caller owns the surface and should call cairo_surface_destroy() when done with it.

This function always returns a valid pointer, but it will return a pointer to a “nil” surface if other is already in an error state or any other error occurs.

Return type:

cairo.Surface

Create a new surface that is as compatible as possible with the given self. For example the new surface will have the same fallback resolution and font options as self. Generally, the new surface will also use the same backend as self, unless that is not possible for some reason. The type of the returned surface may be examined with cairo_surface_get_type().

Initially the surface contents are all 0 (transparent if contents have transparency, black otherwise.)

New in version 2.22.

deiconify()[source]

Attempt to deiconify (unminimize) self. On X11 the window manager may choose to ignore the request to deiconify. When using GTK+, use gtk_window_deiconify() instead of the Gdk.Window variant. Or better yet, you probably want to use gtk_window_present_with_time(), which raises the window, focuses it, unminimizes it, and puts it on the current desktop.

destroy()[source]

Destroys the window system resources associated with self and decrements self's reference count. The window system resources for all children of self are also destroyed, but the children’s reference counts are not decremented.

Note that a window will not be destroyed automatically when its reference count reaches zero. You must call this function yourself before that happens.

destroy_notify()[source]
enable_synchronized_configure()[source]

Does nothing, present only for compatiblity.

New in version 2.6.

Deprecated since version 3.8: this function is no longer needed

end_draw_frame(context)[source]
Parameters:

context (Gdk.DrawingContext) – the Gdk.DrawingContext created by Gdk.Window.begin_draw_frame()

Indicates that the drawing of the contents of self started with gdk_window_begin_frame() has been completed.

This function will take care of destroying the Gdk.DrawingContext.

It is an error to call this function without a matching gdk_window_begin_frame() first.

New in version 3.22.

end_paint()[source]

Indicates that the backing store created by the most recent call to Gdk.Window.begin_paint_region() should be copied onscreen and deleted, leaving the next-most-recent backing store or no backing store at all as the active paint region. See Gdk.Window.begin_paint_region() for full details.

It is an error to call this function without a matching Gdk.Window.begin_paint_region() first.

ensure_native()[source]
Returns:

True if the window has a native window, False otherwise

Return type:

bool

Tries to ensure that there is a window-system native window for this Gdk.Window. This may fail in some situations, returning False.

Offscreen window and children of them can never have native windows.

Some backends may not support native child windows.

New in version 2.18.

flush()[source]

This function does nothing.

New in version 2.18.

Deprecated since version 3.14.

focus(timestamp)[source]
Parameters:

timestamp (int) – timestamp of the event triggering the window focus

Sets keyboard focus to self. In most cases, gtk_window_present_with_time() should be used on a #GtkWindow, rather than calling this function.

freeze_toplevel_updates_libgtk_only()[source]

Temporarily freezes a window and all its descendants such that it won’t receive expose events. The window will begin receiving expose events again when Gdk.Window.thaw_toplevel_updates_libgtk_only() is called. If Gdk.Window.freeze_toplevel_updates_libgtk_only() has been called more than once, Gdk.Window.thaw_toplevel_updates_libgtk_only() must be called an equal number of times to begin processing exposes.

This function is not part of the GDK public API and is only for use by GTK+.

Deprecated since version 3.16: This symbol was never meant to be used outside of GTK+

freeze_updates()[source]

Temporarily freezes a window such that it won’t receive expose events. The window will begin receiving expose events again when Gdk.Window.thaw_updates() is called. If Gdk.Window.freeze_updates() has been called more than once, Gdk.Window.thaw_updates() must be called an equal number of times to begin processing exposes.

fullscreen()[source]

Moves the window into fullscreen mode. This means the window covers the entire screen and is above any panels or task bars.

If the window was already fullscreen, then this function does nothing.

On X11, asks the window manager to put self in a fullscreen state, if the window manager supports this operation. Not all window managers support this, and some deliberately ignore it or don’t have a concept of “fullscreen”; so you can’t rely on the fullscreenification actually happening. But it will happen with most standard window managers, and GDK makes a best effort to get it to happen.

New in version 2.2.

fullscreen_on_monitor(monitor)[source]
Parameters:

monitor (int) – Which monitor to display fullscreen on.

Moves the window into fullscreen mode on the given monitor. This means the window covers the entire screen and is above any panels or task bars.

If the window was already fullscreen, then this function does nothing.

geometry_changed()[source]

This function informs GDK that the geometry of an embedded offscreen window has changed. This is necessary for GDK to keep track of which offscreen window the pointer is in.

New in version 2.18.

get_accept_focus()[source]
Returns:

whether or not the window should receive input focus.

Return type:

bool

Determines whether or not the desktop environment shuld be hinted that the window does not want to receive input focus.

New in version 2.22.

get_background_pattern()[source]
Returns:

The pattern to use for the background or None if there is no background.

Return type:

cairo.Pattern or None

Gets the pattern used to clear the background on self.

New in version 2.22.

Deprecated since version 3.22: Don’t use this function

get_children()[source]
Returns:

list of child windows inside self

Return type:

[Gdk.Window]

Gets the list of children of self known to GDK. This function only returns children created via GDK, so for example it’s useless when used with the root window; it only returns windows an application created itself.

The returned list must be freed, but the elements in the list need not be.

get_children_with_user_data(user_data)[source]
Parameters:

user_data (object or None) – user data to look for

Returns:

list of child windows inside self

Return type:

[Gdk.Window]

Gets the list of children of self known to GDK with a particular user_data set on it.

The returned list must be freed, but the elements in the list need not be.

The list is returned in (relative) stacking order, i.e. the lowest window is first.

New in version 3.10.

get_clip_region()[source]
Returns:

a cairo.Region. This must be freed with cairo_region_destroy() when you are done.

Return type:

cairo.Region

Computes the region of a window that potentially can be written to by drawing primitives. This region may not take into account other factors such as if the window is obscured by other windows, but no area outside of this region will be affected by drawing primitives.

get_composited()[source]
Returns:

True if the window is composited.

Return type:

bool

Determines whether self is composited.

See Gdk.Window.set_composited().

New in version 2.22.

Deprecated since version 3.16: Compositing is an outdated technology that only ever worked on X11.

get_cursor()[source]
Returns:

a Gdk.Cursor, or None. The returned object is owned by the Gdk.Window and should not be unreferenced directly. Use Gdk.Window.set_cursor() to unset the cursor of the window

Return type:

Gdk.Cursor or None

Retrieves a Gdk.Cursor pointer for the cursor currently set on the specified Gdk.Window, or None. If the return value is None then there is no custom cursor set on the specified window, and it is using the cursor for its parent window.

New in version 2.18.

get_decorations()[source]
Returns:

True if the window has decorations set, False otherwise.

decorations:

The window decorations will be written here

Return type:

(bool, decorations: Gdk.WMDecoration)

Returns the decorations set on the Gdk.Window with Gdk.Window.set_decorations().

get_device_cursor(device)[source]
Parameters:

device (Gdk.Device) – a master, pointer Gdk.Device.

Returns:

a Gdk.Cursor, or None. The returned object is owned by the Gdk.Window and should not be unreferenced directly. Use Gdk.Window.set_cursor() to unset the cursor of the window

Return type:

Gdk.Cursor or None

Retrieves a Gdk.Cursor pointer for the device currently set on the specified Gdk.Window, or None. If the return value is None then there is no custom cursor set on the specified window, and it is using the cursor for its parent window.

New in version 3.0.

get_device_events(device)[source]
Parameters:

device (Gdk.Device) – a Gdk.Device.

Returns:

device event mask for self

Return type:

Gdk.EventMask

Returns the event mask for self corresponding to an specific device.

New in version 3.0.

get_device_position(device)[source]
Parameters:

device (Gdk.Device) – pointer Gdk.Device to query to.

Returns:

The window underneath device (as with Gdk.Device.get_window_at_position()), or None if the window is not known to GDK.

x:

return location for the X coordinate of device, or None.

y:

return location for the Y coordinate of device, or None.

mask:

return location for the modifier mask, or None.

Return type:

(Gdk.Window or None, x: int, y: int, mask: Gdk.ModifierType)

Obtains the current device position and modifier state. The position is given in coordinates relative to the upper left corner of self.

Use Gdk.Window.get_device_position_double() if you need subpixel precision.

New in version 3.0.

get_device_position_double(device)[source]
Parameters:

device (Gdk.Device) – pointer Gdk.Device to query to.

Returns:

The window underneath device (as with Gdk.Device.get_window_at_position()), or None if the window is not known to GDK.

x:

return location for the X coordinate of device, or None.

y:

return location for the Y coordinate of device, or None.

mask:

return location for the modifier mask, or None.

Return type:

(Gdk.Window or None, x: float, y: float, mask: Gdk.ModifierType)

Obtains the current device position in doubles and modifier state. The position is given in coordinates relative to the upper left corner of self.

New in version 3.10.

get_display()[source]
Returns:

the Gdk.Display associated with self

Return type:

Gdk.Display

Gets the Gdk.Display associated with a Gdk.Window.

New in version 2.24.

get_drag_protocol()[source]
Returns:

the supported DND protocol.

target:

location of the window where the drop should happen. This may be self or a proxy window, or None if self does not support Drag and Drop.

Return type:

(Gdk.DragProtocol, target: Gdk.Window)

Finds out the DND protocol supported by a window.

New in version 3.0.

get_effective_parent()[source]
Returns:

effective parent of self

Return type:

Gdk.Window

Obtains the parent of self, as known to GDK. Works like Gdk.Window.get_parent() for normal windows, but returns the window’s embedder for offscreen windows.

See also: Gdk.offscreen_window_get_embedder()

New in version 2.22.

get_effective_toplevel()[source]
Returns:

the effective toplevel window containing self

Return type:

Gdk.Window

Gets the toplevel window that’s an ancestor of self.

Works like Gdk.Window.get_toplevel(), but treats an offscreen window’s embedder as its parent, using Gdk.Window.get_effective_parent().

See also: Gdk.offscreen_window_get_embedder()

New in version 2.22.

get_event_compression()[source]
Returns:

True if motion events will be compressed

Return type:

bool

Get the current event compression setting for this window.

New in version 3.12.

get_events()[source]
Returns:

event mask for self

Return type:

Gdk.EventMask

Gets the event mask for self for all master input devices. See Gdk.Window.set_events().

get_focus_on_map()[source]
Returns:

whether or not the window wants to receive input focus when it is mapped.

Return type:

bool

Determines whether or not the desktop environment should be hinted that the window does not want to receive input focus when it is mapped.

New in version 2.22.

get_frame_clock()[source]
Returns:

the frame clock

Return type:

Gdk.FrameClock

Gets the frame clock for the window. The frame clock for a window never changes unless the window is reparented to a new toplevel window.

New in version 3.8.

get_frame_extents()[source]
Returns:

rectangle to fill with bounding box of the window frame

Return type:

rect: Gdk.Rectangle

Obtains the bounding box of the window, including window manager titlebar/borders if any. The frame position is given in root window coordinates. To get the position of the window itself (rather than the frame) in root window coordinates, use Gdk.Window.get_origin().

get_fullscreen_mode()[source]
Returns:

The Gdk.FullscreenMode applied to the window when fullscreen.

Return type:

Gdk.FullscreenMode

Obtains the Gdk.FullscreenMode of the self.

New in version 3.8.

get_geometry()[source]
Returns:

x:

return location for X coordinate of window (relative to its parent)

y:

return location for Y coordinate of window (relative to its parent)

width:

return location for width of window

height:

return location for height of window

Return type:

(x: int, y: int, width: int, height: int)

Any of the return location arguments to this function may be None, if you aren’t interested in getting the value of that field.

The X and Y coordinates returned are relative to the parent window of self, which for toplevels usually means relative to the window decorations (titlebar, etc.) rather than relative to the root window (screen-size background window).

On the X11 platform, the geometry is obtained from the X server, so reflects the latest position of self; this may be out-of-sync with the position of self delivered in the most-recently-processed Gdk.EventConfigure. Gdk.Window.get_position() in contrast gets the position from the most recent configure event.

Note: If self is not a toplevel, it is much better to call Gdk.Window.get_position(), Gdk.Window.get_width() and Gdk.Window.get_height() instead, because it avoids the roundtrip to the X server and because these functions support the full 32-bit coordinate space, whereas Gdk.Window.get_geometry() is restricted to the 16-bit coordinates of X11.

get_group()[source]
Returns:

the group leader window for self

Return type:

Gdk.Window

Returns the group leader window for self. See Gdk.Window.set_group().

New in version 2.4.

get_height()[source]
Returns:

The height of self

Return type:

int

Returns the height of the given self.

On the X11 platform the returned size is the size reported in the most-recently-processed configure event, rather than the current size on the X server.

New in version 2.24.

get_modal_hint()[source]
Returns:

whether or not the window has the modal hint set.

Return type:

bool

Determines whether or not the window manager is hinted that self has modal behaviour.

New in version 2.22.

get_origin()[source]
Returns:

not meaningful, ignore

x:

return location for X coordinate

y:

return location for Y coordinate

Return type:

(int, x: int, y: int)

Obtains the position of a window in root window coordinates. (Compare with Gdk.Window.get_position() and Gdk.Window.get_geometry() which return the position of a window relative to its parent window.)

get_parent()[source]
Returns:

parent of self

Return type:

Gdk.Window

Obtains the parent of self, as known to GDK. Does not query the X server; thus this returns the parent as passed to Gdk.Window.new(), not the actual parent. This should never matter unless you’re using Xlib calls mixed with GDK calls on the X11 platform. It may also matter for toplevel windows, because the window manager may choose to reparent them.

Note that you should use Gdk.Window.get_effective_parent() when writing generic code that walks up a window hierarchy, because Gdk.Window.get_parent() will most likely not do what you expect if there are offscreen windows in the hierarchy.

get_pass_through()[source]
Return type:

bool

Returns whether input to the window is passed through to the window below.

See Gdk.Window.set_pass_through() for details

New in version 3.18.

get_pointer()[source]
Returns:

the window containing the pointer (as with Gdk.Window.at_pointer()), or None if the window containing the pointer isn’t known to GDK

x:

return location for X coordinate of pointer or None to not return the X coordinate

y:

return location for Y coordinate of pointer or None to not return the Y coordinate

mask:

return location for modifier mask or None to not return the modifier mask

Return type:

(Gdk.Window or None, x: int, y: int, mask: Gdk.ModifierType)

Obtains the current pointer position and modifier state. The position is given in coordinates relative to the upper left corner of self.

Deprecated since version 3.0: Use Gdk.Window.get_device_position() instead.

get_position()[source]
Returns:

x:

X coordinate of window

y:

Y coordinate of window

Return type:

(x: int, y: int)

Obtains the position of the window as reported in the most-recently-processed Gdk.EventConfigure. Contrast with Gdk.Window.get_geometry() which queries the X server for the current window position, regardless of which events have been received or processed.

The position coordinates are relative to the window’s parent window.

get_root_coords(x, y)[source]
Parameters:
  • x (int) – X coordinate in window

  • y (int) – Y coordinate in window

Returns:

root_x:

return location for X coordinate

root_y:

return location for Y coordinate

Return type:

(root_x: int, root_y: int)

Obtains the position of a window position in root window coordinates. This is similar to Gdk.Window.get_origin() but allows you to pass in any position in the window, not just the origin.

New in version 2.18.

get_root_origin()[source]
Returns:

x:

return location for X position of window frame

y:

return location for Y position of window frame

Return type:

(x: int, y: int)

Obtains the top-left corner of the window manager frame in root window coordinates.

get_scale_factor()[source]
Returns:

the scale factor

Return type:

int

Returns the internal scale factor that maps from window coordiantes to the actual device pixels. On traditional systems this is 1, but on very high density outputs this can be a higher value (often 2).

A higher value means that drawing is automatically scaled up to a higher resolution, so any code doing drawing will automatically look nicer. However, if you are supplying pixel-based data the scale value can be used to determine whether to use a pixel resource with higher resolution data.

The scale of a window may change during runtime, if this happens a configure event will be sent to the toplevel window.

New in version 3.10.

get_screen()[source]
Returns:

the Gdk.Screen associated with self

Return type:

Gdk.Screen

Gets the Gdk.Screen associated with a Gdk.Window.

New in version 2.24.

get_source_events(source)[source]
Parameters:

source (Gdk.InputSource) – a Gdk.InputSource to define the source class.

Returns:

source event mask for self

Return type:

Gdk.EventMask

Returns the event mask for self corresponding to the device class specified by source.

get_state()[source]
Returns:

window state bitfield

Return type:

Gdk.WindowState

Gets the bitwise OR of the currently active window state flags, from the Gdk.WindowState enumeration.

get_support_multidevice()[source]
Returns:

True if the window handles multidevice features.

Return type:

bool

Returns True if the window is aware of the existence of multiple devices.

New in version 3.0.

get_toplevel()[source]
Returns:

the toplevel window containing self

Return type:

Gdk.Window

Gets the toplevel window that’s an ancestor of self.

Any window type but Gdk.WindowType.CHILD is considered a toplevel window, as is a Gdk.WindowType.CHILD window that has a root window as parent.

Note that you should use Gdk.Window.get_effective_toplevel() when you want to get to a window’s toplevel as seen on screen, because Gdk.Window.get_toplevel() will most likely not do what you expect if there are offscreen windows in the hierarchy.

get_type_hint()[source]
Returns:

The type hint set for self

Return type:

Gdk.WindowTypeHint

This function returns the type hint set for a window.

New in version 2.10.

get_update_area()[source]
Returns:

the update area for self

Return type:

cairo.Region

Transfers ownership of the update area from self to the caller of the function. That is, after calling this function, self will no longer have an invalid/dirty region; the update area is removed from self and handed to you. If a window has no update area, Gdk.Window.get_update_area() returns None. You are responsible for calling cairo_region_destroy() on the returned region if it’s non-None.

get_user_data()[source]
Returns:

return location for user data

Return type:

data: object

Retrieves the user data for self, which is normally the widget that self belongs to. See Gdk.Window.set_user_data().

get_visible_region()[source]
Returns:

a cairo.Region. This must be freed with cairo_region_destroy() when you are done.

Return type:

cairo.Region

Computes the region of the self that is potentially visible. This does not necessarily take into account if the window is obscured by other windows, but no area outside of this region is visible.

get_visual()[source]
Returns:

a Gdk.Visual

Return type:

Gdk.Visual

Gets the Gdk.Visual describing the pixel format of self.

New in version 2.24.

get_width()[source]
Returns:

The width of self

Return type:

int

Returns the width of the given self.

On the X11 platform the returned size is the size reported in the most-recently-processed configure event, rather than the current size on the X server.

New in version 2.24.

get_window_type()[source]
Returns:

type of window

Return type:

Gdk.WindowType

Gets the type of the window. See Gdk.WindowType.

has_native()[source]
Returns:

True if the self has a native window, False otherwise.

Return type:

bool

Checks whether the window has a native window or not. Note that you can use Gdk.Window.ensure_native() if a native window is needed.

New in version 2.22.

hide()[source]

For toplevel windows, withdraws them, so they will no longer be known to the window manager; for all windows, unmaps them, so they won’t be displayed. Normally done automatically as part of gtk_widget_hide().

iconify()[source]

Asks to iconify (minimize) self. The window manager may choose to ignore the request, but normally will honor it. Using gtk_window_iconify() is preferred, if you have a #GtkWindow widget.

This function only makes sense when self is a toplevel window.

input_shape_combine_region(shape_region, offset_x, offset_y)[source]
Parameters:
  • shape_region (cairo.Region) – region of window to be non-transparent

  • offset_x (int) – X position of shape_region in self coordinates

  • offset_y (int) – Y position of shape_region in self coordinates

Like Gdk.Window.shape_combine_region(), but the shape applies only to event handling. Mouse events which happen while the pointer position corresponds to an unset bit in the mask will be passed on the window below self.

An input shape is typically used with RGBA windows. The alpha channel of the window defines which pixels are invisible and allows for nicely antialiased borders, and the input shape controls where the window is “clickable”.

On the X11 platform, this requires version 1.1 of the shape extension.

On the Win32 platform, this functionality is not present and the function does nothing.

New in version 2.10.

invalidate_maybe_recurse(region, child_func, *user_data)[source]
Parameters:

Adds region to the update area for self. The update area is the region that needs to be redrawn, or “dirty region.” The call Gdk.Window.process_updates() sends one or more expose events to the window, which together cover the entire update area. An application would normally redraw the contents of self in response to those expose events.

GDK will call Gdk.Window.process_all_updates() on your behalf whenever your program returns to the main loop and becomes idle, so normally there’s no need to do that manually, you just need to invalidate regions that you know should be redrawn.

The child_func parameter controls whether the region of each child window that intersects region will also be invalidated. Only children for which child_func returns True will have the area invalidated.

invalidate_rect(rect, invalidate_children)[source]
Parameters:
  • rect (Gdk.Rectangle or None) – rectangle to invalidate or None to invalidate the whole window

  • invalidate_children (bool) – whether to also invalidate child windows

A convenience wrapper around Gdk.Window.invalidate_region() which invalidates a rectangular region. See Gdk.Window.invalidate_region() for details.

invalidate_region(region, invalidate_children)[source]
Parameters:

Adds region to the update area for self. The update area is the region that needs to be redrawn, or “dirty region.” The call Gdk.Window.process_updates() sends one or more expose events to the window, which together cover the entire update area. An application would normally redraw the contents of self in response to those expose events.

GDK will call Gdk.Window.process_all_updates() on your behalf whenever your program returns to the main loop and becomes idle, so normally there’s no need to do that manually, you just need to invalidate regions that you know should be redrawn.

The invalidate_children parameter controls whether the region of each child window that intersects region will also be invalidated. If False, then the update area for child windows will remain unaffected. See Gdk.Window.invalidate_maybe_recurse if you need fine grained control over which children are invalidated.

is_destroyed()[source]
Returns:

True if the window is destroyed

Return type:

bool

Check to see if a window is destroyed..

New in version 2.18.

is_input_only()[source]
Returns:

True if self is input only

Return type:

bool

Determines whether or not the window is an input only window.

New in version 2.22.

is_shaped()[source]
Returns:

True if self is shaped

Return type:

bool

Determines whether or not the window is shaped.

New in version 2.22.

is_viewable()[source]
Returns:

True if the window is viewable

Return type:

bool

Check if the window and all ancestors of the window are mapped. (This is not necessarily “viewable” in the X sense, since we only check as far as we have GDK window parents, not to the root window.)

is_visible()[source]
Returns:

True if the window is mapped

Return type:

bool

Checks whether the window has been mapped (with Gdk.Window.show() or Gdk.Window.show_unraised()).

lower()[source]

Lowers self to the bottom of the Z-order (stacking order), so that other windows with the same parent window appear above self. This is true whether or not the other windows are visible.

If self is a toplevel, the window manager may choose to deny the request to move the window in the Z-order, Gdk.Window.lower() only requests the restack, does not guarantee it.

Note that Gdk.Window.show() raises the window again, so don’t call this function before Gdk.Window.show(). (Try Gdk.Window.show_unraised().)

mark_paint_from_clip(cr)[source]
Parameters:

cr (cairo.Context) – a cairo.Context

If you call this during a paint (e.g. between Gdk.Window.begin_paint_region() and Gdk.Window.end_paint() then GDK will mark the current clip region of the window as being drawn. This is required when mixing GL rendering via Gdk.cairo_draw_from_gl() and cairo rendering, as otherwise GDK has no way of knowing when something paints over the GL-drawn regions.

This is typically called automatically by GTK+ and you don’t need to care about this.

New in version 3.16.

maximize()[source]

Maximizes the window. If the window was already maximized, then this function does nothing.

On X11, asks the window manager to maximize self, if the window manager supports this operation. Not all window managers support this, and some deliberately ignore it or don’t have a concept of “maximized”; so you can’t rely on the maximization actually happening. But it will happen with most standard window managers, and GDK makes a best effort to get it to happen.

On Windows, reliably maximizes the window.

merge_child_input_shapes()[source]

Merges the input shape masks for any child windows into the input shape mask for self. i.e. the union of all input masks for self and its children will become the new input mask for self. See Gdk.Window.input_shape_combine_region().

This function is distinct from Gdk.Window.set_child_input_shapes() because it includes self’s input shape mask in the set of shapes to be merged.

New in version 2.10.

merge_child_shapes()[source]

Merges the shape masks for any child windows into the shape mask for self. i.e. the union of all masks for self and its children will become the new mask for self. See Gdk.Window.shape_combine_region().

This function is distinct from Gdk.Window.set_child_shapes() because it includes self’s shape mask in the set of shapes to be merged.

move(x, y)[source]
Parameters:
  • x (int) – X coordinate relative to window’s parent

  • y (int) – Y coordinate relative to window’s parent

Repositions a window relative to its parent window. For toplevel windows, window managers may ignore or modify the move; you should probably use gtk_window_move() on a #GtkWindow widget anyway, instead of using GDK functions. For child windows, the move will reliably succeed.

If you’re also planning to resize the window, use Gdk.Window.move_resize() to both move and resize simultaneously, for a nicer visual effect.

move_region(region, dx, dy)[source]
Parameters:

Move the part of self indicated by region by dy pixels in the Y direction and dx pixels in the X direction. The portions of region that not covered by the new position of region are invalidated.

Child windows are not moved.

New in version 2.8.

move_resize(x, y, width, height)[source]
Parameters:
  • x (int) – new X position relative to window’s parent

  • y (int) – new Y position relative to window’s parent

  • width (int) – new width

  • height (int) – new height

Equivalent to calling Gdk.Window.move() and Gdk.Window.resize(), except that both operations are performed at once, avoiding strange visual effects. (i.e. the user may be able to see the window first move, then resize, if you don’t use Gdk.Window.move_resize().)

move_to_rect(rect, rect_anchor, window_anchor, anchor_hints, rect_anchor_dx, rect_anchor_dy)[source]
Parameters:
  • rect (Gdk.Rectangle) – the destination Gdk.Rectangle to align self with

  • rect_anchor (Gdk.Gravity) – the point on rect to align with self's anchor point

  • window_anchor (Gdk.Gravity) – the point on self to align with rect's anchor point

  • anchor_hints (Gdk.AnchorHints) – positioning hints to use when limited on space

  • rect_anchor_dx (int) – horizontal offset to shift self, i.e. rect's anchor point

  • rect_anchor_dy (int) – vertical offset to shift self, i.e. rect's anchor point

Moves self to rect, aligning their anchor points.

rect is relative to the top-left corner of the window that self is transient for. rect_anchor and window_anchor determine anchor points on rect and self to pin together. rect's anchor point can optionally be offset by rect_anchor_dx and rect_anchor_dy, which is equivalent to offsetting the position of self.

anchor_hints determines how self will be moved if the anchor points cause it to move off-screen. For example, Gdk.AnchorHints.FLIP_X will replace Gdk.Gravity.NORTH_WEST with Gdk.Gravity.NORTH_EAST and vice versa if self extends beyond the left or right edges of the monitor.

Connect to the Gdk.Window ::moved-to-rect signal to find out how it was actually positioned.

New in version 3.24.

peek_children()[source]
Returns:

a reference to the list of child windows in self

Return type:

[Gdk.Window]

Like Gdk.Window.get_children(), but does not copy the list of children, so the list does not need to be freed.

process_updates(update_children)[source]
Parameters:

update_children (bool) – whether to also process updates for child windows

Sends one or more expose events to self. The areas in each expose event will cover the entire update area for the window (see Gdk.Window.invalidate_region() for details). Normally GDK calls Gdk.Window.process_all_updates() on your behalf, so there’s no need to call this function unless you want to force expose events to be delivered immediately and synchronously (vs. the usual case, where GDK delivers them in an idle handler). Occasionally this is useful to produce nicer scrolling behavior, for example.

Deprecated since version 3.22.

raise_()[source]

Raises self to the top of the Z-order (stacking order), so that other windows with the same parent window appear below self. This is true whether or not the windows are visible.

If self is a toplevel, the window manager may choose to deny the request to move the window in the Z-order, Gdk.Window.raise_() only requests the restack, does not guarantee it.

register_dnd()[source]

Registers a window as a potential drop destination.

reparent(new_parent, x, y)[source]
Parameters:
  • new_parent (Gdk.Window) – new parent to move self into

  • x (int) – X location inside the new parent

  • y (int) – Y location inside the new parent

Reparents self into the given new_parent. The window being reparented will be unmapped as a side effect.

resize(width, height)[source]
Parameters:
  • width (int) – new width of the window

  • height (int) – new height of the window

Resizes self; for toplevel windows, asks the window manager to resize the window. The window manager may not allow the resize. When using GTK+, use gtk_window_resize() instead of this low-level GDK function.

Windows may not be resized below 1x1.

If you’re also planning to move the window, use Gdk.Window.move_resize() to both move and resize simultaneously, for a nicer visual effect.

restack(sibling, above)[source]
Parameters:

Changes the position of self in the Z-order (stacking order), so that it is above sibling (if above is True) or below sibling (if above is False).

If sibling is None, then this either raises (if above is True) or lowers the window.

If self is a toplevel, the window manager may choose to deny the request to move the window in the Z-order, Gdk.Window.restack() only requests the restack, does not guarantee it.

New in version 2.18.

scroll(dx, dy)[source]
Parameters:
  • dx (int) – Amount to scroll in the X direction

  • dy (int) – Amount to scroll in the Y direction

Scroll the contents of self, both pixels and children, by the given amount. self itself does not move. Portions of the window that the scroll operation brings in from offscreen areas are invalidated. The invalidated region may be bigger than what would strictly be necessary.

For X11, a minimum area will be invalidated if the window has no subwindows, or if the edges of the window’s parent do not extend beyond the edges of the window. In other cases, a multi-step process is used to scroll the window which may produce temporary visual artifacts and unnecessary invalidations.

set_accept_focus(accept_focus)[source]
Parameters:

accept_focus (bool) – True if the window should receive input focus

Setting accept_focus to False hints the desktop environment that the window doesn’t want to receive input focus.

On X, it is the responsibility of the window manager to interpret this hint. ICCCM-compliant window manager usually respect it.

New in version 2.4.

set_background(color)[source]
Parameters:

color (Gdk.Color) – a Gdk.Color

Sets the background color of self.

However, when using GTK+, influence the background of a widget using a style class or CSS — if you’re an application — or with gtk_style_context_set_background() — if you’re implementing a custom widget.

Deprecated since version 3.4: Don’t use this function

set_background_pattern(pattern)[source]
Parameters:

pattern (cairo.Pattern or None) – a pattern to use, or None

Sets the background of self.

A background of None means that the window won’t have any background. On the X11 backend it’s also possible to inherit the background from the parent window using gdk_x11_get_parent_relative_pattern().

The windowing system will normally fill a window with its background when the window is obscured then exposed.

Deprecated since version 3.22: Don’t use this function

set_background_rgba(rgba)[source]
Parameters:

rgba (Gdk.RGBA) – a Gdk.RGBA color

Sets the background color of self.

See also Gdk.Window.set_background_pattern().

Deprecated since version 3.22: Don’t use this function

set_child_input_shapes()[source]

Sets the input shape mask of self to the union of input shape masks for all children of self, ignoring the input shape mask of self itself. Contrast with Gdk.Window.merge_child_input_shapes() which includes the input shape mask of self in the masks to be merged.

New in version 2.10.

set_child_shapes()[source]

Sets the shape mask of self to the union of shape masks for all children of self, ignoring the shape mask of self itself. Contrast with Gdk.Window.merge_child_shapes() which includes the shape mask of self in the masks to be merged.

set_composited(composited)[source]
Parameters:

composited (bool) – True to set the window as composited

Sets a Gdk.Window as composited, or unsets it. Composited windows do not automatically have their contents drawn to the screen. Drawing is redirected to an offscreen buffer and an expose event is emitted on the parent of the composited window. It is the responsibility of the parent’s expose handler to manually merge the off-screen content onto the screen in whatever way it sees fit.

It only makes sense for child windows to be composited; see Gdk.Window.set_opacity() if you need translucent toplevel windows.

An additional effect of this call is that the area of this window is no longer clipped from regions marked for invalidation on its parent. Draws done on the parent window are also no longer clipped by the child.

This call is only supported on some systems (currently, only X11 with new enough Xcomposite and Xdamage extensions). You must call Gdk.Display.supports_composite() to check if setting a window as composited is supported before attempting to do so.

New in version 2.12.

Deprecated since version 3.16: Compositing is an outdated technology that only ever worked on X11.

set_cursor(cursor)[source]
Parameters:

cursor (Gdk.Cursor or None) – a cursor

Sets the default mouse pointer for a Gdk.Window.

Note that cursor must be for the same display as self.

Use Gdk.Cursor.new_for_display() or Gdk.Cursor.new_from_pixbuf() to create the cursor. To make the cursor invisible, use Gdk.CursorType.BLANK_CURSOR. Passing None for the cursor argument to Gdk.Window.set_cursor() means that self will use the cursor of its parent window. Most windows should use this default.

set_decorations(decorations)[source]
Parameters:

decorations (Gdk.WMDecoration) – decoration hint mask

“Decorations” are the features the window manager adds to a toplevel Gdk.Window. This function sets the traditional Motif window manager hints that tell the window manager which decorations you would like your window to have. Usually you should use gtk_window_set_decorated() on a #GtkWindow instead of using the GDK function directly.

The decorations argument is the logical OR of the fields in the Gdk.WMDecoration enumeration. If Gdk.WMDecoration.ALL is included in the mask, the other bits indicate which decorations should be turned off. If Gdk.WMDecoration.ALL is not included, then the other bits indicate which decorations should be turned on.

Most window managers honor a decorations hint of 0 to disable all decorations, but very few honor all possible combinations of bits.

set_device_cursor(device, cursor)[source]
Parameters:

Sets a specific Gdk.Cursor for a given device when it gets inside self. Use Gdk.Cursor.new_for_display() or Gdk.Cursor.new_from_pixbuf() to create the cursor. To make the cursor invisible, use Gdk.CursorType.BLANK_CURSOR. Passing None for the cursor argument to Gdk.Window.set_cursor() means that self will use the cursor of its parent window. Most windows should use this default.

New in version 3.0.

set_device_events(device, event_mask)[source]
Parameters:

Sets the event mask for a given device (Normally a floating device, not attached to any visible pointer) to self. For example, an event mask including Gdk.EventMask.BUTTON_PRESS_MASK means the window should report button press events. The event mask is the bitwise OR of values from the Gdk.EventMask enumeration.

See the ‘input handling overview [event-masks]’ for details.

New in version 3.0.

set_event_compression(event_compression)[source]
Parameters:

event_compression (bool) – True if motion events should be compressed

Determines whether or not extra unprocessed motion events in the event queue can be discarded. If True only the most recent event will be delivered.

Some types of applications, e.g. paint programs, need to see all motion events and will benefit from turning off event compression.

By default, event compression is enabled.

New in version 3.12.

set_events(event_mask)[source]
Parameters:

event_mask (Gdk.EventMask) – event mask for self

The event mask for a window determines which events will be reported for that window from all master input devices. For example, an event mask including Gdk.EventMask.BUTTON_PRESS_MASK means the window should report button press events. The event mask is the bitwise OR of values from the Gdk.EventMask enumeration.

See the ‘input handling overview [event-masks]’ for details.

set_focus_on_map(focus_on_map)[source]
Parameters:

focus_on_map (bool) – True if the window should receive input focus when mapped

Setting focus_on_map to False hints the desktop environment that the window doesn’t want to receive input focus when it is mapped. focus_on_map should be turned off for windows that aren’t triggered interactively (such as popups from network activity).

On X, it is the responsibility of the window manager to interpret this hint. Window managers following the freedesktop.org window manager extension specification should respect it.

New in version 2.6.

set_fullscreen_mode(mode)[source]
Parameters:

mode (Gdk.FullscreenMode) – fullscreen mode

Specifies whether the self should span over all monitors (in a multi-head setup) or only the current monitor when in fullscreen mode.

The mode argument is from the Gdk.FullscreenMode enumeration. If Gdk.FullscreenMode.ALL_MONITORS is specified, the fullscreen self will span over all monitors from the Gdk.Screen.

On X11, searches through the list of monitors from the Gdk.Screen the ones which delimit the 4 edges of the entire Gdk.Screen and will ask the window manager to span the self over these monitors.

If the XINERAMA extension is not available or not usable, this function has no effect.

Not all window managers support this, so you can’t rely on the fullscreen window to span over the multiple monitors when Gdk.FullscreenMode.ALL_MONITORS is specified.

New in version 3.8.

set_functions(functions)[source]
Parameters:

functions (Gdk.WMFunction) – bitmask of operations to allow on self

Sets hints about the window management functions to make available via buttons on the window frame.

On the X backend, this function sets the traditional Motif window manager hint for this purpose. However, few window managers do anything reliable or interesting with this hint. Many ignore it entirely.

The functions argument is the logical OR of values from the Gdk.WMFunction enumeration. If the bitmask includes Gdk.WMFunction.ALL, then the other bits indicate which functions to disable; if it doesn’t include Gdk.WMFunction.ALL, it indicates which functions to enable.

set_geometry_hints(geometry, geom_mask)[source]
Parameters:

Sets the geometry hints for self. Hints flagged in geom_mask are set, hints not flagged in geom_mask are unset. To unset all hints, use a geom_mask of 0 and a geometry of None.

This function provides hints to the windowing system about acceptable sizes for a toplevel window. The purpose of this is to constrain user resizing, but the windowing system will typically (but is not required to) also constrain the current size of the window to the provided values and constrain programatic resizing via Gdk.Window.resize() or Gdk.Window.move_resize().

Note that on X11, this effect has no effect on windows of type Gdk.WindowType.TEMP or windows where override redirect has been turned on via Gdk.Window.set_override_redirect() since these windows are not resizable by the user.

Since you can’t count on the windowing system doing the constraints for programmatic resizes, you should generally call Gdk.Window.constrain_size() yourself to determine appropriate sizes.

set_group(leader)[source]
Parameters:

leader (Gdk.Window or None) – group leader window, or None to restore the default group leader window

Sets the group leader window for self. By default, GDK sets the group leader for all toplevel windows to a global window implicitly created by GDK. With this function you can override this default.

The group leader window allows the window manager to distinguish all windows that belong to a single application. It may for example allow users to minimize/unminimize all windows belonging to an application at once. You should only set a non-default group window if your application pretends to be multiple applications.

set_icon_list(pixbufs)[source]
Parameters:

pixbufs ([GdkPixbuf.Pixbuf]) – A list of pixbufs, of different sizes.

Sets a list of icons for the window. One of these will be used to represent the window when it has been iconified. The icon is usually shown in an icon box or some sort of task bar. Which icon size is shown depends on the window manager. The window manager can scale the icon but setting several size icons can give better image quality since the window manager may only need to scale the icon by a small amount or not at all.

Note that some platforms don’t support window icons.

set_icon_name(name)[source]
Parameters:

name (str or None) – name of window while iconified (minimized)

Windows may have a name used while minimized, distinct from the name they display in their titlebar. Most of the time this is a bad idea from a user interface standpoint. But you can set such a name with this function, if you like.

After calling this with a non-None name, calls to Gdk.Window.set_title() will not update the icon title.

Using None for name unsets the icon title; further calls to Gdk.Window.set_title() will again update the icon title as well.

Note that some platforms don’t support window icons.

set_keep_above(setting)[source]
Parameters:

setting (bool) – whether to keep self above other windows

Set if self must be kept above other windows. If the window was already above, then this function does nothing.

On X11, asks the window manager to keep self above, if the window manager supports this operation. Not all window managers support this, and some deliberately ignore it or don’t have a concept of “keep above”; so you can’t rely on the window being kept above. But it will happen with most standard window managers, and GDK makes a best effort to get it to happen.

New in version 2.4.

set_keep_below(setting)[source]
Parameters:

setting (bool) – whether to keep self below other windows

Set if self must be kept below other windows. If the window was already below, then this function does nothing.

On X11, asks the window manager to keep self below, if the window manager supports this operation. Not all window managers support this, and some deliberately ignore it or don’t have a concept of “keep below”; so you can’t rely on the window being kept below. But it will happen with most standard window managers, and GDK makes a best effort to get it to happen.

New in version 2.4.

set_modal_hint(modal)[source]
Parameters:

modal (bool) – True if the window is modal, False otherwise.

The application can use this hint to tell the window manager that a certain window has modal behaviour. The window manager can use this information to handle modal windows in a special way.

You should only use this on windows for which you have previously called Gdk.Window.set_transient_for()

set_opacity(opacity)[source]
Parameters:

opacity (float) – opacity

Set self to render as partially transparent, with opacity 0 being fully transparent and 1 fully opaque. (Values of the opacity parameter are clamped to the [0,1] range.)

For toplevel windows this depends on support from the windowing system that may not always be there. For instance, On X11, this works only on X screens with a compositing manager running. On Wayland, there is no per-window opacity value that the compositor would apply. Instead, use gdk_window_set_opaque_region (window, NULL) to tell the compositor that the entire window is (potentially) non-opaque, and draw your content with alpha, or use gtk_widget_set_opacity() to set an overall opacity for your widgets.

For child windows this function only works for non-native windows.

For setting up per-pixel alpha topelevels, see Gdk.Screen.get_rgba_visual(), and for non-toplevels, see Gdk.Window.set_composited().

Support for non-toplevel windows was added in 3.8.

New in version 2.12.

set_opaque_region(region)[source]
Parameters:

region (cairo.Region or None) – a region, or None

For optimisation purposes, compositing window managers may like to not draw obscured regions of windows, or turn off blending during for these regions. With RGB windows with no transparency, this is just the shape of the window, but with ARGB32 windows, the compositor does not know what regions of the window are transparent or not.

This function only works for toplevel windows.

GTK+ will update this property automatically if the self background is opaque, as we know where the opaque regions are. If your window background is not opaque, please update this property in your #GtkWidget::style-updated handler.

New in version 3.10.

set_override_redirect(override_redirect)[source]
Parameters:

override_redirect (bool) – True if window should be override redirect

An override redirect window is not under the control of the window manager. This means it won’t have a titlebar, won’t be minimizable, etc. - it will be entirely under the control of the application. The window manager can’t see the override redirect window at all.

Override redirect should only be used for short-lived temporary windows, such as popup menus. #GtkMenu uses an override redirect window in its implementation, for example.

set_pass_through(pass_through)[source]
Parameters:

pass_through (bool) – a boolean

Sets whether input to the window is passed through to the window below.

The default value of this is False, which means that pointer events that happen inside the window are send first to the window, but if the event is not selected by the event mask then the event is sent to the parent window, and so on up the hierarchy.

If pass_through is True then such pointer events happen as if the window wasn’t there at all, and thus will be sent first to any windows below self. This is useful if the window is used in a transparent fashion. In the terminology of the web this would be called “pointer-events: none”.

Note that a window with pass_through True can still have a subwindow without pass through, so you can get events on a subset of a window. And in that cases you would get the in-between related events such as the pointer enter/leave events on its way to the destination window.

New in version 3.18.

set_role(role)[source]
Parameters:

role (str) – a string indicating its role

When using GTK+, typically you should use gtk_window_set_role() instead of this low-level function.

The window manager and session manager use a window’s role to distinguish it from other kinds of window in the same application. When an application is restarted after being saved in a previous session, all windows with the same title and role are treated as interchangeable. So if you have two windows with the same title that should be distinguished for session management purposes, you should set the role on those windows. It doesn’t matter what string you use for the role, as long as you have a different role for each non-interchangeable kind of window.

set_shadow_width(left, right, top, bottom)[source]
Parameters:
  • left (int) – The left extent

  • right (int) – The right extent

  • top (int) – The top extent

  • bottom (int) – The bottom extent

Newer GTK+ windows using client-side decorations use extra geometry around their frames for effects like shadows and invisible borders. Window managers that want to maximize windows or snap to edges need to know where the extents of the actual frame lie, so that users don’t feel like windows are snapping against random invisible edges.

Note that this property is automatically updated by GTK+, so this function should only be used by applications which do not use GTK+ to create toplevel windows.

New in version 3.12.

set_skip_pager_hint(skips_pager)[source]
Parameters:

skips_pager (bool) – True to skip the pager

Toggles whether a window should appear in a pager (workspace switcher, or other desktop utility program that displays a small thumbnail representation of the windows on the desktop). If a window’s semantic type as specified with Gdk.Window.set_type_hint() already fully describes the window, this function should not be called in addition, instead you should allow the window to be treated according to standard policy for its semantic type.

New in version 2.2.

set_skip_taskbar_hint(skips_taskbar)[source]
Parameters:

skips_taskbar (bool) – True to skip the taskbar

Toggles whether a window should appear in a task list or window list. If a window’s semantic type as specified with Gdk.Window.set_type_hint() already fully describes the window, this function should not be called in addition, instead you should allow the window to be treated according to standard policy for its semantic type.

New in version 2.2.

set_source_events(source, event_mask)[source]
Parameters:

Sets the event mask for any floating device (i.e. not attached to any visible pointer) that has the source defined as source. This event mask will be applied both to currently existing, newly added devices after this call, and devices being attached/detached.

New in version 3.0.

set_startup_id(startup_id)[source]
Parameters:

startup_id (str) – a string with startup-notification identifier

When using GTK+, typically you should use gtk_window_set_startup_id() instead of this low-level function.

New in version 2.12.

set_static_gravities(use_static)[source]
Parameters:

use_static (bool) – True to turn on static gravity

Returns:

False

Return type:

bool

Used to set the bit gravity of the given window to static, and flag it so all children get static subwindow gravity. This is used if you are implementing scary features that involve deep knowledge of the windowing system. Don’t worry about it.

Deprecated since version 3.16: static gravities haven’t worked on anything but X11 for a long time.

set_support_multidevice(support_multidevice)[source]
Parameters:

support_multidevice (bool) – True to enable multidevice support in self.

This function will enable multidevice features in self.

Multidevice aware windows will need to handle properly multiple, per device enter/leave events, device grabs and grab ownerships.

New in version 3.0.

set_title(title)[source]
Parameters:

title (str) – title of self

Sets the title of a toplevel window, to be displayed in the titlebar. If you haven’t explicitly set the icon name for the window (using Gdk.Window.set_icon_name()), the icon name will be set to title as well. title must be in UTF-8 encoding (as with all user-readable strings in GDK/GTK+). title may not be None.

set_transient_for(parent)[source]
Parameters:

parent (Gdk.Window) – another toplevel Gdk.Window

Indicates to the window manager that self is a transient dialog associated with the application window parent. This allows the window manager to do things like center self on parent and keep self above parent.

See gtk_window_set_transient_for() if you’re using #GtkWindow or #GtkDialog.

set_type_hint(hint)[source]
Parameters:

hint (Gdk.WindowTypeHint) – A hint of the function this window will have

The application can use this call to provide a hint to the window manager about the functionality of a window. The window manager can use this information when determining the decoration and behaviour of the window.

The hint must be set before the window is mapped.

set_urgency_hint(urgent)[source]
Parameters:

urgent (bool) – True if the window is urgent

Toggles whether a window needs the user’s urgent attention.

New in version 2.8.

set_user_data(user_data)[source]
Parameters:

user_data (GObject.Object or None) – user data

For most purposes this function is deprecated in favor of GObject.Object.set_data(). However, for historical reasons GTK+ stores the #GtkWidget that owns a Gdk.Window as user data on the Gdk.Window. So, custom widget implementations should use this function for that. If GTK+ receives an event for a Gdk.Window, and the user data for the window is non-None, GTK+ will assume the user data is a #GtkWidget, and forward the event to that widget.

shape_combine_region(shape_region, offset_x, offset_y)[source]
Parameters:
  • shape_region (cairo.Region or None) – region of window to be non-transparent

  • offset_x (int) – X position of shape_region in self coordinates

  • offset_y (int) – Y position of shape_region in self coordinates

Makes pixels in self outside shape_region be transparent, so that the window may be nonrectangular.

If shape_region is None, the shape will be unset, so the whole window will be opaque again. offset_x and offset_y are ignored if shape_region is None.

On the X11 platform, this uses an X server extension which is widely available on most common platforms, but not available on very old X servers, and occasionally the implementation will be buggy. On servers without the shape extension, this function will do nothing.

This function works on both toplevel and child windows.

show()[source]

Like Gdk.Window.show_unraised(), but also raises the window to the top of the window stack (moves the window to the front of the Z-order).

This function maps a window so it’s visible onscreen. Its opposite is Gdk.Window.hide().

When implementing a #GtkWidget, you should call this function on the widget’s Gdk.Window as part of the “map” method.

show_unraised()[source]

Shows a Gdk.Window onscreen, but does not modify its stacking order. In contrast, Gdk.Window.show() will raise the window to the top of the window stack.

On the X11 platform, in Xlib terms, this function calls XMapWindow() (it also updates some internal GDK state, which means that you can’t really use XMapWindow() directly on a GDK window).

show_window_menu(event)[source]
Parameters:

event (Gdk.Event) – a Gdk.Event to show the menu for

Returns:

True if the window menu was shown and False otherwise.

Return type:

bool

Asks the windowing system to show the window menu. The window menu is the menu shown when right-clicking the titlebar on traditional windows managed by the window manager. This is useful for windows using client-side decorations, activating it with a right-click on the window decorations.

New in version 3.14.

stick()[source]

“Pins” a window such that it’s on all workspaces and does not scroll with viewports, for window managers that have scrollable viewports. (When using #GtkWindow, gtk_window_stick() may be more useful.)

On the X11 platform, this function depends on window manager support, so may have no effect with many window managers. However, GDK will do the best it can to convince the window manager to stick the window. For window managers that don’t support this operation, there’s nothing you can do to force it to happen.

thaw_toplevel_updates_libgtk_only()[source]

Thaws a window frozen with Gdk.Window.freeze_toplevel_updates_libgtk_only().

This function is not part of the GDK public API and is only for use by GTK+.

Deprecated since version 3.16: This symbol was never meant to be used outside of GTK+

thaw_updates()[source]

Thaws a window frozen with Gdk.Window.freeze_updates().

unfullscreen()[source]

Moves the window out of fullscreen mode. If the window was not fullscreen, does nothing.

On X11, asks the window manager to move self out of the fullscreen state, if the window manager supports this operation. Not all window managers support this, and some deliberately ignore it or don’t have a concept of “fullscreen”; so you can’t rely on the unfullscreenification actually happening. But it will happen with most standard window managers, and GDK makes a best effort to get it to happen.

New in version 2.2.

unmaximize()[source]

Unmaximizes the window. If the window wasn’t maximized, then this function does nothing.

On X11, asks the window manager to unmaximize self, if the window manager supports this operation. Not all window managers support this, and some deliberately ignore it or don’t have a concept of “maximized”; so you can’t rely on the unmaximization actually happening. But it will happen with most standard window managers, and GDK makes a best effort to get it to happen.

On Windows, reliably unmaximizes the window.

unstick()[source]

Reverse operation for Gdk.Window.stick(); see Gdk.Window.stick(), and gtk_window_unstick().

withdraw()[source]

Withdraws a window (unmaps it and asks the window manager to forget about it). This function is not really useful as Gdk.Window.hide() automatically withdraws toplevel windows before hiding them.

do_create_surface(width, height) virtual
Parameters:
  • width (int) –

  • height (int) –

Return type:

cairo.Surface

do_from_embedder(embedder_x, embedder_y, offscreen_x, offscreen_y) virtual
Parameters:
do_to_embedder(offscreen_x, offscreen_y, embedder_x, embedder_y) virtual
Parameters:

Signal Details

Gdk.Window.signals.create_surface(window, width, height)
Signal Name:

create-surface

Flags:

RUN_LAST

Parameters:
  • window (Gdk.Window) – The object which received the signal

  • width (int) – the width of the offscreen surface to create

  • height (int) – the height of the offscreen surface to create

Returns:

the newly created cairo.Surface for the offscreen window

Return type:

cairo.Surface

The ::create-surface signal is emitted when an offscreen window needs its surface (re)created, which happens either when the window is first drawn to, or when the window is being resized. The first signal handler that returns a non-None surface will stop any further signal emission, and its surface will be used.

Note that it is not possible to access the window’s previous surface from within any callback of this signal. Calling Gdk.offscreen_window_get_surface() will lead to a crash.

New in version 3.0.

Gdk.Window.signals.from_embedder(window, embedder_x, embedder_y)
Signal Name:

from-embedder

Flags:

RUN_LAST

Parameters:
  • window (Gdk.Window) – The object which received the signal

  • embedder_x (float) – x coordinate in the embedder window

  • embedder_y (float) – y coordinate in the embedder window

Returns:

offscreen_x:

return location for the x coordinate in the offscreen window

offscreen_y:

return location for the y coordinate in the offscreen window

Return type:

(offscreen_x: float, offscreen_y: float)

The ::from-embedder signal is emitted to translate coordinates in the embedder of an offscreen window to the offscreen window.

See also Gdk.Window ::to-embedder.

New in version 2.18.

Gdk.Window.signals.moved_to_rect(window, flipped_rect, final_rect, flipped_x, flipped_y)
Signal Name:

moved-to-rect

Flags:

RUN_FIRST

Parameters:
  • window (Gdk.Window) – The object which received the signal

  • flipped_rect (object or None) – the position of window after any possible flipping or None if the backend can’t obtain it

  • final_rect (object or None) – the final position of window or None if the backend can’t obtain it

  • flipped_x (bool) – True if the anchors were flipped horizontally

  • flipped_y (bool) – True if the anchors were flipped vertically

Emitted when the position of window is finalized after being moved to a destination rectangle.

window might be flipped over the destination rectangle in order to keep it on-screen, in which case flipped_x and flipped_y will be set to True accordingly.

flipped_rect is the ideal position of window after any possible flipping, but before any possible sliding. final_rect is flipped_rect, but possibly translated in the case that flipping is still ineffective in keeping window on-screen.

New in version 3.22.

Gdk.Window.signals.pick_embedded_child(window, x, y)
Signal Name:

pick-embedded-child

Flags:

RUN_LAST

Parameters:
  • window (Gdk.Window) – The object which received the signal

  • x (float) – x coordinate in the window

  • y (float) – y coordinate in the window

Returns:

the Gdk.Window of the embedded child at x, y, or None

Return type:

Gdk.Window or None

The ::pick-embedded-child signal is emitted to find an embedded child at the given position.

New in version 2.18.

Gdk.Window.signals.to_embedder(window, offscreen_x, offscreen_y)
Signal Name:

to-embedder

Flags:

RUN_LAST

Parameters:
  • window (Gdk.Window) – The object which received the signal

  • offscreen_x (float) – x coordinate in the offscreen window

  • offscreen_y (float) – y coordinate in the offscreen window

Returns:

embedder_x:

return location for the x coordinate in the embedder window

embedder_y:

return location for the y coordinate in the embedder window

Return type:

(embedder_x: float, embedder_y: float)

The ::to-embedder signal is emitted to translate coordinates in an offscreen window to its embedder.

See also Gdk.Window ::from-embedder.

New in version 2.18.

Property Details

Gdk.Window.props.cursor
Name:

cursor

Type:

Gdk.Cursor

Default Value:

None

Flags:

READABLE, WRITABLE

The mouse pointer for a Gdk.Window. See Gdk.Window.set_cursor() and Gdk.Window.get_cursor() for details.

New in version 2.18.