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

Side by Side Diff: ash/wm/workspace/workspace_layout_manager2.cc

Issue 11087037: Dont allow the user to 'resize a window out of the workarea' (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 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/workspace/workspace_layout_manager2.h" 5 #include "ash/wm/workspace/workspace_layout_manager2.h"
6 6
7 #include "ash/ash_switches.h" 7 #include "ash/ash_switches.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/always_on_top_controller.h" 10 #include "ash/wm/always_on_top_controller.h"
11 #include "ash/wm/base_layout_manager.h" 11 #include "ash/wm/base_layout_manager.h"
12 #include "ash/wm/window_animations.h" 12 #include "ash/wm/window_animations.h"
13 #include "ash/wm/window_properties.h" 13 #include "ash/wm/window_properties.h"
14 #include "ash/wm/window_util.h" 14 #include "ash/wm/window_util.h"
15 #include "ash/wm/workspace/workspace2.h" 15 #include "ash/wm/workspace/workspace2.h"
16 #include "ash/wm/workspace/workspace_manager2.h" 16 #include "ash/wm/workspace/workspace_manager2.h"
17 #include "ash/wm/workspace/workspace_window_resizer.h" 17 #include "ash/wm/workspace/workspace_window_resizer.h"
18 #include "base/auto_reset.h" 18 #include "base/auto_reset.h"
19 #include "base/command_line.h" 19 #include "base/command_line.h"
20 #include "ui/aura/client/aura_constants.h" 20 #include "ui/aura/client/aura_constants.h"
21 #include "ui/aura/root_window.h" 21 #include "ui/aura/root_window.h"
22 #include "ui/aura/window.h" 22 #include "ui/aura/window.h"
23 #include "ui/aura/window_observer.h" 23 #include "ui/aura/window_observer.h"
24 #include "ui/base/events/event.h" 24 #include "ui/base/events/event.h"
25 #include "ui/base/ui_base_types.h" 25 #include "ui/base/ui_base_types.h"
26 26
27 using aura::Window; 27 using aura::Window;
28 28
29 namespace ash { 29 namespace ash {
30
30 namespace internal { 31 namespace internal {
31 32
32 namespace { 33 namespace {
33 34
34 typedef std::map<const aura::Window*, gfx::Rect> BoundsMap; 35 typedef std::map<const aura::Window*, gfx::Rect> BoundsMap;
35 36
36 // Adds an entry from |window| to its bounds and recursively invokes this for 37 // Adds an entry from |window| to its bounds and recursively invokes this for
37 // all children. 38 // all children.
38 void BuildWindowBoundsMap(const aura::Window* window, BoundsMap* bounds_map) { 39 void BuildWindowBoundsMap(const aura::Window* window, BoundsMap* bounds_map) {
39 (*bounds_map)[window] = window->bounds(); 40 (*bounds_map)[window] = window->bounds();
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 AdjustWindowReason reason) { 286 AdjustWindowReason reason) {
286 if (GetTrackedByWorkspace(window) && 287 if (GetTrackedByWorkspace(window) &&
287 !SetMaximizedOrFullscreenBounds(window)) { 288 !SetMaximizedOrFullscreenBounds(window)) {
288 if (reason == ADJUST_WINDOW_SCREEN_SIZE_CHANGED) { 289 if (reason == ADJUST_WINDOW_SCREEN_SIZE_CHANGED) {
289 // The work area may be smaller than the full screen. Put as much of the 290 // The work area may be smaller than the full screen. Put as much of the
290 // window as possible within the display area. 291 // window as possible within the display area.
291 window->SetBounds(window->bounds().AdjustToFit(work_area_)); 292 window->SetBounds(window->bounds().AdjustToFit(work_area_));
292 } else if (reason == ADJUST_WINDOW_DISPLAY_INSETS_CHANGED) { 293 } else if (reason == ADJUST_WINDOW_DISPLAY_INSETS_CHANGED) {
293 // If the window is completely outside the display work area, then move it 294 // If the window is completely outside the display work area, then move it
294 // enough to be visible again. 295 // enough to be visible again.
295 const int kMinAreaVisible = 10;
296 gfx::Rect bounds = window->bounds(); 296 gfx::Rect bounds = window->bounds();
297 if (!work_area_.Intersects(bounds)) { 297 if (!work_area_.Intersects(bounds)) {
298 int y_offset = 0; 298 int y_offset = 0;
299 if (work_area_.bottom() < bounds.y()) { 299 if (work_area_.bottom() < bounds.y()) {
300 y_offset = work_area_.bottom() - bounds.y() - kMinAreaVisible; 300 y_offset = work_area_.bottom() - bounds.y() - kMinimumOnScreenArea;
301 } else if (bounds.bottom() < work_area_.y()) { 301 } else if (bounds.bottom() < work_area_.y()) {
302 y_offset = work_area_.y() - bounds.bottom() + kMinAreaVisible; 302 y_offset = work_area_.y() - bounds.bottom() + kMinimumOnScreenArea;
303 } 303 }
304 304
305 int x_offset = 0; 305 int x_offset = 0;
306 if (work_area_.right() < bounds.x()) { 306 if (work_area_.right() < bounds.x()) {
307 x_offset = work_area_.right() - bounds.x() - kMinAreaVisible; 307 x_offset = work_area_.right() - bounds.x() - kMinimumOnScreenArea;
308 } else if (bounds.right() < work_area_.x()) { 308 } else if (bounds.right() < work_area_.x()) {
309 x_offset = work_area_.x() - bounds.right() + kMinAreaVisible; 309 x_offset = work_area_.x() - bounds.right() + kMinimumOnScreenArea;
310 } 310 }
311 311
312 bounds.Offset(x_offset, y_offset); 312 bounds.Offset(x_offset, y_offset);
313 window->SetBounds(bounds); 313 window->SetBounds(bounds);
314 } 314 }
315 } 315 }
316 } 316 }
317 } 317 }
318 318
319 void WorkspaceLayoutManager2::UpdateBoundsFromShowState(Window* window) { 319 void WorkspaceLayoutManager2::UpdateBoundsFromShowState(Window* window) {
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 } 369 }
370 return false; 370 return false;
371 } 371 }
372 372
373 WorkspaceManager2* WorkspaceLayoutManager2::workspace_manager() { 373 WorkspaceManager2* WorkspaceLayoutManager2::workspace_manager() {
374 return workspace_->workspace_manager(); 374 return workspace_->workspace_manager();
375 } 375 }
376 376
377 } // namespace internal 377 } // namespace internal
378 } // namespace ash 378 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/workspace/workspace_layout_manager2.h ('k') | ash/wm/workspace/workspace_window_resizer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698