diff --git a/gdk/wayland/gdksubsurface-wayland-private.h b/gdk/wayland/gdksubsurface-wayland-private.h index 7c0b6cfed0..567bb70882 100644 --- a/gdk/wayland/gdksubsurface-wayland-private.h +++ b/gdk/wayland/gdksubsurface-wayland-private.h @@ -39,3 +39,6 @@ GType gdk_wayland_subsurface_get_type (void) G_GNUC_CONST; void gdk_wayland_subsurface_request_frame (GdkSubsurface *subsurface); void gdk_wayland_subsurface_clear_frame_callback (GdkSubsurface *subsurface); + +GdkSubsurface * gdk_wayland_surface_create_subsurface (GdkSurface *surface); + diff --git a/gdk/wayland/gdksubsurface-wayland.c b/gdk/wayland/gdksubsurface-wayland.c index de4b298b60..d1b311b8c1 100644 --- a/gdk/wayland/gdksubsurface-wayland.c +++ b/gdk/wayland/gdksubsurface-wayland.c @@ -423,3 +423,46 @@ gdk_wayland_subsurface_clear_frame_callback (GdkSubsurface *sub) g_clear_pointer (&self->frame_callback, wl_callback_destroy); } + +GdkSubsurface * +gdk_wayland_surface_create_subsurface (GdkSurface *surface) +{ + GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface); + GdkDisplay *display = gdk_surface_get_display (surface); + GdkWaylandDisplay *disp = GDK_WAYLAND_DISPLAY (display); + GdkWaylandSubsurface *sub; + struct wl_region *region; + + if (disp->viewporter == NULL) + { + GDK_DISPLAY_DEBUG (display, OFFLOAD, "Can't use subsurfaces without viewporter"); + return NULL; + } + + sub = g_object_new (GDK_TYPE_WAYLAND_SUBSURFACE, NULL); + + sub->surface = wl_compositor_create_surface (disp->compositor); + sub->subsurface = wl_subcompositor_get_subsurface (disp->subcompositor, + sub->surface, + impl->display_server.wl_surface); + sub->viewport = wp_viewporter_get_viewport (disp->viewporter, sub->surface); + + /* No input, please */ + region = wl_compositor_create_region (disp->compositor); + wl_surface_set_input_region (sub->surface, region); + wl_region_destroy (region); + + /* Keep a max-sized opaque region so we don't have to update it + * when the size of the texture changes. + */ + sub->opaque_region = wl_compositor_create_region (disp->compositor); + wl_region_add (sub->opaque_region, 0, 0, G_MAXINT, G_MAXINT); + wl_surface_set_opaque_region (sub->surface, sub->opaque_region); + + sub->above_parent = TRUE; + + GDK_DISPLAY_DEBUG (display, OFFLOAD, "Subsurface %p of surface %p created", sub, impl); + + return GDK_SUBSURFACE (sub); +} + diff --git a/gdk/wayland/gdksurface-wayland.c b/gdk/wayland/gdksurface-wayland.c index 498745c6e9..e96853a6b6 100644 --- a/gdk/wayland/gdksurface-wayland.c +++ b/gdk/wayland/gdksurface-wayland.c @@ -1253,8 +1253,6 @@ gdk_wayland_surface_default_hide_surface (GdkWaylandSurface *surface) { } -static GdkSubsurface *gdk_wayland_surface_create_subsurface (GdkSurface *surface); - static void gdk_wayland_surface_class_init (GdkWaylandSurfaceClass *klass) { @@ -1354,49 +1352,4 @@ gdk_wayland_surface_get_wl_surface (GdkSurface *surface) } /* }}}} */ -/* {{{ Subsurface */ - -static GdkSubsurface * -gdk_wayland_surface_create_subsurface (GdkSurface *surface) -{ - GdkWaylandSurface *impl = GDK_WAYLAND_SURFACE (surface); - GdkDisplay *display = gdk_surface_get_display (surface); - GdkWaylandDisplay *disp = GDK_WAYLAND_DISPLAY (display); - GdkWaylandSubsurface *sub; - struct wl_region *region; - - if (disp->viewporter == NULL) - { - GDK_DISPLAY_DEBUG (display, OFFLOAD, "Can't use subsurfaces without viewporter"); - return NULL; - } - - sub = g_object_new (GDK_TYPE_WAYLAND_SUBSURFACE, NULL); - - sub->surface = wl_compositor_create_surface (disp->compositor); - sub->subsurface = wl_subcompositor_get_subsurface (disp->subcompositor, - sub->surface, - impl->display_server.wl_surface); - sub->viewport = wp_viewporter_get_viewport (disp->viewporter, sub->surface); - - /* No input, please */ - region = wl_compositor_create_region (disp->compositor); - wl_surface_set_input_region (sub->surface, region); - wl_region_destroy (region); - - /* Keep a max-sized opaque region so we don't have to update it - * when the size of the texture changes. - */ - sub->opaque_region = wl_compositor_create_region (disp->compositor); - wl_region_add (sub->opaque_region, 0, 0, G_MAXINT, G_MAXINT); - wl_surface_set_opaque_region (sub->surface, sub->opaque_region); - - sub->above_parent = TRUE; - - GDK_DISPLAY_DEBUG (display, OFFLOAD, "Subsurface %p of surface %p created", sub, impl); - - return GDK_SUBSURFACE (sub); -} - -/* }}} */ /* vim:set foldmethod=marker expandtab: */