| 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/shelf/shelf_layout_manager.h" | 5 #include "ash/shelf/shelf_layout_manager.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 window_overlaps_shelf_(false), | 150 window_overlaps_shelf_(false), |
| 151 mouse_over_shelf_when_auto_hide_timer_started_(false), | 151 mouse_over_shelf_when_auto_hide_timer_started_(false), |
| 152 gesture_drag_status_(GESTURE_DRAG_NONE), | 152 gesture_drag_status_(GESTURE_DRAG_NONE), |
| 153 gesture_drag_amount_(0.f), | 153 gesture_drag_amount_(0.f), |
| 154 gesture_drag_auto_hide_state_(SHELF_AUTO_HIDE_SHOWN), | 154 gesture_drag_auto_hide_state_(SHELF_AUTO_HIDE_SHOWN), |
| 155 update_shelf_observer_(NULL), | 155 update_shelf_observer_(NULL), |
| 156 chromevox_panel_height_(0), | 156 chromevox_panel_height_(0), |
| 157 duration_override_in_ms_(0), | 157 duration_override_in_ms_(0), |
| 158 root_window_controller_observer_( | 158 root_window_controller_observer_( |
| 159 new RootWindowControllerObserverImpl(this)) { | 159 new RootWindowControllerObserverImpl(this)) { |
| 160 DCHECK(shelf_widget_); |
| 160 WmShell::Get()->AddShellObserver(this); | 161 WmShell::Get()->AddShellObserver(this); |
| 161 WmShell::Get()->AddLockStateObserver(this); | 162 WmShell::Get()->AddLockStateObserver(this); |
| 162 WmShell::Get()->AddActivationObserver(this); | 163 WmShell::Get()->AddActivationObserver(this); |
| 163 WmShell::Get()->GetSessionStateDelegate()->AddSessionStateObserver(this); | 164 WmShell::Get()->GetSessionStateDelegate()->AddSessionStateObserver(this); |
| 164 } | 165 } |
| 165 | 166 |
| 166 ShelfLayoutManager::~ShelfLayoutManager() { | 167 ShelfLayoutManager::~ShelfLayoutManager() { |
| 167 if (update_shelf_observer_) | 168 if (update_shelf_observer_) |
| 168 update_shelf_observer_->Detach(); | 169 update_shelf_observer_->Detach(); |
| 169 | 170 |
| (...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 877 else | 878 else |
| 878 show_shelf_region_in_screen.set_width(kMaxAutoHideShowShelfRegionSize); | 879 show_shelf_region_in_screen.set_width(kMaxAutoHideShowShelfRegionSize); |
| 879 | 880 |
| 880 // TODO: Figure out if we need any special handling when the keyboard is | 881 // TODO: Figure out if we need any special handling when the keyboard is |
| 881 // visible. | 882 // visible. |
| 882 return show_shelf_region_in_screen; | 883 return show_shelf_region_in_screen; |
| 883 } | 884 } |
| 884 | 885 |
| 885 ShelfAutoHideState ShelfLayoutManager::CalculateAutoHideState( | 886 ShelfAutoHideState ShelfLayoutManager::CalculateAutoHideState( |
| 886 ShelfVisibilityState visibility_state) const { | 887 ShelfVisibilityState visibility_state) const { |
| 887 if (visibility_state != SHELF_AUTO_HIDE || !shelf_widget_ || | 888 if (visibility_state != SHELF_AUTO_HIDE || !shelf_widget_->shelf()) |
| 888 !shelf_widget_->shelf()) | |
| 889 return SHELF_AUTO_HIDE_HIDDEN; | 889 return SHELF_AUTO_HIDE_HIDDEN; |
| 890 | 890 |
| 891 const int64_t shelf_display_id = WmLookup::Get() | 891 const int64_t shelf_display_id = WmLookup::Get() |
| 892 ->GetWindowForWidget(shelf_widget_) | 892 ->GetWindowForWidget(shelf_widget_) |
| 893 ->GetDisplayNearestWindow() | 893 ->GetDisplayNearestWindow() |
| 894 .id(); | 894 .id(); |
| 895 | 895 |
| 896 // Unhide the shelf only on the active screen when the AppList is shown | 896 // Unhide the shelf only on the active screen when the AppList is shown |
| 897 // (crbug.com/312445). | 897 // (crbug.com/312445). |
| 898 if (WmShell::Get()->GetAppListTargetVisibility()) { | 898 if (WmShell::Get()->GetAppListTargetVisibility()) { |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 980 mouse_over_shelf_when_auto_hide_timer_started_) && | 980 mouse_over_shelf_when_auto_hide_timer_started_) && |
| 981 GetAutoHideShowShelfRegionInScreen().Contains( | 981 GetAutoHideShowShelfRegionInScreen().Contains( |
| 982 cursor_position_in_screen)) { | 982 cursor_position_in_screen)) { |
| 983 return SHELF_AUTO_HIDE_SHOWN; | 983 return SHELF_AUTO_HIDE_SHOWN; |
| 984 } | 984 } |
| 985 | 985 |
| 986 return SHELF_AUTO_HIDE_HIDDEN; | 986 return SHELF_AUTO_HIDE_HIDDEN; |
| 987 } | 987 } |
| 988 | 988 |
| 989 bool ShelfLayoutManager::IsShelfWindow(WmWindow* window) { | 989 bool ShelfLayoutManager::IsShelfWindow(WmWindow* window) { |
| 990 if (!window || !shelf_widget_) | 990 if (!window) |
| 991 return false; | 991 return false; |
| 992 WmWindow* shelf_window = WmLookup::Get()->GetWindowForWidget(shelf_widget_); | 992 WmWindow* shelf_window = WmLookup::Get()->GetWindowForWidget(shelf_widget_); |
| 993 WmWindow* status_window = | 993 WmWindow* status_window = |
| 994 WmLookup::Get()->GetWindowForWidget(shelf_widget_->status_area_widget()); | 994 WmLookup::Get()->GetWindowForWidget(shelf_widget_->status_area_widget()); |
| 995 return (shelf_window && shelf_window->Contains(window)) || | 995 return (shelf_window && shelf_window->Contains(window)) || |
| 996 (status_window && status_window->Contains(window)); | 996 (status_window && status_window->Contains(window)); |
| 997 } | 997 } |
| 998 | 998 |
| 999 int ShelfLayoutManager::GetWorkAreaInsets(const State& state, int size) const { | 999 int ShelfLayoutManager::GetWorkAreaInsets(const State& state, int size) const { |
| 1000 if (state.visibility_state == SHELF_VISIBLE) | 1000 if (state.visibility_state == SHELF_VISIBLE) |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1138 gesture.details().velocity_x() < 0); | 1138 gesture.details().velocity_x() < 0); |
| 1139 } | 1139 } |
| 1140 } else { | 1140 } else { |
| 1141 NOTREACHED(); | 1141 NOTREACHED(); |
| 1142 } | 1142 } |
| 1143 | 1143 |
| 1144 if (!should_change) { | 1144 if (!should_change) { |
| 1145 CancelGestureDrag(); | 1145 CancelGestureDrag(); |
| 1146 return; | 1146 return; |
| 1147 } | 1147 } |
| 1148 if (shelf_widget_) { | 1148 |
| 1149 shelf_widget_->Deactivate(); | 1149 shelf_widget_->Deactivate(); |
| 1150 shelf_widget_->status_area_widget()->Deactivate(); | 1150 shelf_widget_->status_area_widget()->Deactivate(); |
| 1151 } | 1151 |
| 1152 gesture_drag_auto_hide_state_ = | 1152 gesture_drag_auto_hide_state_ = |
| 1153 gesture_drag_auto_hide_state_ == SHELF_AUTO_HIDE_SHOWN | 1153 gesture_drag_auto_hide_state_ == SHELF_AUTO_HIDE_SHOWN |
| 1154 ? SHELF_AUTO_HIDE_HIDDEN | 1154 ? SHELF_AUTO_HIDE_HIDDEN |
| 1155 : SHELF_AUTO_HIDE_SHOWN; | 1155 : SHELF_AUTO_HIDE_SHOWN; |
| 1156 ShelfAutoHideBehavior new_auto_hide_behavior = | 1156 ShelfAutoHideBehavior new_auto_hide_behavior = |
| 1157 gesture_drag_auto_hide_state_ == SHELF_AUTO_HIDE_SHOWN | 1157 gesture_drag_auto_hide_state_ == SHELF_AUTO_HIDE_SHOWN |
| 1158 ? SHELF_AUTO_HIDE_BEHAVIOR_NEVER | 1158 ? SHELF_AUTO_HIDE_BEHAVIOR_NEVER |
| 1159 : SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS; | 1159 : SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS; |
| 1160 | 1160 |
| 1161 // When in fullscreen and the shelf is forced to be auto hidden, the auto hide | 1161 // When in fullscreen and the shelf is forced to be auto hidden, the auto hide |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1177 gesture_drag_status_ = GESTURE_DRAG_NONE; | 1177 gesture_drag_status_ = GESTURE_DRAG_NONE; |
| 1178 } | 1178 } |
| 1179 | 1179 |
| 1180 int ShelfLayoutManager::GetShelfInsetsForAutoHide() const { | 1180 int ShelfLayoutManager::GetShelfInsetsForAutoHide() const { |
| 1181 if (invisible_auto_hide_shelf_) | 1181 if (invisible_auto_hide_shelf_) |
| 1182 return 0; | 1182 return 0; |
| 1183 return GetShelfConstant(SHELF_INSETS_FOR_AUTO_HIDE); | 1183 return GetShelfConstant(SHELF_INSETS_FOR_AUTO_HIDE); |
| 1184 } | 1184 } |
| 1185 | 1185 |
| 1186 } // namespace ash | 1186 } // namespace ash |
| OLD | NEW |