Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions shell/platform/linux/.clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@ InheritParentConfig: true
# EnumCastOutOfRange warns about some common usages of GTK macros
Checks: >-
-clang-analyzer-optin.core.EnumCastOutOfRange

CheckOptions:
- key: readability-identifier-naming.EnumConstantCase
value: "UPPER_CASE"
- key: readability-identifier-naming.EnumConstantPrefix
value: ""
10 changes: 5 additions & 5 deletions shell/platform/linux/fl_accessible_node.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ struct FlAccessibleNodePrivate {
FlutterSemanticsFlag flags;
};

enum { kProp0, kPropEngine, kPropId, kPropLast };
enum { PROP_0, PROP_ENGINE, PROP_ID, PROP_LAST };

#define FL_ACCESSIBLE_NODE_GET_PRIVATE(node) \
((FlAccessibleNodePrivate*)fl_accessible_node_get_instance_private( \
Expand Down Expand Up @@ -145,13 +145,13 @@ static void fl_accessible_node_set_property(GObject* object,
GParamSpec* pspec) {
FlAccessibleNodePrivate* priv = FL_ACCESSIBLE_NODE_GET_PRIVATE(object);
switch (prop_id) {
case kPropEngine:
case PROP_ENGINE:
g_assert(priv->engine == nullptr);
priv->engine = FL_ENGINE(g_value_get_object(value));
g_object_add_weak_pointer(object,
reinterpret_cast<gpointer*>(&priv->engine));
break;
case kPropId:
case PROP_ID:
priv->id = g_value_get_int(value);
break;
default:
Expand Down Expand Up @@ -448,13 +448,13 @@ static void fl_accessible_node_class_init(FlAccessibleNodeClass* klass) {
fl_accessible_node_perform_action_impl;

g_object_class_install_property(
G_OBJECT_CLASS(klass), kPropEngine,
G_OBJECT_CLASS(klass), PROP_ENGINE,
g_param_spec_object(
"engine", "engine", "Flutter engine", fl_engine_get_type(),
static_cast<GParamFlags>(G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS)));
g_object_class_install_property(
G_OBJECT_CLASS(klass), kPropId,
G_OBJECT_CLASS(klass), PROP_ID,
g_param_spec_int(
"id", "id", "Accessibility node ID", 0, G_MAXINT, 0,
static_cast<GParamFlags>(G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
Expand Down
12 changes: 6 additions & 6 deletions shell/platform/linux/fl_application.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ struct FlApplicationPrivate {
((FlApplicationPrivate*)fl_application_get_instance_private( \
FL_APPLICATION(app)))

enum { kSignalRegisterPlugins, kSignalCreateWindow, kSignalLastSignal };
enum { SIGNAL_REGISTER_PLUGINS, SIGNAL_CREATE_WINDOW, LAST_SIGNAL };

static guint fl_application_signals[kSignalLastSignal];
static guint fl_application_signals[LAST_SIGNAL];

G_DEFINE_TYPE_WITH_CODE(FlApplication,
fl_application,
Expand Down Expand Up @@ -95,14 +95,14 @@ static void fl_application_activate(GApplication* application) {
gtk_widget_show(GTK_WIDGET(view));

GtkWindow* window;
g_signal_emit(self, fl_application_signals[kSignalCreateWindow], 0, view,
g_signal_emit(self, fl_application_signals[SIGNAL_CREATE_WINDOW], 0, view,
&window);

// Make the resources for the view so rendering can start.
// We'll show the view when we have the first frame.
gtk_widget_realize(GTK_WIDGET(view));

g_signal_emit(self, fl_application_signals[kSignalRegisterPlugins], 0,
g_signal_emit(self, fl_application_signals[SIGNAL_REGISTER_PLUGINS], 0,
FL_PLUGIN_REGISTRY(view));
}

Expand Down Expand Up @@ -150,11 +150,11 @@ static void fl_application_class_init(FlApplicationClass* klass) {
klass->register_plugins = fl_application_register_plugins;
klass->create_window = fl_application_create_window;

fl_application_signals[kSignalRegisterPlugins] = g_signal_new(
fl_application_signals[SIGNAL_REGISTER_PLUGINS] = g_signal_new(
"register-plugins", fl_application_get_type(), G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET(FlApplicationClass, register_plugins), nullptr, nullptr,
nullptr, G_TYPE_NONE, 1, fl_plugin_registry_get_type());
fl_application_signals[kSignalCreateWindow] = g_signal_new(
fl_application_signals[SIGNAL_CREATE_WINDOW] = g_signal_new(
"create-window", fl_application_get_type(), G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET(FlApplicationClass, create_window),
g_signal_accumulator_first_wins, nullptr, nullptr, GTK_TYPE_WINDOW, 1,
Expand Down
14 changes: 7 additions & 7 deletions shell/platform/linux/fl_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ G_DEFINE_QUARK(fl_engine_error_quark, fl_engine_error)
static void fl_engine_plugin_registry_iface_init(
FlPluginRegistryInterface* iface);

enum { kSignalOnPreEngineRestart, kSignalLastSignal };
enum { SIGNAL_ON_PRE_ENGINE_RESTART, LAST_SIGNAL };

static guint fl_engine_signals[kSignalLastSignal];
static guint fl_engine_signals[LAST_SIGNAL];

G_DEFINE_TYPE_WITH_CODE(
FlEngine,
Expand All @@ -103,7 +103,7 @@ G_DEFINE_TYPE_WITH_CODE(
G_IMPLEMENT_INTERFACE(fl_plugin_registry_get_type(),
fl_engine_plugin_registry_iface_init))

enum { kProp0, kPropBinaryMessenger, kPropLast };
enum { PROP_0, PROP_BINARY_MESSENGER, PROP_LAST };

// Parse a locale into its components.
static void parse_locale(const gchar* locale,
Expand Down Expand Up @@ -386,7 +386,7 @@ static void fl_engine_update_semantics_cb(const FlutterSemanticsUpdate2* update,
static void fl_engine_on_pre_engine_restart_cb(void* user_data) {
FlEngine* self = FL_ENGINE(user_data);

g_signal_emit(self, fl_engine_signals[kSignalOnPreEngineRestart], 0);
g_signal_emit(self, fl_engine_signals[SIGNAL_ON_PRE_ENGINE_RESTART], 0);
}

// Called when a response to a sent platform message is received from the
Expand Down Expand Up @@ -420,7 +420,7 @@ static void fl_engine_set_property(GObject* object,
GParamSpec* pspec) {
FlEngine* self = FL_ENGINE(object);
switch (prop_id) {
case kPropBinaryMessenger:
case PROP_BINARY_MESSENGER:
g_set_object(&self->binary_messenger,
FL_BINARY_MESSENGER(g_value_get_object(value)));
break;
Expand Down Expand Up @@ -477,14 +477,14 @@ static void fl_engine_class_init(FlEngineClass* klass) {
G_OBJECT_CLASS(klass)->set_property = fl_engine_set_property;

g_object_class_install_property(
G_OBJECT_CLASS(klass), kPropBinaryMessenger,
G_OBJECT_CLASS(klass), PROP_BINARY_MESSENGER,
g_param_spec_object(
"binary-messenger", "messenger", "Binary messenger",
fl_binary_messenger_get_type(),
static_cast<GParamFlags>(G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
G_PARAM_STATIC_STRINGS)));

fl_engine_signals[kSignalOnPreEngineRestart] = g_signal_new(
fl_engine_signals[SIGNAL_ON_PRE_ENGINE_RESTART] = g_signal_new(
"on-pre-engine-restart", fl_engine_get_type(), G_SIGNAL_RUN_LAST, 0,
nullptr, nullptr, nullptr, G_TYPE_NONE, 0);
}
Expand Down
2 changes: 0 additions & 2 deletions shell/platform/linux/fl_engine_private.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ G_BEGIN_DECLS
*/

typedef enum {
// NOLINTBEGIN(readability-identifier-naming)
FL_ENGINE_ERROR_FAILED,
// NOLINTEND(readability-identifier-naming)
} FlEngineError;

GQuark fl_engine_error_quark(void) G_GNUC_CONST;
Expand Down
6 changes: 3 additions & 3 deletions shell/platform/linux/fl_gnome_settings.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ struct _FlGnomeSettings {
GSettings* interface_settings;
};

enum { kProp0, kPropInterfaceSettings, kPropLast };
enum { PROP_0, PROP_INTERFACE_SETTINGS, PROP_LAST };

static void fl_gnome_settings_iface_init(FlSettingsInterface* iface);

Expand Down Expand Up @@ -106,7 +106,7 @@ static void fl_gnome_settings_set_property(GObject* object,
GParamSpec* pspec) {
FlGnomeSettings* self = FL_GNOME_SETTINGS(object);
switch (prop_id) {
case kPropInterfaceSettings:
case PROP_INTERFACE_SETTINGS:
fl_gnome_settings_set_interface_settings(
self, G_SETTINGS(g_value_get_object(value)));
break;
Expand All @@ -130,7 +130,7 @@ static void fl_gnome_settings_class_init(FlGnomeSettingsClass* klass) {
object_class->set_property = fl_gnome_settings_set_property;

g_object_class_install_property(
object_class, kPropInterfaceSettings,
object_class, PROP_INTERFACE_SETTINGS,
g_param_spec_object(
kInterfaceSettings, kInterfaceSettings, kDesktopInterfaceSchema,
g_settings_get_type(),
Expand Down
19 changes: 10 additions & 9 deletions shell/platform/linux/fl_key_embedder_responder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ static FlKeyEmbedderUserData* fl_key_embedder_user_data_new(
namespace {

typedef enum {
kStateLogicUndecided,
kStateLogicNormal,
kStateLogicReversed,
STATE_LOGIC_INFERRENCE_UNDECIDED,
STATE_LOGIC_INFERRENCE_NORMAL,
STATE_LOGIC_INFERRENCE_REVERSED,
} StateLogicInferrence;

}
Expand Down Expand Up @@ -246,7 +246,7 @@ FlKeyEmbedderResponder* fl_key_embedder_responder_new(
self->pressing_records = g_hash_table_new(g_direct_hash, g_direct_equal);
self->mapping_records = g_hash_table_new(g_direct_hash, g_direct_equal);
self->lock_records = 0;
self->caps_lock_state_logic_inferrence = kStateLogicUndecided;
self->caps_lock_state_logic_inferrence = STATE_LOGIC_INFERRENCE_UNDECIDED;

self->modifier_bit_to_checked_keys =
g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, g_free);
Expand Down Expand Up @@ -557,7 +557,8 @@ static void update_caps_lock_state_logic_inferrence(
bool is_down_event,
bool enabled_by_state,
int stage_by_record) {
if (self->caps_lock_state_logic_inferrence != kStateLogicUndecided) {
if (self->caps_lock_state_logic_inferrence !=
STATE_LOGIC_INFERRENCE_UNDECIDED) {
return;
}
if (!is_down_event) {
Expand All @@ -567,9 +568,9 @@ static void update_caps_lock_state_logic_inferrence(
stage_by_record, is_down_event, enabled_by_state, false);
if ((stage_by_event == 0 && stage_by_record == 2) ||
(stage_by_event == 2 && stage_by_record == 0)) {
self->caps_lock_state_logic_inferrence = kStateLogicReversed;
self->caps_lock_state_logic_inferrence = STATE_LOGIC_INFERRENCE_REVERSED;
} else {
self->caps_lock_state_logic_inferrence = kStateLogicNormal;
self->caps_lock_state_logic_inferrence = STATE_LOGIC_INFERRENCE_NORMAL;
}
}

Expand Down Expand Up @@ -639,11 +640,11 @@ static void synchronize_lock_states_loop_body(gpointer key,
update_caps_lock_state_logic_inferrence(self, context->is_down,
enabled_by_state, stage_by_record);
g_return_if_fail(self->caps_lock_state_logic_inferrence !=
kStateLogicUndecided);
STATE_LOGIC_INFERRENCE_UNDECIDED);
}
const bool reverse_state_logic =
checked_key->is_caps_lock &&
self->caps_lock_state_logic_inferrence == kStateLogicReversed;
self->caps_lock_state_logic_inferrence == STATE_LOGIC_INFERRENCE_REVERSED;
const int stage_by_event =
this_key_is_event_key
? find_stage_by_self_event(stage_by_record, context->is_down,
Expand Down
22 changes: 11 additions & 11 deletions shell/platform/linux/fl_keyboard_manager_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
// stacktrace wouldn't print where the function is called in the unit tests.

#define EXPECT_KEY_EVENT(RECORD, TYPE, PHYSICAL, LOGICAL, CHAR, SYNTHESIZED) \
EXPECT_EQ((RECORD).type, CallRecord::kKeyCallEmbedder); \
EXPECT_EQ((RECORD).type, CallRecord::KEY_CALL_EMBEDDER); \
EXPECT_EQ((RECORD).event->type, (TYPE)); \
EXPECT_EQ((RECORD).event->physical, (PHYSICAL)); \
EXPECT_EQ((RECORD).event->logical, (LOGICAL)); \
EXPECT_STREQ((RECORD).event->character, (CHAR)); \
EXPECT_EQ((RECORD).event->synthesized, (SYNTHESIZED));

#define VERIFY_DOWN(OUT_LOGICAL, OUT_CHAR) \
EXPECT_EQ(call_records[0].type, CallRecord::kKeyCallEmbedder); \
EXPECT_EQ(call_records[0].type, CallRecord::KEY_CALL_EMBEDDER); \
EXPECT_EQ(call_records[0].event->type, kFlutterKeyEventTypeDown); \
EXPECT_EQ(call_records[0].event->logical, (OUT_LOGICAL)); \
EXPECT_STREQ(call_records[0].event->character, (OUT_CHAR)); \
Expand Down Expand Up @@ -78,8 +78,8 @@ typedef std::function<void(FlKeyEvent*)> RedispatchHandler;
// An instance of `CallRecord` might not have all the fields filled.
typedef struct {
enum {
kKeyCallEmbedder,
kKeyCallChannel,
KEY_CALL_EMBEDDER,
KEY_CALL_CHANNEL,
} type;

AsyncKeyCallback callback;
Expand Down Expand Up @@ -436,7 +436,7 @@ class KeyboardTester {
char* new_event_character = cloneString(event->character);
new_event->character = new_event_character;
storage.push_back(CallRecord{
.type = CallRecord::kKeyCallEmbedder,
.type = CallRecord::KEY_CALL_EMBEDDER,
.callback = std::move(callback),
.event = std::move(new_event),
.event_character = std::unique_ptr<char[]>(new_event_character),
Expand All @@ -455,7 +455,7 @@ class KeyboardTester {
char* new_event_character = cloneString(event->character);
new_event->character = new_event_character;
storage.push_back(CallRecord{
.type = CallRecord::kKeyCallEmbedder,
.type = CallRecord::KEY_CALL_EMBEDDER,
.event = std::move(new_event),
.event_character = std::unique_ptr<char[]>(new_event_character),
});
Expand All @@ -476,7 +476,7 @@ class KeyboardTester {
messenger_, [&storage, this](AsyncKeyCallback callback) {
EXPECT_FALSE(during_redispatch_);
storage.push_back(CallRecord{
.type = CallRecord::kKeyCallChannel,
.type = CallRecord::KEY_CALL_CHANNEL,
.callback = std::move(callback),
});
});
Expand Down Expand Up @@ -703,8 +703,8 @@ TEST(FlKeyboardManagerTest, WithTwoAsyncDelegates) {
EXPECT_EQ(redispatched->len, 0u);
EXPECT_EQ(call_records.size(), 2u);

EXPECT_EQ(call_records[0].type, CallRecord::kKeyCallEmbedder);
EXPECT_EQ(call_records[1].type, CallRecord::kKeyCallChannel);
EXPECT_EQ(call_records[0].type, CallRecord::KEY_CALL_EMBEDDER);
EXPECT_EQ(call_records[1].type, CallRecord::KEY_CALL_CHANNEL);

call_records[0].callback(true);
call_records[1].callback(false);
Expand All @@ -723,8 +723,8 @@ TEST(FlKeyboardManagerTest, WithTwoAsyncDelegates) {
EXPECT_EQ(redispatched->len, 0u);
EXPECT_EQ(call_records.size(), 2u);

EXPECT_EQ(call_records[0].type, CallRecord::kKeyCallEmbedder);
EXPECT_EQ(call_records[1].type, CallRecord::kKeyCallChannel);
EXPECT_EQ(call_records[0].type, CallRecord::KEY_CALL_EMBEDDER);
EXPECT_EQ(call_records[1].type, CallRecord::KEY_CALL_CHANNEL);

call_records[0].callback(false);
call_records[1].callback(false);
Expand Down
9 changes: 5 additions & 4 deletions shell/platform/linux/fl_mouse_cursor_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ struct _FlMouseCursorHandler {
gchar* cursor_name;
};

enum { kSignalCursorChanged, kSignalLastSignal };
enum { SIGNAL_CURSOR_CHANGED, LAST_SIGNAL };

static guint fl_mouse_cursor_handler_signals[kSignalLastSignal];
static guint fl_mouse_cursor_handler_signals[LAST_SIGNAL];

G_DEFINE_TYPE(FlMouseCursorHandler, fl_mouse_cursor_handler, G_TYPE_OBJECT)

Expand Down Expand Up @@ -100,7 +100,8 @@ static void activate_system_cursor(const gchar* kind, gpointer user_data) {
g_free(self->cursor_name);
self->cursor_name = g_strdup(cursor_name);

g_signal_emit(self, fl_mouse_cursor_handler_signals[kSignalCursorChanged], 0);
g_signal_emit(self, fl_mouse_cursor_handler_signals[SIGNAL_CURSOR_CHANGED],
0);
}

static void fl_mouse_cursor_handler_dispose(GObject* object) {
Expand All @@ -117,7 +118,7 @@ static void fl_mouse_cursor_handler_class_init(
FlMouseCursorHandlerClass* klass) {
G_OBJECT_CLASS(klass)->dispose = fl_mouse_cursor_handler_dispose;

fl_mouse_cursor_handler_signals[kSignalCursorChanged] =
fl_mouse_cursor_handler_signals[SIGNAL_CURSOR_CHANGED] =
g_signal_new("cursor-changed", fl_mouse_cursor_handler_get_type(),
G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 0);
}
Expand Down
4 changes: 0 additions & 4 deletions shell/platform/linux/fl_platform_channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,13 @@
G_BEGIN_DECLS

typedef enum {
// NOLINTBEGIN(readability-identifier-naming)
FL_PLATFORM_CHANNEL_EXIT_TYPE_CANCELABLE,
FL_PLATFORM_CHANNEL_EXIT_TYPE_REQUIRED,
// NOLINTEND(readability-identifier-naming)
} FlPlatformChannelExitType;

typedef enum {
// NOLINTBEGIN(readability-identifier-naming)
FL_PLATFORM_CHANNEL_EXIT_RESPONSE_CANCEL,
FL_PLATFORM_CHANNEL_EXIT_RESPONSE_EXIT,
// NOLINTEND(readability-identifier-naming)
} FlPlatformChannelExitResponse;

G_DECLARE_FINAL_TYPE(FlPlatformChannel,
Expand Down
2 changes: 0 additions & 2 deletions shell/platform/linux/fl_renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ G_BEGIN_DECLS
*/

typedef enum {
// NOLINTBEGIN(readability-identifier-naming)
FL_RENDERER_ERROR_FAILED,
// NOLINTEND(readability-identifier-naming)
} FlRendererError;

GQuark fl_renderer_error_quark(void) G_GNUC_CONST;
Expand Down
Loading