Flutter Linux Embedder
fl_subsurface.cc File Reference
#include "flutter/shell/platform/linux/fl_subsurface.h"
#include <wayland-client.h>

Go to the source code of this file.

Classes

struct  _FlSubsurface
 

Functions

static void fl_subsurface_dispose (GObject *object)
 
static void fl_subsurface_class_init (FlSubsurfaceClass *klass)
 
static void fl_subsurface_init (FlSubsurface *self)
 
FlSubsurface * fl_subsurface_new (struct wl_compositor *compositor, struct wl_subcompositor *subcompositor, struct wl_surface *parent_surface)
 
struct wl_surface * fl_subsurface_get_surface (FlSubsurface *self)
 
void fl_subsurface_set_position (FlSubsurface *self, gint x, gint y)
 

Function Documentation

◆ fl_subsurface_class_init()

static void fl_subsurface_class_init ( FlSubsurfaceClass *  klass)
static

Definition at line 28 of file fl_subsurface.cc.

28  {
29  G_OBJECT_CLASS(klass)->dispose = fl_subsurface_dispose;
30 }
static void fl_subsurface_dispose(GObject *object)

References fl_subsurface_dispose().

◆ fl_subsurface_dispose()

static void fl_subsurface_dispose ( GObject *  object)
static

Definition at line 19 of file fl_subsurface.cc.

19  {
20  FlSubsurface* self = FL_SUBSURFACE(object);
21 
22  g_clear_pointer(&self->subsurface, wl_subsurface_destroy);
23  g_clear_pointer(&self->surface, wl_surface_destroy);
24 
25  G_OBJECT_CLASS(fl_subsurface_parent_class)->dispose(object);
26 }

Referenced by fl_subsurface_class_init().

◆ fl_subsurface_get_surface()

struct wl_surface* fl_subsurface_get_surface ( FlSubsurface *  subsurface)

fl_subsurface_get_surface: @subsurface: an #FlSubsurface.

Gets the Wayland surface backing this subsurface.

Returns: a struct wl_surface.

Definition at line 55 of file fl_subsurface.cc.

55  {
56  g_return_val_if_fail(FL_IS_SUBSURFACE(self), nullptr);
57  return self->surface;
58 }

Referenced by setup(), and TEST_F().

◆ fl_subsurface_init()

static void fl_subsurface_init ( FlSubsurface *  self)
static

Definition at line 32 of file fl_subsurface.cc.

32 {}

◆ fl_subsurface_new()

FlSubsurface* fl_subsurface_new ( struct wl_compositor *  compositor,
struct wl_subcompositor *  subcompositor,
struct wl_surface *  parent_surface 
)

FlSubsurface:

#FlSubsurface manages a Wayland subsurface attached to another Wayland surface. It is used to render Flutter content directly to a Wayland surface, independently of the GTK widget hierarchy. fl_subsurface_new: @compositor: the Wayland compositor to create the surface with. @subcompositor: the Wayland subcompositor to create the subsurface with. @parent_surface: the Wayland surface to attach the subsurface to.

Creates a new Wayland subsurface on @parent_surface.

Returns: a new #FlSubsurface.

Definition at line 34 of file fl_subsurface.cc.

36  {
37  FlSubsurface* self =
38  FL_SUBSURFACE(g_object_new(fl_subsurface_get_type(), nullptr));
39 
40  self->surface = wl_compositor_create_surface(compositor);
41  self->subsurface = wl_subcompositor_get_subsurface(
42  subcompositor, self->surface, parent_surface);
43  wl_subsurface_set_sync(self->subsurface);
44 
45  // Give the subsurface an empty input region so pointer, touch and keyboard
46  // events pass through to the parent (GTK) surface, which handles all input
47  // for the view.
48  struct wl_region* input_region = wl_compositor_create_region(compositor);
49  wl_surface_set_input_region(self->surface, input_region);
50  wl_region_destroy(input_region);
51 
52  return self;
53 }

Referenced by fl_wayland_display_create_subsurface().

◆ fl_subsurface_set_position()

void fl_subsurface_set_position ( FlSubsurface *  subsurface,
gint  x,
gint  y 
)

fl_subsurface_set_position: @subsurface: an #FlSubsurface. @x: x coordinate in the parent surface. @y: y coordinate in the parent surface.

Moves the subsurface to the given position relative to the parent surface.

Definition at line 60 of file fl_subsurface.cc.

60  {
61  g_return_if_fail(FL_IS_SUBSURFACE(self));
62  wl_subsurface_set_position(self->subsurface, x, y);
63 }

Referenced by TEST_F().