Remove fl_keyboard_view_delegate_subscribe_to_layout_change and just access the object directly via a method (flutter/engine#55817)
A step on the way to get FlKeyboardHandler out of FlView and into FlEngine.
This commit is contained in:
@@ -429,8 +429,6 @@ static void fl_keyboard_handler_dispose(GObject* object) {
|
||||
FlKeyboardHandler* self = FL_KEYBOARD_HANDLER(object);
|
||||
|
||||
if (self->view_delegate != nullptr) {
|
||||
fl_keyboard_view_delegate_subscribe_to_layout_change(self->view_delegate,
|
||||
nullptr);
|
||||
g_object_remove_weak_pointer(
|
||||
G_OBJECT(self->view_delegate),
|
||||
reinterpret_cast<gpointer*>(&(self->view_delegate)));
|
||||
@@ -505,12 +503,6 @@ FlKeyboardHandler* fl_keyboard_handler_new(
|
||||
FL_KEY_RESPONDER(fl_key_channel_responder_new(
|
||||
fl_keyboard_view_delegate_get_messenger(view_delegate))));
|
||||
|
||||
fl_keyboard_view_delegate_subscribe_to_layout_change(
|
||||
self->view_delegate, [self]() {
|
||||
g_clear_object(&self->derived_layout);
|
||||
self->derived_layout = fl_keyboard_layout_new();
|
||||
});
|
||||
|
||||
// Setup the flutter/keyboard channel.
|
||||
g_autoptr(FlStandardMethodCodec) codec = fl_standard_method_codec_new();
|
||||
self->channel =
|
||||
@@ -579,3 +571,9 @@ GHashTable* fl_keyboard_handler_get_pressed_state(FlKeyboardHandler* self) {
|
||||
FL_KEY_EMBEDDER_RESPONDER(g_ptr_array_index(self->responder_list, 0));
|
||||
return fl_key_embedder_responder_get_pressed_state(responder);
|
||||
}
|
||||
|
||||
void fl_keyboard_handler_notify_layout_changed(FlKeyboardHandler* self) {
|
||||
g_return_if_fail(FL_IS_KEYBOARD_HANDLER(self));
|
||||
g_clear_object(&self->derived_layout);
|
||||
self->derived_layout = fl_keyboard_layout_new();
|
||||
}
|
||||
|
||||
@@ -93,6 +93,14 @@ void fl_keyboard_handler_sync_modifier_if_needed(FlKeyboardHandler* handler,
|
||||
*/
|
||||
GHashTable* fl_keyboard_handler_get_pressed_state(FlKeyboardHandler* handler);
|
||||
|
||||
/**
|
||||
* fl_keyboard_handler_notify_layout_changed:
|
||||
* @handler: the #FlKeyboardHandler self.
|
||||
*
|
||||
* Notify the handler the keyboard layout has changed.
|
||||
*/
|
||||
void fl_keyboard_handler_notify_layout_changed(FlKeyboardHandler* handler);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif // FLUTTER_SHELL_PLATFORM_LINUX_FL_KEYBOARD_HANDLER_H_
|
||||
|
||||
@@ -307,7 +307,6 @@ struct FlMockViewDelegatePrivate {
|
||||
EmbedderCallHandler embedder_handler;
|
||||
bool text_filter_result;
|
||||
RedispatchHandler redispatch_handler;
|
||||
KeyboardLayoutNotifier layout_notifier;
|
||||
const MockLayoutData* layout_data;
|
||||
};
|
||||
|
||||
@@ -383,13 +382,6 @@ static void fl_mock_view_keyboard_redispatch_event(
|
||||
}
|
||||
}
|
||||
|
||||
static void fl_mock_view_keyboard_subscribe_to_layout_change(
|
||||
FlKeyboardViewDelegate* delegate,
|
||||
KeyboardLayoutNotifier notifier) {
|
||||
FlMockViewDelegatePrivate* priv = FL_MOCK_VIEW_DELEGATE_GET_PRIVATE(delegate);
|
||||
priv->layout_notifier = std::move(notifier);
|
||||
}
|
||||
|
||||
static guint fl_mock_view_keyboard_lookup_key(FlKeyboardViewDelegate* delegate,
|
||||
const GdkKeymapKey* key) {
|
||||
FlMockViewDelegatePrivate* priv = FL_MOCK_VIEW_DELEGATE_GET_PRIVATE(delegate);
|
||||
@@ -417,8 +409,6 @@ static void fl_mock_view_keyboard_delegate_iface_init(
|
||||
iface->text_filter_key_press = fl_mock_view_keyboard_text_filter_key_press;
|
||||
iface->get_messenger = fl_mock_view_keyboard_get_messenger;
|
||||
iface->redispatch_event = fl_mock_view_keyboard_redispatch_event;
|
||||
iface->subscribe_to_layout_change =
|
||||
fl_mock_view_keyboard_subscribe_to_layout_change;
|
||||
iface->lookup_key = fl_mock_view_keyboard_lookup_key;
|
||||
iface->get_keyboard_state = fl_mock_view_keyboard_get_keyboard_state;
|
||||
}
|
||||
@@ -458,9 +448,6 @@ static void fl_mock_view_set_layout(FlMockViewDelegate* self,
|
||||
const MockLayoutData* layout) {
|
||||
FlMockViewDelegatePrivate* priv = FL_MOCK_VIEW_DELEGATE_GET_PRIVATE(self);
|
||||
priv->layout_data = layout;
|
||||
if (priv->layout_notifier != nullptr) {
|
||||
priv->layout_notifier();
|
||||
}
|
||||
}
|
||||
|
||||
/***** End FlMockViewDelegate *****/
|
||||
@@ -600,11 +587,14 @@ class KeyboardTester {
|
||||
|
||||
void setLayout(const MockLayoutData& layout) {
|
||||
fl_mock_view_set_layout(view_, &layout);
|
||||
if (handler_ != nullptr) {
|
||||
fl_keyboard_handler_notify_layout_changed(handler_);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
FlMockViewDelegate* view_;
|
||||
FlKeyboardHandler* handler_;
|
||||
FlKeyboardHandler* handler_ = nullptr;
|
||||
GPtrArray* redispatched_events_ = nullptr;
|
||||
bool during_redispatch_ = false;
|
||||
|
||||
|
||||
@@ -48,15 +48,6 @@ void fl_keyboard_view_delegate_redispatch_event(FlKeyboardViewDelegate* self,
|
||||
event);
|
||||
}
|
||||
|
||||
void fl_keyboard_view_delegate_subscribe_to_layout_change(
|
||||
FlKeyboardViewDelegate* self,
|
||||
KeyboardLayoutNotifier notifier) {
|
||||
g_return_if_fail(FL_IS_KEYBOARD_VIEW_DELEGATE(self));
|
||||
|
||||
return FL_KEYBOARD_VIEW_DELEGATE_GET_IFACE(self)->subscribe_to_layout_change(
|
||||
self, std::move(notifier));
|
||||
}
|
||||
|
||||
guint fl_keyboard_view_delegate_lookup_key(FlKeyboardViewDelegate* self,
|
||||
const GdkKeymapKey* key) {
|
||||
g_return_val_if_fail(FL_IS_KEYBOARD_VIEW_DELEGATE(self), 0);
|
||||
|
||||
@@ -14,8 +14,6 @@
|
||||
#include "flutter/shell/platform/linux/fl_key_event.h"
|
||||
#include "flutter/shell/platform/linux/public/flutter_linux/fl_binary_messenger.h"
|
||||
|
||||
typedef std::function<void()> KeyboardLayoutNotifier;
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
G_DECLARE_INTERFACE(FlKeyboardViewDelegate,
|
||||
@@ -48,9 +46,6 @@ struct _FlKeyboardViewDelegateInterface {
|
||||
|
||||
void (*redispatch_event)(FlKeyboardViewDelegate* delegate, FlKeyEvent* event);
|
||||
|
||||
void (*subscribe_to_layout_change)(FlKeyboardViewDelegate* delegate,
|
||||
KeyboardLayoutNotifier notifier);
|
||||
|
||||
guint (*lookup_key)(FlKeyboardViewDelegate* view_delegate,
|
||||
const GdkKeymapKey* key);
|
||||
|
||||
@@ -107,10 +102,6 @@ void fl_keyboard_view_delegate_redispatch_event(
|
||||
FlKeyboardViewDelegate* delegate,
|
||||
FlKeyEvent* event);
|
||||
|
||||
void fl_keyboard_view_delegate_subscribe_to_layout_change(
|
||||
FlKeyboardViewDelegate* delegate,
|
||||
KeyboardLayoutNotifier notifier);
|
||||
|
||||
guint fl_keyboard_view_delegate_lookup_key(FlKeyboardViewDelegate* delegate,
|
||||
const GdkKeymapKey* key);
|
||||
|
||||
|
||||
@@ -76,7 +76,6 @@ struct _FlView {
|
||||
gboolean pointer_inside;
|
||||
|
||||
/* FlKeyboardViewDelegate related properties */
|
||||
KeyboardLayoutNotifier keyboard_layout_notifier;
|
||||
GdkKeymap* keymap;
|
||||
gulong keymap_keys_changed_cb_id; // Signal connection ID for
|
||||
// keymap-keys-changed
|
||||
@@ -394,12 +393,6 @@ static void fl_view_keyboard_delegate_iface_init(
|
||||
gdk_event_put(fl_key_event_get_origin(event));
|
||||
};
|
||||
|
||||
iface->subscribe_to_layout_change = [](FlKeyboardViewDelegate* view_delegate,
|
||||
KeyboardLayoutNotifier notifier) {
|
||||
FlView* self = FL_VIEW(view_delegate);
|
||||
self->keyboard_layout_notifier = std::move(notifier);
|
||||
};
|
||||
|
||||
iface->lookup_key = [](FlKeyboardViewDelegate* view_delegate,
|
||||
const GdkKeymapKey* key) -> guint {
|
||||
FlView* self = FL_VIEW(view_delegate);
|
||||
@@ -566,11 +559,7 @@ static gboolean leave_notify_event_cb(FlView* self,
|
||||
}
|
||||
|
||||
static void keymap_keys_changed_cb(FlView* self) {
|
||||
if (self->keyboard_layout_notifier == nullptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
self->keyboard_layout_notifier();
|
||||
fl_keyboard_handler_notify_layout_changed(self->keyboard_handler);
|
||||
}
|
||||
|
||||
static void gesture_rotation_begin_cb(FlView* self) {
|
||||
|
||||
Reference in New Issue
Block a user