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

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

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