Re: Accuracy of motion events

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2014-09-02 at 11:01 +1000, Lex Trotman wrote:
> As stated before, motion events are only *delivered* per frame, all
> the compress flag does is set it to deliver the motion as one event
> per frame or multiple events per frame.  If you have compress true (as
> above) only one event is delivered, on each frame time, so thats the
> time you see.  You only get the position at the end of the frame.
> 
> If you turn compress off you will get all the events generated during
> the last frame cycle.  That allows applications to trace the positions
> that the cursor moved through.

Yes, I understand this, but unfortunately I see no effect. My current
idea was that it may work not for the main window, but it may work for a
drawing area.

So I changed the C code as below, and appended an output snippet.
As you see, time interval is generally about 12 ms. Maybe the limitation
is my computer, it is some years old now, or maybe the mouse device, it
is from Logitech. When I have some time again I may check on another
computer...

//gcc -Wall -o t t.c `pkg-config --libs --cflags gtk+-3.0`
#include <gtk/gtk.h>

void print_event(GtkWidget *widget, GdkEventMotion *event, gpointer p)
{
  printf("%.0f, %.0f: %d\n", event->x, event->y, event->time);
}

int main( int argc, char *argv[])
{
  GtkWidget *window;
  GtkWidget *darea;
	GdkWindow *gdkwin;

  gtk_init(&argc, &argv);

  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
	darea = gtk_drawing_area_new();
	gtk_widget_set_size_request(darea, 800, 1200);
  gtk_window_set_default_size(GTK_WINDOW(window), 800, 800);
	gtk_container_add(GTK_CONTAINER(window), darea);
	
  gtk_widget_set_events(darea, GDK_POINTER_MOTION_MASK);
	
  gtk_widget_show_all(window);

  g_signal_connect(darea, "motion_notify_event",
      G_CALLBACK (print_event), NULL);

  g_signal_connect_swapped(G_OBJECT(window), "destroy",
      G_CALLBACK(gtk_main_quit), NULL);

  gdkwin = gtk_widget_get_window(darea);

  gdk_window_set_event_compression(gdkwin, FALSE);
  //gdk_window_set_event_compression(gdkwin, TRUE);

  gtk_main();

  return 0;
}

stefan@AMD64X2 ~/rth $ ./t 
7, 625: 2029540
48, 625: 2029552
89, 623: 2029564
132, 623: 2029576
177, 623: 2029588
222, 621: 2029604
267, 621: 2029616
312, 621: 2029628
357, 621: 2029640
398, 621: 2029652
435, 621: 2029664
476, 621: 2029676
501, 621: 2029688
534, 621: 2029704
563, 619: 2029716
590, 619: 2029728
613, 619: 2029740
636, 617: 2029752
657, 617: 2029764
682, 617: 2029776
701, 619: 2029788
722, 621: 2029804
745, 624: 2029816
770, 622: 2029828
793, 625: 2029840


_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
https://mail.gnome.org/mailman/listinfo/gtk-list




[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux