gdk.toplevel_mixin

Module for [Toplevel] interface mixin

Templates 2

tmplToplevelT()

A [gdk.toplevel.Toplevel] is a freestanding toplevel surface.

The [gdk.toplevel.Toplevel] 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.

Functions
bool decorated()

Get decorated property.

Returns

Whether the window manager should add decorations.
void decorated(bool propval)

Set decorated property.

Parameters

propvalWhether the window manager should add decorations.
bool deletable()

Get deletable property.

Returns

Whether the window manager should allow to close the surface.
void deletable(bool propval)

Set deletable property.

Parameters

propvalWhether the window manager should allow to close the surface.
gdk.types.FullscreenMode fullscreenMode()

Get fullscreenMode property.

Returns

The fullscreen mode of the surface.
void fullscreenMode(gdk.types.FullscreenMode propval)

Set fullscreenMode property.

Parameters

propvalThe fullscreen mode of the surface.
void * iconList()

Get iconList property.

Returns

A list of textures to use as icon.
void iconList(void * propval)

Set iconList property.

Parameters

propvalA list of textures to use as icon.
bool modal()

Get modal property.

Returns

Whether the surface is modal.
void modal(bool propval)

Set modal property.

Parameters

propvalWhether the surface is modal.
bool shortcutsInhibited()

Get shortcutsInhibited property.

Returns

Whether the surface should inhibit keyboard shortcuts.
string startupId()

Get startupId property.

Returns

The startup ID of the surface.

See [gdk.app_launch_context.AppLaunchContext] for more information about startup feedback.

void startupId(string propval)

Set startupId property.

Parameters

propvalThe startup ID of the surface. See [gdk.app_launch_context.AppLaunchContext] for more information about startup feedback.

Get state property.

Returns

The state of the toplevel.
string title()

Get title property.

Returns

The title of the surface.
void title(string propval)

Set title property.

Parameters

propvalThe title of the surface.
gdk.surface.Surface transientFor()

Get transientFor property.

Returns

The transient parent of the surface.
void transientFor(gdk.surface.Surface propval)

Set transientFor property.

Parameters

propvalThe transient parent of the surface.
void beginMove(gdk.device.Device device, int button, double x, double y, uint timestamp)

Begins an interactive move operation.

You might use this function to implement draggable titlebars.

Parameters

devicethe device used for the operation
buttonthe button being used to drag, or 0 for a keyboard-initiated drag
xsurface X coordinate of mouse click that began the drag
ysurface Y coordinate of mouse click that began the drag
timestamptimestamp of mouse click that began the drag (use [gdk.event.Event.getTime])
void beginResize(gdk.types.SurfaceEdge edge, gdk.device.Device device, int button, double x, double y, uint timestamp)

Begins an interactive resize operation.

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

Parameters

edgethe edge or corner from which the drag is started
devicethe device used for the operation
buttonthe button being used to drag, or 0 for a keyboard-initiated drag
xsurface X coordinate of mouse click that began the drag
ysurface Y coordinate of mouse click that began the drag
timestamptimestamp of mouse click that began the drag (use [gdk.event.Event.getTime])
void focus(uint timestamp)

Sets keyboard focus to surface.

In most cases, [[gtk.window.Window.presentWithTime]](../gtk4/method.Window.present_with_time.html) should be used on a GtkWindow, rather than calling this function.

Parameters

timestamptimestamp of the event triggering the surface focus

Gets the bitwise or of the currently active surface state flags, from the [gdk.types.ToplevelState] enumeration.

Returns

surface state bitfield
void inhibitSystemShortcuts(gdk.event.Event event = null)

Requests that the toplevel 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 [gdk.toplevel.Toplevel.restoreSystemShortcuts], 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 propertyGdk.Toplevel:shortcuts-inhibited property.

Parameters

eventthe [gdk.event.Event] that is triggering the inhibit request, or null if none is available
bool lower()

Asks to lower the toplevel below other windows.

The windowing system may choose to ignore the request.

Returns

true if the surface was lowered
bool minimize()

Asks to minimize the toplevel.

The windowing system may choose to ignore the request.

Returns

true if the surface was minimized

Present toplevel after having processed the [gdk.toplevel_layout.ToplevelLayout] rules.

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

GDK may emit the signalGdk.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.

Parameters

layoutthe [gdk.toplevel_layout.ToplevelLayout] object used to layout
void restoreSystemShortcuts()

Restore default system keyboard shortcuts which were previously inhibited.

This undoes the effect of [gdk.toplevel.Toplevel.inhibitSystemShortcuts].

void setDecorated(bool decorated)

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.

Parameters

decoratedtrue to request decorations
void setDeletable(bool deletable)

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.

Parameters

deletabletrue to request a delete button
void setIconList(gdk.texture.Texture[] surfaces)

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.

Parameters

surfacesA list of textures to use as icon, of different sizes
void setModal(bool modal)

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 [gdk.toplevel.Toplevel.setTransientFor].

Parameters

modaltrue if the surface is modal, false otherwise.
void setStartupId(string startupId)

Sets the startup notification ID.

When using GTK, typically you should use [[gtk.window.Window.setStartupId]](../gtk4/method.Window.set_startup_id.html) instead of this low-level function.

Parameters

startupIda string with startup-notification identifier
void setTitle(string title)

Sets the title of a toplevel surface.

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

Parameters

titletitle of surface
void setTransientFor(gdk.surface.Surface parent)

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.Window.setTransientFor]](../gtk4/method.Window.set_transient_for.html) if you’re using GtkWindow.

Parameters

parentanother toplevel [gdk.surface.Surface]
bool showWindowMenu(gdk.event.Event event)

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.

Parameters

eventa [gdk.event.Event] to show the menu for

Returns

true if the window menu was shown and false otherwise.
bool supportsEdgeConstraints()

Returns whether the desktop environment supports tiled window states.

Returns

true if the desktop environment supports tiled window states
bool titlebarGesture(gdk.types.TitlebarGesture gesture)
gulong connectComputeSize(T)(T callback, Flag!"After" after = No.After) if (isCallable!T && is(ReturnType!T == void) && (Parameters!T.length < 1 || (ParameterStorageClassTuple!T[0] == ParameterStorageClass.none && is(Parameters!T[0] == gdk.toplevel_size.ToplevelSize))) && (Parameters!T.length < 2 || (ParameterStorageClassTuple!T[1] == ParameterStorageClass.none && is(Parameters!T[1] : gdk.toplevel.Toplevel))) && Parameters!T.length < 3)

Connect to ComputeSize signal.

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 [gdk.toplevel.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 [gdk.toplevel_size.ToplevelSize] object. Failing to do so will result in an arbitrary size being used as a result.

Parameters

callbacksignal callback delegate or function to connect void callback(gdk.toplevel_size.ToplevelSize size, gdk.toplevel.Toplevel toplevel) size a [gdk.toplevel_size.ToplevelSize] (optional) toplevel the instance the signal is connected to (optional)
afterYes.After to execute callback after default handler, No.After to execute before (default)

Returns

Signal ID
tmplToplevelGidBuilderT()
Functions
T decorated(bool propval)

Set decorated property.

Parameters

propvalWhether the window manager should add decorations.

Returns

Builder instance for fluent chaining
T deletable(bool propval)

Set deletable property.

Parameters

propvalWhether the window manager should allow to close the surface.

Returns

Builder instance for fluent chaining
T fullscreenMode(gdk.types.FullscreenMode propval)

Set fullscreenMode property.

Parameters

propvalThe fullscreen mode of the surface.

Returns

Builder instance for fluent chaining
T iconList(void * propval)

Set iconList property.

Parameters

propvalA list of textures to use as icon.

Returns

Builder instance for fluent chaining
T modal(bool propval)

Set modal property.

Parameters

propvalWhether the surface is modal.

Returns

Builder instance for fluent chaining
T startupId(string propval)

Set startupId property.

Parameters

propvalThe startup ID of the surface. See [gdk.app_launch_context.AppLaunchContext] for more information about startup feedback.

Returns

Builder instance for fluent chaining
T title(string propval)

Set title property.

Parameters

propvalThe title of the surface.

Returns

Builder instance for fluent chaining
T transientFor(gdk.surface.Surface propval)

Set transientFor property.

Parameters

propvalThe transient parent of the surface.

Returns

Builder instance for fluent chaining