Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2481)

Unified Diff: ash/wm/gestures/shelf_gesture_handler.cc

Issue 13674020: ash: Stop hiding the shelf on user-action after it was shown using gesture drag. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ash/shelf/shelf_layout_manager_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/wm/gestures/shelf_gesture_handler.cc
diff --git a/ash/wm/gestures/shelf_gesture_handler.cc b/ash/wm/gestures/shelf_gesture_handler.cc
index d000eb5a727e15f9526c455755f42f13edb4f6d3..a4e8737468c556e7a6128b384807c0545418353e 100644
--- a/ash/wm/gestures/shelf_gesture_handler.cc
+++ b/ash/wm/gestures/shelf_gesture_handler.cc
@@ -19,96 +19,6 @@
#include "ui/gfx/transform.h"
#include "ui/views/widget/widget.h"
-namespace {
-
-// A ShelfResetHandler auto-hides the shelf as soon as the user interacts with
-// any non-shelf part of the system. The ShelfResetHandler manages its own
-// lifetime.
-class ShelfResetHandler : public ui::EventHandler,
- public ash::internal::ShelfLayoutManager::Observer {
- public:
- explicit ShelfResetHandler(ash::internal::ShelfLayoutManager* shelf)
- : shelf_(shelf) {
- shelf_->AddObserver(this);
- ash::Shell::GetInstance()->AddPreTargetHandler(this);
- }
-
- private:
- virtual ~ShelfResetHandler() {
- ash::Shell::GetInstance()->RemovePreTargetHandler(this);
- shelf_->RemoveObserver(this);
- }
-
- void ResetShelfState() {
- shelf_->SetAutoHideBehavior(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
- delete this;
- }
-
- bool ShelfIsEventTarget(const ui::Event& event) {
- aura::Window* target = static_cast<aura::Window*>(event.target());
- views::Widget* widget = shelf_->shelf_widget();
- if (widget && widget->GetNativeWindow() == target)
- return true;
- widget = shelf_->shelf_widget()->status_area_widget();
- if (widget && widget->GetNativeWindow() == target)
- return true;
- return false;
- }
-
- void DecideShelfVisibility(const gfx::Point& location) {
- // For the rest of the mouse events, ignore if the event happens inside the
- // shelf.
- views::Widget* widget = shelf_->shelf_widget();
- if (widget &&
- widget->GetWindowBoundsInScreen().Contains(location)) {
- return;
- }
-
- widget = shelf_->shelf_widget()->status_area_widget();
- if (widget &&
- widget->GetWindowBoundsInScreen().Contains(location)) {
- return;
- }
-
- ResetShelfState();
- }
-
- // Overridden from ui::EventHandler:
- virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE {
- if (!ShelfIsEventTarget(*event))
- ResetShelfState();
- }
-
- virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE {
- // Ignore all mouse move events.
- if (event->type() == ui::ET_MOUSE_PRESSED ||
- event->type() == ui::ET_MOUSE_RELEASED) {
- DecideShelfVisibility(event->root_location());
- }
- }
-
- virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE {
- if (!ShelfIsEventTarget(*event))
- DecideShelfVisibility(event->root_location());
- }
-
- virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE {
- if (!ShelfIsEventTarget(*event))
- DecideShelfVisibility(event->root_location());
- }
-
- // Overridden from ash::internal::ShelfLayoutManager::Observer:
- virtual void WillDeleteShelf() OVERRIDE {
- delete this;
- }
-
- ash::internal::ShelfLayoutManager* shelf_;
-
- DISALLOW_COPY_AND_ASSIGN(ShelfResetHandler);
-};
-
-} // namespace
-
namespace ash {
namespace internal {
@@ -165,11 +75,7 @@ bool ShelfGestureHandler::ProcessGestureEvent(const ui::GestureEvent& event) {
tray_handler_.reset();
}
- ShelfVisibilityState old_state = shelf->visibility_state();
shelf->CompleteGestureDrag(event);
- ShelfVisibilityState new_state = shelf->visibility_state();
- if (new_state != old_state && new_state == SHELF_VISIBLE)
- new ShelfResetHandler(shelf);
return true;
}
« no previous file with comments | « ash/shelf/shelf_layout_manager_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698