Mir

Merge lp:~vanvugt/mir/fix-1522673 into lp:mir

Proposed by Daniel van Vugt
Status: Rejected
Rejected by: Daniel van Vugt
Proposed branch: lp:~vanvugt/mir/fix-1522673
Merge into: lp:mir
Diff against target: 97 lines (+14/-12)
4 files modified
include/test/mir/test/event_matchers.h (+1/-1)
playground/demo-shell/window_manager.cpp (+6/-5)
src/platforms/evdev/libinput_device.h (+2/-2)
tests/unit-tests/input/evdev/test_libinput_device.cpp (+5/-4)
To merge this branch: bzr merge lp:~vanvugt/mir/fix-1522673
Reviewer Review Type Date Requested Status
Andreas Pokorny (community) Needs Fixing
PS Jenkins bot (community) continuous-integration Approve
Alan Griffiths Abstain
Alexandros Frantzis (community) Needs Information
Review via email: mp+279551@code.launchpad.net

Commit message

Restore usable mouse wheel support (LP: #1522673)

With the introduction of libinput, mouse wheel (vscroll) events became
backwards and 15x larger than they were with Android Input. So this
reverses that change such that existing toolkits and apps using Mir
don't need modification.

Android Input: Up = +1.0 Down= -1.0
libinput: Up =-15.0 Down=+15.0

I have also modified mir_proving_server to become insensitive to any
similar magnitude changes in future.

To post a comment you must log in.
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

Can we safely assume that the vscroll values (-15,+15) produced by libinput are the same for all devices?

review: Needs Information
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

I think so, yes. Because:

(a) It was always [1,-1] before with all mice and always [-15,+15] now with all (my) mice; and
(b) If you use 'evtest' to look at the raw kernel events, they originate from button 4/5 down/up events. So there is no device-specific scale that changes.

I would like to dig into libinput still and find out why they chose 15...

Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

I'd rather we understood the change than just work around it.

review: Abstain
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

This is the probably the wrong place to a apply a general compensating scaling. Since this can be changed by users soon.

I did not realize that android-input up-(right?) for positive values.
Down-Right is the positive direction in libinput.

A single tick on a mouse wheel on many mice relates to a 15 degree rotation, some scroll wheels do look different and may have finer grained ticks. In that case there is hopefully a udev rule to detect that and provide the property MOUSE_WHEEL_CLICK_ANGLE. Which libinput would then use instead of the default 15.

Libinput does not claim that the value provided is an angle, but rather 'scroll units'.

Because in the past we did forward the raw ticks qtmir applied a scaling factor of 15 to our events.
http://bazaar.launchpad.net/~mir-team/qtmir/trunk/view/head:/src/platforms/mirserver/qteventfeeder.cpp#L573

- note raw ticks that might relate to a different movement angle depending on the granularity of the wheel surface -

Gtk+ on the other hand forwarded the scroll value without scaling so they might work better now:
https://git.gnome.org/browse/gtk+/tree/gdk/mir/gdkmireventsource.c#n183

Even though we could get access to the raw ticks, by further checking the input device event. I suggest we stick with the scroll units - since then we would benefit from per device udev rules.

So we could do the following:
1) Scale every scroll event with (x:1/15, y:-1/15) not by affecting the use configured value, but by scalling libinputs result
2) change gtk to multiply with 15.0
3) keep qtmirs scaling
4) keep proving_server 1:1 mapping

Or
1) forward libinputs result
2) keep gtk 1:1 mapping
3) change qtmirs scaling to just forward
4) change proving servers interpretation of scroll events

review: Needs Fixing
Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

I think we should take the second option from above because then qtmir would behave like the servers in mir -> no additional scaling is applied to events..

Revision history for this message
Andreas Pokorny (andreas-pokorny) wrote :

I went through our downstreams, and I have to correct some of the statements above
especially:

> Gtk+ on the other hand forwarded the scroll value without scaling so they
> might work better now:
> https://git.gnome.org/browse/gtk+/tree/gdk/mir/gdkmireventsource.c#n183

The back-end implementation is correct since gtk expects ticks here..
Additionally the qtmir frontend properly forwards only the 'ticks' to clients and not the scaled scroll values. So at least for 0.18 we should go this way:

1) Scale every scroll event with (horizontal:1/15, vertical:1/15) or take the original tick count value and scale the gesture/finger base scrolls.
2) keep gtk
3) keep qtmirs scaling
4) keep proving_server 1:1 mapping

In the long run it seems more correct to switch to scroll values. We could achieve that by adding additional axes to query.

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

See bug 1522673 for two alternative branches that will probably replace this one.

Unmerged revisions

3177. By Daniel van Vugt

And protect Alt+mousewheel from magnitude changes too.

3176. By Daniel van Vugt

Restore usable mouse wheel support (LP: #1522673)

With the introduction of libinput, mouse wheel (vscroll) events became
backwards and 15x larger than they were with Android Input. So this
reverses that change such that existing toolkits and apps using Mir
don't need modification.

Android Input: Up = +1.0 Down= -1.0
libinput: Up =-15.0 Down=+15.0

I have also modified mir_proving_server to become insensitive to any
similar magnitude changes in future.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'include/test/mir/test/event_matchers.h'
2--- include/test/mir/test/event_matchers.h 2015-11-30 16:34:46 +0000
3+++ include/test/mir/test/event_matchers.h 2015-12-04 09:04:57 +0000
4@@ -308,7 +308,7 @@
5 return false;
6 if (mir_pointer_event_action(pev) != mir_pointer_action_motion)
7 return false;
8- if (mir_pointer_event_axis_value(pev, scroll_axis) != value)
9+ if (fabs(mir_pointer_event_axis_value(pev, scroll_axis) - value) > 0.001f)
10 return false;
11 return true;
12 }
13
14=== modified file 'playground/demo-shell/window_manager.cpp'
15--- playground/demo-shell/window_manager.cpp 2015-08-07 05:46:34 +0000
16+++ playground/demo-shell/window_manager.cpp 2015-12-04 09:04:57 +0000
17@@ -387,10 +387,11 @@
18
19 float new_zoom_mag = 0.0f; // zero means unchanged
20
21- if (modifiers & mir_input_event_modifier_meta &&
22- action == mir_pointer_action_motion)
23- {
24- zoom_exponent += vscroll;
25+ if (modifiers & mir_input_event_modifier_meta &&
26+ action == mir_pointer_action_motion &&
27+ vscroll != 0.0f)
28+ {
29+ zoom_exponent += vscroll > 0.0f ? 1.0f : -1.0f;
30
31 // Negative exponents do work too, but disable them until
32 // there's a clear edge to the desktop.
33@@ -449,7 +450,7 @@
34 vscroll)
35 {
36 float alpha = surf->alpha();
37- alpha += 0.1f * vscroll;
38+ alpha += vscroll > 0.0f ? 0.1f : -0.1f;
39 if (alpha < 0.0f)
40 alpha = 0.0f;
41 else if (alpha > 1.0f)
42
43=== modified file 'src/platforms/evdev/libinput_device.h'
44--- src/platforms/evdev/libinput_device.h 2015-11-30 16:34:46 +0000
45+++ src/platforms/evdev/libinput_device.h 2015-12-04 09:04:57 +0000
46@@ -88,8 +88,8 @@
47 InputDeviceInfo info;
48 mir::geometry::Point pointer_pos;
49 MirPointerButtons button_state;
50- double vertical_scroll_scale{1.0};
51- double horizontal_scroll_scale{1.0};
52+ double vertical_scroll_scale{-0.0667f}; // <- Compatible with android input
53+ double horizontal_scroll_scale{1.0}; // <- Might be wrong. Never tested.
54
55 struct ContactData
56 {
57
58=== modified file 'tests/unit-tests/input/evdev/test_libinput_device.cpp'
59--- tests/unit-tests/input/evdev/test_libinput_device.cpp 2015-11-30 16:34:46 +0000
60+++ tests/unit-tests/input/evdev/test_libinput_device.cpp 2015-12-04 09:04:57 +0000
61@@ -616,8 +616,8 @@
62 InSequence seq;
63 // expect two scroll events..
64 EXPECT_CALL(mock_builder,
65- pointer_event(time_stamp_1, mir_pointer_action_motion, 0, 0.0f, 20.0f, 0.0f, 0.0f));
66- EXPECT_CALL(mock_sink, handle_input(mt::PointerAxisChange(mir_pointer_axis_vscroll, 20.0f)));
67+ pointer_event(time_stamp_1, mir_pointer_action_motion, 0, 0.0f, FloatEq(-1.334f), 0.0f, 0.0f));
68+ EXPECT_CALL(mock_sink, handle_input(mt::PointerAxisChange(mir_pointer_axis_vscroll, -1.334f)));
69 EXPECT_CALL(mock_builder,
70 pointer_event(time_stamp_2, mir_pointer_action_motion, 0, 5.0f, 0.0f, 0.0f, 0.0f));
71 EXPECT_CALL(mock_sink, handle_input(mt::PointerAxisChange(mir_pointer_axis_hscroll, 5.0f)));
72@@ -755,6 +755,7 @@
73
74 TEST_F(LibInputDeviceOnMouse, reads_pointer_settings_from_libinput)
75 {
76+ // XXX Is this test useful?
77 setup_pointer_configuration(mouse.device(), 1, mir_pointer_handedness_right);
78 auto optional_settings = mouse.get_pointer_settings();
79
80@@ -764,7 +765,7 @@
81 EXPECT_THAT(ptr_settings.handedness, Eq(mir_pointer_handedness_right));
82 EXPECT_THAT(ptr_settings.cursor_acceleration_bias, Eq(1.0));
83 EXPECT_THAT(ptr_settings.horizontal_scroll_scale, Eq(1.0));
84- EXPECT_THAT(ptr_settings.vertical_scroll_scale, Eq(1.0));
85+ EXPECT_THAT(ptr_settings.vertical_scroll_scale, Lt(0.0f));
86
87 setup_pointer_configuration(mouse.device(), 0.0, mir_pointer_handedness_left);
88 optional_settings = mouse.get_pointer_settings();
89@@ -775,7 +776,7 @@
90 EXPECT_THAT(ptr_settings.handedness, Eq(mir_pointer_handedness_left));
91 EXPECT_THAT(ptr_settings.cursor_acceleration_bias, Eq(0.0));
92 EXPECT_THAT(ptr_settings.horizontal_scroll_scale, Eq(1.0));
93- EXPECT_THAT(ptr_settings.vertical_scroll_scale, Eq(1.0));
94+ EXPECT_THAT(ptr_settings.vertical_scroll_scale, Lt(0.0f));
95 }
96
97 TEST_F(LibInputDeviceOnMouse, applies_pointer_settings)

Subscribers

People subscribed via source and target branches