gdk: Remove gdk_event_put(), peek() etc

We don't want to treat events like they don't belong to displays. So
instead, people should use gdk_display_put/peek/get_event().
This commit is contained in:
Benjamin Otte 2017-12-13 00:35:16 +01:00
parent 5df527edaf
commit 8a453924a0
8 changed files with 14 additions and 157 deletions

View File

@ -701,10 +701,6 @@ GDK_BUTTON_MIDDLE
GDK_BUTTON_SECONDARY
<SUBSECTION>
gdk_events_pending
gdk_event_peek
gdk_event_get
gdk_event_put
gdk_event_new
gdk_event_copy
gdk_event_free

View File

@ -352,135 +352,6 @@ gdk_event_handler_set (GdkEventFunc func,
_gdk_event_notify = notify;
}
/**
* gdk_events_pending:
*
* Checks if any events are ready to be processed for any display.
*
* Returns: %TRUE if any events are pending.
*/
gboolean
gdk_events_pending (void)
{
GSList *list, *l;
gboolean pending;
pending = FALSE;
list = gdk_display_manager_list_displays (gdk_display_manager_get ());
for (l = list; l; l = l->next)
{
if (_gdk_event_queue_find_first (l->data))
{
pending = TRUE;
goto out;
}
}
for (l = list; l; l = l->next)
{
if (gdk_display_has_pending (l->data))
{
pending = TRUE;
goto out;
}
}
out:
g_slist_free (list);
return pending;
}
/**
* gdk_event_get:
*
* Checks all open displays for a #GdkEvent to process,to be processed
* on, fetching events from the windowing system if necessary.
* See gdk_display_get_event().
*
* Returns: (nullable): the next #GdkEvent to be processed, or %NULL
* if no events are pending. The returned #GdkEvent should be freed
* with gdk_event_free().
**/
GdkEvent*
gdk_event_get (void)
{
GSList *list, *l;
GdkEvent *event;
event = NULL;
list = gdk_display_manager_list_displays (gdk_display_manager_get ());
for (l = list; l; l = l->next)
{
event = gdk_display_get_event (l->data);
if (event)
break;
}
g_slist_free (list);
return event;
}
/**
* gdk_event_peek:
*
* If there is an event waiting in the event queue of some open
* display, returns a copy of it. See gdk_display_peek_event().
*
* Returns: (nullable): a copy of the first #GdkEvent on some event
* queue, or %NULL if no events are in any queues. The returned
* #GdkEvent should be freed with gdk_event_free().
**/
GdkEvent*
gdk_event_peek (void)
{
GSList *list, *l;
GdkEvent *event;
event = NULL;
list = gdk_display_manager_list_displays (gdk_display_manager_get ());
for (l = list; l; l = l->next)
{
event = gdk_display_peek_event (l->data);
if (event)
break;
}
g_slist_free (list);
return event;
}
static GdkDisplay *
event_get_display (const GdkEvent *event)
{
if (event->any.window)
return gdk_window_get_display (event->any.window);
else
return gdk_display_get_default ();
}
/**
* gdk_event_put:
* @event: a #GdkEvent.
*
* Appends a copy of the given event onto the front of the event
* queue for event->any.windows display, or the default event
* queue if event->any.window is %NULL. See gdk_display_put_event().
**/
void
gdk_event_put (const GdkEvent *event)
{
GdkDisplay *display;
g_return_if_fail (event != NULL);
display = event_get_display (event);
gdk_display_put_event (display, event);
}
static GHashTable *event_hash = NULL;
/**
@ -729,7 +600,7 @@ gdk_event_copy (const GdkEvent *event)
}
if (gdk_event_is_allocated (event))
_gdk_display_event_data_copy (event_get_display (event), event, new_event);
_gdk_display_event_data_copy (gdk_event_get_display (event), event, new_event);
return new_event;
}
@ -815,7 +686,7 @@ gdk_event_free (GdkEvent *event)
break;
}
display = event_get_display (event);
display = gdk_event_get_display (event);
if (display)
_gdk_display_event_data_free (display, event);

View File

@ -518,16 +518,6 @@ GType gdk_event_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_3_14
GType gdk_event_sequence_get_type (void) G_GNUC_CONST;
GDK_AVAILABLE_IN_ALL
gboolean gdk_events_pending (void);
GDK_AVAILABLE_IN_ALL
GdkEvent* gdk_event_get (void);
GDK_AVAILABLE_IN_ALL
GdkEvent* gdk_event_peek (void);
GDK_AVAILABLE_IN_ALL
void gdk_event_put (const GdkEvent *event);
GDK_AVAILABLE_IN_ALL
GdkEvent* gdk_event_new (GdkEventType type);
GDK_AVAILABLE_IN_ALL

View File

@ -137,7 +137,7 @@ _gdk_wayland_drag_context_emit_event (GdkDragContext *context,
event->dnd.y_root = GDK_WAYLAND_DRAG_CONTEXT (context)->y;
gdk_event_set_device (event, gdk_drag_context_get_device (context));
gdk_event_put (event);
gdk_display_put_event (gdk_window_get_display (window), event);
gdk_event_free (event);
}

View File

@ -124,7 +124,7 @@ selection_buffer_notify (SelectionBuffer *buffer)
event->selection.time = GDK_CURRENT_TIME;
event->selection.requestor = g_object_ref (l->data);
gdk_event_put (event);
gdk_display_put_event (gdk_window_get_display (l->data), event);
gdk_event_free (event);
}
}
@ -563,7 +563,7 @@ gdk_wayland_selection_emit_request (GdkWindow *window,
event->selection.time = GDK_CURRENT_TIME;
event->selection.requestor = g_object_ref (window);
gdk_event_put (event);
gdk_display_put_event (gdk_window_get_display (window), event);
gdk_event_free (event);
}
@ -1096,7 +1096,7 @@ emit_empty_selection_notify (GdkWindow *requestor,
event->selection.time = GDK_CURRENT_TIME;
event->selection.requestor = g_object_ref (requestor);
gdk_event_put (event);
gdk_display_put_event (gdk_window_get_display (requestor), event);
gdk_event_free (event);
}
@ -1118,7 +1118,7 @@ emit_selection_clear (GdkDisplay *display,
event->selection.requestor = g_object_ref (window);
}
gdk_event_put (event);
gdk_display_put_event (display, event);
gdk_event_free (event);
}

View File

@ -896,7 +896,7 @@ _gdk_device_manager_core_handle_focus (GdkWindow *window,
if (source_device)
gdk_event_set_source_device (event, source_device);
gdk_event_put (event);
gdk_display_put_event (gdk_window_get_display (window), event);
gdk_event_free (event);
}
}

View File

@ -1256,7 +1256,7 @@ send_client_message_async_cb (Window window,
temp_event->dnd.time = GDK_CURRENT_TIME;
gdk_event_set_device (temp_event, gdk_drag_context_get_device (context));
gdk_event_put (temp_event);
gdk_display_put_event (gdk_drag_context_get_display (context), temp_event);
gdk_event_free (temp_event);
}
@ -1309,7 +1309,7 @@ xdnd_send_xevent (GdkX11DragContext *context_x11,
temp_event->any.window = g_object_ref (window);
if ((*xdnd_filters[i].func) (event_send, temp_event, NULL) == GDK_FILTER_TRANSLATE)
gdk_event_put (temp_event);
gdk_display_put_event (display, temp_event);
gdk_event_free (temp_event);
@ -2360,7 +2360,7 @@ gdk_x11_drag_context_drag_motion (GdkDragContext *context,
temp_event->dnd.time = time;
gdk_event_set_device (temp_event, gdk_drag_context_get_device (context));
gdk_event_put (temp_event);
gdk_display_put_event (gdk_drag_context_get_display (context), temp_event);
gdk_event_free (temp_event);
}
else
@ -2405,7 +2405,7 @@ gdk_x11_drag_context_drag_motion (GdkDragContext *context,
temp_event->dnd.time = time;
gdk_event_set_device (temp_event, gdk_drag_context_get_device (context));
gdk_event_put (temp_event);
gdk_display_put_event (gdk_drag_context_get_display (context), temp_event);
gdk_event_free (temp_event);
}
break;

View File

@ -164,7 +164,7 @@ handle_focus_change (GdkEventCrossing *event)
focus_event->focus_change.in = focus_in;
gdk_event_set_device (focus_event, gdk_event_get_device ((GdkEvent *) event));
gdk_event_put (focus_event);
gdk_display_put_event (gdk_window_get_display (event->window), focus_event);
gdk_event_free (focus_event);
}
}
@ -258,7 +258,7 @@ handle_touch_synthetic_crossing (GdkEvent *event)
if (crossing)
{
gdk_event_put (crossing);
gdk_display_put_event (gdk_device_get_display (device), crossing);
gdk_event_free (crossing);
}
}