]> Pileus Git - ~andy/gtk/blobdiff - gdk/gdkdisplay.c
win32: Fix build
[~andy/gtk] / gdk / gdkdisplay.c
index 22aebd7550a536fc45ac6f90e08a152b61c41ac7..79d162b2a9df6261ac18b4612e2b8904ab82646a 100644 (file)
@@ -16,9 +16,7 @@
  * Library General Public License for more details.
  *
  * You should have received a copy of the GNU Library General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
  */
 
 #include "config.h"
 
 /**
  * SECTION:gdkdisplay
- * @Short_description: Controls the keyboard/mouse pointer grabs and a set of <type>GdkScreen</type>s
+ * @Short_description: Controls a set of GdkScreens and their associated input devices
  * @Title: GdkDisplay
  *
  * #GdkDisplay objects purpose are two fold:
  * <itemizedlist>
- * <listitem><para>
- *   To grab/ungrab keyboard focus and mouse pointer
- * </para></listitem>
- * <listitem><para>
- *   To manage and provide information about the #GdkScreen(s)
- *   available for this #GdkDisplay
- * </para></listitem>
+ * <listitem>
+ *   To manage and provide information about input devices (pointers
+ *   and keyboards)
+ * </listitem>
+ * <listitem>
+ *   To manage and provide information about the available #GdkScreens
+ * </listitem>
  * </itemizedlist>
  *
- * #GdkDisplay objects are the GDK representation of the X Display which can be
- * described as <emphasis>a workstation consisting of a keyboard a pointing
- * device (such as a mouse) and one or more screens</emphasis>.
- * It is used to open and keep track of various #GdkScreen objects currently
- * instanciated by the application. It is also used to grab and release the keyboard
- * and the mouse pointer.
+ * GdkDisplay objects are the GDK representation of an X Display,
+ * which can be described as <emphasis>a workstation consisting of
+ * a keyboard, a pointing device (such as a mouse) and one or more
+ * screens</emphasis>.
+ * It is used to open and keep track of various GdkScreen objects
+ * currently instantiated by the application. It is also used to
+ * access the keyboard(s) and mouse pointer(s) of the display.
+ *
+ * Most of the input device handling has been factored out into
+ * the separate #GdkDeviceManager object. Every display has a
+ * device manager, which you can obtain using
+ * gdk_display_get_device_manager().
  */
 
 
@@ -128,7 +132,8 @@ gdk_display_class_init (GdkDisplayClass *class)
 static void
 free_pointer_info (GdkPointerWindowInfo *info)
 {
-  g_object_unref (info->toplevel_under_pointer);
+  if (info->toplevel_under_pointer)
+    g_object_unref (info->toplevel_under_pointer);
   g_slice_free (GdkPointerWindowInfo, info);
 }
 
@@ -147,8 +152,7 @@ free_device_grabs_foreach (gpointer key,
 {
   GList *list = value;
 
-  g_list_foreach (list, (GFunc) free_device_grab, NULL);
-  g_list_free (list);
+  g_list_free_full (list, (GDestroyNotify) free_device_grab);
 
   return TRUE;
 }
@@ -182,6 +186,7 @@ gdk_display_init (GdkDisplay *display)
   display->double_click_time = 250;
   display->double_click_distance = 5;
 
+  display->touch_implicit_grabs = g_array_new (FALSE, FALSE, sizeof (GdkTouchGrabInfo));
   display->device_grabs = g_hash_table_new (NULL, NULL);
   display->motion_hint_info = g_hash_table_new_full (NULL, NULL, NULL,
                                                      (GDestroyNotify) g_free);
@@ -204,8 +209,7 @@ gdk_display_dispose (GObject *object)
 
   device_manager = gdk_display_get_device_manager (GDK_DISPLAY (object));
 
-  g_list_foreach (display->queued_events, (GFunc)gdk_event_free, NULL);
-  g_list_free (display->queued_events);
+  g_list_free_full (display->queued_events, (GDestroyNotify) gdk_event_free);
   display->queued_events = NULL;
   display->queued_tail = NULL;
 
@@ -231,6 +235,9 @@ gdk_display_finalize (GObject *object)
                                NULL);
   g_hash_table_destroy (display->device_grabs);
 
+  g_array_free (display->touch_implicit_grabs, TRUE);
+
+  g_hash_table_destroy (display->motion_hint_info);
   g_hash_table_destroy (display->pointers_info);
   g_hash_table_destroy (display->multiple_click_info);
 
@@ -300,7 +307,11 @@ gdk_display_get_event (GdkDisplay *display)
 {
   g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
 
+  if (display->event_pause_count > 0)
+    return NULL;
+
   GDK_DISPLAY_GET_CLASS (display)->queue_events (display);
+
   return _gdk_event_unqueue (display);
 }
 
@@ -396,42 +407,6 @@ gdk_display_pointer_ungrab (GdkDisplay *display,
   g_list_free (devices);
 }
 
-/**
- * gdk_pointer_ungrab:
- * @time_: a timestamp from a #GdkEvent, or %GDK_CURRENT_TIME if no 
- *  timestamp is available.
- *
- * Ungrabs the pointer on the default display, if it is grabbed by this 
- * application.
- *
- * Deprecated: 3.0: Use gdk_device_ungrab(), together with gdk_device_grab()
- *             instead.
- **/
-void
-gdk_pointer_ungrab (guint32 time)
-{
-  gdk_display_pointer_ungrab (gdk_display_get_default (), time);
-}
-
-/**
- * gdk_pointer_is_grabbed:
- * 
- * Returns %TRUE if the pointer on the default display is currently 
- * grabbed by this application.
- *
- * Note that this does not take the inmplicit pointer grab on button
- * presses into account.
- *
- * Return value: %TRUE if the pointer is currently grabbed by this application.
- *
- * Deprecated: 3.0: Use gdk_display_device_is_grabbed() instead.
- **/
-gboolean
-gdk_pointer_is_grabbed (void)
-{
-  return gdk_display_pointer_is_grabbed (gdk_display_get_default ());
-}
-
 /**
  * gdk_display_keyboard_ungrab:
  * @display: a #GdkDisplay.
@@ -472,23 +447,6 @@ gdk_display_keyboard_ungrab (GdkDisplay *display,
   g_list_free (devices);
 }
 
-/**
- * gdk_keyboard_ungrab:
- * @time_: a timestamp from a #GdkEvent, or %GDK_CURRENT_TIME if no
- *        timestamp is available.
- * 
- * Ungrabs the keyboard on the default display, if it is grabbed by this 
- * application.
- *
- * Deprecated: 3.0: Use gdk_device_ungrab(), together with gdk_device_grab()
- *             instead.
- **/
-void
-gdk_keyboard_ungrab (guint32 time)
-{
-  gdk_display_keyboard_ungrab (gdk_display_get_default (), time);
-}
-
 /**
  * gdk_beep:
  * 
@@ -523,48 +481,6 @@ gdk_flush (void)
   g_slist_free (list);
 }
 
-/**
- * gdk_event_send_client_message:
- * @event: the #GdkEvent to send, which should be a #GdkEventClient.
- * @winid:  the window to send the X ClientMessage event to.
- * 
- * Sends an X ClientMessage event to a given window (which must be
- * on the default #GdkDisplay.)
- * This could be used for communicating between different applications,
- * though the amount of data is limited to 20 bytes.
- * 
- * Return value: non-zero on success.
- **/
-gboolean
-gdk_event_send_client_message (GdkEvent        *event,
-                              GdkNativeWindow  winid)
-{
-  g_return_val_if_fail (event != NULL, FALSE);
-
-  return gdk_event_send_client_message_for_display (gdk_display_get_default (),
-                                                   event, winid);
-}
-
-/**
- * gdk_event_send_clientmessage_toall:
- * @event: the #GdkEvent to send, which should be a #GdkEventClient.
- *
- * Sends an X ClientMessage event to all toplevel windows on the default
- * #GdkScreen.
- *
- * Toplevel windows are determined by checking for the WM_STATE property, as
- * described in the Inter-Client Communication Conventions Manual (ICCCM).
- * If no windows are found with the WM_STATE property set, the message is sent
- * to all children of the root window.
- **/
-void
-gdk_event_send_clientmessage_toall (GdkEvent *event)
-{
-  g_return_if_fail (event != NULL);
-
-  gdk_screen_broadcast_client_message (gdk_screen_get_default (), event);
-}
-
 void
 _gdk_display_enable_motion_hints (GdkDisplay *display,
                                   GdkDevice  *device)
@@ -597,7 +513,7 @@ _gdk_display_enable_motion_hints (GdkDisplay *display,
 /**
  * gdk_display_get_pointer:
  * @display: a #GdkDisplay
- * @screen: (out) (allow-none): location to store the screen that the
+ * @screen: (out) (allow-none) (transfer none): location to store the screen that the
  *          cursor is on, or %NULL.
  * @x: (out) (allow-none): location to store root window X coordinate of pointer, or %NULL.
  * @y: (out) (allow-none): location to store root window Y coordinate of pointer, or %NULL.
@@ -783,6 +699,73 @@ _gdk_display_add_device_grab (GdkDisplay       *display,
   return info;
 }
 
+static void
+_gdk_display_break_touch_grabs (GdkDisplay *display,
+                                GdkDevice  *device,
+                                GdkWindow  *new_grab_window)
+{
+  guint i;
+
+  for (i = 0; i < display->touch_implicit_grabs->len; i++)
+    {
+      GdkTouchGrabInfo *info;
+
+      info = &g_array_index (display->touch_implicit_grabs,
+                             GdkTouchGrabInfo, i);
+
+      if (info->device == device && info->window != new_grab_window)
+        generate_grab_broken_event (GDK_WINDOW (info->window),
+                                    device, TRUE, new_grab_window);
+    }
+}
+
+void
+_gdk_display_add_touch_grab (GdkDisplay       *display,
+                             GdkDevice        *device,
+                             GdkEventSequence *sequence,
+                             GdkWindow        *window,
+                             GdkWindow        *native_window,
+                             GdkEventMask      event_mask,
+                             unsigned long     serial,
+                             guint32           time)
+{
+  GdkTouchGrabInfo info;
+
+  info.device = device;
+  info.sequence = sequence;
+  info.window = g_object_ref (window);
+  info.native_window = g_object_ref (native_window);
+  info.serial = serial;
+  info.event_mask = event_mask;
+  info.time = time;
+
+  g_array_append_val (display->touch_implicit_grabs, info);
+}
+
+gboolean
+_gdk_display_end_touch_grab (GdkDisplay       *display,
+                             GdkDevice        *device,
+                             GdkEventSequence *sequence)
+{
+  guint i;
+
+  for (i = 0; i < display->touch_implicit_grabs->len; i++)
+    {
+      GdkTouchGrabInfo *info;
+
+      info = &g_array_index (display->touch_implicit_grabs,
+                             GdkTouchGrabInfo, i);
+
+      if (info->device == device && info->sequence == sequence)
+        {
+          g_array_remove_index_fast (display->touch_implicit_grabs, i);
+          return TRUE;
+        }
+    }
+
+  return FALSE;
+}
+
 /* _gdk_synthesize_crossing_events only works inside one toplevel.
    This function splits things into two calls if needed, converting the
    coordinates to the right toplevel */
@@ -800,10 +783,6 @@ synthesize_crossing_events (GdkDisplay      *display,
   GdkModifierType state;
   int x, y;
 
-  /* We use the native crossing events if all native */
-  if (_gdk_native_windows)
-    return;
-  
   if (src_window)
     src_toplevel = gdk_window_get_toplevel (src_window);
   else
@@ -820,8 +799,9 @@ synthesize_crossing_events (GdkDisplay      *display,
       src_toplevel == dest_toplevel)
     {
       /* Same toplevels */
-      gdk_window_get_pointer (dest_toplevel,
-                             &x, &y, &state);
+      gdk_window_get_device_position (dest_toplevel,
+                                      device,
+                                     &x, &y, &state);
       _gdk_synthesize_crossing_events (display,
                                       src_window,
                                       dest_window,
@@ -834,8 +814,9 @@ synthesize_crossing_events (GdkDisplay      *display,
     }
   else if (dest_toplevel == NULL)
     {
-      gdk_window_get_pointer (src_toplevel,
-                             &x, &y, &state);
+      gdk_window_get_device_position (src_toplevel,
+                                      device,
+                                     &x, &y, &state);
       _gdk_synthesize_crossing_events (display,
                                        src_window,
                                        NULL,
@@ -849,8 +830,9 @@ synthesize_crossing_events (GdkDisplay      *display,
   else
     {
       /* Different toplevels */
-      gdk_window_get_pointer (src_toplevel,
-                             &x, &y, &state);
+      gdk_window_get_device_position (src_toplevel,
+                                      device,
+                                     &x, &y, &state);
       _gdk_synthesize_crossing_events (display,
                                       src_window,
                                       NULL,
@@ -860,8 +842,9 @@ synthesize_crossing_events (GdkDisplay      *display,
                                       time,
                                       NULL,
                                       serial, FALSE);
-      gdk_window_get_pointer (dest_toplevel,
-                             &x, &y, &state);
+      gdk_window_get_device_position (dest_toplevel,
+                                      device,
+                                     &x, &y, &state);
       _gdk_synthesize_crossing_events (display,
                                       NULL,
                                       dest_window,
@@ -986,17 +969,28 @@ switch_to_pointer_grab (GdkDisplay        *display,
 
       if (grab == NULL) /* Ungrabbed, send events */
        {
-         pointer_window = NULL;
-         if (new_toplevel)
-           {
-             /* Find (possibly virtual) child window */
-             pointer_window =
-               _gdk_window_find_descendant_at (new_toplevel,
-                                               x, y,
-                                               NULL, NULL);
-           }
+          /* If the source device is a touch device, do not
+           * propagate any enter event yet, until one is
+           * synthesized when needed.
+           */
+          if (source_device &&
+              (gdk_device_get_source (source_device) == GDK_SOURCE_TOUCHSCREEN))
+            info->need_touch_press_enter = TRUE;
 
-         if (pointer_window != last_grab->window)
+          pointer_window = NULL;
+
+          if (new_toplevel &&
+              !info->need_touch_press_enter)
+            {
+              /* Find (possibly virtual) child window */
+              pointer_window =
+                _gdk_window_find_descendant_at (new_toplevel,
+                                                x, y,
+                                                NULL, NULL);
+            }
+
+         if (!info->need_touch_press_enter &&
+             pointer_window != last_grab->window)
             synthesize_crossing_events (display, device, source_device,
                                         last_grab->window, pointer_window,
                                         GDK_CROSSING_UNGRAB, time, serial);
@@ -1053,12 +1047,15 @@ _gdk_display_device_grab_update (GdkDisplay *display,
            next_grab = NULL; /* Actually its not yet active */
        }
 
+      if (next_grab)
+        _gdk_display_break_touch_grabs (display, device, next_grab->window);
+
       if ((next_grab == NULL && current_grab->implicit_ungrab) ||
-         (next_grab != NULL && current_grab->window != next_grab->window))
-       generate_grab_broken_event (GDK_WINDOW (current_grab->window),
+          (next_grab != NULL && current_grab->window != next_grab->window))
+        generate_grab_broken_event (GDK_WINDOW (current_grab->window),
                                     device,
-                                   current_grab->implicit,
-                                   next_grab? next_grab->window : NULL);
+                                    current_grab->implicit,
+                                    next_grab? next_grab->window : NULL);
 
       /* Remove old grab */
       grabs = g_list_delete_link (grabs, grabs);
@@ -1117,6 +1114,33 @@ _gdk_display_has_device_grab (GdkDisplay *display,
   return NULL;
 }
 
+GdkTouchGrabInfo *
+_gdk_display_has_touch_grab (GdkDisplay       *display,
+                             GdkDevice        *device,
+                             GdkEventSequence *sequence,
+                             gulong            serial)
+{
+  guint i;
+
+  for (i = 0; i < display->touch_implicit_grabs->len; i++)
+    {
+      GdkTouchGrabInfo *info;
+
+      info = &g_array_index (display->touch_implicit_grabs,
+                             GdkTouchGrabInfo, i);
+
+      if (info->device == device && info->sequence == sequence)
+        {
+          if (serial >= info->serial)
+            return info;
+          else
+            return NULL;
+        }
+    }
+
+  return NULL;
+}
+
 /* Returns true if last grab was ended
  * If if_child is non-NULL, end the grab only if the grabbed
  * window is the same as if_child or a descendant of it */
@@ -1209,6 +1233,9 @@ _gdk_display_get_pointer_info (GdkDisplay *display,
 {
   GdkPointerWindowInfo *info;
 
+  if (device && gdk_device_get_source (device) == GDK_SOURCE_KEYBOARD)
+    device = gdk_device_get_associated_device (device);
+
   if (G_UNLIKELY (!device))
     return NULL;
 
@@ -1313,9 +1340,14 @@ gdk_display_pointer_is_grabbed (GdkDisplay *display)
 
       if (gdk_device_get_source (device) == GDK_SOURCE_MOUSE &&
           gdk_display_device_is_grabbed (display, device))
-        return TRUE;
+        {
+          g_list_free (devices);
+          return TRUE;
+        }
     }
 
+  g_list_free (devices);
+
   return FALSE;
 }
 
@@ -1375,10 +1407,12 @@ gdk_display_get_device_manager (GdkDisplay *display)
  *
  * Since: 2.2
  */
-G_CONST_RETURN gchar *
+const gchar *
 gdk_display_get_name (GdkDisplay *display)
 {
-  return GDK_DISPLAY_GET_CLASS(display)->get_name (display);
+  g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
+
+  return GDK_DISPLAY_GET_CLASS (display)->get_name (display);
 }
 
 gchar *
@@ -1400,7 +1434,9 @@ gdk_get_display (void)
 gint
 gdk_display_get_n_screens (GdkDisplay *display)
 {
-  return GDK_DISPLAY_GET_CLASS(display)->get_n_screens (display);
+  g_return_val_if_fail (GDK_IS_DISPLAY (display), 0);
+
+  return GDK_DISPLAY_GET_CLASS (display)->get_n_screens (display);
 }
 
 /**
@@ -1418,7 +1454,9 @@ GdkScreen *
 gdk_display_get_screen (GdkDisplay *display,
                        gint        screen_num)
 {
-  return GDK_DISPLAY_GET_CLASS(display)->get_screen (display, screen_num);
+  g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
+
+  return GDK_DISPLAY_GET_CLASS (display)->get_screen (display, screen_num);
 }
 
 /**
@@ -1434,7 +1472,9 @@ gdk_display_get_screen (GdkDisplay *display,
 GdkScreen *
 gdk_display_get_default_screen (GdkDisplay *display)
 {
-  return GDK_DISPLAY_GET_CLASS(display)->get_default_screen (display);
+  g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
+
+  return GDK_DISPLAY_GET_CLASS (display)->get_default_screen (display);
 }
 
 /**
@@ -1448,7 +1488,9 @@ gdk_display_get_default_screen (GdkDisplay *display)
 void
 gdk_display_beep (GdkDisplay *display)
 {
-  GDK_DISPLAY_GET_CLASS(display)->beep (display);
+  g_return_if_fail (GDK_IS_DISPLAY (display));
+
+  GDK_DISPLAY_GET_CLASS (display)->beep (display);
 }
 
 /**
@@ -1470,7 +1512,9 @@ gdk_display_beep (GdkDisplay *display)
 void
 gdk_display_sync (GdkDisplay *display)
 {
-  GDK_DISPLAY_GET_CLASS(display)->sync (display);
+  g_return_if_fail (GDK_IS_DISPLAY (display));
+
+  GDK_DISPLAY_GET_CLASS (display)->sync (display);
 }
 
 /**
@@ -1492,7 +1536,9 @@ gdk_display_sync (GdkDisplay *display)
 void
 gdk_display_flush (GdkDisplay *display)
 {
-  GDK_DISPLAY_GET_CLASS(display)->flush (display);
+  g_return_if_fail (GDK_IS_DISPLAY (display));
+
+  GDK_DISPLAY_GET_CLASS (display)->flush (display);
 }
 
 /**
@@ -1511,7 +1557,9 @@ gdk_display_flush (GdkDisplay *display)
 GdkWindow *
 gdk_display_get_default_group (GdkDisplay *display)
 {
-  return GDK_DISPLAY_GET_CLASS(display)->get_default_group (display);
+  g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
+
+  return GDK_DISPLAY_GET_CLASS (display)->get_default_group (display);
 }
 
 /**
@@ -1529,7 +1577,9 @@ gdk_display_get_default_group (GdkDisplay *display)
 gboolean
 gdk_display_supports_selection_notification (GdkDisplay *display)
 {
-  return GDK_DISPLAY_GET_CLASS(display)->supports_selection_notification (display);
+  g_return_val_if_fail (GDK_IS_DISPLAY (display), FALSE);
+
+  return GDK_DISPLAY_GET_CLASS (display)->supports_selection_notification (display);
 }
 
 /**
@@ -1551,11 +1601,13 @@ gdk_display_request_selection_notification (GdkDisplay *display,
                                            GdkAtom     selection)
 
 {
-  return GDK_DISPLAY_GET_CLASS(display)->request_selection_notification (display, selection);
+  g_return_val_if_fail (GDK_IS_DISPLAY (display), FALSE);
+
+  return GDK_DISPLAY_GET_CLASS (display)->request_selection_notification (display, selection);
 }
 
 /**
- * gdk_display_supports_clipboard_persistence
+ * gdk_display_supports_clipboard_persistence:
  * @display: a #GdkDisplay
  *
  * Returns whether the speicifed display supports clipboard
@@ -1570,15 +1622,17 @@ gdk_display_request_selection_notification (GdkDisplay *display,
 gboolean
 gdk_display_supports_clipboard_persistence (GdkDisplay *display)
 {
-  return GDK_DISPLAY_GET_CLASS(display)->supports_clipboard_persistence (display);
+  g_return_val_if_fail (GDK_IS_DISPLAY (display), FALSE);
+
+  return GDK_DISPLAY_GET_CLASS (display)->supports_clipboard_persistence (display);
 }
 
 /**
- * gdk_display_store_clipboard
+ * gdk_display_store_clipboard:
  * @display:          a #GdkDisplay
  * @clipboard_window: a #GdkWindow belonging to the clipboard owner
  * @time_:            a timestamp
- * @targets:         (array length=n_targets): an array of targets
+ * @targets:          (array length=n_targets): an array of targets
  *                    that should be saved, or %NULL
  *                    if all available targets should be saved.
  * @n_targets:        length of the @targets array
@@ -1598,7 +1652,9 @@ gdk_display_store_clipboard (GdkDisplay    *display,
                             const GdkAtom *targets,
                             gint           n_targets)
 {
-  GDK_DISPLAY_GET_CLASS(display)->store_clipboard (display, clipboard_window, time_, targets, n_targets);
+  g_return_if_fail (GDK_IS_DISPLAY (display));
+
+  GDK_DISPLAY_GET_CLASS (display)->store_clipboard (display, clipboard_window, time_, targets, n_targets);
 }
 
 /**
@@ -1615,7 +1671,9 @@ gdk_display_store_clipboard (GdkDisplay    *display,
 gboolean
 gdk_display_supports_shapes (GdkDisplay *display)
 {
-  return GDK_DISPLAY_GET_CLASS(display)->supports_shapes (display);
+  g_return_val_if_fail (GDK_IS_DISPLAY (display), FALSE);
+
+  return GDK_DISPLAY_GET_CLASS (display)->supports_shapes (display);
 }
 
 /**
@@ -1632,7 +1690,9 @@ gdk_display_supports_shapes (GdkDisplay *display)
 gboolean
 gdk_display_supports_input_shapes (GdkDisplay *display)
 {
-  return GDK_DISPLAY_GET_CLASS(display)->supports_input_shapes (display);
+  g_return_val_if_fail (GDK_IS_DISPLAY (display), FALSE);
+
+  return GDK_DISPLAY_GET_CLASS (display)->supports_input_shapes (display);
 }
 
 /**
@@ -1652,7 +1712,9 @@ gdk_display_supports_input_shapes (GdkDisplay *display)
 gboolean
 gdk_display_supports_composite (GdkDisplay *display)
 {
-  return GDK_DISPLAY_GET_CLASS(display)->supports_composite (display);
+  g_return_val_if_fail (GDK_IS_DISPLAY (display), FALSE);
+
+  return GDK_DISPLAY_GET_CLASS (display)->supports_composite (display);
 }
 
 /**
@@ -1672,77 +1734,9 @@ gdk_display_supports_composite (GdkDisplay *display)
 GList *
 gdk_display_list_devices (GdkDisplay *display)
 {
-  return GDK_DISPLAY_GET_CLASS(display)->list_devices (display);
-}
-
-/**
- * gdk_event_send_client_message_for_display:
- * @display: the #GdkDisplay for the window where the message is to be sent.
- * @event: the #GdkEvent to send, which should be a #GdkEventClient.
- * @winid: the window to send the client message to.
- *
- * On X11, sends an X ClientMessage event to a given window. On
- * Windows, sends a message registered with the name
- * GDK_WIN32_CLIENT_MESSAGE.
- *
- * This could be used for communicating between different
- * applications, though the amount of data is limited to 20 bytes on
- * X11, and to just four bytes on Windows.
- *
- * Returns: non-zero on success.
- *
- * Since: 2.2
- */
-gboolean
-gdk_event_send_client_message_for_display (GdkDisplay     *display,
-                                          GdkEvent       *event,
-                                          GdkNativeWindow winid)
-{
-  return GDK_DISPLAY_GET_CLASS(display)->send_client_message (display, event, winid);
-}
+  g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
 
-/**
- * gdk_display_add_client_message_filter: (skip)
- * @display: a #GdkDisplay for which this message filter applies
- * @message_type: the type of ClientMessage events to receive.
- *   This will be checked against the @message_type field
- *   of the XClientMessage event struct.
- * @func: the function to call to process the event.
- * @data: user data to pass to @func.
- *
- * Adds a filter to be called when X ClientMessage events are received.
- * See gdk_window_add_filter() if you are interested in filtering other
- * types of events.
- *
- * Since: 2.2
- **/
-void
-gdk_display_add_client_message_filter (GdkDisplay   *display,
-                                      GdkAtom       message_type,
-                                      GdkFilterFunc func,
-                                      gpointer      data)
-{
-  GDK_DISPLAY_GET_CLASS(display)->add_client_message_filter (display, message_type, func, data);
-}
-
-/**
- * gdk_add_client_message_filter: (skip)
- * @message_type: the type of ClientMessage events to receive. This will be
- *     checked against the <structfield>message_type</structfield> field of the
- *     XClientMessage event struct.
- * @func: the function to call to process the event.
- * @data: user data to pass to @func.
- *
- * Adds a filter to the default display to be called when X ClientMessage events
- * are received. See gdk_display_add_client_message_filter().
- **/
-void
-gdk_add_client_message_filter (GdkAtom       message_type,
-                              GdkFilterFunc func,
-                              gpointer      data)
-{
-  gdk_display_add_client_message_filter (gdk_display_get_default (),
-                                        message_type, func, data);
+  return GDK_DISPLAY_GET_CLASS (display)->list_devices (display);
 }
 
 static GdkAppLaunchContext *
@@ -1772,29 +1766,9 @@ gdk_display_real_get_app_launch_context (GdkDisplay *display)
 GdkAppLaunchContext *
 gdk_display_get_app_launch_context (GdkDisplay *display)
 {
-  return GDK_DISPLAY_GET_CLASS(display)->get_app_launch_context (display);
-}
+  g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
 
-/**
- * gdk_drag_get_protocol_for_display:
- * @display: the #GdkDisplay where the destination window resides
- * @xid: the windowing system id of the destination window.
- * @protocol: (out): location where the supported DND protocol is returned.
- *
- * Finds out the DND protocol supported by a window.
- *
- * Return value: the windowing system id of the window where the drop
- *    should happen. This may be @xid or the id of a proxy window,
- *    or zero if @xid does not support Drag and Drop.
- *
- * Since: 2.2
- */
-GdkNativeWindow
-gdk_drag_get_protocol_for_display (GdkDisplay      *display,
-                                   GdkNativeWindow  xid,
-                                   GdkDragProtocol *protocol)
-{
-  return GDK_DISPLAY_GET_CLASS (display)->get_drag_protocol (display, xid, protocol, NULL);
+  return GDK_DISPLAY_GET_CLASS (display)->get_app_launch_context (display);
 }
 
 /**
@@ -1811,7 +1785,8 @@ gdk_drag_get_protocol_for_display (GdkDisplay      *display,
 GdkDisplay *
 gdk_display_open (const gchar *display_name)
 {
-  return gdk_display_manager_open_display (gdk_display_manager_get (), display_name);
+  return gdk_display_manager_open_display (gdk_display_manager_get (),
+                                           display_name);
 }
 
 /**
@@ -1828,6 +1803,8 @@ gdk_display_open (const gchar *display_name)
 gboolean
 gdk_display_has_pending (GdkDisplay *display)
 {
+  g_return_val_if_fail (GDK_IS_DISPLAY (display), FALSE);
+
   return GDK_DISPLAY_GET_CLASS (display)->has_pending (display);
 }
 
@@ -1946,6 +1923,8 @@ gdk_display_warp_pointer (GdkDisplay *display,
                           gint        x,
                           gint        y)
 {
+  g_return_if_fail (GDK_IS_DISPLAY (display));
+
   gdk_device_warp (display->core_pointer,
                    screen,
                    x, y);
@@ -2023,9 +2002,43 @@ void
 gdk_display_notify_startup_complete (GdkDisplay  *display,
                                      const gchar *startup_id)
 {
+  g_return_if_fail (GDK_IS_DISPLAY (display));
+
   GDK_DISPLAY_GET_CLASS (display)->notify_startup_complete (display, startup_id);
 }
 
+void
+_gdk_display_pause_events (GdkDisplay *display)
+{
+  display->event_pause_count++;
+}
+
+void
+_gdk_display_unpause_events (GdkDisplay *display)
+{
+  g_return_if_fail (display->event_pause_count > 0);
+
+  display->event_pause_count--;
+}
+
+void
+_gdk_display_flush_events (GdkDisplay *display)
+{
+  display->flushing_events = TRUE;
+
+  while (TRUE)
+    {
+      GdkEvent *event = _gdk_event_unqueue (display);
+      if (event == NULL)
+        break;
+
+      _gdk_event_emit (event);
+      gdk_event_free (event);
+    }
+
+  display->flushing_events = FALSE;
+}
+
 void
 _gdk_display_event_data_copy (GdkDisplay     *display,
                               const GdkEvent *event,
@@ -2078,6 +2091,8 @@ _gdk_display_create_window (GdkDisplay *display)
 GdkKeymap*
 gdk_keymap_get_for_display (GdkDisplay *display)
 {
+  g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL);
+
   return GDK_DISPLAY_GET_CLASS (display)->get_keymap (display);
 }