Adjunto 'prueba-multitouch.c'

Descargar

   1 #include <gtk/gtk.h>
   2 
   3 static GHashTable *points;
   4 
   5 static void
   6 window_button_press_cb (GtkWidget *widget,
   7                         GdkEvent  *event,
   8                         gpointer   user_data)
   9 {
  10   GtkDeviceGroup *group = user_data;
  11 
  12   gtk_device_group_add_device (group,
  13                                gdk_event_get_device (event));
  14 }
  15 
  16 static void
  17 window_button_release_cb (GtkWidget *widget,
  18                           GdkEvent  *event,
  19                           gpointer   user_data)
  20 {
  21   GtkDeviceGroup *group = user_data;
  22 
  23   gtk_device_group_remove_device (group,
  24                                   gdk_event_get_device (event));
  25 }
  26 
  27 static void
  28 window_multidevice_event_cb (GtkWidget           *widget,
  29                              GtkDeviceGroup      *group,
  30                              GtkMultiDeviceEvent *event,
  31                              gpointer             user_data)
  32 {
  33   if (event->type == GTK_EVENT_DEVICE_REMOVED)
  34     g_hash_table_remove (points, event->updated_device);
  35   else
  36     {
  37       GdkPoint *point;
  38 
  39       point = g_new0 (GdkPoint, 1);
  40       point->x = event->updated_event->x;
  41       point->y = event->updated_event->y;
  42 
  43       g_hash_table_insert (points, event->updated_device, point);
  44     }
  45 
  46   gtk_widget_queue_draw (widget);
  47 }
  48 
  49 static gboolean
  50 window_expose_cb (GtkWidget *widget,
  51                   GdkEvent  *event,
  52                   gpointer   user_data)
  53 {
  54   GHashTableIter iter;
  55   gpointer key, value;
  56   cairo_t *cr;
  57 
  58   g_hash_table_iter_init (&iter, points);
  59   cr = gdk_cairo_create (widget->window);
  60 
  61   while (g_hash_table_iter_next (&iter, &key, &value))
  62     {
  63       GdkPoint *point = value;
  64 
  65       cairo_arc (cr,
  66                  point->x,
  67                  point->y,
  68                  40,
  69                  0,
  70                  2 * G_PI);
  71 
  72       cairo_set_source_rgb (cr, 0.5, 0.5, 0.5);
  73       cairo_fill (cr);
  74     }
  75 }
  76 
  77 int
  78 main (int argc, char *argv[])
  79 {
  80   GtkWidget *window;
  81   GtkDeviceGroup *group;
  82 
  83   gdk_enable_multidevice ();
  84 
  85   gtk_init (&argc, &argv);
  86 
  87   points = g_hash_table_new_full (NULL, NULL, NULL,
  88                                   (GDestroyNotify) g_free);
  89 
  90   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  91   gtk_widget_set_support_multidevice (window, TRUE);
  92   gtk_widget_set_app_paintable (window, TRUE);
  93 
  94   gtk_widget_add_events (window,
  95                          GDK_POINTER_MOTION_MASK |
  96                          GDK_BUTTON_MOTION_MASK |
  97                          GDK_BUTTON_PRESS_MASK |
  98                          GDK_BUTTON_RELEASE_MASK);
  99 
 100   group = gtk_widget_create_device_group (window);
 101 
 102   g_signal_connect (window, "button-press-event",
 103                     G_CALLBACK (window_button_press_cb), group);
 104   g_signal_connect (window, "button-release-event",
 105                     G_CALLBACK (window_button_release_cb), group);
 106   g_signal_connect (window, "multidevice-event",
 107                     G_CALLBACK (window_multidevice_event_cb), NULL);
 108   g_signal_connect (window, "expose-event",
 109                     G_CALLBACK (window_expose_cb), NULL);
 110 
 111   gtk_widget_show_all (window);
 112 
 113   gtk_main ();
 114 
 115   return 0;
 116 }

Archivos adjuntos

Para referirse a los adjuntos de una página, usa attachment:nombredelarchivo, como se muestra abajo en la lista de archivos. NO uses la URL del enlace [get], ya que puede cambiar fácilmente y dejar de funcionar.

No tienes permisos para adjuntar un archivo a esta página.