[gtk+] x11: Don't use gdk_window_add_filter
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] x11: Don't use gdk_window_add_filter
- Date: Wed, 7 Feb 2018 20:13:04 +0000 (UTC)
commit 65beb0fc222662028b969085bb6e6cc30f263e10
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Feb 6 22:10:43 2018 -0500
x11: Don't use gdk_window_add_filter
This function is going away.
gdk/x11/gdkdisplay-x11.c | 3 ---
gdk/x11/gdkdnd-x11.c | 20 ++++++++++++--------
gdk/x11/gdkeventsource.c | 14 ++++++++++++++
gdk/x11/gdkmain-x11.c | 7 -------
gdk/x11/gdkprivate-x11.h | 5 +++++
5 files changed, 31 insertions(+), 18 deletions(-)
---
diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c
index 75dde8f..8608c54 100644
--- a/gdk/x11/gdkdisplay-x11.c
+++ b/gdk/x11/gdkdisplay-x11.c
@@ -2499,9 +2499,6 @@ gdk_x11_display_set_startup_notification_id (GdkDisplay *display,
* The registered events must have the window field in the same place
* as core X events (this is not the case for e.g. XKB extension events).
*
- * If an event type is registered, events of this type will go through
- * global and window-specific filters (see gdk_window_add_filter()).
- * Unregistered events will only go through global filters.
* GDK may register the events of some X extensions on its own.
*
* This function should only be needed in unusual circumstances, e.g.
diff --git a/gdk/x11/gdkdnd-x11.c b/gdk/x11/gdkdnd-x11.c
index 3290716..2b491e7 100644
--- a/gdk/x11/gdkdnd-x11.c
+++ b/gdk/x11/gdkdnd-x11.c
@@ -1619,14 +1619,20 @@ xdnd_read_actions (GdkX11DragContext *context_x11)
* to continually send actions. So we select on PropertyChangeMask
* and add this filter.
*/
-static GdkFilterReturn
+GdkFilterReturn
xdnd_source_window_filter (GdkXEvent *xev,
GdkEvent *event,
- gpointer cb_data)
+ gpointer data)
{
XEvent *xevent = (XEvent *)xev;
- GdkX11DragContext *context_x11 = cb_data;
- GdkDisplay *display = gdk_drag_context_get_display (GDK_DRAG_CONTEXT (context_x11));
+ GdkX11DragContext *context_x11;
+ GdkDisplay *display;
+
+ if (!data)
+ return GDK_FILTER_CONTINUE;
+
+ context_x11 = data;
+ display = gdk_drag_context_get_display (GDK_DRAG_CONTEXT (context_x11));
if ((xevent->xany.type == PropertyNotify) &&
(xevent->xproperty.atom == gdk_x11_get_xatom_by_name_for_display (display, "XdndActionList")))
@@ -1656,13 +1662,11 @@ xdnd_manage_source_filter (GdkDragContext *context,
gdk_window_set_events (window,
gdk_window_get_events (window) |
GDK_PROPERTY_CHANGE_MASK);
- gdk_window_add_filter (window, xdnd_source_window_filter, context);
+ g_object_set_data (G_OBJECT (window), "xdnd-source-context", context);
}
else
{
- gdk_window_remove_filter (window,
- xdnd_source_window_filter,
- context);
+ g_object_set_data (G_OBJECT (window), "xdnd-source-context", NULL);
/* Should we remove the GDK_PROPERTY_NOTIFY mask?
* but we might want it for other reasons. (Like
* INCR selection transactions).
diff --git a/gdk/x11/gdkeventsource.c b/gdk/x11/gdkeventsource.c
index ed20f47..e30a459 100644
--- a/gdk/x11/gdkeventsource.c
+++ b/gdk/x11/gdkeventsource.c
@@ -305,6 +305,14 @@ gdk_event_source_translate_event (GdkX11Display *x11_display,
result = gdk_window_cache_filter (xevent, event, cache);
}
+ if (result == GDK_FILTER_CONTINUE &&
+ xevent->xany.window == XRootWindow (dpy, 0))
+ result = _gdk_wm_protocols_filter ((GdkXEvent *)xevent, event, NULL);
+
+ if (result == GDK_FILTER_CONTINUE &&
+ xevent->xany.window == XRootWindow (dpy, 0))
+ result = _gdk_x11_dnd_filter ((GdkXEvent *)xevent, event, NULL);
+
/* Run default filters */
if (result == GDK_FILTER_CONTINUE &&
_gdk_default_filters)
@@ -313,6 +321,12 @@ gdk_event_source_translate_event (GdkX11Display *x11_display,
result = gdk_event_apply_filters (xevent, event, NULL);
}
+ if (result == GDK_FILTER_CONTINUE && filter_window)
+ {
+ gpointer context = g_object_get_data (G_OBJECT (filter_window), "xdnd-source-context");
+ result = xdnd_source_window_filter ((GdkXEvent *)xevent, event, context);
+ }
+
if (result == GDK_FILTER_CONTINUE &&
filter_window && filter_window->filters)
{
diff --git a/gdk/x11/gdkmain-x11.c b/gdk/x11/gdkmain-x11.c
index 669158d..72edfe1 100644
--- a/gdk/x11/gdkmain-x11.c
+++ b/gdk/x11/gdkmain-x11.c
@@ -106,13 +106,6 @@ _gdk_x11_windowing_init (void)
{
XSetErrorHandler (gdk_x_error);
XSetIOErrorHandler (gdk_x_io_error);
-
- gdk_window_add_filter (NULL,
- _gdk_wm_protocols_filter,
- NULL);
- gdk_window_add_filter (NULL,
- _gdk_x11_dnd_filter,
- NULL);
}
GdkGrabStatus
diff --git a/gdk/x11/gdkprivate-x11.h b/gdk/x11/gdkprivate-x11.h
index 16acf68..73f3f71 100644
--- a/gdk/x11/gdkprivate-x11.h
+++ b/gdk/x11/gdkprivate-x11.h
@@ -206,6 +206,11 @@ _gdk_x11_dnd_filter (GdkXEvent *xev,
GdkEvent *event,
gpointer data);
+GdkFilterReturn
+xdnd_source_window_filter (GdkXEvent *xev,
+ GdkEvent *event,
+ gpointer data);
+
typedef struct _GdkWindowCache GdkWindowCache;
GdkWindowCache *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]