Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
34 changes: 32 additions & 2 deletions shell/platform/tizen/channels/platform_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@

#include <app.h>

#include <map>

#include "flutter/shell/platform/common/cpp/json_method_codec.h"
#include "flutter/shell/platform/tizen/tizen_log.h"

static constexpr char kChannelName[] = "flutter/platform";

PlatformChannel::PlatformChannel(flutter::BinaryMessenger* messenger)
PlatformChannel::PlatformChannel(flutter::BinaryMessenger* messenger,
TizenRenderer* renderer)
: channel_(std::make_unique<flutter::MethodChannel<rapidjson::Document>>(
messenger, kChannelName, &flutter::JsonMethodCodec::GetInstance())) {
channel_->SetMethodCallHandler(
Expand All @@ -20,6 +23,8 @@ PlatformChannel::PlatformChannel(flutter::BinaryMessenger* messenger)
std::unique_ptr<flutter::MethodResult<rapidjson::Document>> result) {
HandleMethodCall(call, std::move(result));
});
// renderer pointer is managed by TizenEmbedderEngine
tizen_renderer = renderer;
}

PlatformChannel::~PlatformChannel() {}
Expand All @@ -43,7 +48,32 @@ void PlatformChannel::HandleMethodCall(
} else if (method == "Clipboard.hasStrings") {
result->NotImplemented();
} else if (method == "SystemChrome.setPreferredOrientations") {
result->NotImplemented();
const std::string kPortraitUp = "DeviceOrientation.portraitUp";
const std::string kPortraitDown = "DeviceOrientation.portraitDown";
const std::string kLandscapeLeft = "DeviceOrientation.landscapeLeft";
const std::string kLandscapeRight = "DeviceOrientation.landscapeRight";
const std::map<std::string, int> orientation_mapping = {
{kPortraitUp, 0},
{kLandscapeLeft, 90},
{kPortraitDown, 180},
{kLandscapeRight, 270},
};
Comment thread
pkosko marked this conversation as resolved.
Outdated

const auto& list = call.arguments()[0];
std::vector<int> rotations;
for (rapidjson::Value::ConstValueIterator itr = list.Begin();
Comment thread
pkosko marked this conversation as resolved.
Outdated
itr != list.End(); ++itr) {
rotations.push_back(orientation_mapping.at(itr->GetString()));
}
if (rotations.size() == 0) {
// According do docs
// https://api.flutter.dev/flutter/services/SystemChrome/setPreferredOrientations.html
// "The empty list causes the application to defer to the operating system
// default."
rotations = {0, 90, 180, 270};
}
tizen_renderer->SetPreferredOrientations(rotations);
result->Success();
} else if (method == "SystemChrome.setApplicationSwitcherDescription") {
result->NotImplemented();
} else if (method == "SystemChrome.setEnabledSystemUIOverlays") {
Expand Down
5 changes: 4 additions & 1 deletion shell/platform/tizen/channels/platform_channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@

#include "flutter/shell/platform/common/cpp/client_wrapper/include/flutter/binary_messenger.h"
#include "flutter/shell/platform/common/cpp/client_wrapper/include/flutter/method_channel.h"
#include "flutter/shell/platform/tizen/tizen_renderer.h"
#include "rapidjson/document.h"

class PlatformChannel {
public:
explicit PlatformChannel(flutter::BinaryMessenger* messenger);
explicit PlatformChannel(flutter::BinaryMessenger* messenger,
TizenRenderer* renderer);
virtual ~PlatformChannel();

private:
std::unique_ptr<flutter::MethodChannel<rapidjson::Document>> channel_;
TizenRenderer* tizen_renderer;
Comment thread
pkosko marked this conversation as resolved.
Outdated

void HandleMethodCall(
const flutter::MethodCall<rapidjson::Document>& call,
Expand Down
2 changes: 1 addition & 1 deletion shell/platform/tizen/tizen_embedder_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ bool TizenEmbedderEngine::RunEngine(
navigation_channel = std::make_unique<NavigationChannel>(
internal_plugin_registrar_->messenger());
platform_channel = std::make_unique<PlatformChannel>(
internal_plugin_registrar_->messenger());
internal_plugin_registrar_->messenger(), tizen_renderer.get());
Comment thread
pkosko marked this conversation as resolved.
settings_channel = std::make_unique<SettingsChannel>(
internal_plugin_registrar_->messenger());
text_input_channel = std::make_unique<TextInputChannel>(
Expand Down
2 changes: 2 additions & 0 deletions shell/platform/tizen/tizen_renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#define EMBEDDER_TIZEN_RENDERER_H

#include <cstdint>
#include <vector>

class TizenRenderer {
public:
Expand Down Expand Up @@ -36,6 +37,7 @@ class TizenRenderer {
virtual void SetRotate(int angle) = 0;
virtual void ResizeWithRotation(int32_t x, int32_t y, int32_t width,
int32_t height, int32_t degree) = 0;
virtual void SetPreferredOrientations(std::vector<int> rotations) = 0;
Comment thread
pkosko marked this conversation as resolved.
Outdated

protected:
explicit TizenRenderer(TizenRenderer::Delegate& delegate);
Expand Down
6 changes: 6 additions & 0 deletions shell/platform/tizen/tizen_renderer_ecore_wl2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -585,3 +585,9 @@ void TizenRendererEcoreWl2::SendRotationChangeDone() {
ecore_wl2_window_, ecore_wl2_window_rotation_get(ecore_wl2_window_), w,
h);
}

void TizenRendererEcoreWl2::SetPreferredOrientations(
std::vector<int> rotations) {
ecore_wl2_window_available_rotations_set(ecore_wl2_window_, rotations.data(),
rotations.size());
}
1 change: 1 addition & 0 deletions shell/platform/tizen/tizen_renderer_ecore_wl2.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class TizenRendererEcoreWl2 : public TizenRenderer {
void ResizeWithRotation(int32_t x, int32_t y, int32_t width, int32_t height,
int32_t angle) override;
void SetRotate(int angle) override;
void SetPreferredOrientations(std::vector<int> rotations) override;

private:
bool InitializeRenderer();
Expand Down
5 changes: 5 additions & 0 deletions shell/platform/tizen/tizen_renderer_evas_gl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -709,3 +709,8 @@ void TizenRendererEvasGL::ResizeWithRotation(int32_t x, int32_t y,
void TizenRendererEvasGL::SendRotationChangeDone() {
elm_win_wm_rotation_manual_rotation_done(evas_window_);
}

void TizenRendererEvasGL::SetPreferredOrientations(std::vector<int> rotations) {
elm_win_wm_rotation_available_rotations_set(
evas_window_, (const int*)(rotations.data()), rotations.size());
Comment thread
pkosko marked this conversation as resolved.
Outdated
}
1 change: 1 addition & 0 deletions shell/platform/tizen/tizen_renderer_evas_gl.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class TizenRendererEvasGL : public TizenRenderer {
void ResizeWithRotation(int32_t x, int32_t y, int32_t width, int32_t height,
int32_t angle) override;
void SetRotate(int angle) override;
void SetPreferredOrientations(std::vector<int> rotations) override;

void* GetImageHandle();

Expand Down