Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
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
18 changes: 15 additions & 3 deletions flutter/shell/platform/tizen/flutter_tizen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -167,15 +167,27 @@ void FlutterDesktopEngineNotifyLowMemoryWarning(
}

void FlutterDesktopEngineNotifyAppIsInactive(FlutterDesktopEngineRef engine) {
EngineFromHandle(engine)->lifecycle_channel()->AppIsInactive();
flutter::FlutterTizenEngine* tizen_engine = EngineFromHandle(engine);
tizen_engine->lifecycle_channel()->AppIsInactive();
if (tizen_engine->view()) {
tizen_engine->view()->OnFocus(kUnfocused);
}
}

void FlutterDesktopEngineNotifyAppIsResumed(FlutterDesktopEngineRef engine) {
EngineFromHandle(engine)->lifecycle_channel()->AppIsResumed();
flutter::FlutterTizenEngine* tizen_engine = EngineFromHandle(engine);
tizen_engine->lifecycle_channel()->AppIsResumed();
if (tizen_engine->view()) {
tizen_engine->view()->OnFocus(kFocused);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve focus-skip windows as unfocused

When FlutterDesktopWindowProperties.focusable is false, TizenWindowEcoreWl2::SetWindowOptions marks the native window with ecore_wl2_window_focus_skip_set(..., EINA_TRUE), so the app can resume while this view is intentionally unable to receive platform focus. This unconditional kFocused event makes PlatformDispatcher.onViewFocusChange report focus for those overlay/background windows even though native key focus remains elsewhere; gate this on the window's actual/focusable state rather than app resume alone.

Useful? React with 👍 / 👎.

}
}

void FlutterDesktopEngineNotifyAppIsPaused(FlutterDesktopEngineRef engine) {
EngineFromHandle(engine)->lifecycle_channel()->AppIsPaused();
flutter::FlutterTizenEngine* tizen_engine = EngineFromHandle(engine);
tizen_engine->lifecycle_channel()->AppIsPaused();
if (tizen_engine->view()) {
tizen_engine->view()->OnFocus(kUnfocused);
}
}

void FlutterDesktopEngineNotifyAppIsDetached(FlutterDesktopEngineRef engine) {
Expand Down
14 changes: 14 additions & 0 deletions flutter/shell/platform/tizen/flutter_tizen_engine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,13 @@ bool FlutterTizenEngine::RunEngine() {
auto* engine = static_cast<FlutterTizenEngine*>(user_data);
engine->OnUpdateSemantics(update);
};
args.view_focus_change_request_callback =
[](const FlutterViewFocusChangeRequest* request, void* user_data) {
auto* engine = static_cast<FlutterTizenEngine*>(user_data);
if (engine->view()) {
engine->view()->OnFocusChangeRequest(*request);
}
};

if (IsHeaded() && dynamic_cast<TizenRendererEgl*>(renderer_.get())) {
vsync_waiter_ = std::make_unique<TizenVsyncWaiter>(this);
Expand Down Expand Up @@ -341,6 +348,13 @@ void FlutterTizenEngine::SendPointerEvent(const FlutterPointerEvent& event) {
embedder_api_.SendPointerEvent(engine_, &event, 1);
}

void FlutterTizenEngine::SendViewFocusEvent(
const FlutterViewFocusEvent& event) {
if (engine_) {
embedder_api_.SendViewFocusEvent(engine_, &event);
}
}

void FlutterTizenEngine::SendWindowMetrics(int32_t x,
int32_t y,
int32_t width,
Expand Down
3 changes: 3 additions & 0 deletions flutter/shell/platform/tizen/flutter_tizen_engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ class FlutterTizenEngine {
// Informs the engine of an incoming pointer event.
void SendPointerEvent(const FlutterPointerEvent& event);

// Informs the engine of a native view focus change.
void SendViewFocusEvent(const FlutterViewFocusEvent& event);

// Sends a window metrics update to the Flutter engine using current window
// dimensions in physical
void SendWindowMetrics(int32_t x,
Expand Down
27 changes: 27 additions & 0 deletions flutter/shell/platform/tizen/flutter_tizen_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,33 @@ void FlutterTizenView::OnRotate(int32_t degree) {
SendWindowMetrics(geometry.left, geometry.top, width, height, 0.0);
}

void FlutterTizenView::OnFocus(FlutterViewFocusState focus_state) {
if (focus_state == kFocused) {
auto* window = dynamic_cast<TizenWindow*>(tizen_view_.get());
if (window && !window->focusable()) {
return;
}
}
FlutterViewFocusEvent event = {};
event.struct_size = sizeof(event);
event.view_id = view_id_;
event.state = focus_state;
event.direction = FlutterViewFocusDirection::kUndefined;
engine_->SendViewFocusEvent(event);
}

void FlutterTizenView::OnFocusChangeRequest(
const FlutterViewFocusChangeRequest& request) {
if (request.view_id != view_id_ || request.state != kFocused) {
return;
}
if (auto* window = dynamic_cast<TizenWindow*>(tizen_view_.get())) {
if (window->focusable()) {
window->ActivateWindow();
}
}
}

FlutterTizenView::PointerState* FlutterTizenView::GetOrCreatePointerState(
FlutterPointerDeviceKind device_kind,
int32_t device_id) {
Expand Down
4 changes: 4 additions & 0 deletions flutter/shell/platform/tizen/flutter_tizen_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ class FlutterTizenView : public TizenViewEventHandlerDelegate {

void OnRotate(int32_t degree) override;

void OnFocus(FlutterViewFocusState focus_state);

void OnFocusChangeRequest(const FlutterViewFocusChangeRequest& request);

void OnPointerMove(double x,
double y,
size_t timestamp,
Expand Down
2 changes: 2 additions & 0 deletions flutter/shell/platform/tizen/tizen_window.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ class TizenWindow : public TizenViewBase {

virtual void LowerWindow() = 0;

bool focusable() { return focusable_; }

protected:
explicit TizenWindow(TizenGeometry geometry,
bool transparent,
Expand Down
Loading