#include "flutter/shell/platform/linux/fl_mouse_cursor_plugin.h"
#include <gtk/gtk.h>
#include <cstring>
#include "flutter/shell/platform/linux/public/flutter_linux/fl_method_channel.h"
#include "flutter/shell/platform/linux/public/flutter_linux/fl_standard_method_codec.h"
Go to the source code of this file.
◆ activate_system_cursor()
FlMethodResponse * activate_system_cursor |
( |
FlMouseCursorPlugin * |
self, |
|
|
FlValue * |
args |
|
) |
| |
Definition at line 88 of file fl_mouse_cursor_plugin.cc.
89 {
93 }
94
96 const gchar* kind = nullptr;
99 }
100
101 if (
self->system_cursor_table ==
nullptr) {
102 self->system_cursor_table = g_hash_table_new(g_str_hash, g_str_equal);
104 }
105
106 const gchar* cursor_name = reinterpret_cast<const gchar*>(
107 g_hash_table_lookup(
self->system_cursor_table, kind));
108 if (cursor_name == nullptr) {
110 }
111
113 gtk_widget_get_window(gtk_widget_get_toplevel(GTK_WIDGET(
self->view)));
114 g_autoptr(GdkCursor) cursor =
115 gdk_cursor_new_from_name(gdk_window_get_display(
window), cursor_name);
116 gdk_window_set_cursor(
window, cursor);
117
119}
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 void populate_system_cursor_table(GHashTable *table)
static constexpr char kKindKey[]
static constexpr char kFallbackCursor[]
static constexpr char kBadArgumentsError[]
G_MODULE_EXPORT FlValue * fl_value_lookup_string(FlValue *self, const gchar *key)
G_MODULE_EXPORT FlValueType fl_value_get_type(FlValue *self)
G_MODULE_EXPORT const gchar * fl_value_get_string(FlValue *self)
typedefG_BEGIN_DECLS struct _FlValue FlValue
◆ define_system_cursor()
static bool define_system_cursor |
( |
GHashTable * |
table, |
|
|
const gchar * |
key, |
|
|
const gchar * |
value |
|
) |
| |
|
static |
Definition at line 35 of file fl_mouse_cursor_plugin.cc.
37 {
38 return g_hash_table_insert(
39 table,
reinterpret_cast<gpointer
>(
const_cast<gchar*
>(
key)),
40 reinterpret_cast<gpointer
>(
const_cast<gchar*
>(
value)));
41}
◆ fl_mouse_cursor_plugin_class_init()
static void fl_mouse_cursor_plugin_class_init |
( |
FlMouseCursorPluginClass * |
klass | ) |
|
|
static |
◆ fl_mouse_cursor_plugin_dispose()
static void fl_mouse_cursor_plugin_dispose |
( |
GObject * |
object | ) |
|
|
static |
Definition at line 143 of file fl_mouse_cursor_plugin.cc.
143 {
144 FlMouseCursorPlugin*
self = FL_MOUSE_CURSOR_PLUGIN(
object);
145
146 g_clear_object(&
self->channel);
147 if (
self->view !=
nullptr) {
148 g_object_remove_weak_pointer(G_OBJECT(
self->view),
149 reinterpret_cast<gpointer*
>(&(
self->view)));
150 self->view =
nullptr;
151 }
152 g_clear_pointer(&
self->system_cursor_table, g_hash_table_unref);
153
154 G_OBJECT_CLASS(fl_mouse_cursor_plugin_parent_class)->dispose(object);
155}
◆ fl_mouse_cursor_plugin_init()
static void fl_mouse_cursor_plugin_init |
( |
FlMouseCursorPlugin * |
self | ) |
|
|
static |
◆ fl_mouse_cursor_plugin_new()
FlMouseCursorPlugin * fl_mouse_cursor_plugin_new |
( |
FlBinaryMessenger * |
messenger, |
|
|
FlView * |
view |
|
) |
| |
FlMouseCursorPlugin:
#FlMouseCursorPlugin is a mouse_cursor channel that implements the shell side of SystemChannels.mouseCursor from the Flutter services library. fl_mouse_cursor_plugin_new: @messenger: an #FlBinaryMessenger. @view: an #FlView to control.
Creates a new plugin that implements SystemChannels.mouseCursor from the Flutter services library.
Returns: a new #FlMouseCursorPlugin.
Definition at line 163 of file fl_mouse_cursor_plugin.cc.
164 {
165 g_return_val_if_fail(FL_IS_BINARY_MESSENGER(messenger), nullptr);
166
167 FlMouseCursorPlugin*
self = FL_MOUSE_CURSOR_PLUGIN(
168 g_object_new(fl_mouse_cursor_plugin_get_type(), nullptr));
169
174 nullptr);
176 if (view != nullptr) {
177 g_object_add_weak_pointer(G_OBJECT(view),
178 reinterpret_cast<gpointer*
>(&(
self->view)));
179 }
180
182}
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()
◆ method_call_cb()
static void method_call_cb |
( |
FlMethodChannel * |
channel, |
|
|
FlMethodCall * |
method_call, |
|
|
gpointer |
user_data |
|
) |
| |
|
static |
Definition at line 122 of file fl_mouse_cursor_plugin.cc.
124 {
125 FlMouseCursorPlugin*
self = FL_MOUSE_CURSOR_PLUGIN(
user_data);
126
129
130 g_autoptr(FlMethodResponse) response = nullptr;
133 } else {
135 }
136
137 g_autoptr(GError)
error =
nullptr;
139 g_warning(
"Failed to send method call response: %s",
error->message);
140 }
141}
G_MODULE_EXPORT const gchar * fl_method_call_get_name(FlMethodCall *self)
G_MODULE_EXPORT gboolean fl_method_call_respond(FlMethodCall *self, FlMethodResponse *response, GError **error)
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[]
FlMethodResponse * activate_system_cursor(FlMouseCursorPlugin *self, FlValue *args)
const uint8_t uint32_t uint32_t GError ** error
◆ populate_system_cursor_table()
static void populate_system_cursor_table |
( |
GHashTable * |
table | ) |
|
|
static |
Definition at line 47 of file fl_mouse_cursor_plugin.cc.
47 {
48
49
85}
static bool define_system_cursor(GHashTable *table, const gchar *key, const gchar *value)
◆ kActivateSystemCursorMethod
constexpr char kActivateSystemCursorMethod[] = "activateSystemCursor" |
|
staticconstexpr |
◆ kBadArgumentsError
constexpr char kBadArgumentsError[] = "Bad Arguments" |
|
staticconstexpr |
◆ kChannelName
constexpr char kChannelName[] = "flutter/mousecursor" |
|
staticconstexpr |
◆ kFallbackCursor
constexpr char kFallbackCursor[] = "default" |
|
staticconstexpr |
◆ kKindKey
constexpr char kKindKey[] = "kind" |
|
staticconstexpr |