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

Side by Side Diff: mash/simple_wm/move_loop.cc

Issue 2587183002: Adds sizing, maximizing, minimizing to simple_wm (Closed)
Patch Set: . Created 4 years 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 unified diff | Download patch
« no previous file with comments | « mash/simple_wm/move_loop.h ('k') | mash/simple_wm/simple_wm.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "mash/simple_wm/move_loop.h" 5 #include "mash/simple_wm/move_loop.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/memory/ptr_util.h" 8 #include "base/memory/ptr_util.h"
9 #include "ui/aura/client/aura_constants.h"
9 #include "ui/aura/window.h" 10 #include "ui/aura/window.h"
10 #include "ui/base/hit_test.h" 11 #include "ui/base/hit_test.h"
12 #include "ui/base/ui_base_types.h"
11 #include "ui/events/event.h" 13 #include "ui/events/event.h"
12 #include "ui/gfx/geometry/point_conversions.h" 14 #include "ui/gfx/geometry/point_conversions.h"
13 #include "ui/gfx/geometry/rect.h" 15 #include "ui/gfx/geometry/rect.h"
14 16
15 namespace simple_wm { 17 namespace simple_wm {
16 namespace { 18 namespace {
17 19
18 int MouseOnlyEventFlags(int flags) { 20 int MouseOnlyEventFlags(int flags) {
19 return flags & (ui::EF_LEFT_MOUSE_BUTTON | ui::EF_MIDDLE_MOUSE_BUTTON | 21 return flags & (ui::EF_LEFT_MOUSE_BUTTON | ui::EF_MIDDLE_MOUSE_BUTTON |
20 ui::EF_RIGHT_MOUSE_BUTTON); 22 ui::EF_RIGHT_MOUSE_BUTTON);
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 *type = Type::RESIZE; 154 *type = Type::RESIZE;
153 *h_loc = HorizontalLocation::LEFT; 155 *h_loc = HorizontalLocation::LEFT;
154 return true; 156 return true;
155 default: 157 default:
156 break; 158 break;
157 } 159 }
158 return false; 160 return false;
159 } 161 }
160 162
161 void MoveLoop::MoveImpl(const ui::PointerEvent& event) { 163 void MoveLoop::MoveImpl(const ui::PointerEvent& event) {
164 ui::WindowShowState show_state =
165 target_->GetProperty(aura::client::kShowStateKey);
166 // TODO(beng): figure out if there might not be another place to put this,
167 // perhaps prior to move loop creation.
168 if (show_state == ui::SHOW_STATE_MAXIMIZED) {
169 base::AutoReset<bool> resetter(&changing_bounds_, true);
170 target_->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
171 gfx::Rect restored_bounds =
172 *target_->GetProperty(aura::client::kRestoreBoundsKey);
173 // TODO(beng): Not just enough to adjust width and height, probably also
174 // need to take some action to recenter the window relative to
175 // the pointer position within the titlebar.
176 initial_window_bounds_.set_width(restored_bounds.width());
177 initial_window_bounds_.set_height(restored_bounds.height());
178 }
162 const gfx::Vector2d delta = 179 const gfx::Vector2d delta =
163 event.root_location() - initial_event_screen_location_; 180 event.root_location() - initial_event_screen_location_;
164 const gfx::Rect new_bounds(DetermineBoundsFromDelta(delta)); 181 const gfx::Rect new_bounds(DetermineBoundsFromDelta(delta));
165 base::AutoReset<bool> resetter(&changing_bounds_, true); 182 base::AutoReset<bool> resetter(&changing_bounds_, true);
166 target_->SetBounds(new_bounds); 183 target_->SetBounds(new_bounds);
167 //SetWindowUserSetBounds(target_, new_bounds); 184 //SetWindowUserSetBounds(target_, new_bounds);
168 } 185 }
169 186
170 void MoveLoop::Cancel() { 187 void MoveLoop::Cancel() {
171 target_->RemoveObserver(this); 188 target_->RemoveObserver(this);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 if (!changing_bounds_) 231 if (!changing_bounds_)
215 Cancel(); 232 Cancel();
216 } 233 }
217 234
218 void MoveLoop::OnWindowVisibilityChanged(aura::Window* window, bool visible) { 235 void MoveLoop::OnWindowVisibilityChanged(aura::Window* window, bool visible) {
219 DCHECK_EQ(window, target_); 236 DCHECK_EQ(window, target_);
220 Cancel(); 237 Cancel();
221 } 238 }
222 239
223 } // namespace simple_wm 240 } // namespace simple_wm
OLDNEW
« no previous file with comments | « mash/simple_wm/move_loop.h ('k') | mash/simple_wm/simple_wm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698