Interface Toplevel
- All Superinterfaces:
Proxy
- All Known Implementing Classes:
Toplevel.ToplevelImpl
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.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
Toplevel.Builder<B extends Builder<B>>
static interface
Functional interface declaration of theComputeSizeCallback
callback.static class
The ToplevelImpl type represents a native instance of the Toplevel interface.static class
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
Begins an interactive move operation.default void
beginResize
(SurfaceEdge edge, @Nullable Device device, int button, double x, double y, int timestamp) Begins an interactive resize operation.default void
emitComputeSize
(ToplevelSize size) Emits the "compute-size" signal.default void
focus
(int timestamp) Sets keyboard focus tosurface
.default Set
<ToplevelState> getState()
Gets the bitwise or of the currently active surface state flags, from theGdkToplevelState
enumeration.static Type
getType()
Get the GType of the Toplevel classdefault void
inhibitSystemShortcuts
(@Nullable Event event) Requests that the this Toplevel inhibit the system shortcuts.default boolean
lower()
Asks to lower the this Toplevel below other windows.default boolean
minimize()
Asks to minimize the this Toplevel.Emitted when the size for the surface needs to be computed, when it is present.default void
present
(ToplevelLayout layout) Present this Toplevel after having processed theGdkToplevelLayout
rules.default void
Restore default system keyboard shortcuts which were previously inhibited.default void
setDecorated
(boolean decorated) Sets the toplevel to be decorated.default void
setDeletable
(boolean deletable) Sets the toplevel to be deletable.default void
setIconList
(List<Texture> surfaces) Sets a list of icons for the surface.default void
setModal
(boolean modal) Sets the toplevel to be modal.default void
setStartupId
(String startupId) Sets the startup notification ID.default void
Sets the title of a toplevel surface.default void
setTransientFor
(Surface parent) Sets a transient-for parent.default boolean
showWindowMenu
(Event event) Asks the windowing system to show the window menu.default boolean
Returns whether the desktop environment supports tiled window states.default boolean
titlebarGesture
(TitlebarGesture gesture) Performs a title bar gesture.
-
Method Details
-
getType
-
beginMove
Begins an interactive move operation.You might use this function to implement draggable titlebars.
- Parameters:
device
- the device used for the operationbutton
- the button being used to drag, or 0 for a keyboard-initiated dragx
- surface X coordinate of mouse click that began the dragy
- surface Y coordinate of mouse click that began the dragtimestamp
- timestamp of mouse click that began the drag (useEvent.getTime()
)
-
beginResize
default void beginResize(SurfaceEdge edge, @Nullable @Nullable Device device, int button, double x, double y, int timestamp) Begins an interactive resize operation.You might use this function to implement a “window resize grip.”
- Parameters:
edge
- the edge or corner from which the drag is starteddevice
- the device used for the operationbutton
- the button being used to drag, or 0 for a keyboard-initiated dragx
- surface X coordinate of mouse click that began the dragy
- surface Y coordinate of mouse click that began the dragtimestamp
- timestamp of mouse click that began the drag (useEvent.getTime()
)
-
focus
default void focus(int timestamp) Sets keyboard focus tosurface
.In most cases, gtk_window_present_with_time() should be used on a GtkWindow, rather than calling this function.
- Parameters:
timestamp
- timestamp of the event triggering the surface focus
-
getState
Gets the bitwise or of the currently active surface state flags, from theGdkToplevelState
enumeration.- Returns:
- surface state bitfield
-
inhibitSystemShortcuts
Requests that the this 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
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
Gdk.Toplevel:shortcuts-inhibited
property.- Parameters:
event
- theGdkEvent
that is triggering the inhibit request, ornull
if none is available
-
lower
default boolean lower()Asks to lower the this Toplevel below other windows.The windowing system may choose to ignore the request.
- Returns:
true
if the surface was lowered
-
minimize
default boolean minimize()Asks to minimize the this Toplevel.The windowing system may choose to ignore the request.
- Returns:
true
if the surface was minimized
-
present
Present this Toplevel after having processed theGdkToplevelLayout
rules.If the toplevel was previously not showing, it will be showed, otherwise it will change layout according to
layout
.GDK may emit the
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.
- Parameters:
layout
- theGdkToplevelLayout
object used to layout
-
restoreSystemShortcuts
default void restoreSystemShortcuts()Restore default system keyboard shortcuts which were previously inhibited.This undoes the effect of
inhibitSystemShortcuts(org.gnome.gdk.Event)
. -
setDecorated
default void setDecorated(boolean decorated) Sets the toplevel to be decorated.Setting
decorated
tofalse
hints the desktop environment that the surface has its own, client-side decorations and does not need to have window decorations added.- Parameters:
decorated
-true
to request decorations
-
setDeletable
default void setDeletable(boolean deletable) Sets the toplevel to be deletable.Setting
deletable
totrue
hints the desktop environment that it should offer the user a way to close the surface.- Parameters:
deletable
-true
to request a delete button
-
setIconList
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
- A list of textures to use as icon, of different sizes
-
setModal
default void setModal(boolean 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
setTransientFor(org.gnome.gdk.Surface)
.- Parameters:
modal
-true
if the surface is modal,false
otherwise.
-
setStartupId
Sets the startup notification ID.When using GTK, typically you should use gtk_window_set_startup_id() instead of this low-level function.
- Parameters:
startupId
- a string with startup-notification identifier
-
setTitle
Sets the title of a toplevel surface.The title maybe be displayed in the titlebar, in lists of windows, etc.
- Parameters:
title
- title ofsurface
-
setTransientFor
Sets a transient-for parent.Indicates to the window manager that
surface
is a transient dialog associated with the application surfaceparent
. This allows the window manager to do things like centersurface
onparent
and keepsurface
aboveparent
.See gtk_window_set_transient_for() if you’re using GtkWindow.
- Parameters:
parent
- another toplevelGdkSurface
-
showWindowMenu
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
- aGdkEvent
to show the menu for- Returns:
true
if the window menu was shown andfalse
otherwise.
-
supportsEdgeConstraints
default boolean supportsEdgeConstraints()Returns whether the desktop environment supports tiled window states.- Returns:
true
if the desktop environment supports tiled window states
-
titlebarGesture
Performs a title bar gesture.- Parameters:
gesture
- aGdkTitlebarGesture
- Returns:
- whether the gesture was performed
-
onComputeSize
default SignalConnection<Toplevel.ComputeSizeCallback> onComputeSize(Toplevel.ComputeSizeCallback handler) 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
present(org.gnome.gdk.ToplevelLayout)
, 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.ToplevelSize
object. Failing to do so will result in an arbitrary size being used as a result.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitComputeSize
Emits the "compute-size" signal. SeeonComputeSize(org.gnome.gdk.Toplevel.ComputeSizeCallback)
.
-