]> Pileus Git - ~andy/gtk/blobdiff - gdk/gdkevents.c
Document how Cocoa coordinate and monitor layout transforms to GDK work
[~andy/gtk] / gdk / gdkevents.c
index bc0e62a42d6f8dd949772eebef6aa0938e0b8bb1..90e16d7bd85e320fde7e7da66ac9ecca2c3b7e78 100644 (file)
@@ -24,7 +24,7 @@
  * GTK+ at ftp://ftp.gtk.org/pub/gtk/. 
  */
 
-#include <config.h>
+#include "config.h"
 #include <string.h>            /* For memset() */
 
 #include "gdk.h"
@@ -37,7 +37,7 @@ struct _GdkIOClosure
 {
   GdkInputFunction function;
   GdkInputCondition condition;
-  GdkDestroyNotify notify;
+  GDestroyNotify notify;
   gpointer data;
 };
 
@@ -120,6 +120,63 @@ _gdk_event_queue_append (GdkDisplay *display,
   return display->queued_tail;
 }
 
+/**
+ * _gdk_event_queue_insert_after:
+ * @display: a #GdkDisplay
+ * @sibling: Append after this event.
+ * @event: Event to append.
+ *
+ * Appends an event after the specified event, or if it isn't in
+ * the queue, onto the tail of the event queue.
+ *
+ * Returns: the newly appended list node.
+ *
+ * Since: 2.16
+ */
+GList*
+_gdk_event_queue_insert_after (GdkDisplay *display,
+                               GdkEvent   *sibling,
+                               GdkEvent   *event)
+{
+  GList *prev = g_list_find (display->queued_events, sibling);
+  if (prev && prev->next)
+    {
+      display->queued_events = g_list_insert_before (display->queued_events, prev->next, event);
+      return prev->next;
+    }
+  else
+    return _gdk_event_queue_append (display, event);
+}
+
+/**
+ * _gdk_event_queue_insert_after:
+ * @display: a #GdkDisplay
+ * @sibling: Append after this event.
+ * @event: Event to append.
+ *
+ * Appends an event before the specified event, or if it isn't in
+ * the queue, onto the tail of the event queue.
+ *
+ * Returns: the newly appended list node.
+ *
+ * Since: 2.16
+ */
+GList*
+_gdk_event_queue_insert_before (GdkDisplay *display,
+                               GdkEvent   *sibling,
+                               GdkEvent   *event)
+{
+  GList *next = g_list_find (display->queued_events, sibling);
+  if (next)
+    {
+      display->queued_events = g_list_insert_before (display->queued_events, next, event);
+      return next->prev;
+    }
+  else
+    return _gdk_event_queue_append (display, event);
+}
+
+
 /**
  * _gdk_event_queue_remove_link:
  * @display: a #GdkDisplay
@@ -575,6 +632,7 @@ gdk_event_get_time (const GdkEvent *event)
       case GDK_SETTING:
       case GDK_OWNER_CHANGE:
       case GDK_GRAB_BROKEN:
+      case GDK_EVENT_LAST:
         /* return current time */
         break;
       }
@@ -653,6 +711,7 @@ gdk_event_get_state (const GdkEvent        *event,
       case GDK_SETTING:
       case GDK_OWNER_CHANGE:
       case GDK_GRAB_BROKEN:
+      case GDK_EVENT_LAST:
         /* no state field */
         break;
       }
@@ -884,9 +943,17 @@ gdk_event_get_axis (const GdkEvent *event,
 void
 gdk_event_request_motions (const GdkEventMotion *event)
 {
+  GdkDisplay *display;
+  
   g_return_if_fail (event != NULL);
+  
   if (event->type == GDK_MOTION_NOTIFY && event->is_hint)
-    gdk_device_get_state (event->device, event->window, NULL, NULL);
+    {
+      gdk_device_get_state (event->device, event->window, NULL, NULL);
+      
+      display = gdk_drawable_get_display (event->window);
+      _gdk_display_enable_motion_hints (display);
+    }
 }
 
 /**
@@ -1015,12 +1082,29 @@ gdk_io_invoke (GIOChannel   *source,
   return TRUE;
 }
 
+/**
+ * gdk_input_add_full:
+ * @source: a file descriptor.
+ * @condition: the condition.
+ * @function: the callback function.
+ * @data: callback data passed to @function.
+ * @destroy: callback function to call with @data when the input
+ * handler is removed.
+ *
+ * Establish a callback when a condition becomes true on
+ * a file descriptor.
+ *
+ * Returns: a tag that can later be used as an argument to
+ * gdk_input_remove().
+ *
+ * Deprecated: Use g_io_add_watch_full() on a #GIOChannel
+ */
 gint
 gdk_input_add_full (gint             source,
                    GdkInputCondition condition,
                    GdkInputFunction  function,
                    gpointer          data,
-                   GdkDestroyNotify  destroy)
+                   GDestroyNotify    destroy)
 {
   guint result;
   GdkIOClosure *closure = g_new (GdkIOClosure, 1);
@@ -1048,6 +1132,21 @@ gdk_input_add_full (gint       source,
   return result;
 }
 
+/**
+ * gdk_input_add:
+ * @source: a file descriptor.
+ * @condition: the condition.
+ * @function: the callback function.
+ * @data: callback data passed to @function.
+ *
+ * Establish a callback when a condition becomes true on
+ * a file descriptor.
+ *
+ * Returns: a tag that can later be used as an argument to
+ * gdk_input_remove().
+ *
+ * Deprecated: Use g_io_add_watch() on a #GIOChannel
+ */
 gint
 gdk_input_add (gint             source,
               GdkInputCondition condition,
@@ -1069,13 +1168,16 @@ gdk_synthesize_click (GdkDisplay *display,
                      gint        nclicks)
 {
   GdkEvent temp_event;
+  GdkEvent *event_copy;
+  GList *link;
   
   g_return_if_fail (event != NULL);
   
   temp_event = *event;
   temp_event.type = (nclicks == 2) ? GDK_2BUTTON_PRESS : GDK_3BUTTON_PRESS;
-  
-  gdk_display_put_event (display, &temp_event);
+
+  event_copy = gdk_event_copy (&temp_event);
+  link = _gdk_event_queue_append (display, event_copy);
 }
 
 void
@@ -1164,6 +1266,9 @@ gdk_synthesize_window_state (GdkWindow     *window,
   
   ((GdkWindowObject*) window)->state = temp_event.window_state.new_window_state;
 
+  if (temp_event.window_state.changed_mask & GDK_WINDOW_STATE_WITHDRAWN)
+    _gdk_window_update_viewable (window);
+
   /* We only really send the event to toplevels, since
    * all the window states don't apply to non-toplevels.
    * Non-toplevels do use the GDK_WINDOW_STATE_WITHDRAWN flag
@@ -1259,7 +1364,7 @@ gdk_event_get_type (void)
  * Obtains a desktop-wide setting, such as the double-click time,
  * for the default screen. See gdk_screen_get_setting().
  *
- * Returns : %TRUE if the setting existed and a value was stored
+ * Returns: %TRUE if the setting existed and a value was stored
  *   in @value, %FALSE otherwise.
  **/
 gboolean