Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/desktop_background/desktop_background_view.h" | 5 #include "ash/desktop_background/desktop_background_view.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "ash/ash_export.h" | 9 #include "ash/ash_export.h" |
| 10 #include "ash/desktop_background/desktop_background_controller.h" | 10 #include "ash/desktop_background/desktop_background_controller.h" |
| 11 #include "ash/desktop_background/desktop_background_widget_controller.h" | 11 #include "ash/desktop_background/desktop_background_widget_controller.h" |
| 12 #include "ash/desktop_background/user_wallpaper_delegate.h" | 12 #include "ash/desktop_background/user_wallpaper_delegate.h" |
| 13 #include "ash/display/display_manager.h" | 13 #include "ash/display/display_manager.h" |
| 14 #include "ash/root_window_controller.h" | 14 #include "ash/root_window_controller.h" |
| 15 #include "ash/session/session_state_delegate.h" | 15 #include "ash/session/session_state_delegate.h" |
| 16 #include "ash/shell.h" | 16 #include "ash/shell.h" |
| 17 #include "ash/shell_window_ids.h" | 17 #include "ash/shell_window_ids.h" |
| 18 #include "ash/wm/overview/window_selector_controller.h" | |
| 18 #include "ash/wm/window_animations.h" | 19 #include "ash/wm/window_animations.h" |
| 19 #include "base/message_loop/message_loop.h" | 20 #include "base/message_loop/message_loop.h" |
| 20 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
| 21 #include "ui/aura/window_event_dispatcher.h" | 22 #include "ui/aura/window_event_dispatcher.h" |
| 22 #include "ui/base/resource/resource_bundle.h" | 23 #include "ui/base/resource/resource_bundle.h" |
| 23 #include "ui/compositor/layer.h" | 24 #include "ui/compositor/layer.h" |
| 24 #include "ui/gfx/canvas.h" | 25 #include "ui/gfx/canvas.h" |
| 25 #include "ui/gfx/image/image.h" | 26 #include "ui/gfx/image/image.h" |
| 26 #include "ui/gfx/size_conversions.h" | 27 #include "ui/gfx/size_conversions.h" |
| 27 #include "ui/gfx/transform.h" | 28 #include "ui/gfx/transform.h" |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 65 transform.Scale(ui_scale, ui_scale); | 66 transform.Scale(ui_scale, ui_scale); |
| 66 child->SetTransform(transform); | 67 child->SetTransform(transform); |
| 67 } | 68 } |
| 68 | 69 |
| 69 private: | 70 private: |
| 70 DISALLOW_COPY_AND_ASSIGN(LayerControlView); | 71 DISALLOW_COPY_AND_ASSIGN(LayerControlView); |
| 71 }; | 72 }; |
| 72 | 73 |
| 73 } // namespace | 74 } // namespace |
| 74 | 75 |
| 76 namespace internal { | |
|
tdanderson
2014/08/01 19:32:14
newline after line 76
rsadam
2014/08/01 19:57:10
Done.
| |
| 77 // This event handler receives events in the pre-target phase and takes care of | |
| 78 // the following: | |
| 79 // - Disabling overview mode on touch release. | |
| 80 // - Disabling overview mode on mouse release. | |
| 81 class PreEventDispatchHandler : public ui::EventHandler { | |
| 82 public: | |
| 83 PreEventDispatchHandler() {} | |
| 84 virtual ~PreEventDispatchHandler() {} | |
| 85 | |
| 86 private: | |
| 87 // ui::EventHandler: | |
| 88 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE { | |
|
tdanderson
2014/08/01 19:32:14
I'd add a CHECK_EQ to verify that the phase is act
rsadam
2014/08/01 19:57:10
Done.
| |
| 89 WindowSelectorController* controller = | |
| 90 Shell::GetInstance()->window_selector_controller(); | |
| 91 if (event->type() == ui::ET_MOUSE_RELEASED && controller->IsSelecting()) { | |
|
tdanderson
2014/08/01 19:32:14
Since conditional is only one line, omit {} around
rsadam
2014/08/01 19:57:10
Acknowledged! Readded the braces since I moved the
| |
| 92 controller->ToggleOverview(); | |
| 93 } | |
|
tdanderson
2014/08/01 19:32:14
Mark the event as handled (here and also in the ot
rsadam
2014/08/01 19:57:09
Based on my understanding we should only do this i
tdanderson
2014/08/01 20:09:27
Yep, that's correct.
| |
| 94 } | |
| 95 | |
| 96 virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE { | |
|
tdanderson
2014/08/01 19:32:14
We should instead listen for ET_GESTURE_TAP instea
rsadam
2014/08/01 19:57:09
Done.
| |
| 97 WindowSelectorController* controller = | |
| 98 Shell::GetInstance()->window_selector_controller(); | |
| 99 if (event->type() == ui::ET_TOUCH_RELEASED && controller->IsSelecting()) { | |
|
tdanderson
2014/08/01 19:32:14
Same as above, no {}
rsadam
2014/08/01 19:57:10
Acknowledged.
| |
| 100 controller->ToggleOverview(); | |
| 101 } | |
| 102 } | |
| 103 | |
| 104 DISALLOW_COPY_AND_ASSIGN(PreEventDispatchHandler); | |
| 105 }; | |
|
tdanderson
2014/08/01 19:32:14
newline after line 105
rsadam
2014/08/01 19:57:10
Done.
| |
| 106 } // namespace internal | |
| 107 | |
| 75 //////////////////////////////////////////////////////////////////////////////// | 108 //////////////////////////////////////////////////////////////////////////////// |
| 76 // DesktopBackgroundView, public: | 109 // DesktopBackgroundView, public: |
| 77 | 110 |
| 78 DesktopBackgroundView::DesktopBackgroundView() { | 111 DesktopBackgroundView::DesktopBackgroundView() |
| 112 : pre_dispatch_handler_(new internal::PreEventDispatchHandler()) { | |
| 79 set_context_menu_controller(this); | 113 set_context_menu_controller(this); |
| 114 AddPreTargetHandler(pre_dispatch_handler_.get()); | |
| 80 } | 115 } |
| 81 | 116 |
| 82 DesktopBackgroundView::~DesktopBackgroundView() { | 117 DesktopBackgroundView::~DesktopBackgroundView() { |
| 83 } | 118 } |
| 84 | 119 |
| 85 //////////////////////////////////////////////////////////////////////////////// | 120 //////////////////////////////////////////////////////////////////////////////// |
| 86 // DesktopBackgroundView, views::View overrides: | 121 // DesktopBackgroundView, views::View overrides: |
| 87 | 122 |
| 88 void DesktopBackgroundView::OnPaint(gfx::Canvas* canvas) { | 123 void DesktopBackgroundView::OnPaint(gfx::Canvas* canvas) { |
| 89 // Scale the image while maintaining the aspect ratio, cropping as | 124 // Scale the image while maintaining the aspect ratio, cropping as |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 217 // Disable animation if transition to login screen from an empty background. | 252 // Disable animation if transition to login screen from an empty background. |
| 218 wm::SetWindowVisibilityAnimationTransition( | 253 wm::SetWindowVisibilityAnimationTransition( |
| 219 desktop_widget->GetNativeView(), wm::ANIMATE_NONE); | 254 desktop_widget->GetNativeView(), wm::ANIMATE_NONE); |
| 220 } | 255 } |
| 221 | 256 |
| 222 desktop_widget->SetBounds(params.parent->bounds()); | 257 desktop_widget->SetBounds(params.parent->bounds()); |
| 223 return desktop_widget; | 258 return desktop_widget; |
| 224 } | 259 } |
| 225 | 260 |
| 226 } // namespace ash | 261 } // namespace ash |
| OLD | NEW |