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

Side by Side Diff: ui/aura/mus/window_tree_client.h

Issue 2488723002: Reland of Improves focus/activation for aura-mus and DesktopNativeWidgetAura (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « ui/aura/mus/in_flight_change.cc ('k') | ui/aura/mus/window_tree_client.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 UI_AURA_MUS_WINDOW_TREE_CLIENT_H_ 5 #ifndef UI_AURA_MUS_WINDOW_TREE_CLIENT_H_
6 #define UI_AURA_MUS_WINDOW_TREE_CLIENT_H_ 6 #define UI_AURA_MUS_WINDOW_TREE_CLIENT_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
11 #include <memory> 11 #include <memory>
12 #include <set> 12 #include <set>
13 #include <string> 13 #include <string>
14 #include <vector> 14 #include <vector>
15 15
16 #include "base/atomicops.h" 16 #include "base/atomicops.h"
17 #include "base/compiler_specific.h" 17 #include "base/compiler_specific.h"
18 #include "base/macros.h" 18 #include "base/macros.h"
19 #include "base/memory/weak_ptr.h" 19 #include "base/memory/weak_ptr.h"
20 #include "base/observer_list.h" 20 #include "base/observer_list.h"
21 #include "mojo/public/cpp/bindings/associated_binding.h" 21 #include "mojo/public/cpp/bindings/associated_binding.h"
22 #include "mojo/public/cpp/bindings/strong_binding.h" 22 #include "mojo/public/cpp/bindings/strong_binding.h"
23 #include "services/ui/public/interfaces/window_tree.mojom.h" 23 #include "services/ui/public/interfaces/window_tree.mojom.h"
24 #include "ui/aura/aura_export.h" 24 #include "ui/aura/aura_export.h"
25 #include "ui/aura/client/focus_change_observer.h"
26 #include "ui/aura/client/transient_window_client_observer.h" 25 #include "ui/aura/client/transient_window_client_observer.h"
27 #include "ui/aura/mus/capture_synchronizer_delegate.h" 26 #include "ui/aura/mus/capture_synchronizer_delegate.h"
28 #include "ui/aura/mus/drag_drop_controller_host.h" 27 #include "ui/aura/mus/drag_drop_controller_host.h"
28 #include "ui/aura/mus/focus_synchronizer_delegate.h"
29 #include "ui/aura/mus/mus_types.h" 29 #include "ui/aura/mus/mus_types.h"
30 #include "ui/aura/mus/window_manager_delegate.h" 30 #include "ui/aura/mus/window_manager_delegate.h"
31 #include "ui/aura/mus/window_tree_host_mus_delegate.h" 31 #include "ui/aura/mus/window_tree_host_mus_delegate.h"
32 32
33 namespace display { 33 namespace display {
34 class Display; 34 class Display;
35 } 35 }
36 36
37 namespace gfx { 37 namespace gfx {
38 class Insets; 38 class Insets;
39 } 39 }
40 40
41 namespace service_manager { 41 namespace service_manager {
42 class Connector; 42 class Connector;
43 } 43 }
44 44
45 namespace aura { 45 namespace aura {
46 class CaptureSynchronizer; 46 class CaptureSynchronizer;
47 class DragDropControllerMus; 47 class DragDropControllerMus;
48 class FocusSynchronizer;
48 class InFlightBoundsChange; 49 class InFlightBoundsChange;
49 class InFlightChange; 50 class InFlightChange;
50 class InFlightFocusChange; 51 class InFlightFocusChange;
51 class InFlightPropertyChange; 52 class InFlightPropertyChange;
52 class InFlightVisibleChange; 53 class InFlightVisibleChange;
53 class WindowMus; 54 class WindowMus;
54 class WindowPortMus; 55 class WindowPortMus;
55 struct WindowPortInitData; 56 struct WindowPortInitData;
56 struct WindowPortPropertyData; 57 struct WindowPortPropertyData;
57 class WindowTreeClientDelegate; 58 class WindowTreeClientDelegate;
(...skipping 13 matching lines...) Expand all
71 // WindowTreeClient is owned by the creator. Generally when the delegate gets 72 // WindowTreeClient is owned by the creator. Generally when the delegate gets
72 // one of OnEmbedRootDestroyed() or OnLostConnection() it should delete the 73 // one of OnEmbedRootDestroyed() or OnLostConnection() it should delete the
73 // WindowTreeClient. 74 // WindowTreeClient.
74 // 75 //
75 // When WindowTreeClient is deleted all windows are deleted (and observers 76 // When WindowTreeClient is deleted all windows are deleted (and observers
76 // notified). 77 // notified).
77 class AURA_EXPORT WindowTreeClient 78 class AURA_EXPORT WindowTreeClient
78 : NON_EXPORTED_BASE(public ui::mojom::WindowTreeClient), 79 : NON_EXPORTED_BASE(public ui::mojom::WindowTreeClient),
79 NON_EXPORTED_BASE(public ui::mojom::WindowManager), 80 NON_EXPORTED_BASE(public ui::mojom::WindowManager),
80 public CaptureSynchronizerDelegate, 81 public CaptureSynchronizerDelegate,
82 public FocusSynchronizerDelegate,
81 public DragDropControllerHost, 83 public DragDropControllerHost,
82 public WindowManagerClient, 84 public WindowManagerClient,
83 public WindowTreeHostMusDelegate, 85 public WindowTreeHostMusDelegate,
84 public client::FocusChangeObserver,
85 public client::TransientWindowClientObserver { 86 public client::TransientWindowClientObserver {
86 public: 87 public:
87 explicit WindowTreeClient( 88 explicit WindowTreeClient(
88 WindowTreeClientDelegate* delegate, 89 WindowTreeClientDelegate* delegate,
89 WindowManagerDelegate* window_manager_delegate = nullptr, 90 WindowManagerDelegate* window_manager_delegate = nullptr,
90 ui::mojom::WindowTreeClientRequest request = nullptr); 91 ui::mojom::WindowTreeClientRequest request = nullptr);
91 ~WindowTreeClient() override; 92 ~WindowTreeClient() override;
92 93
93 // Establishes the connection by way of the WindowTreeFactory. 94 // Establishes the connection by way of the WindowTreeFactory.
94 void ConnectViaWindowTreeFactory(service_manager::Connector* connector); 95 void ConnectViaWindowTreeFactory(service_manager::Connector* connector);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 Id window_id, 130 Id window_id,
130 ui::mojom::CompositorFrameSinkType type, 131 ui::mojom::CompositorFrameSinkType type,
131 cc::mojom::MojoCompositorFrameSinkRequest compositor_frame_sink, 132 cc::mojom::MojoCompositorFrameSinkRequest compositor_frame_sink,
132 cc::mojom::MojoCompositorFrameSinkClientPtr client); 133 cc::mojom::MojoCompositorFrameSinkClientPtr client);
133 134
134 bool IsRoot(WindowMus* window) const { return roots_.count(window) > 0; } 135 bool IsRoot(WindowMus* window) const { return roots_.count(window) > 0; }
135 136
136 // Returns the root of this connection. 137 // Returns the root of this connection.
137 std::set<Window*> GetRoots(); 138 std::set<Window*> GetRoots();
138 139
139 // Returns the focused window; null if focus is not yet known or another app
140 // is focused.
141 Window* GetFocusedWindow();
142
143 // Returns the current location of the mouse on screen. Note: this method may 140 // Returns the current location of the mouse on screen. Note: this method may
144 // race the asynchronous initialization; but in that case we return (0, 0). 141 // race the asynchronous initialization; but in that case we return (0, 0).
145 gfx::Point GetCursorScreenPoint(); 142 gfx::Point GetCursorScreenPoint();
146 143
147 // See description in window_tree.mojom. When an existing pointer watcher is 144 // See description in window_tree.mojom. When an existing pointer watcher is
148 // updated or cleared then any future events from the server for that watcher 145 // updated or cleared then any future events from the server for that watcher
149 // will be ignored. 146 // will be ignored.
150 void StartPointerWatcher(bool want_moves); 147 void StartPointerWatcher(bool want_moves);
151 void StopPointerWatcher(); 148 void StopPointerWatcher();
152 149
(...skipping 24 matching lines...) Expand all
177 // TODO(sky): this assumes change_ids never wrap, which is a bad assumption. 174 // TODO(sky): this assumes change_ids never wrap, which is a bad assumption.
178 using InFlightMap = std::map<uint32_t, std::unique_ptr<InFlightChange>>; 175 using InFlightMap = std::map<uint32_t, std::unique_ptr<InFlightChange>>;
179 176
180 void RegisterWindowMus(WindowMus* window); 177 void RegisterWindowMus(WindowMus* window);
181 178
182 WindowMus* GetWindowByServerId(Id id); 179 WindowMus* GetWindowByServerId(Id id);
183 180
184 // Returns true if the specified window was created by this client. 181 // Returns true if the specified window was created by this client.
185 bool WasCreatedByThisClient(const WindowMus* window) const; 182 bool WasCreatedByThisClient(const WindowMus* window) const;
186 183
187 void SetFocusFromServer(WindowMus* window);
188 void SetFocusFromServerImpl(client::FocusClient* focus_client,
189 WindowMus* window);
190
191 // Returns the oldest InFlightChange that matches |change|. 184 // Returns the oldest InFlightChange that matches |change|.
192 InFlightChange* GetOldestInFlightChangeMatching(const InFlightChange& change); 185 InFlightChange* GetOldestInFlightChangeMatching(const InFlightChange& change);
193 186
194 // See InFlightChange for details on how InFlightChanges are used. 187 // See InFlightChange for details on how InFlightChanges are used.
195 uint32_t ScheduleInFlightChange(std::unique_ptr<InFlightChange> change); 188 uint32_t ScheduleInFlightChange(std::unique_ptr<InFlightChange> change);
196 189
197 // Returns true if there is an InFlightChange that matches |change|. If there 190 // Returns true if there is an InFlightChange that matches |change|. If there
198 // is an existing change SetRevertValueFrom() is invoked on it. Returns false 191 // is an existing change SetRevertValueFrom() is invoked on it. Returns false
199 // if there is no InFlightChange matching |change|. 192 // if there is no InFlightChange matching |change|.
200 // See InFlightChange for details on how InFlightChanges are used. 193 // See InFlightChange for details on how InFlightChanges are used.
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 const base::Callback<void(bool)>& callback) override; 404 const base::Callback<void(bool)>& callback) override;
412 void RemoveAccelerator(uint32_t id) override; 405 void RemoveAccelerator(uint32_t id) override;
413 void AddActivationParent(Window* window) override; 406 void AddActivationParent(Window* window) override;
414 void RemoveActivationParent(Window* window) override; 407 void RemoveActivationParent(Window* window) override;
415 void ActivateNextWindow() override; 408 void ActivateNextWindow() override;
416 void SetUnderlaySurfaceOffsetAndExtendedHitArea( 409 void SetUnderlaySurfaceOffsetAndExtendedHitArea(
417 Window* window, 410 Window* window,
418 const gfx::Vector2d& offset, 411 const gfx::Vector2d& offset,
419 const gfx::Insets& hit_area) override; 412 const gfx::Insets& hit_area) override;
420 413
421 // Overriden from client::FocusChangeObserver:
422 void OnWindowFocused(Window* gained_focus, Window* lost_focus) override;
423
424 // Overriden from WindowTreeHostMusDelegate: 414 // Overriden from WindowTreeHostMusDelegate:
425 void OnWindowTreeHostBoundsWillChange(WindowTreeHostMus* window_tree_host, 415 void OnWindowTreeHostBoundsWillChange(WindowTreeHostMus* window_tree_host,
426 const gfx::Rect& bounds) override; 416 const gfx::Rect& bounds) override;
427 std::unique_ptr<WindowPortMus> CreateWindowPortForTopLevel() override; 417 std::unique_ptr<WindowPortMus> CreateWindowPortForTopLevel() override;
428 void OnWindowTreeHostCreated(WindowTreeHostMus* window_tree_host) override; 418 void OnWindowTreeHostCreated(WindowTreeHostMus* window_tree_host) override;
429 419
430 // Override from client::TransientWindowClientObserver: 420 // Override from client::TransientWindowClientObserver:
431 void OnTransientChildWindowAdded(Window* parent, 421 void OnTransientChildWindowAdded(Window* parent,
432 Window* transient_child) override; 422 Window* transient_child) override;
433 void OnTransientChildWindowRemoved(Window* parent, 423 void OnTransientChildWindowRemoved(Window* parent,
434 Window* transient_child) override; 424 Window* transient_child) override;
435 425
436 // Overriden from DragDropControllerHost: 426 // Overriden from DragDropControllerHost:
437 uint32_t CreateChangeIdForDrag(WindowMus* window) override; 427 uint32_t CreateChangeIdForDrag(WindowMus* window) override;
438 428
439 // Overrided from CaptureSynchronizerDelegate: 429 // Overrided from CaptureSynchronizerDelegate:
440 uint32_t CreateChangeIdForCapture(WindowMus* window) override; 430 uint32_t CreateChangeIdForCapture(WindowMus* window) override;
441 431
432 // Overrided from FocusSynchronizerDelegate:
433 uint32_t CreateChangeIdForFocus(WindowMus* window) override;
434
442 // The one int in |cursor_location_mapping_|. When we read from this 435 // The one int in |cursor_location_mapping_|. When we read from this
443 // location, we must always read from it atomically. 436 // location, we must always read from it atomically.
444 base::subtle::Atomic32* cursor_location_memory() { 437 base::subtle::Atomic32* cursor_location_memory() {
445 return reinterpret_cast<base::subtle::Atomic32*>( 438 return reinterpret_cast<base::subtle::Atomic32*>(
446 cursor_location_mapping_.get()); 439 cursor_location_mapping_.get());
447 } 440 }
448 441
449 // This is set once and only once when we get OnEmbed(). It gives the unique 442 // This is set once and only once when we get OnEmbed(). It gives the unique
450 // id for this client. 443 // id for this client.
451 ClientSpecificId client_id_; 444 ClientSpecificId client_id_;
452 445
453 // Id assigned to the next window created. 446 // Id assigned to the next window created.
454 ClientSpecificId next_window_id_; 447 ClientSpecificId next_window_id_;
455 448
456 // Id used for the next change id supplied to the server. 449 // Id used for the next change id supplied to the server.
457 uint32_t next_change_id_; 450 uint32_t next_change_id_;
458 InFlightMap in_flight_map_; 451 InFlightMap in_flight_map_;
459 452
460 WindowTreeClientDelegate* delegate_; 453 WindowTreeClientDelegate* delegate_;
461 454
462 WindowManagerDelegate* window_manager_delegate_; 455 WindowManagerDelegate* window_manager_delegate_;
463 456
464 std::set<WindowMus*> roots_; 457 std::set<WindowMus*> roots_;
465 458
466 IdToWindowMap windows_; 459 IdToWindowMap windows_;
467 std::map<ClientSpecificId, std::set<Window*>> embedded_windows_; 460 std::map<ClientSpecificId, std::set<Window*>> embedded_windows_;
468 461
469 std::unique_ptr<CaptureSynchronizer> capture_synchronizer_; 462 std::unique_ptr<CaptureSynchronizer> capture_synchronizer_;
470 463
471 bool setting_focus_ = false; 464 std::unique_ptr<FocusSynchronizer> focus_synchronizer_;
472 WindowMus* window_setting_focus_to_ = nullptr;
473 WindowMus* focused_window_ = nullptr;
474 465
475 mojo::Binding<ui::mojom::WindowTreeClient> binding_; 466 mojo::Binding<ui::mojom::WindowTreeClient> binding_;
476 ui::mojom::WindowTreePtr tree_ptr_; 467 ui::mojom::WindowTreePtr tree_ptr_;
477 // Typically this is the value contained in |tree_ptr_|, but tests may 468 // Typically this is the value contained in |tree_ptr_|, but tests may
478 // directly set this. 469 // directly set this.
479 ui::mojom::WindowTree* tree_; 470 ui::mojom::WindowTree* tree_;
480 471
481 // Set to true if OnEmbed() was received. 472 // Set to true if OnEmbed() was received.
482 bool is_from_embed_ = false; 473 bool is_from_embed_ = false;
483 474
(...skipping 25 matching lines...) Expand all
509 std::unique_ptr<DragDropControllerMus> drag_drop_controller_; 500 std::unique_ptr<DragDropControllerMus> drag_drop_controller_;
510 501
511 base::WeakPtrFactory<WindowTreeClient> weak_factory_; 502 base::WeakPtrFactory<WindowTreeClient> weak_factory_;
512 503
513 DISALLOW_COPY_AND_ASSIGN(WindowTreeClient); 504 DISALLOW_COPY_AND_ASSIGN(WindowTreeClient);
514 }; 505 };
515 506
516 } // namespace aura 507 } // namespace aura
517 508
518 #endif // UI_AURA_MUS_WINDOW_TREE_CLIENT_H_ 509 #endif // UI_AURA_MUS_WINDOW_TREE_CLIENT_H_
OLDNEW
« no previous file with comments | « ui/aura/mus/in_flight_change.cc ('k') | ui/aura/mus/window_tree_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698