| 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" | |
| 19 #include "ash/wm/window_animations.h" | 18 #include "ash/wm/window_animations.h" |
| 20 #include "base/message_loop/message_loop.h" | 19 #include "base/message_loop/message_loop.h" |
| 21 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
| 22 #include "ui/aura/window_event_dispatcher.h" | 21 #include "ui/aura/window_event_dispatcher.h" |
| 23 #include "ui/compositor/layer.h" | 22 #include "ui/compositor/layer.h" |
| 24 #include "ui/gfx/canvas.h" | 23 #include "ui/gfx/canvas.h" |
| 25 #include "ui/gfx/geometry/size_conversions.h" | 24 #include "ui/gfx/geometry/size_conversions.h" |
| 26 #include "ui/gfx/image/image.h" | 25 #include "ui/gfx/image/image.h" |
| 27 #include "ui/gfx/transform.h" | 26 #include "ui/gfx/transform.h" |
| 28 #include "ui/views/widget/widget.h" | 27 #include "ui/views/widget/widget.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 transform.Scale(ui_scale, ui_scale); | 70 transform.Scale(ui_scale, ui_scale); |
| 72 child->SetTransform(transform); | 71 child->SetTransform(transform); |
| 73 } | 72 } |
| 74 | 73 |
| 75 private: | 74 private: |
| 76 DISALLOW_COPY_AND_ASSIGN(LayerControlView); | 75 DISALLOW_COPY_AND_ASSIGN(LayerControlView); |
| 77 }; | 76 }; |
| 78 | 77 |
| 79 } // namespace | 78 } // namespace |
| 80 | 79 |
| 81 // This event handler receives events in the pre-target phase and takes care of | |
| 82 // the following: | |
| 83 // - Disabling overview mode on touch release. | |
| 84 // - Disabling overview mode on mouse release. | |
| 85 class PreEventDispatchHandler : public ui::EventHandler { | |
| 86 public: | |
| 87 PreEventDispatchHandler() {} | |
| 88 ~PreEventDispatchHandler() override {} | |
| 89 | |
| 90 private: | |
| 91 // ui::EventHandler: | |
| 92 void OnMouseEvent(ui::MouseEvent* event) override { | |
| 93 CHECK_EQ(ui::EP_PRETARGET, event->phase()); | |
| 94 WindowSelectorController* controller = | |
| 95 Shell::GetInstance()->window_selector_controller(); | |
| 96 if (event->type() == ui::ET_MOUSE_RELEASED && controller->IsSelecting()) { | |
| 97 controller->ToggleOverview(); | |
| 98 event->StopPropagation(); | |
| 99 } | |
| 100 } | |
| 101 | |
| 102 void OnGestureEvent(ui::GestureEvent* event) override { | |
| 103 CHECK_EQ(ui::EP_PRETARGET, event->phase()); | |
| 104 WindowSelectorController* controller = | |
| 105 Shell::GetInstance()->window_selector_controller(); | |
| 106 if (event->type() == ui::ET_GESTURE_TAP && controller->IsSelecting()) { | |
| 107 controller->ToggleOverview(); | |
| 108 event->StopPropagation(); | |
| 109 } | |
| 110 } | |
| 111 | |
| 112 DISALLOW_COPY_AND_ASSIGN(PreEventDispatchHandler); | |
| 113 }; | |
| 114 | |
| 115 //////////////////////////////////////////////////////////////////////////////// | 80 //////////////////////////////////////////////////////////////////////////////// |
| 116 // DesktopBackgroundView, public: | 81 // DesktopBackgroundView, public: |
| 117 | 82 |
| 118 DesktopBackgroundView::DesktopBackgroundView() | 83 DesktopBackgroundView::DesktopBackgroundView() { |
| 119 : pre_dispatch_handler_(new PreEventDispatchHandler()) { | |
| 120 set_context_menu_controller(this); | 84 set_context_menu_controller(this); |
| 121 AddPreTargetHandler(pre_dispatch_handler_.get()); | |
| 122 } | 85 } |
| 123 | 86 |
| 124 DesktopBackgroundView::~DesktopBackgroundView() { | 87 DesktopBackgroundView::~DesktopBackgroundView() { |
| 125 RemovePreTargetHandler(pre_dispatch_handler_.get()); | |
| 126 } | 88 } |
| 127 | 89 |
| 128 //////////////////////////////////////////////////////////////////////////////// | 90 //////////////////////////////////////////////////////////////////////////////// |
| 129 // DesktopBackgroundView, views::View overrides: | 91 // DesktopBackgroundView, views::View overrides: |
| 130 | 92 |
| 131 void DesktopBackgroundView::OnPaint(gfx::Canvas* canvas) { | 93 void DesktopBackgroundView::OnPaint(gfx::Canvas* canvas) { |
| 132 // Scale the image while maintaining the aspect ratio, cropping as | 94 // Scale the image while maintaining the aspect ratio, cropping as |
| 133 // necessary to fill the background. Ideally the image should be larger | 95 // necessary to fill the background. Ideally the image should be larger |
| 134 // than the largest display supported, if not we will scale and center it if | 96 // than the largest display supported, if not we will scale and center it if |
| 135 // the layout is WALLPAPER_LAYOUT_CENTER_CROPPED. | 97 // the layout is WALLPAPER_LAYOUT_CENTER_CROPPED. |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 // Disable animation if transition to login screen from an empty background. | 222 // Disable animation if transition to login screen from an empty background. |
| 261 wm::SetWindowVisibilityAnimationTransition( | 223 wm::SetWindowVisibilityAnimationTransition( |
| 262 desktop_widget->GetNativeView(), wm::ANIMATE_NONE); | 224 desktop_widget->GetNativeView(), wm::ANIMATE_NONE); |
| 263 } | 225 } |
| 264 | 226 |
| 265 desktop_widget->SetBounds(params.parent->bounds()); | 227 desktop_widget->SetBounds(params.parent->bounds()); |
| 266 return desktop_widget; | 228 return desktop_widget; |
| 267 } | 229 } |
| 268 | 230 |
| 269 } // namespace ash | 231 } // namespace ash |
| OLD | NEW |