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 SERVICES_UI_WS_PLATFORM_DISPLAY_DEFAULT_H_ | 5 #ifndef SERVICES_UI_WS_PLATFORM_DISPLAY_DEFAULT_H_ |
6 #define SERVICES_UI_WS_PLATFORM_DISPLAY_DEFAULT_H_ | 6 #define SERVICES_UI_WS_PLATFORM_DISPLAY_DEFAULT_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "services/ui/display/viewport_metrics.h" | 11 #include "services/ui/display/viewport_metrics.h" |
12 #include "services/ui/ws/frame_generator.h" | 12 #include "services/ui/ws/frame_generator.h" |
13 #include "services/ui/ws/frame_generator_delegate.h" | 13 #include "services/ui/ws/frame_generator_delegate.h" |
14 #include "services/ui/ws/platform_display.h" | 14 #include "services/ui/ws/platform_display.h" |
15 #include "services/ui/ws/platform_display_delegate.h" | 15 #include "services/ui/ws/platform_display_delegate.h" |
| 16 #include "services/ui/ws/server_window.h" |
16 #include "ui/platform_window/platform_window_delegate.h" | 17 #include "ui/platform_window/platform_window_delegate.h" |
17 | 18 |
18 namespace ui { | 19 namespace ui { |
19 | 20 |
20 class ImageCursors; | 21 class ImageCursors; |
21 class LocatedEvent; | 22 class LocatedEvent; |
22 class PlatformWindow; | 23 class PlatformWindow; |
23 | 24 |
24 namespace ws { | 25 namespace ws { |
25 | 26 |
26 // PlatformDisplay implementation that connects to a PlatformWindow and | 27 // PlatformDisplay implementation that connects to a PlatformWindow and |
27 // FrameGenerator for Chrome OS. | 28 // FrameGenerator for Chrome OS. |
28 class PlatformDisplayDefault : public PlatformDisplay, | 29 class PlatformDisplayDefault : public PlatformDisplay, |
29 public ui::PlatformWindowDelegate, | 30 public ui::PlatformWindowDelegate, |
30 public FrameGeneratorDelegate { | 31 public FrameGeneratorDelegate { |
31 public: | 32 public: |
32 explicit PlatformDisplayDefault(const PlatformDisplayInitParams& init_params); | 33 PlatformDisplayDefault(ServerWindow* root_window, |
| 34 const display::ViewportMetrics& metrics); |
33 ~PlatformDisplayDefault() override; | 35 ~PlatformDisplayDefault() override; |
34 | 36 |
35 // PlatformDisplay: | 37 // PlatformDisplay: |
36 void Init(PlatformDisplayDelegate* delegate) override; | 38 void Init(PlatformDisplayDelegate* delegate) override; |
37 int64_t GetId() const override; | |
38 void SetViewportSize(const gfx::Size& size) override; | 39 void SetViewportSize(const gfx::Size& size) override; |
39 void SetTitle(const base::string16& title) override; | 40 void SetTitle(const base::string16& title) override; |
40 void SetCapture() override; | 41 void SetCapture() override; |
41 void ReleaseCapture() override; | 42 void ReleaseCapture() override; |
42 void SetCursorById(mojom::Cursor cursor) override; | 43 void SetCursorById(mojom::Cursor cursor) override; |
43 void UpdateTextInputState(const ui::TextInputState& state) override; | 44 void UpdateTextInputState(const ui::TextInputState& state) override; |
44 void SetImeVisibility(bool visible) override; | 45 void SetImeVisibility(bool visible) override; |
45 gfx::Rect GetBounds() const override; | |
46 bool UpdateViewportMetrics(const display::ViewportMetrics& metrics) override; | 46 bool UpdateViewportMetrics(const display::ViewportMetrics& metrics) override; |
47 const display::ViewportMetrics& GetViewportMetrics() const override; | |
48 gfx::AcceleratedWidget GetAcceleratedWidget() const override; | 47 gfx::AcceleratedWidget GetAcceleratedWidget() const override; |
49 FrameGenerator* GetFrameGenerator() override; | 48 FrameGenerator* GetFrameGenerator() override; |
50 | 49 |
51 private: | 50 private: |
52 // Update the root_location of located events to be relative to the origin | 51 // Update the root_location of located events to be relative to the origin |
53 // of this display. For example, if the origin of this display is (1800, 0) | 52 // of this display. For example, if the origin of this display is (1800, 0) |
54 // and the location of the event is (100, 200) then the root_location will be | 53 // and the location of the event is (100, 200) then the root_location will be |
55 // updated to be (1900, 200). | 54 // updated to be (1900, 200). |
56 // TODO(riajiang): This is totally broken with HDPI. | 55 // TODO(riajiang): This is totally broken with HDPI. |
57 void UpdateEventRootLocation(ui::LocatedEvent* event); | 56 void UpdateEventRootLocation(ui::LocatedEvent* event); |
58 | 57 |
59 // ui::PlatformWindowDelegate: | 58 // ui::PlatformWindowDelegate: |
60 void OnBoundsChanged(const gfx::Rect& new_bounds) override; | 59 void OnBoundsChanged(const gfx::Rect& new_bounds) override; |
61 void OnDamageRect(const gfx::Rect& damaged_region) override; | 60 void OnDamageRect(const gfx::Rect& damaged_region) override; |
62 void DispatchEvent(ui::Event* event) override; | 61 void DispatchEvent(ui::Event* event) override; |
63 void OnCloseRequest() override; | 62 void OnCloseRequest() override; |
64 void OnClosed() override; | 63 void OnClosed() override; |
65 void OnWindowStateChanged(ui::PlatformWindowState new_state) override; | 64 void OnWindowStateChanged(ui::PlatformWindowState new_state) override; |
66 void OnLostCapture() override; | 65 void OnLostCapture() override; |
67 void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget, | 66 void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget, |
68 float device_scale_factor) override; | 67 float device_scale_factor) override; |
69 void OnAcceleratedWidgetDestroyed() override; | 68 void OnAcceleratedWidgetDestroyed() override; |
70 void OnActivationChanged(bool active) override; | 69 void OnActivationChanged(bool active) override; |
71 | 70 |
72 // FrameGeneratorDelegate: | 71 // FrameGeneratorDelegate: |
73 bool IsInHighContrastMode() override; | 72 bool IsInHighContrastMode() override; |
74 | 73 |
75 const int64_t display_id_; | 74 ServerWindow* root_window_; |
76 | 75 |
77 #if !defined(OS_ANDROID) | 76 #if !defined(OS_ANDROID) |
78 std::unique_ptr<ui::ImageCursors> image_cursors_; | 77 std::unique_ptr<ui::ImageCursors> image_cursors_; |
79 #endif | 78 #endif |
80 | 79 |
81 PlatformDisplayDelegate* delegate_ = nullptr; | 80 PlatformDisplayDelegate* delegate_ = nullptr; |
82 std::unique_ptr<FrameGenerator> frame_generator_; | 81 std::unique_ptr<FrameGenerator> frame_generator_; |
83 | 82 |
84 display::ViewportMetrics metrics_; | 83 display::ViewportMetrics metrics_; |
85 std::unique_ptr<ui::PlatformWindow> platform_window_; | 84 std::unique_ptr<ui::PlatformWindow> platform_window_; |
86 gfx::AcceleratedWidget widget_; | 85 gfx::AcceleratedWidget widget_; |
87 ServerWindow* root_window_; | |
88 float init_device_scale_factor_; | 86 float init_device_scale_factor_; |
89 | 87 |
90 DISALLOW_COPY_AND_ASSIGN(PlatformDisplayDefault); | 88 DISALLOW_COPY_AND_ASSIGN(PlatformDisplayDefault); |
91 }; | 89 }; |
92 | 90 |
93 } // namespace ws | 91 } // namespace ws |
94 } // namespace ui | 92 } // namespace ui |
95 | 93 |
96 #endif // SERVICES_UI_WS_PLATFORM_DISPLAY_DEFAULT_H_ | 94 #endif // SERVICES_UI_WS_PLATFORM_DISPLAY_DEFAULT_H_ |
OLD | NEW |