Mir

Merge lp://qastaging/~andreas-pokorny/mir/evdev-input-platform into lp://qastaging/mir

Proposed by Andreas Pokorny
Status: Work in progress
Proposed branch: lp://qastaging/~andreas-pokorny/mir/evdev-input-platform
Merge into: lp://qastaging/mir
Diff against target: 3273 lines (+2839/-12)
54 files modified
include/platform/mir/input/device_capability.h (+50/-0)
include/platform/mir/input/input_device.h (+60/-0)
include/platform/mir/input/input_device_registry.h (+49/-0)
include/platform/mir/input/input_event_handler_register.h (+80/-0)
include/platform/mir/input/input_report.h (+8/-4)
include/platform/mir/input/input_sink.h (+43/-0)
include/platform/mir/input/platform.h (+128/-0)
platform-ABI-sha1sums (+7/-0)
server-ABI-sha1sums (+7/-0)
src/CMakeLists.txt (+4/-0)
src/include/common/mir/find_best.h (+67/-0)
src/include/common/mir/flags.h (+118/-0)
src/platform/CMakeLists.txt (+2/-0)
src/platforms/CMakeLists.txt (+13/-0)
src/platforms/evdev/CMakeLists.txt (+24/-0)
src/platforms/evdev/android_device_provider.cpp (+48/-0)
src/platforms/evdev/android_device_provider.h (+42/-0)
src/platforms/evdev/evdev_device_detection.cpp (+163/-0)
src/platforms/evdev/evdev_device_detection.h (+35/-0)
src/platforms/evdev/evdev_input_device_factory.cpp (+58/-0)
src/platforms/evdev/evdev_input_device_factory.h (+52/-0)
src/platforms/evdev/input_device_factory.h (+50/-0)
src/platforms/evdev/input_device_provider.h (+59/-0)
src/platforms/evdev/libinput_device_provider.cpp (+67/-0)
src/platforms/evdev/libinput_device_provider.h (+42/-0)
src/platforms/evdev/platform.cpp (+179/-0)
src/platforms/evdev/platform.h (+69/-0)
src/platforms/input-platform-symbols.map (+7/-0)
src/server/report/logging/input_report.cpp (+18/-0)
src/server/report/logging/input_report.h (+4/-0)
src/server/report/lttng/input_report.cpp (+10/-0)
src/server/report/lttng/input_report.h (+3/-0)
src/server/report/lttng/input_report_tp.h (+19/-1)
src/server/report/null/input_report.cpp (+8/-0)
src/server/report/null/input_report.h (+3/-0)
tests/include/mir_test_doubles/mock_input_device_registry.h (+46/-0)
tests/include/mir_test_doubles/mock_input_event_handler_register.h (+62/-0)
tests/include/mir_test_framework/executable_path.h (+2/-0)
tests/mir_test_framework/CMakeLists.txt (+6/-0)
tests/mir_test_framework/executable_path.cpp (+27/-0)
tests/mir_test_framework/udev_recordings/joystick-detection.ioctl (+25/-0)
tests/mir_test_framework/udev_recordings/joystick-detection.umockdev (+351/-0)
tests/mir_test_framework/udev_recordings/mt-screen-detection.ioctl (+28/-0)
tests/mir_test_framework/udev_recordings/mt-screen-detection.umockdev (+44/-0)
tests/mir_test_framework/udev_recordings/synaptics-touchpad.ioctl (+0/-7)
tests/unit-tests/CMakeLists.txt (+2/-0)
tests/unit-tests/input/CMakeLists.txt (+1/-0)
tests/unit-tests/input/evdev/CMakeLists.txt (+13/-0)
tests/unit-tests/input/evdev/test_android_device_provider.cpp (+83/-0)
tests/unit-tests/input/evdev/test_evdev_device_detection.cpp (+86/-0)
tests/unit-tests/input/evdev/test_evdev_input_device_factory.cpp (+106/-0)
tests/unit-tests/input/evdev/test_libinput_device_provider.cpp (+82/-0)
tests/unit-tests/input/evdev/test_platform.cpp (+207/-0)
tests/unit-tests/test_find_best.cpp (+72/-0)
To merge this branch: bzr merge lp://qastaging/~andreas-pokorny/mir/evdev-input-platform
Reviewer Review Type Date Requested Status
Daniel van Vugt Needs Fixing
Cemil Azizoglu (community) Needs Resubmitting
PS Jenkins bot (community) continuous-integration Approve
Robert Carr (community) Needs Information
Kevin DuBois (community) Abstain
Review via email: mp+243806@code.qastaging.launchpad.net

Commit message

Adds the first pieces of the evdev input platform.

Those include platform interfaces for dealing with added and removed devices, and sending input events into the system. Evdev device detection to decide which code base should be used for handling the event stream. The decision is made between the android input code already existing in mir and libinput. Many of the added tests make use of recorded umockdev files. This commit fixes empty ioctl return values from the recorded synaptic touch pad and adds a multi touch screen and a joystick to the devices.

The evdev input platform is not installed until the input parts of libmirserver are changed to make use of it.

Description of the change

This change adds the basic interfaces for having input platforms, and implements the framework for an evdev input platform. Several parts are still left out, and the input platform is not yet loaded by the DefaultServerConfiguration. See Follow up steps below.

Relevant Interfaces:
 * mir::input::Plaform - the entry point for the server to deal with a input platform
 * mir::input::Multiplexer an interface for the platform to enqeue actions and get triggered because of readable data in fds
 * mir::input::InputDeviceRegistry an interface to be used by the platforms to inform the server about existing or recently plugged in or removed devices..
 * mir::input::InputDevice an interface for the server to connect (and disconnect) input devices with the input handling
 * mir::input::EventSink interface for input devices to provide input events to the server..
   Those three interfaces above are part of the input mocking/stubbing story for acceptance testing the server or possible shells.

Follow up steps:
 * libinput integration through the LibInputDeviceProvider, which in this MP still provides empty shared_ptrs (still wip at:
   lp:~andreas-pokorny/mir/libinput-integration)
 * similar integration of the EventHub/InputReader code of the android input stack through the AndroidDeviceProvider and input platform loaded inside the server
 * Smaller cleanup of EventHub and InputReader

To post a comment you must log in.
Revision history for this message
Kevin DuBois (kdub) wrote :

64 +++ include/platform/mir/input/event_sink.h
this is the same interface as
src/client/event_sink.h

364 +extern "C" typedef std::unique_ptr<Platform>(*CreatePlatofrm)(
153 + // add devie info here..
typos

264 + std::initializer_list<int> fds,
Fds should be mir::Fd to better manage the lifetime of the FD.

145 +class InputDevice
class name doesnt make sense to me for what the group of functions is doing, but this might be a side effect of the "Multiplexer" naming comment.

349 + * The \a input_device_registry should be informed about input device changes using the MainLoop \a loop.
350 + */
351 + virtual void start_monitor_devices(Multiplexer& loop, std::shared_ptr<InputDeviceRegistry> const& input_device_registry) = 0;
Does the comment need updating? MainLoop doesn't seem related

review: Needs Fixing
2106. By Andreas Pokorny

typos

2107. By Andreas Pokorny

typo

2108. By Andreas Pokorny

renamed Multiplexer to InputEventHandlerRegister

2109. By Andreas Pokorny

last round of method renamings

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

>
> 364 +extern "C" typedef std::unique_ptr<Platform>(*CreatePlatofrm)(
> 153 + // add devie info here..
> typos
>
> 264 + std::initializer_list<int> fds,
> Fds should be mir::Fd to better manage the lifetime of the FD.
>
> 145 +class InputDevice
> class name doesnt make sense to me for what the group of functions is doing,
> but this might be a side effect of the "Multiplexer" naming comment.
>
> 349 + * The \a input_device_registry should be informed about input device
> changes using the MainLoop \a loop.
> 350 + */
> 351 + virtual void start_monitor_devices(Multiplexer& loop,
> std::shared_ptr<InputDeviceRegistry> const& input_device_registry) = 0;
> Does the comment need updating? MainLoop doesn't seem related

done - is the new naming good enough?

Revision history for this message
Cemil Azizoglu (cemil-azizoglu) wrote :

Here's a preliminary review. I'll have to re-review at some point more thoroughly.

33 +enum class DeviceClass : uint32_t
34 +{
35 + unknown = 0,
36 + cursor = 1<<1,
37 + keyboard = 1<<2,
38 + touchpad = 1<<3,
39 + touchscreen = 1<<4,
40 + gamepad = 1<<5,
41 + joystick = 1<<6,
42 + switch_ = 1<<7, // better name needed
43 + multitouch = 1<<8, // multitouch capable
44 + alpha_numeric = 1<<9 // enough keys for text entry
45 +};

This class is a bit strange in the sense that it includes both device class (keyboard, joystick, etc) and capability (multitouch, alpha_numeric, etc) entries. Not sure if it might cause problems later.
-----------------------------------------
161 + virtual void stop(InputEventHandlerRegister& registry) = 0;

Does this implicitly unregister the sink?
-----------------------------------------
279 + * \param owner a distinct value to identify the caller

perhaps s/distinct/unique? There are other instances.
-----------------------------------------
368 + * openning new device and register them at the servers InputDeviceRegistry.

s/openning/opening, s/servers/server's
-----------------------------------------
569 + return Priority::supported;

Do we really support all the devices except touchpad under Android, or is this supposed to be "Priority::unsupported"?

-----------------------------------------
754 +
755 +

superfluous blank line.
-----------------------------------------
1123 + return Priority::supported;

Ditto for libinput. According to the code we support everything but joystick, touchscreen and gamepad.
-----------------------------------------
1318 +void mie::Platform::device_changed(mu::Device const& /*dev*/)
1319 +{
1320 +}

Should we at least print a warning?
-----------------------------------------
1459 +
1460 +

superfluous blank lines.

review: Needs Fixing
Revision history for this message
Kevin DuBois (kdub) wrote :

Typos/names look addressed, still these though:
>
> 64 +++ include/platform/mir/input/event_sink.h
> this is the same interface as
> src/client/event_sink.h
>
> 264 + std::initializer_list<int> fds,
> Fds should be mir::Fd to better manage the lifetime of the FD.

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

> Typos/names look addressed, still these though:
> >
> > 64 +++ include/platform/mir/input/event_sink.h
> > this is the same interface as
> > src/client/event_sink.h

We paused our discussion with unifying both interfaces to a single mir::EventSink vs mir::input::EventSink.

> >
> > 264 + std::initializer_list<int> fds,
> > Fds should be mir::Fd to better manage the lifetime of the FD.

I would like to do that, but I implement that interface with our glib MainLoop implementation which currently does not use mir::Fd. On the caller/libinput side I could just keep the mir::Fd to not close the fd before the libinput context falls out of scope, but on the callee side I would need to do additional tracking to fulfill that interface.

Can we settle with doing that in a separate MP?

2110. By Andreas Pokorny

reverted some additional white space noise. Adopted the naming and ABI settings from lp:~raof/mir/server-platfrom-probing.
Because of that the integration test now also loads the library from file system instead of statically linked

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

> Here's a preliminary review. I'll have to re-review at some point more
> thoroughly.
>
> 33 +enum class DeviceClass : uint32_t
> 34 +{
> 35 + unknown = 0,
> 36 + cursor = 1<<1,
> 37 + keyboard = 1<<2,
> 38 + touchpad = 1<<3,
> 39 + touchscreen = 1<<4,
> 40 + gamepad = 1<<5,
> 41 + joystick = 1<<6,
> 42 + switch_ = 1<<7, // better name needed
> 43 + multitouch = 1<<8, // multitouch capable
> 44 + alpha_numeric = 1<<9 // enough keys for text entry
> 45 +};
>
> This class is a bit strange in the sense that it includes both device class
> (keyboard, joystick, etc) and capability (multitouch, alpha_numeric, etc)
> entries. Not sure if it might cause problems later.

I took those value from android, they are supposed to replace the device detection code that currently lives inside eventhub.cpp. Maybe splitting those entries makes them more reasonable?

> -----------------------------------------
> 161 + virtual void stop(InputEventHandlerRegister& registry) = 0;
>
> Does this implicitly unregister the sink?

it expects the callee to no longer use the sink.

> -----------------------------------------
> 279 + * \param owner a distinct value to identify the caller
>
> perhaps s/distinct/unique? There are other instances.
> -----------------------------------------
> 368 + * openning new device and register them at the servers
> InputDeviceRegistry.
>
> s/openning/opening, s/servers/server's
> -----------------------------------------
> 569 + return Priority::supported;
>
> Do we really support all the devices except touchpad under Android, or is this
> supposed to be "Priority::unsupported"?

Thats the impression i took from the input mappers. MirEvent on the other hand isnt that complete, which MirEvent-2 hopefully resolves.

> -----------------------------------------
> 754 +
> 755 +
>
> superfluous blank line.
> -----------------------------------------
> 1123 + return Priority::supported;
>
> Ditto for libinput. According to the code we support everything but joystick,
> touchscreen and gamepad.

After you pointed that out I reconsidered and took a more conservative approach. The event model inside libinput only supports those cursor/keyboard/touchpad and x-y joysticks and touch screens in a restricted form.

> -----------------------------------------
> 1318 +void mie::Platform::device_changed(mu::Device const& /*dev*/)
> 1319 +{
> 1320 +}
>
> Should we at least print a warning?

I am not sure yet about the semantics of that udev event.

Revision history for this message
Kevin DuBois (kdub) wrote :

> > Typos/names look addressed, still these though:
> > >
> > > 64 +++ include/platform/mir/input/event_sink.h
> > > this is the same interface as
> > > src/client/event_sink.h
>
> We paused our discussion with unifying both interfaces to a single
> mir::EventSink vs mir::input::EventSink.

Abstaining until we figure out why we need the 3rd interface named EventSink in the codebase :)

> > > 264 + std::initializer_list<int> fds,
> > > Fds should be mir::Fd to better manage the lifetime of the FD.
>
> I would like to do that, but I implement that interface with our glib MainLoop
> implementation which currently does not use mir::Fd. On the caller/libinput
> side I could just keep the mir::Fd to not close the fd before the libinput
> context falls out of scope, but on the callee side I would need to do
> additional tracking to fulfill that interface.
>
> Can we settle with doing that in a separate MP?

sure, although a comment or wishlist-bug would help us remember to do it later

review: Abstain
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Robert Carr (robertcarr) wrote :

InputEventHandlerRegistrar is hard to understand as a parameter to InputDevice::start, what is an event sink vs. an event handler? perhaps PollProvider or something would be a better name.

I'm a little surprised by InputDevice::start(sink) and Platform::start(sink) since afaict we mostly use the opposite pattern. How did you arrive at this design?

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

> InputEventHandlerRegistrar is hard to understand as a parameter to
> InputDevice::start, what is an event sink vs. an event handler? perhaps
> PollProvider or something would be a better name.

But does it provide polling just because there might be epoll underneath?
It is an interface to register handlers for specific events - those events are currently: there is something to read at fd, and I just woke up (because you requested it)

> I'm a little surprised by InputDevice::start(sink) and Platform::start(sink)
> since afaict we mostly use the opposite pattern. How did you arrive at this
> design?

Passing that via the contructor and that means through the creation method of the factory would have worked too. I found the approach presented here works similar and is more explicit since now the expectations of what an implementation should behave and use are connected to its interface. That is : use that interface to handle wakeups, provide the events through that interface...

2111. By Andreas Pokorny

merged lp:mir

2112. By Andreas Pokorny

Add input_ to the platform ABI

Otherwise it collides with the graphics platform symbols. Additional this change extracts a find_best algorithm and adds two reports.

2113. By Andreas Pokorny

* New upstream release 0.10.0 (https://launchpad.net/mir/+milestone/0.10.0)
  - Enhancements:
    . Added support for Android HWC 1.3 devices.
    . Reduced build dependencies.
    . Client API: Added version macros.
    . demo-shell: Added desktop zoom feature (Super + mouse wheel).
    . TODO - more
  - ABI summary: Servers need rebuilding, but clients do not;
    . Mirclient ABI unchanged at 8
    . Mircommon ABI unchanged at 3
    . Mirplatform ABI bumped to 5
    . Mirserver ABI bumped to 28
  - Bug fixes:
    . TODO - fill this in just before release

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Robert Carr (robertcarr) wrote :

I'm having trouble reviewing this since as it stands the bits aren't wired together...it would be nice if there were some minimum feature that could be come up with to make a test...or if we could come up with a testing input platform to replace usage of FakeEventHub...the requirements on such a platform may be able to prove the interfaces are sound.

Nonetheless mental model is starting to come together and ill try and finish review tomorrow.

2114. By Andreas Pokorny

merge lp:mir

2115. By Andreas Pokorny

moved evdev platform to platforms

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
2116. By Andreas Pokorny

[ Daniel van Vugt ]
. Plumbing/preparation to support external displays on Android devices.
. Began work on automatic driver probing, to intelligently choose the
best driver for you.
. Demo shell (mir_proving_server): Added desktop zoom feature using
Supermouse wheel.
. Demo renamed: mir_demo_server_shell -> mir_proving_server
. Other demo servers merged into -> mir_demo_server
. Wider support for display buffer pixel formats in the mesa driver, for
wider hardware support.
. Performance: On mesa/desktop at least; only hold compositor buffers
for the duration of the render, instead of the duration of the frame.
Following this change the compositor report can now finally report
render time instead of frame time.
. Mir now starts reliably when a TV is connected by HDMI, and up to
4K resolution (2160p) is known to work.
. Plenty more enhancements logged in the bugs list below.
. [regression] Mir servers (since 0.9) randomly crash in malloc due to
heap corruption (LP: #1401488)
. USCmouse cursor on AMD graphics is drawing incorrectly
(LP: #1391975)
. Mir fails to start when a TV is connected by HDMI
[std::exception::what: Invalid or inconsistent display configuration]
(LP: #1395405)
. Input/event driven clients may freeze indefinitely (LP: #1396006)
. Mir server crashes with "std::exception::what: Failed to get front
buffer object" when trying to fullscreen a surface (LP: #1398296)
. Switching windows with a Trusted Prompt Session active loses the
trusted prompt session (LP: #1355173)
. CI test failure in multiple tests (LP: #1401364)
. dh_install: usr/bin/mir_demo_server exists in debian/tmp but is not
installed to anywhere (LP: #1401365)
. [regression] demo-shell: Instead of moving surfaces they now fly
off-screen (LP: #1403702)
. [regression] Binaries are no longer runnable on other machines (or in
other directories) (LP: #1406073)
. [i865] unity-system-compositor fails to start: Failed to choose ARGB
EGL config (LP: #1212753)
. Mir's compositor holds buffers (blocking clients) for the duration of
the frame, even when not necessary. (LP: #1264934)
. Screen goes blank (black) briefly during display config changes which
don't affect the display mode (LP: #1274359)
. [enhancement] There should be a quit signal sent to sessions instead
of killing them directly (LP: #1304257)
. MirMotionEvent.action needs stronger typing (to MirMotionAction etc)
(LP: #1311699)
. CompositorReport as used by DefaultDisplayBufferCompositor can't
measure render time (LP: #1350716)
. Full screen (bypassed) surfaces (e.g. GLMark2Test) are missing frames
and appear to freeze or judder with swap interval 0 (LP: #1379685)
. Trusted prompts need to be part of the lifecycle (LP: #1384950)
. [testfail] BasicThreadPool.recycles_threads in CI (LP: #1391488)
. acceptance_tests are too chatty (LP: #1394221)
. mir_connection_create_surface callback is sometimes called twice on
error (LP: #1394873)
. File descriptor leaks in tests using UsingStubClientPlatform
(LP: #1395762)
. DisplayLayout resizes a surface to 1x1 if you ask it to fullscreen a
surface that's partially offscreen (LP: #1398294)
. Surfaces can consume input events before they're visible.
(LP: #1400218)
. dpkg-shlibdeps: Lots of warnings about libmirplatformstub.so
(LP: #1401373)
. Leaks in death tests can cause subsequent tests in the same process to
fail (LP: #1402160)
. [regression] lintian: E: mir-demos: binary-or-shlib-defines-rpath ...
(LP: #1406098)
. [regression] Mir utils can't run from the build tree any more
(LP: #1407557)
. fd reception code is not exeception-safe when unexpected numbers of
fds are received (LP: #1394362)
. Mir reports vertical refresh rates slightly inaccurately (LP: #1407558)
. [Enhancement] Add an API to lock surface orientation (LP: #1382209)
. Bootloop with system language Turkish on the Nexus 4 (LP: #1398984)
. Remove the implicit assumption that there every surface can be mapped
to an input handle. (LP: #1216727)
. When revealing hidden surfaces wait for them to become exposed before
sending events which we expect them to receive (LP: #1407783)
[ Ubuntu daily release ]
New rebuild forced

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
2117. By Andreas Pokorny

* New upstream release 0.11.0 (https://launchpad.net/mir/+milestone/0.11.0)
  - Enhancements:
    . Lots more major plumbing in the Android code, on the path to supporting
      external displays.
    . Performance: Use optimally efficient fragment shading when possible.
    . Performance: (Desktop) Composite using double buffering instead of
      triple to reduce visible lag.
    . TODO fill me in more
  - ABI summary: Servers (will?) need rebuilding, but clients do not;
    . Mirclient ABI unchanged at 8
    . Mircommon ABI unchanged at 3
    . Mirplatform ABI bumped to 6
    . Mirserver ABI unchanged at 28 (expect 29 before release)
  - Bug fixes:
    . TODO fill me in at release

2118. By Andreas Pokorny

borrowed path resolution functions from lp:server-platform-probing.
input-evdev is as an intermediate step only installed with mir-test-tools

2119. By Andreas Pokorny

deactivating keyboard support for now - in later mps this would interfere
with cross-device modifier handling, which is currently burried inside EventHub
and needs lifting to a more central location.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
2120. By Andreas Pokorny

install evdev recordings for integration tests

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
2121. By Andreas Pokorny

install to install

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
2122. By Andreas Pokorny

reame EventSink to the more specific InputSink

2123. By Andreas Pokorny

add flags template and rename DeviceClass enumeration

2124. By Andreas Pokorny

merge lp:mir

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
2125. By Andreas Pokorny

Temporary move the evdev platform test to unit-tests until we have a better solution for running umockdev tests

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
2126. By Andreas Pokorny

do not install evdev platform yet

2127. By Andreas Pokorny

merge sha1sums conflicts

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Cemil Azizoglu (cemil-azizoglu) wrote :

I am having a bit of a problem since this branch is not called from anywhere.

It'd be much less overwhelming to understand and review if some plumbing were introduced
first with a stub/fake input platform/devices, along with some acceptance tests, separating out
the android and libinput bits to subsequent followup branches.

The organization of the files/directories is very sensible and I think it'd be quite simple
to do that at this point since not very many people have reviewed it yet.

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

Please kill mir::Flags :)

It will confuse debuggers and developers alike if you force invalid enum values into a variable. A set of bits is just an int. For a better example see:
http://bazaar.launchpad.net/~mir-team/mir/development-branch/revision/2235#include/common/mir_toolkit/events/input/input_event.h

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

> Please kill mir::Flags :)
>
> It will confuse debuggers and developers alike if you force invalid enum
> values into a variable. A set of bits is just an int. For a better example
> see:
> http://bazaar.launchpad.net/~mir-team/mir/development-
> branch/revision/2235#include/common/mir_toolkit/events/input/input_event.h

There is no force involved an no invalid enums.

Revision history for this message
Chris Halse Rogers (raof) wrote :

I like the idea of mir::Flags; a set of flags is *not* just an int, because an int will be able to represent lots of invalid values (unless you have 32 separate flags, I guess).

I'm not sure if mir::Flags, as it currently stands, is worth it. I tried using it in add-dispatchable, and it doesn't handle some common idioms. It's also not clear to me how to improve it to support that, other than going the whole hog and doing class generation with a MIR_DEFINE_FLAGS() macro (which I'd gladly use, but am not volunteering to write ☺).

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

Oh I see you're using std::underlying_type. That should provide you with some kind of integer and allow you to remove the casts. If it doesn't then you can still change value_type to "unsigned int" and remove the casts.

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

It might also help to remove "uint32_t":
36 +enum class DeviceCapability : uint32_t

A simple "enum DeviceCapability" will work.

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

> Oh I see you're using std::underlying_type. That should provide you with some
> kind of integer and allow you to remove the casts. If it doesn't then you can
> still change value_type to "unsigned int" and remove the casts.

The casts inside Flags iteself are needed because it has to support both scoped and non-scoped enums. For scoped those are absolutely necessary and behave as intended. With c++11 enums can be forward declared since the standard now defines the underlying type to default to int32_t (iirc) - and allows manual specification in forward declaration (only for scoped..). Additionally the trait was added to resolve manually specified underlying types. I am sorry there is nothing to fix there.... just to add but more on that on monday i guess.

Unmerged revisions

2127. By Andreas Pokorny

merge sha1sums conflicts

2126. By Andreas Pokorny

do not install evdev platform yet

2125. By Andreas Pokorny

Temporary move the evdev platform test to unit-tests until we have a better solution for running umockdev tests

2124. By Andreas Pokorny

merge lp:mir

2123. By Andreas Pokorny

add flags template and rename DeviceClass enumeration

2122. By Andreas Pokorny

reame EventSink to the more specific InputSink

2121. By Andreas Pokorny

install to install

2120. By Andreas Pokorny

install evdev recordings for integration tests

2119. By Andreas Pokorny

deactivating keyboard support for now - in later mps this would interfere
with cross-device modifier handling, which is currently burried inside EventHub
and needs lifting to a more central location.

2118. By Andreas Pokorny

borrowed path resolution functions from lp:server-platform-probing.
input-evdev is as an intermediate step only installed with mir-test-tools

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.

Subscribers

People subscribed via source and target branches