OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/shelf/shelf_bezel_event_filter.h" | 5 #include "ash/shelf/shelf_bezel_event_filter.h" |
6 | 6 |
7 #include "ash/shelf/shelf_layout_manager.h" | 7 #include "ash/shelf/shelf_layout_manager.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "ui/aura/window.h" | 9 #include "ui/aura/window.h" |
| 10 #include "ui/gfx/screen.h" |
10 #include "ui/wm/core/coordinate_conversion.h" | 11 #include "ui/wm/core/coordinate_conversion.h" |
11 | 12 |
12 namespace ash { | 13 namespace ash { |
13 | 14 |
14 ShelfBezelEventFilter::ShelfBezelEventFilter( | 15 ShelfBezelEventFilter::ShelfBezelEventFilter( |
15 ShelfLayoutManager* shelf) | 16 ShelfLayoutManager* shelf) |
16 : shelf_(shelf), | 17 : shelf_(shelf), |
17 in_touch_drag_(false) { | 18 in_touch_drag_(false) { |
18 Shell::GetInstance()->AddPreTargetHandler(this); | 19 Shell::GetInstance()->AddPreTargetHandler(this); |
19 } | 20 } |
20 | 21 |
21 ShelfBezelEventFilter::~ShelfBezelEventFilter() { | 22 ShelfBezelEventFilter::~ShelfBezelEventFilter() { |
22 Shell::GetInstance()->RemovePreTargetHandler(this); | 23 Shell::GetInstance()->RemovePreTargetHandler(this); |
23 } | 24 } |
24 | 25 |
25 void ShelfBezelEventFilter::OnGestureEvent( | 26 void ShelfBezelEventFilter::OnGestureEvent( |
26 ui::GestureEvent* event) { | 27 ui::GestureEvent* event) { |
27 gfx::Point point_in_screen(event->location()); | 28 gfx::Point point_in_screen(event->location()); |
28 aura::Window* target = static_cast<aura::Window*>(event->target()); | 29 aura::Window* target = static_cast<aura::Window*>(event->target()); |
29 ::wm::ConvertPointToScreen(target, &point_in_screen); | 30 ::wm::ConvertPointToScreen(target, &point_in_screen); |
30 gfx::Rect screen = | 31 gfx::Rect screen = gfx::Screen::GetScreen() |
31 Shell::GetScreen()->GetDisplayNearestPoint(point_in_screen).bounds(); | 32 ->GetDisplayNearestPoint(point_in_screen) |
| 33 .bounds(); |
32 if ((!screen.Contains(point_in_screen) && | 34 if ((!screen.Contains(point_in_screen) && |
33 IsShelfOnBezel(screen, point_in_screen)) || | 35 IsShelfOnBezel(screen, point_in_screen)) || |
34 in_touch_drag_) { | 36 in_touch_drag_) { |
35 if (gesture_handler_.ProcessGestureEvent(*event, target)) { | 37 if (gesture_handler_.ProcessGestureEvent(*event, target)) { |
36 switch (event->type()) { | 38 switch (event->type()) { |
37 case ui::ET_GESTURE_SCROLL_BEGIN: | 39 case ui::ET_GESTURE_SCROLL_BEGIN: |
38 in_touch_drag_ = true; | 40 in_touch_drag_ = true; |
39 break; | 41 break; |
40 case ui::ET_GESTURE_SCROLL_END: | 42 case ui::ET_GESTURE_SCROLL_END: |
41 case ui::ET_SCROLL_FLING_START: | 43 case ui::ET_SCROLL_FLING_START: |
(...skipping 25 matching lines...) Expand all Loading... |
67 break; | 69 break; |
68 case SHELF_ALIGNMENT_RIGHT: | 70 case SHELF_ALIGNMENT_RIGHT: |
69 if (point.x() >= screen.right()) | 71 if (point.x() >= screen.right()) |
70 return true; | 72 return true; |
71 break; | 73 break; |
72 } | 74 } |
73 return false; | 75 return false; |
74 } | 76 } |
75 | 77 |
76 } // namespace ash | 78 } // namespace ash |
OLD | NEW |