gtkmm: Gdk::Toplevel Class Reference

Interface for toplevel surfaces. More...

#include <gdkmm/toplevel.h>

Inheritance diagram for Gdk::Toplevel:

Public Types

enum  State {

  State::MINIMIZED = 1 << 0,

  State::MAXIMIZED = 1 << 1,

  State::STICKY = 1 << 2,

  State::FULLSCREEN = 1 << 3,

  State::ABOVE = 1 << 4,

  State::BELOW = 1 << 5,

  State::FOCUSED = 1 << 6,

  State::TILED = 1 << 7,

  State::TOP_TILED = 1 << 8,

  State::TOP_RESIZABLE = 1 << 9,

  State::RIGHT_TILED = 1 << 10,

  State::RIGHT_RESIZABLE = 1 << 11,

  State::BOTTOM_TILED = 1 << 12,

  State::BOTTOM_RESIZABLE = 1 << 13,

  State::LEFT_TILED = 1 << 14,

  State::LEFT_RESIZABLE = 1 << 15

}
 Specifies the state of a toplevel surface. More...

 
- Public Types inherited from sigc::trackable
typedef internal::func_destroy_notify func_destroy_notify
 
- Public Types inherited from sigc::notifiable
typedef internal::func_destroy_notify func_destroy_notify
 

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, to be displayed in the titlebar, in lists of windows, etc. More...

 
void set_startup_id (const Glib::ustring& startup_id)
 When using GTK, typically you should use gtk_window_set_startup_id() instead of this low-level function. More...

 
void set_transient_for (const Glib::RefPtr< Surface >& parent)
 Indicates to the window manager that surface is a transient dialog associated with the application surface parent. More...

 
void set_modal (bool modal=true)
 The application can use this hint to tell the window manager that a certain surface has modal behaviour. 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)
 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. More...

 
void set_deletable (bool deletable=true)
 Setting deletable to true hints the desktop environment that it should offer the user a way to close the surface. 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, 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. More...

 
void restore_system_shortcuts ()
 Restore default system keyboard shortcuts which were previously requested to be inhibited by inhibit_system_shortcuts(). More...

 
void begin_resize (SurfaceEdge edge, const Glib::RefPtr< Device >& device, int button, double x, double y, guint32 timestamp)
 Begins an interactive resize operation (for a toplevel surface). More...

 
void begin_move (const Glib::RefPtr< Device >& device, int button, double x, double y, guint32 timestamp)
 Begins an interactive move operation (for a toplevel surface). More...

 
Glib::SignalProxy< void(ToplevelSize&)> signal_compute_size ()
 
Glib::PropertyProxy_ReadOnly< Stateproperty_state () const
 State. More...

 
Glib::PropertyProxy< Glib::ustringproperty_title ()
 The title of the surface. More...

 
Glib::PropertyProxy_ReadOnly< Glib::ustringproperty_title () const
 The title of the surface. More...

 
Glib::PropertyProxy< Glib::ustringproperty_startup_id ()
 The startup ID of the surface. More...

 
Glib::PropertyProxy_ReadOnly< Glib::ustringproperty_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 ()
 Decorated. More...

 
Glib::PropertyProxy_ReadOnly< bool > property_decorated () const
 Decorated. More...

 
Glib::PropertyProxy< bool > property_deletable ()
 Deletable. More...

 
Glib::PropertyProxy_ReadOnly< bool > property_deletable () const
 Deletable. More...

 
Glib::PropertyProxy< FullscreenModeproperty_fullscreen_mode ()
 Fullscreen mode. More...

 
Glib::PropertyProxy_ReadOnly< FullscreenModeproperty_fullscreen_mode () const
 Fullscreen mode. More...

 
Glib::PropertyProxy_ReadOnly< bool > property_shortcuts_inhibited () const
 Whether keyboard shortcuts are inhibited. More...

 
- Public Member Functions inherited from Glib::Interface
 Interface ()
 
 Interface (Interface &&src) noexcept
 
Interfaceoperator= (Interface &&src) noexcept
 
 Interface (const Glib::Interface_Class &interface_class)
 
 Interface (GObject *castitem)
 
 ~Interface () noexcept override
 
 Interface (const Interface &)=delete
 
Interfaceoperator= (const Interface &)=delete
 
GObject * gobj ()
 
const GObject * gobj () const
 
- Public Member Functions inherited from Glib::ObjectBase
 ObjectBase (const ObjectBase &)=delete
 
ObjectBaseoperator= (const ObjectBase &)=delete
 
void set_property_value (const Glib::ustring &property_name, const Glib::ValueBase &value)
 
void get_property_value (const Glib::ustring &property_name, Glib::ValueBase &value) const
 
void set_property (const Glib::ustring &property_name, const PropertyType &value)
 
void get_property (const Glib::ustring &property_name, PropertyType &value) const
 
PropertyType get_property (const Glib::ustring &property_name) const
 
sigc::connection connect_property_changed (const Glib::ustring &property_name, const sigc::slot< void()> &slot)
 
sigc::connection connect_property_changed (const Glib::ustring &property_name, sigc::slot< void()> &&slot)
 
void freeze_notify ()
 
void thaw_notify ()
 
virtual void reference () const
 
virtual void unreference () const
 
GObject * gobj ()
 
const GObject * gobj () const
 
GObject * gobj_copy () const
 
- Public Member Functions inherited from sigc::trackable
 trackable () noexcept
 
 trackable (const trackable &src) noexcept
 
 trackable (trackable &&src) noexcept
 
 ~trackable ()
 
void add_destroy_notify_callback (notifiable *data, func_destroy_notify func) const
 
void notify_callbacks ()
 
trackableoperator= (const trackable &src)
 
trackableoperator= (trackable &&src) noexcept
 
void remove_destroy_notify_callback (notifiable *data) const
 

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...

 
- Protected Member Functions inherited from Glib::ObjectBase
 ObjectBase ()
 
 ObjectBase (const char *custom_type_name)
 
 ObjectBase (const std::type_info &custom_type_info)
 
 ObjectBase (ObjectBase &&src) noexcept
 
ObjectBaseoperator= (ObjectBase &&src) noexcept
 
virtual ~ObjectBase () noexcept=0
 
void initialize (GObject *castitem)
 
void initialize_move (GObject *castitem, Glib::ObjectBase *previous_wrapper)
 

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

Gdk::Toplevel::Toplevel ( )
protected

You should derive from this class to use it.

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

Member Function Documentation

static void Gdk::Toplevel::add_interface ( GType  gtype_implementer)
static
void Gdk::Toplevel::begin_move ( const Glib::RefPtr< Device >&  device,
int  button,
double  x,
double  y,
guint32  timestamp 
)

Begins an interactive move operation (for a toplevel surface).

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.
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 (for a toplevel surface).

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()).
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.
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.
static GType Gdk::Toplevel::get_type ( )
static

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

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

Provides access to the underlying C GObject.

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

Provides access to the underlying C GObject.

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

Requests that the toplevel inhibit the system shortcuts, 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 GdkToplevel::property_shortcuts_inhibited() property.

Parameters
eventThe Gdk::Event that is triggering the inhibit request, or nullptr if none is available.
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.
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.
Toplevel& Gdk::Toplevel::operator= ( Toplevel&&  src)
noexcept
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 'compute-size' signal to let the user of this toplevel compute the preferred size of the toplevel surface. See Gdk::Toplevel::signal_compute_size() for details.

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

Parameters
layoutThe Gdk::ToplevelLayout object used to layout.
Glib::PropertyProxy< bool > Gdk::Toplevel::property_decorated ( )

Decorated.

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.
Glib::PropertyProxy_ReadOnly< bool > Gdk::Toplevel::property_decorated ( ) const

Decorated.

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.
Glib::PropertyProxy< bool > Gdk::Toplevel::property_deletable ( )

Deletable.

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.
Glib::PropertyProxy_ReadOnly< bool > Gdk::Toplevel::property_deletable ( ) const

Deletable.

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.
Glib::PropertyProxy< FullscreenMode > Gdk::Toplevel::property_fullscreen_mode ( )

Fullscreen mode.

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.
Glib::PropertyProxy_ReadOnly< FullscreenMode > Gdk::Toplevel::property_fullscreen_mode ( ) const

Fullscreen mode.

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.
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.
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.
Glib::PropertyProxy_ReadOnly< bool > Gdk::Toplevel::property_shortcuts_inhibited ( ) const

Whether keyboard shortcuts are inhibited.

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.
Glib::PropertyProxy< Glib::ustring > Gdk::Toplevel::property_startup_id ( )

The startup ID 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.
Glib::PropertyProxy_ReadOnly< Glib::ustring > Gdk::Toplevel::property_startup_id ( ) const

The startup ID 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.
Glib::PropertyProxy_ReadOnly< State > Gdk::Toplevel::property_state ( ) const

State.

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.
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.
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.
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.
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.
void Gdk::Toplevel::restore_system_shortcuts ( )

Restore default system keyboard shortcuts which were previously requested to be inhibited by inhibit_system_shortcuts().

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

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 Gdk::Toplevel::set_deletable ( bool  deletable = true)

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 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.
void Gdk::Toplevel::set_modal ( bool  modal = true)

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.
void Gdk::Toplevel::set_startup_id ( const Glib::ustring startup_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.
void Gdk::Toplevel::set_title ( const Glib::ustring title)

Sets the title of a toplevel surface, to be displayed in the titlebar, in lists of windows, etc.

Parameters
titleTitle of surface.
void Gdk::Toplevel::set_transient_for ( const Glib::RefPtr< Surface >&  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.
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.
Glib::SignalProxy<void(ToplevelSize&)> Gdk::Toplevel::signal_compute_size ( )
Slot Prototype:
void on_my_compute_size(ToplevelSize& size)

Flags: Run Last

Compute the desired size of the toplevel, given the information passed via the Gdk::ToplevelSize object.

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 GdkToplevel user to handle this signal; failing to do so will result in an arbitrary size being used as a result.

Parameters
sizeA Gdk::ToplevelSize.
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

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.