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

Side by Side Diff: ash/wm/workspace/frame_maximize_button.cc

Issue 10827145: Convert Aura to use ui::Event. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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
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/wm/workspace/frame_maximize_button.h" 5 #include "ash/wm/workspace/frame_maximize_button.h"
6 6
7 #include "ash/launcher/launcher.h" 7 #include "ash/launcher/launcher.h"
8 #include "ash/screen_ash.h" 8 #include "ash/screen_ash.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/wm/property_util.h" 10 #include "ash/wm/property_util.h"
11 #include "ash/wm/maximize_bubble_controller.h" 11 #include "ash/wm/maximize_bubble_controller.h"
12 #include "ash/wm/workspace/phantom_window_controller.h" 12 #include "ash/wm/workspace/phantom_window_controller.h"
13 #include "ash/wm/workspace/snap_sizer.h" 13 #include "ash/wm/workspace/snap_sizer.h"
14 #include "grit/ash_strings.h" 14 #include "grit/ash_strings.h"
15 #include "grit/ui_resources.h" 15 #include "grit/ui_resources.h"
16 #include "ui/aura/event.h"
17 #include "ui/aura/event_filter.h" 16 #include "ui/aura/event_filter.h"
18 #include "ui/aura/window.h" 17 #include "ui/aura/window.h"
18 #include "ui/base/event.h"
19 #include "ui/base/l10n/l10n_util.h" 19 #include "ui/base/l10n/l10n_util.h"
20 #include "ui/base/resource/resource_bundle.h" 20 #include "ui/base/resource/resource_bundle.h"
21 #include "ui/gfx/image/image.h" 21 #include "ui/gfx/image/image.h"
22 #include "ui/gfx/screen.h" 22 #include "ui/gfx/screen.h"
23 #include "ui/views/widget/widget.h" 23 #include "ui/views/widget/widget.h"
24 #include "ui/views/window/non_client_view.h" 24 #include "ui/views/window/non_client_view.h"
25 25
26 using ash::internal::SnapSizer; 26 using ash::internal::SnapSizer;
27 27
28 namespace ash { 28 namespace ash {
29 29
30 namespace { 30 namespace {
31 31
32 // Delay before forcing an update of the snap location. 32 // Delay before forcing an update of the snap location.
33 const int kUpdateDelayMS = 400; 33 const int kUpdateDelayMS = 400;
34 34
35 } 35 }
36 36
37 // EscapeEventFilter is installed on the RootWindow to track when the escape key 37 // EscapeEventFilter is installed on the RootWindow to track when the escape key
38 // is pressed. We use an EventFilter for this as the FrameMaximizeButton 38 // is pressed. We use an EventFilter for this as the FrameMaximizeButton
39 // normally does not get focus. 39 // normally does not get focus.
40 class FrameMaximizeButton::EscapeEventFilter : public aura::EventFilter { 40 class FrameMaximizeButton::EscapeEventFilter : public aura::EventFilter {
41 public: 41 public:
42 explicit EscapeEventFilter(FrameMaximizeButton* button); 42 explicit EscapeEventFilter(FrameMaximizeButton* button);
43 virtual ~EscapeEventFilter(); 43 virtual ~EscapeEventFilter();
44 44
45 // EventFilter overrides: 45 // EventFilter overrides:
46 virtual bool PreHandleKeyEvent(aura::Window* target, 46 virtual bool PreHandleKeyEvent(aura::Window* target,
47 aura::KeyEvent* event) OVERRIDE; 47 ui::KeyEvent* event) OVERRIDE;
48 virtual bool PreHandleMouseEvent(aura::Window* target, 48 virtual bool PreHandleMouseEvent(aura::Window* target,
49 aura::MouseEvent* event) OVERRIDE; 49 ui::MouseEvent* event) OVERRIDE;
50 virtual ui::TouchStatus PreHandleTouchEvent( 50 virtual ui::TouchStatus PreHandleTouchEvent(
51 aura::Window* target, 51 aura::Window* target,
52 aura::TouchEvent* event) OVERRIDE; 52 ui::TouchEventImpl* event) OVERRIDE;
53 virtual ui::GestureStatus PreHandleGestureEvent( 53 virtual ui::GestureStatus PreHandleGestureEvent(
54 aura::Window* target, 54 aura::Window* target,
55 aura::GestureEvent* event) OVERRIDE; 55 ui::GestureEventImpl* event) OVERRIDE;
56 56
57 private: 57 private:
58 FrameMaximizeButton* button_; 58 FrameMaximizeButton* button_;
59 59
60 DISALLOW_COPY_AND_ASSIGN(EscapeEventFilter); 60 DISALLOW_COPY_AND_ASSIGN(EscapeEventFilter);
61 }; 61 };
62 62
63 FrameMaximizeButton::EscapeEventFilter::EscapeEventFilter( 63 FrameMaximizeButton::EscapeEventFilter::EscapeEventFilter(
64 FrameMaximizeButton* button) 64 FrameMaximizeButton* button)
65 : button_(button) { 65 : button_(button) {
66 Shell::GetInstance()->AddEnvEventFilter(this); 66 Shell::GetInstance()->AddEnvEventFilter(this);
67 } 67 }
68 68
69 FrameMaximizeButton::EscapeEventFilter::~EscapeEventFilter() { 69 FrameMaximizeButton::EscapeEventFilter::~EscapeEventFilter() {
70 Shell::GetInstance()->RemoveEnvEventFilter(this); 70 Shell::GetInstance()->RemoveEnvEventFilter(this);
71 } 71 }
72 72
73 bool FrameMaximizeButton::EscapeEventFilter::PreHandleKeyEvent( 73 bool FrameMaximizeButton::EscapeEventFilter::PreHandleKeyEvent(
74 aura::Window* target, 74 aura::Window* target,
75 aura::KeyEvent* event) { 75 ui::KeyEvent* event) {
76 if (event->type() == ui::ET_KEY_PRESSED && 76 if (event->type() == ui::ET_KEY_PRESSED &&
77 event->key_code() == ui::VKEY_ESCAPE) { 77 event->key_code() == ui::VKEY_ESCAPE) {
78 button_->Cancel(false); 78 button_->Cancel(false);
79 } 79 }
80 return false; 80 return false;
81 } 81 }
82 82
83 bool FrameMaximizeButton::EscapeEventFilter::PreHandleMouseEvent( 83 bool FrameMaximizeButton::EscapeEventFilter::PreHandleMouseEvent(
84 aura::Window* target, 84 aura::Window* target,
85 aura::MouseEvent* event) { 85 ui::MouseEvent* event) {
86 return false; 86 return false;
87 } 87 }
88 88
89 ui::TouchStatus FrameMaximizeButton::EscapeEventFilter::PreHandleTouchEvent( 89 ui::TouchStatus FrameMaximizeButton::EscapeEventFilter::PreHandleTouchEvent(
90 aura::Window* target, 90 aura::Window* target,
91 aura::TouchEvent* event) { 91 ui::TouchEventImpl* event) {
92 return ui::TOUCH_STATUS_UNKNOWN; 92 return ui::TOUCH_STATUS_UNKNOWN;
93 } 93 }
94 94
95 ui::GestureStatus FrameMaximizeButton::EscapeEventFilter::PreHandleGestureEvent( 95 ui::GestureStatus FrameMaximizeButton::EscapeEventFilter::PreHandleGestureEvent(
96 aura::Window* target, 96 aura::Window* target,
97 aura::GestureEvent* event) { 97 ui::GestureEventImpl* event) {
98 return ui::GESTURE_STATUS_UNKNOWN; 98 return ui::GESTURE_STATUS_UNKNOWN;
99 } 99 }
100 100
101 // FrameMaximizeButton --------------------------------------------------------- 101 // FrameMaximizeButton ---------------------------------------------------------
102 102
103 FrameMaximizeButton::FrameMaximizeButton(views::ButtonListener* listener, 103 FrameMaximizeButton::FrameMaximizeButton(views::ButtonListener* listener,
104 views::NonClientFrameView* frame) 104 views::NonClientFrameView* frame)
105 : ImageButton(listener), 105 : ImageButton(listener),
106 frame_(frame), 106 frame_(frame),
107 is_snap_enabled_(false), 107 is_snap_enabled_(false),
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 break; 473 break;
474 case SNAP_RESTORE: 474 case SNAP_RESTORE:
475 frame_->GetWidget()->Restore(); 475 frame_->GetWidget()->Restore();
476 break; 476 break;
477 case SNAP_NONE: 477 case SNAP_NONE:
478 NOTREACHED(); 478 NOTREACHED();
479 } 479 }
480 } 480 }
481 481
482 } // namespace ash 482 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/window_modality_controller_unittest.cc ('k') | ash/wm/workspace/multi_window_resize_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698