gtkmm  4.8.0
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Related Functions | List of all members
Gdk::Toplevel Class Reference

Interface for toplevel surfaces. More...

#include <gdkmm/toplevel.h>

Inheritance diagram for Gdk::Toplevel:
Inheritance graph
[legend]

Public Types

enum class  State {
  MINIMIZED = 1 << 0 ,
  MAXIMIZED = 1 << 1 ,
  STICKY = 1 << 2 ,
  FULLSCREEN = 1 << 3 ,
  ABOVE = 1 << 4 ,
  BELOW = 1 << 5 ,
  FOCUSED = 1 << 6 ,
  TILED = 1 << 7 ,
  TOP_TILED = 1 << 8 ,
  TOP_RESIZABLE = 1 << 9 ,
  RIGHT_TILED = 1 << 10 ,
  RIGHT_RESIZABLE = 1 << 11 ,
  BOTTOM_TILED = 1 << 12 ,
  BOTTOM_RESIZABLE = 1 << 13 ,
  LEFT_TILED = 1 << 14 ,
  LEFT_RESIZABLE = 1 << 15
}
 Specifies the state of a toplevel surface. More...
 

Public Member Functions

 Toplevel (Toplevel && src) noexcept
 
Topleveloperator= (Toplevel && src) noexcept
 
 ~Toplevel () noexcept override
 
GdkToplevel * gobj ()
 Provides access to the underlying C GObject. More...
 
const GdkToplevel * gobj () const
 Provides access to the underlying C GObject. More...
 
void present (const Glib::RefPtr< ToplevelLayout > & layout)
 Present toplevel after having processed the Gdk::ToplevelLayout rules. More...
 
bool minimize ()
 Asks to minimize the toplevel. More...
 
bool lower ()
 Asks to lower the toplevel below other windows. More...
 
void focus (guint32 timestamp)
 Sets keyboard focus to surface. More...
 
State get_state () const
 Gets the bitwise or of the currently active surface state flags, from the Gdk::Toplevel::State enumeration. More...
 
void set_title (const Glib::ustring & title)
 Sets the title of a toplevel surface. More...
 
void set_startup_id (const Glib::ustring & startup_id)
 Sets the startup notification ID. More...
 
void set_transient_for (const Glib::RefPtr< Surface > & parent)
 Sets a transient-for parent. More...
 
void set_modal (bool modal=true)
 Sets the toplevel to be modal. More...
 
void set_icon_list (const std::vector< Glib::RefPtr< Texture >> & surfaces)
 Sets a list of icons for the surface. More...
 
bool show_window_menu (const Glib::RefPtr< Event > & event)
 Asks the windowing system to show the window menu. More...
 
void set_decorated (bool decorated=true)
 Sets the toplevel to be decorated. More...
 
void set_deletable (bool deletable=true)
 Sets the toplevel to be deletable. More...
 
bool supports_edge_constraints () const
 Returns whether the desktop environment supports tiled window states. More...
 
void inhibit_system_shortcuts (const Glib::RefPtr< Event > & event)
 Requests that the toplevel inhibit the system shortcuts. More...
 
void restore_system_shortcuts ()
 Restore default system keyboard shortcuts which were previously inhibited. More...
 
void begin_resize (SurfaceEdge edge, const Glib::RefPtr< Device > & device, int button, double x, double y, guint32 timestamp)
 Begins an interactive resize operation. More...
 
void begin_move (const Glib::RefPtr< Device > & device, int button, double x, double y, guint32 timestamp)
 Begins an interactive move operation. More...
 
Glib::SignalProxy< void(ToplevelSize &)> signal_compute_size ()
 
Glib::PropertyProxy_ReadOnly< Stateproperty_state () const
 The state of the toplevel. More...
 
Glib::PropertyProxy< Glib::ustring > property_title ()
 The title of the surface. More...
 
Glib::PropertyProxy_ReadOnly< Glib::ustring > property_title () const
 The title of the surface. More...
 
Glib::PropertyProxy< Glib::ustring > property_startup_id ()
 The startup ID of the surface. More...
 
Glib::PropertyProxy_ReadOnly< Glib::ustring > property_startup_id () const
 The startup ID of the surface. More...
 
Glib::PropertyProxy< Glib::RefPtr< Surface > > property_transient_for ()
 The transient parent of the surface. More...
 
Glib::PropertyProxy_ReadOnly< Glib::RefPtr< Surface > > property_transient_for () const
 The transient parent of the surface. More...
 
Glib::PropertyProxy< bool > property_modal ()
 Whether the surface is modal. More...
 
Glib::PropertyProxy_ReadOnly< bool > property_modal () const
 Whether the surface is modal. More...
 
Glib::PropertyProxy< bool > property_decorated ()
 Whether the window manager should add decorations. More...
 
Glib::PropertyProxy_ReadOnly< bool > property_decorated () const
 Whether the window manager should add decorations. More...
 
Glib::PropertyProxy< bool > property_deletable ()
 Whether the window manager should allow to close the surface. More...
 
Glib::PropertyProxy_ReadOnly< bool > property_deletable () const
 Whether the window manager should allow to close the surface. More...
 
Glib::PropertyProxy< FullscreenModeproperty_fullscreen_mode ()
 The fullscreen mode of the surface. More...
 
Glib::PropertyProxy_ReadOnly< FullscreenModeproperty_fullscreen_mode () const
 The fullscreen mode of the surface. More...
 
Glib::PropertyProxy_ReadOnly< bool > property_shortcuts_inhibited () const
 Whether the surface should inhibit keyboard shortcuts. More...
 

Static Public Member Functions

static void add_interface (GType gtype_implementer)
 
static GType get_type ()
 Get the GType for this class, for use with the underlying GObject type system. More...
 

Protected Member Functions

 Toplevel ()
 You should derive from this class to use it. More...
 

Related Functions

(Note that these are not member functions.)

Glib::RefPtr< Gdk::Toplevelwrap (GdkToplevel * object, bool take_copy=false)
 A Glib::wrap() method for this object. More...
 

Detailed Description

Interface for toplevel surfaces.

A Gdk::Toplevel is a freestanding toplevel surface.

The Gdk::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.

See also
Gdk::Surface, Gdk::Popup
Since gtkmm 3.98:

Constructor & Destructor Documentation

◆ Toplevel() [1/2]

Gdk::Toplevel::Toplevel ( )
protected

You should derive from this class to use it.

◆ Toplevel() [2/2]

Gdk::Toplevel::Toplevel ( Toplevel &&  src)
noexcept

◆ ~Toplevel()

Gdk::Toplevel::~Toplevel ( )
overridenoexcept

Member Function Documentation

◆ add_interface()

static void Gdk::Toplevel::add_interface ( GType  gtype_implementer)
static

◆ begin_move()

void Gdk::Toplevel::begin_move ( const Glib::RefPtr< Device > &  device,
int  button,
double  x,
double  y,
guint32  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::get_time()).

◆ begin_resize()

void Gdk::Toplevel::begin_resize ( SurfaceEdge  edge,
const Glib::RefPtr< Device > &  device,
int  button,
double  x,
double  y,
guint32  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::get_time()).

◆ focus()

void Gdk::Toplevel::focus ( guint32  timestamp)

Sets keyboard focus to surface.

In most cases, Gtk::Window::present_with_time() should be used on a Gtk::Window, rather than calling this function.

Parameters
timestampTimestamp of the event triggering the surface focus.

◆ get_state()

State Gdk::Toplevel::get_state ( ) const

Gets the bitwise or of the currently active surface state flags, from the Gdk::Toplevel::State enumeration.

Returns
Surface state bitfield.

◆ get_type()

static GType Gdk::Toplevel::get_type ( )
static

Get the GType for this class, for use with the underlying GObject type system.

◆ gobj() [1/2]

GdkToplevel* Gdk::Toplevel::gobj ( )
inline

Provides access to the underlying C GObject.

◆ gobj() [2/2]

const GdkToplevel* Gdk::Toplevel::gobj ( ) const
inline

Provides access to the underlying C GObject.

◆ inhibit_system_shortcuts()

void Gdk::Toplevel::inhibit_system_shortcuts ( const Glib::RefPtr< Event > &  event)

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 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_shortcuts_inhibited() property.

Parameters
eventThe Gdk::Event that is triggering the inhibit request, or nullptr if none is available.

◆ lower()

bool Gdk::Toplevel::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.

◆ minimize()

bool Gdk::Toplevel::minimize ( )

Asks to minimize the toplevel.

The windowing system may choose to ignore the request.

Returns
true if the surface was minimized.

◆ operator=()

Toplevel& Gdk::Toplevel::operator= ( Toplevel &&  src)
noexcept

◆ present()

void Gdk::Toplevel::present ( const Glib::RefPtr< ToplevelLayout > &  layout)

Present toplevel after having processed the Gdk::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 signal_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::ToplevelLayout object used to layout.

◆ property_decorated() [1/2]

Glib::PropertyProxy< bool > Gdk::Toplevel::property_decorated ( )

Whether the window manager should add decorations.

Default value: false

Returns
A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

◆ property_decorated() [2/2]

Glib::PropertyProxy_ReadOnly< bool > Gdk::Toplevel::property_decorated ( ) const

Whether the window manager should add decorations.

Default value: false

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ property_deletable() [1/2]

Glib::PropertyProxy< bool > Gdk::Toplevel::property_deletable ( )

Whether the window manager should allow to close the surface.

Default value: false

Returns
A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

◆ property_deletable() [2/2]

Glib::PropertyProxy_ReadOnly< bool > Gdk::Toplevel::property_deletable ( ) const

Whether the window manager should allow to close the surface.

Default value: false

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ property_fullscreen_mode() [1/2]

Glib::PropertyProxy< FullscreenMode > Gdk::Toplevel::property_fullscreen_mode ( )

The fullscreen mode of the surface.

Default value: Gdk::FullscreenMode::ON_CURRENT_MONITOR

Returns
A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

◆ property_fullscreen_mode() [2/2]

Glib::PropertyProxy_ReadOnly< FullscreenMode > Gdk::Toplevel::property_fullscreen_mode ( ) const

The fullscreen mode of the surface.

Default value: Gdk::FullscreenMode::ON_CURRENT_MONITOR

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ property_modal() [1/2]

Glib::PropertyProxy< bool > Gdk::Toplevel::property_modal ( )

Whether the surface is modal.

Default value: false

Returns
A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

◆ property_modal() [2/2]

Glib::PropertyProxy_ReadOnly< bool > Gdk::Toplevel::property_modal ( ) const

Whether the surface is modal.

Default value: false

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ property_shortcuts_inhibited()

Glib::PropertyProxy_ReadOnly< bool > Gdk::Toplevel::property_shortcuts_inhibited ( ) const

Whether the surface should inhibit keyboard shortcuts.

Default value: false

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ property_startup_id() [1/2]

Glib::PropertyProxy< Glib::ustring > Gdk::Toplevel::property_startup_id ( )

The startup ID of the surface.

See Gdk::AppLaunchContext for more information about startup feedback.

Default value: ""

Returns
A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

◆ property_startup_id() [2/2]

Glib::PropertyProxy_ReadOnly< Glib::ustring > Gdk::Toplevel::property_startup_id ( ) const

The startup ID of the surface.

See Gdk::AppLaunchContext for more information about startup feedback.

Default value: ""

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ property_state()

Glib::PropertyProxy_ReadOnly< State > Gdk::Toplevel::property_state ( ) const

The state of the toplevel.

Default value: 0

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ property_title() [1/2]

Glib::PropertyProxy< Glib::ustring > Gdk::Toplevel::property_title ( )

The title of the surface.

Default value: ""

Returns
A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

◆ property_title() [2/2]

Glib::PropertyProxy_ReadOnly< Glib::ustring > Gdk::Toplevel::property_title ( ) const

The title of the surface.

Default value: ""

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ property_transient_for() [1/2]

Glib::PropertyProxy< Glib::RefPtr<Surface> > Gdk::Toplevel::property_transient_for ( )

The transient parent of the surface.

Returns
A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

◆ property_transient_for() [2/2]

Glib::PropertyProxy_ReadOnly< Glib::RefPtr<Surface> > Gdk::Toplevel::property_transient_for ( ) const

The transient parent of the surface.

Returns
A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

◆ restore_system_shortcuts()

void Gdk::Toplevel::restore_system_shortcuts ( )

Restore default system keyboard shortcuts which were previously inhibited.

This undoes the effect of inhibit_system_shortcuts().

◆ set_decorated()

void Gdk::Toplevel::set_decorated ( bool  decorated = true)

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.

◆ set_deletable()

void Gdk::Toplevel::set_deletable ( bool  deletable = true)

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.

◆ set_icon_list()

void Gdk::Toplevel::set_icon_list ( const std::vector< Glib::RefPtr< 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.

◆ set_modal()

void Gdk::Toplevel::set_modal ( bool  modal = true)

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 set_transient_for().

Parameters
modaltrue if the surface is modal, false otherwise.

◆ set_startup_id()

void Gdk::Toplevel::set_startup_id ( const Glib::ustring &  startup_id)

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_idA string with startup-notification identifier.

◆ set_title()

void Gdk::Toplevel::set_title ( const Glib::ustring &  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.

◆ set_transient_for()

void Gdk::Toplevel::set_transient_for ( const Glib::RefPtr< 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::set_transient_for() if you’re using Gtk::Window or Gtk::Dialog.

Parameters
parentAnother toplevel Gdk::Surface.

◆ show_window_menu()

bool Gdk::Toplevel::show_window_menu ( const Glib::RefPtr< 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 to show the menu for.
Returns
true if the window menu was shown and false otherwise.

◆ signal_compute_size()

Glib::SignalProxy<void(ToplevelSize&)> Gdk::Toplevel::signal_compute_size ( )
Slot Prototype:
void on_my_compute_size(ToplevelSize& size)

Flags: Run Last

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

It will normally be emitted during or after 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.

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

Parameters
sizeA Gdk::ToplevelSize.

◆ supports_edge_constraints()

bool Gdk::Toplevel::supports_edge_constraints ( ) const

Returns whether the desktop environment supports tiled window states.

Returns
true if the desktop environment supports tiled window states.

Friends And Related Function Documentation

◆ wrap()

Glib::RefPtr< Gdk::Toplevel > wrap ( GdkToplevel *  object,
bool  take_copy = false 
)
related

A Glib::wrap() method for this object.

Parameters
objectThe C instance.
take_copyFalse if the result should take ownership of the C instance. True if it should take a new copy or ref.
Returns
A C++ instance that wraps this C instance.