waylandsink: Simplify input region handling
authorRobert Mader <robert.mader@collabora.com>
Mon, 13 Dec 2021 13:31:06 +0000 (14:31 +0100)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Thu, 13 Jan 2022 19:39:59 +0000 (19:39 +0000)
We only need to unset the input region for the area surface when
we don't have our own toplevel surface. By default, the input region
covers the whole surface, thus no need to change it on resize.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1446>

subprojects/gst-plugins-bad/ext/wayland/wlwindow.c

index 961acd1..49a0447 100644 (file)
@@ -222,11 +222,7 @@ gst_wl_window_new_internal (GstWlDisplay * display, GMutex * render_lock)
         window->video_surface);
   }
 
-  /* do not accept input */
-  region = wl_compositor_create_region (display->compositor);
-  wl_surface_set_input_region (window->area_surface, region);
-  wl_region_destroy (region);
-
+  /* never accept input events on the video surface */
   region = wl_compositor_create_region (display->compositor);
   wl_surface_set_input_region (window->video_surface, region);
   wl_region_destroy (region);
@@ -345,8 +341,14 @@ gst_wl_window_new_in_surface (GstWlDisplay * display,
     struct wl_surface * parent, GMutex * render_lock)
 {
   GstWlWindow *window;
+  struct wl_region *region;
   window = gst_wl_window_new_internal (display, render_lock);
 
+  /* do not accept input events on the area surface when embedded */
+  region = wl_compositor_create_region (display->compositor);
+  wl_surface_set_input_region (window->area_surface, region);
+  wl_region_destroy (region);
+
   /* embed in parent */
   window->area_subsurface =
       wl_subcompositor_get_subsurface (display->subcompositor,
@@ -412,16 +414,6 @@ gst_wl_window_resize_video_surface (GstWlWindow * window, gboolean commit)
     wl_surface_commit (window->video_surface_wrapper);
   }
 
-  if (gst_wl_window_is_toplevel (window)) {
-    struct wl_region *region;
-
-    region = wl_compositor_create_region (window->display->compositor);
-    wl_region_add (region, 0, 0, window->render_rectangle.w,
-        window->render_rectangle.h);
-    wl_surface_set_input_region (window->area_surface, region);
-    wl_region_destroy (region);
-  }
-
   /* this is saved for use in wl_surface_damage */
   window->video_rectangle = res;
 }