Module: Gdk::Toplevel

Defined in:
(unknown)

Overview

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.

Instance Method Summary collapse

Instance Method Details

#begin_move(device, button, x, y, timestamp) ⇒ nil

Begins an interactive move operation.

You might use this function to implement draggable titlebars.

Parameters:

  • device (Gdk::Device)

    the device used for the operation

  • button (Integer)

    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 (Integer)

    timestamp of mouse click that began the drag (use
    [methodGdk.Event.get_time])

Returns:

  • (nil)

#begin_resize(edge, device, button, x, y, timestamp) ⇒ nil

Begins an interactive resize operation.

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

Parameters:

  • edge (Gdk::SurfaceEdge)

    the edge or corner from which the drag is started

  • device (Gdk::Device)

    the device used for the operation

  • button (Integer)

    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 (Integer)

    timestamp of mouse click that began the drag (use
    [methodGdk.Event.get_time])

Returns:

  • (nil)

#decorated=(decorated) ⇒ nil

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:

  • decorated (Boolean)

    true to request decorations

Returns:

  • (nil)

#deletable=(deletable) ⇒ nil

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:

  • deletable (Boolean)

    true to request a delete button

Returns:

  • (nil)

#focus(timestamp) ⇒ nil

Sets keyboard focus to surface.

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

Parameters:

  • timestamp (Integer)

    timestamp of the event triggering the surface focus

Returns:

  • (nil)

#icon_list=(surfaces) ⇒ nil

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:

  • surfaces (GLib::List<Gdk::Texture>)

    A list of textures to use as icon, of different sizes

Returns:

  • (nil)

#inhibit_system_shortcuts(event) ⇒ nil

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 [methodGdk.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 [propertyGdk.Toplevel:shortcuts-inhibited] property.

Parameters:

  • event (Gdk::Event)

    the GdkEvent that is triggering the inhibit
    request, or nil if none is available

Returns:

  • (nil)

#lowerBoolean

Asks to lower the toplevel below other windows.

The windowing system may choose to ignore the request.

Returns:

  • (Boolean)

    true if the surface was lowered

#minimizeBoolean

Asks to minimize the toplevel.

The windowing system may choose to ignore the request.

Returns:

  • (Boolean)

    true if the surface was minimized

#modal=(modal) ⇒ nil

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 [methodGdk.Toplevel.set_transient_for].

Parameters:

  • modal (Boolean)

    true if the surface is modal, false otherwise.

Returns:

  • (nil)

#present(layout) ⇒ nil

Present toplevel 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 [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:

  • layout (Gdk::ToplevelLayout)

    the GdkToplevelLayout object used to layout

Returns:

  • (nil)

#restore_system_shortcutsnil

Restore default system keyboard shortcuts which were previously
inhibited.

This undoes the effect of [methodGdk.Toplevel.inhibit_system_shortcuts].

Returns:

  • (nil)

#show_window_menu(event) ⇒ Boolean

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:

  • event (Gdk::Event)

    a GdkEvent to show the menu for

Returns:

  • (Boolean)

    true if the window menu was shown and false otherwise.

#startup_id=(startup_id) ⇒ nil

Sets the startup notification ID.

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

Parameters:

  • startup_id (String)

    a string with startup-notification identifier

Returns:

  • (nil)

#stateGdk::ToplevelState

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

Returns:

#supports_edge_constraintsBoolean

Returns whether the desktop environment supports
tiled window states.

Returns:

  • (Boolean)

    true if the desktop environment supports tiled window states

#title=(title) ⇒ nil

Sets the title of a toplevel surface.

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

Parameters:

  • title (String)

    title of surface

Returns:

  • (nil)

#titlebar_gesture(gesture) ⇒ Boolean

Parameters:

Returns:

  • (Boolean)

#transient_for=(parent) ⇒ nil

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.

Parameters:

Returns:

  • (nil)