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
1=== modified file 'miral-shell/canonical_window_manager.cpp'
2--- miral-shell/canonical_window_manager.cpp 2016-06-02 16:19:39 +0000
3+++ miral-shell/canonical_window_manager.cpp 2016-06-02 16:19:39 +0000
4@@ -630,20 +630,46 @@
5 }
6 }
7
8+ int touch_pinch_size = 0;
9+ Displacement pinch_delta;
10+
11+ for (auto i = 0U; i != count; ++i)
12+ {
13+ for (auto j = 0U; j != i; ++j)
14+ {
15+ int dx = mir_touch_event_axis_value(event, i, mir_touch_axis_x) -
16+ mir_touch_event_axis_value(event, j, mir_touch_axis_x);
17+
18+ int dy = mir_touch_event_axis_value(event, i, mir_touch_axis_y) -
19+ mir_touch_event_axis_value(event, j, mir_touch_axis_y);
20+
21+ int size = dx*dx + dy*dy;
22+
23+ if (touch_pinch_size < size)
24+ {
25+ touch_pinch_size = size;
26+ pinch_delta = Displacement{dx, dy};
27+ }
28+ }
29+ }
30+
31 bool consumes_event = false;
32 if (is_drag)
33 {
34- switch (count)
35+ if (count == 3)
36 {
37- case 4:
38- resize(cursor);
39- consumes_event = true;
40- break;
41-
42- case 3:
43 drag(cursor);
44+
45+ if (auto window = tools->active_window())
46+ {
47+ auto const numerator = sqrtf(touch_pinch_size) - sqrtf(old_touch_pinch_size);
48+ auto const denominator = sqrtf(pinch_delta.length_squared());
49+ auto const displacement = (numerator / denominator) * pinch_delta;
50+ auto const new_size = as_displacement(window.size()) + displacement;
51+
52+ apply_resize(tools->info_for(window), window.top_left(), as_size(new_size));
53+ }
54 consumes_event = true;
55- break;
56 }
57 }
58 else
59@@ -653,6 +679,7 @@
60 }
61
62 old_cursor = cursor;
63+ old_touch_pinch_size = touch_pinch_size;
64 return consumes_event;
65 }
66
67
68=== modified file 'miral-shell/canonical_window_manager.h'
69--- miral-shell/canonical_window_manager.h 2016-06-02 10:03:55 +0000
70+++ miral-shell/canonical_window_manager.h 2016-06-02 16:19:39 +0000
71@@ -108,6 +108,7 @@
72 bool resizing = false;
73 bool left_resize = false;
74 bool top_resize = false;
75+ long long old_touch_pinch_size = 0;
76 };
77
78 #endif /* MIRAL_SHELL_CANONICAL_WINDOW_MANAGER_H_ */

Subscribers

People subscribed via source and target branches