Chromium Code Reviews| Index: ui/views/mus/native_widget_mus.cc |
| diff --git a/ui/views/mus/native_widget_mus.cc b/ui/views/mus/native_widget_mus.cc |
| index 959b656065b347cef0eaa371f17eed9ab0c75cd7..35206cdcd85953b9ac48df5c217763db13035bf9 100644 |
| --- a/ui/views/mus/native_widget_mus.cc |
| +++ b/ui/views/mus/native_widget_mus.cc |
| @@ -4,6 +4,9 @@ |
| #include "ui/views/mus/native_widget_mus.h" |
| +#include <utility> |
| +#include <vector> |
| + |
| #include "base/callback.h" |
| #include "base/macros.h" |
| #include "base/message_loop/message_loop.h" |
| @@ -32,10 +35,14 @@ |
| #include "ui/gfx/path.h" |
| #include "ui/native_theme/native_theme_aura.h" |
| #include "ui/platform_window/platform_window_delegate.h" |
| +#include "ui/views/drag_utils.h" |
| +#include "ui/views/mus/drag_drop_client_mus.h" |
| +#include "ui/views/mus/drop_target_mus.h" |
| #include "ui/views/mus/window_manager_connection.h" |
| #include "ui/views/mus/window_manager_constants_converters.h" |
| #include "ui/views/mus/window_manager_frame_values.h" |
| #include "ui/views/mus/window_tree_host_mus.h" |
| +#include "ui/views/widget/drop_helper.h" |
| #include "ui/views/widget/native_widget_aura.h" |
| #include "ui/views/widget/widget_delegate.h" |
| #include "ui/views/window/custom_frame_view.h" |
| @@ -96,9 +103,9 @@ class FocusControllerMus : public wm::FocusController { |
| class ContentWindowLayoutManager : public aura::LayoutManager { |
| public: |
| - ContentWindowLayoutManager(aura::Window* outer, aura::Window* inner) |
| + ContentWindowLayoutManager(aura::Window* outer, aura::Window* inner) |
| : outer_(outer), inner_(inner) {} |
| - ~ContentWindowLayoutManager() override {} |
| + ~ContentWindowLayoutManager() override {} |
| private: |
| // aura::LayoutManager: |
| @@ -523,6 +530,7 @@ NativeWidgetMus::NativeWidgetMus(internal::NativeWidgetDelegate* delegate, |
| show_state_before_fullscreen_(ui::mojom::ShowState::DEFAULT), |
| ownership_(Widget::InitParams::NATIVE_WIDGET_OWNS_WIDGET), |
| content_(new aura::Window(this)), |
| + last_drop_operation_(ui::DragDropTypes::DRAG_NONE), |
| close_widget_factory_(this) { |
| window_->set_input_event_handler(this); |
| mus_window_observer_.reset(new MusWindowObserver(this)); |
| @@ -704,6 +712,11 @@ void NativeWidgetMus::InitNativeWidget(const Widget::InitParams& params) { |
| aura::client::SetScreenPositionClient(hosted_window, |
| screen_position_client_.get()); |
| + drop_target_.reset(new DropTargetMus(content_)); |
|
sky
2016/09/23 16:14:09
MakeUnique
Elliot Glaysher
2016/09/23 21:40:48
Changed entire file to use MakeUnique.
|
| + window_->SetCanAcceptDrops(drop_target_.get()); |
| + drop_helper_.reset(new DropHelper(GetWidget()->GetRootView())); |
|
sky
2016/09/23 16:14:09
MakeUnique
|
| + aura::client::SetDragDropDelegate(content_, this); |
| + |
| // TODO(erg): Remove this check when ash/mus/move_event_handler.cc's |
| // direct usage of ui::Window::SetPredefinedCursor() is switched to a |
| // private method on WindowManagerClient. |
| @@ -743,6 +756,16 @@ void NativeWidgetMus::InitNativeWidget(const Widget::InitParams& params) { |
| if (!params.bounds.size().IsEmpty()) |
| SetBounds(params.bounds); |
| + if (!params.parent) { |
|
sky
2016/09/23 16:14:09
I'm unclear as to why you don't create this for ev
Elliot Glaysher
2016/09/23 21:40:48
I'm not sure I believe that this is true.
It appe
sky
2016/09/26 02:12:59
See line 541, which creates the WindowTreeHost whi
Elliot Glaysher
2016/09/26 20:57:29
Disabled the test as discussed in person.
|
| + // On the desktop, we initialize some aura::clients on only the root |
| + // window; DesktopNativeWidgetAura and NativeWidgetAura do different |
| + // things. When we make a DesktopNativeWidgetMus (and that should be the |
| + // root NativeWidget in programs other than the window manager), these |
| + // should go there. |
| + drag_drop_client_.reset(new DragDropClientMus(content_, window_)); |
|
sky
2016/09/23 16:14:09
MakeUnique
|
| + aura::client::SetDragDropClient(hosted_window, drag_drop_client_.get()); |
| + } |
| + |
| // TODO(beng): much else, see [Desktop]NativeWidgetAura. |
| native_widget_delegate_->OnNativeWidgetCreated(false); |
| @@ -1150,13 +1173,13 @@ void NativeWidgetMus::FlashFrame(bool flash_frame) { |
| // NOTIMPLEMENTED(); |
| } |
| -void NativeWidgetMus::RunShellDrag( |
| - View* view, |
| - const ui::OSExchangeData& data, |
| - const gfx::Point& location, |
| - int operation, |
| - ui::DragDropTypes::DragEventSource source) { |
| - // NOTIMPLEMENTED(); |
| +void NativeWidgetMus::RunShellDrag(View* view, |
| + const ui::OSExchangeData& data, |
| + const gfx::Point& location, |
| + int drag_operations, |
| + ui::DragDropTypes::DragEventSource source) { |
| + if (window_) |
| + views::RunShellDrag(content_, data, location, drag_operations, source); |
| } |
| void NativeWidgetMus::SchedulePaintInRect(const gfx::Rect& rect) { |
| @@ -1410,6 +1433,36 @@ void NativeWidgetMus::OnHostCloseRequested(const aura::WindowTreeHost* host) { |
| GetWidget()->Close(); |
| } |
| +//////////////////////////////////////////////////////////////////////////////// |
| +// NativeWidgetMus, aura::WindowDragDropDelegate implementation: |
| + |
| +void NativeWidgetMus::OnDragEntered(const ui::DropTargetEvent& event) { |
| + DCHECK(drop_helper_); |
| + last_drop_operation_ = drop_helper_->OnDragOver( |
| + event.data(), event.location(), event.source_operations()); |
| +} |
| + |
| +int NativeWidgetMus::OnDragUpdated(const ui::DropTargetEvent& event) { |
| + DCHECK(drop_helper_); |
| + last_drop_operation_ = drop_helper_->OnDragOver( |
| + event.data(), event.location(), event.source_operations()); |
| + return last_drop_operation_; |
| +} |
| + |
| +void NativeWidgetMus::OnDragExited() { |
| + DCHECK(drop_helper_); |
| + drop_helper_->OnDragExit(); |
| +} |
| + |
| +int NativeWidgetMus::OnPerformDrop(const ui::DropTargetEvent& event) { |
| + DCHECK(drop_helper_); |
| + return drop_helper_->OnDrop(event.data(), event.location(), |
| + last_drop_operation_); |
| +} |
| + |
| +//////////////////////////////////////////////////////////////////////////////// |
| +// NativeWidgetMus, ui::InputEventHandler implementation: |
| + |
| void NativeWidgetMus::OnWindowInputEvent( |
| ui::Window* view, |
| const ui::Event& event_in, |