mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-13 22:10:08 +00:00
tests: Stop using ::motion-notify-event
We can use the generic ::event signal here.
This commit is contained in:
parent
472f5e4b13
commit
81b8f0493a
@ -4,11 +4,12 @@
|
||||
GtkAdjustment *adjustment;
|
||||
int cursor_x, cursor_y;
|
||||
|
||||
static void
|
||||
on_motion_notify (GtkWidget *window,
|
||||
GdkEventMotion *event)
|
||||
static gboolean
|
||||
event_cb (GtkWidget *window,
|
||||
GdkEvent *event)
|
||||
{
|
||||
if (gdk_event_get_window ((GdkEvent*)event) == gtk_widget_get_window (window))
|
||||
if (gdk_event_get_event_type (event) == GDK_MOTION_NOTIFY &&
|
||||
gdk_event_get_window (event) == gtk_widget_get_window (window))
|
||||
{
|
||||
gdouble x, y;
|
||||
float processing_ms = gtk_adjustment_get_value (adjustment);
|
||||
@ -19,6 +20,8 @@ on_motion_notify (GtkWidget *window,
|
||||
cursor_y = y;
|
||||
gtk_widget_queue_draw (window);
|
||||
}
|
||||
|
||||
return GDK_EVENT_PROPAGATE;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -67,8 +70,8 @@ main (int argc, char **argv)
|
||||
gtk_widget_set_vexpand (da, TRUE);
|
||||
gtk_box_pack_end (GTK_BOX (vbox), da);
|
||||
|
||||
g_signal_connect (window, "motion-notify-event",
|
||||
G_CALLBACK (on_motion_notify), NULL);
|
||||
g_signal_connect (window, "event",
|
||||
G_CALLBACK (event_cb), NULL);
|
||||
g_signal_connect (window, "destroy",
|
||||
G_CALLBACK (gtk_main_quit), NULL);
|
||||
|
||||
|
@ -19,13 +19,16 @@ place_popup (GtkWidget *parent,
|
||||
gint width, height;
|
||||
gdouble x, y;
|
||||
|
||||
gtk_window_get_size (GTK_WINDOW (popup), &width, &height);
|
||||
gdk_event_get_root_coords (event, &x, &y);
|
||||
gtk_window_move (GTK_WINDOW (popup),
|
||||
(int) x - width / 2,
|
||||
(int) y - height / 2);
|
||||
if (gdk_event_get_event_type (event) == GDK_MOTION_NOTIFY)
|
||||
{
|
||||
gtk_window_get_size (GTK_WINDOW (popup), &width, &height);
|
||||
gdk_event_get_root_coords (event, &x, &y);
|
||||
gtk_window_move (GTK_WINDOW (popup),
|
||||
(int) x - width / 2,
|
||||
(int) y - height / 2);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return GDK_EVENT_PROPAGATE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@ -40,7 +43,7 @@ on_map (GtkWidget *parent)
|
||||
|
||||
gtk_widget_set_size_request (GTK_WIDGET (popup), 20, 20);
|
||||
gtk_window_set_transient_for (GTK_WINDOW (popup), GTK_WINDOW (parent));
|
||||
g_signal_connect (parent, "motion-notify-event", G_CALLBACK (place_popup), popup);
|
||||
g_signal_connect (parent, "event", G_CALLBACK (place_popup), popup);
|
||||
|
||||
gtk_widget_show (popup);
|
||||
|
||||
|
@ -203,18 +203,21 @@ gtk_focus_widget_snapshot (GtkWidget *widget, GtkSnapshot *snapshot)
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_focus_widget_motion_notify_event (GtkWidget *widget,
|
||||
GdkEventMotion *event)
|
||||
gtk_focus_widget_event (GtkWidget *widget,
|
||||
GdkEvent *event)
|
||||
{
|
||||
GtkFocusWidget *self = GTK_FOCUS_WIDGET (widget);
|
||||
gdouble x, y;
|
||||
|
||||
gdk_event_get_coords ((GdkEvent *)event, &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);
|
||||
gtk_widget_queue_draw (widget);
|
||||
}
|
||||
|
||||
return GDK_EVENT_PROPAGATE;
|
||||
}
|
||||
@ -261,7 +264,7 @@ 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->motion_notify_event = gtk_focus_widget_motion_notify_event;
|
||||
widget_class->event = gtk_focus_widget_event;
|
||||
|
||||
gtk_widget_class_set_css_name (widget_class, "focuswidget");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user