blob: 1f4cad045ca36212d1d4c8e48a3d21eb85345a7c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
// Copyright 2019 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.
#ifndef UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_WINDOW_MANAGER_H_
#define UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_WINDOW_MANAGER_H_
#include <memory>
#include "base/containers/flat_map.h"
#include "base/macros.h"
#include "base/observer_list.h"
#include "ui/gfx/native_widget_types.h"
#include "ui/ozone/platform/wayland/host/wayland_window_observer.h"
namespace ui {
class WaylandWindow;
// Stores and returns WaylandWindows. Clients that are interested in knowing
// when a new window is added or removed, but set self as an observer.
class WaylandWindowManager {
public:
WaylandWindowManager();
~WaylandWindowManager();
void AddObserver(WaylandWindowObserver* observer);
void RemoveObserver(WaylandWindowObserver* observer);
// Notifies observers that the Window has been ack configured and
// WaylandBufferManagerHost can start attaching buffers to the |surface_|.
void NotifyWindowConfigured(WaylandWindow* window);
// Stores the window that should grab the located events.
void GrabLocatedEvents(WaylandWindow* event_grabber);
// Removes the window that should grab the located events.
void UngrabLocatedEvents(WaylandWindow* event_grabber);
// Returns current event grabber.
WaylandWindow* located_events_grabber() const {
return located_events_grabber_;
}
// Returns a window found by |widget|.
WaylandWindow* GetWindow(gfx::AcceleratedWidget widget) const;
// Returns a window with largests bounds.
WaylandWindow* GetWindowWithLargestBounds() const;
// Returns a current focused window by pointer or touch.
WaylandWindow* GetCurrentFocusedWindow() const;
// Returns a current focused window by keyboard.
WaylandWindow* GetCurrentKeyboardFocusedWindow() const;
// TODO(crbug.com/971525): remove this in favor of targeted subscription of
// windows to their outputs.
std::vector<WaylandWindow*> GetWindowsOnOutput(uint32_t output_id);
// Returns all stored windows.
std::vector<WaylandWindow*> GetAllWindows() const;
void AddWindow(gfx::AcceleratedWidget widget, WaylandWindow* window);
void RemoveWindow(gfx::AcceleratedWidget widget);
private:
base::ObserverList<WaylandWindowObserver> observers_;
base::flat_map<gfx::AcceleratedWidget, WaylandWindow*> window_map_;
WaylandWindow* located_events_grabber_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(WaylandWindowManager);
};
} // namespace ui
#endif // UI_OZONE_PLATFORM_WAYLAND_HOST_WAYLAND_WINDOW_MANAGER_H_
|