-
Notifications
You must be signed in to change notification settings - Fork 6k
Add platform view support for Linux shell #24169
Add platform view support for Linux shell #24169
Conversation
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat. If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
f30bd85 to
d4cdf91
Compare
d4cdf91 to
2bc8aaf
Compare
|
@robert-ancell @wmww |
| button.button.button = event->button; | ||
| button.button.device = event->device; | ||
| button.button.x_root = event->x_root; | ||
| button.button.y_root = event->y_root; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason to copy each field individually instead of copying the whole event and making required adjustments? Seems to me like the latter would have less opportunities for subtle errors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
| int64_t id) { | ||
| gpointer p = g_hash_table_lookup(self->platform_views, GINT_TO_POINTER(id)); | ||
| if (p && FL_IS_PLATFORM_VIEW(p)) { | ||
| return FL_PLATFORM_VIEW(p); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the FL_IS_PLATFORM_VIEW() check necessary? Will it ever be anything other than null or a platform view? Even if it is, the FL_PLATFORM_VIEW() cast should return null in that case (it would just print an error as well).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
| return FL_METHOD_RESPONSE(fl_method_error_response_new( | ||
| kBadArgumentsError, "View type does not exist", nullptr)); | ||
| } | ||
| FlPlatformViewFactory* factory = FL_PLATFORM_VIEW_FACTORY(factory_pointer); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This probably won't fail, but it can't hurt to move the FL_PLATFORM_VIEW_FACTORY() cast to above the check and then check if factory exists, rather than checking factory_pointer (assuming that factory shouldn't ever be null)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
| static FlMethodResponse* platform_views_accept_gesture( | ||
| FlPlatformViewsPlugin* self, | ||
| FlValue* args) { | ||
| if (fl_value_get_type(args) != FL_VALUE_TYPE_LIST) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps we should also check if the list has the expected number of elements?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
| FlPlatformViewsPlugin* self, | ||
| int view_identifier) { | ||
| return (FlPlatformView*)g_hash_table_lookup(self->platform_views, | ||
| GINT_TO_POINTER(view_identifier)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be a safe FL_PLATFORM_VIEW() cast?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's safe, because we have checked its type in platform_views_create before inserting it into platform_views.
| /** | ||
| * fl_platform_views_plugin_new: | ||
| * @messenger: an #FlBinaryMessenger. | ||
| * @gesture_helper: an #FlGestureHelper for accepting gestures by Dart side. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I said in the other comment, ownership of gesture_helper is unclear to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
wmww
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
|
It's unclear who the owner of this PR is. Does this need additional reviews or can we land this? cc @cbracken. |
The native implementation and interfaces are approved by wmww. Because I have added logics to deal with messages from framework side channel |
|
Thanks for the clarification. The framework patch does seem to be being actively reviewed. Once that is good to go, we can land this as well. |
e92cef5 to
098a052
Compare
098a052 to
d81f161
Compare
|
A reviewer was added to the framework patch but it hasn't landed yet. @goderbauer Is there anything we can do to expedite that review? This patch has been pending for close to a month. |
|
@gspencergoog This is the engine patch for flutter/flutter#74814. Are we able to find a reviewer for this? |
|
@chinmaygarde: working on it. @cbracken is going to take a look, and we think @cyanglaz might be a good candidate to review, if he's up for it. |
|
|
@iskakaushik and @robert-ancell I believe this is ready for another review. |
|
@huanghongxun please remove the gesture helper and do in a following PR as requested by @iskakaushik. If there's anything else you can split out, that will help a lot. These PRs are really big and that makes them slow to review. I would much prefer to review 3 smaller PRs in a row than one big one and that will be faster. |
|
@robert-ancell I have proposed #26288 with all requested changes resolved. |
|
@huanghongxun Since this PR has not been updated in quite some time, I am going to close it as presumed stale. |
|
I don't know about others but I have been waiting so long for this PR. What's remaining? Address code reviews? Split the pull request? If @huanghongxun doesn't have time, maybe I can help. In my opinion, getting webview to work on flutter desktop should be a priority for the Flutter team. I'm puzzled why is not? |
|
Thank you @huanghongxun |
This pull request is part of #23985. For framework API, see flutter/flutter#74814.
This pull request adds platform view API to Linux shell.
Code changes:
FlGestureHelperfor accepting gesture, redistributing press, release and motion events to platform view. Because only Flutter framework knows about whether we can touch and operate with the platform view by hit test. If Flutter framework accepts a gesture,FlGestureHelperwill send following pointer events to GtkWidget. For hover events, If Flutter framework has notified enter and exit event,FlGestureHelperwill also send pointer hover event (or GdkEventMotion) to platform view.FlPlatformViewto wrap a GtkWidget, owned byFlPlatformViewsPlugin. This abstraction allows us to owning aFlMethodChannelinFlPlatformViewfor communication with dart codes.FlPlatformViewFactoryfor creating platform views for specific view type. Flutter Framework will call functions ofFlPlatformViewFactorywhen creating a new platform view.FlPlatformViewsPluginfor implementingSystemChannels.platform_viewsfrom Flutter services library.A working demo with webview: https://github.com/wechat-miniprogram/gtktest.
This pr does not support applying mutations on the platform views yet. I will open a PR later to implement that feature.
This pr is part of platform view implementation on Linux, related issue: flutter/flutter#41724.
Pre-launch Checklist
writing and running engine tests.
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.