OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_VIEWS_MUS_SCREEN_MUS_H_ | 5 #ifndef UI_VIEWS_MUS_SCREEN_MUS_H_ |
6 #define UI_VIEWS_MUS_SCREEN_MUS_H_ | 6 #define UI_VIEWS_MUS_SCREEN_MUS_H_ |
7 | 7 |
8 #include <vector> | |
9 | |
10 #include "base/observer_list.h" | |
11 #include "base/run_loop.h" | |
12 #include "mojo/public/cpp/bindings/binding.h" | 8 #include "mojo/public/cpp/bindings/binding.h" |
13 #include "services/ui/public/interfaces/display.mojom.h" | 9 #include "services/ui/public/interfaces/display.mojom.h" |
14 #include "ui/display/display.h" | 10 #include "ui/display/screen_base.h" |
15 #include "ui/display/screen.h" | |
16 #include "ui/views/mus/display_list.h" | |
17 #include "ui/views/mus/mus_export.h" | 11 #include "ui/views/mus/mus_export.h" |
18 | 12 |
19 namespace shell { | 13 namespace shell { |
20 class Connector; | 14 class Connector; |
21 } | 15 } |
22 | 16 |
23 namespace views { | 17 namespace views { |
24 | 18 |
25 class ScreenMusDelegate; | 19 class ScreenMusDelegate; |
26 | 20 |
27 // Screen implementation backed by ui::mojom::DisplayManager. | 21 // Screen implementation backed by ui::mojom::DisplayManager. |
28 class VIEWS_MUS_EXPORT ScreenMus | 22 class VIEWS_MUS_EXPORT ScreenMus |
29 : public display::Screen, | 23 : public display::ScreenBase, |
30 public NON_EXPORTED_BASE(ui::mojom::DisplayManagerObserver) { | 24 public NON_EXPORTED_BASE(ui::mojom::DisplayManagerObserver) { |
31 public: | 25 public: |
32 // |delegate| can be nullptr. | 26 // |delegate| can be nullptr. |
33 explicit ScreenMus(ScreenMusDelegate* delegate); | 27 explicit ScreenMus(ScreenMusDelegate* delegate); |
34 ~ScreenMus() override; | 28 ~ScreenMus() override; |
35 | 29 |
36 void Init(shell::Connector* connector); | 30 void Init(shell::Connector* connector); |
37 | 31 |
38 private: | 32 private: |
39 // Invoked when a display changed in some weay, including being added. | |
40 // If |is_primary| is true, |changed_display| is the primary display. | |
41 void ProcessDisplayChanged(const display::Display& changed_display, | |
42 bool is_primary); | |
43 | |
44 // display::Screen: | 33 // display::Screen: |
45 gfx::Point GetCursorScreenPoint() override; | 34 gfx::Point GetCursorScreenPoint() override; |
46 bool IsWindowUnderCursor(gfx::NativeWindow window) override; | 35 bool IsWindowUnderCursor(gfx::NativeWindow window) override; |
47 gfx::NativeWindow GetWindowAtScreenPoint(const gfx::Point& point) override; | |
48 display::Display GetPrimaryDisplay() const override; | |
49 display::Display GetDisplayNearestWindow(gfx::NativeView view) const override; | |
50 display::Display GetDisplayNearestPoint( | |
51 const gfx::Point& point) const override; | |
52 int GetNumDisplays() const override; | |
53 std::vector<display::Display> GetAllDisplays() const override; | |
54 display::Display GetDisplayMatching( | |
55 const gfx::Rect& match_rect) const override; | |
56 void AddObserver(display::DisplayObserver* observer) override; | |
57 void RemoveObserver(display::DisplayObserver* observer) override; | |
58 | 36 |
59 // ui::mojom::DisplayManager: | 37 // ui::mojom::DisplayManager: |
60 void OnDisplays(mojo::Array<ui::mojom::WsDisplayPtr> ws_displays) override; | 38 void OnDisplays(mojo::Array<ui::mojom::WsDisplayPtr> ws_displays) override; |
61 void OnDisplaysChanged( | 39 void OnDisplaysChanged( |
62 mojo::Array<ui::mojom::WsDisplayPtr> ws_displays) override; | 40 mojo::Array<ui::mojom::WsDisplayPtr> ws_displays) override; |
63 void OnDisplayRemoved(int64_t id) override; | 41 void OnDisplayRemoved(int64_t id) override; |
64 | 42 |
65 ScreenMusDelegate* delegate_; // Can be nullptr. | 43 ScreenMusDelegate* delegate_; // Can be nullptr. |
66 ui::mojom::DisplayManagerPtr display_manager_; | 44 ui::mojom::DisplayManagerPtr display_manager_; |
67 mojo::Binding<ui::mojom::DisplayManagerObserver> | 45 mojo::Binding<ui::mojom::DisplayManagerObserver> |
68 display_manager_observer_binding_; | 46 display_manager_observer_binding_; |
69 DisplayList display_list_; | |
70 | 47 |
71 DISALLOW_COPY_AND_ASSIGN(ScreenMus); | 48 DISALLOW_COPY_AND_ASSIGN(ScreenMus); |
72 }; | 49 }; |
73 | 50 |
74 } // namespace views | 51 } // namespace views |
75 | 52 |
76 #endif // UI_VIEWS_MUS_SCREEN_MUS_H_ | 53 #endif // UI_VIEWS_MUS_SCREEN_MUS_H_ |
OLD | NEW |