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 { | |
| 77 | |
| 78 // This event handler receives events in the pre-target phase and takes care of | |
| 79 // the following: | |
| 80 // - Disabling overview mode on touch release. | |
| 81 // - Disabling overview mode on mouse release. | |
| 82 class PreEventDispatchHandler : public ui::EventHandler { | |
| 83 public: | |
| 84 PreEventDispatchHandler() {} | |
| 85 virtual ~PreEventDispatchHandler() {} | |
| 86 | |
| 87 private: | |
| 88 // ui::EventHandler: | |
| 89 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE { | |
| 90 CHECK_EQ(ui::EP_PRETARGET, event->phase()); | |
| 91 if (event->handled()) | |
|
tdanderson
2014/08/01 20:09:27
Is there a particular reason you added this check
rsadam
2014/08/05 14:52:55
I went back and looked at root_view.cc and this ch
| |
| 92 return; | |
| 93 WindowSelectorController* controller = | |
| 94 Shell::GetInstance()->window_selector_controller(); | |
| 95 if (event->type() == ui::ET_MOUSE_RELEASED && controller->IsSelecting()) { | |
| 96 controller->ToggleOverview(); | |
| 97 event->StopPropagation(); | |
| 98 } | |
| 99 } | |
| 100 | |
| 101 virtual void OnTouchEvent(ui::TouchEvent* event) OVERRIDE { | |
|
tdanderson
2014/08/01 20:09:27
Since you've changed to listening for gestures, th
rsadam
2014/08/05 14:52:54
Done.
| |
| 102 CHECK_EQ(ui::EP_PRETARGET, event->phase()); | |
| 103 if (event->handled()) | |
| 104 return; | |
| 105 WindowSelectorController* controller = | |
| 106 Shell::GetInstance()->window_selector_controller(); | |
| 107 if (event->type() == ui::ET_GESTURE_TAP && controller->IsSelecting()) { | |
| 108 controller->ToggleOverview(); | |
| 109 event->StopPropagation(); | |
| 110 } | |
| 111 } | |
| 112 | |
| 113 DISALLOW_COPY_AND_ASSIGN(PreEventDispatchHandler); | |
| 114 }; | |
| 115 | |
| 116 } // namespace internal | |
| 117 | |
| 75 //////////////////////////////////////////////////////////////////////////////// | 118 //////////////////////////////////////////////////////////////////////////////// |
| 76 // DesktopBackgroundView, public: | 119 // DesktopBackgroundView, public: |
| 77 | 120 |
| 78 DesktopBackgroundView::DesktopBackgroundView() { | 121 DesktopBackgroundView::DesktopBackgroundView() |
| 122 : pre_dispatch_handler_(new internal::PreEventDispatchHandler()) { | |
| 79 set_context_menu_controller(this); | 123 set_context_menu_controller(this); |
| 124 AddPreTargetHandler(pre_dispatch_handler_.get()); | |
| 80 } | 125 } |
| 81 | 126 |
| 82 DesktopBackgroundView::~DesktopBackgroundView() { | 127 DesktopBackgroundView::~DesktopBackgroundView() { |
|
bshe
2014/08/05 11:38:28
nit: do you need to remove the handler here?
rsadam
2014/08/05 14:52:55
Done.
| |
| 83 } | 128 } |
| 84 | 129 |
| 85 //////////////////////////////////////////////////////////////////////////////// | 130 //////////////////////////////////////////////////////////////////////////////// |
| 86 // DesktopBackgroundView, views::View overrides: | 131 // DesktopBackgroundView, views::View overrides: |
| 87 | 132 |
| 88 void DesktopBackgroundView::OnPaint(gfx::Canvas* canvas) { | 133 void DesktopBackgroundView::OnPaint(gfx::Canvas* canvas) { |
| 89 // Scale the image while maintaining the aspect ratio, cropping as | 134 // Scale the image while maintaining the aspect ratio, cropping as |
| 90 // necessary to fill the background. Ideally the image should be larger | 135 // necessary to fill the background. Ideally the image should be larger |
| 91 // than the largest display supported, if not we will scale and center it if | 136 // than the largest display supported, if not we will scale and center it if |
| 92 // the layout is WALLPAPER_LAYOUT_CENTER_CROPPED. | 137 // the layout is WALLPAPER_LAYOUT_CENTER_CROPPED. |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 217 // Disable animation if transition to login screen from an empty background. | 262 // Disable animation if transition to login screen from an empty background. |
| 218 wm::SetWindowVisibilityAnimationTransition( | 263 wm::SetWindowVisibilityAnimationTransition( |
| 219 desktop_widget->GetNativeView(), wm::ANIMATE_NONE); | 264 desktop_widget->GetNativeView(), wm::ANIMATE_NONE); |
| 220 } | 265 } |
| 221 | 266 |
| 222 desktop_widget->SetBounds(params.parent->bounds()); | 267 desktop_widget->SetBounds(params.parent->bounds()); |
| 223 return desktop_widget; | 268 return desktop_widget; |
| 224 } | 269 } |
| 225 | 270 |
| 226 } // namespace ash | 271 } // namespace ash |
| OLD | NEW |