Mir

Merge lp:~vanvugt/mir/modifier-groups into lp:mir

Proposed by Daniel van Vugt
Status: Work in progress
Proposed branch: lp:~vanvugt/mir/modifier-groups
Merge into: lp:mir
Diff against target: 122 lines (+39/-8)
6 files modified
client-ABI-sha1sums (+1/-1)
common-ABI-sha1sums (+1/-1)
include/common/mir_toolkit/events/input/input_event.h (+12/-4)
platform-ABI-sha1sums (+1/-1)
server-ABI-sha1sums (+1/-1)
tests/unit-tests/input/test_input_event.cpp (+23/-0)
To merge this branch: bzr merge lp:~vanvugt/mir/modifier-groups
Reviewer Review Type Date Requested Status
Robert Carr (community) Abstain
Daniel van Vugt Needs Fixing
Alan Griffiths Needs Information
Alexandros Frantzis (community) Needs Information
PS Jenkins bot (community) continuous-integration Approve
Cemil Azizoglu (community) Approve
Review via email: mp+246676@code.launchpad.net

Commit message

Fix wasteful allocation of modifier bit flags that allowed for impossible combinations.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Cemil Azizoglu (cemil-azizoglu) wrote :

Wouldn't

mir_input_event_modifier_alt = mir_input_event_modifier_alt_left | mir_input_event_modifier_alt_right,

have been better?

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

I thought the same thing afterwards...

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

Just did a quick audit. This stuff appeared in r2129 so first released in Mir 0.10.0. I think that makes it new enough that we can safely change the API without anyone complaining.

lp:~vanvugt/mir/modifier-groups updated
2233. By Daniel van Vugt

Merge latest trunk

2234. By Daniel van Vugt

Changed syntax per Cemil's comments.

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

Changed to the syntax Cemil mentioned. It's a little bit more ugly but also more verbose. Don't know if that's better or worse.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alexandros Frantzis (afrantzis) wrote :

OK with this as long as there is no good reason for having separate alt/shift/ctrl values in the first place. I vaguely remember some discussions about this, but not the conclusion. Robert?

Also, since this is a breaking change anyway, why not reorganize the enum to avoid holes?

> This stuff appeared in r2129 so first released in Mir 0.10.0. I think that makes it
> new enough that we can safely change the API without anyone complaining.

That's only true as long as no one uses 0.10 and then moves to a later version. I don't think we have the luxury to skip bumps in the client ABI as we have been doing on some occasions on the server side.

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

*Needs Discussion*

I know this example is a different enum, but do we plan to support the equivalent of:

            switch (event.modifiers & modifier_mask)
            {
            case mir_key_modifier_alt:
                wm->toggle(mir_surface_state_maximized);
                return true;

(from examples/server_example_window_management.cpp)

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

Alexandros: Yeah we could fill the holes but I felt that would increase the risk of ABI breaks if all the bits moved instead of just four of them. Same kind of risk, but more limited.

Alan: Your example is certainly unusual and does expect mir_key_modifier_alt to be a single bit (or for the user to hold down both Alts at once :). I don't think that's common usage. More commonly mir_key_modifier_alt will be used as a mask. So in the long run I suspect the masks proposed here are going to be more useful. That said, this is not a critical change either.

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

Alan's example code needs modification if this branch is to land. But I'm undecided now.

review: Needs Fixing
Revision history for this message
Robert Carr (robertcarr) wrote :

I'm not sure. I suspect both series of flags are inadequate and eventually we will have to use a dynamic modifier system similar to xkb_modmask_t (this can of course be backwards compatible with either this branch or the current devel branches).

I would say its not worth the churn but I didn't think very hard.

review: Abstain

Unmerged revisions

2234. By Daniel van Vugt

Changed syntax per Cemil's comments.

2233. By Daniel van Vugt

Merge latest trunk

2232. By Daniel van Vugt

Fix search/replace error, and improve formatting

2231. By Daniel van Vugt

Ensure each modifier with separate left/right keys doesn't get three
separate flag bits. So that one may test for:
    mods & mir_input_event_modifier_shift
without needing to know which shift key it is.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'client-ABI-sha1sums'
2--- client-ABI-sha1sums 2015-01-15 13:07:37 +0000
3+++ client-ABI-sha1sums 2015-01-19 03:53:36 +0000
4@@ -15,7 +15,7 @@
5 f4d39e9893ce6308bddd83a49b90f0051f565323 include/common/mir_toolkit/event.h
6 2507f2929415aa423f9551d3c595c439fe1c6efd include/common/mir_toolkit/events/event_deprecated.h
7 cb2358a701db2b9c8d9ba1c877f29f834af259a7 include/common/mir_toolkit/events/event.h
8-caaf95ea6c02570ab733ade70aba2ecea810b3a7 include/common/mir_toolkit/events/input/input_event.h
9+3e86fb1c906b2c9b27760bfef2847b7cd4d79b36 include/common/mir_toolkit/events/input/input_event.h
10 7748a12138474e9be218eeb8f14b372af0fcec7e include/common/mir_toolkit/events/input/key_input_event.h
11 489e8bae7c3e949ac449b09bd3bf554dae0e8986 include/common/mir_toolkit/events/input/pointer_input_event.h
12 de7c23453e6d897296f32e49d9ba952a1baa0200 include/common/mir_toolkit/events/input/touch_input_event.h
13
14=== modified file 'common-ABI-sha1sums'
15--- common-ABI-sha1sums 2015-01-15 13:07:37 +0000
16+++ common-ABI-sha1sums 2015-01-19 03:53:36 +0000
17@@ -22,7 +22,7 @@
18 f4d39e9893ce6308bddd83a49b90f0051f565323 include/common/mir_toolkit/event.h
19 2507f2929415aa423f9551d3c595c439fe1c6efd include/common/mir_toolkit/events/event_deprecated.h
20 cb2358a701db2b9c8d9ba1c877f29f834af259a7 include/common/mir_toolkit/events/event.h
21-caaf95ea6c02570ab733ade70aba2ecea810b3a7 include/common/mir_toolkit/events/input/input_event.h
22+3e86fb1c906b2c9b27760bfef2847b7cd4d79b36 include/common/mir_toolkit/events/input/input_event.h
23 7748a12138474e9be218eeb8f14b372af0fcec7e include/common/mir_toolkit/events/input/key_input_event.h
24 489e8bae7c3e949ac449b09bd3bf554dae0e8986 include/common/mir_toolkit/events/input/pointer_input_event.h
25 de7c23453e6d897296f32e49d9ba952a1baa0200 include/common/mir_toolkit/events/input/touch_input_event.h
26
27=== modified file 'include/common/mir_toolkit/events/input/input_event.h'
28--- include/common/mir_toolkit/events/input/input_event.h 2015-01-05 23:06:03 +0000
29+++ include/common/mir_toolkit/events/input/input_event.h 2015-01-19 03:53:36 +0000
30@@ -44,20 +44,28 @@
31 */
32 typedef enum {
33 mir_input_event_modifier_none = 1 << 0,
34- mir_input_event_modifier_alt = 1 << 1,
35+ /* Unused 1 << 1 */
36 mir_input_event_modifier_alt_left = 1 << 2,
37 mir_input_event_modifier_alt_right = 1 << 3,
38- mir_input_event_modifier_shift = 1 << 4,
39+ mir_input_event_modifier_alt = mir_input_event_modifier_alt_left
40+ | mir_input_event_modifier_alt_right,
41+ /* Unused 1 << 4 */
42 mir_input_event_modifier_shift_left = 1 << 5,
43 mir_input_event_modifier_shift_right = 1 << 6,
44+ mir_input_event_modifier_shift = mir_input_event_modifier_shift_left
45+ | mir_input_event_modifier_shift_right,
46 mir_input_event_modifier_sym = 1 << 7,
47 mir_input_event_modifier_function = 1 << 8,
48- mir_input_event_modifier_ctrl = 1 << 9,
49+ /* Unused 1 << 9 */
50 mir_input_event_modifier_ctrl_left = 1 << 10,
51 mir_input_event_modifier_ctrl_right = 1 << 11,
52- mir_input_event_modifier_meta = 1 << 12,
53+ mir_input_event_modifier_ctrl = mir_input_event_modifier_ctrl_left
54+ | mir_input_event_modifier_ctrl_right,
55+ /* Unused 1 << 12 */
56 mir_input_event_modifier_meta_left = 1 << 13,
57 mir_input_event_modifier_meta_right = 1 << 14,
58+ mir_input_event_modifier_meta = mir_input_event_modifier_meta_left
59+ | mir_input_event_modifier_meta_right,
60 mir_input_event_modifier_caps_lock = 1 << 15,
61 mir_input_event_modifier_num_lock = 1 << 16,
62 mir_input_event_modifier_scroll_lock = 1 << 17
63
64=== modified file 'platform-ABI-sha1sums'
65--- platform-ABI-sha1sums 2015-01-15 13:07:37 +0000
66+++ platform-ABI-sha1sums 2015-01-19 03:53:36 +0000
67@@ -22,7 +22,7 @@
68 f4d39e9893ce6308bddd83a49b90f0051f565323 include/common/mir_toolkit/event.h
69 2507f2929415aa423f9551d3c595c439fe1c6efd include/common/mir_toolkit/events/event_deprecated.h
70 cb2358a701db2b9c8d9ba1c877f29f834af259a7 include/common/mir_toolkit/events/event.h
71-caaf95ea6c02570ab733ade70aba2ecea810b3a7 include/common/mir_toolkit/events/input/input_event.h
72+3e86fb1c906b2c9b27760bfef2847b7cd4d79b36 include/common/mir_toolkit/events/input/input_event.h
73 7748a12138474e9be218eeb8f14b372af0fcec7e include/common/mir_toolkit/events/input/key_input_event.h
74 489e8bae7c3e949ac449b09bd3bf554dae0e8986 include/common/mir_toolkit/events/input/pointer_input_event.h
75 de7c23453e6d897296f32e49d9ba952a1baa0200 include/common/mir_toolkit/events/input/touch_input_event.h
76
77=== modified file 'server-ABI-sha1sums'
78--- server-ABI-sha1sums 2015-01-15 13:07:37 +0000
79+++ server-ABI-sha1sums 2015-01-19 03:53:36 +0000
80@@ -22,7 +22,7 @@
81 f4d39e9893ce6308bddd83a49b90f0051f565323 include/common/mir_toolkit/event.h
82 2507f2929415aa423f9551d3c595c439fe1c6efd include/common/mir_toolkit/events/event_deprecated.h
83 cb2358a701db2b9c8d9ba1c877f29f834af259a7 include/common/mir_toolkit/events/event.h
84-caaf95ea6c02570ab733ade70aba2ecea810b3a7 include/common/mir_toolkit/events/input/input_event.h
85+3e86fb1c906b2c9b27760bfef2847b7cd4d79b36 include/common/mir_toolkit/events/input/input_event.h
86 7748a12138474e9be218eeb8f14b372af0fcec7e include/common/mir_toolkit/events/input/key_input_event.h
87 489e8bae7c3e949ac449b09bd3bf554dae0e8986 include/common/mir_toolkit/events/input/pointer_input_event.h
88 de7c23453e6d897296f32e49d9ba952a1baa0200 include/common/mir_toolkit/events/input/touch_input_event.h
89
90=== modified file 'tests/unit-tests/input/test_input_event.cpp'
91--- tests/unit-tests/input/test_input_event.cpp 2015-01-14 19:37:28 +0000
92+++ tests/unit-tests/input/test_input_event.cpp 2015-01-19 03:53:36 +0000
93@@ -88,6 +88,29 @@
94 EXPECT_NE(nullptr, mir_event_get_input_event(&motion_ev));
95 }
96
97+TEST(InputEvent, modifier_families_are_inclusive)
98+{
99+ EXPECT_TRUE(mir_input_event_modifier_alt_left &
100+ mir_input_event_modifier_alt);
101+ EXPECT_TRUE(mir_input_event_modifier_alt_right &
102+ mir_input_event_modifier_alt);
103+
104+ EXPECT_TRUE(mir_input_event_modifier_shift_left &
105+ mir_input_event_modifier_shift);
106+ EXPECT_TRUE(mir_input_event_modifier_shift_right &
107+ mir_input_event_modifier_shift);
108+
109+ EXPECT_TRUE(mir_input_event_modifier_ctrl_left &
110+ mir_input_event_modifier_ctrl);
111+ EXPECT_TRUE(mir_input_event_modifier_ctrl_right &
112+ mir_input_event_modifier_ctrl);
113+
114+ EXPECT_TRUE(mir_input_event_modifier_meta_left &
115+ mir_input_event_modifier_meta);
116+ EXPECT_TRUE(mir_input_event_modifier_meta_right &
117+ mir_input_event_modifier_meta);
118+}
119+
120 // MirInputEvent properties common to all events.
121
122 TEST(CommonInputEventProperties, device_id_taken_from_old_style_event)

Subscribers

People subscribed via source and target branches