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 9bed4cca17d179f1dc34a82c230db8139edd6ec4..2c3fec31e461380f6fb6676645c5557eac7b1bad 100644 |
| --- a/ui/views/mus/native_widget_mus.cc |
| +++ b/ui/views/mus/native_widget_mus.cc |
| @@ -7,6 +7,7 @@ |
| #include "base/callback.h" |
| #include "base/macros.h" |
| #include "base/message_loop/message_loop.h" |
| +#include "base/run_loop.h" |
| #include "base/threading/thread_task_runner_handle.h" |
| #include "components/bitmap_uploader/bitmap_uploader.h" |
| #include "components/mus/public/cpp/property_type_converters.h" |
| @@ -29,6 +30,7 @@ |
| #include "ui/base/view_prop.h" |
| #include "ui/display/display.h" |
| #include "ui/display/screen.h" |
| +#include "ui/display/screen.h" |
| #include "ui/events/event.h" |
| #include "ui/gfx/canvas.h" |
| #include "ui/gfx/path.h" |
| @@ -328,7 +330,7 @@ SkBitmap AppIconFromDelegate(WidgetDelegate* delegate) { |
| return app_icon.GetRepresentation(1.f).sk_bitmap(); |
| } |
| -// Handles acknowledgement of an input event, either immediately when a nested |
| +// Handles acknowledgment of an input event, either immediately when a nested |
| // message loop starts, or upon destruction. |
| class EventAckHandler : public base::MessageLoop::NestingObserver { |
| public: |
| @@ -366,6 +368,13 @@ class EventAckHandler : public base::MessageLoop::NestingObserver { |
| DISALLOW_COPY_AND_ASSIGN(EventAckHandler); |
| }; |
| +void OnMoveLoopEnd(bool* out_success, |
| + base::Closure quit_closure, |
| + bool in_success) { |
| + *out_success = in_success; |
| + quit_closure.Run(); |
| +} |
| + |
| } // namespace |
| class NativeWidgetMus::MusWindowObserver : public mus::WindowObserver { |
| @@ -438,6 +447,13 @@ class NativeWidgetMus::MusWindowObserver : public mus::WindowObserver { |
| DCHECK_EQ(window, mus_window()); |
| window_tree_host()->SetBounds(new_bounds); |
| } |
| + void OnWindowBoundsChanged(mus::Window* window, |
| + const gfx::Rect& old_bounds, |
| + const gfx::Rect& new_bounds) override { |
| + Widget* widget = NativeWidgetMus::GetWidgetForWindow(window); |
|
sky
2016/06/30 00:18:31
How come NativeWidgetMus::OnBoundsChanged doesn't
Elliot Glaysher
2016/06/30 19:48:25
Because it doesn't get called in response to this.
|
| + if (widget) |
| + widget->OnNativeWidgetMove(); |
| + } |
| void OnWindowFocusChanged(mus::Window* gained_focus, |
| mus::Window* lost_focus) override { |
| if (gained_focus == mus_window()) |
| @@ -804,14 +820,14 @@ void NativeWidgetMus::ViewRemoved(View* view) { |
| // used safely in a world where we separate things with mojo. They should be |
| // removed; not ported. |
| void NativeWidgetMus::SetNativeWindowProperty(const char* name, void* value) { |
| - // TODO(beng): push properties to mus::Window. |
| - // NOTIMPLEMENTED(); |
| + native_window_properties_[name] = value; |
| } |
| void* NativeWidgetMus::GetNativeWindowProperty(const char* name) const { |
| - // TODO(beng): pull properties to mus::Window. |
| - // NOTIMPLEMENTED(); |
| - return nullptr; |
| + auto it = native_window_properties_.find(name); |
| + if (it == native_window_properties_.end()) |
| + return nullptr; |
| + return it->second; |
| } |
| TooltipManager* NativeWidgetMus::GetTooltipManager() const { |
| @@ -1166,12 +1182,31 @@ Widget::MoveLoopResult NativeWidgetMus::RunMoveLoop( |
| const gfx::Vector2d& drag_offset, |
| Widget::MoveLoopSource source, |
| Widget::MoveLoopEscapeBehavior escape_behavior) { |
| - // NOTIMPLEMENTED(); |
| - return Widget::MOVE_LOOP_CANCELED; |
| + ReleaseCapture(); |
| + |
| + base::MessageLoopForUI* loop = base::MessageLoopForUI::current(); |
| + base::MessageLoop::ScopedNestableTaskAllower allow_nested(loop); |
| + base::RunLoop run_loop; |
| + |
| + mus::mojom::MoveLoopSource mus_source = |
| + source == Widget::MOVE_LOOP_SOURCE_MOUSE ? |
| + mus::mojom::MoveLoopSource::MOUSE : |
| + mus::mojom::MoveLoopSource::TOUCH; |
| + |
| + bool success = false; |
| + gfx::Point cursor_location = |
| + display::Screen::GetScreen()->GetCursorScreenPoint(); |
| + window_->PerformWindowMove( |
| + mus_source, cursor_location, |
| + base::Bind(OnMoveLoopEnd, &success, run_loop.QuitClosure())); |
| + |
| + run_loop.Run(); |
| + |
| + return success ? Widget::MOVE_LOOP_SUCCESSFUL : Widget::MOVE_LOOP_CANCELED; |
| } |
| void NativeWidgetMus::EndMoveLoop() { |
| - // NOTIMPLEMENTED(); |
| + window_->CancelWindowMove(); |
| } |
| void NativeWidgetMus::SetVisibilityChangedAnimationsEnabled(bool value) { |