Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/overview/window_selector.h" | 5 #include "ash/wm/overview/window_selector.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <functional> | 8 #include <functional> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <utility> | 10 #include <utility> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "ash/accessibility_delegate.h" | 13 #include "ash/accessibility_delegate.h" |
| 14 #include "ash/ash_switches.h" | 14 #include "ash/ash_switches.h" |
| 15 #include "ash/metrics/user_metrics_recorder.h" | |
| 16 #include "ash/root_window_controller.h" | |
| 17 #include "ash/shell.h" | 15 #include "ash/shell.h" |
| 18 #include "ash/shell_window_ids.h" | |
| 19 #include "ash/wm/aura/wm_window_aura.h" | |
| 20 #include "ash/wm/common/panels/panel_layout_manager.h" | 16 #include "ash/wm/common/panels/panel_layout_manager.h" |
| 17 #include "ash/wm/common/shelf/wm_shelf.h" | |
| 21 #include "ash/wm/common/switchable_windows.h" | 18 #include "ash/wm/common/switchable_windows.h" |
| 22 #include "ash/wm/common/window_state.h" | 19 #include "ash/wm/common/window_state.h" |
| 23 #include "ash/wm/mru_window_tracker.h" | 20 #include "ash/wm/common/wm_globals.h" |
| 21 #include "ash/wm/common/wm_lookup.h" | |
| 22 #include "ash/wm/common/wm_root_window_controller.h" | |
| 23 #include "ash/wm/common/wm_shell_window_ids.h" | |
| 24 #include "ash/wm/common/wm_user_metrics_action.h" | |
| 25 #include "ash/wm/common/wm_window.h" | |
| 24 #include "ash/wm/overview/window_grid.h" | 26 #include "ash/wm/overview/window_grid.h" |
| 25 #include "ash/wm/overview/window_selector_delegate.h" | 27 #include "ash/wm/overview/window_selector_delegate.h" |
| 26 #include "ash/wm/overview/window_selector_item.h" | 28 #include "ash/wm/overview/window_selector_item.h" |
| 27 #include "ash/wm/window_state_aura.h" | |
| 28 #include "ash/wm/window_util.h" | |
| 29 #include "base/auto_reset.h" | 29 #include "base/auto_reset.h" |
| 30 #include "base/command_line.h" | 30 #include "base/command_line.h" |
| 31 #include "base/metrics/histogram.h" | 31 #include "base/metrics/histogram.h" |
| 32 #include "third_party/skia/include/core/SkPaint.h" | 32 #include "third_party/skia/include/core/SkPaint.h" |
| 33 #include "third_party/skia/include/core/SkPath.h" | 33 #include "third_party/skia/include/core/SkPath.h" |
| 34 #include "ui/aura/client/focus_client.h" | |
| 35 #include "ui/aura/window.h" | |
| 36 #include "ui/aura/window_event_dispatcher.h" | |
| 37 #include "ui/aura/window_observer.h" | |
| 38 #include "ui/base/resource/resource_bundle.h" | 34 #include "ui/base/resource/resource_bundle.h" |
| 39 #include "ui/compositor/scoped_layer_animation_settings.h" | 35 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 40 #include "ui/display/screen.h" | 36 #include "ui/display/screen.h" |
| 41 #include "ui/events/event.h" | 37 #include "ui/events/event.h" |
| 42 #include "ui/gfx/canvas.h" | 38 #include "ui/gfx/canvas.h" |
| 43 #include "ui/gfx/skia_util.h" | 39 #include "ui/gfx/skia_util.h" |
| 44 #include "ui/views/border.h" | 40 #include "ui/views/border.h" |
| 45 #include "ui/views/controls/textfield/textfield.h" | 41 #include "ui/views/controls/textfield/textfield.h" |
| 46 #include "ui/views/layout/box_layout.h" | 42 #include "ui/views/layout/box_layout.h" |
| 47 #include "ui/wm/core/window_util.h" | |
| 48 #include "ui/wm/public/activation_client.h" | |
| 49 | 43 |
| 50 namespace ash { | 44 namespace ash { |
| 51 | 45 |
| 52 namespace { | 46 namespace { |
| 53 | 47 |
| 54 // The proportion of screen width that the text filter takes. | 48 // The proportion of screen width that the text filter takes. |
| 55 const float kTextFilterScreenProportion = 0.25; | 49 const float kTextFilterScreenProportion = 0.25; |
| 56 | 50 |
| 57 // The amount of padding surrounding the text in the text filtering textbox. | 51 // The amount of padding surrounding the text in the text filtering textbox. |
| 58 const int kTextFilterHorizontalPadding = 8; | 52 const int kTextFilterHorizontalPadding = 8; |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 69 ::ui::ResourceBundle::FontStyle::MediumFont; | 63 ::ui::ResourceBundle::FontStyle::MediumFont; |
| 70 | 64 |
| 71 // The alpha value for the background of the text filtering textbox. | 65 // The alpha value for the background of the text filtering textbox. |
| 72 const unsigned char kTextFilterOpacity = 180; | 66 const unsigned char kTextFilterOpacity = 180; |
| 73 | 67 |
| 74 // The radius used for the rounded corners on the text filtering textbox. | 68 // The radius used for the rounded corners on the text filtering textbox. |
| 75 const int kTextFilterCornerRadius = 1; | 69 const int kTextFilterCornerRadius = 1; |
| 76 | 70 |
| 77 // A comparator for locating a grid with a given root window. | 71 // A comparator for locating a grid with a given root window. |
| 78 struct RootWindowGridComparator { | 72 struct RootWindowGridComparator { |
| 79 explicit RootWindowGridComparator(const aura::Window* root_window) | 73 explicit RootWindowGridComparator(const wm::WmWindow* root_window) |
| 80 : root_window_(root_window) { | 74 : root_window_(root_window) {} |
| 75 | |
| 76 bool operator()(const std::unique_ptr<WindowGrid>& grid) const { | |
| 77 return grid->root_window() == root_window_; | |
| 81 } | 78 } |
| 82 | 79 |
| 83 bool operator()(WindowGrid* grid) const { | 80 const wm::WmWindow* root_window_; |
| 84 return (grid->root_window() == root_window_); | |
| 85 } | |
| 86 | |
| 87 const aura::Window* root_window_; | |
| 88 }; | 81 }; |
| 89 | 82 |
| 90 // A comparator for locating a selectable window given a targeted window. | 83 // A comparator for locating a selectable window given a targeted window. |
| 91 struct WindowSelectorItemTargetComparator { | 84 struct WindowSelectorItemTargetComparator { |
| 92 explicit WindowSelectorItemTargetComparator(const aura::Window* target_window) | 85 explicit WindowSelectorItemTargetComparator(const wm::WmWindow* target_window) |
| 93 : target(target_window) { | 86 : target(target_window) {} |
| 94 } | |
| 95 | 87 |
| 96 bool operator()(WindowSelectorItem* window) const { | 88 bool operator()(WindowSelectorItem* window) const { |
| 97 return window->GetWindow() == target; | 89 return window->GetWindow() == target; |
| 98 } | 90 } |
| 99 | 91 |
| 100 const aura::Window* target; | 92 const wm::WmWindow* target; |
| 101 }; | 93 }; |
| 102 | 94 |
| 103 // A comparator for locating a selector item for a given root. | 95 // A comparator for locating a selector item for a given root. |
| 104 struct WindowSelectorItemForRoot { | 96 struct WindowSelectorItemForRoot { |
| 105 explicit WindowSelectorItemForRoot(const aura::Window* root) | 97 explicit WindowSelectorItemForRoot(const wm::WmWindow* root) |
| 106 : root_window(root) { | 98 : root_window(root) {} |
| 107 } | |
| 108 | 99 |
| 109 bool operator()(WindowSelectorItem* item) const { | 100 bool operator()(WindowSelectorItem* item) const { |
| 110 return item->root_window() == root_window; | 101 return item->root_window() == root_window; |
| 111 } | 102 } |
| 112 | 103 |
| 113 const aura::Window* root_window; | 104 const wm::WmWindow* root_window; |
| 114 }; | 105 }; |
| 115 | 106 |
| 116 // A View having rounded corners and a specified background color which is | 107 // A View having rounded corners and a specified background color which is |
| 117 // only painted within the bounds defined by the rounded corners. | 108 // only painted within the bounds defined by the rounded corners. |
| 118 // TODO(tdanderson): This duplicates code from RoundedImageView. Refactor these | 109 // TODO(tdanderson): This duplicates code from RoundedImageView. Refactor these |
| 119 // classes and move into ui/views. | 110 // classes and move into ui/views. |
| 120 class RoundedContainerView : public views::View { | 111 class RoundedContainerView : public views::View { |
| 121 public: | 112 public: |
| 122 RoundedContainerView(int corner_radius, SkColor background) | 113 RoundedContainerView(int corner_radius, SkColor background) |
| 123 : corner_radius_(corner_radius), | 114 : corner_radius_(corner_radius), |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 144 | 135 |
| 145 private: | 136 private: |
| 146 int corner_radius_; | 137 int corner_radius_; |
| 147 SkColor background_; | 138 SkColor background_; |
| 148 | 139 |
| 149 DISALLOW_COPY_AND_ASSIGN(RoundedContainerView); | 140 DISALLOW_COPY_AND_ASSIGN(RoundedContainerView); |
| 150 }; | 141 }; |
| 151 | 142 |
| 152 // Triggers a shelf visibility update on all root window controllers. | 143 // Triggers a shelf visibility update on all root window controllers. |
| 153 void UpdateShelfVisibility() { | 144 void UpdateShelfVisibility() { |
| 154 Shell::RootWindowControllerList root_window_controllers = | 145 for (wm::WmWindow* root : wm::WmGlobals::Get()->GetAllRootWindows()) |
| 155 Shell::GetInstance()->GetAllRootWindowControllers(); | 146 root->GetRootWindowController()->GetShelf()->UpdateVisibilityState(); |
| 156 for (Shell::RootWindowControllerList::iterator iter = | |
| 157 root_window_controllers.begin(); | |
| 158 iter != root_window_controllers.end(); ++iter) { | |
| 159 (*iter)->UpdateShelfVisibility(); | |
| 160 } | |
| 161 } | 147 } |
| 162 | 148 |
| 163 // Initializes the text filter on the top of the main root window and requests | 149 // Initializes the text filter on the top of the main root window and requests |
| 164 // focus on its textfield. | 150 // focus on its textfield. |
| 165 views::Widget* CreateTextFilter(views::TextfieldController* controller, | 151 views::Widget* CreateTextFilter(views::TextfieldController* controller, |
| 166 aura::Window* root_window) { | 152 wm::WmWindow* root_window) { |
| 167 views::Widget* widget = new views::Widget; | 153 views::Widget* widget = new views::Widget; |
| 168 views::Widget::InitParams params; | 154 views::Widget::InitParams params; |
| 169 params.type = views::Widget::InitParams::TYPE_WINDOW_FRAMELESS; | 155 params.type = views::Widget::InitParams::TYPE_WINDOW_FRAMELESS; |
| 170 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; | 156 params.ownership = views::Widget::InitParams::WIDGET_OWNS_NATIVE_WIDGET; |
| 171 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; | 157 params.opacity = views::Widget::InitParams::TRANSLUCENT_WINDOW; |
| 172 params.parent = Shell::GetContainer(root_window, | |
| 173 kShellWindowId_OverlayContainer); | |
| 174 params.accept_events = true; | 158 params.accept_events = true; |
| 175 params.bounds = gfx::Rect( | 159 params.bounds = gfx::Rect( |
| 176 root_window->bounds().width() / 2 * (1 - kTextFilterScreenProportion), | 160 root_window->GetBounds().width() / 2 * (1 - kTextFilterScreenProportion), |
| 177 kTextFilterDistanceFromTop, | 161 kTextFilterDistanceFromTop, |
| 178 root_window->bounds().width() * kTextFilterScreenProportion, | 162 root_window->GetBounds().width() * kTextFilterScreenProportion, |
| 179 kTextFilterHeight); | 163 kTextFilterHeight); |
| 164 root_window->GetRootWindowController()->ConfigureWidgetInitParamsForContainer( | |
| 165 widget, kShellWindowId_OverlayContainer, ¶ms); | |
| 180 widget->Init(params); | 166 widget->Init(params); |
| 181 | 167 |
| 182 // Use |container| to specify the padding surrounding the text and to give | 168 // Use |container| to specify the padding surrounding the text and to give |
| 183 // the textfield rounded corners. | 169 // the textfield rounded corners. |
| 184 views::View* container = new RoundedContainerView( | 170 views::View* container = new RoundedContainerView( |
| 185 kTextFilterCornerRadius, SkColorSetARGB(kTextFilterOpacity, 0, 0, 0)); | 171 kTextFilterCornerRadius, SkColorSetARGB(kTextFilterOpacity, 0, 0, 0)); |
| 186 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 172 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
| 187 int text_height = bundle.GetFontList(kTextFilterFontStyle).GetHeight(); | 173 int text_height = bundle.GetFontList(kTextFilterFontStyle).GetHeight(); |
| 188 DCHECK(text_height); | 174 DCHECK(text_height); |
| 189 int vertical_padding = (kTextFilterHeight - text_height) / 2; | 175 int vertical_padding = (kTextFilterHeight - text_height) / 2; |
| 190 container->SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, | 176 container->SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, |
| 191 kTextFilterHorizontalPadding, | 177 kTextFilterHorizontalPadding, |
| 192 vertical_padding, | 178 vertical_padding, |
| 193 0)); | 179 0)); |
| 194 | 180 |
| 195 views::Textfield* textfield = new views::Textfield; | 181 views::Textfield* textfield = new views::Textfield; |
| 196 textfield->set_controller(controller); | 182 textfield->set_controller(controller); |
| 197 textfield->SetBackgroundColor(SK_ColorTRANSPARENT); | 183 textfield->SetBackgroundColor(SK_ColorTRANSPARENT); |
| 198 textfield->SetBorder(views::Border::NullBorder()); | 184 textfield->SetBorder(views::Border::NullBorder()); |
| 199 textfield->SetTextColor(SK_ColorWHITE); | 185 textfield->SetTextColor(SK_ColorWHITE); |
| 200 textfield->SetFontList(bundle.GetFontList(kTextFilterFontStyle)); | 186 textfield->SetFontList(bundle.GetFontList(kTextFilterFontStyle)); |
| 201 | 187 |
| 202 container->AddChildView(textfield); | 188 container->AddChildView(textfield); |
| 203 widget->SetContentsView(container); | 189 widget->SetContentsView(container); |
| 204 | 190 |
| 205 // The textfield initially contains no text, so shift its position to be | 191 // The textfield initially contains no text, so shift its position to be |
| 206 // outside the visible bounds of the screen. | 192 // outside the visible bounds of the screen. |
| 207 gfx::Transform transform; | 193 gfx::Transform transform; |
| 208 transform.Translate(0, -WindowSelector::kTextFilterBottomEdge); | 194 transform.Translate(0, -WindowSelector::kTextFilterBottomEdge); |
| 209 widget->GetNativeWindow()->SetTransform(transform); | 195 wm::WmLookup::Get()->GetWindowForWidget(widget)->SetTransform(transform); |
| 210 widget->Show(); | 196 widget->Show(); |
| 211 textfield->RequestFocus(); | 197 textfield->RequestFocus(); |
| 212 | 198 |
| 213 return widget; | 199 return widget; |
| 214 } | 200 } |
| 215 | 201 |
| 216 } // namespace | 202 } // namespace |
| 217 | 203 |
| 218 const int WindowSelector::kTextFilterBottomEdge = | 204 const int WindowSelector::kTextFilterBottomEdge = |
| 219 kTextFilterDistanceFromTop + kTextFilterHeight; | 205 kTextFilterDistanceFromTop + kTextFilterHeight; |
| 220 | 206 |
| 221 // static | 207 // static |
| 222 bool WindowSelector::IsSelectable(aura::Window* window) { | 208 bool WindowSelector::IsSelectable(wm::WmWindow* window) { |
| 223 wm::WindowState* state = wm::GetWindowState(window); | 209 wm::WindowState* state = window->GetWindowState(); |
| 224 if (state->GetStateType() == wm::WINDOW_STATE_TYPE_DOCKED || | 210 if (state->GetStateType() == wm::WINDOW_STATE_TYPE_DOCKED || |
| 225 state->GetStateType() == wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED) { | 211 state->GetStateType() == wm::WINDOW_STATE_TYPE_DOCKED_MINIMIZED) { |
| 226 return false; | 212 return false; |
| 227 } | 213 } |
| 228 return state->IsUserPositionable(); | 214 return state->IsUserPositionable(); |
| 229 } | 215 } |
| 230 | 216 |
| 231 WindowSelector::WindowSelector(WindowSelectorDelegate* delegate) | 217 WindowSelector::WindowSelector(WindowSelectorDelegate* delegate) |
| 232 : delegate_(delegate), | 218 : delegate_(delegate), |
| 233 restore_focus_window_(aura::client::GetFocusClient( | 219 restore_focus_window_(wm::WmGlobals::Get()->GetFocusedWindow()), |
| 234 Shell::GetPrimaryRootWindow())->GetFocusedWindow()), | |
| 235 ignore_activations_(false), | 220 ignore_activations_(false), |
| 236 selected_grid_index_(0), | 221 selected_grid_index_(0), |
| 237 overview_start_time_(base::Time::Now()), | 222 overview_start_time_(base::Time::Now()), |
| 238 num_key_presses_(0), | 223 num_key_presses_(0), |
| 239 num_items_(0), | 224 num_items_(0), |
| 240 showing_selection_widget_(false), | 225 showing_selection_widget_(false), |
| 241 text_filter_string_length_(0), | 226 text_filter_string_length_(0), |
| 242 num_times_textfield_cleared_(0), | 227 num_times_textfield_cleared_(0), |
| 243 restoring_minimized_windows_(false) { | 228 restoring_minimized_windows_(false) { |
| 244 DCHECK(delegate_); | 229 DCHECK(delegate_); |
| 245 } | 230 } |
| 246 | 231 |
| 247 WindowSelector::~WindowSelector() { | 232 WindowSelector::~WindowSelector() { |
| 248 RemoveAllObservers(); | 233 RemoveAllObservers(); |
| 249 } | 234 } |
| 250 | 235 |
| 251 // NOTE: The work done in Init() is not done in the constructor because it may | 236 // NOTE: The work done in Init() is not done in the constructor because it may |
| 252 // cause other, unrelated classes, (ie PanelLayoutManager) to make indirect | 237 // cause other, unrelated classes, (ie PanelLayoutManager) to make indirect |
| 253 // calls to restoring_minimized_windows() on a partially constructed object. | 238 // calls to restoring_minimized_windows() on a partially constructed object. |
| 254 void WindowSelector::Init(const WindowList& windows) { | 239 void WindowSelector::Init(const WindowList& windows) { |
| 255 if (restore_focus_window_) | 240 if (restore_focus_window_) |
| 256 restore_focus_window_->AddObserver(this); | 241 restore_focus_window_->AddObserver(this); |
| 257 | 242 |
| 258 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 243 wm::WmGlobals* globals = wm::WmGlobals::Get(); |
| 244 | |
| 245 std::vector<wm::WmWindow*> root_windows = globals->GetAllRootWindows(); | |
| 259 std::sort(root_windows.begin(), root_windows.end(), | 246 std::sort(root_windows.begin(), root_windows.end(), |
| 260 [](const aura::Window* a, const aura::Window* b) { | 247 [](const wm::WmWindow* a, const wm::WmWindow* b) { |
| 261 // Since we don't know if windows are vertically or horizontally | 248 // Since we don't know if windows are vertically or horizontally |
| 262 // oriented we use both x and y position. This may be confusing | 249 // oriented we use both x and y position. This may be confusing |
| 263 // if you have 3 or more monitors which are not strictly | 250 // if you have 3 or more monitors which are not strictly |
| 264 // horizontal or vertical but that case is not yet supported. | 251 // horizontal or vertical but that case is not yet supported. |
| 265 return (a->GetBoundsInScreen().x() + a->GetBoundsInScreen().y()) < | 252 return (a->GetBoundsInScreen().x() + a->GetBoundsInScreen().y()) < |
| 266 (b->GetBoundsInScreen().x() + b->GetBoundsInScreen().y()); | 253 (b->GetBoundsInScreen().x() + b->GetBoundsInScreen().y()); |
| 267 }); | 254 }); |
| 268 | 255 |
| 269 for (aura::Window::Windows::const_iterator iter = root_windows.begin(); | 256 for (wm::WmWindow* root : root_windows) { |
| 270 iter != root_windows.end(); iter++) { | |
| 271 // Observed switchable containers for newly created windows on all root | 257 // Observed switchable containers for newly created windows on all root |
| 272 // windows. | 258 // windows. |
| 273 for (size_t i = 0; i < wm::kSwitchableWindowContainerIdsLength; ++i) { | 259 for (size_t i = 0; i < wm::kSwitchableWindowContainerIdsLength; ++i) { |
| 274 aura::Window* container = | 260 wm::WmWindow* container = |
| 275 Shell::GetContainer(*iter, wm::kSwitchableWindowContainerIds[i]); | 261 root->GetChildByShellWindowId(wm::kSwitchableWindowContainerIds[i]); |
| 276 container->AddObserver(this); | 262 container->AddObserver(this); |
| 277 observed_windows_.insert(container); | 263 observed_windows_.insert(container); |
| 278 } | 264 } |
| 279 | 265 |
| 280 // Hide the callout widgets for panels. It is safe to call this for | 266 // Hide the callout widgets for panels. It is safe to call this for |
| 281 // root windows that don't contain any panel windows. | 267 // root windows that don't contain any panel windows. |
| 282 PanelLayoutManager::Get(wm::WmWindowAura::Get(*iter)) | 268 PanelLayoutManager::Get(root)->SetShowCalloutWidgets(false); |
| 283 ->SetShowCalloutWidgets(false); | |
| 284 | 269 |
| 285 std::unique_ptr<WindowGrid> grid(new WindowGrid(*iter, windows, this)); | 270 std::unique_ptr<WindowGrid> grid(new WindowGrid(root, windows, this)); |
| 286 if (grid->empty()) | 271 if (grid->empty()) |
| 287 continue; | 272 continue; |
| 288 num_items_ += grid->size(); | 273 num_items_ += grid->size(); |
| 289 grid_list_.push_back(std::move(grid)); | 274 grid_list_.push_back(std::move(grid)); |
| 290 } | 275 } |
| 291 | 276 |
| 292 { | 277 { |
| 293 // The calls to WindowGrid::PrepareForOverview() and CreateTextFilter(...) | 278 // The calls to WindowGrid::PrepareForOverview() and CreateTextFilter(...) |
| 294 // requires some LayoutManagers (ie PanelLayoutManager) to perform layouts | 279 // requires some LayoutManagers (ie PanelLayoutManager) to perform layouts |
| 295 // so that windows are correctly visible and properly animated in overview | 280 // so that windows are correctly visible and properly animated in overview |
| 296 // mode. Otherwise these layouts should be suppressed during overview mode | 281 // mode. Otherwise these layouts should be suppressed during overview mode |
| 297 // so they don't conflict with overview mode animations. The | 282 // so they don't conflict with overview mode animations. The |
| 298 // |restoring_minimized_windows_| flag enables the PanelLayoutManager to | 283 // |restoring_minimized_windows_| flag enables the PanelLayoutManager to |
| 299 // make this decision. | 284 // make this decision. |
| 300 base::AutoReset<bool> auto_restoring_minimized_windows( | 285 base::AutoReset<bool> auto_restoring_minimized_windows( |
| 301 &restoring_minimized_windows_, true); | 286 &restoring_minimized_windows_, true); |
| 302 | 287 |
| 303 // Do not call PrepareForOverview until all items are added to window_list_ | 288 // Do not call PrepareForOverview until all items are added to window_list_ |
| 304 // as we don't want to cause any window updates until all windows in | 289 // as we don't want to cause any window updates until all windows in |
| 305 // overview are observed. See http://crbug.com/384495. | 290 // overview are observed. See http://crbug.com/384495. |
| 306 for (WindowGrid* window_grid : grid_list_) { | 291 for (std::unique_ptr<WindowGrid>& window_grid : grid_list_) { |
| 307 window_grid->PrepareForOverview(); | 292 window_grid->PrepareForOverview(); |
| 308 window_grid->PositionWindows(true); | 293 window_grid->PositionWindows(true); |
| 309 } | 294 } |
| 310 | 295 |
| 311 text_filter_widget_.reset( | 296 text_filter_widget_.reset( |
| 312 CreateTextFilter(this, Shell::GetPrimaryRootWindow())); | 297 CreateTextFilter(this, globals->GetPrimaryRootWindow())); |
| 313 } | 298 } |
| 314 | 299 |
| 315 DCHECK(!grid_list_.empty()); | 300 DCHECK(!grid_list_.empty()); |
| 316 UMA_HISTOGRAM_COUNTS_100("Ash.WindowSelector.Items", num_items_); | 301 UMA_HISTOGRAM_COUNTS_100("Ash.WindowSelector.Items", num_items_); |
| 317 | 302 |
| 318 Shell* shell = Shell::GetInstance(); | 303 globals->AddActivationObserver(this); |
| 319 | |
| 320 shell->activation_client()->AddObserver(this); | |
| 321 | 304 |
| 322 display::Screen::GetScreen()->AddObserver(this); | 305 display::Screen::GetScreen()->AddObserver(this); |
| 323 shell->metrics()->RecordUserMetricsAction(UMA_WINDOW_OVERVIEW); | 306 globals->RecordUserMetricsAction(wm::WmUserMetricsAction::WINDOW_OVERVIEW); |
| 324 // Send an a11y alert. | 307 // Send an a11y alert. |
| 325 shell->accessibility_delegate()->TriggerAccessibilityAlert( | 308 Shell::GetInstance()->accessibility_delegate()->TriggerAccessibilityAlert( |
| 326 ui::A11Y_ALERT_WINDOW_OVERVIEW_MODE_ENTERED); | 309 ui::A11Y_ALERT_WINDOW_OVERVIEW_MODE_ENTERED); |
| 327 | 310 |
| 328 UpdateShelfVisibility(); | 311 UpdateShelfVisibility(); |
| 329 } | 312 } |
| 330 | 313 |
| 331 // NOTE: The work done in Shutdown() is not done in the destructor because it | 314 // NOTE: The work done in Shutdown() is not done in the destructor because it |
| 332 // may cause other, unrelated classes, (ie PanelLayoutManager) to make indirect | 315 // may cause other, unrelated classes, (ie PanelLayoutManager) to make indirect |
| 333 // calls to restoring_minimized_windows() on a partially destructed object. | 316 // calls to restoring_minimized_windows() on a partially destructed object. |
| 334 void WindowSelector::Shutdown() { | 317 void WindowSelector::Shutdown() { |
| 335 ResetFocusRestoreWindow(true); | 318 ResetFocusRestoreWindow(true); |
| 336 RemoveAllObservers(); | 319 RemoveAllObservers(); |
| 337 | 320 |
| 338 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 321 std::vector<wm::WmWindow*> root_windows = |
| 339 for (aura::Window::Windows::const_iterator iter = root_windows.begin(); | 322 wm::WmGlobals::Get()->GetAllRootWindows(); |
| 340 iter != root_windows.end(); iter++) { | 323 for (wm::WmWindow* window : root_windows) { |
| 341 // Un-hide the callout widgets for panels. It is safe to call this for | 324 // Un-hide the callout widgets for panels. It is safe to call this for |
| 342 // root_windows that don't contain any panel windows. | 325 // root_windows that don't contain any panel windows. |
| 343 PanelLayoutManager::Get(wm::WmWindowAura::Get(*iter)) | 326 PanelLayoutManager::Get(window)->SetShowCalloutWidgets(true); |
| 344 ->SetShowCalloutWidgets(true); | |
| 345 } | 327 } |
| 346 | 328 |
| 347 size_t remaining_items = 0; | 329 size_t remaining_items = 0; |
| 348 for (WindowGrid* window_grid : grid_list_) { | 330 for (std::unique_ptr<WindowGrid>& window_grid : grid_list_) { |
| 349 for (WindowSelectorItem* window_selector_item : window_grid->window_list()) | 331 for (WindowSelectorItem* window_selector_item : window_grid->window_list()) |
| 350 window_selector_item->RestoreWindow(); | 332 window_selector_item->RestoreWindow(); |
| 351 remaining_items += window_grid->size(); | 333 remaining_items += window_grid->size(); |
| 352 } | 334 } |
| 353 | 335 |
| 354 DCHECK(num_items_ >= remaining_items); | 336 DCHECK(num_items_ >= remaining_items); |
| 355 UMA_HISTOGRAM_COUNTS_100("Ash.WindowSelector.OverviewClosedItems", | 337 UMA_HISTOGRAM_COUNTS_100("Ash.WindowSelector.OverviewClosedItems", |
| 356 num_items_ - remaining_items); | 338 num_items_ - remaining_items); |
| 357 UMA_HISTOGRAM_MEDIUM_TIMES("Ash.WindowSelector.TimeInOverview", | 339 UMA_HISTOGRAM_MEDIUM_TIMES("Ash.WindowSelector.TimeInOverview", |
| 358 base::Time::Now() - overview_start_time_); | 340 base::Time::Now() - overview_start_time_); |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 370 "Ash.WindowSelector.ItemsWhenTextFilteringUsed", | 352 "Ash.WindowSelector.ItemsWhenTextFilteringUsed", |
| 371 remaining_items); | 353 remaining_items); |
| 372 } | 354 } |
| 373 | 355 |
| 374 // Clearing the window list resets the ignored_by_shelf flag on the windows. | 356 // Clearing the window list resets the ignored_by_shelf flag on the windows. |
| 375 grid_list_.clear(); | 357 grid_list_.clear(); |
| 376 UpdateShelfVisibility(); | 358 UpdateShelfVisibility(); |
| 377 } | 359 } |
| 378 | 360 |
| 379 void WindowSelector::RemoveAllObservers() { | 361 void WindowSelector::RemoveAllObservers() { |
| 380 Shell* shell = Shell::GetInstance(); | 362 for (wm::WmWindow* window : observed_windows_) |
| 381 for (aura::Window* window : observed_windows_) | |
| 382 window->RemoveObserver(this); | 363 window->RemoveObserver(this); |
| 383 | 364 |
| 384 shell->activation_client()->RemoveObserver(this); | 365 wm::WmGlobals::Get()->RemoveActivationObserver(this); |
| 385 display::Screen::GetScreen()->RemoveObserver(this); | 366 display::Screen::GetScreen()->RemoveObserver(this); |
| 386 if (restore_focus_window_) | 367 if (restore_focus_window_) |
| 387 restore_focus_window_->RemoveObserver(this); | 368 restore_focus_window_->RemoveObserver(this); |
| 388 } | 369 } |
| 389 | 370 |
| 390 void WindowSelector::CancelSelection() { | 371 void WindowSelector::CancelSelection() { |
| 391 delegate_->OnSelectionEnded(); | 372 delegate_->OnSelectionEnded(); |
| 392 } | 373 } |
| 393 | 374 |
| 394 void WindowSelector::OnGridEmpty(WindowGrid* grid) { | 375 void WindowSelector::OnGridEmpty(WindowGrid* grid) { |
| 395 ScopedVector<WindowGrid>::iterator iter = | 376 size_t index = 0; |
| 396 std::find(grid_list_.begin(), grid_list_.end(), grid); | 377 for (auto iter = grid_list_.begin(); iter != grid_list_.end(); ++iter) { |
| 397 DCHECK(iter != grid_list_.end()); | 378 if (grid == (*iter).get()) { |
| 398 size_t index = iter - grid_list_.begin(); | 379 index = iter - grid_list_.begin(); |
| 399 grid_list_.erase(iter); | 380 grid_list_.erase(iter); |
| 381 break; | |
| 382 } | |
| 383 } | |
| 400 if (index > 0 && selected_grid_index_ >= index) { | 384 if (index > 0 && selected_grid_index_ >= index) { |
| 401 selected_grid_index_--; | 385 selected_grid_index_--; |
| 402 // If the grid which became empty was the one with the selected window, we | 386 // If the grid which became empty was the one with the selected window, we |
| 403 // need to select a window on the newly selected grid. | 387 // need to select a window on the newly selected grid. |
| 404 if (selected_grid_index_ == index - 1) | 388 if (selected_grid_index_ == index - 1) |
| 405 Move(LEFT, true); | 389 Move(LEFT, true); |
| 406 } | 390 } |
| 407 if (grid_list_.empty()) | 391 if (grid_list_.empty()) |
| 408 CancelSelection(); | 392 CancelSelection(); |
| 409 } | 393 } |
| 410 | 394 |
| 411 void WindowSelector::SelectWindow(aura::Window* window) { | 395 void WindowSelector::SelectWindow(wm::WmWindow* window) { |
| 412 // Record UMA_WINDOW_OVERVIEW_ACTIVE_WINDOW_CHANGED if the user is selecting | 396 // Record UMA_WINDOW_OVERVIEW_ACTIVE_WINDOW_CHANGED if the user is selecting |
| 413 // a window other than the window that was active prior to entering overview | 397 // a window other than the window that was active prior to entering overview |
| 414 // mode (i.e., the window at the front of the MRU list). | 398 // mode (i.e., the window at the front of the MRU list). |
| 415 MruWindowTracker::WindowList window_list = | 399 std::vector<wm::WmWindow*> window_list = |
| 416 Shell::GetInstance()->mru_window_tracker()->BuildMruWindowList(); | 400 wm::WmGlobals::Get()->GetMruWindowList(); |
| 417 if (window_list.size() > 0 && window_list[0] != window) { | 401 if (!window_list.empty() && window_list[0] != window) { |
| 418 Shell::GetInstance()->metrics()->RecordUserMetricsAction( | 402 wm::WmGlobals::Get()->RecordUserMetricsAction( |
| 419 UMA_WINDOW_OVERVIEW_ACTIVE_WINDOW_CHANGED); | 403 wm::WmUserMetricsAction::WINDOW_OVERVIEW_ACTIVE_WINDOW_CHANGED); |
| 420 } | 404 } |
| 421 | 405 |
| 422 wm::GetWindowState(window)->Activate(); | 406 window->GetWindowState()->Activate(); |
| 423 } | 407 } |
| 424 | 408 |
| 425 bool WindowSelector::HandleKeyEvent(views::Textfield* sender, | 409 bool WindowSelector::HandleKeyEvent(views::Textfield* sender, |
| 426 const ui::KeyEvent& key_event) { | 410 const ui::KeyEvent& key_event) { |
| 427 if (key_event.type() != ui::ET_KEY_PRESSED) | 411 if (key_event.type() != ui::ET_KEY_PRESSED) |
| 428 return false; | 412 return false; |
| 429 | 413 |
| 430 switch (key_event.key_code()) { | 414 switch (key_event.key_code()) { |
| 431 case ui::VKEY_ESCAPE: | 415 case ui::VKEY_ESCAPE: |
| 432 CancelSelection(); | 416 CancelSelection(); |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 450 break; | 434 break; |
| 451 case ui::VKEY_RETURN: | 435 case ui::VKEY_RETURN: |
| 452 // Ignore if no item is selected. | 436 // Ignore if no item is selected. |
| 453 if (!grid_list_[selected_grid_index_]->is_selecting()) | 437 if (!grid_list_[selected_grid_index_]->is_selecting()) |
| 454 return false; | 438 return false; |
| 455 UMA_HISTOGRAM_COUNTS_100("Ash.WindowSelector.ArrowKeyPresses", | 439 UMA_HISTOGRAM_COUNTS_100("Ash.WindowSelector.ArrowKeyPresses", |
| 456 num_key_presses_); | 440 num_key_presses_); |
| 457 UMA_HISTOGRAM_CUSTOM_COUNTS( | 441 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 458 "Ash.WindowSelector.KeyPressesOverItemsRatio", | 442 "Ash.WindowSelector.KeyPressesOverItemsRatio", |
| 459 (num_key_presses_ * 100) / num_items_, 1, 300, 30); | 443 (num_key_presses_ * 100) / num_items_, 1, 300, 30); |
| 460 Shell::GetInstance()->metrics()->RecordUserMetricsAction( | 444 wm::WmGlobals::Get()->RecordUserMetricsAction( |
| 461 UMA_WINDOW_OVERVIEW_ENTER_KEY); | 445 wm::WmUserMetricsAction::WINDOW_OVERVIEW_ENTER_KEY); |
| 462 SelectWindow( | 446 SelectWindow( |
| 463 grid_list_[selected_grid_index_]->SelectedWindow()->GetWindow()); | 447 grid_list_[selected_grid_index_]->SelectedWindow()->GetWindow()); |
| 464 break; | 448 break; |
| 465 default: | 449 default: |
| 466 // Not a key we are interested in, allow the textfield to handle it. | 450 // Not a key we are interested in, allow the textfield to handle it. |
| 467 return false; | 451 return false; |
| 468 } | 452 } |
| 469 return true; | 453 return true; |
| 470 } | 454 } |
| 471 | 455 |
| 472 void WindowSelector::OnDisplayAdded(const display::Display& display) {} | 456 void WindowSelector::OnDisplayAdded(const display::Display& display) {} |
| 473 | 457 |
| 474 void WindowSelector::OnDisplayRemoved(const display::Display& display) { | 458 void WindowSelector::OnDisplayRemoved(const display::Display& display) { |
| 475 // TODO(flackr): Keep window selection active on remaining displays. | 459 // TODO(flackr): Keep window selection active on remaining displays. |
| 476 CancelSelection(); | 460 CancelSelection(); |
| 477 } | 461 } |
| 478 | 462 |
| 479 void WindowSelector::OnDisplayMetricsChanged(const display::Display& display, | 463 void WindowSelector::OnDisplayMetricsChanged(const display::Display& display, |
| 480 uint32_t metrics) { | 464 uint32_t metrics) { |
| 481 PositionWindows(/* animate */ false); | 465 PositionWindows(/* animate */ false); |
| 482 RepositionTextFilterOnDisplayMetricsChange(); | 466 RepositionTextFilterOnDisplayMetricsChange(); |
| 483 } | 467 } |
| 484 | 468 |
| 485 void WindowSelector::OnWindowAdded(aura::Window* new_window) { | 469 void WindowSelector::OnWindowTreeChanged(wm::WmWindow* window, |
| 470 const TreeChangeParams& params) { | |
| 471 if (!observed_windows_.count(window) || | |
|
James Cook
2016/05/27 00:02:51
It took me a minute to figure out this was the rig
sky
2016/05/27 03:18:04
Done.
| |
| 472 !observed_windows_.count(params.new_parent)) { | |
| 473 return; | |
| 474 } | |
| 475 | |
| 476 wm::WmWindow* new_window = params.target; | |
| 486 if (!IsSelectable(new_window)) | 477 if (!IsSelectable(new_window)) |
| 487 return; | 478 return; |
| 488 | 479 |
| 489 for (size_t i = 0; i < wm::kSwitchableWindowContainerIdsLength; ++i) { | 480 for (size_t i = 0; i < wm::kSwitchableWindowContainerIdsLength; ++i) { |
| 490 if (new_window->parent()->id() == wm::kSwitchableWindowContainerIds[i] && | 481 if (new_window->GetParent()->GetShellWindowId() == |
| 491 !::wm::GetTransientParent(new_window)) { | 482 wm::kSwitchableWindowContainerIds[i] && |
| 483 !new_window->GetTransientParent()) { | |
| 492 // The new window is in one of the switchable containers, abort overview. | 484 // The new window is in one of the switchable containers, abort overview. |
| 493 CancelSelection(); | 485 CancelSelection(); |
| 494 return; | 486 return; |
| 495 } | 487 } |
| 496 } | 488 } |
| 497 } | 489 } |
| 498 | 490 |
| 499 void WindowSelector::OnWindowDestroying(aura::Window* window) { | 491 void WindowSelector::OnWindowDestroying(wm::WmWindow* window) { |
| 500 window->RemoveObserver(this); | 492 window->RemoveObserver(this); |
| 501 observed_windows_.erase(window); | 493 observed_windows_.erase(window); |
| 502 if (window == restore_focus_window_) | 494 if (window == restore_focus_window_) |
| 503 restore_focus_window_ = nullptr; | 495 restore_focus_window_ = nullptr; |
| 504 } | 496 } |
| 505 | 497 |
| 506 void WindowSelector::OnWindowActivated( | 498 void WindowSelector::OnWindowActivated(wm::WmWindow* gained_active, |
| 507 aura::client::ActivationChangeObserver::ActivationReason reason, | 499 wm::WmWindow* lost_active) { |
| 508 aura::Window* gained_active, | 500 if (ignore_activations_ || !gained_active || |
| 509 aura::Window* lost_active) { | 501 gained_active == GetTextFilterWidgetWindow()) { |
| 510 if (ignore_activations_ || | |
| 511 !gained_active || | |
| 512 gained_active == text_filter_widget_->GetNativeWindow()) { | |
| 513 return; | 502 return; |
| 514 } | 503 } |
| 515 | 504 |
| 516 ScopedVector<WindowGrid>::iterator grid = | 505 auto grid = |
| 517 std::find_if(grid_list_.begin(), grid_list_.end(), | 506 std::find_if(grid_list_.begin(), grid_list_.end(), |
| 518 RootWindowGridComparator(gained_active->GetRootWindow())); | 507 RootWindowGridComparator(gained_active->GetRootWindow())); |
| 519 if (grid == grid_list_.end()) | 508 if (grid == grid_list_.end()) |
| 520 return; | 509 return; |
| 521 const std::vector<WindowSelectorItem*> windows = (*grid)->window_list(); | 510 const std::vector<WindowSelectorItem*> windows = (*grid)->window_list(); |
| 522 | 511 |
| 523 ScopedVector<WindowSelectorItem>::const_iterator iter = std::find_if( | 512 auto iter = std::find_if(windows.begin(), windows.end(), |
| 524 windows.begin(), windows.end(), | 513 WindowSelectorItemTargetComparator(gained_active)); |
| 525 WindowSelectorItemTargetComparator(gained_active)); | |
| 526 | 514 |
| 527 if (iter != windows.end()) | 515 if (iter != windows.end()) |
| 528 (*iter)->ShowWindowOnExit(); | 516 (*iter)->ShowWindowOnExit(); |
| 529 | 517 |
| 530 // Don't restore focus on exit if a window was just activated. | 518 // Don't restore focus on exit if a window was just activated. |
| 531 ResetFocusRestoreWindow(false); | 519 ResetFocusRestoreWindow(false); |
| 532 CancelSelection(); | 520 CancelSelection(); |
| 533 } | 521 } |
| 534 | 522 |
| 535 void WindowSelector::OnAttemptToReactivateWindow(aura::Window* request_active, | 523 void WindowSelector::OnAttemptToReactivateWindow(wm::WmWindow* request_active, |
| 536 aura::Window* actual_active) { | 524 wm::WmWindow* actual_active) { |
| 537 OnWindowActivated(aura::client::ActivationChangeObserver::ActivationReason:: | 525 OnWindowActivated(request_active, actual_active); |
| 538 ACTIVATION_CLIENT, | |
| 539 request_active, actual_active); | |
| 540 } | 526 } |
| 541 | 527 |
| 542 void WindowSelector::ContentsChanged(views::Textfield* sender, | 528 void WindowSelector::ContentsChanged(views::Textfield* sender, |
| 543 const base::string16& new_contents) { | 529 const base::string16& new_contents) { |
| 544 text_filter_string_length_ = new_contents.length(); | 530 text_filter_string_length_ = new_contents.length(); |
| 545 if (!text_filter_string_length_) | 531 if (!text_filter_string_length_) |
| 546 num_times_textfield_cleared_++; | 532 num_times_textfield_cleared_++; |
| 547 | 533 |
| 548 bool should_show_selection_widget = !new_contents.empty(); | 534 bool should_show_selection_widget = !new_contents.empty(); |
| 549 if (showing_selection_widget_ != should_show_selection_widget) { | 535 if (showing_selection_widget_ != should_show_selection_widget) { |
| 536 wm::WmWindow* text_filter_widget_window = GetTextFilterWidgetWindow(); | |
| 550 ui::ScopedLayerAnimationSettings animation_settings( | 537 ui::ScopedLayerAnimationSettings animation_settings( |
| 551 text_filter_widget_->GetNativeWindow()->layer()->GetAnimator()); | 538 text_filter_widget_window->GetLayer()->GetAnimator()); |
| 552 animation_settings.SetPreemptionStrategy( | 539 animation_settings.SetPreemptionStrategy( |
| 553 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); | 540 ui::LayerAnimator::IMMEDIATELY_ANIMATE_TO_NEW_TARGET); |
| 554 animation_settings.SetTweenType(showing_selection_widget_ ? | 541 animation_settings.SetTweenType(showing_selection_widget_ ? |
| 555 gfx::Tween::FAST_OUT_LINEAR_IN : gfx::Tween::LINEAR_OUT_SLOW_IN); | 542 gfx::Tween::FAST_OUT_LINEAR_IN : gfx::Tween::LINEAR_OUT_SLOW_IN); |
| 556 | 543 |
| 557 gfx::Transform transform; | 544 gfx::Transform transform; |
| 558 if (should_show_selection_widget) { | 545 if (should_show_selection_widget) { |
| 559 transform.Translate(0, 0); | 546 transform.Translate(0, 0); |
| 560 text_filter_widget_->GetNativeWindow()->layer()->SetOpacity(1); | 547 text_filter_widget_window->SetOpacity(1); |
| 561 } else { | 548 } else { |
| 562 transform.Translate(0, -kTextFilterBottomEdge); | 549 transform.Translate(0, -kTextFilterBottomEdge); |
| 563 text_filter_widget_->GetNativeWindow()->layer()->SetOpacity(0); | 550 text_filter_widget_window->SetOpacity(0); |
| 564 } | 551 } |
| 565 | 552 |
| 566 text_filter_widget_->GetNativeWindow()->SetTransform(transform); | 553 text_filter_widget_window->SetTransform(transform); |
| 567 showing_selection_widget_ = should_show_selection_widget; | 554 showing_selection_widget_ = should_show_selection_widget; |
| 568 } | 555 } |
| 569 for (ScopedVector<WindowGrid>::iterator iter = grid_list_.begin(); | 556 for (auto iter = grid_list_.begin(); iter != grid_list_.end(); iter++) |
| 570 iter != grid_list_.end(); iter++) { | |
| 571 (*iter)->FilterItems(new_contents); | 557 (*iter)->FilterItems(new_contents); |
| 572 } | |
| 573 | 558 |
| 574 // If the selection widget is not active, execute a Move() command so that it | 559 // If the selection widget is not active, execute a Move() command so that it |
| 575 // shows up on the first undimmed item. | 560 // shows up on the first undimmed item. |
| 576 if (grid_list_[selected_grid_index_]->is_selecting()) | 561 if (grid_list_[selected_grid_index_]->is_selecting()) |
| 577 return; | 562 return; |
| 578 Move(WindowSelector::RIGHT, false); | 563 Move(WindowSelector::RIGHT, false); |
| 579 } | 564 } |
| 580 | 565 |
| 566 wm::WmWindow* WindowSelector::GetTextFilterWidgetWindow() { | |
| 567 return wm::WmLookup::Get()->GetWindowForWidget(text_filter_widget_.get()); | |
| 568 } | |
| 569 | |
| 581 void WindowSelector::PositionWindows(bool animate) { | 570 void WindowSelector::PositionWindows(bool animate) { |
| 582 for (ScopedVector<WindowGrid>::iterator iter = grid_list_.begin(); | 571 for (std::unique_ptr<WindowGrid>& grid : grid_list_) |
| 583 iter != grid_list_.end(); iter++) { | 572 grid->PositionWindows(animate); |
| 584 (*iter)->PositionWindows(animate); | |
| 585 } | |
| 586 } | 573 } |
| 587 | 574 |
| 588 void WindowSelector::RepositionTextFilterOnDisplayMetricsChange() { | 575 void WindowSelector::RepositionTextFilterOnDisplayMetricsChange() { |
| 589 aura::Window* root_window = Shell::GetPrimaryRootWindow(); | 576 wm::WmWindow* root_window = wm::WmGlobals::Get()->GetPrimaryRootWindow(); |
| 590 gfx::Rect rect( | 577 gfx::Rect rect( |
| 591 root_window->bounds().width() / 2 * (1 - kTextFilterScreenProportion), | 578 root_window->GetBounds().width() / 2 * (1 - kTextFilterScreenProportion), |
| 592 kTextFilterDistanceFromTop, | 579 kTextFilterDistanceFromTop, |
| 593 root_window->bounds().width() * kTextFilterScreenProportion, | 580 root_window->GetBounds().width() * kTextFilterScreenProportion, |
| 594 kTextFilterHeight); | 581 kTextFilterHeight); |
| 595 | 582 |
| 596 text_filter_widget_->SetBounds(rect); | 583 text_filter_widget_->SetBounds(rect); |
| 597 | 584 |
| 598 gfx::Transform transform; | 585 gfx::Transform transform; |
| 599 transform.Translate(0, text_filter_string_length_ == 0 | 586 transform.Translate(0, text_filter_string_length_ == 0 |
| 600 ? -WindowSelector::kTextFilterBottomEdge | 587 ? -WindowSelector::kTextFilterBottomEdge |
| 601 : 0); | 588 : 0); |
| 602 text_filter_widget_->GetNativeWindow()->SetTransform(transform); | 589 GetTextFilterWidgetWindow()->SetTransform(transform); |
| 603 } | 590 } |
| 604 | 591 |
| 605 void WindowSelector::ResetFocusRestoreWindow(bool focus) { | 592 void WindowSelector::ResetFocusRestoreWindow(bool focus) { |
| 606 if (!restore_focus_window_) | 593 if (!restore_focus_window_) |
| 607 return; | 594 return; |
| 608 if (focus) { | 595 if (focus) { |
| 609 base::AutoReset<bool> restoring_focus(&ignore_activations_, true); | 596 base::AutoReset<bool> restoring_focus(&ignore_activations_, true); |
| 610 restore_focus_window_->Focus(); | 597 restore_focus_window_->Activate(); |
| 611 } | 598 } |
| 612 // If the window is in the observed_windows_ list it needs to continue to be | 599 // If the window is in the observed_windows_ list it needs to continue to be |
| 613 // observed. | 600 // observed. |
| 614 if (observed_windows_.find(restore_focus_window_) == | 601 if (observed_windows_.find(restore_focus_window_) == |
| 615 observed_windows_.end()) { | 602 observed_windows_.end()) { |
| 616 restore_focus_window_->RemoveObserver(this); | 603 restore_focus_window_->RemoveObserver(this); |
| 617 } | 604 } |
| 618 restore_focus_window_ = nullptr; | 605 restore_focus_window_ = nullptr; |
| 619 } | 606 } |
| 620 | 607 |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 634 for (size_t i = 0; | 621 for (size_t i = 0; |
| 635 i <= grid_list_.size() && | 622 i <= grid_list_.size() && |
| 636 grid_list_[selected_grid_index_]->Move(direction, animate); i++) { | 623 grid_list_[selected_grid_index_]->Move(direction, animate); i++) { |
| 637 selected_grid_index_ = | 624 selected_grid_index_ = |
| 638 (selected_grid_index_ + display_direction + grid_list_.size()) % | 625 (selected_grid_index_ + display_direction + grid_list_.size()) % |
| 639 grid_list_.size(); | 626 grid_list_.size(); |
| 640 } | 627 } |
| 641 } | 628 } |
| 642 | 629 |
| 643 } // namespace ash | 630 } // namespace ash |
| OLD | NEW |