| 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..dc549c85fc712be1c63d9d0c0ae4b78c29fc2785 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,86 @@ 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) const;
|
| +
|
| + 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) const{
|
| + 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;
|
| + }
|
| + return false;
|
| +}
|
| +
|
| // ShelfLayoutManager:UpdateShelfObserver --------------------------------------
|
|
|
| // UpdateShelfObserver is used to delay updating the background until the
|
| @@ -172,6 +258,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 +654,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 +961,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();
|
|
|