2012-09-26 14:28:06 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
GtkAdjustment *adjustment;
|
|
|
|
int cursor_x, cursor_y;
|
|
|
|
|
|
|
|
static void
|
|
|
|
on_motion_notify (GtkWidget *window,
|
|
|
|
GdkEventMotion *event)
|
|
|
|
{
|
2017-08-28 23:11:14 +00:00
|
|
|
if (gdk_event_get_window ((GdkEvent*)event) == gtk_widget_get_window (window))
|
2012-09-26 14:28:06 +00:00
|
|
|
{
|
2017-08-28 23:11:14 +00:00
|
|
|
gdouble x, y;
|
2012-09-26 14:28:06 +00:00
|
|
|
float processing_ms = gtk_adjustment_get_value (adjustment);
|
|
|
|
g_usleep (processing_ms * 1000);
|
2017-08-28 23:11:14 +00:00
|
|
|
|
|
|
|
gdk_event_get_coords ((GdkEvent *)event, &x, &y);
|
|
|
|
cursor_x = x;
|
|
|
|
cursor_y = y;
|
2012-09-26 14:28:06 +00:00
|
|
|
gtk_widget_queue_draw (window);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-11-18 14:09:36 +00:00
|
|
|
on_draw (GtkDrawingArea *da,
|
|
|
|
cairo_t *cr,
|
|
|
|
int width,
|
|
|
|
int height,
|
|
|
|
gpointer data)
|
2012-09-26 14:28:06 +00:00
|
|
|
{
|
|
|
|
cairo_set_source_rgb (cr, 1, 1, 1);
|
|
|
|
cairo_paint (cr);
|
|
|
|
|
|
|
|
cairo_set_source_rgb (cr, 0, 0.5, 0.5);
|
|
|
|
|
|
|
|
cairo_arc (cr, cursor_x, cursor_y, 10, 0, 2 * M_PI);
|
|
|
|
cairo_stroke (cr);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main (int argc, char **argv)
|
|
|
|
{
|
|
|
|
GtkWidget *window;
|
|
|
|
GtkWidget *vbox;
|
|
|
|
GtkWidget *label;
|
|
|
|
GtkWidget *scale;
|
2016-11-18 14:09:36 +00:00
|
|
|
GtkWidget *da;
|
2012-09-26 14:28:06 +00:00
|
|
|
|
2016-12-28 13:53:22 +00:00
|
|
|
gtk_init ();
|
2012-09-26 14:28:06 +00:00
|
|
|
|
|
|
|
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
|
|
|
gtk_window_set_default_size (GTK_WINDOW (window), 300, 300);
|
|
|
|
|
|
|
|
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
|
|
|
gtk_container_add (GTK_CONTAINER (window), vbox);
|
|
|
|
|
|
|
|
adjustment = gtk_adjustment_new (20, 0, 200, 1, 10, 0);
|
|
|
|
scale = gtk_scale_new (GTK_ORIENTATION_HORIZONTAL, adjustment);
|
2017-04-21 20:34:36 +00:00
|
|
|
gtk_box_pack_end (GTK_BOX (vbox), scale);
|
2012-09-26 14:28:06 +00:00
|
|
|
|
|
|
|
label = gtk_label_new ("Event processing time (ms):");
|
2014-05-13 11:28:20 +00:00
|
|
|
gtk_widget_set_halign (label, GTK_ALIGN_CENTER);
|
2017-04-21 20:34:36 +00:00
|
|
|
gtk_box_pack_end (GTK_BOX (vbox), label);
|
2012-09-26 14:28:06 +00:00
|
|
|
|
2016-11-18 14:09:36 +00:00
|
|
|
da = gtk_drawing_area_new ();
|
|
|
|
gtk_drawing_area_set_draw_func (GTK_DRAWING_AREA (da), on_draw, NULL, NULL);
|
2017-04-21 16:59:59 +00:00
|
|
|
gtk_widget_set_vexpand (da, TRUE);
|
2017-04-21 20:34:36 +00:00
|
|
|
gtk_box_pack_end (GTK_BOX (vbox), da);
|
2016-11-18 14:09:36 +00:00
|
|
|
|
2012-09-26 14:28:06 +00:00
|
|
|
g_signal_connect (window, "motion-notify-event",
|
|
|
|
G_CALLBACK (on_motion_notify), NULL);
|
|
|
|
g_signal_connect (window, "destroy",
|
|
|
|
G_CALLBACK (gtk_main_quit), NULL);
|
|
|
|
|
2017-01-19 09:02:04 +00:00
|
|
|
gtk_widget_show (window);
|
2012-09-26 14:28:06 +00:00
|
|
|
gtk_main ();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|