[gtk/readonly-events-1: 96/149] x11: Change the wm protocols filter api



commit 15501afdbb60a14d7b2608eda68efbbfbd72fd67
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Feb 15 10:43:29 2020 -0500

    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.

 gdk/x11/gdkdisplay-x11.c | 12 ++++++------
 gdk/x11/gdkdisplay-x11.h |  3 ++-
 gdk/x11/gdkeventsource.c | 14 +++-----------
 3 files changed, 11 insertions(+), 18 deletions(-)
---
diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c
index 342c1b2afb..57d3464fdf 100644
--- a/gdk/x11/gdkdisplay-x11.c
+++ b/gdk/x11/gdkdisplay-x11.c
@@ -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]);
 
diff --git a/gdk/x11/gdkdisplay-x11.h b/gdk/x11/gdkdisplay-x11.h
index c326b6a23e..5949123270 100644
--- a/gdk/x11/gdkdisplay-x11.h
+++ b/gdk/x11/gdkdisplay-x11.h
@@ -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
diff --git a/gdk/x11/gdkeventsource.c b/gdk/x11/gdkeventsource.c
index dad87eb6df..2ca0f2c4a6 100644
--- a/gdk/x11/gdkeventsource.c
+++ b/gdk/x11/gdkeventsource.c
@@ -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() */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]