[gtk+/wip/carlosg/event-delivery: 240/261] gtkwindow: Add private API to update pointer cursors
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/carlosg/event-delivery: 240/261] gtkwindow: Add private API to update pointer cursors
- Date: Mon, 8 May 2017 21:04:50 +0000 (UTC)
commit fe017a6a7a7c9ccd959f2b69fc593a67ab66d840
Author: Carlos Garnacho <carlosg gnome org>
Date: Tue Apr 4 17:08:48 2017 +0200
gtkwindow: Add private API to update pointer cursors
gtk/gtkwindow.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++
gtk/gtkwindowprivate.h | 3 ++
2 files changed, 56 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 83f51a0..2bc44bb 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -11385,3 +11385,56 @@ gtk_window_set_pointer_focus_grab (GtkWindow *window,
g_assert (focus != NULL);
gtk_pointer_focus_set_implicit_grab (focus, grab_widget);
}
+
+static void
+update_cursor (GtkWindow *toplevel,
+ GdkDevice *device,
+ GtkWidget *target)
+{
+ GdkCursor *cursor = NULL;
+ GList *widgets = NULL, *l;
+
+ while (target)
+ {
+ widgets = g_list_prepend (widgets, target);
+ target = _gtk_widget_get_parent (target);
+ }
+
+ for (l = widgets; l; l = l->next)
+ {
+ cursor = gtk_widget_get_cursor (l->data);
+ if (cursor)
+ break;
+ }
+
+ gdk_window_set_device_cursor (gtk_widget_get_window (GTK_WIDGET (toplevel)),
+ device, cursor);
+ g_list_free (widgets);
+}
+
+void
+gtk_window_maybe_update_cursor (GtkWindow *window,
+ GtkWidget *widget,
+ GdkDevice *device)
+{
+ GList *l = window->priv->foci;
+
+ for (l = window->priv->foci; l; l = l->next)
+ {
+ GtkPointerFocus *focus = l->data;
+
+ if (focus->sequence)
+ continue;
+ if (device && device != focus->device)
+ continue;
+
+ if (widget != focus->target &&
+ !gtk_widget_is_ancestor (focus->target, widget))
+ continue;
+
+ update_cursor (focus->toplevel, focus->device, focus->target);
+
+ if (device)
+ break;
+ }
+}
diff --git a/gtk/gtkwindowprivate.h b/gtk/gtkwindowprivate.h
index 8571219..1d97de7 100644
--- a/gtk/gtkwindowprivate.h
+++ b/gtk/gtkwindowprivate.h
@@ -164,6 +164,9 @@ void gtk_window_update_pointer_focus_on_state_change (GtkWindow *win
void gtk_window_maybe_revoke_implicit_grab (GtkWindow *window,
GdkDevice *device,
GtkWidget *grab_widget);
+void gtk_window_maybe_update_cursor (GtkWindow *window,
+ GtkWidget *widget,
+ GdkDevice *device);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]