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

Side by Side Diff: ash/wm/sticky_keys_unittest.cc

Issue 97963002: events: Remove KeyEvent::Copy(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix-win Created 7 years 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
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/wm/sticky_keys.h" 5 #include "ash/wm/sticky_keys.h"
6 6
7 #include <X11/Xlib.h> 7 #include <X11/Xlib.h>
8 #undef None 8 #undef None
9 #undef Bool 9 #undef Bool
10 #undef RootWindow 10 #undef RootWindow
(...skipping 26 matching lines...) Expand all
37 virtual ~EventBuffer() {} 37 virtual ~EventBuffer() {}
38 38
39 void PopEvents(ScopedVector<ui::Event>* events) { 39 void PopEvents(ScopedVector<ui::Event>* events) {
40 events->clear(); 40 events->clear();
41 events->swap(events_); 41 events->swap(events_);
42 } 42 }
43 43
44 private: 44 private:
45 // ui::EventHandler overrides: 45 // ui::EventHandler overrides:
46 virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE { 46 virtual void OnKeyEvent(ui::KeyEvent* event) OVERRIDE {
47 events_.push_back(event->Copy()); 47 events_.push_back(new ui::KeyEvent(*event));
48 } 48 }
49 49
50 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE { 50 virtual void OnMouseEvent(ui::MouseEvent* event) OVERRIDE {
51 if (event->IsMouseWheelEvent()) { 51 if (event->IsMouseWheelEvent()) {
52 events_.push_back( 52 events_.push_back(
53 new ui::MouseWheelEvent(*static_cast<ui::MouseWheelEvent*>(event))); 53 new ui::MouseWheelEvent(*static_cast<ui::MouseWheelEvent*>(event)));
54 } else { 54 } else {
55 events_.push_back(new ui::MouseEvent(event->native_event())); 55 events_.push_back(new ui::MouseEvent(event->native_event()));
56 } 56 }
57 } 57 }
(...skipping 27 matching lines...) Expand all
85 85
86 // Detect a special shortcut when it is dispatched. This shortcut will 86 // Detect a special shortcut when it is dispatched. This shortcut will
87 // not be hit in the LOCKED state as this case does not involve the 87 // not be hit in the LOCKED state as this case does not involve the
88 // delegate. 88 // delegate.
89 if (event->type() == ui::ET_KEY_PRESSED && 89 if (event->type() == ui::ET_KEY_PRESSED &&
90 event->key_code() == ui::VKEY_J && 90 event->key_code() == ui::VKEY_J &&
91 event->flags() | ui::EF_CONTROL_DOWN) { 91 event->flags() | ui::EF_CONTROL_DOWN) {
92 delegate_->OnShortcutPressed(); 92 delegate_->OnShortcutPressed();
93 } 93 }
94 94
95 events_.push_back(event->Copy()); 95 events_.push_back(new ui::KeyEvent(*event));
96 } 96 }
97 97
98 virtual void DispatchMouseEvent(ui::MouseEvent* event, 98 virtual void DispatchMouseEvent(ui::MouseEvent* event,
99 aura::Window* target) OVERRIDE { 99 aura::Window* target) OVERRIDE {
100 ASSERT_EQ(delegate_->GetExpectedTarget(), target); 100 ASSERT_EQ(delegate_->GetExpectedTarget(), target);
101 events_.push_back( 101 events_.push_back(
102 new ui::MouseEvent(*event, target, target->GetRootWindow())); 102 new ui::MouseEvent(*event, target, target->GetRootWindow()));
103 } 103 }
104 104
105 virtual void DispatchScrollEvent(ui::ScrollEvent* event, 105 virtual void DispatchScrollEvent(ui::ScrollEvent* event,
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 static_cast<ui::MouseWheelEvent*>(events[0])->y_offset()); 736 static_cast<ui::MouseWheelEvent*>(events[0])->y_offset());
737 EXPECT_TRUE(events[0]->flags() & ui::EF_CONTROL_DOWN); 737 EXPECT_TRUE(events[0]->flags() & ui::EF_CONTROL_DOWN);
738 EXPECT_EQ(ui::ET_KEY_RELEASED, events[1]->type()); 738 EXPECT_EQ(ui::ET_KEY_RELEASED, events[1]->type());
739 EXPECT_EQ(ui::VKEY_CONTROL, 739 EXPECT_EQ(ui::VKEY_CONTROL,
740 static_cast<ui::KeyEvent*>(events[1])->key_code()); 740 static_cast<ui::KeyEvent*>(events[1])->key_code());
741 741
742 Shell::GetInstance()->RemovePreTargetHandler(&buffer); 742 Shell::GetInstance()->RemovePreTargetHandler(&buffer);
743 } 743 }
744 744
745 } // namespace ash 745 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698