Gdk.Toplevel

g GObject.GInterface GObject.GInterface Gdk.Toplevel Gdk.Toplevel GObject.GInterface->Gdk.Toplevel

Implementations:

None

Methods

begin_move (device, button, x, y, timestamp)

begin_resize (edge, device, button, x, y, timestamp)

focus (timestamp)

get_state ()

inhibit_system_shortcuts (event)

lower ()

minimize ()

present (layout)

restore_system_shortcuts ()

set_decorated (decorated)

set_deletable (deletable)

set_icon_list (surfaces)

set_modal (modal)

set_startup_id (startup_id)

set_title (title)

set_transient_for (parent)

show_window_menu (event)

supports_edge_constraints ()

titlebar_gesture (gesture)

Virtual Methods

None

Properties

Name

Type

Flags

Short Description

decorated

bool

r/w/en

deletable

bool

r/w/en

fullscreen-mode

Gdk.FullscreenMode

r/w/en

icon-list

int

r/w/en

modal

bool

r/w/en

shortcuts-inhibited

bool

r/en

startup-id

str

r/w/en

state

Gdk.ToplevelState

r

title

str

r/w/en

transient-for

Gdk.Surface

r/w/en

Signals

Name

Short Description

compute-size

Emitted when the size for the surface needs to be computed, when it is present.

Fields

None

Class Details

class Gdk.Toplevel
Bases:

GObject.GInterface

Structure:

Gdk.ToplevelInterface

A GdkToplevel is a freestanding toplevel surface.

The GdkToplevel interface provides useful APIs for interacting with the windowing system, such as controlling maximization and size of the surface, setting icons and transient parents for dialogs.

begin_move(device, button, x, 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

  • x (float) – surface X coordinate of mouse click that began the drag

  • y (float) – surface Y coordinate of mouse click that began the drag

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

Begins an interactive move operation.

You might use this function to implement draggable titlebars.

begin_resize(edge, device, button, x, y, timestamp)[source]
Parameters:
  • edge (Gdk.SurfaceEdge) – the edge or corner from which the drag is started

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

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

  • x (float) – surface X coordinate of mouse click that began the drag

  • y (float) – surface Y coordinate of mouse click that began the drag

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

Begins an interactive resize operation.

You might use this function to implement a “window resize grip.”

focus(timestamp)[source]
Parameters:

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

Sets keyboard focus to surface.

In most cases, gtk_window_present_with_time() should be used on a GtkWindow, rather than calling this function.

get_state()[source]
Returns:

surface state bitfield

Return type:

Gdk.ToplevelState

Gets the bitwise or of the currently active surface state flags, from the GdkToplevelState enumeration.

inhibit_system_shortcuts(event)[source]
Parameters:

event (Gdk.Event or None) – the GdkEvent that is triggering the inhibit request, or None if none is available

Requests that the self inhibit the system shortcuts.

This is asking the desktop environment/windowing system to let all keyboard events reach the surface, as long as it is focused, instead of triggering system actions.

If granted, the rerouting remains active until the default shortcuts processing is restored with [method`Gdk`.Toplevel.restore_system_shortcuts], or the request is revoked by the desktop environment, windowing system or the user.

A typical use case for this API is remote desktop or virtual machine viewers which need to inhibit the default system keyboard shortcuts so that the remote session or virtual host gets those instead of the local environment.

The windowing system or desktop environment may ask the user to grant or deny the request or even choose to ignore the request entirely.

The caller can be notified whenever the request is granted or revoked by listening to the [property`Gdk`.Toplevel:shortcuts-inhibited] property.

lower()[source]
Returns:

True if the surface was lowered

Return type:

bool

Asks to lower the self below other windows.

The windowing system may choose to ignore the request.

minimize()[source]
Returns:

True if the surface was minimized

Return type:

bool

Asks to minimize the self.

The windowing system may choose to ignore the request.

present(layout)[source]
Parameters:

layout (Gdk.ToplevelLayout) – the GdkToplevelLayout object used to layout

Present self after having processed the GdkToplevelLayout rules.

If the toplevel was previously not showing, it will be showed, otherwise it will change layout according to layout.

GDK may emit the [signal`Gdk`.Toplevel::compute-size] signal to let the user of this toplevel compute the preferred size of the toplevel surface.

Presenting is asynchronous and the specified layout parameters are not guaranteed to be respected.

restore_system_shortcuts()[source]

Restore default system keyboard shortcuts which were previously inhibited.

This undoes the effect of [method`Gdk`.Toplevel.inhibit_system_shortcuts].

set_decorated(decorated)[source]
Parameters:

decorated (bool) – True to request decorations

Sets the toplevel to be decorated.

Setting decorated to False hints the desktop environment that the surface has its own, client-side decorations and does not need to have window decorations added.

set_deletable(deletable)[source]
Parameters:

deletable (bool) – True to request a delete button

Sets the toplevel to be deletable.

Setting deletable to True hints the desktop environment that it should offer the user a way to close the surface.

set_icon_list(surfaces)[source]
Parameters:

surfaces ([Gdk.Texture]) – A list of textures to use as icon, of different sizes

Sets a list of icons for the surface.

One of these will be used to represent the surface in iconic form. The icon may be shown in window lists or task bars. 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.

Note that some platforms don’t support surface icons.

set_modal(modal)[source]
Parameters:

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

Sets the toplevel to be modal.

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

You should only use this on surfaces for which you have previously called [method`Gdk`.Toplevel.set_transient_for].

set_startup_id(startup_id)[source]
Parameters:

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

Sets the startup notification ID.

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

set_title(title)[source]
Parameters:

title (str) – title of surface

Sets the title of a toplevel surface.

The title maybe be displayed in the titlebar, in lists of windows, etc.

set_transient_for(parent)[source]
Parameters:

parent (Gdk.Surface) – another toplevel GdkSurface

Sets a transient-for parent.

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

See gtk_window_set_transient_for() if you’re using GtkWindow.

show_window_menu(event)[source]
Parameters:

event (Gdk.Event) – a GdkEvent 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.

supports_edge_constraints()[source]
Returns:

True if the desktop environment supports tiled window states

Return type:

bool

Returns whether the desktop environment supports tiled window states.

titlebar_gesture(gesture)[source]
Parameters:

gesture (Gdk.TitlebarGesture) – a GdkTitlebarGesture

Return type:

bool

New in version 4.4.

Signal Details

Gdk.Toplevel.signals.compute_size(toplevel, size)
Signal Name:

compute-size

Flags:

RUN_LAST

Parameters:

Emitted when the size for the surface needs to be computed, when it is present.

This signal will normally be emitted during or after a call to [method`Gdk`.Toplevel.present], depending on the configuration received by the windowing system. It may also be emitted at any other point in time, in response to the windowing system spontaneously changing the configuration of the toplevel surface.

It is the responsibility of the toplevel user to handle this signal and compute the desired size of the toplevel, given the information passed via the [struct`Gdk`.ToplevelSize] object. Failing to do so will result in an arbitrary size being used as a result.

Property Details

Gdk.Toplevel.props.decorated
Name:

decorated

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Whether the window manager should add decorations.

Gdk.Toplevel.props.deletable
Name:

deletable

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Whether the window manager should allow to close the surface.

Gdk.Toplevel.props.fullscreen_mode
Name:

fullscreen-mode

Type:

Gdk.FullscreenMode

Default Value:

Gdk.FullscreenMode.CURRENT_MONITOR

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The fullscreen mode of the surface.

Gdk.Toplevel.props.icon_list
Name:

icon-list

Type:

int

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

A list of textures to use as icon.

Gdk.Toplevel.props.modal
Name:

modal

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

Whether the surface is modal.

Gdk.Toplevel.props.shortcuts_inhibited
Name:

shortcuts-inhibited

Type:

bool

Default Value:

False

Flags:

READABLE, EXPLICIT_NOTIFY

Whether the surface should inhibit keyboard shortcuts.

Gdk.Toplevel.props.startup_id
Name:

startup-id

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The startup ID of the surface.

See [class`Gdk`.AppLaunchContext] for more information about startup feedback.

Gdk.Toplevel.props.state
Name:

state

Type:

Gdk.ToplevelState

Default Value:

0

Flags:

READABLE

The state of the toplevel.

Gdk.Toplevel.props.title
Name:

title

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The title of the surface.

Gdk.Toplevel.props.transient_for
Name:

transient-for

Type:

Gdk.Surface

Default Value:

None

Flags:

READABLE, WRITABLE, EXPLICIT_NOTIFY

The transient parent of the surface.