[gtk/present-toplevel-2: 49/71] toplevel: Add focus
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/present-toplevel-2: 49/71] toplevel: Add focus
- Date: Thu, 5 Mar 2020 02:30:41 +0000 (UTC)
commit 23e175d822f7544864b4bd6ad812e337c3dc4be0
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Mar 3 10:05:15 2020 -0800
toplevel: Add focus
gdk/gdktoplevel.c | 26 ++++++++++++++++++++++++++
gdk/gdktoplevel.h | 4 ++++
gdk/gdktoplevelprivate.h | 2 ++
3 files changed, 32 insertions(+)
---
diff --git a/gdk/gdktoplevel.c b/gdk/gdktoplevel.c
index c3dadb7a43..9b53caf7bb 100644
--- a/gdk/gdktoplevel.c
+++ b/gdk/gdktoplevel.c
@@ -52,6 +52,12 @@ gdk_toplevel_default_minimize (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)
@@ -64,6 +70,7 @@ gdk_toplevel_default_init (GdkToplevelInterface *iface)
{
iface->present = gdk_toplevel_default_present;
iface->minimize = gdk_toplevel_default_minimize;
+ iface->focus = gdk_toplevel_default_focus;
iface->show_window_menu = gdk_toplevel_default_show_window_menu;
g_object_interface_install_property (iface,
@@ -178,6 +185,25 @@ gdk_toplevel_minimize (GdkToplevel *toplevel)
return GDK_TOPLEVEL_GET_IFACE (toplevel)->minimize (toplevel);
}
+/**
+ * gdk_toplevel_focus:
+ * @toplevel: a #GdkToplevel
+ * @timestamp: timestamp of the event triggering the surface focus
+ *
+ * Sets keyboard focus to @surface.
+ *
+ * In most cases, gtk_window_present_with_time() should be used
+ * on a #GtkWindow, rather than calling this function.
+ */
+void
+gdk_toplevel_focus (GdkToplevel *toplevel,
+ guint32 timestamp)
+{
+ g_return_if_fail (GDK_IS_TOPLEVEL (toplevel));
+
+ return GDK_TOPLEVEL_GET_IFACE (toplevel)->focus (toplevel, timestamp);
+}
+
/**
* gdk_toplevel_get_state:
* @toplevel: a #GdkToplevel
diff --git a/gdk/gdktoplevel.h b/gdk/gdktoplevel.h
index fdb17f4fc8..9854d0f30c 100644
--- a/gdk/gdktoplevel.h
+++ b/gdk/gdktoplevel.h
@@ -43,6 +43,10 @@ gboolean gdk_toplevel_present (GdkToplevel *toplevel,
GDK_AVAILABLE_IN_ALL
gboolean gdk_toplevel_minimize (GdkToplevel *toplevel);
+GDK_AVAILABLE_IN_ALL
+void gdk_toplevel_focus (GdkToplevel *toplevel,
+ guint32 timestamp);
+
GDK_AVAILABLE_IN_ALL
GdkSurfaceState gdk_toplevel_get_state (GdkToplevel *toplevel);
diff --git a/gdk/gdktoplevelprivate.h b/gdk/gdktoplevelprivate.h
index f3d22880f0..09a3d905e4 100644
--- a/gdk/gdktoplevelprivate.h
+++ b/gdk/gdktoplevelprivate.h
@@ -15,6 +15,8 @@ struct _GdkToplevelInterface
int height,
GdkToplevelLayout *layout);
gboolean (* minimize) (GdkToplevel *toplevel);
+ void (* focus) (GdkToplevel *toplevel,
+ guint32 timestamp);
gboolean (* show_window_menu) (GdkToplevel *toplevel,
GdkEvent *event);
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]