mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-09 18:30:08 +00:00
tests: Port testwidgetfocus to using a motion controller
This commit is contained in:
parent
8f6f980e49
commit
5d1b2f627c
@ -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");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user