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



commit 78e7091874cf89d577abcd2bc1660da64d54fb6a
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 ea3d80d40f..40bd26c0b4 100644
--- a/gdk/x11/gdkdisplay-x11.c
+++ b/gdk/x11/gdkdisplay-x11.c
@@ -1206,11 +1206,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;
 
@@ -1248,7 +1248,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,
@@ -1320,7 +1320,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]