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/wm/workspace/workspace_event_filter.h" | 5 #include "ash/wm/workspace/workspace_event_handler.h" |
6 | 6 |
7 #include "ash/screen_ash.h" | 7 #include "ash/screen_ash.h" |
8 #include "ash/wm/property_util.h" | 8 #include "ash/wm/property_util.h" |
9 #include "ash/wm/window_util.h" | 9 #include "ash/wm/window_util.h" |
10 #include "ash/wm/workspace/workspace_window_resizer.h" | 10 #include "ash/wm/workspace/workspace_window_resizer.h" |
11 #include "ui/aura/client/aura_constants.h" | 11 #include "ui/aura/client/aura_constants.h" |
12 #include "ui/aura/window.h" | 12 #include "ui/aura/window.h" |
13 #include "ui/aura/window_delegate.h" | 13 #include "ui/aura/window_delegate.h" |
14 #include "ui/base/events/event.h" | 14 #include "ui/base/events/event.h" |
15 #include "ui/base/hit_test.h" | 15 #include "ui/base/hit_test.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 } | 47 } |
48 } else { | 48 } else { |
49 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); | 49 window->SetProperty(aura::client::kShowStateKey, ui::SHOW_STATE_MAXIMIZED); |
50 } | 50 } |
51 } | 51 } |
52 | 52 |
53 } // namespace | 53 } // namespace |
54 | 54 |
55 namespace internal { | 55 namespace internal { |
56 | 56 |
57 WorkspaceEventFilter::WorkspaceEventFilter(aura::Window* owner) | 57 WorkspaceEventHandler::WorkspaceEventHandler(aura::Window* owner) |
58 : ToplevelWindowEventFilter(owner), | 58 : ToplevelWindowEventHandler(owner), |
59 destroyed_(NULL) { | 59 destroyed_(NULL) { |
60 } | 60 } |
61 | 61 |
62 WorkspaceEventFilter::~WorkspaceEventFilter() { | 62 WorkspaceEventHandler::~WorkspaceEventHandler() { |
63 if (destroyed_) | 63 if (destroyed_) |
64 *destroyed_ = true; | 64 *destroyed_ = true; |
65 } | 65 } |
66 | 66 |
67 bool WorkspaceEventFilter::PreHandleMouseEvent(aura::Window* target, | 67 ui::EventResult WorkspaceEventHandler::OnMouseEvent(ui::MouseEvent* event) { |
68 ui::MouseEvent* event) { | 68 aura::Window* target = static_cast<aura::Window*>(event->target()); |
69 switch (event->type()) { | 69 switch (event->type()) { |
70 case ui::ET_MOUSE_MOVED: { | 70 case ui::ET_MOUSE_MOVED: { |
71 int component = | 71 int component = |
72 target->delegate()->GetNonClientComponent(event->location()); | 72 target->delegate()->GetNonClientComponent(event->location()); |
73 multi_window_resize_controller_.Show(target, component, | 73 multi_window_resize_controller_.Show(target, component, |
74 event->location()); | 74 event->location()); |
75 break; | 75 break; |
76 } | 76 } |
77 case ui::ET_MOUSE_ENTERED: | 77 case ui::ET_MOUSE_ENTERED: |
78 break; | 78 break; |
79 case ui::ET_MOUSE_CAPTURE_CHANGED: | 79 case ui::ET_MOUSE_CAPTURE_CHANGED: |
80 case ui::ET_MOUSE_EXITED: | 80 case ui::ET_MOUSE_EXITED: |
81 break; | 81 break; |
82 case ui::ET_MOUSE_PRESSED: { | 82 case ui::ET_MOUSE_PRESSED: { |
83 if (event->flags() & ui::EF_IS_DOUBLE_CLICK && | 83 if (event->flags() & ui::EF_IS_DOUBLE_CLICK && |
84 target->delegate()->GetNonClientComponent(event->location()) == | 84 target->delegate()->GetNonClientComponent(event->location()) == |
85 HTCAPTION) { | 85 HTCAPTION) { |
86 bool destroyed = false; | 86 bool destroyed = false; |
87 destroyed_ = &destroyed; | 87 destroyed_ = &destroyed; |
88 ToggleMaximizedState(target); | 88 ToggleMaximizedState(target); |
89 if (destroyed) | 89 if (destroyed) |
90 return false; | 90 return ui::ER_UNHANDLED; |
91 destroyed_ = NULL; | 91 destroyed_ = NULL; |
92 } | 92 } |
93 multi_window_resize_controller_.Hide(); | 93 multi_window_resize_controller_.Hide(); |
94 HandleVerticalResizeDoubleClick(target, event); | 94 HandleVerticalResizeDoubleClick(target, event); |
95 break; | 95 break; |
96 } | 96 } |
97 default: | 97 default: |
98 break; | 98 break; |
99 } | 99 } |
100 return ToplevelWindowEventFilter::PreHandleMouseEvent(target, event); | 100 return ToplevelWindowEventHandler::OnMouseEvent(event); |
101 } | 101 } |
102 | 102 |
103 ui::EventResult WorkspaceEventFilter::PreHandleGestureEvent( | 103 ui::EventResult WorkspaceEventHandler::OnGestureEvent(ui::GestureEvent* event) { |
104 aura::Window* target, | 104 aura::Window* target = static_cast<aura::Window*>(event->target()); |
105 ui::GestureEvent* event) { | |
106 if (event->type() == ui::ET_GESTURE_DOUBLE_TAP && | 105 if (event->type() == ui::ET_GESTURE_DOUBLE_TAP && |
107 target->delegate()->GetNonClientComponent(event->location()) == | 106 target->delegate()->GetNonClientComponent(event->location()) == |
108 HTCAPTION) { | 107 HTCAPTION) { |
109 ToggleMaximizedState(target); // |this| may be destroyed from here. | 108 ToggleMaximizedState(target); // |this| may be destroyed from here. |
110 return ui::ER_CONSUMED; | 109 return ui::ER_CONSUMED; |
111 } | 110 } |
112 return ToplevelWindowEventFilter::PreHandleGestureEvent(target, event); | 111 return ToplevelWindowEventHandler::OnGestureEvent(event); |
113 } | 112 } |
114 | 113 |
115 WindowResizer* WorkspaceEventFilter::CreateWindowResizer( | 114 WindowResizer* WorkspaceEventHandler::CreateWindowResizer( |
116 aura::Window* window, | 115 aura::Window* window, |
117 const gfx::Point& point_in_parent, | 116 const gfx::Point& point_in_parent, |
118 int window_component) { | 117 int window_component) { |
119 // Allow dragging maximized windows if it's not tracked by workspace. This is | 118 // Allow dragging maximized windows if it's not tracked by workspace. This is |
120 // set by tab dragging code. | 119 // set by tab dragging code. |
121 if (!wm::IsWindowNormal(window) && | 120 if (!wm::IsWindowNormal(window) && |
122 (window_component != HTCAPTION || GetTrackedByWorkspace(window))) { | 121 (window_component != HTCAPTION || GetTrackedByWorkspace(window))) { |
123 return NULL; | 122 return NULL; |
124 } | 123 } |
125 return WorkspaceWindowResizer::Create( | 124 return WorkspaceWindowResizer::Create( |
126 window, point_in_parent, window_component, | 125 window, point_in_parent, window_component, |
127 std::vector<aura::Window*>()); | 126 std::vector<aura::Window*>()); |
128 } | 127 } |
129 | 128 |
130 void WorkspaceEventFilter::HandleVerticalResizeDoubleClick( | 129 void WorkspaceEventHandler::HandleVerticalResizeDoubleClick( |
131 aura::Window* target, | 130 aura::Window* target, |
132 ui::MouseEvent* event) { | 131 ui::MouseEvent* event) { |
133 if (event->flags() & ui::EF_IS_DOUBLE_CLICK && | 132 if (event->flags() & ui::EF_IS_DOUBLE_CLICK && |
134 !wm::IsWindowMaximized(target)) { | 133 !wm::IsWindowMaximized(target)) { |
135 int component = | 134 int component = |
136 target->delegate()->GetNonClientComponent(event->location()); | 135 target->delegate()->GetNonClientComponent(event->location()); |
137 gfx::Rect work_area = | 136 gfx::Rect work_area = |
138 gfx::Screen::GetDisplayNearestWindow(target).work_area(); | 137 gfx::Screen::GetDisplayNearestWindow(target).work_area(); |
139 const gfx::Rect* restore_bounds = | 138 const gfx::Rect* restore_bounds = |
140 target->GetProperty(aura::client::kRestoreBoundsKey); | 139 target->GetProperty(aura::client::kRestoreBoundsKey); |
(...skipping 20 matching lines...) Expand all Loading... |
161 target->bounds().y(), | 160 target->bounds().y(), |
162 work_area.width(), | 161 work_area.width(), |
163 target->bounds().height())); | 162 target->bounds().height())); |
164 } | 163 } |
165 } | 164 } |
166 } | 165 } |
167 } | 166 } |
168 | 167 |
169 } // namespace internal | 168 } // namespace internal |
170 } // namespace ash | 169 } // namespace ash |
OLD | NEW |