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

Unified Diff: ash/shelf/shelf_layout_manager.cc

Issue 15931005: Move bezel event routing for the shelf into ShelfLayoutManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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.h ('k') | ash/shelf/shelf_layout_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/shelf/shelf_layout_manager.cc
diff --git a/ash/shelf/shelf_layout_manager.cc b/ash/shelf/shelf_layout_manager.cc
index cf3e9b3af311d655e13463e352ec482d084d9474..fc25a94447e7dfa1e791a05658afbfcf17b4c08b 100644
--- a/ash/shelf/shelf_layout_manager.cc
+++ b/ash/shelf/shelf_layout_manager.cc
@@ -6,6 +6,9 @@
#include <algorithm>
#include <cmath>
+#include <cstring>
+#include <string>
+#include <vector>
#include "ash/ash_switches.h"
#include "ash/launcher/launcher.h"
@@ -23,15 +26,19 @@
#include "ash/wm/window_cycle_controller.h"
#include "ash/wm/window_properties.h"
#include "ash/wm/window_util.h"
-#include "ash/wm/workspace_controller.h"
#include "ash/wm/workspace/workspace_animations.h"
+#include "ash/wm/workspace_controller.h"
#include "base/auto_reset.h"
#include "base/command_line.h"
+#include "base/command_line.h"
#include "base/i18n/rtl.h"
+#include "base/string_number_conversions.h"
+#include "base/string_util.h"
#include "ui/aura/client/activation_client.h"
#include "ui/aura/root_window.h"
#include "ui/base/events/event.h"
#include "ui/base/events/event_handler.h"
+#include "ui/base/ui_base_switches.h"
#include "ui/compositor/layer.h"
#include "ui/compositor/layer_animation_observer.h"
#include "ui/compositor/layer_animator.h"
@@ -92,7 +99,6 @@ class ShelfLayoutManager::AutoHideEventFilter : public ui::EventHandler {
ShelfLayoutManager* shelf_;
bool in_mouse_drag_;
ShelfGestureHandler gesture_handler_;
-
DISALLOW_COPY_AND_ASSIGN(AutoHideEventFilter);
};
@@ -128,6 +134,88 @@ void ShelfLayoutManager::AutoHideEventFilter::OnGestureEvent(
}
}
+// ShelfLayoutManager::BezelEventFilter -------------------------------------
+
+// Notifies ShelfLayoutManager any time the mouse moves.
+class ShelfLayoutManager::BezelEventFilter : public ui::EventHandler {
+ public:
+ explicit BezelEventFilter(ShelfLayoutManager* shelf);
+ virtual ~BezelEventFilter();
+
+ // Overridden from ui::EventHandler:
+ virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE;
+
+ private:
+ bool IsShelfOnBezel(const gfx::Rect& screen,
+ const gfx::Point& point);
sadrul 2013/05/31 14:40:38 const method
rharrison 2013/05/31 15:15:46 Done.
+
+ ShelfLayoutManager* shelf_; // non-owned
+ bool in_touch_drag_;
+ ShelfGestureHandler gesture_handler_;
+ DISALLOW_COPY_AND_ASSIGN(BezelEventFilter);
+};
+
+ShelfLayoutManager::BezelEventFilter::BezelEventFilter(
+ ShelfLayoutManager* shelf)
+ : shelf_(shelf),
+ in_touch_drag_(false) {
+ Shell::GetInstance()->AddPreTargetHandler(this);
+}
+
+ShelfLayoutManager::BezelEventFilter::~BezelEventFilter() {
+ Shell::GetInstance()->RemovePreTargetHandler(this);
+}
+
+void ShelfLayoutManager::BezelEventFilter::OnGestureEvent(
+ ui::GestureEvent* event) {
+ gfx::Rect screen =
+ Shell::GetScreen()->GetDisplayNearestPoint(event->location()).bounds();
+ if ((!screen.Contains(event->location()) &&
+ IsShelfOnBezel(screen, event->location())) ||
+ in_touch_drag_) {
+ if (gesture_handler_.ProcessGestureEvent(*event)) {
+ switch (event->type()) {
+ case ui::ET_GESTURE_SCROLL_BEGIN:
+ in_touch_drag_ = true;
+ break;
+ case ui::ET_GESTURE_SCROLL_END:
+ case ui::ET_SCROLL_FLING_START:
+ in_touch_drag_ = false;
+ break;
+ default:
+ break;
+ }
+ event->StopPropagation();
+ }
+ }
+}
+
+bool ShelfLayoutManager::BezelEventFilter::IsShelfOnBezel(
+ const gfx::Rect& screen,
+ const gfx::Point& point) {
+ switch (shelf_->GetAlignment()) {
+ case SHELF_ALIGNMENT_BOTTOM:
+ if (point.y() >= screen.bottom())
+ return true;
+ break;
+ case SHELF_ALIGNMENT_LEFT:
+ if (point.x() <= screen.x())
+ return true;
+ break;
+ case SHELF_ALIGNMENT_TOP:
+ if (point.y() <= screen.y())
+ return true;
+ break;
+ case SHELF_ALIGNMENT_RIGHT:
+ if (point.x() >= screen.right())
+ return true;
+ break;
+ default:
sadrul 2013/05/31 14:40:38 remove default
rharrison 2013/05/31 15:15:46 Done.
+ break;
+ }
+ return false;
+}
+
// ShelfLayoutManager:UpdateShelfObserver --------------------------------------
// UpdateShelfObserver is used to delay updating the background until the
@@ -172,6 +260,7 @@ ShelfLayoutManager::ShelfLayoutManager(ShelfWidget* shelf)
shelf_(shelf),
workspace_controller_(NULL),
window_overlaps_shelf_(false),
+ bezel_event_filter_(new BezelEventFilter(this)),
gesture_drag_status_(GESTURE_DRAG_NONE),
gesture_drag_amount_(0.f),
gesture_drag_auto_hide_state_(SHELF_AUTO_HIDE_SHOWN),
@@ -567,10 +656,10 @@ void ShelfLayoutManager::SetState(ShelfVisibilityState visibility_state) {
if (state.visibility_state == SHELF_AUTO_HIDE) {
// When state is SHELF_AUTO_HIDE we need to track when the mouse is over the
// launcher to unhide the shelf. AutoHideEventFilter does that for us.
- if (!event_filter_)
- event_filter_.reset(new AutoHideEventFilter(this));
+ if (!auto_hide_event_filter_)
+ auto_hide_event_filter_.reset(new AutoHideEventFilter(this));
} else {
- event_filter_.reset(NULL);
+ auto_hide_event_filter_.reset(NULL);
}
auto_hide_timer_.Stop();
@@ -874,7 +963,7 @@ ShelfAutoHideState ShelfLayoutManager::CalculateAutoHideState(
return SHELF_AUTO_HIDE_SHOWN;
// Don't show if the user is dragging the mouse.
- if (event_filter_.get() && event_filter_->in_mouse_drag())
+ if (auto_hide_event_filter_.get() && auto_hide_event_filter_->in_mouse_drag())
return SHELF_AUTO_HIDE_HIDDEN;
gfx::Rect shelf_region = shelf_->GetWindowBoundsInScreen();
« no previous file with comments | « ash/shelf/shelf_layout_manager.h ('k') | ash/shelf/shelf_layout_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698