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