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