[gtk] window: Directly find the cursor in the widget hierarchy
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk] window: Directly find the cursor in the widget hierarchy
- Date: Wed, 16 Jan 2019 18:24:24 +0000 (UTC)
commit 374e93ef9620ecf390733c437d40eb73470209c0
Author: Timm Bäder <mail baedert org>
Date: Wed Jan 16 17:37:42 2019 +0100
window: Directly find the cursor in the widget hierarchy
Instead of recording the way up from the target widget to the grab
widget (or toplevel) and then walking that path upwards, just walk the
parent chain and look at the cursor.
gtk/gtkwindow.c | 20 ++++++++------------
1 file changed, 8 insertions(+), 12 deletions(-)
---
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 4c6162cf5c..b58610c341 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -11231,14 +11231,13 @@ update_cursor (GtkWindow *toplevel,
GtkWidget *target)
{
GdkCursor *cursor = NULL;
- GList *widgets = NULL, *l;
if (grab_widget && !gtk_widget_is_ancestor (target, grab_widget))
{
/* Outside the grab widget, cursor stays to whatever the grab
* widget says.
*/
- widgets = g_list_prepend (widgets, grab_widget);
+ cursor = gtk_widget_get_cursor (grab_widget);
}
else
{
@@ -11247,23 +11246,20 @@ update_cursor (GtkWindow *toplevel,
*/
while (target)
{
- widgets = g_list_prepend (widgets, target);
if (grab_widget && target == grab_widget)
break;
+
+ cursor = gtk_widget_get_cursor (target);
+
+ if (cursor)
+ break;
+
target = _gtk_widget_get_parent (target);
}
}
- for (l = g_list_last (widgets); l; l = l->prev)
- {
- cursor = gtk_widget_get_cursor (l->data);
- if (cursor)
- break;
- }
-
gdk_surface_set_device_cursor (gtk_widget_get_surface (GTK_WIDGET (toplevel)),
- device, cursor);
- g_list_free (widgets);
+ device, cursor);
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]