blob: 8ba3b1067ad439ae5ab804377eb74ff64c497a66 [file] [log] [blame]
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <set>
#include "base/macros.h"
#include "services/ui/ws/server_window_observer.h"
namespace ui {
namespace ws {
class ServerWindowDrawnTrackerObserver;
// ServerWindowDrawnTracker notifies its observer any time the drawn state of
// the supplied window changes.
// NOTE: you must ensure this class is destroyed before the root.
class ServerWindowDrawnTracker : public ServerWindowObserver {
ServerWindowDrawnTracker(ServerWindow* window,
ServerWindowDrawnTrackerObserver* observer);
~ServerWindowDrawnTracker() override;
ServerWindow* window() { return window_; }
void SetDrawn(ServerWindow* ancestor, bool drawn);
// Adds |this| as an observer to |window_| and its ancestors.
void AddObservers();
// Stops observerving any windows we added as an observer in AddObservers().
void RemoveObservers();
// ServerWindowObserver:
void OnWindowDestroying(ServerWindow* window) override;
void OnWindowDestroyed(ServerWindow* window) override;
void OnWillChangeWindowHierarchy(ServerWindow* window,
ServerWindow* new_parent,
ServerWindow* old_parent) override;
void OnWindowHierarchyChanged(ServerWindow* window,
ServerWindow* new_parent,
ServerWindow* old_parent) override;
void OnWillChangeWindowVisibility(ServerWindow* window) override;
void OnWindowVisibilityChanged(ServerWindow* window) override;
ServerWindow* window_;
ServerWindowDrawnTrackerObserver* observer_;
bool drawn_;
// Set of windows we're observing. This is |window_| and all its ancestors.
std::set<ServerWindow*> windows_;
} // namespace ws
} // namespace ui