x11: Change the wm protocols filter api

Instead of passing a half-constructed event and expect
it to be filled in, pass the surface as in argument, and
add an out argument for a newly constructed GdkEvent.
This commit is contained in:
Matthias Clasen 2020-02-15 10:43:29 -05:00
parent 94fe0944cc
commit 15501afdbb
3 changed files with 11 additions and 18 deletions

View File

@ -1216,11 +1216,11 @@ server_time_to_monotonic_time (GdkX11Display *display_x11,
}
GdkFilterReturn
_gdk_wm_protocols_filter (const XEvent *xevent,
GdkEvent *event,
gpointer data)
_gdk_wm_protocols_filter (const XEvent *xevent,
GdkSurface *win,
GdkEvent **event,
gpointer data)
{
GdkSurface *win = event->any.surface;
GdkDisplay *display;
Atom atom;
@ -1258,7 +1258,7 @@ _gdk_wm_protocols_filter (const XEvent *xevent,
if (surface_impl->toplevel->frame_pending)
{
surface_impl->toplevel->frame_pending = FALSE;
gdk_surface_thaw_updates (event->any.surface);
gdk_surface_thaw_updates (win);
}
gdk_frame_clock_get_refresh_info (clock,
@ -1330,7 +1330,7 @@ _gdk_wm_protocols_filter (const XEvent *xevent,
g_message ("delete window:\t\twindow: %ld",
xevent->xclient.window));
event->any.type = GDK_DELETE;
*event = gdk_event_delete_new (win);
gdk_x11_surface_set_user_time (win, xevent->xclient.data.l[1]);

View File

@ -179,7 +179,8 @@ gboolean gdk_x11_display_request_selection_notification (GdkDisplay
const char *selection);
GdkFilterReturn _gdk_wm_protocols_filter (const XEvent *xevent,
GdkEvent *event,
GdkSurface *win,
GdkEvent **event,
gpointer data);
G_END_DECLS

View File

@ -232,11 +232,9 @@ gdk_event_source_translate_event (GdkX11Display *x11_display,
x11_screen = GDK_X11_DISPLAY (display)->screen;
dpy = GDK_DISPLAY_XDISPLAY (display);
event = gdk_event_new (GDK_NOTHING);
event = NULL;
filter_surface = gdk_event_source_get_filter_surface (event_source, xevent,
&event_translator);
if (filter_surface)
event->any.surface = g_object_ref (filter_surface);
/* apply XSettings filters */
if (xevent->xany.window == XRootWindow (dpy, 0))
@ -258,7 +256,7 @@ gdk_event_source_translate_event (GdkX11Display *x11_display,
}
if (result == GDK_FILTER_CONTINUE)
result = _gdk_wm_protocols_filter (xevent, event, NULL);
result = _gdk_wm_protocols_filter (xevent, filter_surface, &event, NULL);
if (result == GDK_FILTER_CONTINUE &&
gdk_x11_drop_filter (event->any.surface, xevent))
@ -267,17 +265,11 @@ gdk_event_source_translate_event (GdkX11Display *x11_display,
if (result != GDK_FILTER_CONTINUE)
{
if (result == GDK_FILTER_REMOVE)
{
g_object_unref (event);
return NULL;
}
return NULL;
else /* GDK_FILTER_TRANSLATE */
return event;
}
g_object_unref (event);
event = NULL;
if (event_translator)
{
/* Event translator was gotten before in get_filter_window() */