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..2ebd568e708947d2f6f827544a4a560c41e4970a 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) { |
@@ -1231,18 +1259,8 @@ gfx::Size NativeWidgetMus::GetMaximumSize() const { |
void NativeWidgetMus::OnBoundsChanged(const gfx::Rect& old_bounds, |
const gfx::Rect& new_bounds) { |
- // Assume that if the old bounds was completely empty a move happened. This |
- // handles the case of a maximize animation acquiring the layer (acquiring a |
- // layer results in clearing the bounds). |
- if (old_bounds.origin() != new_bounds.origin() || |
- (old_bounds == gfx::Rect(0, 0, 0, 0) && !new_bounds.IsEmpty())) { |
- native_widget_delegate_->OnNativeWidgetMove(); |
- } |
- if (old_bounds.size() != new_bounds.size()) { |
- native_widget_delegate_->OnNativeWidgetSizeChanged(new_bounds.size()); |
- UpdateClientArea(); |
- UpdateHitTestMask(); |
- } |
+ // This is handled in OnHost{Resized,Moved}() like DesktopNativeWidgetAura |
+ // instead of here like in NativeWidgetAura. |
} |
gfx::NativeCursor NativeWidgetMus::GetCursor(const gfx::Point& point) { |
@@ -1345,6 +1363,19 @@ void NativeWidgetMus::OnGestureEvent(ui::GestureEvent* event) { |
native_widget_delegate_->OnGestureEvent(event); |
} |
+void NativeWidgetMus::OnHostResized(const aura::WindowTreeHost* host) { |
+ gfx::Rect new_bounds = gfx::Rect(host->window()->bounds().size()); |
+ content_->SetBounds(new_bounds); |
sadrul
2016/07/04 20:11:38
Do you need to SetBounds() here? It should already
Elliot Glaysher
2016/07/07 19:12:06
You're right that it isn't needed; I removed the c
|
+ native_widget_delegate_->OnNativeWidgetSizeChanged(new_bounds.size()); |
+ UpdateClientArea(); |
+ UpdateHitTestMask(); |
+} |
+ |
+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(); |
} |