forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 17
Add window channel #201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
swift-kim
merged 7 commits into
flutter-tizen:flutter-2.5.1-tizen
from
HakkyuKim:flutter-2.5.1-add-window-channel
Nov 9, 2021
Merged
Add window channel #201
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
828416e
Add window channel
HakkyuKim 423a9c5
Obtain real screen size
HakkyuKim a61f3fd
Rename some namings
HakkyuKim 84e3413
Move SetGeometry to TizenRender to remove macros
HakkyuKim 4a95961
Finish resolving previous conflict
HakkyuKim 5edc836
Suppress unused private field warning
HakkyuKim 3922988
Explicitly initialize with zeros
HakkyuKim File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| // Copyright 2021 Samsung Electronics Co., Ltd. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| #pragma clang diagnostic push | ||
| #pragma clang diagnostic ignored "-Wunused-private-field" | ||
| #include "window_channel.h" | ||
| #pragma clang diagnostic pop | ||
|
|
||
| #include "flutter/shell/platform/common/client_wrapper/include/flutter/standard_method_codec.h" | ||
| #include "flutter/shell/platform/tizen/channels/encodable_value_holder.h" | ||
| #include "flutter/shell/platform/tizen/logger.h" | ||
|
|
||
| namespace flutter { | ||
|
|
||
| namespace { | ||
|
|
||
| constexpr char kChannelName[] = "tizen/internal/window"; | ||
|
|
||
| } // namespace | ||
|
|
||
| WindowChannel::WindowChannel(BinaryMessenger* messenger, | ||
| TizenRenderer* renderer, | ||
| TizenRenderer::Delegate* delegate) | ||
| : renderer_(renderer), delegate_(delegate) { | ||
| channel_ = std::make_unique<MethodChannel<EncodableValue>>( | ||
| messenger, kChannelName, &StandardMethodCodec::GetInstance()); | ||
| channel_->SetMethodCallHandler([this](const auto& call, auto result) { | ||
| this->HandleMethodCall(call, std::move(result)); | ||
| }); | ||
| } | ||
|
|
||
| WindowChannel::~WindowChannel() {} | ||
|
|
||
| void WindowChannel::HandleMethodCall( | ||
| const MethodCall<EncodableValue>& method_call, | ||
| std::unique_ptr<MethodResult<EncodableValue>> result) { | ||
| const auto& method_name = method_call.method_name(); | ||
|
|
||
| if (method_name == "getWindowGeometry") { | ||
| TizenRenderer::Geometry geometry = renderer_->GetWindowGeometry(); | ||
| EncodableMap map; | ||
| map[EncodableValue("x")] = EncodableValue(geometry.x); | ||
| map[EncodableValue("y")] = EncodableValue(geometry.y); | ||
| map[EncodableValue("width")] = EncodableValue(geometry.w); | ||
| map[EncodableValue("height")] = EncodableValue(geometry.h); | ||
| result->Success(EncodableValue(map)); | ||
| } else if (method_name == "setWindowGeometry") { | ||
| #ifdef TIZEN_RENDERER_EVAS_GL | ||
| FT_LOG(Error) << "setWindowGeometry is not supported on evas_gl."; | ||
| result->NotImplemented(); | ||
| #else | ||
| auto arguments = std::get_if<EncodableMap>(method_call.arguments()); | ||
| if (!arguments) { | ||
| result->Error("Invalid arguments"); | ||
| return; | ||
| } | ||
| EncodableValueHolder<int32_t> x(arguments, "x"); | ||
| EncodableValueHolder<int32_t> y(arguments, "y"); | ||
| EncodableValueHolder<int32_t> width(arguments, "width"); | ||
| EncodableValueHolder<int32_t> height(arguments, "height"); | ||
|
|
||
| TizenRenderer::Geometry geometry = renderer_->GetWindowGeometry(); | ||
|
|
||
| delegate_->OnGeometryChange(x ? *x : geometry.x, y ? *y : geometry.y, | ||
| width ? *width : geometry.w, | ||
| height ? *height : geometry.h); | ||
| result->Success(); | ||
| #endif | ||
| } else if (method_name == "getScreenGeometry") { | ||
| TizenRenderer::Geometry geometry = renderer_->GetScreenGeometry(); | ||
| EncodableMap map; | ||
| map[EncodableValue("width")] = EncodableValue(geometry.w); | ||
| map[EncodableValue("height")] = EncodableValue(geometry.h); | ||
| result->Success(EncodableValue(map)); | ||
| } else { | ||
| result->NotImplemented(); | ||
| } | ||
| } | ||
|
|
||
| } // namespace flutter |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| // Copyright 2021 Samsung Electronics Co., Ltd. All rights reserved. | ||
| // Use of this source code is governed by a BSD-style license that can be | ||
| // found in the LICENSE file. | ||
|
|
||
| #ifndef EMBEDDER_WINDOW_CHANNEL_H_ | ||
| #define EMBEDDER_WINDOW_CHANNEL_H_ | ||
|
|
||
| #include <memory> | ||
|
|
||
| #include "flutter/shell/platform/common/client_wrapper/include/flutter/binary_messenger.h" | ||
| #include "flutter/shell/platform/common/client_wrapper/include/flutter/encodable_value.h" | ||
| #include "flutter/shell/platform/common/client_wrapper/include/flutter/method_channel.h" | ||
| #include "flutter/shell/platform/tizen/tizen_renderer.h" | ||
|
|
||
| namespace flutter { | ||
|
|
||
| class WindowChannel { | ||
| public: | ||
| explicit WindowChannel(BinaryMessenger* messenger, | ||
| TizenRenderer* renderer, | ||
| TizenRenderer::Delegate* delegate); | ||
| virtual ~WindowChannel(); | ||
|
|
||
| private: | ||
| void HandleMethodCall(const MethodCall<EncodableValue>& method_call, | ||
| std::unique_ptr<MethodResult<EncodableValue>> result); | ||
|
|
||
| std::unique_ptr<MethodChannel<EncodableValue>> channel_; | ||
|
|
||
| // A reference to the renderer object managed by FlutterTizenEngine. | ||
| // This can be nullptr if the engine is running in headless mode. | ||
| TizenRenderer* renderer_; | ||
| TizenRenderer::Delegate* delegate_; | ||
| }; | ||
|
|
||
| } // namespace flutter | ||
|
|
||
| #endif // EMBEDDER_WINDOW_CHANNEL_H_ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.