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

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

Issue 13896026: Stick windows to sides of workspaces (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Dock with zero width (rebase) Created 7 years, 6 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
« no previous file with comments | « ash/wm/drag_window_resizer.h ('k') | ash/wm/drag_window_resizer_unittest.cc » ('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 (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/drag_window_resizer.h" 5 #include "ash/wm/drag_window_resizer.h"
6 6
7 #include "ash/display/mouse_cursor_event_filter.h" 7 #include "ash/display/mouse_cursor_event_filter.h"
8 #include "ash/screen_ash.h" 8 #include "ash/screen_ash.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/wm/coordinate_conversion.h" 10 #include "ash/wm/coordinate_conversion.h"
(...skipping 26 matching lines...) Expand all
37 aura::RootWindow* GetAnotherRootWindow(aura::RootWindow* root_window) { 37 aura::RootWindow* GetAnotherRootWindow(aura::RootWindow* root_window) {
38 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); 38 Shell::RootWindowList root_windows = Shell::GetAllRootWindows();
39 if (root_windows.size() < 2) 39 if (root_windows.size() < 2)
40 return NULL; 40 return NULL;
41 DCHECK_EQ(2U, root_windows.size()); 41 DCHECK_EQ(2U, root_windows.size());
42 if (root_windows[0] == root_window) 42 if (root_windows[0] == root_window)
43 return root_windows[1]; 43 return root_windows[1];
44 return root_windows[0]; 44 return root_windows[0];
45 } 45 }
46 46
47 } 47 } // namespace
48
49 // static
50 DragWindowResizer* DragWindowResizer::instance_ = NULL;
48 51
49 DragWindowResizer::~DragWindowResizer() { 52 DragWindowResizer::~DragWindowResizer() {
50 Shell* shell = Shell::GetInstance(); 53 Shell* shell = Shell::GetInstance();
51 shell->mouse_cursor_filter()->set_mouse_warp_mode( 54 shell->mouse_cursor_filter()->set_mouse_warp_mode(
52 MouseCursorEventFilter::WARP_ALWAYS); 55 MouseCursorEventFilter::WARP_ALWAYS);
53 shell->mouse_cursor_filter()->HideSharedEdgeIndicator(); 56 shell->mouse_cursor_filter()->HideSharedEdgeIndicator();
57 if (instance_ == this)
58 instance_ = NULL;
54 59
55 if (destroyed_) 60 if (destroyed_)
56 *destroyed_ = true; 61 *destroyed_ = true;
57 } 62 }
58 63
59 // static 64 // static
60 DragWindowResizer* DragWindowResizer::Create( 65 DragWindowResizer* DragWindowResizer::Create(
61 WindowResizer* next_window_resizer, 66 WindowResizer* next_window_resizer,
62 aura::Window* window, 67 aura::Window* window,
63 const gfx::Point& location, 68 const gfx::Point& location,
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 next_window_resizer_->RevertDrag(); 125 next_window_resizer_->RevertDrag();
121 126
122 drag_window_controller_.reset(); 127 drag_window_controller_.reset();
123 GetTarget()->layer()->SetOpacity(details_.initial_opacity); 128 GetTarget()->layer()->SetOpacity(details_.initial_opacity);
124 } 129 }
125 130
126 aura::Window* DragWindowResizer::GetTarget() { 131 aura::Window* DragWindowResizer::GetTarget() {
127 return next_window_resizer_->GetTarget(); 132 return next_window_resizer_->GetTarget();
128 } 133 }
129 134
135 const gfx::Point& DragWindowResizer::GetInitialLocation() const {
136 return details_.initial_location_in_parent;
137 }
138
130 DragWindowResizer::DragWindowResizer(WindowResizer* next_window_resizer, 139 DragWindowResizer::DragWindowResizer(WindowResizer* next_window_resizer,
131 const Details& details) 140 const Details& details)
132 : next_window_resizer_(next_window_resizer), 141 : next_window_resizer_(next_window_resizer),
133 details_(details), 142 details_(details),
134 destroyed_(NULL) { 143 destroyed_(NULL) {
135 // The pointer should be confined in one display during resizing a window 144 // The pointer should be confined in one display during resizing a window
136 // because the window cannot span two displays at the same time anyway. The 145 // because the window cannot span two displays at the same time anyway. The
137 // exception is window/tab dragging operation. During that operation, 146 // exception is window/tab dragging operation. During that operation,
138 // |mouse_warp_mode_| should be set to WARP_DRAG so that the user could move a 147 // |mouse_warp_mode_| should be set to WARP_DRAG so that the user could move a
139 // window/tab to another display. 148 // window/tab to another display.
140 MouseCursorEventFilter* mouse_cursor_filter = 149 MouseCursorEventFilter* mouse_cursor_filter =
141 Shell::GetInstance()->mouse_cursor_filter(); 150 Shell::GetInstance()->mouse_cursor_filter();
142 mouse_cursor_filter->set_mouse_warp_mode( 151 mouse_cursor_filter->set_mouse_warp_mode(
143 ShouldAllowMouseWarp() ? 152 ShouldAllowMouseWarp() ?
144 MouseCursorEventFilter::WARP_DRAG : MouseCursorEventFilter::WARP_NONE); 153 MouseCursorEventFilter::WARP_DRAG : MouseCursorEventFilter::WARP_NONE);
145 if (ShouldAllowMouseWarp()) { 154 if (ShouldAllowMouseWarp()) {
146 mouse_cursor_filter->ShowSharedEdgeIndicator( 155 mouse_cursor_filter->ShowSharedEdgeIndicator(
147 details.window->GetRootWindow()); 156 details.window->GetRootWindow());
148 } 157 }
158 instance_ = this;
149 } 159 }
150 160
151 void DragWindowResizer::UpdateDragWindow(const gfx::Rect& bounds, 161 void DragWindowResizer::UpdateDragWindow(const gfx::Rect& bounds,
152 bool in_original_root) { 162 bool in_original_root) {
153 if (details_.window_component != HTCAPTION || !ShouldAllowMouseWarp()) 163 if (details_.window_component != HTCAPTION || !ShouldAllowMouseWarp())
154 return; 164 return;
155 165
156 // It's available. Show a phantom window on the display if needed. 166 // It's available. Show a phantom window on the display if needed.
157 aura::RootWindow* another_root = 167 aura::RootWindow* another_root =
158 GetAnotherRootWindow(GetTarget()->GetRootWindow()); 168 GetAnotherRootWindow(GetTarget()->GetRootWindow());
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 202
193 bool DragWindowResizer::ShouldAllowMouseWarp() { 203 bool DragWindowResizer::ShouldAllowMouseWarp() {
194 return (details_.window_component == HTCAPTION) && 204 return (details_.window_component == HTCAPTION) &&
195 !GetTarget()->transient_parent() && 205 !GetTarget()->transient_parent() &&
196 (GetTarget()->type() == aura::client::WINDOW_TYPE_NORMAL || 206 (GetTarget()->type() == aura::client::WINDOW_TYPE_NORMAL ||
197 GetTarget()->type() == aura::client::WINDOW_TYPE_PANEL); 207 GetTarget()->type() == aura::client::WINDOW_TYPE_PANEL);
198 } 208 }
199 209
200 } // namespace internal 210 } // namespace internal
201 } // namespace ash 211 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/drag_window_resizer.h ('k') | ash/wm/drag_window_resizer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698