| 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/gestures/shelf_gesture_handler.h" | 5 #include "ash/wm/gestures/shelf_gesture_handler.h" |
| 6 | 6 |
| 7 #include "ash/root_window_controller.h" | 7 #include "ash/root_window_controller.h" |
| 8 #include "ash/shelf_types.h" | 8 #include "ash/shelf/shelf_layout_manager.h" |
| 9 #include "ash/shelf/shelf_types.h" |
| 10 #include "ash/shelf/shelf_widget.h" |
| 9 #include "ash/shell.h" | 11 #include "ash/shell.h" |
| 10 #include "ash/shell_delegate.h" | 12 #include "ash/shell_delegate.h" |
| 11 #include "ash/system/status_area_widget.h" | 13 #include "ash/system/status_area_widget.h" |
| 12 #include "ash/wm/gestures/tray_gesture_handler.h" | 14 #include "ash/wm/gestures/tray_gesture_handler.h" |
| 13 #include "ash/wm/shelf_layout_manager.h" | |
| 14 #include "ash/wm/window_util.h" | 15 #include "ash/wm/window_util.h" |
| 15 #include "ui/aura/window.h" | 16 #include "ui/aura/window.h" |
| 16 #include "ui/compositor/layer.h" | 17 #include "ui/compositor/layer.h" |
| 17 #include "ui/compositor/scoped_layer_animation_settings.h" | 18 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 18 #include "ui/gfx/transform.h" | 19 #include "ui/gfx/transform.h" |
| 19 #include "ui/views/widget/widget.h" | 20 #include "ui/views/widget/widget.h" |
| 20 | 21 |
| 21 namespace { | 22 namespace { |
| 22 | 23 |
| 23 // A ShelfResetHandler auto-hides the shelf as soon as the user interacts with | 24 // A ShelfResetHandler auto-hides the shelf as soon as the user interacts with |
| (...skipping 14 matching lines...) Expand all Loading... |
| 38 shelf_->RemoveObserver(this); | 39 shelf_->RemoveObserver(this); |
| 39 } | 40 } |
| 40 | 41 |
| 41 void ResetShelfState() { | 42 void ResetShelfState() { |
| 42 shelf_->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 43 shelf_->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
| 43 delete this; | 44 delete this; |
| 44 } | 45 } |
| 45 | 46 |
| 46 bool ShelfIsEventTarget(const ui::Event& event) { | 47 bool ShelfIsEventTarget(const ui::Event& event) { |
| 47 aura::Window* target = static_cast<aura::Window*>(event.target()); | 48 aura::Window* target = static_cast<aura::Window*>(event.target()); |
| 48 views::Widget* widget = shelf_->launcher_widget(); | 49 views::Widget* widget = shelf_->shelf_widget(); |
| 49 if (widget && widget->GetNativeWindow() == target) | 50 if (widget && widget->GetNativeWindow() == target) |
| 50 return true; | 51 return true; |
| 51 widget = shelf_->status_area_widget(); | 52 widget = shelf_->shelf_widget()->status_area_widget(); |
| 52 if (widget && widget->GetNativeWindow() == target) | 53 if (widget && widget->GetNativeWindow() == target) |
| 53 return true; | 54 return true; |
| 54 return false; | 55 return false; |
| 55 } | 56 } |
| 56 | 57 |
| 57 void DecideShelfVisibility(const gfx::Point& location) { | 58 void DecideShelfVisibility(const gfx::Point& location) { |
| 58 // For the rest of the mouse events, ignore if the event happens inside the | 59 // For the rest of the mouse events, ignore if the event happens inside the |
| 59 // shelf. | 60 // shelf. |
| 60 views::Widget* widget = shelf_->launcher_widget(); | 61 views::Widget* widget = shelf_->shelf_widget(); |
| 61 if (widget && | 62 if (widget && |
| 62 widget->GetWindowBoundsInScreen().Contains(location)) { | 63 widget->GetWindowBoundsInScreen().Contains(location)) { |
| 63 return; | 64 return; |
| 64 } | 65 } |
| 65 | 66 |
| 66 widget = shelf_->status_area_widget(); | 67 widget = shelf_->shelf_widget()->status_area_widget(); |
| 67 if (widget && | 68 if (widget && |
| 68 widget->GetWindowBoundsInScreen().Contains(location)) { | 69 widget->GetWindowBoundsInScreen().Contains(location)) { |
| 69 return; | 70 return; |
| 70 } | 71 } |
| 71 | 72 |
| 72 ResetShelfState(); | 73 ResetShelfState(); |
| 73 } | 74 } |
| 74 | 75 |
| 75 // Overridden from ui::EventHandler: | 76 // Overridden from ui::EventHandler: |
| 76 virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE { | 77 virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 // The gestures are disabled in the lock/login screen. | 126 // The gestures are disabled in the lock/login screen. |
| 126 return false; | 127 return false; |
| 127 } | 128 } |
| 128 | 129 |
| 129 // The gesture are disabled for fullscreen windows. | 130 // The gesture are disabled for fullscreen windows. |
| 130 aura::Window* active = wm::GetActiveWindow(); | 131 aura::Window* active = wm::GetActiveWindow(); |
| 131 if (active && wm::IsWindowFullscreen(active)) | 132 if (active && wm::IsWindowFullscreen(active)) |
| 132 return false; | 133 return false; |
| 133 | 134 |
| 134 // TODO(oshima): Find the root window controller from event's location. | 135 // TODO(oshima): Find the root window controller from event's location. |
| 135 ShelfLayoutManager* shelf = Shell::GetPrimaryRootWindowController()->shelf(); | 136 ShelfLayoutManager* shelf = |
| 137 Shell::GetPrimaryRootWindowController()->shelf_layout_manager(); |
| 136 if (event.type() == ui::ET_GESTURE_SCROLL_BEGIN) { | 138 if (event.type() == ui::ET_GESTURE_SCROLL_BEGIN) { |
| 137 drag_in_progress_ = true; | 139 drag_in_progress_ = true; |
| 138 shelf->StartGestureDrag(event); | 140 shelf->StartGestureDrag(event); |
| 139 return true; | 141 return true; |
| 140 } | 142 } |
| 141 | 143 |
| 142 if (!drag_in_progress_) | 144 if (!drag_in_progress_) |
| 143 return false; | 145 return false; |
| 144 | 146 |
| 145 if (event.type() == ui::ET_GESTURE_SCROLL_UPDATE) { | 147 if (event.type() == ui::ET_GESTURE_SCROLL_UPDATE) { |
| (...skipping 25 matching lines...) Expand all Loading... |
| 171 return true; | 173 return true; |
| 172 } | 174 } |
| 173 | 175 |
| 174 // Unexpected event. Reset the state and let the event fall through. | 176 // Unexpected event. Reset the state and let the event fall through. |
| 175 shelf->CancelGestureDrag(); | 177 shelf->CancelGestureDrag(); |
| 176 return false; | 178 return false; |
| 177 } | 179 } |
| 178 | 180 |
| 179 } // namespace internal | 181 } // namespace internal |
| 180 } // namespace ash | 182 } // namespace ash |
| OLD | NEW |