| Flutter Linux Embedder |

Classes | Enumerations | Functions | Variables
fl_mouse_cursor_handler.cc File Reference
`#include "flutter/shell/platform/linux/fl_mouse_cursor_handler.h"`
`#include <cstring>`
`#include "flutter/shell/platform/linux/fl_mouse_cursor_channel.h"`

Go to the source code of this file.

## Classes
struct | _FlMouseCursorHandler

## Enumerations
enum | { SIGNAL_CURSOR_CHANGED , LAST_SIGNAL }

## Functions
static bool | define_system_cursor (GHashTable *table, const gchar *key, const gchar *value)
static void | populate_system_cursor_table (GHashTable *table)
static void | activate_system_cursor (const gchar *kind, gpointer user_data)
static void | fl_mouse_cursor_handler_dispose (GObject *object)
static void | fl_mouse_cursor_handler_class_init (FlMouseCursorHandlerClass *klass)
static void | fl_mouse_cursor_handler_init (FlMouseCursorHandler *self)
FlMouseCursorHandler * | fl_mouse_cursor_handler_new (FlBinaryMessenger *messenger)
const gchar * | fl_mouse_cursor_handler_get_cursor_name (FlMouseCursorHandler *self)

## Variables
static constexpr char | kFallbackCursor [] = "default"
static guint | fl_mouse_cursor_handler_signals [LAST_SIGNAL]
static FlMouseCursorChannelVTable | mouse_cursor_vtable

## Enumeration Type Documentation

## ◆ anonymous enum

anonymous enum

Enumerator
SIGNAL_CURSOR_CHANGED |
LAST_SIGNAL |

Definition at line 24 of file fl_mouse_cursor_handler.cc.

24 { SIGNAL_CURSOR_CHANGED, LAST_SIGNAL };
LAST_SIGNAL
@ LAST_SIGNAL
Definition: fl_mouse_cursor_handler.cc:24
SIGNAL_CURSOR_CHANGED
@ SIGNAL_CURSOR_CHANGED
Definition: fl_mouse_cursor_handler.cc:24

## Function Documentation

## ◆ activate_system_cursor()

static void activate_system_cursor | ( | const gchar * | kind,
|  | gpointer | user_data
| ) |  |
| static

Definition at line 86 of file fl_mouse_cursor_handler.cc.

86 {
87 FlMouseCursorHandler* self = FL_MOUSE_CURSOR_HANDLER(user_data);
88
89 if (self->system_cursor_table == nullptr) {
90 self->system_cursor_table = g_hash_table_new(g_str_hash, g_str_equal);
91 populate_system_cursor_table(self->system_cursor_table);
92 }
93
94 const gchar* cursor_name = reinterpret_cast<const gchar*>(
95 g_hash_table_lookup(self->system_cursor_table, kind));
96 if (cursor_name == nullptr) {
97 cursor_name = kFallbackCursor;
98 }
99
100 g_free(self->cursor_name);
101 self->cursor_name = g_strdup(cursor_name);
102
103 g_signal_emit(self, fl_mouse_cursor_handler_signals[SIGNAL_CURSOR_CHANGED],
104 0);
105 }
g_signal_emit
g_signal_emit(self, fl_application_signals[SIGNAL_CREATE_WINDOW], 0, view, &window)
self
g_cond_signal & self
Definition: fl_compositor_software.cc:67
user_data
G_BEGIN_DECLS G_MODULE_EXPORT FlValue gpointer user_data
Definition: fl_event_channel.h:90
populate_system_cursor_table
static void populate_system_cursor_table(GHashTable *table)
Definition: fl_mouse_cursor_handler.cc:45
kFallbackCursor
static constexpr char kFallbackCursor[]
Definition: fl_mouse_cursor_handler.cc:11
fl_mouse_cursor_handler_signals
static guint fl_mouse_cursor_handler_signals[LAST_SIGNAL]
Definition: fl_mouse_cursor_handler.cc:26

References fl_mouse_cursor_handler_signals, g_signal_emit(), kFallbackCursor, populate_system_cursor_table(), self, SIGNAL_CURSOR_CHANGED, and user_data.

## ◆ define_system_cursor()

static bool define_system_cursor | ( | GHashTable * | table,
|  | const gchar * | key,
|  | const gchar * | value
| ) |  |
| static

Definition at line 33 of file fl_mouse_cursor_handler.cc.

35 {
36 return g_hash_table_insert(
37 table, reinterpret_cast<gpointer>(const_cast<gchar*>(key)),
38 reinterpret_cast<gpointer>(const_cast<gchar*>(value)));
39 }
value
uint8_t value
Definition: fl_standard_message_codec.cc:36

References value.

Referenced by populate_system_cursor_table().

## ◆ fl_mouse_cursor_handler_class_init()

static void fl_mouse_cursor_handler_class_init | ( | FlMouseCursorHandlerClass * | klass | ) |
| static

Definition at line 117 of file fl_mouse_cursor_handler.cc.

118 {
119 G_OBJECT_CLASS(klass)->dispose = fl_mouse_cursor_handler_dispose;
120
121 fl_mouse_cursor_handler_signals[SIGNAL_CURSOR_CHANGED] =
122 g_signal_new("cursor-changed", fl_mouse_cursor_handler_get_type(),
123 G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 0);
124 }
fl_mouse_cursor_handler_dispose
static void fl_mouse_cursor_handler_dispose(GObject *object)
Definition: fl_mouse_cursor_handler.cc:107

References fl_mouse_cursor_handler_dispose(), fl_mouse_cursor_handler_signals, and SIGNAL_CURSOR_CHANGED.

## ◆ fl_mouse_cursor_handler_dispose()

static void fl_mouse_cursor_handler_dispose | ( | GObject * | object | ) |
| static

Definition at line 107 of file fl_mouse_cursor_handler.cc.

107 {
108 FlMouseCursorHandler* self = FL_MOUSE_CURSOR_HANDLER(object);
109
110 g_clear_object(&self->channel);
111 g_clear_pointer(&self->system_cursor_table, g_hash_table_unref);
112 g_clear_pointer(&self->cursor_name, g_free);
113
114 G_OBJECT_CLASS(fl_mouse_cursor_handler_parent_class)->dispose(object);
115 }

References self.

Referenced by fl_mouse_cursor_handler_class_init().

## ◆ fl_mouse_cursor_handler_get_cursor_name()

const gchar* fl_mouse_cursor_handler_get_cursor_name | ( | FlMouseCursorHandler * | handler | ) |

fl_mouse_cursor_handler_get_cursor_name: @handler: an #FlMouseCursorHandler.

Get the name of the current mouse cursor.

Returns: a mouse cursor name.

Definition at line 147 of file fl_mouse_cursor_handler.cc.

148 {
149 g_return_val_if_fail(FL_IS_MOUSE_CURSOR_HANDLER(self), nullptr);
150 return self->cursor_name;
151 }

Referenced by cursor_changed_cb().

## ◆ fl_mouse_cursor_handler_init()

static void fl_mouse_cursor_handler_init | ( | FlMouseCursorHandler * | self | ) |
| static

Definition at line 126 of file fl_mouse_cursor_handler.cc.

126 {
127 self->cursor_name = g_strdup("");
128 }

## ◆ fl_mouse_cursor_handler_new()

FlMouseCursorHandler* fl_mouse_cursor_handler_new | ( | FlBinaryMessenger * | messenger | ) |

FlMouseCursorHandler:

#FlMouseCursorHandler is a mouse_cursor channel that implements the shell side of SystemChannels.mouseCursor from the Flutter services library. fl_mouse_cursor_handler_new: @messenger: an #FlBinaryMessenger.

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

Returns: a new #FlMouseCursorHandler.

Definition at line 134 of file fl_mouse_cursor_handler.cc.

135 {
136 g_return_val_if_fail(FL_IS_BINARY_MESSENGER(messenger), nullptr);
137
138 FlMouseCursorHandler* self = FL_MOUSE_CURSOR_HANDLER(
139 g_object_new(fl_mouse_cursor_handler_get_type(), nullptr));
140
141 self->channel =
142 fl_mouse_cursor_channel_new(messenger, &mouse_cursor_vtable, self);
143
144 return self;
145 }
fl_mouse_cursor_channel_new
FlMouseCursorChannel * fl_mouse_cursor_channel_new(FlBinaryMessenger *messenger, FlMouseCursorChannelVTable *vtable, gpointer user_data)
Definition: fl_mouse_cursor_channel.cc:85
mouse_cursor_vtable
static FlMouseCursorChannelVTable mouse_cursor_vtable
Definition: fl_mouse_cursor_handler.cc:130

References fl_mouse_cursor_channel_new(), and mouse_cursor_vtable.

Referenced by fl_engine_new_full().

## ◆ populate_system_cursor_table()

static void populate_system_cursor_table | ( | GHashTable * | table | ) |
| static

Definition at line 45 of file fl_mouse_cursor_handler.cc.

45 {
46 // The following mapping must be kept in sync with Flutter framework's
47 // mouse_cursor.dart.
48 define_system_cursor(table, "alias", "alias");
49 define_system_cursor(table, "allScroll", "all-scroll");
50 define_system_cursor(table, "basic", "default");
51 define_system_cursor(table, "cell", "cell");
52 define_system_cursor(table, "click", "pointer");
53 define_system_cursor(table, "contextMenu", "context-menu");
54 define_system_cursor(table, "copy", "copy");
55 define_system_cursor(table, "forbidden", "not-allowed");
56 define_system_cursor(table, "grab", "grab");
57 define_system_cursor(table, "grabbing", "grabbing");
58 define_system_cursor(table, "help", "help");
59 define_system_cursor(table, "move", "move");
60 define_system_cursor(table, "none", "none");
61 define_system_cursor(table, "noDrop", "no-drop");
62 define_system_cursor(table, "precise", "crosshair");
63 define_system_cursor(table, "progress", "progress");
64 define_system_cursor(table, "text", "text");
65 define_system_cursor(table, "resizeColumn", "col-resize");
66 define_system_cursor(table, "resizeDown", "s-resize");
67 define_system_cursor(table, "resizeDownLeft", "sw-resize");
68 define_system_cursor(table, "resizeDownRight", "se-resize");
69 define_system_cursor(table, "resizeLeft", "w-resize");
70 define_system_cursor(table, "resizeLeftRight", "ew-resize");
71 define_system_cursor(table, "resizeRight", "e-resize");
72 define_system_cursor(table, "resizeRow", "row-resize");
73 define_system_cursor(table, "resizeUp", "n-resize");
74 define_system_cursor(table, "resizeUpDown", "ns-resize");
75 define_system_cursor(table, "resizeUpLeft", "nw-resize");
76 define_system_cursor(table, "resizeUpRight", "ne-resize");
77 define_system_cursor(table, "resizeUpLeftDownRight", "nwse-resize");
78 define_system_cursor(table, "resizeUpRightDownLeft", "nesw-resize");
79 define_system_cursor(table, "verticalText", "vertical-text");
80 define_system_cursor(table, "wait", "wait");
81 define_system_cursor(table, "zoomIn", "zoom-in");
82 define_system_cursor(table, "zoomOut", "zoom-out");
83 }
define_system_cursor
static bool define_system_cursor(GHashTable *table, const gchar *key, const gchar *value)
Definition: fl_mouse_cursor_handler.cc:33

References define_system_cursor().

Referenced by activate_system_cursor().

## Variable Documentation

## ◆ fl_mouse_cursor_handler_signals

guint fl_mouse_cursor_handler_signals[LAST_SIGNAL]
| static

Definition at line 26 of file fl_mouse_cursor_handler.cc.

Referenced by activate_system_cursor(), and fl_mouse_cursor_handler_class_init().

## ◆ kFallbackCursor

constexpr char kFallbackCursor[] = "default"
| static constexpr

Definition at line 11 of file fl_mouse_cursor_handler.cc.

Referenced by activate_system_cursor().

## ◆ mouse_cursor_vtable

FlMouseCursorChannelVTable mouse_cursor_vtable
| static

Initial value:
= {
.activate_system_cursor = activate_system_cursor,
}
activate_system_cursor
static void activate_system_cursor(const gchar *kind, gpointer user_data)
Definition: fl_mouse_cursor_handler.cc:86

Definition at line 130 of file fl_mouse_cursor_handler.cc.

Referenced by fl_mouse_cursor_handler_new().