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

Side by Side Diff: ui/aura/mus/window_tree_client.cc

Issue 2779093004: Update event states in Env when target window has been destroyed. (Closed)
Patch Set: test Created 3 years, 8 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
« no previous file with comments | « ui/aura/env_input_state_controller.cc ('k') | ui/aura/mus/window_tree_client_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "ui/aura/mus/window_tree_client.h" 5 #include "ui/aura/mus/window_tree_client.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <string> 9 #include <string>
10 #include <utility> 10 #include <utility>
(...skipping 11 matching lines...) Expand all
22 #include "services/ui/common/accelerator_util.h" 22 #include "services/ui/common/accelerator_util.h"
23 #include "services/ui/public/cpp/gpu/gpu.h" 23 #include "services/ui/public/cpp/gpu/gpu.h"
24 #include "services/ui/public/cpp/property_type_converters.h" 24 #include "services/ui/public/cpp/property_type_converters.h"
25 #include "services/ui/public/interfaces/constants.mojom.h" 25 #include "services/ui/public/interfaces/constants.mojom.h"
26 #include "services/ui/public/interfaces/window_manager.mojom.h" 26 #include "services/ui/public/interfaces/window_manager.mojom.h"
27 #include "services/ui/public/interfaces/window_manager_window_tree_factory.mojom .h" 27 #include "services/ui/public/interfaces/window_manager_window_tree_factory.mojom .h"
28 #include "ui/aura/client/aura_constants.h" 28 #include "ui/aura/client/aura_constants.h"
29 #include "ui/aura/client/drag_drop_client.h" 29 #include "ui/aura/client/drag_drop_client.h"
30 #include "ui/aura/client/transient_window_client.h" 30 #include "ui/aura/client/transient_window_client.h"
31 #include "ui/aura/env.h" 31 #include "ui/aura/env.h"
32 #include "ui/aura/env_input_state_controller.h"
32 #include "ui/aura/mus/capture_synchronizer.h" 33 #include "ui/aura/mus/capture_synchronizer.h"
33 #include "ui/aura/mus/drag_drop_controller_mus.h" 34 #include "ui/aura/mus/drag_drop_controller_mus.h"
34 #include "ui/aura/mus/focus_synchronizer.h" 35 #include "ui/aura/mus/focus_synchronizer.h"
35 #include "ui/aura/mus/in_flight_change.h" 36 #include "ui/aura/mus/in_flight_change.h"
36 #include "ui/aura/mus/input_method_mus.h" 37 #include "ui/aura/mus/input_method_mus.h"
37 #include "ui/aura/mus/mus_context_factory.h" 38 #include "ui/aura/mus/mus_context_factory.h"
38 #include "ui/aura/mus/property_converter.h" 39 #include "ui/aura/mus/property_converter.h"
39 #include "ui/aura/mus/property_utils.h" 40 #include "ui/aura/mus/property_utils.h"
40 #include "ui/aura/mus/window_manager_delegate.h" 41 #include "ui/aura/mus/window_manager_delegate.h"
41 #include "ui/aura/mus/window_mus.h" 42 #include "ui/aura/mus/window_mus.h"
42 #include "ui/aura/mus/window_port_mus.h" 43 #include "ui/aura/mus/window_port_mus.h"
43 #include "ui/aura/mus/window_tree_client_delegate.h" 44 #include "ui/aura/mus/window_tree_client_delegate.h"
44 #include "ui/aura/mus/window_tree_client_observer.h" 45 #include "ui/aura/mus/window_tree_client_observer.h"
45 #include "ui/aura/mus/window_tree_client_test_observer.h" 46 #include "ui/aura/mus/window_tree_client_test_observer.h"
46 #include "ui/aura/mus/window_tree_host_mus.h" 47 #include "ui/aura/mus/window_tree_host_mus.h"
47 #include "ui/aura/window.h" 48 #include "ui/aura/window.h"
48 #include "ui/aura/window_delegate.h" 49 #include "ui/aura/window_delegate.h"
50 #include "ui/aura/window_event_dispatcher.h"
49 #include "ui/aura/window_tracker.h" 51 #include "ui/aura/window_tracker.h"
50 #include "ui/base/layout.h" 52 #include "ui/base/layout.h"
51 #include "ui/base/ui_base_types.h" 53 #include "ui/base/ui_base_types.h"
52 #include "ui/display/screen.h" 54 #include "ui/display/screen.h"
53 #include "ui/events/event.h" 55 #include "ui/events/event.h"
54 #include "ui/gfx/geometry/dip_util.h" 56 #include "ui/gfx/geometry/dip_util.h"
55 #include "ui/gfx/geometry/insets.h" 57 #include "ui/gfx/geometry/insets.h"
56 #include "ui/gfx/geometry/size.h" 58 #include "ui/gfx/geometry/size.h"
57 59
58 #if defined(HiWord) 60 #if defined(HiWord)
(...skipping 1146 matching lines...) Expand 10 before | Expand all | Expand 10 after
1205 int64_t display_id, 1207 int64_t display_id,
1206 std::unique_ptr<ui::Event> event, 1208 std::unique_ptr<ui::Event> event,
1207 bool matches_pointer_watcher) { 1209 bool matches_pointer_watcher) {
1208 DCHECK(event); 1210 DCHECK(event);
1209 1211
1210 WindowMus* window = GetWindowByServerId(window_id); // May be null. 1212 WindowMus* window = GetWindowByServerId(window_id); // May be null.
1211 1213
1212 if (event->IsKeyEvent()) { 1214 if (event->IsKeyEvent()) {
1213 DCHECK(!matches_pointer_watcher); // PointerWatcher isn't for key events. 1215 DCHECK(!matches_pointer_watcher); // PointerWatcher isn't for key events.
1214 if (!window || !window->GetWindow()->GetHost()) { 1216 if (!window || !window->GetWindow()->GetHost()) {
1215 tree_->OnWindowInputEventAck(event_id, ui::mojom::EventResult::UNHANDLED); 1217 // Drop the |event| and not necessary to update event states as it's a
1218 // key event.
1219 tree_->OnWindowInputEventAck(event_id, ui::mojom::EventResult::HANDLED);
sadrul 2017/03/31 05:10:51 I actually think this should be UNHANDLED. (becaus
riajiang 2017/03/31 21:24:03 Right! Done.
1216 return; 1220 return;
1217 } 1221 }
1218 InputMethodMus* input_method = GetWindowTreeHostMus(window)->input_method(); 1222 InputMethodMus* input_method = GetWindowTreeHostMus(window)->input_method();
1219 input_method->DispatchKeyEvent(event->AsKeyEvent(), 1223 input_method->DispatchKeyEvent(event->AsKeyEvent(),
1220 CreateEventResultCallback(event_id)); 1224 CreateEventResultCallback(event_id));
1221 return; 1225 return;
1222 } 1226 }
1223 1227
1224 if (matches_pointer_watcher && has_pointer_watcher_) { 1228 if (matches_pointer_watcher && has_pointer_watcher_) {
1225 DCHECK(event->IsPointerEvent()); 1229 DCHECK(event->IsPointerEvent());
1226 std::unique_ptr<ui::Event> event_in_dip(ui::Event::Clone(*event)); 1230 std::unique_ptr<ui::Event> event_in_dip(ui::Event::Clone(*event));
1227 ConvertEventLocationToDip(display_id, event_in_dip->AsLocatedEvent()); 1231 ConvertEventLocationToDip(display_id, event_in_dip->AsLocatedEvent());
1228 delegate_->OnPointerEventObserved(*event_in_dip->AsPointerEvent(), 1232 delegate_->OnPointerEventObserved(*event_in_dip->AsPointerEvent(),
1229 window ? window->GetWindow() : nullptr); 1233 window ? window->GetWindow() : nullptr);
1230 } 1234 }
1231 1235
1232 // TODO: use |display_id| to find host and send there. 1236 // If the window has already been deleted, use |event| to update event states
1237 // kept in aura::Env and drop the |event|. Any WindowTreeHost should be okay
1238 // to get aura::EnvInputStateController from since these are global states.
1233 if (!window || !window->GetWindow()->GetHost()) { 1239 if (!window || !window->GetWindow()->GetHost()) {
1234 tree_->OnWindowInputEventAck(event_id, ui::mojom::EventResult::UNHANDLED); 1240 DCHECK(!roots_.empty());
1241 EnvInputStateController* env_controller =
1242 GetWindowTreeHostMus(*roots_.begin())->dispatcher()->env_controller();
1243 if (event->IsMousePointerEvent()) {
1244 if (event->type() == ui::ET_POINTER_WHEEL_CHANGED) {
1245 ui::MouseWheelEvent mapped_event(*event->AsPointerEvent());
1246 env_controller->UpdateStateForMouseEvent(nullptr, mapped_event);
1247 } else {
1248 ui::MouseEvent mapped_event(*event->AsPointerEvent());
1249 env_controller->UpdateStateForMouseEvent(nullptr, mapped_event);
1250 }
1251 } else if (event->IsMouseEvent()) {
1252 env_controller->UpdateStateForMouseEvent(nullptr, *event->AsMouseEvent());
1253 } else if (event->IsTouchPointerEvent()) {
1254 ui::TouchEvent mapped_event(*event->AsPointerEvent());
1255 env_controller->UpdateStateForTouchEvent(mapped_event);
1256 } else if (event->IsTouchEvent()) {
1257 env_controller->UpdateStateForTouchEvent(*event->AsTouchEvent());
1258 }
sadrul 2017/03/31 05:10:51 Two comments: . We should not receive MouseEvent o
riajiang 2017/03/31 21:24:03 As discussed offline, going to use the MapEvent he
1259 tree_->OnWindowInputEventAck(event_id, ui::mojom::EventResult::HANDLED);
sadrul 2017/03/31 05:10:51 UNHANDLED.
riajiang 2017/03/31 21:24:03 Done.
1235 return; 1260 return;
1236 } 1261 }
1237 1262
1238 EventAckHandler ack_handler(CreateEventResultCallback(event_id)); 1263 EventAckHandler ack_handler(CreateEventResultCallback(event_id));
1239 // TODO(moshayedi): crbug.com/617222. No need to convert to ui::MouseEvent or 1264 // TODO(moshayedi): crbug.com/617222. No need to convert to ui::MouseEvent or
1240 // ui::TouchEvent once we have proper support for pointer events. 1265 // ui::TouchEvent once we have proper support for pointer events.
1241 if (event->IsMousePointerEvent()) { 1266 if (event->IsMousePointerEvent()) {
1242 if (event->type() == ui::ET_POINTER_WHEEL_CHANGED) { 1267 if (event->type() == ui::ET_POINTER_WHEEL_CHANGED) {
1243 ui::MouseWheelEvent mapped_event(*event->AsPointerEvent()); 1268 ui::MouseWheelEvent mapped_event(*event->AsPointerEvent());
1244 DispatchEventToTarget(&mapped_event, window); 1269 DispatchEventToTarget(&mapped_event, window);
(...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after
1948 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>( 1973 return ScheduleInFlightChange(base::MakeUnique<InFlightCaptureChange>(
1949 this, capture_synchronizer_.get(), window)); 1974 this, capture_synchronizer_.get(), window));
1950 } 1975 }
1951 1976
1952 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) { 1977 uint32_t WindowTreeClient::CreateChangeIdForFocus(WindowMus* window) {
1953 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>( 1978 return ScheduleInFlightChange(base::MakeUnique<InFlightFocusChange>(
1954 this, focus_synchronizer_.get(), window)); 1979 this, focus_synchronizer_.get(), window));
1955 } 1980 }
1956 1981
1957 } // namespace aura 1982 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/env_input_state_controller.cc ('k') | ui/aura/mus/window_tree_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698