[gtk+/events-refactor: 781/1085] GdkEventSource: Add gdk_event_source_select_events().



commit 8c18a08cafb578d881e235d217503adc4768384b
Author: Carlos Garnacho <carlos lanedo com>
Date:   Sun Aug 23 00:45:22 2009 +0200

    GdkEventSource: Add gdk_event_source_select_events().

 gdk/x11/gdkeventsource.c |   38 ++++++++++++++++++++++++++++++++++++++
 gdk/x11/gdkeventsource.h |    6 ++++++
 2 files changed, 44 insertions(+), 0 deletions(-)
---
diff --git a/gdk/x11/gdkeventsource.c b/gdk/x11/gdkeventsource.c
index b7adf4c..c37ca34 100644
--- a/gdk/x11/gdkeventsource.c
+++ b/gdk/x11/gdkeventsource.c
@@ -294,3 +294,41 @@ gdk_event_source_add_translator (GdkEventSource     *source,
 
   source->translators = g_list_prepend (source->translators, translator);
 }
+
+void
+gdk_event_source_select_events (GdkEventSource *source,
+                                Window          window,
+                                GdkEventMask    event_mask,
+                                unsigned int    extra_x_mask)
+{
+  unsigned int xmask = extra_x_mask;
+  GList *list;
+  gint i;
+
+  list = source->translators;
+
+  while (list)
+    {
+      GdkEventTranslator *translator = list->data;
+      GdkEventMask translator_mask, mask;
+
+      translator_mask = gdk_event_translator_get_handled_events (translator);
+      mask = event_mask & translator_mask;
+
+      if (mask != 0)
+        {
+          gdk_event_translator_select_window_events (translator, window, mask);
+          event_mask &= ~(mask);
+        }
+
+      list = list->next;
+    }
+
+  for (i = 0; i < _gdk_nenvent_masks; i++)
+    {
+      if (event_mask & (1 << (i + 1)))
+        xmask |= _gdk_event_mask_table[i];
+    }
+
+  XSelectInput (GDK_DISPLAY_XDISPLAY (source->display), window, xmask);
+}
diff --git a/gdk/x11/gdkeventsource.h b/gdk/x11/gdkeventsource.h
index f433759..c1e5239 100644
--- a/gdk/x11/gdkeventsource.h
+++ b/gdk/x11/gdkeventsource.h
@@ -32,6 +32,12 @@ GSource * gdk_event_source_new            (GdkDisplay *display);
 void      gdk_event_source_add_translator (GdkEventSource     *source,
                                            GdkEventTranslator *translator);
 
+void      gdk_event_source_select_events  (GdkEventSource *source,
+                                           Window          window,
+                                           GdkEventMask    event_mask,
+                                           unsigned int    extra_x_mask);
+
+
 G_END_DECLS
 
 #endif /* __GDK_EVENT_SOURCE_H__ */



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