Skip to content

Commit

Permalink
Remove device_profile (flutter-tizen#131)
Browse files Browse the repository at this point in the history
* Remove device_profile

* Remove flutter:: from key_event_channel.cc

* Remove system_info dependency
  • Loading branch information
swift-kim authored Jul 2, 2021
1 parent 79020af commit 044ba9f
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 54 deletions.
1 change: 0 additions & 1 deletion shell/platform/tizen/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ template("embedder_for_profile") {
"base-utils-i18n",
"capi-appfw-application",
"capi-base-common",
"capi-system-info",
"capi-system-system-settings",
"dlog",
"ecore",
Expand Down
4 changes: 2 additions & 2 deletions shell/platform/tizen/channels/key_event_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,8 @@ void KeyEventChannel::SendKeyEvent(Ecore_Event_Key* key,
channel_->Send(event, [callback = std::move(callback)](const uint8_t* reply,
size_t reply_size) {
if (reply != nullptr) {
auto decoded = flutter::JsonMessageCodec::GetInstance().DecodeMessage(
reply, reply_size);
auto decoded =
JsonMessageCodec::GetInstance().DecodeMessage(reply, reply_size);
bool handled = (*decoded)[kHandledKey].GetBool();
callback(handled);
}
Expand Down
22 changes: 12 additions & 10 deletions shell/platform/tizen/channels/text_input_channel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -424,13 +424,13 @@ bool TextInputChannel::FilterEvent(Ecore_Event_Key* event) {
imf_event.dev_name = is_ime ? "ime" : "";
imf_event.keycode = event->keycode;

#ifdef WEARABLE_PROFILE
// FIXME: Only for wearable.
if (is_ime && strcmp(event->key, "Select") == 0) {
if (engine_->device_profile == DeviceProfile::kWearable) {
// FIXME: for wearable
in_select_mode_ = true;
FT_LOGI("Set select mode[true]");
}
in_select_mode_ = true;
FT_LOGI("Set select mode[true]");
}
#endif

if (is_ime) {
if (!strcmp(event->key, "Left") || !strcmp(event->key, "Right") ||
Expand All @@ -457,24 +457,26 @@ bool TextInputChannel::FilterEvent(Ecore_Event_Key* event) {
last_handled_ecore_event_keyname_ = event->keyname;
}

if (!handled && !strcmp(event->key, "Return") && in_select_mode_ &&
engine_->device_profile == DeviceProfile::kWearable) {
#ifdef WEARABLE_PROFILE
if (!handled && !strcmp(event->key, "Return") && in_select_mode_) {
in_select_mode_ = false;
handled = true;
FT_LOGI("Set select mode[false]");
}
#endif

return handled;
}

void TextInputChannel::NonIMFFallback(Ecore_Event_Key* event) {
// For mobile, fix me!
if (engine_->device_profile == DeviceProfile::kMobile &&
edit_status_ == EditStatus::kPreeditEnd) {
#ifdef MOBILE_PROFILE
// FIXME: Only for mobile.
if (edit_status_ == EditStatus::kPreeditEnd) {
SetEditStatus(EditStatus::kNone);
FT_LOGW("Ignore key-event[%s]!", event->keyname);
return;
}
#endif

bool select = !strcmp(event->key, "Select");
bool is_filtered = true;
Expand Down
59 changes: 22 additions & 37 deletions shell/platform/tizen/flutter_tizen_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,43 +5,35 @@

#include "flutter_tizen_engine.h"

#include <system_info.h>

#include <filesystem>
#include <string>
#include <vector>

#include "flutter/shell/platform/tizen/tizen_log.h"

namespace flutter {

namespace {

// Unique number associated with platform tasks.
static constexpr size_t kPlatformTaskRunnerIdentifier = 1;
constexpr size_t kPlatformTaskRunnerIdentifier = 1;
#ifdef TIZEN_RENDERER_EVAS_GL
static constexpr size_t kRenderTaskRunnerIdentifier = 2;
constexpr size_t kRenderTaskRunnerIdentifier = 2;
#endif

namespace flutter {
#if defined(MOBILE_PROFILE)
constexpr double kProfileFactor = 0.7;
#elif defined(WEARABLE_PROFILE)
constexpr double kProfileFactor = 0.4;
#elif defined(TV_PROFILE)
constexpr double kProfileFactor = 2.0;
#else
constexpr double kProfileFactor = 1.0;
#endif

static DeviceProfile GetDeviceProfile() {
char* feature_profile;
system_info_get_platform_string("http://tizen.org/feature/profile",
&feature_profile);
std::string profile(feature_profile);
free(feature_profile);

if (profile == "mobile") {
return DeviceProfile::kMobile;
} else if (profile == "wearable") {
return DeviceProfile::kWearable;
} else if (profile == "tv") {
return DeviceProfile::kTV;
} else if (profile == "common") {
return DeviceProfile::kCommon;
}
return DeviceProfile::kUnknown;
}
} // namespace

FlutterTizenEngine::FlutterTizenEngine(bool headed)
: device_profile(GetDeviceProfile()) {
FlutterTizenEngine::FlutterTizenEngine(bool headed) {
embedder_api_.struct_size = sizeof(FlutterEngineProcTable);
FlutterEngineGetProcAddresses(&embedder_api_);

Expand Down Expand Up @@ -342,19 +334,12 @@ void FlutterTizenEngine::SendWindowMetrics(int32_t width,
// The scale factor is computed based on the display DPI and the current
// profile. A fixed DPI value (72) is used on TVs. See:
// https://docs.tizen.org/application/native/guides/ui/efl/multiple-screens
#ifdef TV_PROFILE
double dpi = 72.0;
if (renderer && device_profile != DeviceProfile::kTV) {
dpi = static_cast<double>(renderer->GetDpi());
}
double profile_factor = 1.0;
if (device_profile == DeviceProfile::kWearable) {
profile_factor = 0.4;
} else if (device_profile == DeviceProfile::kMobile) {
profile_factor = 0.7;
} else if (device_profile == DeviceProfile::kTV) {
profile_factor = 2.0;
}
double scale_factor = dpi / 90.0 * profile_factor;
#else
double dpi = static_cast<double>(renderer->GetDpi());
#endif
double scale_factor = dpi / 90.0 * kProfileFactor;
event.pixel_ratio = std::max(scale_factor, 1.0);
} else {
event.pixel_ratio = pixel_ratio;
Expand Down
4 changes: 0 additions & 4 deletions shell/platform/tizen/flutter_tizen_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ struct AOTDataDeleter {

using UniqueAotDataPtr = std::unique_ptr<_FlutterEngineAOTData, AOTDataDeleter>;

enum DeviceProfile { kUnknown, kMobile, kWearable, kTV, kCommon };

// Manages state associated with the underlying FlutterEngine.
class FlutterTizenEngine : public TizenRenderer::Delegate {
public:
Expand Down Expand Up @@ -140,8 +138,6 @@ class FlutterTizenEngine : public TizenRenderer::Delegate {
std::unique_ptr<TextInputChannel> text_input_channel;
std::unique_ptr<PlatformViewChannel> platform_view_channel;

const DeviceProfile device_profile;

private:
bool IsHeaded() { return renderer != nullptr; }
UniqueAotDataPtr LoadAotData(std::string aot_data_path);
Expand Down

0 comments on commit 044ba9f

Please sign in to comment.