OLD | NEW |
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/shelf_layout_manager.h" | 5 #include "ash/wm/shelf_layout_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "ash/launcher/launcher.h" | 9 #include "ash/launcher/launcher.h" |
10 #include "ash/screen_ash.h" | 10 #include "ash/screen_ash.h" |
11 #include "ash/shell.h" | 11 #include "ash/shell.h" |
12 #include "ash/shell_delegate.h" | 12 #include "ash/shell_delegate.h" |
13 #include "ash/shell_window_ids.h" | 13 #include "ash/shell_window_ids.h" |
14 #include "ash/system/status_area_widget.h" | 14 #include "ash/system/status_area_widget.h" |
15 #include "ash/system/tray/system_tray.h" | 15 #include "ash/system/tray/system_tray.h" |
| 16 #include "ash/system/web_notification/web_notification_tray.h" |
16 #include "ash/wm/workspace/workspace_manager.h" | 17 #include "ash/wm/workspace/workspace_manager.h" |
17 #include "base/auto_reset.h" | 18 #include "base/auto_reset.h" |
18 #include "base/i18n/rtl.h" | 19 #include "base/i18n/rtl.h" |
19 #include "ui/aura/client/activation_client.h" | 20 #include "ui/aura/client/activation_client.h" |
20 #include "ui/aura/event.h" | 21 #include "ui/aura/event.h" |
21 #include "ui/aura/event_filter.h" | 22 #include "ui/aura/event_filter.h" |
22 #include "ui/aura/root_window.h" | 23 #include "ui/aura/root_window.h" |
23 #include "ui/compositor/layer.h" | 24 #include "ui/compositor/layer.h" |
24 #include "ui/compositor/layer_animation_observer.h" | 25 #include "ui/compositor/layer_animation_observer.h" |
25 #include "ui/compositor/layer_animator.h" | 26 #include "ui/compositor/layer_animator.h" |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 LayoutShelf(); | 190 LayoutShelf(); |
190 } | 191 } |
191 | 192 |
192 bool ShelfLayoutManager::SetAlignment(ShelfAlignment alignment) { | 193 bool ShelfLayoutManager::SetAlignment(ShelfAlignment alignment) { |
193 if (alignment_ == alignment) | 194 if (alignment_ == alignment) |
194 return false; | 195 return false; |
195 | 196 |
196 alignment_ = alignment; | 197 alignment_ = alignment; |
197 if (launcher_) | 198 if (launcher_) |
198 launcher_->SetAlignment(alignment); | 199 launcher_->SetAlignment(alignment); |
199 if (Shell::GetInstance()->status_area_widget()) | 200 StatusAreaWidget* status_area_widget = |
| 201 Shell::GetInstance()->status_area_widget(); |
| 202 if (status_area_widget) { |
200 Shell::GetInstance()->status_area_widget()->SetShelfAlignment(alignment); | 203 Shell::GetInstance()->status_area_widget()->SetShelfAlignment(alignment); |
201 if (Shell::GetInstance()->system_tray()) | 204 if (status_area_widget->system_tray()) |
202 Shell::GetInstance()->system_tray()->SetShelfAlignment(alignment); | 205 status_area_widget->system_tray()->SetShelfAlignment(alignment); |
| 206 if (status_area_widget->web_notification_tray()) |
| 207 status_area_widget->web_notification_tray()->SetShelfAlignment(alignment); |
| 208 } |
203 LayoutShelf(); | 209 LayoutShelf(); |
204 return true; | 210 return true; |
205 } | 211 } |
206 | 212 |
207 gfx::Rect ShelfLayoutManager::GetIdealBounds() { | 213 gfx::Rect ShelfLayoutManager::GetIdealBounds() { |
208 // TODO: this is wrong. Figure out what monitor shelf is on and everything | 214 // TODO: this is wrong. Figure out what monitor shelf is on and everything |
209 // should be based on it. | 215 // should be based on it. |
210 gfx::Rect bounds( | 216 gfx::Rect bounds( |
211 gfx::Screen::GetMonitorNearestWindow(status_->GetNativeView()).bounds()); | 217 gfx::Screen::GetMonitorNearestWindow(status_->GetNativeView()).bounds()); |
212 int width = 0, height = 0; | 218 int width = 0, height = 0; |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 state.visibility_state == AUTO_HIDE) ? 1.0f : 0.0f; | 492 state.visibility_state == AUTO_HIDE) ? 1.0f : 0.0f; |
487 } | 493 } |
488 | 494 |
489 void ShelfLayoutManager::UpdateShelfBackground( | 495 void ShelfLayoutManager::UpdateShelfBackground( |
490 BackgroundAnimator::ChangeType type) { | 496 BackgroundAnimator::ChangeType type) { |
491 bool launcher_paints = GetLauncherPaintsBackground(); | 497 bool launcher_paints = GetLauncherPaintsBackground(); |
492 if (launcher_) | 498 if (launcher_) |
493 launcher_->SetPaintsBackground(launcher_paints, type); | 499 launcher_->SetPaintsBackground(launcher_paints, type); |
494 // SystemTray normally draws a background, but we don't want it to draw a | 500 // SystemTray normally draws a background, but we don't want it to draw a |
495 // background when the launcher does. | 501 // background when the launcher does. |
496 if (Shell::GetInstance()->system_tray()) { | 502 StatusAreaWidget* status_area_widget = |
497 Shell::GetInstance()->system_tray()->SetPaintsBackground( | 503 Shell::GetInstance()->status_area_widget(); |
| 504 if (!status_area_widget) |
| 505 return; |
| 506 if (status_area_widget->system_tray()) { |
| 507 status_area_widget->system_tray()->SetPaintsBackground( |
| 508 !launcher_paints, type); |
| 509 } |
| 510 if (status_area_widget->web_notification_tray()) { |
| 511 status_area_widget->web_notification_tray()->SetPaintsBackground( |
498 !launcher_paints, type); | 512 !launcher_paints, type); |
499 } | 513 } |
500 } | 514 } |
501 | 515 |
502 bool ShelfLayoutManager::GetLauncherPaintsBackground() const { | 516 bool ShelfLayoutManager::GetLauncherPaintsBackground() const { |
503 return (!state_.is_screen_locked && window_overlaps_shelf_) || | 517 return (!state_.is_screen_locked && window_overlaps_shelf_) || |
504 state_.visibility_state == AUTO_HIDE; | 518 state_.visibility_state == AUTO_HIDE; |
505 } | 519 } |
506 | 520 |
507 void ShelfLayoutManager::UpdateAutoHideStateNow() { | 521 void ShelfLayoutManager::UpdateAutoHideStateNow() { |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 int ShelfLayoutManager::GetWorkAreaSize(const State& state, int size) const { | 587 int ShelfLayoutManager::GetWorkAreaSize(const State& state, int size) const { |
574 if (state.visibility_state == VISIBLE) | 588 if (state.visibility_state == VISIBLE) |
575 return size; | 589 return size; |
576 if (state.visibility_state == AUTO_HIDE) | 590 if (state.visibility_state == AUTO_HIDE) |
577 return kAutoHideSize; | 591 return kAutoHideSize; |
578 return 0; | 592 return 0; |
579 } | 593 } |
580 | 594 |
581 } // namespace internal | 595 } // namespace internal |
582 } // namespace ash | 596 } // namespace ash |
OLD | NEW |