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

Side by Side Diff: ash/sticky_keys/sticky_keys_controller.cc

Issue 227113009: Fix sticky keys crash when handling synthetic events without a native event. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: mouse wheel Created 6 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 | Annotate | Revision Log
« no previous file with comments | « ash/sticky_keys/sticky_keys_controller.h ('k') | ash/sticky_keys/sticky_keys_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 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/sticky_keys/sticky_keys_controller.h" 5 #include "ash/sticky_keys/sticky_keys_controller.h"
6 6
7 #if defined(USE_X11) 7 #if defined(USE_X11)
8 #include <X11/extensions/XInput2.h> 8 #include <X11/extensions/XInput2.h>
9 #include <X11/Xlib.h> 9 #include <X11/Xlib.h>
10 #undef RootWindow 10 #undef RootWindow
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 void StickyKeysHandlerDelegateImpl::DispatchKeyEvent(ui::KeyEvent* event, 62 void StickyKeysHandlerDelegateImpl::DispatchKeyEvent(ui::KeyEvent* event,
63 aura::Window* target) { 63 aura::Window* target) {
64 DispatchEvent(event, target); 64 DispatchEvent(event, target);
65 } 65 }
66 66
67 void StickyKeysHandlerDelegateImpl::DispatchMouseEvent(ui::MouseEvent* event, 67 void StickyKeysHandlerDelegateImpl::DispatchMouseEvent(ui::MouseEvent* event,
68 aura::Window* target) { 68 aura::Window* target) {
69 DCHECK(target); 69 DCHECK(target);
70 // We need to send a new, untransformed mouse event to the host. 70 // We need to send a new, untransformed mouse event to the host.
71 if (event->IsMouseWheelEvent()) { 71 if (event->IsMouseWheelEvent()) {
72 ui::MouseWheelEvent new_event(event->native_event()); 72 if (event->HasNativeEvent()) {
73 DispatchEvent(&new_event, target); 73 ui::MouseWheelEvent new_event(event->native_event());
74 DispatchEvent(&new_event, target);
75 } else {
76 aura::Window* source = static_cast<aura::Window*>(event->target());
77 ui::MouseWheelEvent new_event(*static_cast<ui::MouseWheelEvent*>(event),
78 source,
79 source->GetRootWindow(),
80 event->type(),
81 event->flags());
sadrul 2014/04/07 21:57:33 It looks like this ctor for MouseWheelEvent is not
Tim Song 2014/04/07 22:23:27 Done.
82 // Transform the location back to host coordinates before dispatching.
83 new_event.UpdateForRootTransform(source->GetHost()->GetRootTransform());
84 DispatchEvent(&new_event, target);
85 }
74 } else { 86 } else {
75 ui::MouseEvent new_event(event->native_event()); 87 if (event->HasNativeEvent()) {
76 DispatchEvent(&new_event, target); 88 ui::MouseEvent new_event(event->native_event());
89 DispatchEvent(&new_event, target);
90 } else {
91 aura::Window* source = static_cast<aura::Window*>(event->target());
92 ui::MouseEvent new_event(*event, source, source->GetRootWindow());
93 // Transform the location back to host coordinates before dispatching.
94 new_event.UpdateForRootTransform(source->GetHost()->GetRootTransform());
95 DispatchEvent(&new_event, target);
96 }
sadrul 2014/04/07 21:57:33 You can always just create the new event out of th
Tim Song 2014/04/07 22:23:27 Done. You're right, it should be equivalent in thi
77 } 97 }
78 } 98 }
79 99
80 void StickyKeysHandlerDelegateImpl::DispatchScrollEvent( 100 void StickyKeysHandlerDelegateImpl::DispatchScrollEvent(
81 ui::ScrollEvent* event, 101 ui::ScrollEvent* event,
82 aura::Window* target) { 102 aura::Window* target) {
83 DispatchEvent(event, target); 103 DispatchEvent(event, target);
84 } 104 }
85 105
86 void StickyKeysHandlerDelegateImpl::DispatchEvent(ui::Event* event, 106 void StickyKeysHandlerDelegateImpl::DispatchEvent(ui::Event* event,
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
519 &xievent->mods.effective)); 539 &xievent->mods.effective));
520 } 540 }
521 } 541 }
522 #elif defined(USE_OZONE) 542 #elif defined(USE_OZONE)
523 NOTIMPLEMENTED() << "Modifier key is not handled"; 543 NOTIMPLEMENTED() << "Modifier key is not handled";
524 #endif 544 #endif
525 event->set_flags(event->flags() | modifier_flag_); 545 event->set_flags(event->flags() | modifier_flag_);
526 } 546 }
527 547
528 } // namespace ash 548 } // namespace ash
OLDNEW
« no previous file with comments | « ash/sticky_keys/sticky_keys_controller.h ('k') | ash/sticky_keys/sticky_keys_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698