Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ui/arc/notification/arc_custom_notification_view.h" | 5 #include "ui/arc/notification/arc_custom_notification_view.h" |
| 6 | 6 |
| 7 #include "components/exo/notification_surface.h" | 7 #include "components/exo/notification_surface.h" |
| 8 #include "components/exo/surface.h" | 8 #include "components/exo/surface.h" |
| 9 #include "third_party/skia/include/core/SkColor.h" | 9 #include "third_party/skia/include/core/SkColor.h" |
| 10 #include "ui/base/l10n/l10n_util.h" | 10 #include "ui/base/l10n/l10n_util.h" |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 33 // ui::EventHandler | 33 // ui::EventHandler |
| 34 void OnEvent(ui::Event* event) override { | 34 void OnEvent(ui::Event* event) override { |
| 35 // Do not forward event targeted to the floating close button so that | 35 // Do not forward event targeted to the floating close button so that |
| 36 // keyboard press and tap are handled properly. | 36 // keyboard press and tap are handled properly. |
| 37 if (owner_->floating_close_button_widget_ && event->target() && | 37 if (owner_->floating_close_button_widget_ && event->target() && |
| 38 owner_->floating_close_button_widget_->GetNativeWindow() == | 38 owner_->floating_close_button_widget_->GetNativeWindow() == |
| 39 event->target()) { | 39 event->target()) { |
| 40 return; | 40 return; |
| 41 } | 41 } |
| 42 | 42 |
| 43 owner_->OnEvent(event); | 43 if (event->IsScrollEvent()) |
| 44 ForwardScrollEvent(event->AsScrollEvent()); | |
| 45 else if (event->IsMouseWheelEvent()) | |
| 46 ForwardMouseWheelEvent(event->AsMouseWheelEvent()); | |
| 47 else if (!event->IsTouchEvent()) | |
|
yoshiki
2016/08/31 18:04:37
nit: as we discussed in chat, please add a comment
xiyuan
2016/08/31 18:08:23
Done.
| |
| 48 owner_->OnEvent(event); | |
| 49 } | |
| 50 | |
| 51 void ForwardScrollEvent(ui::ScrollEvent* event) { | |
| 52 views::Widget* widget = owner_->GetWidget(); | |
| 53 if (!widget) | |
| 54 return; | |
| 55 | |
| 56 event->target()->ConvertEventToTarget(widget->GetNativeWindow(), event); | |
| 57 widget->OnScrollEvent(event); | |
| 58 } | |
| 59 | |
| 60 void ForwardMouseWheelEvent(ui::MouseWheelEvent* event) { | |
| 61 views::Widget* widget = owner_->GetWidget(); | |
| 62 if (!widget) | |
| 63 return; | |
| 64 | |
| 65 event->target()->ConvertEventToTarget(widget->GetNativeWindow(), event); | |
| 66 widget->OnMouseEvent(event); | |
| 44 } | 67 } |
| 45 | 68 |
| 46 ArcCustomNotificationView* const owner_; | 69 ArcCustomNotificationView* const owner_; |
| 47 | 70 |
| 48 DISALLOW_COPY_AND_ASSIGN(EventForwarder); | 71 DISALLOW_COPY_AND_ASSIGN(EventForwarder); |
| 49 }; | 72 }; |
| 50 | 73 |
| 51 class ArcCustomNotificationView::SlideHelper | 74 class ArcCustomNotificationView::SlideHelper |
| 52 : public ui::LayerAnimationObserver { | 75 : public ui::LayerAnimationObserver { |
| 53 public: | 76 public: |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 319 } else if (!item_->pinned() && !floating_close_button_widget_) { | 342 } else if (!item_->pinned() && !floating_close_button_widget_) { |
| 320 CreateFloatingCloseButton(); | 343 CreateFloatingCloseButton(); |
| 321 } | 344 } |
| 322 } | 345 } |
| 323 | 346 |
| 324 void ArcCustomNotificationView::OnItemNotificationSurfaceRemoved() { | 347 void ArcCustomNotificationView::OnItemNotificationSurfaceRemoved() { |
| 325 SetSurface(nullptr); | 348 SetSurface(nullptr); |
| 326 } | 349 } |
| 327 | 350 |
| 328 } // namespace arc | 351 } // namespace arc |
| OLD | NEW |