[gtk/present-toplevel-2: 40/59] toplevel: add focus properties
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/present-toplevel-2: 40/59] toplevel: add focus properties
- Date: Thu, 5 Mar 2020 18:19:59 +0000 (UTC)
commit ef63dfe7f57c2e59931e35925c14a7553de76de5
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Mar 3 10:27:40 2020 -0800
toplevel: add focus properties
gdk/gdktoplevel.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++
gdk/gdktoplevel.h | 7 +++++++
gdk/gdktoplevelprivate.h | 2 ++
3 files changed, 59 insertions(+)
---
diff --git a/gdk/gdktoplevel.c b/gdk/gdktoplevel.c
index 9b53caf7bb..82114fefad 100644
--- a/gdk/gdktoplevel.c
+++ b/gdk/gdktoplevel.c
@@ -120,6 +120,18 @@ gdk_toplevel_default_init (GdkToplevelInterface *iface)
"Whether the surface is below all other surfaces",
FALSE,
G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY));
+ g_object_interface_install_property (iface,
+ g_param_spec_boolean ("accept-focus",
+ "Accept focus",
+ "Whether the surface should accept keyboard focus",
+ TRUE,
+ G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY));
+ g_object_interface_install_property (iface,
+ g_param_spec_boolean ("focus-on-map",
+ "Focus on map",
+ "Whether the surface should receive keyboard focus on map",
+ TRUE,
+ G_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY));
}
guint
@@ -134,6 +146,8 @@ gdk_toplevel_install_properties (GObjectClass *object_class,
g_object_class_override_property (object_class, first_prop + GDK_TOPLEVEL_PROP_STICKY, "sticky");
g_object_class_override_property (object_class, first_prop + GDK_TOPLEVEL_PROP_KEEP_ABOVE, "keep-above");
g_object_class_override_property (object_class, first_prop + GDK_TOPLEVEL_PROP_KEEP_BELOW, "keep-below");
+ g_object_class_override_property (object_class, first_prop + GDK_TOPLEVEL_PROP_ACCEPT_FOCUS,
"accept-focus");
+ g_object_class_override_property (object_class, first_prop + GDK_TOPLEVEL_PROP_FOCUS_ON_MAP,
"focus-on-map");
return GDK_TOPLEVEL_NUM_PROPERTIES;
}
@@ -377,3 +391,39 @@ gdk_toplevel_set_keep_below (GdkToplevel *toplevel,
g_object_set (toplevel, "keep-below", below, NULL);
}
+
+/**
+ * gdk_toplevel_set_accept_focus:
+ * @toplevel: a #GdkToplevel
+ * @accept_focus: whether @toplevel should accept keyboard focus
+ *
+ * Setting @accept_focus to %FALSE hints the desktop environment
+ * that the surface doesn’t want to receive input focus.
+ */
+void
+gdk_toplevel_set_accept_focus (GdkToplevel *toplevel,
+ gboolean accept_focus)
+{
+ g_return_if_fail (GDK_IS_TOPLEVEL (toplevel));
+
+ g_object_set (toplevel, "accept-focus", accept_focus, NULL);
+}
+
+/**
+ * gdk_toplevel_set_focus_on_map:
+ * @toplevel: a #GdkToplevel
+ * @focus_on_map: whether @toplevel should receive input focus when mapped
+ *
+ * Setting @focus_on_map to %FALSE hints the desktop environment that the
+ * surface doesn’t want to receive input focus when it is mapped.
+ * focus_on_map should be turned off for surfaces that aren’t triggered
+ * interactively (such as popups from network activity).
+ */
+void
+gdk_toplevel_set_focus_on_map (GdkToplevel *toplevel,
+ gboolean focus_on_map)
+{
+ g_return_if_fail (GDK_IS_TOPLEVEL (toplevel));
+
+ g_object_set (toplevel, "focus-on-map", focus_on_map, NULL);
+}
diff --git a/gdk/gdktoplevel.h b/gdk/gdktoplevel.h
index 9854d0f30c..800d9cdff3 100644
--- a/gdk/gdktoplevel.h
+++ b/gdk/gdktoplevel.h
@@ -81,6 +81,13 @@ GDK_AVAILABLE_IN_ALL
void gdk_toplevel_set_keep_below (GdkToplevel *toplevel,
gboolean below);
+GDK_AVAILABLE_IN_ALL
+void gdk_toplevel_set_accept_focus (GdkToplevel *toplevel,
+ gboolean accept_focus);
+
+GDK_AVAILABLE_IN_ALL
+void gdk_toplevel_set_focus_on_map (GdkToplevel *toplevel,
+ gboolean focus_on_map);
G_END_DECLS
#endif /* __GDK_TOPLEVEL_H__ */
diff --git a/gdk/gdktoplevelprivate.h b/gdk/gdktoplevelprivate.h
index 09a3d905e4..062814776b 100644
--- a/gdk/gdktoplevelprivate.h
+++ b/gdk/gdktoplevelprivate.h
@@ -30,6 +30,8 @@ typedef enum {
GDK_TOPLEVEL_PROP_STICKY,
GDK_TOPLEVEL_PROP_KEEP_ABOVE,
GDK_TOPLEVEL_PROP_KEEP_BELOW,
+ GDK_TOPLEVEL_PROP_ACCEPT_FOCUS,
+ GDK_TOPLEVEL_PROP_FOCUS_ON_MAP,
GDK_TOPLEVEL_NUM_PROPERTIES
} GdkToplevelProperties;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]