diff options
author | Carlos Garnacho <carlosg@gnome.org> | 2018-07-30 13:13:24 +0200 |
---|---|---|
committer | Carlos Garnacho <carlosg@gnome.org> | 2018-07-30 13:14:12 +0200 |
commit | 5d1b2f627c4958e915a5fef2754696a7a6d58c6c (patch) | |
tree | 0364ea611db367db647d2e50351e02323adc75a6 | |
parent | 8f6f980e49e8597fe4b77443128ed54ea77119e2 (diff) | |
download | gtk+-5d1b2f627c4958e915a5fef2754696a7a6d58c6c.tar.gz |
tests: Port testwidgetfocus to using a motion controller
-rw-r--r-- | tests/testwidgetfocus.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/tests/testwidgetfocus.c b/tests/testwidgetfocus.c index fc76ed2235..de179d4b35 100644 --- a/tests/testwidgetfocus.c +++ b/tests/testwidgetfocus.c @@ -199,24 +199,18 @@ gtk_focus_widget_snapshot (GtkWidget *widget, GtkSnapshot *snapshot) } } -static gboolean -gtk_focus_widget_event (GtkWidget *widget, - GdkEvent *event) +static void +motion_cb (GtkEventControllerMotion *controller, + gdouble x, + gdouble y, + GtkWidget *widget) { GtkFocusWidget *self = GTK_FOCUS_WIDGET (widget); - double x, y; - - if (gdk_event_get_event_type (event) == GDK_MOTION_NOTIFY) - { - gdk_event_get_coords ((GdkEvent *)event, &x, &y); - self->mouse_x = x; - self->mouse_y = y; + self->mouse_x = x; + self->mouse_y = y; - gtk_widget_queue_draw (widget); - } - - return GDK_EVENT_PROPAGATE; + gtk_widget_queue_draw (widget); } static void @@ -235,6 +229,8 @@ gtk_focus_widget_finalize (GObject *object) static void gtk_focus_widget_init (GtkFocusWidget *self) { + GtkEventController *controller; + gtk_widget_set_has_surface (GTK_WIDGET (self), FALSE); self->child1 = gtk_button_new_with_label ("1"); @@ -248,6 +244,11 @@ gtk_focus_widget_init (GtkFocusWidget *self) self->mouse_x = G_MININT; self->mouse_y = G_MININT; + + controller = gtk_event_controller_motion_new (); + g_signal_connect (controller, "motion", + G_CALLBACK (motion_cb), self); + gtk_widget_add_controller (GTK_WIDGET (self), controller); } static void @@ -261,7 +262,6 @@ gtk_focus_widget_class_init (GtkFocusWidgetClass *klass) widget_class->snapshot = gtk_focus_widget_snapshot; widget_class->measure = gtk_focus_widget_measure; widget_class->size_allocate = gtk_focus_widget_size_allocate; - widget_class->event = gtk_focus_widget_event; gtk_widget_class_set_css_name (widget_class, "focuswidget"); } |