OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/overview/transparent_activate_window_button.h" | 5 #include "ash/wm/overview/transparent_activate_window_button.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/shell_window_ids.h" | 8 #include "ash/shell_window_ids.h" |
9 #include "ash/wm/window_state.h" | 9 #include "ash/wm/window_state.h" |
10 #include "ui/views/controls/button/custom_button.h" | 10 #include "ui/views/controls/button/custom_button.h" |
11 #include "ui/views/widget/widget.h" | 11 #include "ui/views/widget/widget.h" |
12 | 12 |
13 namespace ash { | 13 namespace ash { |
14 | 14 |
15 namespace { | 15 namespace { |
16 const char kTransparentButtonName[] = "TransparentButton"; | 16 const char kTransparentButtonName[] = "TransparentButton"; |
17 | 17 |
18 // Transparent button that handles events which activate windows in overview | 18 // Transparent button that handles events which activate windows in overview |
19 // mode. | 19 // mode. |
20 class TransparentButton : public views::CustomButton { | 20 class TransparentButton : public views::CustomButton { |
21 public: | 21 public: |
22 explicit TransparentButton(views::ButtonListener* listener) | 22 explicit TransparentButton(views::ButtonListener* listener) |
23 : CustomButton(listener) { | 23 : CustomButton(listener) { |
24 } | 24 } |
25 virtual ~TransparentButton() {} | 25 ~TransparentButton() override {} |
26 | 26 |
27 // views::CustomButton: | 27 // views::CustomButton: |
28 void OnGestureEvent(ui::GestureEvent* event) override { | 28 void OnGestureEvent(ui::GestureEvent* event) override { |
29 // TODO(tdanderson): Re-evaluate whether we want to set capture once | 29 // TODO(tdanderson): Re-evaluate whether we want to set capture once |
30 // the a fix has landed to avoid crashing when a window | 30 // the a fix has landed to avoid crashing when a window |
31 // having an active gesture sequence is destroyed as a | 31 // having an active gesture sequence is destroyed as a |
32 // result of a gesture in a separate window. | 32 // result of a gesture in a separate window. |
33 if (event->type() == ui::ET_GESTURE_TAP_DOWN) | 33 if (event->type() == ui::ET_GESTURE_TAP_DOWN) |
34 GetWidget()->SetCapture(this); | 34 GetWidget()->SetCapture(this); |
35 | 35 |
36 if (event->type() == ui::ET_GESTURE_TAP || | 36 if (event->type() == ui::ET_GESTURE_TAP || |
37 event->type() == ui::ET_GESTURE_END) { | 37 event->type() == ui::ET_GESTURE_END) { |
38 GetWidget()->ReleaseCapture(); | 38 GetWidget()->ReleaseCapture(); |
39 } | 39 } |
40 | 40 |
41 CustomButton::OnGestureEvent(event); | 41 CustomButton::OnGestureEvent(event); |
42 event->StopPropagation(); | 42 event->StopPropagation(); |
43 } | 43 } |
44 | 44 |
45 virtual const char* GetClassName() const override { | 45 const char* GetClassName() const override { return kTransparentButtonName; } |
46 return kTransparentButtonName; | |
47 } | |
48 | 46 |
49 private: | 47 private: |
50 DISALLOW_COPY_AND_ASSIGN(TransparentButton); | 48 DISALLOW_COPY_AND_ASSIGN(TransparentButton); |
51 }; | 49 }; |
52 | 50 |
53 // Initializes the event handler transparent window. | 51 // Initializes the event handler transparent window. |
54 views::Widget* InitEventHandler(aura::Window* root_window) { | 52 views::Widget* InitEventHandler(aura::Window* root_window) { |
55 views::Widget* widget = new views::Widget; | 53 views::Widget* widget = new views::Widget; |
56 views::Widget::InitParams params; | 54 views::Widget::InitParams params; |
57 params.type = views::Widget::InitParams::TYPE_POPUP; | 55 params.type = views::Widget::InitParams::TYPE_POPUP; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 | 90 |
93 TransparentActivateWindowButton::~TransparentActivateWindowButton() { | 91 TransparentActivateWindowButton::~TransparentActivateWindowButton() { |
94 } | 92 } |
95 | 93 |
96 void TransparentActivateWindowButton::ButtonPressed(views::Button* sender, | 94 void TransparentActivateWindowButton::ButtonPressed(views::Button* sender, |
97 const ui::Event& event) { | 95 const ui::Event& event) { |
98 wm::GetWindowState(activate_window_)->Activate(); | 96 wm::GetWindowState(activate_window_)->Activate(); |
99 } | 97 } |
100 | 98 |
101 } // namespace ash | 99 } // namespace ash |
OLD | NEW |