| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_NATIVE_WIDGET_MUS_H_ | 5 #ifndef UI_VIEWS_MUS_NATIVE_WIDGET_MUS_H_ |
| 6 #define UI_VIEWS_MUS_NATIVE_WIDGET_MUS_H_ | 6 #define UI_VIEWS_MUS_NATIVE_WIDGET_MUS_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <string> | 12 #include <string> |
| 13 | 13 |
| 14 #include "base/callback.h" | 14 #include "base/callback.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
| 17 #include "services/ui/public/cpp/input_event_handler.h" | 17 #include "services/ui/public/cpp/input_event_handler.h" |
| 18 #include "services/ui/public/interfaces/window_tree.mojom.h" | 18 #include "services/ui/public/interfaces/window_tree.mojom.h" |
| 19 #include "ui/aura/window_delegate.h" | 19 #include "ui/aura/window_delegate.h" |
| 20 #include "ui/aura/window_tree_host_observer.h" | 20 #include "ui/aura/window_tree_host_observer.h" |
| 21 #include "ui/platform_window/platform_window_delegate.h" | 21 #include "ui/platform_window/platform_window_delegate.h" |
| 22 #include "ui/views/mus/mus_export.h" | 22 #include "ui/views/mus/mus_export.h" |
| 23 #include "ui/views/mus/window_tree_host_mus.h" | 23 #include "ui/views/mus/window_tree_host_mus.h" |
| 24 #include "ui/views/widget/native_widget_private.h" | 24 #include "ui/views/widget/native_widget_private.h" |
| 25 #include "ui/wm/public/drag_drop_delegate.h" |
| 25 | 26 |
| 26 namespace aura { | 27 namespace aura { |
| 27 namespace client { | 28 namespace client { |
| 28 class DefaultCaptureClient; | 29 class DefaultCaptureClient; |
| 29 class ScreenPositionClient; | 30 class ScreenPositionClient; |
| 30 class WindowTreeClient; | 31 class WindowTreeClient; |
| 31 } | 32 } |
| 32 class Window; | 33 class Window; |
| 33 } | 34 } |
| 34 | 35 |
| 35 namespace ui { | 36 namespace ui { |
| 36 class Window; | 37 class Window; |
| 37 class WindowTreeClient; | 38 class WindowTreeClient; |
| 38 namespace mojom { | 39 namespace mojom { |
| 39 enum class Cursor; | 40 enum class Cursor; |
| 40 enum class EventResult; | 41 enum class EventResult; |
| 41 } | 42 } |
| 42 } | 43 } |
| 43 | 44 |
| 44 namespace ui { | 45 namespace ui { |
| 45 class Event; | 46 class Event; |
| 46 } | 47 } |
| 47 | 48 |
| 48 namespace wm { | 49 namespace wm { |
| 49 class CursorManager; | 50 class CursorManager; |
| 50 class FocusController; | 51 class FocusController; |
| 51 } | 52 } |
| 52 | 53 |
| 53 namespace views { | 54 namespace views { |
| 55 class DropHelper; |
| 56 class DropTargetMus; |
| 54 class WidgetDelegate; | 57 class WidgetDelegate; |
| 55 | 58 |
| 56 // An implementation of NativeWidget that binds to a ui::Window. Because Aura | 59 // An implementation of NativeWidget that binds to a ui::Window. Because Aura |
| 57 // is used extensively within Views code, this code uses aura and binds to the | 60 // is used extensively within Views code, this code uses aura and binds to the |
| 58 // ui::Window via a Mus-specific aura::WindowTreeHost impl. Because the root | 61 // ui::Window via a Mus-specific aura::WindowTreeHost impl. Because the root |
| 59 // aura::Window in a hierarchy is created without a delegate by the | 62 // aura::Window in a hierarchy is created without a delegate by the |
| 60 // aura::WindowTreeHost, we must create a child aura::Window in this class | 63 // aura::WindowTreeHost, we must create a child aura::Window in this class |
| 61 // (content_) and attach it to the root. | 64 // (content_) and attach it to the root. |
| 62 class VIEWS_MUS_EXPORT NativeWidgetMus | 65 class VIEWS_MUS_EXPORT NativeWidgetMus |
| 63 : public internal::NativeWidgetPrivate, | 66 : public internal::NativeWidgetPrivate, |
| 64 public aura::WindowDelegate, | 67 public aura::WindowDelegate, |
| 65 public aura::WindowTreeHostObserver, | 68 public aura::WindowTreeHostObserver, |
| 69 public aura::client::DragDropDelegate, |
| 66 public NON_EXPORTED_BASE(ui::InputEventHandler) { | 70 public NON_EXPORTED_BASE(ui::InputEventHandler) { |
| 67 public: | 71 public: |
| 68 NativeWidgetMus(internal::NativeWidgetDelegate* delegate, | 72 NativeWidgetMus(internal::NativeWidgetDelegate* delegate, |
| 69 ui::Window* window, | 73 ui::Window* window, |
| 70 ui::mojom::SurfaceType surface_type); | 74 ui::mojom::SurfaceType surface_type); |
| 71 ~NativeWidgetMus() override; | 75 ~NativeWidgetMus() override; |
| 72 | 76 |
| 73 // Configures the set of properties supplied to the window manager when | 77 // Configures the set of properties supplied to the window manager when |
| 74 // creating a new Window for a Widget. | 78 // creating a new Window for a Widget. |
| 75 static void ConfigurePropertiesForNewWindow( | 79 static void ConfigurePropertiesForNewWindow( |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 bool IsMaximized() const override; | 161 bool IsMaximized() const override; |
| 158 bool IsMinimized() const override; | 162 bool IsMinimized() const override; |
| 159 void Restore() override; | 163 void Restore() override; |
| 160 void SetFullscreen(bool fullscreen) override; | 164 void SetFullscreen(bool fullscreen) override; |
| 161 bool IsFullscreen() const override; | 165 bool IsFullscreen() const override; |
| 162 void SetOpacity(float opacity) override; | 166 void SetOpacity(float opacity) override; |
| 163 void FlashFrame(bool flash_frame) override; | 167 void FlashFrame(bool flash_frame) override; |
| 164 void RunShellDrag(View* view, | 168 void RunShellDrag(View* view, |
| 165 const ui::OSExchangeData& data, | 169 const ui::OSExchangeData& data, |
| 166 const gfx::Point& location, | 170 const gfx::Point& location, |
| 167 int operation, | 171 int drag_operations, |
| 168 ui::DragDropTypes::DragEventSource source) override; | 172 ui::DragDropTypes::DragEventSource source) override; |
| 169 void SchedulePaintInRect(const gfx::Rect& rect) override; | 173 void SchedulePaintInRect(const gfx::Rect& rect) override; |
| 170 void SetCursor(gfx::NativeCursor cursor) override; | 174 void SetCursor(gfx::NativeCursor cursor) override; |
| 171 bool IsMouseEventsEnabled() const override; | 175 bool IsMouseEventsEnabled() const override; |
| 172 void ClearNativeFocus() override; | 176 void ClearNativeFocus() override; |
| 173 gfx::Rect GetWorkAreaBoundsInScreen() const override; | 177 gfx::Rect GetWorkAreaBoundsInScreen() const override; |
| 174 Widget::MoveLoopResult RunMoveLoop( | 178 Widget::MoveLoopResult RunMoveLoop( |
| 175 const gfx::Vector2d& drag_offset, | 179 const gfx::Vector2d& drag_offset, |
| 176 Widget::MoveLoopSource source, | 180 Widget::MoveLoopSource source, |
| 177 Widget::MoveLoopEscapeBehavior escape_behavior) override; | 181 Widget::MoveLoopEscapeBehavior escape_behavior) override; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 void OnMouseEvent(ui::MouseEvent* event) override; | 216 void OnMouseEvent(ui::MouseEvent* event) override; |
| 213 void OnScrollEvent(ui::ScrollEvent* event) override; | 217 void OnScrollEvent(ui::ScrollEvent* event) override; |
| 214 void OnGestureEvent(ui::GestureEvent* event) override; | 218 void OnGestureEvent(ui::GestureEvent* event) override; |
| 215 | 219 |
| 216 // Overridden from aura::WindowTreeHostObserver: | 220 // Overridden from aura::WindowTreeHostObserver: |
| 217 void OnHostResized(const aura::WindowTreeHost* host) override; | 221 void OnHostResized(const aura::WindowTreeHost* host) override; |
| 218 void OnHostMoved(const aura::WindowTreeHost* host, | 222 void OnHostMoved(const aura::WindowTreeHost* host, |
| 219 const gfx::Point& new_origin) override; | 223 const gfx::Point& new_origin) override; |
| 220 void OnHostCloseRequested(const aura::WindowTreeHost* host) override; | 224 void OnHostCloseRequested(const aura::WindowTreeHost* host) override; |
| 221 | 225 |
| 226 // Overridden from aura::client::DragDropDelegate: |
| 227 void OnDragEntered(const ui::DropTargetEvent& event) override; |
| 228 int OnDragUpdated(const ui::DropTargetEvent& event) override; |
| 229 void OnDragExited() override; |
| 230 int OnPerformDrop(const ui::DropTargetEvent& event) override; |
| 231 |
| 222 // Overridden from ui::InputEventHandler: | 232 // Overridden from ui::InputEventHandler: |
| 223 void OnWindowInputEvent( | 233 void OnWindowInputEvent( |
| 224 ui::Window* view, | 234 ui::Window* view, |
| 225 const ui::Event& event, | 235 const ui::Event& event, |
| 226 std::unique_ptr<base::Callback<void(ui::mojom::EventResult)>>* | 236 std::unique_ptr<base::Callback<void(ui::mojom::EventResult)>>* |
| 227 ack_callback) override; | 237 ack_callback) override; |
| 228 | 238 |
| 229 private: | 239 private: |
| 230 friend class NativeWidgetMusTest; | 240 friend class NativeWidgetMusTest; |
| 231 class MusWindowObserver; | 241 class MusWindowObserver; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 | 275 |
| 266 // Functions with the same name require the ui::WindowObserver to be in | 276 // Functions with the same name require the ui::WindowObserver to be in |
| 267 // a separate class. | 277 // a separate class. |
| 268 std::unique_ptr<MusWindowObserver> mus_window_observer_; | 278 std::unique_ptr<MusWindowObserver> mus_window_observer_; |
| 269 | 279 |
| 270 // This is misnamed; The native widget interface offers something called | 280 // This is misnamed; The native widget interface offers something called |
| 271 // "native window properties" which are properties which it stores locally, | 281 // "native window properties" which are properties which it stores locally, |
| 272 // and this is used to unsafely pass void* pointers around chrome. | 282 // and this is used to unsafely pass void* pointers around chrome. |
| 273 std::map<std::string, void*> native_window_properties_; | 283 std::map<std::string, void*> native_window_properties_; |
| 274 | 284 |
| 285 // Receives drop events for |window_|. |
| 286 std::unique_ptr<DropTargetMus> drop_target_; |
| 287 |
| 275 // Aura configuration. | 288 // Aura configuration. |
| 276 std::unique_ptr<WindowTreeHostMus> window_tree_host_; | 289 std::unique_ptr<WindowTreeHostMus> window_tree_host_; |
| 277 aura::Window* content_; | 290 aura::Window* content_; |
| 278 std::unique_ptr<wm::FocusController> focus_client_; | 291 std::unique_ptr<wm::FocusController> focus_client_; |
| 279 std::unique_ptr<MusCaptureClient> capture_client_; | 292 std::unique_ptr<MusCaptureClient> capture_client_; |
| 280 std::unique_ptr<aura::client::WindowTreeClient> window_tree_client_; | 293 std::unique_ptr<aura::client::WindowTreeClient> window_tree_client_; |
| 281 std::unique_ptr<aura::client::ScreenPositionClient> screen_position_client_; | 294 std::unique_ptr<aura::client::ScreenPositionClient> screen_position_client_; |
| 282 std::unique_ptr<wm::CursorManager> cursor_manager_; | 295 std::unique_ptr<wm::CursorManager> cursor_manager_; |
| 283 | 296 |
| 297 std::unique_ptr<DropHelper> drop_helper_; |
| 298 int last_drop_operation_; |
| 299 |
| 284 base::WeakPtrFactory<NativeWidgetMus> close_widget_factory_; | 300 base::WeakPtrFactory<NativeWidgetMus> close_widget_factory_; |
| 285 | 301 |
| 286 DISALLOW_COPY_AND_ASSIGN(NativeWidgetMus); | 302 DISALLOW_COPY_AND_ASSIGN(NativeWidgetMus); |
| 287 }; | 303 }; |
| 288 | 304 |
| 289 } // namespace views | 305 } // namespace views |
| 290 | 306 |
| 291 #endif // UI_VIEWS_MUS_NATIVE_WIDGET_MUS_H_ | 307 #endif // UI_VIEWS_MUS_NATIVE_WIDGET_MUS_H_ |
| OLD | NEW |