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

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

Issue 9558004: Makes windows no longer open maximized by default. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to trunk Created 8 years, 9 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
« no previous file with comments | « ash/wm/workspace/workspace_manager.h ('k') | ash/wm/workspace/workspace_manager_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/workspace/workspace_manager.h" 5 #include "ash/wm/workspace/workspace_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/wm/property_util.h" 10 #include "ash/wm/property_util.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 } 57 }
58 58
59 } 59 }
60 60
61 namespace ash { 61 namespace ash {
62 namespace internal { 62 namespace internal {
63 63
64 //////////////////////////////////////////////////////////////////////////////// 64 ////////////////////////////////////////////////////////////////////////////////
65 // WindowManager, public: 65 // WindowManager, public:
66 66
67 // static
68 const int WorkspaceManager::kOpenMaximizedThreshold = 1600;
69
70 WorkspaceManager::WorkspaceManager(aura::Window* contents_view) 67 WorkspaceManager::WorkspaceManager(aura::Window* contents_view)
71 : contents_view_(contents_view), 68 : contents_view_(contents_view),
72 active_workspace_(NULL), 69 active_workspace_(NULL),
73 workspace_size_( 70 workspace_size_(
74 gfx::Screen::GetMonitorAreaNearestWindow(contents_view_).size()), 71 gfx::Screen::GetMonitorAreaNearestWindow(contents_view_).size()),
75 is_overview_(false), 72 is_overview_(false),
76 ignored_window_(NULL), 73 ignored_window_(NULL),
77 grid_size_(0), 74 grid_size_(0),
78 open_new_windows_maximized_(true),
79 shelf_(NULL) { 75 shelf_(NULL) {
80 DCHECK(contents_view); 76 DCHECK(contents_view);
81 } 77 }
82 78
83 WorkspaceManager::~WorkspaceManager() { 79 WorkspaceManager::~WorkspaceManager() {
84 for (size_t i = 0; i < workspaces_.size(); ++i) { 80 for (size_t i = 0; i < workspaces_.size(); ++i) {
85 Workspace* workspace = workspaces_[i]; 81 Workspace* workspace = workspaces_[i];
86 for (size_t j = 0; j < workspace->windows().size(); ++j) 82 for (size_t j = 0; j < workspace->windows().size(); ++j)
87 workspace->windows()[j]->RemoveObserver(this); 83 workspace->windows()[j]->RemoveObserver(this);
88 } 84 }
89 std::vector<Workspace*> copy_to_delete(workspaces_); 85 std::vector<Workspace*> copy_to_delete(workspaces_);
90 STLDeleteElements(&copy_to_delete); 86 STLDeleteElements(&copy_to_delete);
91 } 87 }
92 88
93 bool WorkspaceManager::IsManagedWindow(aura::Window* window) const { 89 bool WorkspaceManager::IsManagedWindow(aura::Window* window) const {
94 return window->type() == aura::client::WINDOW_TYPE_NORMAL && 90 return window->type() == aura::client::WINDOW_TYPE_NORMAL &&
95 !window->transient_parent(); 91 !window->transient_parent();
96 } 92 }
97 93
98 bool WorkspaceManager::ShouldMaximize(aura::Window* window) const {
99 return !window->GetProperty(aura::client::kShowStateKey) &&
100 open_new_windows_maximized_ &&
101 contents_view_->bounds().width() < kOpenMaximizedThreshold;
102 }
103
104 void WorkspaceManager::AddWindow(aura::Window* window) { 94 void WorkspaceManager::AddWindow(aura::Window* window) {
105 DCHECK(IsManagedWindow(window)); 95 DCHECK(IsManagedWindow(window));
106 96
107 Workspace* current_workspace = FindBy(window); 97 Workspace* current_workspace = FindBy(window);
108 if (current_workspace) { 98 if (current_workspace) {
109 // Already know about this window. Make sure the workspace is active. 99 // Already know about this window. Make sure the workspace is active.
110 if (active_workspace_ != current_workspace) { 100 if (active_workspace_ != current_workspace) {
111 if (active_workspace_) 101 if (active_workspace_)
112 window->layer()->GetAnimator()->StopAnimating(); 102 window->layer()->GetAnimator()->StopAnimating();
113 current_workspace->Activate(); 103 current_workspace->Activate();
114 } 104 }
115 return; 105 return;
116 } 106 }
117 107
118 if (!wm::IsWindowMaximized(window) && !wm::IsWindowFullscreen(window)) { 108 if (!wm::IsWindowMaximized(window) && !wm::IsWindowFullscreen(window)) {
119 SetRestoreBounds(window, window->bounds()); 109 SetRestoreBounds(window, window->bounds());
120 } 110 }
121 111
122 if (!window->GetProperty(aura::client::kShowStateKey)) { 112 if (!window->GetProperty(aura::client::kShowStateKey))
123 if (ShouldMaximize(window)) { 113 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
124 window->SetProperty(aura::client::kShowStateKey,
125 ui::SHOW_STATE_MAXIMIZED);
126 } else {
127 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_NORMAL);
128 }
129 }
130 114
131 if (wm::IsWindowMaximized(window) || wm::IsWindowFullscreen(window)) { 115 if (wm::IsWindowMaximized(window) || wm::IsWindowFullscreen(window)) {
132 SetFullScreenOrMaximizedBounds(window); 116 SetFullScreenOrMaximizedBounds(window);
133 } else { 117 } else {
134 if (grid_size_ > 1) 118 if (grid_size_ > 1)
135 SetWindowBounds(window, AlignBoundsToGrid(window->GetTargetBounds())); 119 SetWindowBounds(window, AlignBoundsToGrid(window->GetTargetBounds()));
136 } 120 }
137 121
138 // Add the observer after we change the state in anyway. 122 // Add the observer after we change the state in anyway.
139 window->AddObserver(this); 123 window->AddObserver(this);
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 if (type == Workspace::TYPE_MAXIMIZED) 400 if (type == Workspace::TYPE_MAXIMIZED)
417 workspace = new MaximizedWorkspace(this); 401 workspace = new MaximizedWorkspace(this);
418 else 402 else
419 workspace = new ManagedWorkspace(this); 403 workspace = new ManagedWorkspace(this);
420 AddWorkspace(workspace); 404 AddWorkspace(workspace);
421 return workspace; 405 return workspace;
422 } 406 }
423 407
424 } // namespace internal 408 } // namespace internal
425 } // namespace ash 409 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/workspace/workspace_manager.h ('k') | ash/wm/workspace/workspace_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698