Skip to content

Commit 819a825

Browse files
authored
Add IsFocused/SetFocus APIs to TizenView (#354)
* Add getter and setter of focused state of TizenView and change Unfocus() method to SetFocus(). * Update based on review * Fix name
1 parent f11f8f1 commit 819a825

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

shell/platform/tizen/channels/platform_channel.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ void PlatformChannel::SystemNavigatorPop() {
161161
if (view_->GetType() == TizenViewType::kWindow) {
162162
ui_app_exit();
163163
} else {
164-
reinterpret_cast<TizenView*>(view_)->Unfocus();
164+
reinterpret_cast<TizenView*>(view_)->SetFocus(false);
165165
}
166166
}
167167

shell/platform/tizen/flutter_tizen.cc

+18
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "flutter/shell/platform/tizen/flutter_tizen_view.h"
1414
#include "flutter/shell/platform/tizen/logger.h"
1515
#include "flutter/shell/platform/tizen/public/flutter_platform_view.h"
16+
#include "flutter/shell/platform/tizen/tizen_view.h"
1617
#include "flutter/shell/platform/tizen/tizen_window.h"
1718
#ifndef WEARABLE_PROFILE
1819
#include "flutter/shell/platform/tizen/tizen_window_ecore_wl2.h"
@@ -274,6 +275,23 @@ void FlutterDesktopViewOnKeyEvent(FlutterDesktopViewRef view,
274275
is_down);
275276
}
276277

278+
void FlutterDesktopViewSetFocus(FlutterDesktopViewRef view, bool focused) {
279+
auto* tizen_view = reinterpret_cast<flutter::TizenViewBase*>(
280+
ViewFromHandle(view)->tizen_view());
281+
if (tizen_view->GetType() == flutter::TizenViewType::kView) {
282+
reinterpret_cast<flutter::TizenView*>(tizen_view)->SetFocus(focused);
283+
}
284+
}
285+
286+
bool FlutterDesktopViewIsFocused(FlutterDesktopViewRef view) {
287+
auto* tizen_view = reinterpret_cast<flutter::TizenViewBase*>(
288+
ViewFromHandle(view)->tizen_view());
289+
if (tizen_view->GetType() == flutter::TizenViewType::kView) {
290+
return reinterpret_cast<flutter::TizenView*>(tizen_view)->focused();
291+
}
292+
return false;
293+
}
294+
277295
void FlutterDesktopRegisterViewFactory(
278296
FlutterDesktopPluginRegistrarRef registrar,
279297
const char* view_type,

shell/platform/tizen/public/flutter_tizen.h

+5
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,11 @@ FLUTTER_EXPORT void FlutterDesktopViewOnKeyEvent(FlutterDesktopViewRef view,
216216
uint32_t scan_code,
217217
bool is_down);
218218

219+
FLUTTER_EXPORT void FlutterDesktopViewSetFocus(FlutterDesktopViewRef view,
220+
bool focused);
221+
222+
FLUTTER_EXPORT bool FlutterDesktopViewIsFocused(FlutterDesktopViewRef view);
223+
219224
// ========== Plugin Registrar (extensions) ==========
220225

221226
// Returns the view associated with this registrar's engine instance.

shell/platform/tizen/tizen_view.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ class TizenView : public TizenViewBase {
2020

2121
TizenViewType GetType() override { return TizenViewType::kView; };
2222

23-
void Unfocus() { focused_ = false; };
23+
bool focused() { return focused_; };
24+
25+
void SetFocus(bool focused) { focused_ = focused; };
2426

2527
protected:
2628
explicit TizenView(int32_t width, int32_t height)

0 commit comments

Comments
 (0)