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

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

Issue 9566014: Attempt 2: Allows tab dragging when maximized on aura. To fix it I made it so (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix 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_layout_manager.h ('k') | ash/wm/workspace/workspace_manager.h » ('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_layout_manager.h" 5 #include "ash/wm/workspace/workspace_layout_manager.h"
6 6
7 #include "ash/wm/property_util.h" 7 #include "ash/wm/property_util.h"
8 #include "ash/wm/window_util.h" 8 #include "ash/wm/window_util.h"
9 #include "ash/wm/workspace/workspace.h" 9 #include "ash/wm/workspace/workspace.h"
10 #include "ash/wm/workspace/workspace_manager.h" 10 #include "ash/wm/workspace/workspace_manager.h"
11 #include "ash/wm/workspace/workspace_window_resizer.h"
11 #include "ui/aura/client/aura_constants.h" 12 #include "ui/aura/client/aura_constants.h"
12 #include "ui/aura/event.h" 13 #include "ui/aura/event.h"
13 #include "ui/aura/root_window.h" 14 #include "ui/aura/root_window.h"
14 #include "ui/aura/screen_aura.h" 15 #include "ui/aura/screen_aura.h"
15 #include "ui/aura/window.h" 16 #include "ui/aura/window.h"
16 #include "ui/aura/window_observer.h" 17 #include "ui/aura/window_observer.h"
17 #include "ui/base/ui_base_types.h" 18 #include "ui/base/ui_base_types.h"
18 #include "ui/gfx/rect.h" 19 #include "ui/gfx/rect.h"
19 #include "ui/views/widget/native_widget_aura.h" 20 #include "ui/views/widget/native_widget_aura.h"
20 21
21 namespace ash { 22 namespace ash {
22 namespace internal { 23 namespace internal {
23 24
24 //////////////////////////////////////////////////////////////////////////////// 25 ////////////////////////////////////////////////////////////////////////////////
25 // WorkspaceLayoutManager, public: 26 // WorkspaceLayoutManager, public:
26 27
27 WorkspaceLayoutManager::WorkspaceLayoutManager( 28 WorkspaceLayoutManager::WorkspaceLayoutManager(
28 WorkspaceManager* workspace_manager) 29 WorkspaceManager* workspace_manager)
29 : workspace_manager_(workspace_manager) { 30 : workspace_manager_(workspace_manager) {
30 } 31 }
31 32
32 WorkspaceLayoutManager::~WorkspaceLayoutManager() {} 33 WorkspaceLayoutManager::~WorkspaceLayoutManager() {
34 const aura::Window::Windows& windows(
35 workspace_manager_->contents_view()->children());
36 for (size_t i = 0; i < windows.size(); ++i)
37 windows[i]->RemoveObserver(this);
38 }
33 39
34 void WorkspaceLayoutManager::OnWindowResized() { 40 void WorkspaceLayoutManager::OnWindowResized() {
35 // Workspace is updated via RootWindowObserver::OnRootWindowResized. 41 // Workspace is updated via RootWindowObserver::OnRootWindowResized.
36 } 42 }
37 43
38 void WorkspaceLayoutManager::OnWindowAddedToLayout(aura::Window* child) { 44 void WorkspaceLayoutManager::OnWindowAddedToLayout(aura::Window* child) {
45 child->AddObserver(this);
39 if (!workspace_manager_->IsManagedWindow(child)) 46 if (!workspace_manager_->IsManagedWindow(child))
40 return; 47 return;
41 48
42 if (child->IsVisible()) { 49 if (child->IsVisible()) {
43 workspace_manager_->AddWindow(child); 50 workspace_manager_->AddWindow(child);
44 } else if (wm::IsWindowMaximized(child)) { 51 } else if (wm::IsWindowMaximized(child)) {
45 SetChildBoundsDirect(child, 52 SetChildBoundsDirect(child,
46 gfx::Screen::GetMonitorWorkAreaNearestWindow(child)); 53 gfx::Screen::GetMonitorWorkAreaNearestWindow(child));
47 } else if (wm::IsWindowFullscreen(child)) { 54 } else if (wm::IsWindowFullscreen(child)) {
48 SetChildBoundsDirect(child, 55 SetChildBoundsDirect(child,
49 gfx::Screen::GetMonitorAreaNearestWindow(child)); 56 gfx::Screen::GetMonitorAreaNearestWindow(child));
50 } else { 57 } else {
51 // Align non-maximized/fullscreen windows to a grid. 58 // Align non-maximized/fullscreen windows to a grid.
52 SetChildBoundsDirect( 59 SetChildBoundsDirect(
53 child, workspace_manager_->AlignBoundsToGrid(child->GetTargetBounds())); 60 child, workspace_manager_->AlignBoundsToGrid(child->GetTargetBounds()));
54 } 61 }
55 } 62 }
56 63
57 void WorkspaceLayoutManager::OnWillRemoveWindowFromLayout( 64 void WorkspaceLayoutManager::OnWillRemoveWindowFromLayout(
58 aura::Window* child) { 65 aura::Window* child) {
66 child->RemoveObserver(this);
59 ClearRestoreBounds(child); 67 ClearRestoreBounds(child);
60 workspace_manager_->RemoveWindow(child); 68 workspace_manager_->RemoveWindow(child);
61 } 69 }
62 70
63 void WorkspaceLayoutManager::OnChildWindowVisibilityChanged( 71 void WorkspaceLayoutManager::OnChildWindowVisibilityChanged(
64 aura::Window* child, 72 aura::Window* child,
65 bool visible) { 73 bool visible) {
66 if (!workspace_manager_->IsManagedWindow(child)) 74 if (!workspace_manager_->IsManagedWindow(child))
67 return; 75 return;
68 if (visible) 76 if (visible)
69 workspace_manager_->AddWindow(child); 77 workspace_manager_->AddWindow(child);
70 else 78 else
71 workspace_manager_->RemoveWindow(child); 79 workspace_manager_->RemoveWindow(child);
72 } 80 }
73 81
74 void WorkspaceLayoutManager::SetChildBounds( 82 void WorkspaceLayoutManager::SetChildBounds(
75 aura::Window* child, 83 aura::Window* child,
76 const gfx::Rect& requested_bounds) { 84 const gfx::Rect& requested_bounds) {
77 gfx::Rect child_bounds(requested_bounds); 85 gfx::Rect child_bounds(requested_bounds);
78 if (wm::IsWindowMaximized(child)) { 86 if (GetTrackedByWorkspace(child)) {
79 child_bounds = gfx::Screen::GetMonitorWorkAreaNearestWindow(child); 87 if (wm::IsWindowMaximized(child)) {
80 } else if (wm::IsWindowFullscreen(child)) { 88 child_bounds = gfx::Screen::GetMonitorWorkAreaNearestWindow(child);
81 child_bounds = gfx::Screen::GetMonitorAreaNearestWindow(child); 89 } else if (wm::IsWindowFullscreen(child)) {
82 } else { 90 child_bounds = gfx::Screen::GetMonitorAreaNearestWindow(child);
83 child_bounds = gfx::Screen::GetMonitorWorkAreaNearestWindow(child). 91 } else {
84 AdjustToFit(requested_bounds); 92 child_bounds = gfx::Screen::GetMonitorWorkAreaNearestWindow(child).
93 AdjustToFit(requested_bounds);
94 }
85 } 95 }
86 SetChildBoundsDirect(child, child_bounds); 96 SetChildBoundsDirect(child, child_bounds);
87 } 97 }
88 98
99 void WorkspaceLayoutManager::OnWindowPropertyChanged(aura::Window* window,
100 const void* key,
101 intptr_t old) {
102 if (key == ash::kWindowTrackedByWorkspaceSplitPropKey &&
103 ash::GetTrackedByWorkspace(window)) {
104 // We currently don't need to support transitioning from true to false, so
105 // we ignore it.
106 workspace_manager_->AddWindow(window);
107 }
108 }
109
89 } // namespace internal 110 } // namespace internal
90 } // namespace ash 111 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/workspace/workspace_layout_manager.h ('k') | ash/wm/workspace/workspace_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698