[gtksourceview] hover: return focus to view when dismissing
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtksourceview] hover: return focus to view when dismissing
- Date: Mon, 11 Jul 2022 17:56:02 +0000 (UTC)
commit 858b04ea54e0b79406d473f6b74d4af40f884f8d
Author: Christian Hergert <chergert redhat com>
Date: Mon Jul 11 10:55:57 2022 -0700
hover: return focus to view when dismissing
But only if the hover assistant contains the current focus.
gtksourceview/gtksourcehoverassistant.c | 13 +++++++++++++
1 file changed, 13 insertions(+)
---
diff --git a/gtksourceview/gtksourcehoverassistant.c b/gtksourceview/gtksourcehoverassistant.c
index 75acf952..5e9a32b1 100644
--- a/gtksourceview/gtksourcehoverassistant.c
+++ b/gtksourceview/gtksourcehoverassistant.c
@@ -90,7 +90,20 @@ gtk_source_hover_assistant_motion_cb (GtkSourceHoverAssistant *self,
y < -GRACE_Y ||
y > height + GRACE_Y)
{
+ GtkWidget *focus = gtk_root_get_focus (root);
+ GtkWidget *view = gtk_widget_get_ancestor (GTK_WIDGET (self), GTK_SOURCE_TYPE_VIEW);
+ gboolean return_focus;
+
+ return_focus = focus != NULL &&
+ (focus == GTK_WIDGET (self) ||
+ gtk_widget_is_ancestor (focus, GTK_WIDGET (self)));
+
gtk_widget_hide (GTK_WIDGET (self));
+
+ if (return_focus && view != NULL)
+ {
+ gtk_widget_grab_focus (GTK_WIDGET (view));
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]