Flutter Linux Embedder
fl_mouse_cursor_channel.cc File Reference

Go to the source code of this file.

Classes

struct  _FlMouseCursorChannel
 

Functions

static FlMethodResponse * activate_system_cursor (FlMouseCursorChannel *self, FlValue *args)
 
static void method_call_cb (FlMethodChannel *channel, FlMethodCall *method_call, gpointer user_data)
 
static void fl_mouse_cursor_channel_dispose (GObject *object)
 
static void fl_mouse_cursor_channel_class_init (FlMouseCursorChannelClass *klass)
 
static void fl_mouse_cursor_channel_init (FlMouseCursorChannel *self)
 
FlMouseCursorChannel * fl_mouse_cursor_channel_new (FlBinaryMessenger *messenger, FlMouseCursorChannelVTable *vtable, gpointer user_data)
 

Variables

static constexpr char kChannelName [] = "flutter/mousecursor"
 
static constexpr char kBadArgumentsError [] = "Bad Arguments"
 
static constexpr char kActivateSystemCursorMethod [] = "activateSystemCursor"
 
static constexpr char kKindKey [] = "kind"
 

Function Documentation

◆ activate_system_cursor()

static FlMethodResponse* activate_system_cursor ( FlMouseCursorChannel *  self,
FlValue args 
)
static

Definition at line 30 of file fl_mouse_cursor_channel.cc.

31  {
33  return FL_METHOD_RESPONSE(fl_method_error_response_new(
34  kBadArgumentsError, "Argument map missing or malformed", nullptr));
35  }
36 
38  const gchar* kind = nullptr;
39  if (kind_value != nullptr &&
40  fl_value_get_type(kind_value) == FL_VALUE_TYPE_STRING) {
41  kind = fl_value_get_string(kind_value);
42  }
43 
44  self->vtable->activate_system_cursor(kind, self->user_data);
45 
46  return FL_METHOD_RESPONSE(fl_method_success_response_new(nullptr));
47 }
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
G_MODULE_EXPORT FlMethodErrorResponse * fl_method_error_response_new(const gchar *code, const gchar *message, FlValue *details)
G_MODULE_EXPORT FlMethodSuccessResponse * fl_method_success_response_new(FlValue *result)
static constexpr char kKindKey[]
static constexpr char kBadArgumentsError[]
G_MODULE_EXPORT FlValue * fl_value_lookup_string(FlValue *self, const gchar *key)
Definition: fl_value.cc:811
G_MODULE_EXPORT FlValueType fl_value_get_type(FlValue *self)
Definition: fl_value.cc:466
G_MODULE_EXPORT const gchar * fl_value_get_string(FlValue *self)
Definition: fl_value.cc:682
typedefG_BEGIN_DECLS struct _FlValue FlValue
Definition: fl_value.h:42
@ FL_VALUE_TYPE_STRING
Definition: fl_value.h:68
@ FL_VALUE_TYPE_MAP
Definition: fl_value.h:74

References args, fl_method_error_response_new(), fl_method_success_response_new(), fl_value_get_string(), fl_value_get_type(), fl_value_lookup_string(), FL_VALUE_TYPE_MAP, FL_VALUE_TYPE_STRING, kBadArgumentsError, and kKindKey.

Referenced by method_call_cb().

◆ fl_mouse_cursor_channel_class_init()

static void fl_mouse_cursor_channel_class_init ( FlMouseCursorChannelClass *  klass)
static

Definition at line 79 of file fl_mouse_cursor_channel.cc.

80  {
81  G_OBJECT_CLASS(klass)->dispose = fl_mouse_cursor_channel_dispose;
82 }
static void fl_mouse_cursor_channel_dispose(GObject *object)

References fl_mouse_cursor_channel_dispose().

◆ fl_mouse_cursor_channel_dispose()

static void fl_mouse_cursor_channel_dispose ( GObject *  object)
static

Definition at line 71 of file fl_mouse_cursor_channel.cc.

71  {
72  FlMouseCursorChannel* self = FL_MOUSE_CURSOR_CHANNEL(object);
73 
74  g_clear_object(&self->channel);
75 
76  G_OBJECT_CLASS(fl_mouse_cursor_channel_parent_class)->dispose(object);
77 }

Referenced by fl_mouse_cursor_channel_class_init().

◆ fl_mouse_cursor_channel_init()

static void fl_mouse_cursor_channel_init ( FlMouseCursorChannel *  self)
static

Definition at line 84 of file fl_mouse_cursor_channel.cc.

84 {}

◆ fl_mouse_cursor_channel_new()

FlMouseCursorChannel* fl_mouse_cursor_channel_new ( FlBinaryMessenger *  messenger,
FlMouseCursorChannelVTable vtable,
gpointer  user_data 
)

fl_mouse_cursor_channel_new: @messenger: an #FlBinaryMessenger. @vtable: callbacks for incoming method calls. @user_data: data to pass in callbacks.

Creates a new channel that implements SystemChannels.mouseCursor from the Flutter services library.

Returns: a new #FlMouseCursorChannel.

Definition at line 86 of file fl_mouse_cursor_channel.cc.

89  {
90  g_return_val_if_fail(FL_IS_BINARY_MESSENGER(messenger), nullptr);
91 
92  FlMouseCursorChannel* self = FL_MOUSE_CURSOR_CHANNEL(
93  g_object_new(fl_mouse_cursor_channel_get_type(), nullptr));
94 
95  self->vtable = vtable;
96  self->user_data = user_data;
97 
98  g_autoptr(FlStandardMethodCodec) codec = fl_standard_method_codec_new();
99  self->channel =
100  fl_method_channel_new(messenger, kChannelName, FL_METHOD_CODEC(codec));
102  nullptr);
103 
104  return self;
105 }
g_autoptr(FlEngine) engine
const char FlTextDirection FlAssertiveness gpointer user_data
G_MODULE_EXPORT FlMethodChannel * fl_method_channel_new(FlBinaryMessenger *messenger, const gchar *name, FlMethodCodec *codec)
G_MODULE_EXPORT void fl_method_channel_set_method_call_handler(FlMethodChannel *self, FlMethodChannelMethodCallHandler handler, gpointer user_data, GDestroyNotify destroy_notify)
static void method_call_cb(FlMethodChannel *channel, FlMethodCall *method_call, gpointer user_data)
static constexpr char kChannelName[]
G_MODULE_EXPORT FlStandardMethodCodec * fl_standard_method_codec_new()

References fl_method_channel_new(), fl_method_channel_set_method_call_handler(), fl_standard_method_codec_new(), g_autoptr(), kChannelName, method_call_cb(), and user_data.

Referenced by fl_mouse_cursor_handler_new().

◆ method_call_cb()

static void method_call_cb ( FlMethodChannel *  channel,
FlMethodCall *  method_call,
gpointer  user_data 
)
static

Definition at line 50 of file fl_mouse_cursor_channel.cc.

52  {
53  FlMouseCursorChannel* self = FL_MOUSE_CURSOR_CHANNEL(user_data);
54 
55  const gchar* method = fl_method_call_get_name(method_call);
57 
58  g_autoptr(FlMethodResponse) response = nullptr;
59  if (strcmp(method, kActivateSystemCursorMethod) == 0) {
60  response = activate_system_cursor(self, args);
61  } else {
62  response = FL_METHOD_RESPONSE(fl_method_not_implemented_response_new());
63  }
64 
65  g_autoptr(GError) error = nullptr;
66  if (!fl_method_call_respond(method_call, response, &error)) {
67  g_warning("Failed to send method call response: %s", error->message);
68  }
69 }
G_MODULE_EXPORT gboolean fl_method_call_respond(FlMethodCall *self, FlMethodResponse *response, GError **error)
G_MODULE_EXPORT const gchar * fl_method_call_get_name(FlMethodCall *self)
G_MODULE_EXPORT FlValue * fl_method_call_get_args(FlMethodCall *self)
G_BEGIN_DECLS G_MODULE_EXPORT FlMethodCall * method_call
G_MODULE_EXPORT FlMethodNotImplementedResponse * fl_method_not_implemented_response_new()
static constexpr char kActivateSystemCursorMethod[]
static FlMethodResponse * activate_system_cursor(FlMouseCursorChannel *self, FlValue *args)
const uint8_t uint32_t uint32_t GError ** error

References activate_system_cursor(), args, error, fl_method_call_get_args(), fl_method_call_get_name(), fl_method_call_respond(), fl_method_not_implemented_response_new(), g_autoptr(), kActivateSystemCursorMethod, method_call, and user_data.

Referenced by fl_mouse_cursor_channel_new().

Variable Documentation

◆ kActivateSystemCursorMethod

constexpr char kActivateSystemCursorMethod[] = "activateSystemCursor"
staticconstexpr

Definition at line 14 of file fl_mouse_cursor_channel.cc.

Referenced by method_call_cb().

◆ kBadArgumentsError

constexpr char kBadArgumentsError[] = "Bad Arguments"
staticconstexpr

Definition at line 13 of file fl_mouse_cursor_channel.cc.

Referenced by activate_system_cursor().

◆ kChannelName

constexpr char kChannelName[] = "flutter/mousecursor"
staticconstexpr

Definition at line 12 of file fl_mouse_cursor_channel.cc.

Referenced by fl_mouse_cursor_channel_new().

◆ kKindKey

constexpr char kKindKey[] = "kind"
staticconstexpr

Definition at line 15 of file fl_mouse_cursor_channel.cc.

Referenced by activate_system_cursor().