From 8a453924a07649cdbebfd841e00044381ecc0764 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 13 Dec 2017 00:35:16 +0100 Subject: [PATCH] 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(). --- docs/reference/gdk/gdk4-sections.txt | 4 - gdk/gdkevents.c | 133 +-------------------------- gdk/gdkevents.h | 10 -- gdk/wayland/gdkdnd-wayland.c | 2 +- gdk/wayland/gdkselection-wayland.c | 8 +- gdk/x11/gdkdevicemanager-core-x11.c | 2 +- gdk/x11/gdkdnd-x11.c | 8 +- gdk/x11/gdkeventsource.c | 4 +- 8 files changed, 14 insertions(+), 157 deletions(-) diff --git a/docs/reference/gdk/gdk4-sections.txt b/docs/reference/gdk/gdk4-sections.txt index a22b4d36fb..e18a2d5abf 100644 --- a/docs/reference/gdk/gdk4-sections.txt +++ b/docs/reference/gdk/gdk4-sections.txt @@ -701,10 +701,6 @@ GDK_BUTTON_MIDDLE GDK_BUTTON_SECONDARY -gdk_events_pending -gdk_event_peek -gdk_event_get -gdk_event_put gdk_event_new gdk_event_copy gdk_event_free diff --git a/gdk/gdkevents.c b/gdk/gdkevents.c index 0cafdb27fe..054ca11206 100644 --- a/gdk/gdkevents.c +++ b/gdk/gdkevents.c @@ -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.window’s 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); diff --git a/gdk/gdkevents.h b/gdk/gdkevents.h index 9318e8854b..e9e6f030f8 100644 --- a/gdk/gdkevents.h +++ b/gdk/gdkevents.h @@ -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 diff --git a/gdk/wayland/gdkdnd-wayland.c b/gdk/wayland/gdkdnd-wayland.c index 2a2c56c51f..208b71e20d 100644 --- a/gdk/wayland/gdkdnd-wayland.c +++ b/gdk/wayland/gdkdnd-wayland.c @@ -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); } diff --git a/gdk/wayland/gdkselection-wayland.c b/gdk/wayland/gdkselection-wayland.c index cb888f0bbc..8f69bee53d 100644 --- a/gdk/wayland/gdkselection-wayland.c +++ b/gdk/wayland/gdkselection-wayland.c @@ -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); } diff --git a/gdk/x11/gdkdevicemanager-core-x11.c b/gdk/x11/gdkdevicemanager-core-x11.c index 76914f1fdd..22e55a69d4 100644 --- a/gdk/x11/gdkdevicemanager-core-x11.c +++ b/gdk/x11/gdkdevicemanager-core-x11.c @@ -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); } } diff --git a/gdk/x11/gdkdnd-x11.c b/gdk/x11/gdkdnd-x11.c index a5d35dfaca..a6b76ea85a 100644 --- a/gdk/x11/gdkdnd-x11.c +++ b/gdk/x11/gdkdnd-x11.c @@ -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; diff --git a/gdk/x11/gdkeventsource.c b/gdk/x11/gdkeventsource.c index cb1f811c9a..cbd5c17b03 100644 --- a/gdk/x11/gdkeventsource.c +++ b/gdk/x11/gdkeventsource.c @@ -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); } }