Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(398)

Issue 1909733002: mus: Add EventObserver to allow passively listening to UI events (Closed)

Created:
4 years, 8 months ago by James Cook
Modified:
4 years, 8 months ago
Reviewers:
sadrul, sky
CC:
chromium-reviews, rjkroege, qsr+mojo_chromium.org, viettrungluu+watch_chromium.org, yzshen+watch_chromium.org, abarth-chromium, Aaron Boodman, darin (slow to review), ben+mojo_chromium.org
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

mus: Add EventObserver to allow passively listening to UI events In order to close the system tray bubble, ash_sysui needs to be able to listen for events that are not targeted to its windows. * Add a SetEventObserver/ClearEventObserver interface to WindowTree. * Event observers are set using the same mojom::EventMatchers used by accelerators. * The window server tests incoming events from any display and sends them to all WindowTrees with a matching event observer that belong to the same user. A follow-up CL will add a client-side "PointerWatcher" mechanism and use it in ash_sysui to close the tray bubble. BUG=599142 TEST=added to mus_ws_unittests Committed: https://crrev.com/46fcd654384263357e045cb538e655e62a11f3f4 Cr-Commit-Position: refs/heads/master@{#389315}

Patch Set 1 #

Patch Set 2 : . #

Total comments: 12

Patch Set 3 : review comments #

Total comments: 6

Patch Set 4 : event observer id #

Patch Set 5 : rebase #

Total comments: 4
Unified diffs Side-by-side diffs Delta from patch set Stats (+490 lines, -224 lines) Patch
M components/mus/public/cpp/BUILD.gn View 1 2 1 chunk +2 lines, -2 lines 0 comments Download
D components/mus/public/cpp/event_matcher.h View 1 2 1 chunk +0 lines, -20 lines 0 comments Download
A + components/mus/public/cpp/event_matcher_util.h View 1 2 2 chunks +3 lines, -3 lines 0 comments Download
D components/mus/public/cpp/lib/event_matcher.cc View 1 2 1 chunk +0 lines, -27 lines 0 comments Download
A + components/mus/public/cpp/lib/event_matcher_util.cc View 1 2 1 chunk +1 line, -1 line 0 comments Download
M components/mus/public/cpp/lib/window_tree_client_impl.h View 1 2 3 4 1 chunk +4 lines, -1 line 0 comments Download
M components/mus/public/cpp/lib/window_tree_client_impl.cc View 1 2 3 4 2 chunks +10 lines, -1 line 0 comments Download
M components/mus/public/cpp/tests/test_window_tree.h View 1 2 3 1 chunk +2 lines, -0 lines 0 comments Download
M components/mus/public/cpp/tests/test_window_tree.cc View 1 2 3 1 chunk +3 lines, -0 lines 0 comments Download
M components/mus/public/cpp/tests/window_tree_client_impl_unittest.cc View 1 2 3 4 1 chunk +2 lines, -2 lines 0 comments Download
M components/mus/public/interfaces/input_event_matcher.mojom View 1 chunk +1 line, -0 lines 0 comments Download
M components/mus/public/interfaces/window_tree.mojom View 1 2 3 3 chunks +21 lines, -3 lines 4 comments Download
M components/mus/ws/BUILD.gn View 1 2 3 4 2 chunks +3 lines, -0 lines 0 comments Download
M components/mus/ws/accelerator.h View 1 2 3 4 2 chunks +7 lines, -22 lines 0 comments Download
M components/mus/ws/accelerator.cc View 1 2 2 chunks +5 lines, -96 lines 0 comments Download
M components/mus/ws/event_dispatcher.cc View 1 2 3 4 3 chunks +8 lines, -4 lines 0 comments Download
M components/mus/ws/event_dispatcher_delegate.h View 1 2 3 1 chunk +4 lines, -0 lines 0 comments Download
M components/mus/ws/event_dispatcher_unittest.cc View 1 2 3 4 4 chunks +27 lines, -1 line 0 comments Download
A components/mus/ws/event_matcher.h View 1 2 1 chunk +56 lines, -0 lines 0 comments Download
A + components/mus/ws/event_matcher.cc View 1 2 4 chunks +14 lines, -22 lines 0 comments Download
A components/mus/ws/event_matcher_unittest.cc View 1 2 1 chunk +71 lines, -0 lines 0 comments Download
M components/mus/ws/test_change_tracker.h View 1 2 3 3 chunks +6 lines, -1 line 0 comments Download
M components/mus/ws/test_change_tracker.cc View 1 2 3 3 chunks +29 lines, -5 lines 0 comments Download
M components/mus/ws/test_utils.h View 1 2 3 4 4 chunks +9 lines, -1 line 0 comments Download
M components/mus/ws/test_utils.cc View 1 2 3 4 2 chunks +13 lines, -2 lines 0 comments Download
M components/mus/ws/window_manager_state.h View 1 2 3 4 1 chunk +1 line, -0 lines 0 comments Download
M components/mus/ws/window_manager_state.cc View 1 2 3 4 2 chunks +12 lines, -0 lines 0 comments Download
M components/mus/ws/window_manager_state_unittest.cc View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M components/mus/ws/window_server.h View 1 2 3 4 1 chunk +6 lines, -0 lines 0 comments Download
M components/mus/ws/window_server.cc View 1 2 3 4 1 chunk +10 lines, -0 lines 0 comments Download
M components/mus/ws/window_tree.h View 1 2 3 4 5 chunks +14 lines, -1 line 0 comments Download
M components/mus/ws/window_tree.cc View 1 2 3 4 3 chunks +22 lines, -3 lines 0 comments Download
M components/mus/ws/window_tree_client_unittest.cc View 1 2 3 4 2 chunks +3 lines, -1 line 0 comments Download
M components/mus/ws/window_tree_unittest.cc View 1 2 3 4 4 chunks +116 lines, -0 lines 0 comments Download
M mash/browser_driver/browser_driver_application_delegate.cc View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M mash/wm/accelerator_registrar_unittest.cc View 1 2 1 chunk +1 line, -1 line 0 comments Download
M mash/wm/root_window_controller.cc View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download
M mash/wm/window_manager_application.cc View 1 2 3 4 1 chunk +1 line, -1 line 0 comments Download

Dependent Patchsets:

Messages

Total messages: 23 (8 generated)
James Cook
sky, please take a look. I'm not thrilled with the name EventTester. I thought about ...
4 years, 8 months ago (2016-04-21 16:42:37 UTC) #3
sky
+sadrul https://codereview.chromium.org/1909733002/diff/20001/components/mus/public/interfaces/window_tree.mojom File components/mus/public/interfaces/window_tree.mojom (right): https://codereview.chromium.org/1909733002/diff/20001/components/mus/public/interfaces/window_tree.mojom#newcode117 components/mus/public/interfaces/window_tree.mojom:117: SetEventObserver(EventMatcher matcher); Declare this as EventMatcher?, then you ...
4 years, 8 months ago (2016-04-21 17:23:04 UTC) #5
sadrul
https://codereview.chromium.org/1909733002/diff/20001/components/mus/ws/window_server.cc File components/mus/ws/window_server.cc (right): https://codereview.chromium.org/1909733002/diff/20001/components/mus/ws/window_server.cc#newcode405 components/mus/ws/window_server.cc:405: } It should send only if the requestor and ...
4 years, 8 months ago (2016-04-21 19:15:29 UTC) #6
James Cook
sky, please take a look. I decided to keep two functions in the mojo WindowTreeClient ...
4 years, 8 months ago (2016-04-22 18:22:55 UTC) #8
sky
https://codereview.chromium.org/1909733002/diff/30001/components/mus/public/interfaces/window_tree.mojom File components/mus/public/interfaces/window_tree.mojom (right): https://codereview.chromium.org/1909733002/diff/30001/components/mus/public/interfaces/window_tree.mojom#newcode374 components/mus/public/interfaces/window_tree.mojom:374: bool matched_observer); Rather than a bool for matched_observer I ...
4 years, 8 months ago (2016-04-22 20:18:48 UTC) #9
James Cook
sky, please take another look. https://codereview.chromium.org/1909733002/diff/30001/components/mus/public/interfaces/window_tree.mojom File components/mus/public/interfaces/window_tree.mojom (right): https://codereview.chromium.org/1909733002/diff/30001/components/mus/public/interfaces/window_tree.mojom#newcode374 components/mus/public/interfaces/window_tree.mojom:374: bool matched_observer); On 2016/04/22 ...
4 years, 8 months ago (2016-04-22 21:25:08 UTC) #10
sky
LGTM
4 years, 8 months ago (2016-04-22 21:42:12 UTC) #11
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1909733002/70001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1909733002/70001
4 years, 8 months ago (2016-04-22 22:38:30 UTC) #14
commit-bot: I haz the power
Committed patchset #5 (id:70001)
4 years, 8 months ago (2016-04-23 00:03:17 UTC) #16
commit-bot: I haz the power
Patchset 5 (id:??) landed as https://crrev.com/46fcd654384263357e045cb538e655e62a11f3f4 Cr-Commit-Position: refs/heads/master@{#389315}
4 years, 8 months ago (2016-04-23 00:05:20 UTC) #18
sadrul
https://codereview.chromium.org/1909733002/diff/70001/components/mus/public/interfaces/window_tree.mojom File components/mus/public/interfaces/window_tree.mojom (right): https://codereview.chromium.org/1909733002/diff/70001/components/mus/public/interfaces/window_tree.mojom#newcode119 components/mus/public/interfaces/window_tree.mojom:119: SetEventObserver(EventMatcher? matcher, uint32 observer_id); This feels fairly awkward. What ...
4 years, 8 months ago (2016-04-23 01:24:39 UTC) #19
James Cook
https://codereview.chromium.org/1909733002/diff/70001/components/mus/public/interfaces/window_tree.mojom File components/mus/public/interfaces/window_tree.mojom (right): https://codereview.chromium.org/1909733002/diff/70001/components/mus/public/interfaces/window_tree.mojom#newcode119 components/mus/public/interfaces/window_tree.mojom:119: SetEventObserver(EventMatcher? matcher, uint32 observer_id); On 2016/04/23 01:24:39, sadrul wrote: ...
4 years, 8 months ago (2016-04-25 16:23:35 UTC) #20
sadrul
https://codereview.chromium.org/1909733002/diff/70001/components/mus/public/interfaces/window_tree.mojom File components/mus/public/interfaces/window_tree.mojom (right): https://codereview.chromium.org/1909733002/diff/70001/components/mus/public/interfaces/window_tree.mojom#newcode119 components/mus/public/interfaces/window_tree.mojom:119: SetEventObserver(EventMatcher? matcher, uint32 observer_id); On 2016/04/25 16:23:35, James Cook ...
4 years, 8 months ago (2016-04-25 16:33:34 UTC) #21
James Cook
https://codereview.chromium.org/1909733002/diff/70001/components/mus/public/interfaces/window_tree.mojom File components/mus/public/interfaces/window_tree.mojom (right): https://codereview.chromium.org/1909733002/diff/70001/components/mus/public/interfaces/window_tree.mojom#newcode119 components/mus/public/interfaces/window_tree.mojom:119: SetEventObserver(EventMatcher? matcher, uint32 observer_id); On 2016/04/25 16:33:34, sadrul wrote: ...
4 years, 8 months ago (2016-04-25 16:52:00 UTC) #22
sky
4 years, 8 months ago (2016-04-25 18:24:06 UTC) #23
Message was sent while issue was closed.
I actually like what you have here and like the id for the reasons I
asked for early in the review. Will respond to your other email
shortly.

  -Scott

On Mon, Apr 25, 2016 at 9:52 AM,  <jamescook@chromium.org> wrote:
>
>
https://codereview.chromium.org/1909733002/diff/70001/components/mus/public/i...
> File components/mus/public/interfaces/window_tree.mojom (right):
>
>
https://codereview.chromium.org/1909733002/diff/70001/components/mus/public/i...
> components/mus/public/interfaces/window_tree.mojom:119:
> SetEventObserver(EventMatcher? matcher, uint32 observer_id);
> On 2016/04/25 16:33:34, sadrul wrote:
>> On 2016/04/25 16:23:35, James Cook wrote:
>> > On 2016/04/23 01:24:39, sadrul wrote:
>> > > This feels fairly awkward. What happens if multiple matchers match
> an event?
>> > >
>> > > I think it's simpler to just not send a message to the client for
> the
>> observer
>> > > when the client itself is the target. The client should already
> have enough
>> > > information to decide whether or not the local
> Mouse/PointerWatcher should
>> > > trigger or not. If we wanted to make this super clear, we could
> call this
>> > > ExternalEventObserver instead of just EventObserver. But the
> |observer_id|
>> > thing
>> > > feels weird.
>> >
>> > I don't understand. You can't have multiple EventMatchers, by
> design.
>>
>> I realized this after I left the comment. My initial understanding
> from reading
>> this was that you could register multiple observers with different
> observer-id
>> and matcher.
>>
>> I think it would be simpler to have a single
>> 'Set[External]EventsToObserve(EventMatcher? matcher)'. The client-side
>> (PointerMatcher, etc.) would have to track the various kinds of events
> to watch
>> for anyway, e.g. some parts of a client could be interested in
> pointer-down
>> events (bubble-closer in ash_sysui), while some other parts could be
> interested
>> in pointer-move events (e.g. auto-hide/show shelf, also in ash_sysui),
> and the
>> client-lib would have to make sure one doesn't override the other. So,
> it would
>> make sense to simplify the server-side code.
>>
>> > It's up to
>> > the client to decide what to do with matched events.
>> >
>> > I went with this pattern because I wanted a single source of truth
> about
>> whether
>> > an event matched or not, and that felt like it should be the server.
>> >
>> > Scott, do you have an opinion here?
>
> I agree that the observer_id thing feels weird (you're right that it
> seems to imply you can set multiple observers).
>
> I don't think the client is going to need to keep track of separate
> lists of who is interested in which event. I would just implement it
> like EventHandler -- there's a master list of everyone interested in
> pointer events and the interface looks like:
>
> void OnMouseDown(const MouseEvent& event) {}
> void OnMouseUp(const MouseEvent& event) {}
> ...
>
> and various bits of UI just implement the methods for the event types
> they care about. (This also makes it clear that not all event types are
> supported, and that you can't event->SetHandled() or
> event->StopPropagation().)
>
> Let's move to email -- I just sent mail to you and Scott, proposing that
> we don't use EventMatcher at all. :-)
>
> https://codereview.chromium.org/1909733002/

-- 
You received this message because you are subscribed to the Google Groups
"Chromium-reviews" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to chromium-reviews+unsubscribe@chromium.org.

Powered by Google App Engine
This is Rietveld 408576698