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

Side by Side Diff: ash/wm/window_util.cc

Issue 14273008: Add ash-enable-sticky-edges for 'sticky' instead of 'snap' behavior. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ash/wm/window_util.h" 5 #include "ash/wm/window_util.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "ash/ash_constants.h" 9 #include "ash/ash_constants.h"
10 #include "ash/ash_switches.h"
10 #include "ash/root_window_controller.h" 11 #include "ash/root_window_controller.h"
11 #include "ash/shell.h" 12 #include "ash/shell.h"
12 #include "ash/shell_window_ids.h" 13 #include "ash/shell_window_ids.h"
13 #include "ash/wm/activation_controller.h" 14 #include "ash/wm/activation_controller.h"
14 #include "ash/wm/window_properties.h" 15 #include "ash/wm/window_properties.h"
16 #include "ash/wm/workspace/workspace_window_resizer.h"
17 #include "base/command_line.h"
15 #include "ui/aura/client/activation_client.h" 18 #include "ui/aura/client/activation_client.h"
16 #include "ui/aura/client/aura_constants.h" 19 #include "ui/aura/client/aura_constants.h"
17 #include "ui/aura/root_window.h" 20 #include "ui/aura/root_window.h"
18 #include "ui/aura/window.h" 21 #include "ui/aura/window.h"
19 #include "ui/aura/window_delegate.h" 22 #include "ui/aura/window_delegate.h"
20 #include "ui/compositor/layer.h" 23 #include "ui/compositor/layer.h"
21 #include "ui/gfx/display.h" 24 #include "ui/gfx/display.h"
22 #include "ui/gfx/rect.h" 25 #include "ui/gfx/rect.h"
23 #include "ui/gfx/screen.h" 26 #include "ui/gfx/screen.h"
24 #include "ui/views/corewm/window_util.h" 27 #include "ui/views/corewm/window_util.h"
25 #include "ui/views/view.h" 28 #include "ui/views/view.h"
26 #include "ui/views/widget/widget.h" 29 #include "ui/views/widget/widget.h"
27 30
31 namespace {
32
33 // Number of pixels of mouse movement required before windows drag or resize
34 // beyond the edge of a workspace.
35 const int kWindowStickySize = 64;
36
37 }
38
28 namespace ash { 39 namespace ash {
29 namespace wm { 40 namespace wm {
30 41
31 // TODO(beng): replace many of these functions with the corewm versions. 42 // TODO(beng): replace many of these functions with the corewm versions.
32 void ActivateWindow(aura::Window* window) { 43 void ActivateWindow(aura::Window* window) {
33 views::corewm::ActivateWindow(window); 44 views::corewm::ActivateWindow(window);
34 } 45 }
35 46
36 void DeactivateWindow(aura::Window* window) { 47 void DeactivateWindow(aura::Window* window) {
37 views::corewm::DeactivateWindow(window); 48 views::corewm::DeactivateWindow(window);
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 target->GetWidget()->GetNativeView()->GetRootWindow(); 222 target->GetWidget()->GetNativeView()->GetRootWindow();
212 if (!target_root || target_root == window->GetRootWindow()) 223 if (!target_root || target_root == window->GetRootWindow())
213 return false; 224 return false;
214 aura::Window* window_container = 225 aura::Window* window_container =
215 ash::Shell::GetContainer(target_root, window->parent()->id()); 226 ash::Shell::GetContainer(target_root, window->parent()->id());
216 // Move the window to the target launcher. 227 // Move the window to the target launcher.
217 window_container->AddChild(window); 228 window_container->AddChild(window);
218 return true; 229 return true;
219 } 230 }
220 231
232 bool ShouldStickToEdge(int distance_from_edge) {
233 if (CommandLine::ForCurrentProcess()->HasSwitch(
234 switches::kAshEnableStickyEdges)) {
235 return distance_from_edge < 0 &&
236 distance_from_edge > -kWindowStickySize;
237 } else {
238 const int sticky_size = internal::WorkspaceWindowResizer::kScreenEdgeInset;
flackr 2013/04/16 00:32:14 Assuming this method stays here we should probably
stevenjb 2013/04/16 20:08:20 Moved back.
239 return distance_from_edge < sticky_size &&
240 distance_from_edge > -sticky_size * 2;
241 }
242 }
243
221 } // namespace wm 244 } // namespace wm
222 } // namespace ash 245 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698