[gtk+/wip/carlosg/event-delivery: 11/75] gtk: Implement cursor updates
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/carlosg/event-delivery: 11/75] gtk: Implement cursor updates
- Date: Tue, 9 May 2017 17:38:07 +0000 (UTC)
commit 5c724bb2d6d456df58e11f5893c01a371f4529bc
Author: Carlos Garnacho <carlosg gnome org>
Date: Fri Mar 31 17:54:06 2017 +0200
gtk: Implement cursor updates
As we don't obey GdkWindow cursors anymore, someone must set those.
Use the private Gtkwidget API at the moment.
gtk/gtkmain.c | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkmain.c b/gtk/gtkmain.c
index 3912749..2f45867 100644
--- a/gtk/gtkmain.c
+++ b/gtk/gtkmain.c
@@ -1307,6 +1307,23 @@ check_event_in_child_popover (GtkWidget *event_widget,
return (popover_parent == grab_widget || gtk_widget_is_ancestor (popover_parent, grab_widget));
}
+static void
+update_cursor (GtkWindow *toplevel,
+ GdkDevice *device,
+ GtkWidget *target)
+{
+ GdkCursor *cursor = NULL;
+
+ while (!cursor && target)
+ {
+ cursor = gtk_widget_get_cursor (target);
+ target = _gtk_widget_get_parent (target);
+ }
+
+ gdk_window_set_device_cursor (gtk_widget_get_window (GTK_WIDGET (toplevel)),
+ device, cursor);
+}
+
static GdkNotifyType
get_virtual_notify_type (GdkNotifyType notify_type)
{
@@ -1484,6 +1501,8 @@ handle_pointing_event (GdkEvent *event)
case GDK_ENTER_NOTIFY:
target = _gtk_toplevel_pick (toplevel, x, y, NULL, NULL);
old_target = update_pointer_focus_state (toplevel, event, target);
+ if (event->type == GDK_MOTION_NOTIFY || event->type == GDK_ENTER_NOTIFY)
+ update_cursor (toplevel, device, target);
/* Let it take the effective pointer focus anyway, as it may change due
* to implicit grabs.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]