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

Side by Side Diff: ash/wm/dock/docked_window_resizer.cc

Issue 138003007: [Cleanup] Screen cleanup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: make sure screen_for_shutdown is reset everytime Created 6 years, 11 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/dock/docked_window_resizer.h" 5 #include "ash/wm/dock/docked_window_resizer.h"
6 6
7 #include "ash/display/display_controller.h" 7 #include "ash/display/display_controller.h"
8 #include "ash/root_window_controller.h" 8 #include "ash/root_window_controller.h"
9 #include "ash/screen_ash.h" 9 #include "ash/screen_util.h"
10 #include "ash/shelf/shelf.h" 10 #include "ash/shelf/shelf.h"
11 #include "ash/shelf/shelf_types.h" 11 #include "ash/shelf/shelf_types.h"
12 #include "ash/shelf/shelf_widget.h" 12 #include "ash/shelf/shelf_widget.h"
13 #include "ash/shell.h" 13 #include "ash/shell.h"
14 #include "ash/shell_window_ids.h" 14 #include "ash/shell_window_ids.h"
15 #include "ash/wm/coordinate_conversion.h" 15 #include "ash/wm/coordinate_conversion.h"
16 #include "ash/wm/dock/docked_window_layout_manager.h" 16 #include "ash/wm/dock/docked_window_layout_manager.h"
17 #include "ash/wm/window_state.h" 17 #include "ash/wm/window_state.h"
18 #include "ash/wm/window_util.h" 18 #include "ash/wm/window_util.h"
19 #include "ash/wm/workspace/magnetism_matcher.h" 19 #include "ash/wm/workspace/magnetism_matcher.h"
(...skipping 11 matching lines...) Expand all
31 #include "ui/gfx/screen.h" 31 #include "ui/gfx/screen.h"
32 #include "ui/views/widget/widget.h" 32 #include "ui/views/widget/widget.h"
33 33
34 namespace ash { 34 namespace ash {
35 namespace internal { 35 namespace internal {
36 36
37 namespace { 37 namespace {
38 38
39 DockedWindowLayoutManager* GetDockedLayoutManagerAtPoint( 39 DockedWindowLayoutManager* GetDockedLayoutManagerAtPoint(
40 const gfx::Point& point) { 40 const gfx::Point& point) {
41 gfx::Display display = ScreenAsh::FindDisplayContainingPoint(point); 41 gfx::Display display = ScreenUtil::FindDisplayContainingPoint(point);
42 if (!display.is_valid()) 42 if (!display.is_valid())
43 return NULL; 43 return NULL;
44 aura::Window* root = Shell::GetInstance()->display_controller()-> 44 aura::Window* root = Shell::GetInstance()->display_controller()->
45 GetRootWindowForDisplayId(display.id()); 45 GetRootWindowForDisplayId(display.id());
46 aura::Window* dock_container = Shell::GetContainer( 46 aura::Window* dock_container = Shell::GetContainer(
47 root, kShellWindowId_DockedContainer); 47 root, kShellWindowId_DockedContainer);
48 return static_cast<DockedWindowLayoutManager*>( 48 return static_cast<DockedWindowLayoutManager*>(
49 dock_container->layout_manager()); 49 dock_container->layout_manager());
50 } 50 }
51 51
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 was_docked_ = GetTarget()->parent() == dock_container; 150 was_docked_ = GetTarget()->parent() == dock_container;
151 is_docked_ = was_docked_; 151 is_docked_ = was_docked_;
152 } 152 }
153 153
154 void DockedWindowResizer::MaybeSnapToEdge(const gfx::Rect& bounds, 154 void DockedWindowResizer::MaybeSnapToEdge(const gfx::Rect& bounds,
155 gfx::Point* offset) { 155 gfx::Point* offset) {
156 // Windows only snap magnetically when they were previously docked. 156 // Windows only snap magnetically when they were previously docked.
157 if (!was_docked_) 157 if (!was_docked_)
158 return; 158 return;
159 DockedAlignment dock_alignment = dock_layout_->CalculateAlignment(); 159 DockedAlignment dock_alignment = dock_layout_->CalculateAlignment();
160 gfx::Rect dock_bounds = ScreenAsh::ConvertRectFromScreen( 160 gfx::Rect dock_bounds = ScreenUtil::ConvertRectFromScreen(
161 GetTarget()->parent(), 161 GetTarget()->parent(),
162 dock_layout_->dock_container()->GetBoundsInScreen()); 162 dock_layout_->dock_container()->GetBoundsInScreen());
163 163
164 // Short-range magnetism when retaining docked state. Same constant as in 164 // Short-range magnetism when retaining docked state. Same constant as in
165 // MagnetismMatcher is used for consistency. 165 // MagnetismMatcher is used for consistency.
166 const int kSnapToDockDistance = MagnetismMatcher::kMagneticDistance; 166 const int kSnapToDockDistance = MagnetismMatcher::kMagneticDistance;
167 167
168 if (dock_alignment == DOCKED_ALIGNMENT_LEFT || 168 if (dock_alignment == DOCKED_ALIGNMENT_LEFT ||
169 dock_alignment == DOCKED_ALIGNMENT_NONE) { 169 dock_alignment == DOCKED_ALIGNMENT_NONE) {
170 const int distance = bounds.x() - dock_bounds.x(); 170 const int distance = bounds.x() - dock_bounds.x();
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 did_move_or_resize_ = false; 219 did_move_or_resize_ = false;
220 aura::Window* window = GetTarget(); 220 aura::Window* window = GetTarget();
221 const bool is_attached_panel = window->type() == ui::wm::WINDOW_TYPE_PANEL && 221 const bool is_attached_panel = window->type() == ui::wm::WINDOW_TYPE_PANEL &&
222 window_state_->panel_attached(); 222 window_state_->panel_attached();
223 const bool is_resized = 223 const bool is_resized =
224 (details().bounds_change & WindowResizer::kBoundsChange_Resizes) != 0; 224 (details().bounds_change & WindowResizer::kBoundsChange_Resizes) != 0;
225 225
226 // When drag is completed the dragged docked window is resized to the bounds 226 // When drag is completed the dragged docked window is resized to the bounds
227 // calculated by the layout manager that conform to other docked windows. 227 // calculated by the layout manager that conform to other docked windows.
228 if (!is_attached_panel && is_docked_ && !is_resized) { 228 if (!is_attached_panel && is_docked_ && !is_resized) {
229 gfx::Rect bounds = ScreenAsh::ConvertRectFromScreen( 229 gfx::Rect bounds = ScreenUtil::ConvertRectFromScreen(
230 window->parent(), dock_layout_->dragged_bounds()); 230 window->parent(), dock_layout_->dragged_bounds());
231 if (!bounds.IsEmpty() && bounds.width() != window->bounds().width()) { 231 if (!bounds.IsEmpty() && bounds.width() != window->bounds().width()) {
232 window->SetBounds(bounds); 232 window->SetBounds(bounds);
233 } 233 }
234 } 234 }
235 // If a window has restore bounds, update the restore origin and width but not 235 // If a window has restore bounds, update the restore origin and width but not
236 // the height (since the height is auto-calculated for the docked windows). 236 // the height (since the height is auto-calculated for the docked windows).
237 if (is_resized && is_docked_ && window_state_->HasRestoreBounds()) { 237 if (is_resized && is_docked_ && window_state_->HasRestoreBounds()) {
238 gfx::Rect restore_bounds = window->GetBoundsInScreen(); 238 gfx::Rect restore_bounds = window->GetBoundsInScreen();
239 restore_bounds.set_height( 239 restore_bounds.set_height(
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 // before. 311 // before.
312 if (is_docked_) { 312 if (is_docked_) {
313 wm::GetWindowState(window)->set_bounds_changed_by_user( 313 wm::GetWindowState(window)->set_bounds_changed_by_user(
314 was_docked_ && (is_resized || was_bounds_changed_by_user_)); 314 was_docked_ && (is_resized || was_bounds_changed_by_user_));
315 } 315 }
316 return action; 316 return action;
317 } 317 }
318 318
319 } // namespace internal 319 } // namespace internal
320 } // namespace ash 320 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/dock/docked_window_layout_manager_unittest.cc ('k') | ash/wm/dock/docked_window_resizer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698