Skip to content

Fix point up event #100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
29 changes: 17 additions & 12 deletions flutter/shell/platform/tizen/flutter_tizen_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -231,15 +231,16 @@ FlutterTizenView::PointerState* FlutterTizenView::GetOrCreatePointerState(
}

FlutterPointerPhase FlutterTizenView::GetPointerPhaseFromState(
const PointerState* state) const {
bool is_button_down,
uint64_t button_type) const {
// For details about this logic, see FlutterPointerPhase in the embedder.h
// file.
if (state->buttons == 0) {
return state->flutter_state_is_down ? FlutterPointerPhase::kUp
: FlutterPointerPhase::kHover;
if (button_type == 0) {
return is_button_down ? FlutterPointerPhase::kUp
: FlutterPointerPhase::kHover;
} else {
return state->flutter_state_is_down ? FlutterPointerPhase::kMove
: FlutterPointerPhase::kDown;
return is_button_down ? FlutterPointerPhase::kMove
: FlutterPointerPhase::kDown;
}
}

Expand All @@ -249,7 +250,8 @@ void FlutterTizenView::OnPointerMove(double x,
FlutterPointerDeviceKind device_kind,
int32_t device_id) {
PointerState* state = GetOrCreatePointerState(device_kind, device_id);
FlutterPointerPhase phase = GetPointerPhaseFromState(state);
FlutterPointerPhase phase =
GetPointerPhaseFromState(state->flutter_state_is_down, state->buttons);
SendFlutterPointerEvent(phase, x, y, 0, 0, timestamp, state);
}

Expand All @@ -262,7 +264,8 @@ void FlutterTizenView::OnPointerDown(double x,
if (button != 0) {
PointerState* state = GetOrCreatePointerState(device_kind, device_id);
state->buttons |= button;
FlutterPointerPhase phase = GetPointerPhaseFromState(state);
FlutterPointerPhase phase =
GetPointerPhaseFromState(state->flutter_state_is_down, state->buttons);
SendFlutterPointerEvent(phase, x, y, 0, 0, timestamp, state);

state->flutter_state_is_down = true;
Expand All @@ -277,10 +280,11 @@ void FlutterTizenView::OnPointerUp(double x,
int32_t device_id) {
if (button != 0) {
PointerState* state = GetOrCreatePointerState(device_kind, device_id);
state->buttons &= ~button;
FlutterPointerPhase phase = GetPointerPhaseFromState(state);
uint64_t clear_button_state = state->buttons & ~button;
Copy link
Member

Choose a reason for hiding this comment

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

Could you please check this part? This code is identical to the implementation of window. The state of the buttons sent to flutter may be different from the existing one. Will it change the existing behavior or cause problems?
https://github.com/flutter/flutter/blob/master/engine/src/flutter/shell/platform/windows/flutter_windows_view.cc#L267

FlutterPointerPhase phase = GetPointerPhaseFromState(
state->flutter_state_is_down, clear_button_state);
SendFlutterPointerEvent(phase, x, y, 0, 0, timestamp, state);

state->buttons = clear_button_state;
if (phase == FlutterPointerPhase::kUp) {
state->flutter_state_is_down = false;
}
Expand All @@ -295,7 +299,8 @@ void FlutterTizenView::OnScroll(double x,
FlutterPointerDeviceKind device_kind,
int32_t device_id) {
PointerState* state = GetOrCreatePointerState(device_kind, device_id);
FlutterPointerPhase phase = GetPointerPhaseFromState(state);
FlutterPointerPhase phase =
GetPointerPhaseFromState(state->flutter_state_is_down, state->buttons);
SendFlutterPointerEvent(phase, x, y, delta_x, delta_y, timestamp, state);
}

Expand Down
3 changes: 2 additions & 1 deletion flutter/shell/platform/tizen/flutter_tizen_view.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,8 @@ class FlutterTizenView : public TizenViewEventHandlerDelegate {
int32_t device_id);

// Returns a FlutterPointerPhase corresponding to the current pointer state.
FlutterPointerPhase GetPointerPhaseFromState(const PointerState* state) const;
FlutterPointerPhase GetPointerPhaseFromState(bool is_button_down,
uint64_t button_type) const;

// Sends a window metrics update to the Flutter engine using current window
// dimensions in physical.
Expand Down