| 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 #include <cmath> | 8 #include <cmath> |
| 9 | 9 |
| 10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
| 11 #include "ash/launcher/launcher.h" | 11 #include "ash/launcher/launcher.h" |
| 12 #include "ash/root_window_controller.h" |
| 12 #include "ash/screen_ash.h" | 13 #include "ash/screen_ash.h" |
| 13 #include "ash/shell.h" | 14 #include "ash/shell.h" |
| 14 #include "ash/shell_delegate.h" | 15 #include "ash/shell_delegate.h" |
| 15 #include "ash/shell_window_ids.h" | 16 #include "ash/shell_window_ids.h" |
| 16 #include "ash/system/status_area_widget.h" | 17 #include "ash/system/status_area_widget.h" |
| 17 #include "ash/wm/workspace_controller.h" | 18 #include "ash/wm/workspace_controller.h" |
| 18 #include "ash/wm/workspace/workspace_animations.h" | 19 #include "ash/wm/workspace/workspace_animations.h" |
| 19 #include "base/auto_reset.h" | 20 #include "base/auto_reset.h" |
| 20 #include "base/command_line.h" | 21 #include "base/command_line.h" |
| 21 #include "base/i18n/rtl.h" | 22 #include "base/i18n/rtl.h" |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 } | 225 } |
| 225 | 226 |
| 226 bool ShelfLayoutManager::SetAlignment(ShelfAlignment alignment) { | 227 bool ShelfLayoutManager::SetAlignment(ShelfAlignment alignment) { |
| 227 if (alignment_ == alignment) | 228 if (alignment_ == alignment) |
| 228 return false; | 229 return false; |
| 229 | 230 |
| 230 alignment_ = alignment; | 231 alignment_ = alignment; |
| 231 if (launcher_) | 232 if (launcher_) |
| 232 launcher_->SetAlignment(alignment); | 233 launcher_->SetAlignment(alignment); |
| 233 StatusAreaWidget* status_area_widget = | 234 StatusAreaWidget* status_area_widget = |
| 234 Shell::GetInstance()->status_area_widget(); | 235 RootWindowController::ForLauncher(root_window_)->status_area_widget(); |
| 235 if (status_area_widget) | 236 if (status_area_widget) |
| 236 Shell::GetInstance()->status_area_widget()->SetShelfAlignment(alignment); | 237 status_area_widget->SetShelfAlignment(alignment); |
| 237 LayoutShelf(); | 238 LayoutShelf(); |
| 238 return true; | 239 return true; |
| 239 } | 240 } |
| 240 | 241 |
| 241 gfx::Rect ShelfLayoutManager::GetIdealBounds() { | 242 gfx::Rect ShelfLayoutManager::GetIdealBounds() { |
| 242 // TODO(oshima): this is wrong. Figure out what display shelf is on | 243 // TODO(oshima): this is wrong. Figure out what display shelf is on |
| 243 // and everything should be based on it. | 244 // and everything should be based on it. |
| 244 gfx::Rect bounds(ScreenAsh::GetDisplayBoundsInParent( | 245 gfx::Rect bounds(ScreenAsh::GetDisplayBoundsInParent( |
| 245 status_->GetNativeView())); | 246 status_->GetNativeView())); |
| 246 int width = 0, height = 0; | 247 int width = 0, height = 0; |
| (...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 810 } | 811 } |
| 811 | 812 |
| 812 void ShelfLayoutManager::UpdateShelfBackground( | 813 void ShelfLayoutManager::UpdateShelfBackground( |
| 813 BackgroundAnimator::ChangeType type) { | 814 BackgroundAnimator::ChangeType type) { |
| 814 bool launcher_paints = GetLauncherPaintsBackground(); | 815 bool launcher_paints = GetLauncherPaintsBackground(); |
| 815 if (launcher_) | 816 if (launcher_) |
| 816 launcher_->SetPaintsBackground(launcher_paints, type); | 817 launcher_->SetPaintsBackground(launcher_paints, type); |
| 817 // The status area normally draws a background, but we don't want it to draw a | 818 // The status area normally draws a background, but we don't want it to draw a |
| 818 // background when the launcher does or when we're at login/lock screen. | 819 // background when the launcher does or when we're at login/lock screen. |
| 819 StatusAreaWidget* status_area_widget = | 820 StatusAreaWidget* status_area_widget = |
| 820 Shell::GetInstance()->status_area_widget(); | 821 RootWindowController::ForLauncher(root_window_)->status_area_widget(); |
| 821 if (status_area_widget) { | 822 if (status_area_widget) { |
| 822 ShellDelegate* delegate = Shell::GetInstance()->delegate(); | 823 ShellDelegate* delegate = Shell::GetInstance()->delegate(); |
| 823 bool delegate_allows_tray_bg = !delegate || | 824 bool delegate_allows_tray_bg = !delegate || |
| 824 (delegate->IsUserLoggedIn() && !delegate->IsScreenLocked()); | 825 (delegate->IsUserLoggedIn() && !delegate->IsScreenLocked()); |
| 825 bool status_area_paints = !launcher_paints && delegate_allows_tray_bg; | 826 bool status_area_paints = !launcher_paints && delegate_allows_tray_bg; |
| 826 status_area_widget->SetPaintsBackground(status_area_paints, type); | 827 status_area_widget->SetPaintsBackground(status_area_paints, type); |
| 827 } | 828 } |
| 828 } | 829 } |
| 829 | 830 |
| 830 bool ShelfLayoutManager::GetLauncherPaintsBackground() const { | 831 bool ShelfLayoutManager::GetLauncherPaintsBackground() const { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 842 if (visibility_state != AUTO_HIDE || !launcher_widget()) | 843 if (visibility_state != AUTO_HIDE || !launcher_widget()) |
| 843 return AUTO_HIDE_HIDDEN; | 844 return AUTO_HIDE_HIDDEN; |
| 844 | 845 |
| 845 if (gesture_drag_status_ == GESTURE_DRAG_COMPLETE_IN_PROGRESS) | 846 if (gesture_drag_status_ == GESTURE_DRAG_COMPLETE_IN_PROGRESS) |
| 846 return gesture_drag_auto_hide_state_; | 847 return gesture_drag_auto_hide_state_; |
| 847 | 848 |
| 848 Shell* shell = Shell::GetInstance(); | 849 Shell* shell = Shell::GetInstance(); |
| 849 if (shell->GetAppListTargetVisibility()) | 850 if (shell->GetAppListTargetVisibility()) |
| 850 return AUTO_HIDE_SHOWN; | 851 return AUTO_HIDE_SHOWN; |
| 851 | 852 |
| 852 if (shell->status_area_widget() && | 853 StatusAreaWidget* status_area_widget = |
| 853 shell->status_area_widget()->ShouldShowLauncher()) | 854 RootWindowController::ForLauncher(root_window_)->status_area_widget(); |
| 855 |
| 856 if (status_area_widget && status_area_widget->ShouldShowLauncher()) |
| 854 return AUTO_HIDE_SHOWN; | 857 return AUTO_HIDE_SHOWN; |
| 855 | 858 |
| 856 if (launcher_ && launcher_->IsShowingMenu()) | 859 if (launcher_ && launcher_->IsShowingMenu()) |
| 857 return AUTO_HIDE_SHOWN; | 860 return AUTO_HIDE_SHOWN; |
| 858 | 861 |
| 859 if (launcher_ && launcher_->IsShowingOverflowBubble()) | 862 if (launcher_ && launcher_->IsShowingOverflowBubble()) |
| 860 return AUTO_HIDE_SHOWN; | 863 return AUTO_HIDE_SHOWN; |
| 861 | 864 |
| 862 if (launcher_widget()->IsActive() || status_->IsActive()) | 865 if (launcher_widget()->IsActive() || status_->IsActive()) |
| 863 return AUTO_HIDE_SHOWN; | 866 return AUTO_HIDE_SHOWN; |
| 864 | 867 |
| 865 // Don't show if the user is dragging the mouse. | 868 // Don't show if the user is dragging the mouse. |
| 866 if (event_filter_.get() && event_filter_->in_mouse_drag()) | 869 if (event_filter_.get() && event_filter_->in_mouse_drag()) |
| 867 return AUTO_HIDE_HIDDEN; | 870 return AUTO_HIDE_HIDDEN; |
| 868 | 871 |
| 869 gfx::Rect shelf_region = launcher_widget()->GetWindowBoundsInScreen(); | 872 gfx::Rect shelf_region = launcher_widget()->GetWindowBoundsInScreen(); |
| 870 if (shell->status_area_widget() && | 873 if (status_area_widget && |
| 871 shell->status_area_widget()->IsMessageBubbleShown() && | 874 status_area_widget->IsMessageBubbleShown() && |
| 872 IsVisible()) { | 875 IsVisible()) { |
| 873 // Increase the the hit test area to prevent the shelf from disappearing | 876 // Increase the the hit test area to prevent the shelf from disappearing |
| 874 // when the mouse is over the bubble gap. | 877 // when the mouse is over the bubble gap. |
| 875 shelf_region.Inset(alignment_ == SHELF_ALIGNMENT_RIGHT ? | 878 shelf_region.Inset(alignment_ == SHELF_ALIGNMENT_RIGHT ? |
| 876 -kNotificationBubbleGapHeight : 0, | 879 -kNotificationBubbleGapHeight : 0, |
| 877 alignment_ == SHELF_ALIGNMENT_BOTTOM ? | 880 alignment_ == SHELF_ALIGNMENT_BOTTOM ? |
| 878 -kNotificationBubbleGapHeight : 0, | 881 -kNotificationBubbleGapHeight : 0, |
| 879 alignment_ == SHELF_ALIGNMENT_LEFT ? | 882 alignment_ == SHELF_ALIGNMENT_LEFT ? |
| 880 -kNotificationBubbleGapHeight : 0, | 883 -kNotificationBubbleGapHeight : 0, |
| 881 0); | 884 0); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 921 int ShelfLayoutManager::GetWorkAreaSize(const State& state, int size) const { | 924 int ShelfLayoutManager::GetWorkAreaSize(const State& state, int size) const { |
| 922 if (state.visibility_state == VISIBLE) | 925 if (state.visibility_state == VISIBLE) |
| 923 return size; | 926 return size; |
| 924 if (state.visibility_state == AUTO_HIDE) | 927 if (state.visibility_state == AUTO_HIDE) |
| 925 return kAutoHideSize; | 928 return kAutoHideSize; |
| 926 return 0; | 929 return 0; |
| 927 } | 930 } |
| 928 | 931 |
| 929 } // namespace internal | 932 } // namespace internal |
| 930 } // namespace ash | 933 } // namespace ash |
| OLD | NEW |