| 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> |
| 10 #include <string> |
| 11 #include <vector> |
| 9 | 12 |
| 10 #include "ash/ash_switches.h" | 13 #include "ash/ash_switches.h" |
| 11 #include "ash/launcher/launcher.h" | 14 #include "ash/launcher/launcher.h" |
| 12 #include "ash/launcher/launcher_types.h" | 15 #include "ash/launcher/launcher_types.h" |
| 13 #include "ash/root_window_controller.h" | 16 #include "ash/root_window_controller.h" |
| 14 #include "ash/screen_ash.h" | 17 #include "ash/screen_ash.h" |
| 15 #include "ash/session_state_delegate.h" | 18 #include "ash/session_state_delegate.h" |
| 19 #include "ash/shelf/shelf_bezel_event_filter.h" |
| 16 #include "ash/shelf/shelf_layout_manager_observer.h" | 20 #include "ash/shelf/shelf_layout_manager_observer.h" |
| 17 #include "ash/shelf/shelf_widget.h" | 21 #include "ash/shelf/shelf_widget.h" |
| 18 #include "ash/shell.h" | 22 #include "ash/shell.h" |
| 19 #include "ash/shell_window_ids.h" | 23 #include "ash/shell_window_ids.h" |
| 20 #include "ash/system/status_area_widget.h" | 24 #include "ash/system/status_area_widget.h" |
| 21 #include "ash/wm/gestures/shelf_gesture_handler.h" | 25 #include "ash/wm/gestures/shelf_gesture_handler.h" |
| 22 #include "ash/wm/property_util.h" | 26 #include "ash/wm/property_util.h" |
| 23 #include "ash/wm/window_cycle_controller.h" | 27 #include "ash/wm/window_cycle_controller.h" |
| 24 #include "ash/wm/window_properties.h" | 28 #include "ash/wm/window_properties.h" |
| 25 #include "ash/wm/window_util.h" | 29 #include "ash/wm/window_util.h" |
| 30 #include "ash/wm/workspace/workspace_animations.h" |
| 26 #include "ash/wm/workspace_controller.h" | 31 #include "ash/wm/workspace_controller.h" |
| 27 #include "ash/wm/workspace/workspace_animations.h" | |
| 28 #include "base/auto_reset.h" | 32 #include "base/auto_reset.h" |
| 29 #include "base/command_line.h" | 33 #include "base/command_line.h" |
| 34 #include "base/command_line.h" |
| 30 #include "base/i18n/rtl.h" | 35 #include "base/i18n/rtl.h" |
| 36 #include "base/string_number_conversions.h" |
| 37 #include "base/string_util.h" |
| 31 #include "ui/aura/client/activation_client.h" | 38 #include "ui/aura/client/activation_client.h" |
| 32 #include "ui/aura/root_window.h" | 39 #include "ui/aura/root_window.h" |
| 33 #include "ui/base/events/event.h" | 40 #include "ui/base/events/event.h" |
| 34 #include "ui/base/events/event_handler.h" | 41 #include "ui/base/events/event_handler.h" |
| 42 #include "ui/base/ui_base_switches.h" |
| 35 #include "ui/compositor/layer.h" | 43 #include "ui/compositor/layer.h" |
| 36 #include "ui/compositor/layer_animation_observer.h" | 44 #include "ui/compositor/layer_animation_observer.h" |
| 37 #include "ui/compositor/layer_animator.h" | 45 #include "ui/compositor/layer_animator.h" |
| 38 #include "ui/compositor/scoped_layer_animation_settings.h" | 46 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 39 #include "ui/gfx/screen.h" | 47 #include "ui/gfx/screen.h" |
| 40 #include "ui/views/widget/widget.h" | 48 #include "ui/views/widget/widget.h" |
| 41 | 49 |
| 42 namespace ash { | 50 namespace ash { |
| 43 namespace internal { | 51 namespace internal { |
| 44 | 52 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 bool in_mouse_drag() const { return in_mouse_drag_; } | 93 bool in_mouse_drag() const { return in_mouse_drag_; } |
| 86 | 94 |
| 87 // Overridden from ui::EventHandler: | 95 // Overridden from ui::EventHandler: |
| 88 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE; | 96 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE; |
| 89 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; | 97 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; |
| 90 | 98 |
| 91 private: | 99 private: |
| 92 ShelfLayoutManager* shelf_; | 100 ShelfLayoutManager* shelf_; |
| 93 bool in_mouse_drag_; | 101 bool in_mouse_drag_; |
| 94 ShelfGestureHandler gesture_handler_; | 102 ShelfGestureHandler gesture_handler_; |
| 95 | |
| 96 DISALLOW_COPY_AND_ASSIGN(AutoHideEventFilter); | 103 DISALLOW_COPY_AND_ASSIGN(AutoHideEventFilter); |
| 97 }; | 104 }; |
| 98 | 105 |
| 99 ShelfLayoutManager::AutoHideEventFilter::AutoHideEventFilter( | 106 ShelfLayoutManager::AutoHideEventFilter::AutoHideEventFilter( |
| 100 ShelfLayoutManager* shelf) | 107 ShelfLayoutManager* shelf) |
| 101 : shelf_(shelf), | 108 : shelf_(shelf), |
| 102 in_mouse_drag_(false) { | 109 in_mouse_drag_(false) { |
| 103 Shell::GetInstance()->AddPreTargetHandler(this); | 110 Shell::GetInstance()->AddPreTargetHandler(this); |
| 104 } | 111 } |
| 105 | 112 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 165 // ShelfLayoutManager ---------------------------------------------------------- | 172 // ShelfLayoutManager ---------------------------------------------------------- |
| 166 | 173 |
| 167 ShelfLayoutManager::ShelfLayoutManager(ShelfWidget* shelf) | 174 ShelfLayoutManager::ShelfLayoutManager(ShelfWidget* shelf) |
| 168 : root_window_(shelf->GetNativeView()->GetRootWindow()), | 175 : root_window_(shelf->GetNativeView()->GetRootWindow()), |
| 169 in_layout_(false), | 176 in_layout_(false), |
| 170 auto_hide_behavior_(SHELF_AUTO_HIDE_BEHAVIOR_NEVER), | 177 auto_hide_behavior_(SHELF_AUTO_HIDE_BEHAVIOR_NEVER), |
| 171 alignment_(SHELF_ALIGNMENT_BOTTOM), | 178 alignment_(SHELF_ALIGNMENT_BOTTOM), |
| 172 shelf_(shelf), | 179 shelf_(shelf), |
| 173 workspace_controller_(NULL), | 180 workspace_controller_(NULL), |
| 174 window_overlaps_shelf_(false), | 181 window_overlaps_shelf_(false), |
| 182 bezel_event_filter_(new ShelfBezelEventFilter(this)), |
| 175 gesture_drag_status_(GESTURE_DRAG_NONE), | 183 gesture_drag_status_(GESTURE_DRAG_NONE), |
| 176 gesture_drag_amount_(0.f), | 184 gesture_drag_amount_(0.f), |
| 177 gesture_drag_auto_hide_state_(SHELF_AUTO_HIDE_SHOWN), | 185 gesture_drag_auto_hide_state_(SHELF_AUTO_HIDE_SHOWN), |
| 178 update_shelf_observer_(NULL) { | 186 update_shelf_observer_(NULL) { |
| 179 Shell::GetInstance()->AddShellObserver(this); | 187 Shell::GetInstance()->AddShellObserver(this); |
| 180 aura::client::GetActivationClient(root_window_)->AddObserver(this); | 188 aura::client::GetActivationClient(root_window_)->AddObserver(this); |
| 181 } | 189 } |
| 182 | 190 |
| 183 ShelfLayoutManager::~ShelfLayoutManager() { | 191 ShelfLayoutManager::~ShelfLayoutManager() { |
| 184 if (update_shelf_observer_) | 192 if (update_shelf_observer_) |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 | 568 |
| 561 if (state_.Equals(state)) | 569 if (state_.Equals(state)) |
| 562 return; // Nothing changed. | 570 return; // Nothing changed. |
| 563 | 571 |
| 564 FOR_EACH_OBSERVER(ShelfLayoutManagerObserver, observers_, | 572 FOR_EACH_OBSERVER(ShelfLayoutManagerObserver, observers_, |
| 565 WillChangeVisibilityState(visibility_state)); | 573 WillChangeVisibilityState(visibility_state)); |
| 566 | 574 |
| 567 if (state.visibility_state == SHELF_AUTO_HIDE) { | 575 if (state.visibility_state == SHELF_AUTO_HIDE) { |
| 568 // When state is SHELF_AUTO_HIDE we need to track when the mouse is over the | 576 // When state is SHELF_AUTO_HIDE we need to track when the mouse is over the |
| 569 // launcher to unhide the shelf. AutoHideEventFilter does that for us. | 577 // launcher to unhide the shelf. AutoHideEventFilter does that for us. |
| 570 if (!event_filter_) | 578 if (!auto_hide_event_filter_) |
| 571 event_filter_.reset(new AutoHideEventFilter(this)); | 579 auto_hide_event_filter_.reset(new AutoHideEventFilter(this)); |
| 572 } else { | 580 } else { |
| 573 event_filter_.reset(NULL); | 581 auto_hide_event_filter_.reset(NULL); |
| 574 } | 582 } |
| 575 | 583 |
| 576 auto_hide_timer_.Stop(); | 584 auto_hide_timer_.Stop(); |
| 577 | 585 |
| 578 // Animating the background when transitioning from auto-hide & hidden to | 586 // Animating the background when transitioning from auto-hide & hidden to |
| 579 // visible is janky. Update the background immediately in this case. | 587 // visible is janky. Update the background immediately in this case. |
| 580 BackgroundAnimator::ChangeType change_type = | 588 BackgroundAnimator::ChangeType change_type = |
| 581 (state_.visibility_state == SHELF_AUTO_HIDE && | 589 (state_.visibility_state == SHELF_AUTO_HIDE && |
| 582 state_.auto_hide_state == SHELF_AUTO_HIDE_HIDDEN && | 590 state_.auto_hide_state == SHELF_AUTO_HIDE_HIDDEN && |
| 583 state.visibility_state == SHELF_VISIBLE) ? | 591 state.visibility_state == SHELF_VISIBLE) ? |
| (...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 867 if (shelf_->launcher() && shelf_->launcher()->IsShowingMenu()) | 875 if (shelf_->launcher() && shelf_->launcher()->IsShowingMenu()) |
| 868 return SHELF_AUTO_HIDE_SHOWN; | 876 return SHELF_AUTO_HIDE_SHOWN; |
| 869 | 877 |
| 870 if (shelf_->launcher() && shelf_->launcher()->IsShowingOverflowBubble()) | 878 if (shelf_->launcher() && shelf_->launcher()->IsShowingOverflowBubble()) |
| 871 return SHELF_AUTO_HIDE_SHOWN; | 879 return SHELF_AUTO_HIDE_SHOWN; |
| 872 | 880 |
| 873 if (shelf_->IsActive() || shelf_->status_area_widget()->IsActive()) | 881 if (shelf_->IsActive() || shelf_->status_area_widget()->IsActive()) |
| 874 return SHELF_AUTO_HIDE_SHOWN; | 882 return SHELF_AUTO_HIDE_SHOWN; |
| 875 | 883 |
| 876 // Don't show if the user is dragging the mouse. | 884 // Don't show if the user is dragging the mouse. |
| 877 if (event_filter_.get() && event_filter_->in_mouse_drag()) | 885 if (auto_hide_event_filter_.get() && auto_hide_event_filter_->in_mouse_drag()) |
| 878 return SHELF_AUTO_HIDE_HIDDEN; | 886 return SHELF_AUTO_HIDE_HIDDEN; |
| 879 | 887 |
| 880 gfx::Rect shelf_region = shelf_->GetWindowBoundsInScreen(); | 888 gfx::Rect shelf_region = shelf_->GetWindowBoundsInScreen(); |
| 881 if (shelf_->status_area_widget() && | 889 if (shelf_->status_area_widget() && |
| 882 shelf_->status_area_widget()->IsMessageBubbleShown() && | 890 shelf_->status_area_widget()->IsMessageBubbleShown() && |
| 883 IsVisible()) { | 891 IsVisible()) { |
| 884 // Increase the the hit test area to prevent the shelf from disappearing | 892 // Increase the the hit test area to prevent the shelf from disappearing |
| 885 // when the mouse is over the bubble gap. | 893 // when the mouse is over the bubble gap. |
| 886 shelf_region.Inset(alignment_ == SHELF_ALIGNMENT_RIGHT ? | 894 shelf_region.Inset(alignment_ == SHELF_ALIGNMENT_RIGHT ? |
| 887 -kNotificationBubbleGapHeight : 0, | 895 -kNotificationBubbleGapHeight : 0, |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 969 return gfx::Insets(0, distance, 0, 0); | 977 return gfx::Insets(0, distance, 0, 0); |
| 970 case SHELF_ALIGNMENT_TOP: | 978 case SHELF_ALIGNMENT_TOP: |
| 971 return gfx::Insets(0, 0, distance, 0); | 979 return gfx::Insets(0, 0, distance, 0); |
| 972 } | 980 } |
| 973 NOTREACHED(); | 981 NOTREACHED(); |
| 974 return gfx::Insets(); | 982 return gfx::Insets(); |
| 975 } | 983 } |
| 976 | 984 |
| 977 } // namespace internal | 985 } // namespace internal |
| 978 } // namespace ash | 986 } // namespace ash |
| OLD | NEW |