blob: 47f590ffca87df8d8d248655c305533bb771ba82 [file] [log] [blame]
// Copyright 2018 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 <vector>
#include "base/macros.h"
#include "ui/aura/aura_export.h"
namespace aura {
class Window;
class WindowMus;
class WindowTreeClient;
// TopmostWindowTracker keeps track of the topmost window under the touch/mouse.
// It is created through WindowTreeClient::StartObservingTopmostWindow().
class AURA_EXPORT TopmostWindowTracker {
explicit TopmostWindowTracker(WindowTreeClient* client);
aura::Window* topmost() { return topmost_; }
aura::Window* second_topmost() { return second_topmost_; }
friend class WindowTreeClient;
// Updates the topmost and the real_topmost windows to the specified ones.
// Will be called by WindowTreeClient.
void OnTopmostWindowChanged(const std::vector<WindowMus*> topmosts);
WindowTreeClient* client_;
// The root window for the topmost window under the current cursor position.
// This can be the event target.
aura::Window* topmost_ = nullptr;
// Another root window for the topmost window under the current cursor
// position. This is the second topmost window if the topmost window happens
// to be the current event target. If the topmost window isn't the event
// target, this will point to the same topmost window.
aura::Window* second_topmost_ = nullptr;
} // namespace aura