Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Side by Side Diff: ui/views/mus/native_widget_mus.h

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

Powered by Google App Engine
This is Rietveld 408576698