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

Side by Side Diff: components/mus/ws/window_tree.h

Issue 1909733002: mus: Add EventObserver to allow passively listening to UI events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COMPONENTS_MUS_WS_WINDOW_TREE_H_ 5 #ifndef COMPONENTS_MUS_WS_WINDOW_TREE_H_
6 #define COMPONENTS_MUS_WS_WINDOW_TREE_H_ 6 #define COMPONENTS_MUS_WS_WINDOW_TREE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 21 matching lines...) Expand all
32 namespace ui { 32 namespace ui {
33 class Event; 33 class Event;
34 } 34 }
35 35
36 namespace mus { 36 namespace mus {
37 namespace ws { 37 namespace ws {
38 38
39 class AccessPolicy; 39 class AccessPolicy;
40 class DisplayManager; 40 class DisplayManager;
41 class Display; 41 class Display;
42 class EventMatcher;
42 class ServerWindow; 43 class ServerWindow;
43 class TargetedEvent; 44 class TargetedEvent;
44 class WindowManagerState; 45 class WindowManagerState;
45 class WindowServer; 46 class WindowServer;
46 class WindowTreeTest; 47 class WindowTreeTest;
47 48
48 namespace test { 49 namespace test {
49 class WindowTreeTestApi; 50 class WindowTreeTestApi;
50 } 51 }
51 52
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 const ServerWindow* new_focused_window); 205 const ServerWindow* new_focused_window);
205 void ProcessLostCapture(const ServerWindow* old_lost_capture, 206 void ProcessLostCapture(const ServerWindow* old_lost_capture,
206 bool originated_change); 207 bool originated_change);
207 void ProcessTransientWindowAdded(const ServerWindow* window, 208 void ProcessTransientWindowAdded(const ServerWindow* window,
208 const ServerWindow* transient_window, 209 const ServerWindow* transient_window,
209 bool originated_change); 210 bool originated_change);
210 void ProcessTransientWindowRemoved(const ServerWindow* window, 211 void ProcessTransientWindowRemoved(const ServerWindow* window,
211 const ServerWindow* transient_window, 212 const ServerWindow* transient_window,
212 bool originated_change); 213 bool originated_change);
213 214
215 // Sends this event to the client if it matches an active event observer.
216 void SendToEventObserver(const ui::Event& event);
217
214 private: 218 private:
215 friend class test::WindowTreeTestApi; 219 friend class test::WindowTreeTestApi;
216 220
217 struct WaitingForTopLevelWindowInfo { 221 struct WaitingForTopLevelWindowInfo {
218 WaitingForTopLevelWindowInfo(const ClientWindowId& client_window_id, 222 WaitingForTopLevelWindowInfo(const ClientWindowId& client_window_id,
219 uint32_t wm_change_id) 223 uint32_t wm_change_id)
220 : client_window_id(client_window_id), wm_change_id(wm_change_id) {} 224 : client_window_id(client_window_id), wm_change_id(wm_change_id) {}
221 ~WaitingForTopLevelWindowInfo() {} 225 ~WaitingForTopLevelWindowInfo() {}
222 226
223 // Id supplied from the client. 227 // Id supplied from the client.
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 void ReorderWindow(uint32_t change_Id, 336 void ReorderWindow(uint32_t change_Id,
333 Id window_id, 337 Id window_id,
334 Id relative_window_id, 338 Id relative_window_id,
335 mojom::OrderDirection direction) override; 339 mojom::OrderDirection direction) override;
336 void GetWindowTree( 340 void GetWindowTree(
337 Id window_id, 341 Id window_id,
338 const mojo::Callback<void(mojo::Array<mojom::WindowDataPtr>)>& callback) 342 const mojo::Callback<void(mojo::Array<mojom::WindowDataPtr>)>& callback)
339 override; 343 override;
340 void SetCapture(uint32_t change_id, Id window_id) override; 344 void SetCapture(uint32_t change_id, Id window_id) override;
341 void ReleaseCapture(uint32_t change_id, Id window_id) override; 345 void ReleaseCapture(uint32_t change_id, Id window_id) override;
346 void SetEventObserver(mojom::EventMatcherPtr matcher,
347 uint32_t observer_id) override;
342 void SetWindowBounds(uint32_t change_id, 348 void SetWindowBounds(uint32_t change_id,
343 Id window_id, 349 Id window_id,
344 mojo::RectPtr bounds) override; 350 mojo::RectPtr bounds) override;
345 void SetWindowVisibility(uint32_t change_id, 351 void SetWindowVisibility(uint32_t change_id,
346 Id window_id, 352 Id window_id,
347 bool visible) override; 353 bool visible) override;
348 void SetWindowProperty(uint32_t change_id, 354 void SetWindowProperty(uint32_t change_id,
349 Id transport_window_id, 355 Id transport_window_id,
350 const mojo::String& name, 356 const mojo::String& name,
351 mojo::Array<uint8_t> value) override; 357 mojo::Array<uint8_t> value) override;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 Id transport_window_id) override; 406 Id transport_window_id) override;
401 407
402 // AccessPolicyDelegate: 408 // AccessPolicyDelegate:
403 bool HasRootForAccessPolicy(const ServerWindow* window) const override; 409 bool HasRootForAccessPolicy(const ServerWindow* window) const override;
404 bool IsWindowKnownForAccessPolicy(const ServerWindow* window) const override; 410 bool IsWindowKnownForAccessPolicy(const ServerWindow* window) const override;
405 bool IsWindowRootOfAnotherTreeForAccessPolicy( 411 bool IsWindowRootOfAnotherTreeForAccessPolicy(
406 const ServerWindow* window) const override; 412 const ServerWindow* window) const override;
407 413
408 WindowServer* window_server_; 414 WindowServer* window_server_;
409 415
410 const UserId user_id_; 416 UserId user_id_;
411 417
412 // Id of this tree as assigned by WindowServer. 418 // Id of this tree as assigned by WindowServer.
413 const ConnectionSpecificId id_; 419 const ConnectionSpecificId id_;
414 std::string connection_name_; 420 std::string connection_name_;
415 421
416 ConnectionSpecificId next_window_id_; 422 ConnectionSpecificId next_window_id_;
417 423
418 std::unique_ptr<WindowTreeBinding> binding_; 424 std::unique_ptr<WindowTreeBinding> binding_;
419 425
420 std::unique_ptr<mus::ws::AccessPolicy> access_policy_; 426 std::unique_ptr<mus::ws::AccessPolicy> access_policy_;
421 427
422 // The roots, or embed points, of this tree. A WindowTree may have any 428 // The roots, or embed points, of this tree. A WindowTree may have any
423 // number of roots, including 0. 429 // number of roots, including 0.
424 std::set<const ServerWindow*> roots_; 430 std::set<const ServerWindow*> roots_;
425 431
426 // The windows created by this tree. This tree owns these objects. 432 // The windows created by this tree. This tree owns these objects.
427 base::hash_map<WindowId, ServerWindow*> created_window_map_; 433 base::hash_map<WindowId, ServerWindow*> created_window_map_;
428 434
429 // The client is allowed to assign ids. These two maps providing the mapping 435 // The client is allowed to assign ids. These two maps providing the mapping
430 // from the ids native to the server (WindowId) to those understood by the 436 // from the ids native to the server (WindowId) to those understood by the
431 // client (ClientWindowId). 437 // client (ClientWindowId).
432 base::hash_map<ClientWindowId, WindowId> client_id_to_window_id_map_; 438 base::hash_map<ClientWindowId, WindowId> client_id_to_window_id_map_;
433 base::hash_map<WindowId, ClientWindowId> window_id_to_client_id_map_; 439 base::hash_map<WindowId, ClientWindowId> window_id_to_client_id_map_;
434 440
435 uint32_t event_ack_id_; 441 uint32_t event_ack_id_;
436 442
443 // Set when the client is using SetEventObserver() to observe events,
444 // otherwise null.
445 std::unique_ptr<EventMatcher> event_observer_matcher_;
446
447 // The ID supplied by the client for the current event observer.
448 uint32_t event_observer_id_ = 0;
449
437 // WindowManager the current event came from. 450 // WindowManager the current event came from.
438 WindowManagerState* event_source_wms_ = nullptr; 451 WindowManagerState* event_source_wms_ = nullptr;
439 452
440 std::queue<std::unique_ptr<TargetedEvent>> event_queue_; 453 std::queue<std::unique_ptr<TargetedEvent>> event_queue_;
441 454
442 std::unique_ptr<mojo::AssociatedBinding<mojom::WindowManagerClient>> 455 std::unique_ptr<mojo::AssociatedBinding<mojom::WindowManagerClient>>
443 window_manager_internal_client_binding_; 456 window_manager_internal_client_binding_;
444 mojom::WindowManager* window_manager_internal_; 457 mojom::WindowManager* window_manager_internal_;
445 458
446 std::unique_ptr<WaitingForTopLevelWindowInfo> 459 std::unique_ptr<WaitingForTopLevelWindowInfo>
447 waiting_for_top_level_window_info_; 460 waiting_for_top_level_window_info_;
448 461
449 DISALLOW_COPY_AND_ASSIGN(WindowTree); 462 DISALLOW_COPY_AND_ASSIGN(WindowTree);
450 }; 463 };
451 464
452 } // namespace ws 465 } // namespace ws
453 } // namespace mus 466 } // namespace mus
454 467
455 #endif // COMPONENTS_MUS_WS_WINDOW_TREE_H_ 468 #endif // COMPONENTS_MUS_WS_WINDOW_TREE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698