Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Side by Side Diff: ash/desktop_background/desktop_background_view.cc

Issue 435023003: Add pretargethandler to exit overview mode on touch/click. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix diamond inheritance. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ash/desktop_background/desktop_background_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 // This event handler receives events in the pre-target phase and takes care of
77 // the following:
78 // - Disabling overview mode on touch release.
79 // - Disabling overview mode on mouse release.
80 class PreEventDispatchHandler : public ui::EventHandler {
81 public:
82 PreEventDispatchHandler() {}
83 virtual ~PreEventDispatchHandler() {}
84
85 private:
86 // ui::EventHandler:
87 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE {
88 CHECK_EQ(ui::EP_PRETARGET, event->phase());
89 WindowSelectorController* controller =
90 Shell::GetInstance()->window_selector_controller();
91 if (event->type() == ui::ET_MOUSE_RELEASED && controller->IsSelecting()) {
92 controller->ToggleOverview();
93 event->StopPropagation();
94 }
95 }
96
97 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE {
98 CHECK_EQ(ui::EP_PRETARGET, event->phase());
99 WindowSelectorController* controller =
100 Shell::GetInstance()->window_selector_controller();
101 if (event->type() == ui::ET_GESTURE_TAP && controller->IsSelecting()) {
102 controller->ToggleOverview();
103 event->StopPropagation();
104 }
105 }
106
107 DISALLOW_COPY_AND_ASSIGN(PreEventDispatchHandler);
108 };
109
75 //////////////////////////////////////////////////////////////////////////////// 110 ////////////////////////////////////////////////////////////////////////////////
76 // DesktopBackgroundView, public: 111 // DesktopBackgroundView, public:
77 112
78 DesktopBackgroundView::DesktopBackgroundView() { 113 DesktopBackgroundView::DesktopBackgroundView()
114 : pre_dispatch_handler_(new PreEventDispatchHandler()) {
79 set_context_menu_controller(this); 115 set_context_menu_controller(this);
116 AddPreTargetHandler(pre_dispatch_handler_.get());
80 } 117 }
81 118
82 DesktopBackgroundView::~DesktopBackgroundView() { 119 DesktopBackgroundView::~DesktopBackgroundView() {
120 RemovePreTargetHandler(pre_dispatch_handler_.get());
83 } 121 }
84 122
85 //////////////////////////////////////////////////////////////////////////////// 123 ////////////////////////////////////////////////////////////////////////////////
86 // DesktopBackgroundView, views::View overrides: 124 // DesktopBackgroundView, views::View overrides:
87 125
88 void DesktopBackgroundView::OnPaint(gfx::Canvas* canvas) { 126 void DesktopBackgroundView::OnPaint(gfx::Canvas* canvas) {
89 // Scale the image while maintaining the aspect ratio, cropping as 127 // Scale the image while maintaining the aspect ratio, cropping as
90 // necessary to fill the background. Ideally the image should be larger 128 // 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 129 // than the largest display supported, if not we will scale and center it if
92 // the layout is WALLPAPER_LAYOUT_CENTER_CROPPED. 130 // the layout is WALLPAPER_LAYOUT_CENTER_CROPPED.
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 // Disable animation if transition to login screen from an empty background. 255 // Disable animation if transition to login screen from an empty background.
218 wm::SetWindowVisibilityAnimationTransition( 256 wm::SetWindowVisibilityAnimationTransition(
219 desktop_widget->GetNativeView(), wm::ANIMATE_NONE); 257 desktop_widget->GetNativeView(), wm::ANIMATE_NONE);
220 } 258 }
221 259
222 desktop_widget->SetBounds(params.parent->bounds()); 260 desktop_widget->SetBounds(params.parent->bounds());
223 return desktop_widget; 261 return desktop_widget;
224 } 262 }
225 263
226 } // namespace ash 264 } // namespace ash
OLDNEW
« no previous file with comments | « ash/desktop_background/desktop_background_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698