From ca56b156ffa9234fc7a14b6086583e564e959d0e Mon Sep 17 00:00:00 2001 From: JunsuChoi Date: Thu, 22 Sep 2022 11:29:40 +0900 Subject: [PATCH 1/3] Add getter and setter of focused state of TizenView and change Unfocus() method to SetFocus(). --- .../tizen/channels/platform_channel.cc | 2 +- shell/platform/tizen/flutter_tizen.cc | 22 +++++++++++++++++++ shell/platform/tizen/public/flutter_tizen.h | 5 +++++ shell/platform/tizen/tizen_view.h | 4 +++- 4 files changed, 31 insertions(+), 2 deletions(-) diff --git a/shell/platform/tizen/channels/platform_channel.cc b/shell/platform/tizen/channels/platform_channel.cc index 62d6f2e625982..2dd575ac1f83c 100644 --- a/shell/platform/tizen/channels/platform_channel.cc +++ b/shell/platform/tizen/channels/platform_channel.cc @@ -161,7 +161,7 @@ void PlatformChannel::SystemNavigatorPop() { if (view_->GetType() == TizenViewType::kWindow) { ui_app_exit(); } else { - reinterpret_cast(view_)->Unfocus(); + reinterpret_cast(view_)->SetFocus(false); } } diff --git a/shell/platform/tizen/flutter_tizen.cc b/shell/platform/tizen/flutter_tizen.cc index 6907e68f8d06b..bbe56a766e399 100644 --- a/shell/platform/tizen/flutter_tizen.cc +++ b/shell/platform/tizen/flutter_tizen.cc @@ -13,6 +13,7 @@ #include "flutter/shell/platform/tizen/flutter_tizen_view.h" #include "flutter/shell/platform/tizen/logger.h" #include "flutter/shell/platform/tizen/public/flutter_platform_view.h" +#include "flutter/shell/platform/tizen/tizen_view.h" #include "flutter/shell/platform/tizen/tizen_window.h" #ifndef WEARABLE_PROFILE #include "flutter/shell/platform/tizen/tizen_window_ecore_wl2.h" @@ -274,6 +275,27 @@ void FlutterDesktopViewOnKeyEvent(FlutterDesktopViewRef view, is_down); } +void FlutterDesktopViewSetFocus(FlutterDesktopViewRef view_ref, bool focus) { + flutter::FlutterTizenView* view = ViewFromHandle(view_ref); + auto* tizen_view_base = + reinterpret_cast(view->tizen_view()); + if (tizen_view_base->GetType() == flutter::TizenViewType::kView) { + auto* tizen_view = reinterpret_cast(tizen_view_base); + tizen_view->SetFocus(focus); + } +} + +bool FlutterDesktopViewIsFocused(FlutterDesktopViewRef view_ref) { + flutter::FlutterTizenView* view = ViewFromHandle(view_ref); + auto* tizen_view_base = + reinterpret_cast(view->tizen_view()); + if (tizen_view_base->GetType() == flutter::TizenViewType::kView) { + auto* tizen_view = reinterpret_cast(tizen_view_base); + return tizen_view->focused(); + } + return false; +} + void FlutterDesktopRegisterViewFactory( FlutterDesktopPluginRegistrarRef registrar, const char* view_type, diff --git a/shell/platform/tizen/public/flutter_tizen.h b/shell/platform/tizen/public/flutter_tizen.h index 2597014b2b8c8..3f0ea8b0263d1 100644 --- a/shell/platform/tizen/public/flutter_tizen.h +++ b/shell/platform/tizen/public/flutter_tizen.h @@ -216,6 +216,11 @@ FLUTTER_EXPORT void FlutterDesktopViewOnKeyEvent(FlutterDesktopViewRef view, uint32_t scan_code, bool is_down); +FLUTTER_EXPORT void FlutterDesktopViewSetFocus(FlutterDesktopViewRef view, + bool focus); + +FLUTTER_EXPORT bool FlutterDesktopViewIsFocused(FlutterDesktopViewRef view); + // ========== Plugin Registrar (extensions) ========== // Returns the view associated with this registrar's engine instance. diff --git a/shell/platform/tizen/tizen_view.h b/shell/platform/tizen/tizen_view.h index 066ed8d3fd3d4..5556dcb86969a 100644 --- a/shell/platform/tizen/tizen_view.h +++ b/shell/platform/tizen/tizen_view.h @@ -20,7 +20,9 @@ class TizenView : public TizenViewBase { TizenViewType GetType() override { return TizenViewType::kView; }; - void Unfocus() { focused_ = false; }; + bool focused() { return focused_; }; + + void SetFocus(bool focus) { focused_ = focus; }; protected: explicit TizenView(int32_t width, int32_t height) From 929a0a6a5cbb61a7a6205546408d1b1edd57852c Mon Sep 17 00:00:00 2001 From: JunsuChoi Date: Tue, 27 Sep 2022 14:22:04 +0900 Subject: [PATCH 2/3] Update based on review --- shell/platform/tizen/flutter_tizen.cc | 24 +++++++++------------ shell/platform/tizen/public/flutter_tizen.h | 2 +- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/shell/platform/tizen/flutter_tizen.cc b/shell/platform/tizen/flutter_tizen.cc index bbe56a766e399..a41b0b9202362 100644 --- a/shell/platform/tizen/flutter_tizen.cc +++ b/shell/platform/tizen/flutter_tizen.cc @@ -275,23 +275,19 @@ void FlutterDesktopViewOnKeyEvent(FlutterDesktopViewRef view, is_down); } -void FlutterDesktopViewSetFocus(FlutterDesktopViewRef view_ref, bool focus) { - flutter::FlutterTizenView* view = ViewFromHandle(view_ref); - auto* tizen_view_base = - reinterpret_cast(view->tizen_view()); - if (tizen_view_base->GetType() == flutter::TizenViewType::kView) { - auto* tizen_view = reinterpret_cast(tizen_view_base); - tizen_view->SetFocus(focus); +void FlutterDesktopViewSetFocus(FlutterDesktopViewRef view, bool focused) { + auto* tizen_view = reinterpret_cast( + ViewFromHandle(view)->tizen_view()); + if (tizen_view->GetType() == flutter::TizenViewType::kView) { + reinterpret_cast(tizen_view)->SetFocus(focused); } } -bool FlutterDesktopViewIsFocused(FlutterDesktopViewRef view_ref) { - flutter::FlutterTizenView* view = ViewFromHandle(view_ref); - auto* tizen_view_base = - reinterpret_cast(view->tizen_view()); - if (tizen_view_base->GetType() == flutter::TizenViewType::kView) { - auto* tizen_view = reinterpret_cast(tizen_view_base); - return tizen_view->focused(); +bool FlutterDesktopViewIsFocused(FlutterDesktopViewRef view) { + auto* tizen_view = reinterpret_cast( + ViewFromHandle(view)->tizen_view()); + if (tizen_view->GetType() == flutter::TizenViewType::kView) { + return reinterpret_cast(tizen_view)->focused(); } return false; } diff --git a/shell/platform/tizen/public/flutter_tizen.h b/shell/platform/tizen/public/flutter_tizen.h index 3f0ea8b0263d1..23b4d3767193d 100644 --- a/shell/platform/tizen/public/flutter_tizen.h +++ b/shell/platform/tizen/public/flutter_tizen.h @@ -217,7 +217,7 @@ FLUTTER_EXPORT void FlutterDesktopViewOnKeyEvent(FlutterDesktopViewRef view, bool is_down); FLUTTER_EXPORT void FlutterDesktopViewSetFocus(FlutterDesktopViewRef view, - bool focus); + bool focused); FLUTTER_EXPORT bool FlutterDesktopViewIsFocused(FlutterDesktopViewRef view); From 0042ed4afd5d8926803cbd08248a1729a7164b65 Mon Sep 17 00:00:00 2001 From: JunsuChoi Date: Tue, 27 Sep 2022 14:59:22 +0900 Subject: [PATCH 3/3] Fix name --- shell/platform/tizen/tizen_view.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/platform/tizen/tizen_view.h b/shell/platform/tizen/tizen_view.h index 5556dcb86969a..d9979632c634e 100644 --- a/shell/platform/tizen/tizen_view.h +++ b/shell/platform/tizen/tizen_view.h @@ -22,7 +22,7 @@ class TizenView : public TizenViewBase { bool focused() { return focused_; }; - void SetFocus(bool focus) { focused_ = focus; }; + void SetFocus(bool focused) { focused_ = focused; }; protected: explicit TizenView(int32_t width, int32_t height)