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 18 matching lines...) Expand all Loading... |
29 #include "ash/wm/window_properties.h" | 29 #include "ash/wm/window_properties.h" |
30 #include "ash/wm/window_util.h" | 30 #include "ash/wm/window_util.h" |
31 #include "ash/wm/workspace_controller.h" | 31 #include "ash/wm/workspace_controller.h" |
32 #include "base/auto_reset.h" | 32 #include "base/auto_reset.h" |
33 #include "base/command_line.h" | 33 #include "base/command_line.h" |
34 #include "base/command_line.h" | 34 #include "base/command_line.h" |
35 #include "base/i18n/rtl.h" | 35 #include "base/i18n/rtl.h" |
36 #include "base/strings/string_number_conversions.h" | 36 #include "base/strings/string_number_conversions.h" |
37 #include "base/strings/string_util.h" | 37 #include "base/strings/string_util.h" |
38 #include "ui/aura/client/activation_client.h" | 38 #include "ui/aura/client/activation_client.h" |
| 39 #include "ui/aura/client/cursor_client.h" |
39 #include "ui/aura/root_window.h" | 40 #include "ui/aura/root_window.h" |
40 #include "ui/base/events/event.h" | 41 #include "ui/base/events/event.h" |
41 #include "ui/base/events/event_handler.h" | 42 #include "ui/base/events/event_handler.h" |
42 #include "ui/base/ui_base_switches.h" | 43 #include "ui/base/ui_base_switches.h" |
43 #include "ui/compositor/layer.h" | 44 #include "ui/compositor/layer.h" |
44 #include "ui/compositor/layer_animation_observer.h" | 45 #include "ui/compositor/layer_animation_observer.h" |
45 #include "ui/compositor/layer_animator.h" | 46 #include "ui/compositor/layer_animator.h" |
46 #include "ui/compositor/scoped_layer_animation_settings.h" | 47 #include "ui/compositor/scoped_layer_animation_settings.h" |
47 #include "ui/gfx/screen.h" | 48 #include "ui/gfx/screen.h" |
48 #include "ui/views/widget/widget.h" | 49 #include "ui/views/widget/widget.h" |
(...skipping 885 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
934 // TODO: Figure out if we need any special handling when the keyboard is | 935 // TODO: Figure out if we need any special handling when the keyboard is |
935 // visible. | 936 // visible. |
936 return show_shelf_region_in_screen; | 937 return show_shelf_region_in_screen; |
937 } | 938 } |
938 | 939 |
939 ShelfAutoHideState ShelfLayoutManager::CalculateAutoHideState( | 940 ShelfAutoHideState ShelfLayoutManager::CalculateAutoHideState( |
940 ShelfVisibilityState visibility_state) const { | 941 ShelfVisibilityState visibility_state) const { |
941 if (visibility_state != SHELF_AUTO_HIDE || !shelf_) | 942 if (visibility_state != SHELF_AUTO_HIDE || !shelf_) |
942 return SHELF_AUTO_HIDE_HIDDEN; | 943 return SHELF_AUTO_HIDE_HIDDEN; |
943 | 944 |
944 if (gesture_drag_status_ == GESTURE_DRAG_COMPLETE_IN_PROGRESS) | |
945 return gesture_drag_auto_hide_state_; | |
946 | |
947 Shell* shell = Shell::GetInstance(); | 945 Shell* shell = Shell::GetInstance(); |
948 if (shell->GetAppListTargetVisibility()) | 946 if (shell->GetAppListTargetVisibility()) |
949 return SHELF_AUTO_HIDE_SHOWN; | 947 return SHELF_AUTO_HIDE_SHOWN; |
950 | 948 |
951 if (shelf_->status_area_widget() && | 949 if (shelf_->status_area_widget() && |
952 shelf_->status_area_widget()->ShouldShowLauncher()) | 950 shelf_->status_area_widget()->ShouldShowLauncher()) |
953 return SHELF_AUTO_HIDE_SHOWN; | 951 return SHELF_AUTO_HIDE_SHOWN; |
954 | 952 |
955 if (shelf_->launcher() && shelf_->launcher()->IsShowingMenu()) | 953 if (shelf_->launcher() && shelf_->launcher()->IsShowingMenu()) |
956 return SHELF_AUTO_HIDE_SHOWN; | 954 return SHELF_AUTO_HIDE_SHOWN; |
957 | 955 |
958 if (shelf_->launcher() && shelf_->launcher()->IsShowingOverflowBubble()) | 956 if (shelf_->launcher() && shelf_->launcher()->IsShowingOverflowBubble()) |
959 return SHELF_AUTO_HIDE_SHOWN; | 957 return SHELF_AUTO_HIDE_SHOWN; |
960 | 958 |
961 if (shelf_->IsActive() || shelf_->status_area_widget()->IsActive()) | 959 if (shelf_->IsActive() || shelf_->status_area_widget()->IsActive()) |
962 return SHELF_AUTO_HIDE_SHOWN; | 960 return SHELF_AUTO_HIDE_SHOWN; |
963 | 961 |
| 962 const std::vector<aura::Window*> windows = |
| 963 ash::MruWindowTracker::BuildWindowList(false); |
| 964 |
| 965 // Process the window list and check if there are any visible windows. |
| 966 bool visible_window = false; |
| 967 for (size_t i = 0; i < windows.size(); ++i) { |
| 968 if (windows[i] && windows[i]->IsVisible() && |
| 969 !ash::wm::IsWindowMinimized(windows[i]) && |
| 970 root_window_ == windows[i]->GetRootWindow()) { |
| 971 visible_window = true; |
| 972 break; |
| 973 } |
| 974 } |
| 975 // If there are no visible windows do not hide the shelf. |
| 976 if (!visible_window) |
| 977 return SHELF_AUTO_HIDE_SHOWN; |
| 978 |
| 979 if (gesture_drag_status_ == GESTURE_DRAG_COMPLETE_IN_PROGRESS) |
| 980 return gesture_drag_auto_hide_state_; |
| 981 |
964 // Don't show if the user is dragging the mouse. | 982 // Don't show if the user is dragging the mouse. |
965 if (auto_hide_event_filter_.get() && auto_hide_event_filter_->in_mouse_drag()) | 983 if (auto_hide_event_filter_.get() && auto_hide_event_filter_->in_mouse_drag()) |
966 return SHELF_AUTO_HIDE_HIDDEN; | 984 return SHELF_AUTO_HIDE_HIDDEN; |
967 | 985 |
| 986 // Ignore the mouse position if mouse events are disabled. |
| 987 aura::client::CursorClient* cursor_client = aura::client::GetCursorClient( |
| 988 shelf_->GetNativeWindow()->GetRootWindow()); |
| 989 if (!cursor_client->IsMouseEventsEnabled()) |
| 990 return SHELF_AUTO_HIDE_HIDDEN; |
| 991 |
968 gfx::Rect shelf_region = shelf_->GetWindowBoundsInScreen(); | 992 gfx::Rect shelf_region = shelf_->GetWindowBoundsInScreen(); |
969 if (shelf_->status_area_widget() && | 993 if (shelf_->status_area_widget() && |
970 shelf_->status_area_widget()->IsMessageBubbleShown() && | 994 shelf_->status_area_widget()->IsMessageBubbleShown() && |
971 IsVisible()) { | 995 IsVisible()) { |
972 // Increase the the hit test area to prevent the shelf from disappearing | 996 // Increase the the hit test area to prevent the shelf from disappearing |
973 // when the mouse is over the bubble gap. | 997 // when the mouse is over the bubble gap. |
974 shelf_region.Inset(alignment_ == SHELF_ALIGNMENT_RIGHT ? | 998 shelf_region.Inset(alignment_ == SHELF_ALIGNMENT_RIGHT ? |
975 -kNotificationBubbleGapHeight : 0, | 999 -kNotificationBubbleGapHeight : 0, |
976 alignment_ == SHELF_ALIGNMENT_BOTTOM ? | 1000 alignment_ == SHELF_ALIGNMENT_BOTTOM ? |
977 -kNotificationBubbleGapHeight : 0, | 1001 -kNotificationBubbleGapHeight : 0, |
(...skipping 20 matching lines...) Expand all Loading... |
998 // shelf slightly to make it easier to show the shelf in this situation. We | 1022 // shelf slightly to make it easier to show the shelf in this situation. We |
999 // do not check |auto_hide_timer_|.IsRunning() because it returns false when | 1023 // do not check |auto_hide_timer_|.IsRunning() because it returns false when |
1000 // the timer's task is running. | 1024 // the timer's task is running. |
1001 if ((state_.auto_hide_state == SHELF_AUTO_HIDE_SHOWN || | 1025 if ((state_.auto_hide_state == SHELF_AUTO_HIDE_SHOWN || |
1002 mouse_over_shelf_when_auto_hide_timer_started_) && | 1026 mouse_over_shelf_when_auto_hide_timer_started_) && |
1003 GetAutoHideShowShelfRegionInScreen().Contains( | 1027 GetAutoHideShowShelfRegionInScreen().Contains( |
1004 cursor_position_in_screen)) { | 1028 cursor_position_in_screen)) { |
1005 return SHELF_AUTO_HIDE_SHOWN; | 1029 return SHELF_AUTO_HIDE_SHOWN; |
1006 } | 1030 } |
1007 | 1031 |
1008 const std::vector<aura::Window*> windows = | 1032 return SHELF_AUTO_HIDE_HIDDEN; |
1009 ash::MruWindowTracker::BuildWindowList(false); | |
1010 | |
1011 // Process the window list and check if there are any visible windows. | |
1012 for (size_t i = 0; i < windows.size(); ++i) { | |
1013 if (windows[i] && windows[i]->IsVisible() && | |
1014 !ash::wm::IsWindowMinimized(windows[i]) && | |
1015 root_window_ == windows[i]->GetRootWindow()) | |
1016 return SHELF_AUTO_HIDE_HIDDEN; | |
1017 } | |
1018 | |
1019 // If there are no visible windows do not hide the shelf. | |
1020 return SHELF_AUTO_HIDE_SHOWN; | |
1021 } | 1033 } |
1022 | 1034 |
1023 void ShelfLayoutManager::UpdateHitTestBounds() { | 1035 void ShelfLayoutManager::UpdateHitTestBounds() { |
1024 gfx::Insets mouse_insets; | 1036 gfx::Insets mouse_insets; |
1025 gfx::Insets touch_insets; | 1037 gfx::Insets touch_insets; |
1026 if (state_.visibility_state == SHELF_VISIBLE) { | 1038 if (state_.visibility_state == SHELF_VISIBLE) { |
1027 // Let clicks at the very top of the launcher through so windows can be | 1039 // Let clicks at the very top of the launcher through so windows can be |
1028 // resized with the bottom-right corner and bottom edge. | 1040 // resized with the bottom-right corner and bottom edge. |
1029 mouse_insets = GetInsetsForAlignment(kWorkspaceAreaVisibleInset); | 1041 mouse_insets = GetInsetsForAlignment(kWorkspaceAreaVisibleInset); |
1030 } else if (state_.visibility_state == SHELF_AUTO_HIDE) { | 1042 } else if (state_.visibility_state == SHELF_AUTO_HIDE) { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1086 return gfx::Insets(0, distance, 0, 0); | 1098 return gfx::Insets(0, distance, 0, 0); |
1087 case SHELF_ALIGNMENT_TOP: | 1099 case SHELF_ALIGNMENT_TOP: |
1088 return gfx::Insets(0, 0, distance, 0); | 1100 return gfx::Insets(0, 0, distance, 0); |
1089 } | 1101 } |
1090 NOTREACHED(); | 1102 NOTREACHED(); |
1091 return gfx::Insets(); | 1103 return gfx::Insets(); |
1092 } | 1104 } |
1093 | 1105 |
1094 } // namespace internal | 1106 } // namespace internal |
1095 } // namespace ash | 1107 } // namespace ash |
OLD | NEW |