Merge lp:~alan-griffiths/miral/an-alternative-touch-resize-algorithm into lp:miral

Proposed by Alan Griffiths
Status: Rejected
Rejected by: Alan Griffiths
Proposed branch: lp:~alan-griffiths/miral/an-alternative-touch-resize-algorithm
Merge into: lp:miral
Prerequisite: lp:~alan-griffiths/miral/slightly-less-broken-touch-handling
Diff against target: 78 lines (+36/-8)
2 files modified
miral-shell/canonical_window_manager.cpp (+35/-8)
miral-shell/canonical_window_manager.h (+1/-0)
To merge this branch: bzr merge lp:~alan-griffiths/miral/an-alternative-touch-resize-algorithm
Reviewer Review Type Date Requested Status
Mir development team Pending
Review via email: mp+296345@code.launchpad.net

Commit message

Copy the touch resize logic used by mir_proving_server

Description of the change

An experiment - I don't have a good approach to touch resize yet.

Seeking on whether this is an improvement.

To post a comment you must log in.

Unmerged revisions

183. By Alan Griffiths

Delete debug code

182. By Alan Griffiths

Try the touch resize logic used by mir_proving_server

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'miral-shell/canonical_window_manager.cpp'
--- miral-shell/canonical_window_manager.cpp 2016-06-02 16:19:39 +0000
+++ miral-shell/canonical_window_manager.cpp 2016-06-02 16:19:39 +0000
@@ -630,20 +630,46 @@
630 }630 }
631 }631 }
632632
633 int touch_pinch_size = 0;
634 Displacement pinch_delta;
635
636 for (auto i = 0U; i != count; ++i)
637 {
638 for (auto j = 0U; j != i; ++j)
639 {
640 int dx = mir_touch_event_axis_value(event, i, mir_touch_axis_x) -
641 mir_touch_event_axis_value(event, j, mir_touch_axis_x);
642
643 int dy = mir_touch_event_axis_value(event, i, mir_touch_axis_y) -
644 mir_touch_event_axis_value(event, j, mir_touch_axis_y);
645
646 int size = dx*dx + dy*dy;
647
648 if (touch_pinch_size < size)
649 {
650 touch_pinch_size = size;
651 pinch_delta = Displacement{dx, dy};
652 }
653 }
654 }
655
633 bool consumes_event = false;656 bool consumes_event = false;
634 if (is_drag)657 if (is_drag)
635 {658 {
636 switch (count)659 if (count == 3)
637 {660 {
638 case 4:
639 resize(cursor);
640 consumes_event = true;
641 break;
642
643 case 3:
644 drag(cursor);661 drag(cursor);
662
663 if (auto window = tools->active_window())
664 {
665 auto const numerator = sqrtf(touch_pinch_size) - sqrtf(old_touch_pinch_size);
666 auto const denominator = sqrtf(pinch_delta.length_squared());
667 auto const displacement = (numerator / denominator) * pinch_delta;
668 auto const new_size = as_displacement(window.size()) + displacement;
669
670 apply_resize(tools->info_for(window), window.top_left(), as_size(new_size));
671 }
645 consumes_event = true;672 consumes_event = true;
646 break;
647 }673 }
648 }674 }
649 else675 else
@@ -653,6 +679,7 @@
653 }679 }
654680
655 old_cursor = cursor;681 old_cursor = cursor;
682 old_touch_pinch_size = touch_pinch_size;
656 return consumes_event;683 return consumes_event;
657}684}
658685
659686
=== modified file 'miral-shell/canonical_window_manager.h'
--- miral-shell/canonical_window_manager.h 2016-06-02 10:03:55 +0000
+++ miral-shell/canonical_window_manager.h 2016-06-02 16:19:39 +0000
@@ -108,6 +108,7 @@
108 bool resizing = false;108 bool resizing = false;
109 bool left_resize = false;109 bool left_resize = false;
110 bool top_resize = false;110 bool top_resize = false;
111 long long old_touch_pinch_size = 0;
111};112};
112113
113#endif /* MIRAL_SHELL_CANONICAL_WINDOW_MANAGER_H_ */114#endif /* MIRAL_SHELL_CANONICAL_WINDOW_MANAGER_H_ */

Subscribers

People subscribed via source and target branches