OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_controller.h" | 5 #include "ash/wm/workspace_controller.h" |
6 | 6 |
7 #include "ash/launcher/launcher.h" | 7 #include "ash/launcher/launcher.h" |
8 #include "ash/launcher/launcher_model.h" | 8 #include "ash/launcher/launcher_model.h" |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/wm/default_container_layout_manager.h" | 10 #include "ash/wm/default_container_layout_manager.h" |
11 #include "ash/wm/window_util.h" | 11 #include "ash/wm/window_util.h" |
12 #include "ash/wm/workspace/workspace.h" | 12 #include "ash/wm/workspace/workspace.h" |
13 #include "ash/wm/workspace/workspace_manager.h" | 13 #include "ash/wm/workspace/workspace_manager.h" |
14 #include "ui/aura/client/activation_client.h" | 14 #include "ui/aura/client/activation_client.h" |
15 #include "ui/aura/client/aura_constants.h" | 15 #include "ui/aura/client/aura_constants.h" |
16 #include "ui/aura/root_window.h" | 16 #include "ui/aura/root_window.h" |
17 #include "ui/aura/window.h" | 17 #include "ui/aura/window.h" |
18 | 18 |
19 namespace aura_shell { | 19 namespace ash { |
20 namespace internal { | 20 namespace internal { |
21 | 21 |
22 WorkspaceController::WorkspaceController(aura::Window* viewport) | 22 WorkspaceController::WorkspaceController(aura::Window* viewport) |
23 : workspace_manager_(new WorkspaceManager(viewport)), | 23 : workspace_manager_(new WorkspaceManager(viewport)), |
24 launcher_model_(NULL), | 24 launcher_model_(NULL), |
25 ignore_move_event_(false) { | 25 ignore_move_event_(false) { |
26 workspace_manager_->AddObserver(this); | 26 workspace_manager_->AddObserver(this); |
27 aura::RootWindow::GetInstance()->AddRootWindowObserver(this); | 27 aura::RootWindow::GetInstance()->AddRootWindowObserver(this); |
28 aura::RootWindow::GetInstance()->AddObserver(this); | 28 aura::RootWindow::GetInstance()->AddObserver(this); |
29 } | 29 } |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 void* old) { | 61 void* old) { |
62 if (key == aura::client::kRootWindowActiveWindow) { | 62 if (key == aura::client::kRootWindowActiveWindow) { |
63 // FindBy handles NULL. | 63 // FindBy handles NULL. |
64 Workspace* workspace = workspace_manager_->FindBy(GetActiveWindow()); | 64 Workspace* workspace = workspace_manager_->FindBy(GetActiveWindow()); |
65 if (workspace) | 65 if (workspace) |
66 workspace->Activate(); | 66 workspace->Activate(); |
67 } | 67 } |
68 } | 68 } |
69 | 69 |
70 //////////////////////////////////////////////////////////////////////////////// | 70 //////////////////////////////////////////////////////////////////////////////// |
71 // WorkspaceController, aura_shell::internal::WorkspaceObserver overrides: | 71 // WorkspaceController, ash::internal::WorkspaceObserver overrides: |
72 | 72 |
73 void WorkspaceController::WindowMoved(WorkspaceManager* manager, | 73 void WorkspaceController::WindowMoved(WorkspaceManager* manager, |
74 aura::Window* source, | 74 aura::Window* source, |
75 aura::Window* target) { | 75 aura::Window* target) { |
76 if (ignore_move_event_ || !launcher_model_) | 76 if (ignore_move_event_ || !launcher_model_) |
77 return; | 77 return; |
78 int start_index = launcher_model_->ItemIndexByWindow(source); | 78 int start_index = launcher_model_->ItemIndexByWindow(source); |
79 int target_index = launcher_model_->ItemIndexByWindow(target); | 79 int target_index = launcher_model_->ItemIndexByWindow(target); |
80 // The following condition may not be hold depending on future | 80 // The following condition may not be hold depending on future |
81 // launcher design. Using DCHECK so that we can catch such change. | 81 // launcher design. Using DCHECK so that we can catch such change. |
82 DCHECK(start_index >=0); | 82 DCHECK(start_index >=0); |
83 DCHECK(target_index >=0); | 83 DCHECK(target_index >=0); |
84 | 84 |
85 ignore_move_event_ = true; | 85 ignore_move_event_ = true; |
86 launcher_model_->Move(start_index, target_index); | 86 launcher_model_->Move(start_index, target_index); |
87 ignore_move_event_ = false; | 87 ignore_move_event_ = false; |
88 } | 88 } |
89 | 89 |
90 void WorkspaceController::ActiveWorkspaceChanged(WorkspaceManager* manager, | 90 void WorkspaceController::ActiveWorkspaceChanged(WorkspaceManager* manager, |
91 Workspace* old) { | 91 Workspace* old) { |
92 // TODO(oshima): Update Launcher and Status area state when the active | 92 // TODO(oshima): Update Launcher and Status area state when the active |
93 // workspace's fullscreen state changes. | 93 // workspace's fullscreen state changes. |
94 //NOTIMPLEMENTED(); | 94 //NOTIMPLEMENTED(); |
95 } | 95 } |
96 | 96 |
97 //////////////////////////////////////////////////////////////////////////////// | 97 //////////////////////////////////////////////////////////////////////////////// |
98 // WorkspaceController, aura_shell::LauncherModelObserver overrides: | 98 // WorkspaceController, ash::LauncherModelObserver overrides: |
99 | 99 |
100 void WorkspaceController::LauncherItemAdded(int index) { | 100 void WorkspaceController::LauncherItemAdded(int index) { |
101 } | 101 } |
102 | 102 |
103 void WorkspaceController::LauncherItemRemoved(int index) { | 103 void WorkspaceController::LauncherItemRemoved(int index) { |
104 } | 104 } |
105 | 105 |
106 void WorkspaceController::LauncherItemMoved(int start_index, int target_index) { | 106 void WorkspaceController::LauncherItemMoved(int start_index, int target_index) { |
107 if (ignore_move_event_) | 107 if (ignore_move_event_) |
108 return; | 108 return; |
109 DCHECK(launcher_model_); | 109 DCHECK(launcher_model_); |
110 // Adjust target/source indices as the item positions in |launcher_model_| | 110 // Adjust target/source indices as the item positions in |launcher_model_| |
111 // has already been updated. | 111 // has already been updated. |
112 aura::Window* start = launcher_model_->items()[target_index].window; | 112 aura::Window* start = launcher_model_->items()[target_index].window; |
113 size_t target_index_in_model = | 113 size_t target_index_in_model = |
114 start_index < target_index ? target_index - 1 : target_index + 1; | 114 start_index < target_index ? target_index - 1 : target_index + 1; |
115 DCHECK_LE(target_index_in_model, launcher_model_->items().size()); | 115 DCHECK_LE(target_index_in_model, launcher_model_->items().size()); |
116 aura::Window* target = launcher_model_->items()[target_index_in_model].window; | 116 aura::Window* target = launcher_model_->items()[target_index_in_model].window; |
117 | 117 |
118 ignore_move_event_ = true; | 118 ignore_move_event_ = true; |
119 workspace_manager_->RotateWindows(start, target); | 119 workspace_manager_->RotateWindows(start, target); |
120 ignore_move_event_ = false; | 120 ignore_move_event_ = false; |
121 } | 121 } |
122 | 122 |
123 void WorkspaceController::LauncherItemImagesChanged(int index) { | 123 void WorkspaceController::LauncherItemImagesChanged(int index) { |
124 } | 124 } |
125 | 125 |
126 } // namespace internal | 126 } // namespace internal |
127 } // namespace aura_shell | 127 } // namespace ash |
OLD | NEW |