Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
sxychenjing
engine
提交
ab23dc3a
E
engine
项目概览
sxychenjing
/
engine
与 Fork 源项目一致
从无法访问的项目Fork
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
engine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ab23dc3a
编写于
8月 03, 2020
作者:
R
Robert Ancell
提交者:
Robert Ancell
8月 05, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update code style to pass clang-tidy checks
上级
4d5b0c31
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
292 addition
and
150 deletion
+292
-150
shell/platform/linux/fl_basic_message_channel.cc
shell/platform/linux/fl_basic_message_channel.cc
+14
-7
shell/platform/linux/fl_binary_messenger.cc
shell/platform/linux/fl_binary_messenger.cc
+14
-7
shell/platform/linux/fl_engine.cc
shell/platform/linux/fl_engine.cc
+37
-19
shell/platform/linux/fl_json_method_codec.cc
shell/platform/linux/fl_json_method_codec.cc
+6
-3
shell/platform/linux/fl_method_channel.cc
shell/platform/linux/fl_method_channel.cc
+14
-7
shell/platform/linux/fl_method_codec.cc
shell/platform/linux/fl_method_codec.cc
+2
-1
shell/platform/linux/fl_renderer.cc
shell/platform/linux/fl_renderer.cc
+4
-2
shell/platform/linux/fl_standard_message_codec.cc
shell/platform/linux/fl_standard_message_codec.cc
+75
-38
shell/platform/linux/fl_standard_method_codec.cc
shell/platform/linux/fl_standard_method_codec.cc
+25
-12
shell/platform/linux/fl_text_input_plugin.cc
shell/platform/linux/fl_text_input_plugin.cc
+23
-14
shell/platform/linux/fl_value.cc
shell/platform/linux/fl_value.cc
+59
-29
shell/platform/linux/fl_view.cc
shell/platform/linux/fl_view.cc
+19
-11
未找到文件。
shell/platform/linux/fl_basic_message_channel.cc
浏览文件 @
ab23dc3a
...
...
@@ -117,8 +117,9 @@ static void channel_closed_cb(gpointer user_data) {
self
->
channel_closed
=
TRUE
;
// Disconnect handler.
if
(
self
->
message_handler_destroy_notify
!=
nullptr
)
if
(
self
->
message_handler_destroy_notify
!=
nullptr
)
{
self
->
message_handler_destroy_notify
(
self
->
message_handler_data
);
}
self
->
message_handler
=
nullptr
;
self
->
message_handler_data
=
nullptr
;
self
->
message_handler_destroy_notify
=
nullptr
;
...
...
@@ -136,8 +137,9 @@ static void fl_basic_message_channel_dispose(GObject* object) {
g_clear_pointer
(
&
self
->
name
,
g_free
);
g_clear_object
(
&
self
->
codec
);
if
(
self
->
message_handler_destroy_notify
!=
nullptr
)
if
(
self
->
message_handler_destroy_notify
!=
nullptr
)
{
self
->
message_handler_destroy_notify
(
self
->
message_handler_data
);
}
self
->
message_handler
=
nullptr
;
self
->
message_handler_data
=
nullptr
;
self
->
message_handler_destroy_notify
=
nullptr
;
...
...
@@ -187,13 +189,15 @@ G_MODULE_EXPORT void fl_basic_message_channel_set_message_handler(
g_warning
(
"Attempted to set message handler on a closed FlBasicMessageChannel"
);
}
if
(
destroy_notify
!=
nullptr
)
if
(
destroy_notify
!=
nullptr
)
{
destroy_notify
(
user_data
);
}
return
;
}
if
(
self
->
message_handler_destroy_notify
!=
nullptr
)
if
(
self
->
message_handler_destroy_notify
!=
nullptr
)
{
self
->
message_handler_destroy_notify
(
self
->
message_handler_data
);
}
self
->
message_handler
=
handler
;
self
->
message_handler_data
=
user_data
;
...
...
@@ -211,8 +215,9 @@ G_MODULE_EXPORT gboolean fl_basic_message_channel_respond(
g_autoptr
(
GBytes
)
data
=
fl_message_codec_encode_message
(
self
->
codec
,
message
,
error
);
if
(
data
==
nullptr
)
if
(
data
==
nullptr
)
{
return
FALSE
;
}
gboolean
result
=
fl_binary_messenger_send_response
(
self
->
messenger
,
response_handle
->
response_handle
,
data
,
error
);
...
...
@@ -237,8 +242,9 @@ G_MODULE_EXPORT void fl_basic_message_channel_send(FlBasicMessageChannel* self,
g_autoptr
(
GBytes
)
data
=
fl_message_codec_encode_message
(
self
->
codec
,
message
,
&
error
);
if
(
data
==
nullptr
)
{
if
(
task
!=
nullptr
)
if
(
task
!=
nullptr
)
{
g_task_return_error
(
task
,
error
);
}
return
;
}
...
...
@@ -260,8 +266,9 @@ G_MODULE_EXPORT FlValue* fl_basic_message_channel_send_finish(
g_autoptr
(
GBytes
)
message
=
fl_binary_messenger_send_on_channel_finish
(
self
->
messenger
,
r
,
error
);
if
(
message
==
nullptr
)
if
(
message
==
nullptr
)
{
return
nullptr
;
}
return
fl_message_codec_decode_message
(
self
->
codec
,
message
,
error
);
}
shell/platform/linux/fl_binary_messenger.cc
浏览文件 @
ab23dc3a
...
...
@@ -43,8 +43,9 @@ static void fl_binary_messenger_response_handle_dispose(GObject* object) {
FlBinaryMessengerResponseHandle
*
self
=
FL_BINARY_MESSENGER_RESPONSE_HANDLE
(
object
);
if
(
self
->
response_handle
!=
nullptr
&&
self
->
messenger
->
engine
!=
nullptr
)
if
(
self
->
response_handle
!=
nullptr
&&
self
->
messenger
->
engine
!=
nullptr
)
{
g_critical
(
"FlBinaryMessengerResponseHandle was not responded to"
);
}
g_clear_object
(
&
self
->
messenger
);
self
->
response_handle
=
nullptr
;
...
...
@@ -93,8 +94,9 @@ static PlatformMessageHandler* platform_message_handler_new(
static
void
platform_message_handler_free
(
gpointer
data
)
{
PlatformMessageHandler
*
self
=
static_cast
<
PlatformMessageHandler
*>
(
data
);
if
(
self
->
message_handler_destroy_notify
)
if
(
self
->
message_handler_destroy_notify
)
{
self
->
message_handler_destroy_notify
(
self
->
message_handler_data
);
}
g_free
(
self
);
}
...
...
@@ -116,8 +118,9 @@ static gboolean fl_binary_messenger_platform_message_cb(
PlatformMessageHandler
*
handler
=
static_cast
<
PlatformMessageHandler
*>
(
g_hash_table_lookup
(
self
->
platform_message_handlers
,
channel
));
if
(
handler
==
nullptr
)
if
(
handler
==
nullptr
)
{
return
FALSE
;
}
g_autoptr
(
FlBinaryMessengerResponseHandle
)
handle
=
fl_binary_messenger_response_handle_new
(
self
,
response_handle
);
...
...
@@ -180,8 +183,9 @@ G_MODULE_EXPORT void fl_binary_messenger_set_message_handler_on_channel(
"Attempted to set message handler on an FlBinaryMessenger without an "
"engine"
);
}
if
(
destroy_notify
!=
nullptr
)
if
(
destroy_notify
!=
nullptr
)
{
destroy_notify
(
user_data
);
}
return
;
}
...
...
@@ -204,8 +208,9 @@ G_MODULE_EXPORT gboolean fl_binary_messenger_send_response(
g_return_val_if_fail
(
response_handle
->
messenger
==
self
,
FALSE
);
g_return_val_if_fail
(
response_handle
->
response_handle
!=
nullptr
,
FALSE
);
if
(
self
->
engine
==
nullptr
)
if
(
self
->
engine
==
nullptr
)
{
return
TRUE
;
}
if
(
response_handle
->
response_handle
==
nullptr
)
{
g_set_error
(
...
...
@@ -239,8 +244,9 @@ G_MODULE_EXPORT void fl_binary_messenger_send_on_channel(
g_return_if_fail
(
FL_IS_BINARY_MESSENGER
(
self
));
g_return_if_fail
(
channel
!=
nullptr
);
if
(
self
->
engine
==
nullptr
)
if
(
self
->
engine
==
nullptr
)
{
return
;
}
fl_engine_send_platform_message
(
self
->
engine
,
channel
,
message
,
cancellable
,
...
...
@@ -259,8 +265,9 @@ G_MODULE_EXPORT GBytes* fl_binary_messenger_send_on_channel_finish(
g_autoptr
(
GTask
)
task
=
G_TASK
(
result
);
GAsyncResult
*
r
=
G_ASYNC_RESULT
(
g_task_propagate_pointer
(
task
,
nullptr
));
if
(
self
->
engine
==
nullptr
)
if
(
self
->
engine
==
nullptr
)
{
return
nullptr
;
}
return
fl_engine_send_platform_message_finish
(
self
->
engine
,
r
,
error
);
}
shell/platform/linux/fl_engine.cc
浏览文件 @
ab23dc3a
...
...
@@ -94,34 +94,42 @@ static void parse_locale(const gchar* locale,
// Passes locale information to the Flutter engine.
static
void
setup_locales
(
FlEngine
*
self
)
{
const
gchar
*
const
*
languages
=
g_get_language_names
();
g_autoptr
(
GPtrArray
)
locales
=
g_ptr_array_new_with_free_func
(
g_free
);
g_autoptr
(
GPtrArray
)
locales
_array
=
g_ptr_array_new_with_free_func
(
g_free
);
// Helper array to take ownership of the strings passed to Flutter.
g_autoptr
(
GPtrArray
)
locale_strings
=
g_ptr_array_new_with_free_func
(
g_free
);
for
(
int
i
=
0
;
languages
[
i
]
!=
nullptr
;
i
++
)
{
gchar
*
language
,
*
territory
,
*
codeset
,
*
modifier
;
parse_locale
(
languages
[
i
],
&
language
,
&
territory
,
&
codeset
,
&
modifier
);
if
(
language
!=
nullptr
)
if
(
language
!=
nullptr
)
{
g_ptr_array_add
(
locale_strings
,
language
);
if
(
territory
!=
nullptr
)
}
if
(
territory
!=
nullptr
)
{
g_ptr_array_add
(
locale_strings
,
territory
);
if
(
codeset
!=
nullptr
)
}
if
(
codeset
!=
nullptr
)
{
g_ptr_array_add
(
locale_strings
,
codeset
);
if
(
modifier
!=
nullptr
)
}
if
(
modifier
!=
nullptr
)
{
g_ptr_array_add
(
locale_strings
,
modifier
);
}
FlutterLocale
*
locale
=
static_cast
<
FlutterLocale
*>
(
g_malloc0
(
sizeof
(
FlutterLocale
)));
g_ptr_array_add
(
locales
,
locale
);
g_ptr_array_add
(
locales
_array
,
locale
);
locale
->
struct_size
=
sizeof
(
FlutterLocale
);
locale
->
language_code
=
language
;
locale
->
country_code
=
territory
;
locale
->
script_code
=
codeset
;
locale
->
variant_code
=
modifier
;
}
FlutterLocale
**
locales
=
reinterpret_cast
<
FlutterLocale
**>
(
locales_array
->
pdata
);
FlutterEngineResult
result
=
FlutterEngineUpdateLocales
(
self
->
engine
,
(
const
FlutterLocale
**
)
locales
->
pdata
,
locales
->
len
);
if
(
result
!=
kSuccess
)
self
->
engine
,
const_cast
<
const
FlutterLocale
**>
(
locales
),
locales_array
->
len
);
if
(
result
!=
kSuccess
)
{
g_warning
(
"Failed to set up Flutter locales"
);
}
}
// Callback to run a Flutter task in the GLib main loop.
...
...
@@ -133,8 +141,9 @@ static gboolean flutter_source_dispatch(GSource* source,
FlutterEngineResult
result
=
FlutterEngineRunTask
(
self
->
engine
,
&
fl_source
->
task
);
if
(
result
!=
kSuccess
)
if
(
result
!=
kSuccess
)
{
g_warning
(
"Failed to run Flutter task
\n
"
);
}
return
G_SOURCE_REMOVE
;
}
...
...
@@ -160,8 +169,9 @@ static bool fl_engine_gl_make_current(void* user_data) {
FlEngine
*
self
=
static_cast
<
FlEngine
*>
(
user_data
);
g_autoptr
(
GError
)
error
=
nullptr
;
gboolean
result
=
fl_renderer_make_current
(
self
->
renderer
,
&
error
);
if
(
!
result
)
if
(
!
result
)
{
g_warning
(
"%s"
,
error
->
message
);
}
return
result
;
}
...
...
@@ -169,8 +179,9 @@ static bool fl_engine_gl_clear_current(void* user_data) {
FlEngine
*
self
=
static_cast
<
FlEngine
*>
(
user_data
);
g_autoptr
(
GError
)
error
=
nullptr
;
gboolean
result
=
fl_renderer_clear_current
(
self
->
renderer
,
&
error
);
if
(
!
result
)
if
(
!
result
)
{
g_warning
(
"%s"
,
error
->
message
);
}
return
result
;
}
...
...
@@ -183,8 +194,9 @@ static bool fl_engine_gl_present(void* user_data) {
FlEngine
*
self
=
static_cast
<
FlEngine
*>
(
user_data
);
g_autoptr
(
GError
)
error
=
nullptr
;
gboolean
result
=
fl_renderer_present
(
self
->
renderer
,
&
error
);
if
(
!
result
)
if
(
!
result
)
{
g_warning
(
"%s"
,
error
->
message
);
}
return
result
;
}
...
...
@@ -192,8 +204,9 @@ static bool fl_engine_gl_make_resource_current(void* user_data) {
FlEngine
*
self
=
static_cast
<
FlEngine
*>
(
user_data
);
g_autoptr
(
GError
)
error
=
nullptr
;
gboolean
result
=
fl_renderer_make_resource_current
(
self
->
renderer
,
&
error
);
if
(
!
result
)
if
(
!
result
)
{
g_warning
(
"%s"
,
error
->
message
);
}
return
result
;
}
...
...
@@ -246,7 +259,7 @@ static void fl_engine_platform_message_response_cb(const uint8_t* data,
void
*
user_data
)
{
g_autoptr
(
GTask
)
task
=
G_TASK
(
user_data
);
g_task_return_pointer
(
task
,
g_bytes_new
(
data
,
data_length
),
(
GDestroyNotify
)
g_bytes_unref
);
reinterpret_cast
<
GDestroyNotify
>
(
g_bytes_unref
)
);
}
// Implements FlPluginRegistry::get_registrar_for_plugin.
...
...
@@ -318,8 +331,9 @@ G_MODULE_EXPORT FlEngine* fl_engine_new_headless(FlDartProject* project) {
gboolean
fl_engine_start
(
FlEngine
*
self
,
GError
**
error
)
{
g_return_val_if_fail
(
FL_IS_ENGINE
(
self
),
FALSE
);
if
(
!
fl_renderer_start
(
self
->
renderer
,
error
))
if
(
!
fl_renderer_start
(
self
->
renderer
,
error
))
{
return
FALSE
;
}
FlutterRendererConfig
config
=
{};
config
.
type
=
kOpenGL
;
...
...
@@ -499,8 +513,9 @@ void fl_engine_send_platform_message(FlEngine* self,
g_object_unref
(
task
);
}
if
(
response_handle
!=
nullptr
)
if
(
response_handle
!=
nullptr
)
{
FlutterPlatformMessageReleaseResponseHandle
(
self
->
engine
,
response_handle
);
}
}
GBytes
*
fl_engine_send_platform_message_finish
(
FlEngine
*
self
,
...
...
@@ -518,8 +533,9 @@ void fl_engine_send_window_metrics_event(FlEngine* self,
double
pixel_ratio
)
{
g_return_if_fail
(
FL_IS_ENGINE
(
self
));
if
(
self
->
engine
==
nullptr
)
if
(
self
->
engine
==
nullptr
)
{
return
;
}
FlutterWindowMetricsEvent
event
=
{};
event
.
struct_size
=
sizeof
(
FlutterWindowMetricsEvent
);
...
...
@@ -539,8 +555,9 @@ void fl_engine_send_mouse_pointer_event(FlEngine* self,
int64_t
buttons
)
{
g_return_if_fail
(
FL_IS_ENGINE
(
self
));
if
(
self
->
engine
==
nullptr
)
if
(
self
->
engine
==
nullptr
)
{
return
;
}
FlutterPointerEvent
fl_event
=
{};
fl_event
.
struct_size
=
sizeof
(
fl_event
);
...
...
@@ -548,8 +565,9 @@ void fl_engine_send_mouse_pointer_event(FlEngine* self,
fl_event
.
timestamp
=
timestamp
;
fl_event
.
x
=
x
;
fl_event
.
y
=
y
;
if
(
scroll_delta_x
!=
0
||
scroll_delta_y
!=
0
)
if
(
scroll_delta_x
!=
0
||
scroll_delta_y
!=
0
)
{
fl_event
.
signal_kind
=
kFlutterPointerSignalKindScroll
;
}
fl_event
.
scroll_delta_x
=
scroll_delta_x
;
fl_event
.
scroll_delta_y
=
scroll_delta_y
;
fl_event
.
device_kind
=
kFlutterPointerDeviceKindMouse
;
...
...
shell/platform/linux/fl_json_method_codec.cc
浏览文件 @
ab23dc3a
...
...
@@ -56,8 +56,9 @@ static gboolean fl_json_method_codec_decode_method_call(FlMethodCodec* codec,
g_autoptr
(
FlValue
)
value
=
fl_message_codec_decode_message
(
FL_MESSAGE_CODEC
(
self
->
codec
),
message
,
error
);
if
(
value
==
nullptr
)
if
(
value
==
nullptr
)
{
return
FALSE
;
}
if
(
fl_value_get_type
(
value
)
!=
FL_VALUE_TYPE_MAP
)
{
g_set_error
(
error
,
FL_MESSAGE_CODEC_ERROR
,
FL_MESSAGE_CODEC_ERROR_FAILED
,
...
...
@@ -131,8 +132,9 @@ static FlMethodResponse* fl_json_method_codec_decode_response(
g_autoptr
(
FlValue
)
value
=
fl_message_codec_decode_message
(
FL_MESSAGE_CODEC
(
self
->
codec
),
message
,
error
);
if
(
value
==
nullptr
)
if
(
value
==
nullptr
)
{
return
nullptr
;
}
if
(
fl_value_get_type
(
value
)
!=
FL_VALUE_TYPE_LIST
)
{
g_set_error
(
error
,
FL_MESSAGE_CODEC_ERROR
,
FL_MESSAGE_CODEC_ERROR_FAILED
,
...
...
@@ -167,8 +169,9 @@ static FlMethodResponse* fl_json_method_codec_decode_response(
:
nullptr
;
FlValue
*
args
=
fl_value_get_list_value
(
value
,
2
);
if
(
fl_value_get_type
(
args
)
==
FL_VALUE_TYPE_NULL
)
if
(
fl_value_get_type
(
args
)
==
FL_VALUE_TYPE_NULL
)
{
args
=
nullptr
;
}
return
FL_METHOD_RESPONSE
(
fl_method_error_response_new
(
code
,
message
,
args
));
...
...
shell/platform/linux/fl_method_channel.cc
浏览文件 @
ab23dc3a
...
...
@@ -44,8 +44,9 @@ static void message_cb(FlBinaryMessenger* messenger,
gpointer
user_data
)
{
FlMethodChannel
*
self
=
FL_METHOD_CHANNEL
(
user_data
);
if
(
self
->
method_call_handler
==
nullptr
)
if
(
self
->
method_call_handler
==
nullptr
)
{
return
;
}
g_autofree
gchar
*
method
=
nullptr
;
g_autoptr
(
FlValue
)
args
=
nullptr
;
...
...
@@ -76,8 +77,9 @@ static void channel_closed_cb(gpointer user_data) {
self
->
channel_closed
=
TRUE
;
// Disconnect handler.
if
(
self
->
method_call_handler_destroy_notify
!=
nullptr
)
if
(
self
->
method_call_handler_destroy_notify
!=
nullptr
)
{
self
->
method_call_handler_destroy_notify
(
self
->
method_call_handler_data
);
}
self
->
method_call_handler
=
nullptr
;
self
->
method_call_handler_data
=
nullptr
;
self
->
method_call_handler_destroy_notify
=
nullptr
;
...
...
@@ -95,8 +97,9 @@ static void fl_method_channel_dispose(GObject* object) {
g_clear_pointer
(
&
self
->
name
,
g_free
);
g_clear_object
(
&
self
->
codec
);
if
(
self
->
method_call_handler_destroy_notify
!=
nullptr
)
if
(
self
->
method_call_handler_destroy_notify
!=
nullptr
)
{
self
->
method_call_handler_destroy_notify
(
self
->
method_call_handler_data
);
}
self
->
method_call_handler
=
nullptr
;
self
->
method_call_handler_data
=
nullptr
;
self
->
method_call_handler_destroy_notify
=
nullptr
;
...
...
@@ -145,13 +148,15 @@ G_MODULE_EXPORT void fl_method_channel_set_method_call_handler(
g_warning
(
"Attempted to set method call handler on a closed FlMethodChannel"
);
}
if
(
destroy_notify
!=
nullptr
)
if
(
destroy_notify
!=
nullptr
)
{
destroy_notify
(
user_data
);
}
return
;
}
if
(
self
->
method_call_handler_destroy_notify
!=
nullptr
)
if
(
self
->
method_call_handler_destroy_notify
!=
nullptr
)
{
self
->
method_call_handler_destroy_notify
(
self
->
method_call_handler_data
);
}
self
->
method_call_handler
=
handler
;
self
->
method_call_handler_data
=
user_data
;
...
...
@@ -176,8 +181,9 @@ G_MODULE_EXPORT void fl_method_channel_invoke_method(
g_autoptr
(
GBytes
)
message
=
fl_method_codec_encode_method_call
(
self
->
codec
,
method
,
args
,
&
error
);
if
(
message
==
nullptr
)
{
if
(
task
!=
nullptr
)
if
(
task
!=
nullptr
)
{
g_task_return_error
(
task
,
error
);
}
return
;
}
...
...
@@ -199,8 +205,9 @@ G_MODULE_EXPORT FlMethodResponse* fl_method_channel_invoke_method_finish(
g_autoptr
(
GBytes
)
response
=
fl_binary_messenger_send_on_channel_finish
(
self
->
messenger
,
r
,
error
);
if
(
response
==
nullptr
)
if
(
response
==
nullptr
)
{
return
nullptr
;
}
return
fl_method_codec_decode_response
(
self
->
codec
,
response
,
error
);
}
...
...
shell/platform/linux/fl_method_codec.cc
浏览文件 @
ab23dc3a
...
...
@@ -68,8 +68,9 @@ FlMethodResponse* fl_method_codec_decode_response(FlMethodCodec* self,
g_return_val_if_fail
(
FL_IS_METHOD_CODEC
(
self
),
nullptr
);
g_return_val_if_fail
(
message
!=
nullptr
,
nullptr
);
if
(
g_bytes_get_size
(
message
)
==
0
)
if
(
g_bytes_get_size
(
message
)
==
0
)
{
return
FL_METHOD_RESPONSE
(
fl_method_not_implemented_response_new
());
}
return
FL_METHOD_CODEC_GET_CLASS
(
self
)
->
decode_response
(
self
,
message
,
error
);
}
shell/platform/linux/fl_renderer.cc
浏览文件 @
ab23dc3a
...
...
@@ -39,9 +39,10 @@ static void create_resource_surface(FlRenderer* self, EGLConfig config) {
priv
->
resource_context
=
eglCreateContext
(
priv
->
egl_display
,
config
,
priv
->
egl_context
,
context_attributes
);
if
(
priv
->
resource_context
==
EGL_NO_CONTEXT
)
if
(
priv
->
resource_context
==
EGL_NO_CONTEXT
)
{
g_warning
(
"Failed to create EGL resource context: %s"
,
egl_error_to_string
(
eglGetError
()));
}
}
static
void
fl_renderer_class_init
(
FlRendererClass
*
klass
)
{}
...
...
@@ -188,8 +189,9 @@ gboolean fl_renderer_make_resource_current(FlRenderer* self, GError** error) {
static_cast
<
FlRendererPrivate
*>
(
fl_renderer_get_instance_private
(
self
));
if
(
priv
->
resource_surface
==
EGL_NO_SURFACE
||
priv
->
resource_context
==
EGL_NO_CONTEXT
)
priv
->
resource_context
==
EGL_NO_CONTEXT
)
{
return
FALSE
;
}
if
(
!
eglMakeCurrent
(
priv
->
egl_display
,
priv
->
resource_surface
,
priv
->
resource_surface
,
priv
->
resource_context
))
{
...
...
shell/platform/linux/fl_standard_message_codec.cc
浏览文件 @
ab23dc3a
...
...
@@ -66,8 +66,9 @@ static void write_float64(GByteArray* buffer, double value) {
// Write padding bytes to align to @align multiple of bytes.
static
void
write_align
(
GByteArray
*
buffer
,
guint
align
)
{
while
(
buffer
->
len
%
align
!=
0
)
while
(
buffer
->
len
%
align
!=
0
)
{
write_uint8
(
buffer
,
0
);
}
}
// Checks there is enough data in @buffer to be read.
...
...
@@ -88,12 +89,14 @@ static gboolean read_align(GBytes* buffer,
size_t
*
offset
,
size_t
align
,
GError
**
error
)
{
if
((
*
offset
)
%
align
==
0
)
if
((
*
offset
)
%
align
==
0
)
{
return
TRUE
;
}
size_t
required
=
align
-
(
*
offset
)
%
align
;
if
(
!
check_size
(
buffer
,
*
offset
,
required
,
error
))
if
(
!
check_size
(
buffer
,
*
offset
,
required
,
error
))
{
return
FALSE
;
}
(
*
offset
)
+=
required
;
return
TRUE
;
...
...
@@ -111,8 +114,9 @@ static gboolean read_uint8(GBytes* buffer,
size_t
*
offset
,
uint8_t
*
value
,
GError
**
error
)
{
if
(
!
check_size
(
buffer
,
*
offset
,
sizeof
(
uint8_t
),
error
))
if
(
!
check_size
(
buffer
,
*
offset
,
sizeof
(
uint8_t
),
error
))
{
return
FALSE
;
}
*
value
=
get_data
(
buffer
,
offset
)[
0
];
(
*
offset
)
++
;
...
...
@@ -125,8 +129,9 @@ static gboolean read_uint16(GBytes* buffer,
size_t
*
offset
,
uint16_t
*
value
,
GError
**
error
)
{
if
(
!
check_size
(
buffer
,
*
offset
,
sizeof
(
uint16_t
),
error
))
if
(
!
check_size
(
buffer
,
*
offset
,
sizeof
(
uint16_t
),
error
))
{
return
FALSE
;
}
*
value
=
reinterpret_cast
<
const
uint16_t
*>
(
get_data
(
buffer
,
offset
))[
0
];
*
offset
+=
sizeof
(
uint16_t
);
...
...
@@ -139,8 +144,9 @@ static gboolean read_uint32(GBytes* buffer,
size_t
*
offset
,
uint32_t
*
value
,
GError
**
error
)
{
if
(
!
check_size
(
buffer
,
*
offset
,
sizeof
(
uint32_t
),
error
))
if
(
!
check_size
(
buffer
,
*
offset
,
sizeof
(
uint32_t
),
error
))
{
return
FALSE
;
}
*
value
=
reinterpret_cast
<
const
uint32_t
*>
(
get_data
(
buffer
,
offset
))[
0
];
*
offset
+=
sizeof
(
uint32_t
);
...
...
@@ -153,8 +159,9 @@ static gboolean read_uint32(GBytes* buffer,
static
FlValue
*
read_int32_value
(
GBytes
*
buffer
,
size_t
*
offset
,
GError
**
error
)
{
if
(
!
check_size
(
buffer
,
*
offset
,
sizeof
(
int32_t
),
error
))
if
(
!
check_size
(
buffer
,
*
offset
,
sizeof
(
int32_t
),
error
))
{
return
nullptr
;
}
FlValue
*
value
=
fl_value_new_int
(
reinterpret_cast
<
const
int32_t
*>
(
get_data
(
buffer
,
offset
))[
0
]);
...
...
@@ -168,8 +175,9 @@ static FlValue* read_int32_value(GBytes* buffer,
static
FlValue
*
read_int64_value
(
GBytes
*
buffer
,
size_t
*
offset
,
GError
**
error
)
{
if
(
!
check_size
(
buffer
,
*
offset
,
sizeof
(
int64_t
),
error
))
if
(
!
check_size
(
buffer
,
*
offset
,
sizeof
(
int64_t
),
error
))
{
return
nullptr
;
}
FlValue
*
value
=
fl_value_new_int
(
reinterpret_cast
<
const
int64_t
*>
(
get_data
(
buffer
,
offset
))[
0
]);
...
...
@@ -183,10 +191,12 @@ static FlValue* read_int64_value(GBytes* buffer,
static
FlValue
*
read_float64_value
(
GBytes
*
buffer
,
size_t
*
offset
,
GError
**
error
)
{
if
(
!
read_align
(
buffer
,
offset
,
8
,
error
))
if
(
!
read_align
(
buffer
,
offset
,
8
,
error
))
{
return
nullptr
;
if
(
!
check_size
(
buffer
,
*
offset
,
sizeof
(
double
),
error
))
}
if
(
!
check_size
(
buffer
,
*
offset
,
sizeof
(
double
),
error
))
{
return
nullptr
;
}
FlValue
*
value
=
fl_value_new_float
(
reinterpret_cast
<
const
double
*>
(
get_data
(
buffer
,
offset
))[
0
]);
...
...
@@ -203,10 +213,12 @@ static FlValue* read_string_value(FlStandardMessageCodec* self,
GError
**
error
)
{
uint32_t
length
;
if
(
!
fl_standard_message_codec_read_size
(
self
,
buffer
,
offset
,
&
length
,
error
))
error
))
{
return
nullptr
;
if
(
!
check_size
(
buffer
,
*
offset
,
length
,
error
))
}
if
(
!
check_size
(
buffer
,
*
offset
,
length
,
error
))
{
return
nullptr
;
}
FlValue
*
value
=
fl_value_new_string_sized
(
reinterpret_cast
<
const
gchar
*>
(
get_data
(
buffer
,
offset
)),
length
);
*
offset
+=
length
;
...
...
@@ -222,10 +234,12 @@ static FlValue* read_uint8_list_value(FlStandardMessageCodec* self,
GError
**
error
)
{
uint32_t
length
;
if
(
!
fl_standard_message_codec_read_size
(
self
,
buffer
,
offset
,
&
length
,
error
))
error
))
{
return
nullptr
;
if
(
!
check_size
(
buffer
,
*
offset
,
sizeof
(
uint8_t
)
*
length
,
error
))
}
if
(
!
check_size
(
buffer
,
*
offset
,
sizeof
(
uint8_t
)
*
length
,
error
))
{
return
nullptr
;
}
FlValue
*
value
=
fl_value_new_uint8_list
(
get_data
(
buffer
,
offset
),
length
);
*
offset
+=
length
;
return
value
;
...
...
@@ -240,12 +254,15 @@ static FlValue* read_int32_list_value(FlStandardMessageCodec* self,
GError
**
error
)
{
uint32_t
length
;
if
(
!
fl_standard_message_codec_read_size
(
self
,
buffer
,
offset
,
&
length
,
error
))
error
))
{
return
nullptr
;
if
(
!
read_align
(
buffer
,
offset
,
4
,
error
))
}
if
(
!
read_align
(
buffer
,
offset
,
4
,
error
))
{
return
nullptr
;
if
(
!
check_size
(
buffer
,
*
offset
,
sizeof
(
int32_t
)
*
length
,
error
))
}
if
(
!
check_size
(
buffer
,
*
offset
,
sizeof
(
int32_t
)
*
length
,
error
))
{
return
nullptr
;
}
FlValue
*
value
=
fl_value_new_int32_list
(
reinterpret_cast
<
const
int32_t
*>
(
get_data
(
buffer
,
offset
)),
length
);
*
offset
+=
sizeof
(
int32_t
)
*
length
;
...
...
@@ -261,12 +278,15 @@ static FlValue* read_int64_list_value(FlStandardMessageCodec* self,
GError
**
error
)
{
uint32_t
length
;
if
(
!
fl_standard_message_codec_read_size
(
self
,
buffer
,
offset
,
&
length
,
error
))
error
))
{
return
nullptr
;
if
(
!
read_align
(
buffer
,
offset
,
8
,
error
))
}
if
(
!
read_align
(
buffer
,
offset
,
8
,
error
))
{
return
nullptr
;
if
(
!
check_size
(
buffer
,
*
offset
,
sizeof
(
int64_t
)
*
length
,
error
))
}
if
(
!
check_size
(
buffer
,
*
offset
,
sizeof
(
int64_t
)
*
length
,
error
))
{
return
nullptr
;
}
FlValue
*
value
=
fl_value_new_int64_list
(
reinterpret_cast
<
const
int64_t
*>
(
get_data
(
buffer
,
offset
)),
length
);
*
offset
+=
sizeof
(
int64_t
)
*
length
;
...
...
@@ -282,12 +302,15 @@ static FlValue* read_float64_list_value(FlStandardMessageCodec* self,
GError
**
error
)
{
uint32_t
length
;
if
(
!
fl_standard_message_codec_read_size
(
self
,
buffer
,
offset
,
&
length
,
error
))
error
))
{
return
nullptr
;
if
(
!
read_align
(
buffer
,
offset
,
8
,
error
))
}
if
(
!
read_align
(
buffer
,
offset
,
8
,
error
))
{
return
nullptr
;
if
(
!
check_size
(
buffer
,
*
offset
,
sizeof
(
double
)
*
length
,
error
))
}
if
(
!
check_size
(
buffer
,
*
offset
,
sizeof
(
double
)
*
length
,
error
))
{
return
nullptr
;
}
FlValue
*
value
=
fl_value_new_float_list
(
reinterpret_cast
<
const
double
*>
(
get_data
(
buffer
,
offset
)),
length
);
*
offset
+=
sizeof
(
double
)
*
length
;
...
...
@@ -303,15 +326,17 @@ static FlValue* read_list_value(FlStandardMessageCodec* self,
GError
**
error
)
{
uint32_t
length
;
if
(
!
fl_standard_message_codec_read_size
(
self
,
buffer
,
offset
,
&
length
,
error
))
error
))
{
return
nullptr
;
}
g_autoptr
(
FlValue
)
list
=
fl_value_new_list
();
for
(
size_t
i
=
0
;
i
<
length
;
i
++
)
{
g_autoptr
(
FlValue
)
child
=
fl_standard_message_codec_read_value
(
self
,
buffer
,
offset
,
error
);
if
(
child
==
nullptr
)
if
(
child
==
nullptr
)
{
return
nullptr
;
}
fl_value_append
(
list
,
child
);
}
...
...
@@ -327,19 +352,22 @@ static FlValue* read_map_value(FlStandardMessageCodec* self,
GError
**
error
)
{
uint32_t
length
;
if
(
!
fl_standard_message_codec_read_size
(
self
,
buffer
,
offset
,
&
length
,
error
))
error
))
{
return
nullptr
;
}
g_autoptr
(
FlValue
)
map
=
fl_value_new_map
();
for
(
size_t
i
=
0
;
i
<
length
;
i
++
)
{
g_autoptr
(
FlValue
)
key
=
fl_standard_message_codec_read_value
(
self
,
buffer
,
offset
,
error
);
if
(
key
==
nullptr
)
if
(
key
==
nullptr
)
{
return
nullptr
;
}
g_autoptr
(
FlValue
)
value
=
fl_standard_message_codec_read_value
(
self
,
buffer
,
offset
,
error
);
if
(
value
==
nullptr
)
if
(
value
==
nullptr
)
{
return
nullptr
;
}
fl_value_set
(
map
,
key
,
value
);
}
...
...
@@ -354,8 +382,9 @@ static GBytes* fl_standard_message_codec_encode_message(FlMessageCodec* codec,
reinterpret_cast
<
FlStandardMessageCodec
*>
(
codec
);
g_autoptr
(
GByteArray
)
buffer
=
g_byte_array_new
();
if
(
!
fl_standard_message_codec_write_value
(
self
,
buffer
,
message
,
error
))
if
(
!
fl_standard_message_codec_write_value
(
self
,
buffer
,
message
,
error
))
{
return
nullptr
;
}
return
g_byte_array_free_to_bytes
(
static_cast
<
GByteArray
*>
(
g_steal_pointer
(
&
buffer
)));
}
...
...
@@ -370,8 +399,9 @@ static FlValue* fl_standard_message_codec_decode_message(FlMessageCodec* codec,
size_t
offset
=
0
;
g_autoptr
(
FlValue
)
value
=
fl_standard_message_codec_read_value
(
self
,
message
,
&
offset
,
error
);
if
(
value
==
nullptr
)
if
(
value
==
nullptr
)
{
return
nullptr
;
}
if
(
offset
!=
g_bytes_get_size
(
message
))
{
g_set_error
(
error
,
FL_MESSAGE_CODEC_ERROR
,
...
...
@@ -419,16 +449,19 @@ gboolean fl_standard_message_codec_read_size(FlStandardMessageCodec* codec,
uint32_t
*
value
,
GError
**
error
)
{
uint8_t
value8
;
if
(
!
read_uint8
(
buffer
,
offset
,
&
value8
,
error
))
if
(
!
read_uint8
(
buffer
,
offset
,
&
value8
,
error
))
{
return
FALSE
;
}
if
(
value8
==
255
)
{
if
(
!
read_uint32
(
buffer
,
offset
,
value
,
error
))
if
(
!
read_uint32
(
buffer
,
offset
,
value
,
error
))
{
return
FALSE
;
}
}
else
if
(
value8
==
254
)
{
uint16_t
value16
;
if
(
!
read_uint16
(
buffer
,
offset
,
&
value16
,
error
))
if
(
!
read_uint16
(
buffer
,
offset
,
&
value16
,
error
))
{
return
FALSE
;
}
*
value
=
value16
;
}
else
{
*
value
=
value8
;
...
...
@@ -451,10 +484,11 @@ gboolean fl_standard_message_codec_write_value(FlStandardMessageCodec* self,
write_uint8
(
buffer
,
kValueNull
);
return
TRUE
;
case
FL_VALUE_TYPE_BOOL
:
if
(
fl_value_get_bool
(
value
))
if
(
fl_value_get_bool
(
value
))
{
write_uint8
(
buffer
,
kValueTrue
);
else
}
else
{
write_uint8
(
buffer
,
kValueFalse
);
}
return
TRUE
;
case
FL_VALUE_TYPE_INT
:
{
int64_t
v
=
fl_value_get_int
(
value
);
...
...
@@ -528,8 +562,9 @@ gboolean fl_standard_message_codec_write_value(FlStandardMessageCodec* self,
fl_value_get_length
(
value
));
for
(
size_t
i
=
0
;
i
<
fl_value_get_length
(
value
);
i
++
)
{
if
(
!
fl_standard_message_codec_write_value
(
self
,
buffer
,
fl_value_get_list_value
(
value
,
i
),
error
))
self
,
buffer
,
fl_value_get_list_value
(
value
,
i
),
error
))
{
return
FALSE
;
}
}
return
TRUE
;
case
FL_VALUE_TYPE_MAP
:
...
...
@@ -540,8 +575,9 @@ gboolean fl_standard_message_codec_write_value(FlStandardMessageCodec* self,
if
(
!
fl_standard_message_codec_write_value
(
self
,
buffer
,
fl_value_get_map_key
(
value
,
i
),
error
)
||
!
fl_standard_message_codec_write_value
(
self
,
buffer
,
fl_value_get_map_value
(
value
,
i
),
error
))
self
,
buffer
,
fl_value_get_map_value
(
value
,
i
),
error
))
{
return
FALSE
;
}
}
return
TRUE
;
}
...
...
@@ -557,8 +593,9 @@ FlValue* fl_standard_message_codec_read_value(FlStandardMessageCodec* self,
size_t
*
offset
,
GError
**
error
)
{
uint8_t
type
;
if
(
!
read_uint8
(
buffer
,
offset
,
&
type
,
error
))
if
(
!
read_uint8
(
buffer
,
offset
,
&
type
,
error
))
{
return
nullptr
;
}
g_autoptr
(
FlValue
)
value
=
nullptr
;
if
(
type
==
kValueNull
)
{
...
...
shell/platform/linux/fl_standard_method_codec.cc
浏览文件 @
ab23dc3a
...
...
@@ -44,10 +44,13 @@ static GBytes* fl_standard_method_codec_encode_method_call(FlMethodCodec* codec,
g_autoptr
(
GByteArray
)
buffer
=
g_byte_array_new
();
g_autoptr
(
FlValue
)
name_value
=
fl_value_new_string
(
name
);
if
(
!
fl_standard_message_codec_write_value
(
self
->
codec
,
buffer
,
name_value
,
error
))
error
))
{
return
nullptr
;
if
(
!
fl_standard_message_codec_write_value
(
self
->
codec
,
buffer
,
args
,
error
))
}
if
(
!
fl_standard_message_codec_write_value
(
self
->
codec
,
buffer
,
args
,
error
))
{
return
nullptr
;
}
return
g_byte_array_free_to_bytes
(
static_cast
<
GByteArray
*>
(
g_steal_pointer
(
&
buffer
)));
...
...
@@ -65,8 +68,9 @@ static gboolean fl_standard_method_codec_decode_method_call(
size_t
offset
=
0
;
g_autoptr
(
FlValue
)
name_value
=
fl_standard_message_codec_read_value
(
self
->
codec
,
message
,
&
offset
,
error
);
if
(
name_value
==
nullptr
)
if
(
name_value
==
nullptr
)
{
return
FALSE
;
}
if
(
fl_value_get_type
(
name_value
)
!=
FL_VALUE_TYPE_STRING
)
{
g_set_error
(
error
,
FL_MESSAGE_CODEC_ERROR
,
FL_MESSAGE_CODEC_ERROR_FAILED
,
"Method call name wrong type"
);
...
...
@@ -75,8 +79,9 @@ static gboolean fl_standard_method_codec_decode_method_call(
g_autoptr
(
FlValue
)
args_value
=
fl_standard_message_codec_read_value
(
self
->
codec
,
message
,
&
offset
,
error
);
if
(
args_value
==
nullptr
)
if
(
args_value
==
nullptr
)
{
return
FALSE
;
}
if
(
offset
!=
g_bytes_get_size
(
message
))
{
g_set_error
(
error
,
FL_MESSAGE_CODEC_ERROR
,
FL_MESSAGE_CODEC_ERROR_FAILED
,
...
...
@@ -101,8 +106,9 @@ static GBytes* fl_standard_method_codec_encode_success_envelope(
guint8
type
=
kEnvelopeTypeSuccess
;
g_byte_array_append
(
buffer
,
&
type
,
1
);
if
(
!
fl_standard_message_codec_write_value
(
self
->
codec
,
buffer
,
result
,
error
))
error
))
{
return
nullptr
;
}
return
g_byte_array_free_to_bytes
(
static_cast
<
GByteArray
*>
(
g_steal_pointer
(
&
buffer
)));
...
...
@@ -122,16 +128,19 @@ static GBytes* fl_standard_method_codec_encode_error_envelope(
g_byte_array_append
(
buffer
,
&
type
,
1
);
g_autoptr
(
FlValue
)
code_value
=
fl_value_new_string
(
code
);
if
(
!
fl_standard_message_codec_write_value
(
self
->
codec
,
buffer
,
code_value
,
error
))
error
))
{
return
nullptr
;
}
g_autoptr
(
FlValue
)
message_value
=
message
!=
nullptr
?
fl_value_new_string
(
message
)
:
nullptr
;
if
(
!
fl_standard_message_codec_write_value
(
self
->
codec
,
buffer
,
message_value
,
error
))
error
))
{
return
nullptr
;
}
if
(
!
fl_standard_message_codec_write_value
(
self
->
codec
,
buffer
,
details
,
error
))
error
))
{
return
nullptr
;
}
return
g_byte_array_free_to_bytes
(
static_cast
<
GByteArray
*>
(
g_steal_pointer
(
&
buffer
)));
...
...
@@ -160,8 +169,9 @@ static FlMethodResponse* fl_standard_method_codec_decode_response(
if
(
type
==
kEnvelopeTypeError
)
{
g_autoptr
(
FlValue
)
code
=
fl_standard_message_codec_read_value
(
self
->
codec
,
message
,
&
offset
,
error
);
if
(
code
==
nullptr
)
if
(
code
==
nullptr
)
{
return
nullptr
;
}
if
(
fl_value_get_type
(
code
)
!=
FL_VALUE_TYPE_STRING
)
{
g_set_error
(
error
,
FL_MESSAGE_CODEC_ERROR
,
FL_MESSAGE_CODEC_ERROR_FAILED
,
"Error code wrong type"
);
...
...
@@ -170,8 +180,9 @@ static FlMethodResponse* fl_standard_method_codec_decode_response(
g_autoptr
(
FlValue
)
error_message
=
fl_standard_message_codec_read_value
(
self
->
codec
,
message
,
&
offset
,
error
);
if
(
error_message
==
nullptr
)
if
(
error_message
==
nullptr
)
{
return
nullptr
;
}
if
(
fl_value_get_type
(
error_message
)
!=
FL_VALUE_TYPE_STRING
&&
fl_value_get_type
(
error_message
)
!=
FL_VALUE_TYPE_NULL
)
{
g_set_error
(
error
,
FL_MESSAGE_CODEC_ERROR
,
FL_MESSAGE_CODEC_ERROR_FAILED
,
...
...
@@ -181,8 +192,9 @@ static FlMethodResponse* fl_standard_method_codec_decode_response(
g_autoptr
(
FlValue
)
details
=
fl_standard_message_codec_read_value
(
self
->
codec
,
message
,
&
offset
,
error
);
if
(
details
==
nullptr
)
if
(
details
==
nullptr
)
{
return
nullptr
;
}
response
=
FL_METHOD_RESPONSE
(
fl_method_error_response_new
(
fl_value_get_string
(
code
),
...
...
@@ -194,8 +206,9 @@ static FlMethodResponse* fl_standard_method_codec_decode_response(
g_autoptr
(
FlValue
)
result
=
fl_standard_message_codec_read_value
(
self
->
codec
,
message
,
&
offset
,
error
);
if
(
result
==
nullptr
)
if
(
result
==
nullptr
)
{
return
nullptr
;
}
response
=
FL_METHOD_RESPONSE
(
fl_method_success_response_new
(
result
));
}
else
{
...
...
shell/platform/linux/fl_text_input_plugin.cc
浏览文件 @
ab23dc3a
...
...
@@ -61,8 +61,9 @@ static gboolean finish_method(GObject* object,
GError
**
error
)
{
g_autoptr
(
FlMethodResponse
)
response
=
fl_method_channel_invoke_method_finish
(
FL_METHOD_CHANNEL
(
object
),
result
,
error
);
if
(
response
==
nullptr
)
if
(
response
==
nullptr
)
{
return
FALSE
;
}
return
fl_method_response_get_result
(
response
,
error
)
!=
nullptr
;
}
...
...
@@ -113,8 +114,9 @@ static void perform_action_response_cb(GObject* object,
GAsyncResult
*
result
,
gpointer
user_data
)
{
g_autoptr
(
GError
)
error
=
nullptr
;
if
(
!
finish_method
(
object
,
result
,
&
error
))
if
(
!
finish_method
(
object
,
result
,
&
error
))
{
g_warning
(
"Failed to call %s: %s"
,
kPerformActionMethod
,
error
->
message
);
}
}
// Inform Flutter that the input has been activated.
...
...
@@ -150,8 +152,9 @@ static gboolean im_retrieve_surrounding_cb(FlTextInputPlugin* self) {
static
gboolean
im_delete_surrounding_cb
(
FlTextInputPlugin
*
self
,
gint
offset
,
gint
n_chars
)
{
if
(
self
->
text_model
->
DeleteSurrounding
(
offset
,
n_chars
))
if
(
self
->
text_model
->
DeleteSurrounding
(
offset
,
n_chars
))
{
update_editing_state
(
self
);
}
return
TRUE
;
}
...
...
@@ -168,8 +171,9 @@ static FlMethodResponse* set_client(FlTextInputPlugin* self, FlValue* args) {
g_free
(
self
->
input_action
);
FlValue
*
input_action_value
=
fl_value_lookup_string
(
config_value
,
kInputActionKey
);
if
(
fl_value_get_type
(
input_action_value
)
==
FL_VALUE_TYPE_STRING
)
if
(
fl_value_get_type
(
input_action_value
)
==
FL_VALUE_TYPE_STRING
)
{
self
->
input_action
=
g_strdup
(
fl_value_get_string
(
input_action_value
));
}
return
FL_METHOD_RESPONSE
(
fl_method_success_response_new
(
nullptr
));
}
...
...
@@ -224,22 +228,24 @@ static void method_call_cb(FlMethodChannel* channel,
FlValue
*
args
=
fl_method_call_get_args
(
method_call
);
g_autoptr
(
FlMethodResponse
)
response
=
nullptr
;
if
(
strcmp
(
method
,
kSetClientMethod
)
==
0
)
if
(
strcmp
(
method
,
kSetClientMethod
)
==
0
)
{
response
=
set_client
(
self
,
args
);
else
if
(
strcmp
(
method
,
kShowMethod
)
==
0
)
}
else
if
(
strcmp
(
method
,
kShowMethod
)
==
0
)
{
response
=
show
(
self
);
else
if
(
strcmp
(
method
,
kSetEditingStateMethod
)
==
0
)
}
else
if
(
strcmp
(
method
,
kSetEditingStateMethod
)
==
0
)
{
response
=
set_editing_state
(
self
,
args
);
else
if
(
strcmp
(
method
,
kClearClientMethod
)
==
0
)
}
else
if
(
strcmp
(
method
,
kClearClientMethod
)
==
0
)
{
response
=
clear_client
(
self
);
else
if
(
strcmp
(
method
,
kHideMethod
)
==
0
)
}
else
if
(
strcmp
(
method
,
kHideMethod
)
==
0
)
{
response
=
hide
(
self
);
else
}
else
{
response
=
FL_METHOD_RESPONSE
(
fl_method_not_implemented_response_new
());
}
g_autoptr
(
GError
)
error
=
nullptr
;
if
(
!
fl_method_call_respond
(
method_call
,
response
,
&
error
))
if
(
!
fl_method_call_respond
(
method_call
,
response
,
&
error
))
{
g_warning
(
"Failed to send method call response: %s"
,
error
->
message
);
}
}
static
void
fl_text_input_plugin_dispose
(
GObject
*
object
)
{
...
...
@@ -293,11 +299,13 @@ gboolean fl_text_input_plugin_filter_keypress(FlTextInputPlugin* self,
GdkEventKey
*
event
)
{
g_return_val_if_fail
(
FL_IS_TEXT_INPUT_PLUGIN
(
self
),
FALSE
);
if
(
self
->
client_id
==
kClientIdUnset
)
if
(
self
->
client_id
==
kClientIdUnset
)
{
return
FALSE
;
}
if
(
gtk_im_context_filter_keypress
(
self
->
im_context
,
event
))
if
(
gtk_im_context_filter_keypress
(
self
->
im_context
,
event
))
{
return
TRUE
;
}
// Handle navigation keys.
gboolean
changed
=
FALSE
;
...
...
@@ -334,8 +342,9 @@ gboolean fl_text_input_plugin_filter_keypress(FlTextInputPlugin* self,
}
}
if
(
changed
)
if
(
changed
)
{
update_editing_state
(
self
);
}
return
FALSE
;
}
shell/platform/linux/fl_value.cc
浏览文件 @
ab23dc3a
...
...
@@ -86,8 +86,9 @@ static ssize_t fl_value_lookup_index(FlValue* self, FlValue* key) {
for
(
size_t
i
=
0
;
i
<
fl_value_get_length
(
self
);
i
++
)
{
FlValue
*
k
=
fl_value_get_map_key
(
self
,
i
);
if
(
fl_value_equal
(
k
,
key
))
if
(
fl_value_equal
(
k
,
key
))
{
return
i
;
}
}
return
-
1
;
}
...
...
@@ -109,8 +110,9 @@ static void float_to_string(double value, GString* buffer) {
zero_count
=
zero_count
==
0
?
0
:
zero_count
-
1
;
break
;
}
if
(
buffer
->
str
[
i
]
!=
'0'
)
if
(
buffer
->
str
[
i
]
!=
'0'
)
{
break
;
}
zero_count
++
;
}
g_string_truncate
(
buffer
,
buffer
->
len
-
zero_count
);
...
...
@@ -122,10 +124,11 @@ static void value_to_string(FlValue* value, GString* buffer) {
g_string_append
(
buffer
,
"null"
);
return
;
case
FL_VALUE_TYPE_BOOL
:
if
(
fl_value_get_bool
(
value
))
if
(
fl_value_get_bool
(
value
))
{
g_string_append
(
buffer
,
"true"
);
else
}
else
{
g_string_append
(
buffer
,
"false"
);
}
return
;
case
FL_VALUE_TYPE_INT
:
int_to_string
(
fl_value_get_int
(
value
),
buffer
);
...
...
@@ -141,8 +144,9 @@ static void value_to_string(FlValue* value, GString* buffer) {
g_string_append
(
buffer
,
"["
);
const
uint8_t
*
values
=
fl_value_get_uint8_list
(
value
);
for
(
size_t
i
=
0
;
i
<
fl_value_get_length
(
value
);
i
++
)
{
if
(
i
!=
0
)
if
(
i
!=
0
)
{
g_string_append
(
buffer
,
", "
);
}
int_to_string
(
values
[
i
],
buffer
);
}
g_string_append
(
buffer
,
"]"
);
...
...
@@ -152,8 +156,9 @@ static void value_to_string(FlValue* value, GString* buffer) {
g_string_append
(
buffer
,
"["
);
const
int32_t
*
values
=
fl_value_get_int32_list
(
value
);
for
(
size_t
i
=
0
;
i
<
fl_value_get_length
(
value
);
i
++
)
{
if
(
i
!=
0
)
if
(
i
!=
0
)
{
g_string_append
(
buffer
,
", "
);
}
int_to_string
(
values
[
i
],
buffer
);
}
g_string_append
(
buffer
,
"]"
);
...
...
@@ -163,8 +168,9 @@ static void value_to_string(FlValue* value, GString* buffer) {
g_string_append
(
buffer
,
"["
);
const
int64_t
*
values
=
fl_value_get_int64_list
(
value
);
for
(
size_t
i
=
0
;
i
<
fl_value_get_length
(
value
);
i
++
)
{
if
(
i
!=
0
)
if
(
i
!=
0
)
{
g_string_append
(
buffer
,
", "
);
}
int_to_string
(
values
[
i
],
buffer
);
}
g_string_append
(
buffer
,
"]"
);
...
...
@@ -174,8 +180,9 @@ static void value_to_string(FlValue* value, GString* buffer) {
g_string_append
(
buffer
,
"["
);
const
double
*
values
=
fl_value_get_float_list
(
value
);
for
(
size_t
i
=
0
;
i
<
fl_value_get_length
(
value
);
i
++
)
{
if
(
i
!=
0
)
if
(
i
!=
0
)
{
g_string_append
(
buffer
,
", "
);
}
float_to_string
(
values
[
i
],
buffer
);
}
g_string_append
(
buffer
,
"]"
);
...
...
@@ -184,8 +191,9 @@ static void value_to_string(FlValue* value, GString* buffer) {
case
FL_VALUE_TYPE_LIST
:
{
g_string_append
(
buffer
,
"["
);
for
(
size_t
i
=
0
;
i
<
fl_value_get_length
(
value
);
i
++
)
{
if
(
i
!=
0
)
if
(
i
!=
0
)
{
g_string_append
(
buffer
,
", "
);
}
value_to_string
(
fl_value_get_list_value
(
value
,
i
),
buffer
);
}
g_string_append
(
buffer
,
"]"
);
...
...
@@ -194,8 +202,9 @@ static void value_to_string(FlValue* value, GString* buffer) {
case
FL_VALUE_TYPE_MAP
:
{
g_string_append
(
buffer
,
"{"
);
for
(
size_t
i
=
0
;
i
<
fl_value_get_length
(
value
);
i
++
)
{
if
(
i
!=
0
)
if
(
i
!=
0
)
{
g_string_append
(
buffer
,
", "
);
}
value_to_string
(
fl_value_get_map_key
(
value
,
i
),
buffer
);
g_string_append
(
buffer
,
": "
);
value_to_string
(
fl_value_get_map_value
(
value
,
i
),
buffer
);
...
...
@@ -307,8 +316,9 @@ G_MODULE_EXPORT FlValue* fl_value_new_list_from_strv(
const
gchar
*
const
*
str_array
)
{
g_return_val_if_fail
(
str_array
!=
nullptr
,
nullptr
);
g_autoptr
(
FlValue
)
value
=
fl_value_new_list
();
for
(
int
i
=
0
;
str_array
[
i
]
!=
nullptr
;
i
++
)
for
(
int
i
=
0
;
str_array
[
i
]
!=
nullptr
;
i
++
)
{
fl_value_append_take
(
value
,
fl_value_new_string
(
str_array
[
i
]));
}
return
fl_value_ref
(
value
);
}
...
...
@@ -330,8 +340,9 @@ G_MODULE_EXPORT void fl_value_unref(FlValue* self) {
g_return_if_fail
(
self
!=
nullptr
);
g_return_if_fail
(
self
->
ref_count
>
0
);
self
->
ref_count
--
;
if
(
self
->
ref_count
!=
0
)
if
(
self
->
ref_count
!=
0
)
{
return
;
}
switch
(
self
->
type
)
{
case
FL_VALUE_TYPE_STRING
:
{
...
...
@@ -388,8 +399,9 @@ G_MODULE_EXPORT bool fl_value_equal(FlValue* a, FlValue* b) {
g_return_val_if_fail
(
a
!=
nullptr
,
false
);
g_return_val_if_fail
(
b
!=
nullptr
,
false
);
if
(
a
->
type
!=
b
->
type
)
if
(
a
->
type
!=
b
->
type
)
{
return
false
;
}
switch
(
a
->
type
)
{
case
FL_VALUE_TYPE_NULL
:
...
...
@@ -406,70 +418,83 @@ G_MODULE_EXPORT bool fl_value_equal(FlValue* a, FlValue* b) {
return
g_strcmp0
(
a_
->
value
,
b_
->
value
)
==
0
;
}
case
FL_VALUE_TYPE_UINT8_LIST
:
{
if
(
fl_value_get_length
(
a
)
!=
fl_value_get_length
(
b
))
if
(
fl_value_get_length
(
a
)
!=
fl_value_get_length
(
b
))
{
return
false
;
}
const
uint8_t
*
values_a
=
fl_value_get_uint8_list
(
a
);
const
uint8_t
*
values_b
=
fl_value_get_uint8_list
(
b
);
for
(
size_t
i
=
0
;
i
<
fl_value_get_length
(
a
);
i
++
)
{
if
(
values_a
[
i
]
!=
values_b
[
i
])
if
(
values_a
[
i
]
!=
values_b
[
i
])
{
return
false
;
}
}
return
true
;
}
case
FL_VALUE_TYPE_INT32_LIST
:
{
if
(
fl_value_get_length
(
a
)
!=
fl_value_get_length
(
b
))
if
(
fl_value_get_length
(
a
)
!=
fl_value_get_length
(
b
))
{
return
false
;
}
const
int32_t
*
values_a
=
fl_value_get_int32_list
(
a
);
const
int32_t
*
values_b
=
fl_value_get_int32_list
(
b
);
for
(
size_t
i
=
0
;
i
<
fl_value_get_length
(
a
);
i
++
)
{
if
(
values_a
[
i
]
!=
values_b
[
i
])
if
(
values_a
[
i
]
!=
values_b
[
i
])
{
return
false
;
}
}
return
true
;
}
case
FL_VALUE_TYPE_INT64_LIST
:
{
if
(
fl_value_get_length
(
a
)
!=
fl_value_get_length
(
b
))
if
(
fl_value_get_length
(
a
)
!=
fl_value_get_length
(
b
))
{
return
false
;
}
const
int64_t
*
values_a
=
fl_value_get_int64_list
(
a
);
const
int64_t
*
values_b
=
fl_value_get_int64_list
(
b
);
for
(
size_t
i
=
0
;
i
<
fl_value_get_length
(
a
);
i
++
)
{
if
(
values_a
[
i
]
!=
values_b
[
i
])
if
(
values_a
[
i
]
!=
values_b
[
i
])
{
return
false
;
}
}
return
true
;
}
case
FL_VALUE_TYPE_FLOAT_LIST
:
{
if
(
fl_value_get_length
(
a
)
!=
fl_value_get_length
(
b
))
if
(
fl_value_get_length
(
a
)
!=
fl_value_get_length
(
b
))
{
return
false
;
}
const
double
*
values_a
=
fl_value_get_float_list
(
a
);
const
double
*
values_b
=
fl_value_get_float_list
(
b
);
for
(
size_t
i
=
0
;
i
<
fl_value_get_length
(
a
);
i
++
)
{
if
(
values_a
[
i
]
!=
values_b
[
i
])
if
(
values_a
[
i
]
!=
values_b
[
i
])
{
return
false
;
}
}
return
true
;
}
case
FL_VALUE_TYPE_LIST
:
{
if
(
fl_value_get_length
(
a
)
!=
fl_value_get_length
(
b
))
if
(
fl_value_get_length
(
a
)
!=
fl_value_get_length
(
b
))
{
return
false
;
}
for
(
size_t
i
=
0
;
i
<
fl_value_get_length
(
a
);
i
++
)
{
if
(
!
fl_value_equal
(
fl_value_get_list_value
(
a
,
i
),
fl_value_get_list_value
(
b
,
i
)))
fl_value_get_list_value
(
b
,
i
)))
{
return
false
;
}
}
return
true
;
}
case
FL_VALUE_TYPE_MAP
:
{
if
(
fl_value_get_length
(
a
)
!=
fl_value_get_length
(
b
))
if
(
fl_value_get_length
(
a
)
!=
fl_value_get_length
(
b
))
{
return
false
;
}
for
(
size_t
i
=
0
;
i
<
fl_value_get_length
(
a
);
i
++
)
{
FlValue
*
key
=
fl_value_get_map_key
(
a
,
i
);
FlValue
*
value_b
=
fl_value_lookup
(
b
,
key
);
if
(
value_b
==
nullptr
)
if
(
value_b
==
nullptr
)
{
return
false
;
}
FlValue
*
value_a
=
fl_value_get_map_value
(
a
,
i
);
if
(
!
fl_value_equal
(
value_a
,
value_b
))
if
(
!
fl_value_equal
(
value_a
,
value_b
))
{
return
false
;
}
}
return
true
;
}
...
...
@@ -676,16 +701,21 @@ G_MODULE_EXPORT FlValue* fl_value_lookup(FlValue* self, FlValue* key) {
g_return_val_if_fail
(
self
->
type
==
FL_VALUE_TYPE_MAP
,
nullptr
);
ssize_t
index
=
fl_value_lookup_index
(
self
,
key
);
if
(
index
<
0
)
if
(
index
<
0
)
{
return
nullptr
;
}
return
fl_value_get_map_value
(
self
,
index
);
}
G_MODULE_EXPORT
FlValue
*
fl_value_lookup_string
(
FlValue
*
self
,
const
gchar
*
key
)
{
g_return_val_if_fail
(
self
!=
nullptr
,
nullptr
);
g_autoptr
(
FlValue
)
string_key
=
fl_value_new_string
(
key
);
return
fl_value_lookup
(
self
,
string_key
);
FlValue
*
string_key
=
fl_value_new_string
(
key
);
FlValue
*
value
=
fl_value_lookup
(
self
,
string_key
);
// Explicit unref used because the g_autoptr is triggering a false positive
// with clang-tidy.
fl_value_unref
(
string_key
);
return
value
;
}
G_MODULE_EXPORT
gchar
*
fl_value_to_string
(
FlValue
*
value
)
{
...
...
shell/platform/linux/fl_view.cc
浏览文件 @
ab23dc3a
...
...
@@ -70,25 +70,28 @@ static gboolean fl_view_send_pointer_button_event(FlView* self,
return
FALSE
;
}
int
old_button_state
=
self
->
button_state
;
FlutterPointerPhase
phase
;
FlutterPointerPhase
phase
=
kMove
;
if
(
event
->
type
==
GDK_BUTTON_PRESS
)
{
// Drop the event if Flutter already thinks the button is down.
if
((
self
->
button_state
&
button
)
!=
0
)
if
((
self
->
button_state
&
button
)
!=
0
)
{
return
FALSE
;
}
self
->
button_state
^=
button
;
phase
=
old_button_state
==
0
?
kDown
:
kMove
;
}
else
if
(
event
->
type
==
GDK_BUTTON_RELEASE
)
{
// Drop the event if Flutter already thinks the button is up.
if
((
self
->
button_state
&
button
)
==
0
)
if
((
self
->
button_state
&
button
)
==
0
)
{
return
FALSE
;
}
self
->
button_state
^=
button
;
phase
=
self
->
button_state
==
0
?
kUp
:
kMove
;
}
if
(
self
->
engine
==
nullptr
)
if
(
self
->
engine
==
nullptr
)
{
return
FALSE
;
}
gint
scale_factor
=
gtk_widget_get_scale_factor
(
GTK_WIDGET
(
self
));
fl_engine_send_mouse_pointer_event
(
...
...
@@ -178,8 +181,9 @@ static void fl_view_notify(GObject* object, GParamSpec* pspec) {
fl_view_send_window_metrics
(
self
);
}
if
(
G_OBJECT_CLASS
(
fl_view_parent_class
)
->
notify
!=
nullptr
)
if
(
G_OBJECT_CLASS
(
fl_view_parent_class
)
->
notify
!=
nullptr
)
{
G_OBJECT_CLASS
(
fl_view_parent_class
)
->
notify
(
object
,
pspec
);
}
}
static
void
fl_view_dispose
(
GObject
*
object
)
{
...
...
@@ -203,8 +207,9 @@ static void fl_view_realize(GtkWidget* widget) {
gtk_widget_set_realized
(
widget
,
TRUE
);
g_autoptr
(
GError
)
error
=
nullptr
;
if
(
!
fl_renderer_setup
(
self
->
renderer
,
&
error
))
if
(
!
fl_renderer_setup
(
self
->
renderer
,
&
error
))
{
g_warning
(
"Failed to setup renderer: %s"
,
error
->
message
);
}
GtkAllocation
allocation
;
gtk_widget_get_allocation
(
widget
,
&
allocation
);
...
...
@@ -236,8 +241,9 @@ static void fl_view_realize(GtkWidget* widget) {
FL_RENDERER_X11
(
self
->
renderer
),
GDK_X11_WINDOW
(
gtk_widget_get_window
(
GTK_WIDGET
(
self
))));
if
(
!
fl_engine_start
(
self
->
engine
,
&
error
))
if
(
!
fl_engine_start
(
self
->
engine
,
&
error
))
{
g_warning
(
"Failed to start Flutter engine: %s"
,
error
->
message
);
}
}
// Implements GtkWidget::size-allocate.
...
...
@@ -263,8 +269,9 @@ static gboolean fl_view_button_press_event(GtkWidget* widget,
// Flutter doesn't handle double and triple click events.
if
(
event
->
type
==
GDK_DOUBLE_BUTTON_PRESS
||
event
->
type
==
GDK_TRIPLE_BUTTON_PRESS
)
event
->
type
==
GDK_TRIPLE_BUTTON_PRESS
)
{
return
FALSE
;
}
return
fl_view_send_pointer_button_event
(
self
,
event
);
}
...
...
@@ -298,8 +305,8 @@ static gboolean fl_view_scroll_event(GtkWidget* widget, GdkEventScroll* event) {
scroll_delta_x
=
1
;
}
// TODO
: See if this can be queried from the OS; this value is chosen
// arbitrarily to get something that feels reasonable.
// TODO
(robert-ancell): See if this can be queried from the OS; this value is
//
chosen
arbitrarily to get something that feels reasonable.
const
int
kScrollOffsetMultiplier
=
20
;
scroll_delta_x
*=
kScrollOffsetMultiplier
;
scroll_delta_y
*=
kScrollOffsetMultiplier
;
...
...
@@ -319,8 +326,9 @@ static gboolean fl_view_motion_notify_event(GtkWidget* widget,
GdkEventMotion
*
event
)
{
FlView
*
self
=
FL_VIEW
(
widget
);
if
(
self
->
engine
==
nullptr
)
if
(
self
->
engine
==
nullptr
)
{
return
FALSE
;
}
gint
scale_factor
=
gtk_widget_get_scale_factor
(
GTK_WIDGET
(
self
));
fl_engine_send_mouse_pointer_event
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录