| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_H_ | 5 #ifndef SERVICES_UI_WS_PLATFORM_DISPLAY_H_ |
| 6 #define SERVICES_UI_WS_PLATFORM_DISPLAY_H_ | 6 #define SERVICES_UI_WS_PLATFORM_DISPLAY_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 | 11 |
| 12 #include "base/macros.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/memory/weak_ptr.h" | |
| 14 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
| 15 #include "build/build_config.h" | |
| 16 #include "services/ui/display/viewport_metrics.h" | 14 #include "services/ui/display/viewport_metrics.h" |
| 17 #include "services/ui/public/interfaces/cursor.mojom.h" | 15 #include "services/ui/public/interfaces/cursor.mojom.h" |
| 18 #include "services/ui/public/interfaces/window_manager.mojom.h" | |
| 19 #include "services/ui/public/interfaces/window_manager_constants.mojom.h" | |
| 20 #include "services/ui/public/interfaces/window_tree.mojom.h" | |
| 21 #include "services/ui/ws/frame_generator.h" | |
| 22 #include "services/ui/ws/frame_generator_delegate.h" | |
| 23 #include "services/ui/ws/platform_display_delegate.h" | |
| 24 #include "ui/display/display.h" | |
| 25 #include "ui/platform_window/platform_window_delegate.h" | |
| 26 | 16 |
| 27 namespace gfx { | 17 namespace gfx { |
| 28 class Rect; | 18 class Rect; |
| 29 } | 19 } |
| 30 | 20 |
| 31 namespace gpu { | 21 namespace gpu { |
| 32 class GpuChannelHost; | 22 class GpuChannelHost; |
| 33 } | 23 } |
| 34 | 24 |
| 35 namespace ui { | 25 namespace ui { |
| 36 | 26 |
| 37 class CursorLoader; | |
| 38 class PlatformWindow; | |
| 39 struct TextInputState; | 27 struct TextInputState; |
| 40 | 28 |
| 41 namespace ws { | 29 namespace ws { |
| 42 | 30 |
| 31 class PlatformDisplayDelegate; |
| 43 class PlatformDisplayFactory; | 32 class PlatformDisplayFactory; |
| 44 struct PlatformDisplayInitParams; | 33 struct PlatformDisplayInitParams; |
| 45 class ServerWindow; | |
| 46 | 34 |
| 47 // PlatformDisplay is used to connect the root ServerWindow to a display. | 35 // PlatformDisplay is used to connect the root ServerWindow to a display. |
| 48 class PlatformDisplay { | 36 class PlatformDisplay { |
| 49 public: | 37 public: |
| 50 virtual ~PlatformDisplay() {} | 38 virtual ~PlatformDisplay() {} |
| 51 | 39 |
| 52 static std::unique_ptr<PlatformDisplay> Create( | 40 static std::unique_ptr<PlatformDisplay> Create( |
| 53 const PlatformDisplayInitParams& init_params); | 41 const PlatformDisplayInitParams& init_params); |
| 54 | 42 |
| 55 virtual int64_t GetId() const = 0; | 43 virtual int64_t GetId() const = 0; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 // (non-test) environment. | 77 // (non-test) environment. |
| 90 static void set_factory_for_testing(PlatformDisplayFactory* factory) { | 78 static void set_factory_for_testing(PlatformDisplayFactory* factory) { |
| 91 PlatformDisplay::factory_ = factory; | 79 PlatformDisplay::factory_ = factory; |
| 92 } | 80 } |
| 93 | 81 |
| 94 private: | 82 private: |
| 95 // Static factory instance (always NULL for non-test). | 83 // Static factory instance (always NULL for non-test). |
| 96 static PlatformDisplayFactory* factory_; | 84 static PlatformDisplayFactory* factory_; |
| 97 }; | 85 }; |
| 98 | 86 |
| 99 // PlatformDisplay implementation that connects to the services necessary to | |
| 100 // actually display. | |
| 101 class DefaultPlatformDisplay : public PlatformDisplay, | |
| 102 public ui::PlatformWindowDelegate, | |
| 103 private FrameGeneratorDelegate { | |
| 104 public: | |
| 105 explicit DefaultPlatformDisplay(const PlatformDisplayInitParams& init_params); | |
| 106 ~DefaultPlatformDisplay() override; | |
| 107 | |
| 108 // PlatformDisplay: | |
| 109 void Init(PlatformDisplayDelegate* delegate) override; | |
| 110 int64_t GetId() const override; | |
| 111 void SetViewportSize(const gfx::Size& size) override; | |
| 112 void SetTitle(const base::string16& title) override; | |
| 113 void SetCapture() override; | |
| 114 void ReleaseCapture() override; | |
| 115 void SetCursorById(mojom::Cursor cursor) override; | |
| 116 void UpdateTextInputState(const ui::TextInputState& state) override; | |
| 117 void SetImeVisibility(bool visible) override; | |
| 118 gfx::Rect GetBounds() const override; | |
| 119 bool UpdateViewportMetrics(const display::ViewportMetrics& metrics) override; | |
| 120 const display::ViewportMetrics& GetViewportMetrics() const override; | |
| 121 bool IsPrimaryDisplay() const override; | |
| 122 void OnGpuChannelEstablished( | |
| 123 scoped_refptr<gpu::GpuChannelHost> gpu_channel) override; | |
| 124 | |
| 125 private: | |
| 126 // Update the root_location of located events to be relative to the origin | |
| 127 // of this display. For example, if the origin of this display is (1800, 0) | |
| 128 // and the location of the event is (100, 200) then the root_location will be | |
| 129 // updated to be (1900, 200). | |
| 130 void UpdateEventRootLocation(ui::LocatedEvent* event); | |
| 131 | |
| 132 // ui::PlatformWindowDelegate: | |
| 133 void OnBoundsChanged(const gfx::Rect& new_bounds) override; | |
| 134 void OnDamageRect(const gfx::Rect& damaged_region) override; | |
| 135 void DispatchEvent(ui::Event* event) override; | |
| 136 void OnCloseRequest() override; | |
| 137 void OnClosed() override; | |
| 138 void OnWindowStateChanged(ui::PlatformWindowState new_state) override; | |
| 139 void OnLostCapture() override; | |
| 140 void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget, | |
| 141 float device_scale_factor) override; | |
| 142 void OnAcceleratedWidgetDestroyed() override; | |
| 143 void OnActivationChanged(bool active) override; | |
| 144 | |
| 145 // FrameGeneratorDelegate: | |
| 146 bool IsInHighContrastMode() override; | |
| 147 | |
| 148 int64_t id_; | |
| 149 | |
| 150 #if !defined(OS_ANDROID) | |
| 151 std::unique_ptr<ui::CursorLoader> cursor_loader_; | |
| 152 #endif | |
| 153 | |
| 154 PlatformDisplayDelegate* delegate_ = nullptr; | |
| 155 std::unique_ptr<FrameGenerator> frame_generator_; | |
| 156 | |
| 157 display::ViewportMetrics metrics_; | |
| 158 std::unique_ptr<ui::PlatformWindow> platform_window_; | |
| 159 | |
| 160 DISALLOW_COPY_AND_ASSIGN(DefaultPlatformDisplay); | |
| 161 }; | |
| 162 | 87 |
| 163 } // namespace ws | 88 } // namespace ws |
| 164 | |
| 165 } // namespace ui | 89 } // namespace ui |
| 166 | 90 |
| 167 #endif // SERVICES_UI_WS_PLATFORM_DISPLAY_H_ | 91 #endif // SERVICES_UI_WS_PLATFORM_DISPLAY_H_ |
| OLD | NEW |