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

Unified Diff: components/mus/example/wm/move_loop.cc

Issue 1414943003: Moves move logic into WM instead of WS (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix compile Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/mus/example/wm/move_loop.h ('k') | components/mus/example/wm/window_manager_application.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/mus/example/wm/move_loop.cc
diff --git a/components/mus/ws/move_loop.cc b/components/mus/example/wm/move_loop.cc
similarity index 74%
rename from components/mus/ws/move_loop.cc
rename to components/mus/example/wm/move_loop.cc
index 56faa75edb7e934811565bdffb4228e55fd2cf2d..c5dc87897aab560b5c9926aae7afb3fe7c5898cb 100644
--- a/components/mus/ws/move_loop.cc
+++ b/components/mus/example/wm/move_loop.cc
@@ -2,16 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "components/mus/ws/move_loop.h"
+#include "components/mus/example/wm/move_loop.h"
#include "base/auto_reset.h"
-#include "components/mus/ws/server_window.h"
+#include "components/mus/public/cpp/window.h"
+#include "mojo/converters/geometry/geometry_type_converters.h"
#include "ui/gfx/geometry/point_conversions.h"
#include "ui/gfx/geometry/rect.h"
#include "ui/mojo/events/input_event_constants.mojom.h"
-namespace mus {
-namespace ws {
namespace {
gfx::Point EventLocationToPoint(const mojo::Event& event) {
@@ -40,13 +39,12 @@ MoveLoop::~MoveLoop() {
}
// static
-scoped_ptr<MoveLoop> MoveLoop::Create(ServerWindow* target,
+scoped_ptr<MoveLoop> MoveLoop::Create(mus::Window* target,
const mojo::Event& event) {
- DCHECK(event.action == mojo::EVENT_TYPE_POINTER_DOWN);
+ DCHECK_EQ(event.action, mojo::EVENT_TYPE_POINTER_DOWN);
const gfx::Point location(EventLocationToPoint(event));
- if (!target->parent() || !target->parent()->is_draggable_window_container() ||
- !gfx::Rect(target->bounds().size()).Contains(location) ||
- target->client_area().Contains(location)) {
+ if (!gfx::Rect(target->bounds().To<gfx::Rect>().size()).Contains(location) ||
+ target->client_area().To<gfx::Rect>().Contains(location)) {
return nullptr;
}
@@ -90,11 +88,11 @@ MoveLoop::MoveResult MoveLoop::Move(const mojo::Event& event) {
return MoveResult::CONTINUE;
}
-MoveLoop::MoveLoop(ServerWindow* target, const mojo::Event& event)
+MoveLoop::MoveLoop(mus::Window* target, const mojo::Event& event)
: target_(target),
pointer_id_(event.pointer_data->pointer_id),
initial_event_screen_location_(EventScreenLocationToPoint(event)),
- initial_window_bounds_(target->bounds()),
+ initial_window_bounds_(target->bounds().To<gfx::Rect>()),
changing_bounds_(false) {
target->AddObserver(this);
}
@@ -105,7 +103,7 @@ void MoveLoop::MoveImpl(const mojo::Event& event) {
const gfx::Rect new_bounds(initial_window_bounds_.origin() + delta,
initial_window_bounds_.size());
base::AutoReset<bool> resetter(&changing_bounds_, true);
- target_->SetBounds(new_bounds);
+ target_->SetBounds(*mojo::Rect::From(new_bounds));
}
void MoveLoop::Cancel() {
@@ -115,28 +113,23 @@ void MoveLoop::Cancel() {
void MoveLoop::Revert() {
base::AutoReset<bool> resetter(&changing_bounds_, true);
- target_->SetBounds(initial_window_bounds_);
+ target_->SetBounds(*mojo::Rect::From(initial_window_bounds_));
}
-void MoveLoop::OnWindowHierarchyChanged(ServerWindow* window,
- ServerWindow* new_parent,
- ServerWindow* old_parent) {
- DCHECK_EQ(window, target_);
- Cancel();
+void MoveLoop::OnTreeChanged(const TreeChangeParams& params) {
+ if (params.target == target_)
+ Cancel();
}
-void MoveLoop::OnWindowBoundsChanged(ServerWindow* window,
- const gfx::Rect& old_bounds,
- const gfx::Rect& new_bounds) {
+void MoveLoop::OnWindowBoundsChanged(mus::Window* window,
+ const mojo::Rect& old_bounds,
+ const mojo::Rect& new_bounds) {
DCHECK_EQ(window, target_);
if (!changing_bounds_)
Cancel();
}
-void MoveLoop::OnWindowVisibilityChanged(ServerWindow* window) {
+void MoveLoop::OnWindowVisibilityChanged(mus::Window* window) {
DCHECK_EQ(window, target_);
Cancel();
}
-
-} // namespace ws
-} // namespace mus
« no previous file with comments | « components/mus/example/wm/move_loop.h ('k') | components/mus/example/wm/window_manager_application.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698