Index: ash/system/tray/tray_background_view.cc |
diff --git a/ash/system/tray/tray_background_view.cc b/ash/system/tray/tray_background_view.cc |
index b19b137cfe596d95c38b415745a76a77af585508..aec12e1b7baec2910889dfa8f0062b8c711f73fb 100644 |
--- a/ash/system/tray/tray_background_view.cc |
+++ b/ash/system/tray/tray_background_view.cc |
@@ -16,7 +16,9 @@ |
#include "ash/system/tray/system_tray.h" |
#include "ash/system/tray/tray_constants.h" |
#include "ash/system/tray/tray_event_filter.h" |
+#include "ash/wm/maximize_mode/maximize_mode_controller.h" |
#include "ash/wm/window_animations.h" |
+#include "base/command_line.h" |
#include "grit/ash_resources.h" |
#include "ui/accessibility/ax_view_state.h" |
#include "ui/aura/window.h" |
@@ -25,6 +27,7 @@ |
#include "ui/compositor/layer.h" |
#include "ui/compositor/layer_animation_element.h" |
#include "ui/compositor/scoped_layer_animation_settings.h" |
+#include "ui/events/event_constants.h" |
#include "ui/gfx/animation/tween.h" |
#include "ui/gfx/canvas.h" |
#include "ui/gfx/image/image_skia.h" |
@@ -308,6 +311,7 @@ TrayBackgroundView::TrayBackgroundView(StatusAreaWidget* status_area_widget) |
kTrayBackgroundHoverAlpha - kTrayBackgroundAlpha), |
hovered_(false), |
draw_background_as_active_(false), |
+ touch_feedback_enabled_(false), |
widget_observer_(new TrayWidgetObserver(this)) { |
set_notify_enter_exit_on_child(true); |
@@ -325,11 +329,20 @@ TrayBackgroundView::TrayBackgroundView(StatusAreaWidget* status_area_widget) |
SetFillsBoundsOpaquely(false); |
// Start the tray items not visible, because visibility changes are animated. |
views::View::SetVisible(false); |
+ |
+ Shell* shell = Shell::GetInstance(); |
+ shell->AddShellObserver(this); |
+ if (shell->maximize_mode_controller()->IsMaximizeModeWindowManagerEnabled() && |
+ CommandLine::ForCurrentProcess()-> |
+ HasSwitch(switches::kAshEnableTouchViewTouchFeedback)) { |
+ touch_feedback_enabled_ = true; |
+ } |
} |
TrayBackgroundView::~TrayBackgroundView() { |
if (GetWidget()) |
GetWidget()->RemoveObserver(widget_observer_.get()); |
+ Shell::GetInstance()->RemoveShellObserver(this); |
} |
void TrayBackgroundView::Initialize() { |
@@ -426,6 +439,26 @@ gfx::Rect TrayBackgroundView::GetFocusBounds() { |
return GetContentsBounds(); |
} |
+void TrayBackgroundView::OnGestureEvent(ui::GestureEvent* event) { |
+ if (touch_feedback_enabled_) { |
+ switch (event->type()) { |
flackr
2014/08/29 15:34:10
For so few cases an if / else if is probably clean
jonross
2014/08/29 17:20:21
Done.
|
+ case ui::ET_GESTURE_TAP_DOWN: { |
+ SetDrawBackgroundAsActive(true); |
+ break; |
+ } |
+ case ui::ET_GESTURE_SCROLL_BEGIN: |
+ case ui::ET_GESTURE_TAP_CANCEL: { |
flackr
2014/08/29 15:34:10
Do you need ET_GESTURE_TAP as well to restore the
jonross
2014/08/29 17:20:21
Currently when you touch these icons they are only
|
+ SetDrawBackgroundAsActive(false); |
+ break; |
+ } |
+ default: { |
+ // No action |
+ } |
+ } |
+ } |
+ ActionableView::OnGestureEvent(event); |
+} |
+ |
void TrayBackgroundView::UpdateBackground(int alpha) { |
// The animator should never fire when the alternate shelf layout is used. |
if (!background_ || draw_background_as_active_) |
@@ -435,6 +468,15 @@ void TrayBackgroundView::UpdateBackground(int alpha) { |
SchedulePaint(); |
} |
+void TrayBackgroundView::OnMaximizeModeStarted() { |
+ touch_feedback_enabled_ = CommandLine::ForCurrentProcess()-> |
+ HasSwitch(switches::kAshEnableTouchViewTouchFeedback); |
+} |
+ |
+void TrayBackgroundView::OnMaximizeModeEnded() { |
+ touch_feedback_enabled_ = false; |
+} |
+ |
void TrayBackgroundView::SetContents(views::View* contents) { |
SetLayoutManager(new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); |
AddChildView(contents); |
@@ -628,6 +670,8 @@ TrayBubbleView::AnchorAlignment TrayBackgroundView::GetAnchorAlignment() const { |
} |
void TrayBackgroundView::SetDrawBackgroundAsActive(bool visible) { |
+ if (draw_background_as_active_ == visible) |
+ return; |
draw_background_as_active_ = visible; |
if (!background_) |
return; |