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..0b3caf767dae7eb893275267c5348958e5090733 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 { |
@@ -804,14 +813,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 +1175,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) { |
@@ -1345,6 +1373,17 @@ void NativeWidgetMus::OnGestureEvent(ui::GestureEvent* event) { |
native_widget_delegate_->OnGestureEvent(event); |
} |
+void NativeWidgetMus::OnHostResized(const aura::WindowTreeHost* host) { |
sky
2016/06/30 23:23:54
How come both this and NativeWidgetMus::OnBoundsCh
Elliot Glaysher
2016/07/01 00:09:58
I changed it, didn't notice any problems locally a
|
+ gfx::Rect new_bounds = gfx::Rect(host->window()->bounds().size()); |
+ content_->SetBounds(new_bounds); |
+ native_widget_delegate_->OnNativeWidgetSizeChanged(new_bounds.size()); |
+} |
+ |
+void NativeWidgetMus::OnHostMoved(const aura::WindowTreeHost* host, |
+ const gfx::Point& new_origin) { |
+ native_widget_delegate_->OnNativeWidgetMove(); |
+} |
+ |
void NativeWidgetMus::OnHostCloseRequested(const aura::WindowTreeHost* host) { |
GetWidget()->Close(); |
} |