| 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 <cstring> | 9 #include <cstring> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 #include "base/strings/string_number_conversions.h" | 39 #include "base/strings/string_number_conversions.h" |
| 40 #include "base/strings/string_util.h" | 40 #include "base/strings/string_util.h" |
| 41 #include "ui/aura/client/cursor_client.h" | 41 #include "ui/aura/client/cursor_client.h" |
| 42 #include "ui/aura/mus/mus_util.h" | 42 #include "ui/aura/mus/mus_util.h" |
| 43 #include "ui/aura/window_event_dispatcher.h" | 43 #include "ui/aura/window_event_dispatcher.h" |
| 44 #include "ui/base/ui_base_switches.h" | 44 #include "ui/base/ui_base_switches.h" |
| 45 #include "ui/compositor/layer.h" | 45 #include "ui/compositor/layer.h" |
| 46 #include "ui/compositor/layer_animation_observer.h" | 46 #include "ui/compositor/layer_animation_observer.h" |
| 47 #include "ui/compositor/layer_animator.h" | 47 #include "ui/compositor/layer_animator.h" |
| 48 #include "ui/compositor/scoped_layer_animation_settings.h" | 48 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 49 #include "ui/display/screen.h" |
| 49 #include "ui/events/event.h" | 50 #include "ui/events/event.h" |
| 50 #include "ui/events/event_handler.h" | 51 #include "ui/events/event_handler.h" |
| 51 #include "ui/gfx/screen.h" | |
| 52 #include "ui/keyboard/keyboard_util.h" | 52 #include "ui/keyboard/keyboard_util.h" |
| 53 #include "ui/views/border.h" | 53 #include "ui/views/border.h" |
| 54 #include "ui/views/widget/widget.h" | 54 #include "ui/views/widget/widget.h" |
| 55 #include "ui/wm/public/activation_client.h" | 55 #include "ui/wm/public/activation_client.h" |
| 56 | 56 |
| 57 namespace ash { | 57 namespace ash { |
| 58 namespace { | 58 namespace { |
| 59 | 59 |
| 60 // Delay before showing the shelf. This is after the mouse stops moving. | 60 // Delay before showing the shelf. This is after the mouse stops moving. |
| 61 const int kAutoHideDelayMS = 200; | 61 const int kAutoHideDelayMS = 200; |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 ShelfAutoHideState auto_hide_state = | 314 ShelfAutoHideState auto_hide_state = |
| 315 CalculateAutoHideState(state_.visibility_state); | 315 CalculateAutoHideState(state_.visibility_state); |
| 316 if (auto_hide_state != state_.auto_hide_state) { | 316 if (auto_hide_state != state_.auto_hide_state) { |
| 317 if (auto_hide_state == SHELF_AUTO_HIDE_HIDDEN) { | 317 if (auto_hide_state == SHELF_AUTO_HIDE_HIDDEN) { |
| 318 // Hides happen immediately. | 318 // Hides happen immediately. |
| 319 SetState(state_.visibility_state); | 319 SetState(state_.visibility_state); |
| 320 } else { | 320 } else { |
| 321 if (!auto_hide_timer_.IsRunning()) { | 321 if (!auto_hide_timer_.IsRunning()) { |
| 322 mouse_over_shelf_when_auto_hide_timer_started_ = | 322 mouse_over_shelf_when_auto_hide_timer_started_ = |
| 323 shelf_->GetWindowBoundsInScreen().Contains( | 323 shelf_->GetWindowBoundsInScreen().Contains( |
| 324 gfx::Screen::GetScreen()->GetCursorScreenPoint()); | 324 display::Screen::GetScreen()->GetCursorScreenPoint()); |
| 325 } | 325 } |
| 326 auto_hide_timer_.Start( | 326 auto_hide_timer_.Start( |
| 327 FROM_HERE, | 327 FROM_HERE, |
| 328 base::TimeDelta::FromMilliseconds(kAutoHideDelayMS), | 328 base::TimeDelta::FromMilliseconds(kAutoHideDelayMS), |
| 329 this, &ShelfLayoutManager::UpdateAutoHideStateNow); | 329 this, &ShelfLayoutManager::UpdateAutoHideStateNow); |
| 330 } | 330 } |
| 331 } else { | 331 } else { |
| 332 StopAutoHideTimer(); | 332 StopAutoHideTimer(); |
| 333 } | 333 } |
| 334 } | 334 } |
| (...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 994 shelf_region.Inset( | 994 shelf_region.Inset( |
| 995 alignment == wm::SHELF_ALIGNMENT_RIGHT ? -kNotificationBubbleGapHeight | 995 alignment == wm::SHELF_ALIGNMENT_RIGHT ? -kNotificationBubbleGapHeight |
| 996 : 0, | 996 : 0, |
| 997 IsHorizontalAlignment() ? -kNotificationBubbleGapHeight : 0, | 997 IsHorizontalAlignment() ? -kNotificationBubbleGapHeight : 0, |
| 998 alignment == wm::SHELF_ALIGNMENT_LEFT ? -kNotificationBubbleGapHeight | 998 alignment == wm::SHELF_ALIGNMENT_LEFT ? -kNotificationBubbleGapHeight |
| 999 : 0, | 999 : 0, |
| 1000 0); | 1000 0); |
| 1001 } | 1001 } |
| 1002 | 1002 |
| 1003 gfx::Point cursor_position_in_screen = | 1003 gfx::Point cursor_position_in_screen = |
| 1004 gfx::Screen::GetScreen()->GetCursorScreenPoint(); | 1004 display::Screen::GetScreen()->GetCursorScreenPoint(); |
| 1005 if (shelf_region.Contains(cursor_position_in_screen)) | 1005 if (shelf_region.Contains(cursor_position_in_screen)) |
| 1006 return SHELF_AUTO_HIDE_SHOWN; | 1006 return SHELF_AUTO_HIDE_SHOWN; |
| 1007 | 1007 |
| 1008 // When the shelf is auto hidden and the shelf is on the boundary between two | 1008 // When the shelf is auto hidden and the shelf is on the boundary between two |
| 1009 // displays, it is hard to trigger showing the shelf. For instance, if a | 1009 // displays, it is hard to trigger showing the shelf. For instance, if a |
| 1010 // user's primary display is left of their secondary display, it is hard to | 1010 // user's primary display is left of their secondary display, it is hard to |
| 1011 // unautohide a left aligned shelf on the secondary display. | 1011 // unautohide a left aligned shelf on the secondary display. |
| 1012 // It is hard because: | 1012 // It is hard because: |
| 1013 // - It is hard to stop the cursor in the shelf "light bar" and not overshoot. | 1013 // - It is hard to stop the cursor in the shelf "light bar" and not overshoot. |
| 1014 // - The cursor is warped to the other display if the cursor gets to the edge | 1014 // - The cursor is warped to the other display if the cursor gets to the edge |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1101 UpdateBoundsAndOpacity(target_bounds, true, NULL); | 1101 UpdateBoundsAndOpacity(target_bounds, true, NULL); |
| 1102 UpdateVisibilityState(); | 1102 UpdateVisibilityState(); |
| 1103 } | 1103 } |
| 1104 | 1104 |
| 1105 void ShelfLayoutManager::UpdateShelfVisibilityAfterLoginUIChange() { | 1105 void ShelfLayoutManager::UpdateShelfVisibilityAfterLoginUIChange() { |
| 1106 UpdateVisibilityState(); | 1106 UpdateVisibilityState(); |
| 1107 LayoutShelf(); | 1107 LayoutShelf(); |
| 1108 } | 1108 } |
| 1109 | 1109 |
| 1110 } // namespace ash | 1110 } // namespace ash |
| OLD | NEW |