2020-02-29 15:07:43 +00:00
|
|
|
|
/*
|
|
|
|
|
* Copyright © 2020 Red Hat, Inc.
|
|
|
|
|
*
|
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*
|
|
|
|
|
* Authors: Matthias Clasen <mclasen@redhat.com>
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
|
|
#include "gdkintl.h"
|
|
|
|
|
#include "gdk-private.h"
|
|
|
|
|
#include "gdktoplevelprivate.h"
|
|
|
|
|
|
2020-07-30 21:06:59 +00:00
|
|
|
|
#include <graphene-gobject.h>
|
2020-05-17 15:45:37 +00:00
|
|
|
|
#include <math.h>
|
|
|
|
|
|
2020-02-29 15:07:43 +00:00
|
|
|
|
/**
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* GdkToplevel:
|
2020-02-29 15:07:43 +00:00
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* A `GdkToplevel` is a freestanding toplevel surface.
|
2020-10-29 18:00:24 +00:00
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* 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.
|
2020-02-29 15:07:43 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2020-03-10 11:24:04 +00:00
|
|
|
|
G_DEFINE_INTERFACE (GdkToplevel, gdk_toplevel, GDK_TYPE_SURFACE)
|
2020-02-29 15:07:43 +00:00
|
|
|
|
|
2020-07-30 21:06:59 +00:00
|
|
|
|
enum
|
|
|
|
|
{
|
|
|
|
|
COMPUTE_SIZE,
|
|
|
|
|
|
|
|
|
|
N_SIGNALS
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static guint signals[N_SIGNALS] = { 0 };
|
|
|
|
|
|
2020-11-20 15:56:36 +00:00
|
|
|
|
static void
|
2020-02-29 15:07:43 +00:00
|
|
|
|
gdk_toplevel_default_present (GdkToplevel *toplevel,
|
|
|
|
|
GdkToplevelLayout *layout)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
gdk_toplevel_default_minimize (GdkToplevel *toplevel)
|
|
|
|
|
{
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
gdk_toplevel_default_lower (GdkToplevel *toplevel)
|
|
|
|
|
{
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_toplevel_default_focus (GdkToplevel *toplevel,
|
|
|
|
|
guint32 timestamp)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
|
gdk_toplevel_default_show_window_menu (GdkToplevel *toplevel,
|
|
|
|
|
GdkEvent *event)
|
|
|
|
|
{
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-09 18:38:08 +00:00
|
|
|
|
static gboolean
|
|
|
|
|
gdk_toplevel_default_supports_edge_constraints (GdkToplevel *toplevel)
|
|
|
|
|
{
|
|
|
|
|
return FALSE;
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-20 14:17:41 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_toplevel_default_inhibit_system_shortcuts (GdkToplevel *toplevel,
|
|
|
|
|
GdkEvent *event)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gdk_toplevel_default_restore_system_shortcuts (GdkToplevel *toplevel)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-30 21:06:59 +00:00
|
|
|
|
void
|
|
|
|
|
gdk_toplevel_notify_compute_size (GdkToplevel *toplevel,
|
|
|
|
|
GdkToplevelSize *size)
|
|
|
|
|
{
|
|
|
|
|
g_signal_emit (toplevel, signals[COMPUTE_SIZE], 0, size);
|
2020-08-07 16:45:19 +00:00
|
|
|
|
gdk_toplevel_size_validate (size);
|
2020-07-30 21:06:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
2020-02-29 15:07:43 +00:00
|
|
|
|
static void
|
|
|
|
|
gdk_toplevel_default_init (GdkToplevelInterface *iface)
|
|
|
|
|
{
|
|
|
|
|
iface->present = gdk_toplevel_default_present;
|
|
|
|
|
iface->minimize = gdk_toplevel_default_minimize;
|
|
|
|
|
iface->lower = gdk_toplevel_default_lower;
|
|
|
|
|
iface->focus = gdk_toplevel_default_focus;
|
|
|
|
|
iface->show_window_menu = gdk_toplevel_default_show_window_menu;
|
2020-03-09 18:38:08 +00:00
|
|
|
|
iface->supports_edge_constraints = gdk_toplevel_default_supports_edge_constraints;
|
2020-03-20 14:17:41 +00:00
|
|
|
|
iface->inhibit_system_shortcuts = gdk_toplevel_default_inhibit_system_shortcuts;
|
|
|
|
|
iface->restore_system_shortcuts = gdk_toplevel_default_restore_system_shortcuts;
|
2020-02-29 15:07:43 +00:00
|
|
|
|
|
2021-02-21 05:13:57 +00:00
|
|
|
|
/**
|
2021-02-25 01:06:52 +00:00
|
|
|
|
* GdkToplevel:state: (attributes org.gtk.Property.get=gdk_toplevel_get_state)
|
2021-02-21 05:13:57 +00:00
|
|
|
|
*
|
|
|
|
|
* The state of the toplevel.
|
|
|
|
|
*/
|
2020-02-29 15:07:43 +00:00
|
|
|
|
g_object_interface_install_property (iface,
|
|
|
|
|
g_param_spec_flags ("state",
|
|
|
|
|
P_("State"),
|
|
|
|
|
P_("State"),
|
gdk: Replace 'WITHDRAWN' state with async 'is-mapped' boolean
It was used by all surfaces to track 'is-mapped', but still part of the
GdkToplevelState, and is now replaced with a separate boolean in the
GdkSurface structure.
It also caused issues when a widget was unmapped, and due to that
unmapped a popover which hid its corresponding surface. When this
surface was hidden, it emitted a state change event, which would then go
back into GTK and queue a resize on popover widget, which would travel
back down to the widget that was originally unmapped, causing confusino
when doing future allocations.
To summarize, one should not hide widgets during allocation, and to
avoid this, make this new is-mapped boolean asynchronous when hiding a
surface, meaning the notification event for the changed mapped state
will be emitted in an idle callback. This avoids the above described
reentry issue.
2020-12-07 17:18:38 +00:00
|
|
|
|
GDK_TYPE_TOPLEVEL_STATE, 0,
|
2020-02-29 15:07:43 +00:00
|
|
|
|
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
|
2021-02-21 05:13:57 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2021-02-25 01:06:52 +00:00
|
|
|
|
* GdkToplevel:title: (attributes org.gtk.Property.set=gdk_toplevel_set_title)
|
2021-02-21 05:13:57 +00:00
|
|
|
|
*
|
|
|
|
|
* The title of the surface.
|
|
|
|
|
*/
|
2020-02-29 15:07:43 +00:00
|
|
|
|
g_object_interface_install_property (iface,
|
|
|
|
|
g_param_spec_string ("title",
|
|
|
|
|
"Title",
|
|
|
|
|
"The title of the surface",
|
|
|
|
|
NULL,
|
|
|
|
|
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY));
|
2021-02-21 05:13:57 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2021-02-25 01:06:52 +00:00
|
|
|
|
* GdkToplevel:startup-id: (attributes org.gtk.Property.set=gdk_toplevel_set_startup_id)
|
2021-02-21 05:13:57 +00:00
|
|
|
|
*
|
|
|
|
|
* The startup ID of the surface.
|
|
|
|
|
*
|
|
|
|
|
* See [class@Gdk.AppLaunchContext] for more information about
|
|
|
|
|
* startup feedback.
|
|
|
|
|
*/
|
2020-02-29 15:07:43 +00:00
|
|
|
|
g_object_interface_install_property (iface,
|
|
|
|
|
g_param_spec_string ("startup-id",
|
|
|
|
|
"Startup ID",
|
|
|
|
|
"The startup ID of the surface",
|
|
|
|
|
NULL,
|
|
|
|
|
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY));
|
2021-02-21 05:13:57 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2021-02-25 01:06:52 +00:00
|
|
|
|
* GdkToplevel:transient-for: (attributes org.gtk.Property.set=gdk_toplevel_set_transient_for)
|
2021-02-21 05:13:57 +00:00
|
|
|
|
*
|
|
|
|
|
* The transient parent of the surface.
|
|
|
|
|
*/
|
2020-02-29 15:07:43 +00:00
|
|
|
|
g_object_interface_install_property (iface,
|
|
|
|
|
g_param_spec_object ("transient-for",
|
|
|
|
|
"Transient For",
|
|
|
|
|
"The transient parent of the surface",
|
|
|
|
|
GDK_TYPE_SURFACE,
|
|
|
|
|
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY));
|
2021-02-21 05:13:57 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2021-02-25 01:06:52 +00:00
|
|
|
|
* GdkToplevel:modal: (attributes org.gtk.Property.set=gdk_toplevel_set_modal)
|
2021-02-21 05:13:57 +00:00
|
|
|
|
*
|
|
|
|
|
* Whether the surface is modal.
|
|
|
|
|
*/
|
2020-02-29 15:07:43 +00:00
|
|
|
|
g_object_interface_install_property (iface,
|
|
|
|
|
g_param_spec_boolean ("modal",
|
|
|
|
|
"Modal",
|
|
|
|
|
"Whether the surface is modal",
|
|
|
|
|
FALSE,
|
|
|
|
|
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY));
|
2021-02-21 05:13:57 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2021-02-25 01:06:52 +00:00
|
|
|
|
* GdkToplevel:icon-list: (attributes org.gtk.Property.set=gdk_toplevel_set_icon_list)
|
2021-02-21 05:13:57 +00:00
|
|
|
|
*
|
|
|
|
|
* A list of textures to use as icon.
|
|
|
|
|
*/
|
2020-02-29 15:07:43 +00:00
|
|
|
|
g_object_interface_install_property (iface,
|
|
|
|
|
g_param_spec_pointer ("icon-list",
|
|
|
|
|
"Icon List",
|
|
|
|
|
"The list of icon textures",
|
|
|
|
|
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY));
|
2021-02-21 05:13:57 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2021-02-25 01:06:52 +00:00
|
|
|
|
* GdkToplevel:decorated: (attributes org.gtk.Property.set=gdk_toplevel_set_decorated)
|
2021-02-21 05:13:57 +00:00
|
|
|
|
*
|
|
|
|
|
* Whether the window manager should add decorations.
|
|
|
|
|
*/
|
2020-02-29 15:07:43 +00:00
|
|
|
|
g_object_interface_install_property (iface,
|
|
|
|
|
g_param_spec_boolean ("decorated",
|
|
|
|
|
"Decorated",
|
|
|
|
|
"Decorated",
|
|
|
|
|
FALSE,
|
|
|
|
|
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY));
|
2021-02-21 05:13:57 +00:00
|
|
|
|
|
|
|
|
|
/**
|
2021-02-25 01:06:52 +00:00
|
|
|
|
* GdkToplevel:deletable: (attributes org.gtk.Property.set=gdk_toplevel_set_deletable)
|
2021-02-21 05:13:57 +00:00
|
|
|
|
*
|
|
|
|
|
* Whether the window manager should allow to close the surface.
|
|
|
|
|
*/
|
2020-02-29 15:07:43 +00:00
|
|
|
|
g_object_interface_install_property (iface,
|
|
|
|
|
g_param_spec_boolean ("deletable",
|
|
|
|
|
"Deletable",
|
|
|
|
|
"Deletable",
|
|
|
|
|
FALSE,
|
|
|
|
|
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY));
|
2021-02-21 05:13:57 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* GdkToplevel:fullscreen-mode:
|
|
|
|
|
*
|
|
|
|
|
* The fullscreen mode of the surface.
|
|
|
|
|
*/
|
2020-03-09 18:49:59 +00:00
|
|
|
|
g_object_interface_install_property (iface,
|
|
|
|
|
g_param_spec_enum ("fullscreen-mode",
|
|
|
|
|
"Fullscreen mode",
|
|
|
|
|
"Fullscreen mode",
|
|
|
|
|
GDK_TYPE_FULLSCREEN_MODE,
|
|
|
|
|
GDK_FULLSCREEN_ON_CURRENT_MONITOR,
|
|
|
|
|
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY));
|
2021-02-21 05:13:57 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* GdkToplevel:shortcuts-inhibited:
|
|
|
|
|
*
|
|
|
|
|
* Whether the surface should inhibit keyboard shortcuts.
|
|
|
|
|
*/
|
2020-03-20 14:17:41 +00:00
|
|
|
|
g_object_interface_install_property (iface,
|
|
|
|
|
g_param_spec_boolean ("shortcuts-inhibited",
|
|
|
|
|
"Shortcuts inhibited",
|
|
|
|
|
"Whether keyboard shortcuts are inhibited",
|
|
|
|
|
FALSE,
|
|
|
|
|
G_PARAM_READABLE | G_PARAM_EXPLICIT_NOTIFY));
|
2020-07-30 21:06:59 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* GdkToplevel::compute-size:
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @toplevel: a `GdkToplevel`
|
|
|
|
|
* @size: (type Gdk.ToplevelSize) (out caller-allocates): a `GdkToplevelSize`
|
2020-07-30 21:06:59 +00:00
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* Emitted when the size for the surface needs to be computed, when
|
|
|
|
|
* it is present.
|
2020-07-30 21:06:59 +00:00
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* It will normally be emitted during or after [method@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.
|
2020-07-30 21:06:59 +00:00
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* 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 [struct@Gdk.ToplevelSize] object. Failing to do so
|
|
|
|
|
* will result in an arbitrary size being used as a result.
|
2020-07-30 21:06:59 +00:00
|
|
|
|
*/
|
|
|
|
|
signals[COMPUTE_SIZE] =
|
|
|
|
|
g_signal_new ("compute-size",
|
|
|
|
|
GDK_TYPE_TOPLEVEL,
|
|
|
|
|
G_SIGNAL_RUN_LAST,
|
|
|
|
|
0,
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
NULL,
|
|
|
|
|
G_TYPE_NONE, 1,
|
|
|
|
|
GDK_TYPE_TOPLEVEL_SIZE | G_SIGNAL_TYPE_STATIC_SCOPE);
|
2020-02-29 15:07:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
guint
|
|
|
|
|
gdk_toplevel_install_properties (GObjectClass *object_class,
|
|
|
|
|
guint first_prop)
|
|
|
|
|
{
|
|
|
|
|
g_object_class_override_property (object_class, first_prop + GDK_TOPLEVEL_PROP_STATE, "state");
|
|
|
|
|
g_object_class_override_property (object_class, first_prop + GDK_TOPLEVEL_PROP_TITLE, "title");
|
|
|
|
|
g_object_class_override_property (object_class, first_prop + GDK_TOPLEVEL_PROP_STARTUP_ID, "startup-id");
|
|
|
|
|
g_object_class_override_property (object_class, first_prop + GDK_TOPLEVEL_PROP_TRANSIENT_FOR, "transient-for");
|
|
|
|
|
g_object_class_override_property (object_class, first_prop + GDK_TOPLEVEL_PROP_MODAL, "modal");
|
|
|
|
|
g_object_class_override_property (object_class, first_prop + GDK_TOPLEVEL_PROP_ICON_LIST, "icon-list");
|
|
|
|
|
g_object_class_override_property (object_class, first_prop + GDK_TOPLEVEL_PROP_DECORATED, "decorated");
|
|
|
|
|
g_object_class_override_property (object_class, first_prop + GDK_TOPLEVEL_PROP_DELETABLE, "deletable");
|
2020-03-09 18:49:59 +00:00
|
|
|
|
g_object_class_override_property (object_class, first_prop + GDK_TOPLEVEL_PROP_FULLSCREEN_MODE, "fullscreen-mode");
|
2020-03-20 14:17:41 +00:00
|
|
|
|
g_object_class_override_property (object_class, first_prop + GDK_TOPLEVEL_PROP_SHORTCUTS_INHIBITED, "shortcuts-inhibited");
|
2020-02-29 15:07:43 +00:00
|
|
|
|
|
|
|
|
|
return GDK_TOPLEVEL_NUM_PROPERTIES;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gdk_toplevel_present:
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @toplevel: the `GdkToplevel` to show
|
|
|
|
|
* @layout: the `GdkToplevelLayout` object used to layout
|
|
|
|
|
*
|
|
|
|
|
* Present @toplevel after having processed the `GdkToplevelLayout` rules.
|
2020-02-29 15:07:43 +00:00
|
|
|
|
*
|
2020-08-04 06:21:38 +00:00
|
|
|
|
* If the toplevel was previously not showing, it will be showed,
|
2020-02-29 15:07:43 +00:00
|
|
|
|
* otherwise it will change layout according to @layout.
|
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* GDK may emit the [signal@Gdk.Toplevel::compute-size] signal to let
|
|
|
|
|
* the user of this toplevel compute the preferred size of the toplevel
|
|
|
|
|
* surface.
|
2020-07-30 21:06:59 +00:00
|
|
|
|
*
|
2020-11-20 15:56:36 +00:00
|
|
|
|
* Presenting is asynchronous and the specified layout parameters are not
|
|
|
|
|
* guaranteed to be respected.
|
2020-02-29 15:07:43 +00:00
|
|
|
|
*/
|
2020-11-20 15:56:36 +00:00
|
|
|
|
void
|
2020-02-29 15:07:43 +00:00
|
|
|
|
gdk_toplevel_present (GdkToplevel *toplevel,
|
|
|
|
|
GdkToplevelLayout *layout)
|
|
|
|
|
{
|
2020-11-20 15:56:36 +00:00
|
|
|
|
g_return_if_fail (GDK_IS_TOPLEVEL (toplevel));
|
|
|
|
|
g_return_if_fail (layout != NULL);
|
2020-02-29 15:07:43 +00:00
|
|
|
|
|
2020-11-20 15:56:36 +00:00
|
|
|
|
GDK_TOPLEVEL_GET_IFACE (toplevel)->present (toplevel, layout);
|
2020-02-29 15:07:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gdk_toplevel_minimize:
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @toplevel: a `GdkToplevel`
|
2020-02-29 15:07:43 +00:00
|
|
|
|
*
|
|
|
|
|
* Asks to minimize the @toplevel.
|
|
|
|
|
*
|
|
|
|
|
* The windowing system may choose to ignore the request.
|
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE if the surface was minimized
|
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
gdk_toplevel_minimize (GdkToplevel *toplevel)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GDK_IS_TOPLEVEL (toplevel), FALSE);
|
|
|
|
|
|
|
|
|
|
return GDK_TOPLEVEL_GET_IFACE (toplevel)->minimize (toplevel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gdk_toplevel_lower:
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @toplevel: a `GdkToplevel`
|
2020-02-29 15:07:43 +00:00
|
|
|
|
*
|
|
|
|
|
* Asks to lower the @toplevel below other windows.
|
|
|
|
|
*
|
|
|
|
|
* The windowing system may choose to ignore the request.
|
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE if the surface was lowered
|
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
gdk_toplevel_lower (GdkToplevel *toplevel)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GDK_IS_TOPLEVEL (toplevel), FALSE);
|
|
|
|
|
|
|
|
|
|
return GDK_TOPLEVEL_GET_IFACE (toplevel)->lower (toplevel);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gdk_toplevel_focus:
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @toplevel: a `GdkToplevel`
|
2020-02-29 15:07:43 +00:00
|
|
|
|
* @timestamp: timestamp of the event triggering the surface focus
|
|
|
|
|
*
|
|
|
|
|
* Sets keyboard focus to @surface.
|
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* In most cases, [method@Gtk.Window.present_with_time] should be
|
|
|
|
|
* used on a [class@Gtk.Window], rather than calling this function.
|
2020-02-29 15:07:43 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gdk_toplevel_focus (GdkToplevel *toplevel,
|
|
|
|
|
guint32 timestamp)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GDK_IS_TOPLEVEL (toplevel));
|
|
|
|
|
|
2021-04-16 03:22:27 +00:00
|
|
|
|
GDK_TOPLEVEL_GET_IFACE (toplevel)->focus (toplevel, timestamp);
|
2020-02-29 15:07:43 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-25 01:06:52 +00:00
|
|
|
|
* gdk_toplevel_get_state: (attributes org.gtk.Method.get_property=state)
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @toplevel: a `GdkToplevel`
|
2020-02-29 15:07:43 +00:00
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* Gets the bitwise or of the currently active surface state flags,
|
|
|
|
|
* from the `GdkToplevelState` enumeration.
|
2020-02-29 15:07:43 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns: surface state bitfield
|
|
|
|
|
*/
|
2020-09-10 04:39:03 +00:00
|
|
|
|
GdkToplevelState
|
2020-02-29 15:07:43 +00:00
|
|
|
|
gdk_toplevel_get_state (GdkToplevel *toplevel)
|
|
|
|
|
{
|
2020-09-10 04:39:03 +00:00
|
|
|
|
GdkToplevelState state;
|
2020-02-29 15:07:43 +00:00
|
|
|
|
|
|
|
|
|
g_return_val_if_fail (GDK_IS_TOPLEVEL (toplevel), 0);
|
|
|
|
|
|
|
|
|
|
g_object_get (toplevel, "state", &state, NULL);
|
|
|
|
|
|
|
|
|
|
return state;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-25 01:06:52 +00:00
|
|
|
|
* gdk_toplevel_set_title: (attributes org.gtk.Method.set_property=title)
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @toplevel: a `GdkToplevel`
|
2020-02-29 15:07:43 +00:00
|
|
|
|
* @title: title of @surface
|
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* Sets the title of a toplevel surface.
|
|
|
|
|
*
|
|
|
|
|
* The title maybe be displayed in the titlebar,
|
2020-02-29 15:07:43 +00:00
|
|
|
|
* in lists of windows, etc.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gdk_toplevel_set_title (GdkToplevel *toplevel,
|
|
|
|
|
const char *title)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GDK_IS_TOPLEVEL (toplevel));
|
|
|
|
|
|
|
|
|
|
g_object_set (toplevel, "title", title, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-25 01:06:52 +00:00
|
|
|
|
* gdk_toplevel_set_startup_id: (attributes org.gtk.Method.set_property=startup-id)
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @toplevel: a `GdkToplevel`
|
2020-02-29 15:07:43 +00:00
|
|
|
|
* @startup_id: a string with startup-notification identifier
|
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* Sets the startup notification ID.
|
|
|
|
|
*
|
|
|
|
|
* When using GTK, typically you should use
|
|
|
|
|
* [method@Gtk.Window.set_startup_id] instead of this
|
|
|
|
|
* low-level function.
|
2020-02-29 15:07:43 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gdk_toplevel_set_startup_id (GdkToplevel *toplevel,
|
|
|
|
|
const char *startup_id)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GDK_IS_TOPLEVEL (toplevel));
|
|
|
|
|
|
|
|
|
|
g_object_set (toplevel, "startup-id", startup_id, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-25 01:06:52 +00:00
|
|
|
|
* gdk_toplevel_set_transient_for: (attributes org.gtk.Method.set_property=transient-for)
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @toplevel: a `GdkToplevel`
|
|
|
|
|
* @parent: another toplevel `GdkSurface`
|
2020-02-29 15:07:43 +00:00
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* Sets a transient-for parent.
|
2020-02-29 15:07:43 +00:00
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* 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 [method@Gtk.Window.set_transient_for] if you’re using
|
|
|
|
|
* [class@Gtk.Window] or [class@Gtk.Dialog].
|
2020-02-29 15:07:43 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gdk_toplevel_set_transient_for (GdkToplevel *toplevel,
|
|
|
|
|
GdkSurface *parent)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GDK_IS_TOPLEVEL (toplevel));
|
|
|
|
|
|
|
|
|
|
g_object_set (toplevel, "transient-for", parent, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-14 05:23:09 +00:00
|
|
|
|
/**
|
2021-02-25 01:06:52 +00:00
|
|
|
|
* gdk_toplevel_set_modal: (attributes org.gtk.Method.set_property=modal)
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @toplevel: a `GdkToplevel`
|
2020-03-14 05:23:09 +00:00
|
|
|
|
* @modal: %TRUE if the surface is modal, %FALSE otherwise.
|
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* Sets the toplevel to be modal.
|
|
|
|
|
*
|
2020-03-14 05:23:09 +00:00
|
|
|
|
* 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
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* previously called [method@Gdk.Toplevel.set_transient_for].
|
2020-03-14 05:23:09 +00:00
|
|
|
|
*/
|
2020-02-29 15:07:43 +00:00
|
|
|
|
void
|
|
|
|
|
gdk_toplevel_set_modal (GdkToplevel *toplevel,
|
|
|
|
|
gboolean modal)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GDK_IS_TOPLEVEL (toplevel));
|
|
|
|
|
|
|
|
|
|
g_object_set (toplevel, "modal", modal, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-25 01:06:52 +00:00
|
|
|
|
* gdk_toplevel_set_icon_list: (attributes org.gtk.Method.set_property=icon-list)
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @toplevel: a `GdkToplevel`
|
2020-02-29 15:07:43 +00:00
|
|
|
|
* @surfaces: (transfer none) (element-type GdkTexture):
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* A list of textures to use as icon, of different sizes
|
2020-02-29 15:07:43 +00:00
|
|
|
|
*
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gdk_toplevel_set_icon_list (GdkToplevel *toplevel,
|
|
|
|
|
GList *surfaces)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GDK_IS_TOPLEVEL (toplevel));
|
|
|
|
|
|
|
|
|
|
g_object_set (toplevel, "icon-list", surfaces, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gdk_toplevel_show_window_menu:
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @toplevel: a `GdkToplevel`
|
|
|
|
|
* @event: a `GdkEvent` to show the menu for
|
2020-02-29 15:07:43 +00:00
|
|
|
|
*
|
|
|
|
|
* 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.
|
|
|
|
|
*
|
|
|
|
|
* Returns: %TRUE if the window menu was shown and %FALSE otherwise.
|
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
gdk_toplevel_show_window_menu (GdkToplevel *toplevel,
|
|
|
|
|
GdkEvent *event)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GDK_IS_TOPLEVEL (toplevel), FALSE);
|
|
|
|
|
|
|
|
|
|
return GDK_TOPLEVEL_GET_IFACE (toplevel)->show_window_menu (toplevel, event);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-25 01:06:52 +00:00
|
|
|
|
* gdk_toplevel_set_decorated: (attributes org.gtk.Method.set_property=decorated)
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @toplevel: a `GdkToplevel`
|
2020-02-29 15:07:43 +00:00
|
|
|
|
* @decorated: %TRUE to request decorations
|
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* Sets the toplevel to be decorated.
|
|
|
|
|
*
|
2020-02-29 15:07:43 +00:00
|
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gdk_toplevel_set_decorated (GdkToplevel *toplevel,
|
|
|
|
|
gboolean decorated)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GDK_IS_TOPLEVEL (toplevel));
|
|
|
|
|
|
|
|
|
|
g_object_set (toplevel, "decorated", decorated, NULL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-02-25 01:06:52 +00:00
|
|
|
|
* gdk_toplevel_set_deletable: (attributes org.gtk.Method.set_property=deletable)
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @toplevel: a `GdkToplevel`
|
2020-02-29 15:07:43 +00:00
|
|
|
|
* @deletable: %TRUE to request a delete button
|
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* Sets the toplevel to be deletable.
|
|
|
|
|
*
|
2020-02-29 15:07:43 +00:00
|
|
|
|
* Setting @deletable to %TRUE hints the desktop environment
|
|
|
|
|
* that it should offer the user a way to close the surface.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gdk_toplevel_set_deletable (GdkToplevel *toplevel,
|
|
|
|
|
gboolean deletable)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GDK_IS_TOPLEVEL (toplevel));
|
|
|
|
|
|
|
|
|
|
g_object_set (toplevel, "deletable", deletable, NULL);
|
|
|
|
|
}
|
2020-03-09 18:38:08 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gdk_toplevel_supports_edge_constraints:
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @toplevel: a `GdkToplevel`
|
2020-03-09 18:38:08 +00:00
|
|
|
|
*
|
|
|
|
|
* Returns whether the desktop environment supports
|
|
|
|
|
* tiled window states.
|
|
|
|
|
*
|
2021-05-18 21:05:26 +00:00
|
|
|
|
* Returns: %TRUE if the desktop environment supports tiled window states
|
2020-03-09 18:38:08 +00:00
|
|
|
|
*/
|
|
|
|
|
gboolean
|
|
|
|
|
gdk_toplevel_supports_edge_constraints (GdkToplevel *toplevel)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (GDK_IS_TOPLEVEL (toplevel), FALSE);
|
|
|
|
|
|
|
|
|
|
return GDK_TOPLEVEL_GET_IFACE (toplevel)->supports_edge_constraints (toplevel);
|
|
|
|
|
}
|
2020-03-20 14:17:41 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gdk_toplevel_inhibit_system_shortcuts:
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @toplevel: a `GdkToplevel`
|
|
|
|
|
* @event: (nullable): the `GdkEvent` that is triggering the inhibit
|
|
|
|
|
* request, or %NULL if none is available
|
|
|
|
|
*
|
|
|
|
|
* Requests that the @toplevel inhibit the system shortcuts.
|
2020-03-20 14:17:41 +00:00
|
|
|
|
*
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* 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.
|
2020-03-20 14:17:41 +00:00
|
|
|
|
*
|
|
|
|
|
* If granted, the rerouting remains active until the default shortcuts
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* processing is restored with [method@Gdk.Toplevel.restore_system_shortcuts],
|
2020-05-28 08:00:03 +00:00
|
|
|
|
* or the request is revoked by the desktop environment, windowing system
|
2020-03-20 14:17:41 +00:00
|
|
|
|
* 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
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* by listening to the [property@Gdk.Toplevel:shortcuts-inhibited] property.
|
2020-03-20 14:17:41 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gdk_toplevel_inhibit_system_shortcuts (GdkToplevel *toplevel,
|
|
|
|
|
GdkEvent *event)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GDK_IS_TOPLEVEL (toplevel));
|
|
|
|
|
|
|
|
|
|
GDK_TOPLEVEL_GET_IFACE (toplevel)->inhibit_system_shortcuts (toplevel,
|
|
|
|
|
event);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gdk_toplevel_restore_system_shortcuts:
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @toplevel: a `GdkToplevel`
|
2020-03-20 14:17:41 +00:00
|
|
|
|
*
|
|
|
|
|
* Restore default system keyboard shortcuts which were previously
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* inhibited.
|
|
|
|
|
*
|
|
|
|
|
* This undoes the effect of [method@Gdk.Toplevel.inhibit_system_shortcuts].
|
2020-03-20 14:17:41 +00:00
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gdk_toplevel_restore_system_shortcuts (GdkToplevel *toplevel)
|
|
|
|
|
{
|
|
|
|
|
g_return_if_fail (GDK_IS_TOPLEVEL (toplevel));
|
|
|
|
|
|
|
|
|
|
GDK_TOPLEVEL_GET_IFACE (toplevel)->restore_system_shortcuts (toplevel);
|
|
|
|
|
}
|
2020-05-17 15:45:37 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gdk_toplevel_begin_resize:
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @toplevel: a `GdkToplevel`
|
2020-05-17 15:45:37 +00:00
|
|
|
|
* @edge: the edge or corner from which the drag is started
|
2020-05-17 16:35:45 +00:00
|
|
|
|
* @device: (nullable): the device used for the operation
|
2020-05-17 15:45:37 +00:00
|
|
|
|
* @button: the button being used to drag, or 0 for a keyboard-initiated drag
|
|
|
|
|
* @x: surface X coordinate of mouse click that began the drag
|
|
|
|
|
* @y: surface Y coordinate of mouse click that began the drag
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @timestamp: timestamp of mouse click that began the drag (use
|
|
|
|
|
* [method@Gdk.Event.get_time])
|
|
|
|
|
*
|
|
|
|
|
* Begins an interactive resize operation.
|
2020-05-17 15:45:37 +00:00
|
|
|
|
*
|
|
|
|
|
* You might use this function to implement a “window resize grip.”
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gdk_toplevel_begin_resize (GdkToplevel *toplevel,
|
|
|
|
|
GdkSurfaceEdge edge,
|
|
|
|
|
GdkDevice *device,
|
|
|
|
|
int button,
|
|
|
|
|
double x,
|
|
|
|
|
double y,
|
|
|
|
|
guint32 timestamp)
|
|
|
|
|
{
|
2020-05-17 16:35:45 +00:00
|
|
|
|
g_return_if_fail (GDK_IS_TOPLEVEL (toplevel));
|
|
|
|
|
|
|
|
|
|
if (device == NULL)
|
|
|
|
|
{
|
|
|
|
|
GdkSeat *seat = gdk_display_get_default_seat (GDK_SURFACE (toplevel)->display);
|
|
|
|
|
if (button == 0)
|
|
|
|
|
device = gdk_seat_get_keyboard (seat);
|
|
|
|
|
else
|
|
|
|
|
device = gdk_seat_get_pointer (seat);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GDK_TOPLEVEL_GET_IFACE (toplevel)->begin_resize (toplevel,
|
|
|
|
|
edge,
|
|
|
|
|
device,
|
|
|
|
|
button,
|
|
|
|
|
x, y,
|
|
|
|
|
timestamp);
|
2020-05-17 15:45:37 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* gdk_toplevel_begin_move:
|
2021-05-20 03:39:18 +00:00
|
|
|
|
* @toplevel: a `GdkToplevel`
|
2020-05-17 15:45:37 +00:00
|
|
|
|
* @device: the device used for the operation
|
|
|
|
|
* @button: the button being used to drag, or 0 for a keyboard-initiated drag
|
|
|
|
|
* @x: surface X coordinate of mouse click that began the drag
|
|
|
|
|
* @y: surface Y coordinate of mouse click that began the drag
|
2021-02-21 05:13:57 +00:00
|
|
|
|
* @timestamp: timestamp of mouse click that began the drag (use
|
|
|
|
|
* [method@Gdk.Event.get_time])
|
|
|
|
|
*
|
|
|
|
|
* Begins an interactive move operation.
|
2020-05-17 15:45:37 +00:00
|
|
|
|
*
|
|
|
|
|
* You might use this function to implement draggable titlebars.
|
|
|
|
|
*/
|
|
|
|
|
void
|
|
|
|
|
gdk_toplevel_begin_move (GdkToplevel *toplevel,
|
|
|
|
|
GdkDevice *device,
|
|
|
|
|
int button,
|
|
|
|
|
double x,
|
|
|
|
|
double y,
|
|
|
|
|
guint32 timestamp)
|
|
|
|
|
{
|
2020-05-17 16:35:45 +00:00
|
|
|
|
g_return_if_fail (GDK_IS_TOPLEVEL (toplevel));
|
|
|
|
|
|
|
|
|
|
if (device == NULL)
|
|
|
|
|
{
|
|
|
|
|
GdkSeat *seat = gdk_display_get_default_seat (GDK_SURFACE (toplevel)->display);
|
|
|
|
|
if (button == 0)
|
|
|
|
|
device = gdk_seat_get_keyboard (seat);
|
|
|
|
|
else
|
|
|
|
|
device = gdk_seat_get_pointer (seat);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GDK_TOPLEVEL_GET_IFACE (toplevel)->begin_move (toplevel,
|
|
|
|
|
device,
|
|
|
|
|
button,
|
|
|
|
|
x, y,
|
|
|
|
|
timestamp);
|
2020-05-17 15:45:37 +00:00
|
|
|
|
}
|