OLD | NEW |
| (Empty) |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef COMPONENTS_MUS_WS_SERVER_WINDOW_DRAWN_TRACKER_H_ | |
6 #define COMPONENTS_MUS_WS_SERVER_WINDOW_DRAWN_TRACKER_H_ | |
7 | |
8 #include <set> | |
9 | |
10 #include "base/macros.h" | |
11 #include "components/mus/ws/server_window_observer.h" | |
12 | |
13 namespace mus { | |
14 | |
15 namespace ws { | |
16 | |
17 class ServerWindowDrawnTrackerObserver; | |
18 | |
19 // ServerWindowDrawnTracker notifies its observer any time the drawn state of | |
20 // the supplied window changes. | |
21 // | |
22 // NOTE: you must ensure this class is destroyed before the root. | |
23 class ServerWindowDrawnTracker : public ServerWindowObserver { | |
24 public: | |
25 ServerWindowDrawnTracker(ServerWindow* window, | |
26 ServerWindowDrawnTrackerObserver* observer); | |
27 ~ServerWindowDrawnTracker() override; | |
28 | |
29 ServerWindow* window() { return window_; } | |
30 | |
31 private: | |
32 void SetDrawn(ServerWindow* ancestor, bool drawn); | |
33 | |
34 // Adds |this| as an observer to |window_| and its ancestors. | |
35 void AddObservers(); | |
36 | |
37 // Stops observerving any windows we added as an observer in AddObservers(). | |
38 void RemoveObservers(); | |
39 | |
40 // ServerWindowObserver: | |
41 void OnWindowDestroying(ServerWindow* window) override; | |
42 void OnWindowDestroyed(ServerWindow* window) override; | |
43 void OnWillChangeWindowHierarchy(ServerWindow* window, | |
44 ServerWindow* new_parent, | |
45 ServerWindow* old_parent) override; | |
46 void OnWindowHierarchyChanged(ServerWindow* window, | |
47 ServerWindow* new_parent, | |
48 ServerWindow* old_parent) override; | |
49 void OnWillChangeWindowVisibility(ServerWindow* window) override; | |
50 void OnWindowVisibilityChanged(ServerWindow* window) override; | |
51 | |
52 ServerWindow* window_; | |
53 ServerWindowDrawnTrackerObserver* observer_; | |
54 bool drawn_; | |
55 // Set of windows we're observing. This is |window_| and all its ancestors. | |
56 std::set<ServerWindow*> windows_; | |
57 | |
58 DISALLOW_COPY_AND_ASSIGN(ServerWindowDrawnTracker); | |
59 }; | |
60 | |
61 } // namespace ws | |
62 | |
63 } // namespace mus | |
64 | |
65 #endif // COMPONENTS_MUS_WS_SERVER_WINDOW_DRAWN_TRACKER_H_ | |
OLD | NEW |