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

Side by Side Diff: mojo/services/native_viewport/platform_viewport_x11.cc

Issue 476283006: mojo: Fix double character inserts on Windows by removing a Linux hack. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move input method to its own file. Created 6 years, 3 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
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 "mojo/services/native_viewport/platform_viewport.h" 5 #include "mojo/services/native_viewport/platform_viewport.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "mojo/services/public/cpp/input_events/lib/mojo_extended_key_event_data .h"
9 #include "ui/events/event.h" 10 #include "ui/events/event.h"
10 #include "ui/events/event_utils.h" 11 #include "ui/events/event_utils.h"
11 #include "ui/events/platform/platform_event_dispatcher.h" 12 #include "ui/events/platform/platform_event_dispatcher.h"
12 #include "ui/events/platform/platform_event_source.h" 13 #include "ui/events/platform/platform_event_source.h"
13 #include "ui/gfx/rect.h" 14 #include "ui/gfx/rect.h"
14 #include "ui/platform_window/platform_window.h" 15 #include "ui/platform_window/platform_window.h"
15 #include "ui/platform_window/platform_window_delegate.h" 16 #include "ui/platform_window/platform_window_delegate.h"
16 #include "ui/platform_window/x11/x11_window.h" 17 #include "ui/platform_window/x11/x11_window.h"
17 18
18 namespace mojo { 19 namespace mojo {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 virtual void OnBoundsChanged(const gfx::Rect& new_bounds) OVERRIDE { 73 virtual void OnBoundsChanged(const gfx::Rect& new_bounds) OVERRIDE {
73 bounds_ = new_bounds; 74 bounds_ = new_bounds;
74 delegate_->OnBoundsChanged(new_bounds); 75 delegate_->OnBoundsChanged(new_bounds);
75 } 76 }
76 77
77 virtual void OnDamageRect(const gfx::Rect& damaged_region) OVERRIDE { 78 virtual void OnDamageRect(const gfx::Rect& damaged_region) OVERRIDE {
78 } 79 }
79 80
80 virtual void DispatchEvent(ui::Event* event) OVERRIDE { 81 virtual void DispatchEvent(ui::Event* event) OVERRIDE {
81 delegate_->OnEvent(event); 82 delegate_->OnEvent(event);
83
84 // We want to emulate the WM_CHAR generation behaviour of Windows.
85 //
86 // On Linux, we've previously inserted characters by having
87 // InputMethodAuraLinux take all key down events and send a character event
88 // to the TextInputClient. This causes a mismatch in code that has to be
89 // shared between Windows and Linux, including blink code. Now that we're
90 // trying to have one way of doing things, we need to standardize on and
91 // emulate Windows character events.
92 //
93 // This is equivalent to what we're doing in the current Linux port, but
94 // done once instead of done multiple times in different places.
95 if (event->type() == ui::ET_KEY_PRESSED) {
96 ui::KeyEvent* key_press_event = static_cast<ui::KeyEvent*>(event);
97 ui::KeyEvent char_event(key_press_event->GetCharacter(),
98 key_press_event->key_code(),
99 key_press_event->flags());
100
101 DCHECK_EQ(key_press_event->GetCharacter(), char_event.GetCharacter());
102 DCHECK_EQ(key_press_event->key_code(), char_event.key_code());
103 DCHECK_EQ(key_press_event->flags(), char_event.flags());
104
105 char_event.SetExtendedKeyEventData(scoped_ptr<ui::ExtendedKeyEventData>(
106 new MojoExtendedKeyEventData(
107 ui::WindowsKeycodeFromNative(key_press_event->native_event()),
108 ui::TextFromNative(key_press_event->native_event()),
109 ui::UnmodifiedTextFromNative(key_press_event->native_event()))));
110 char_event.set_platform_keycode(key_press_event->platform_keycode());
111
112 delegate_->OnEvent(&char_event);
113 }
82 } 114 }
83 115
84 virtual void OnCloseRequest() OVERRIDE { 116 virtual void OnCloseRequest() OVERRIDE {
85 platform_window_->Close(); 117 platform_window_->Close();
86 } 118 }
87 119
88 virtual void OnClosed() OVERRIDE { 120 virtual void OnClosed() OVERRIDE {
89 delegate_->OnDestroyed(); 121 delegate_->OnDestroyed();
90 } 122 }
91 123
(...skipping 17 matching lines...) Expand all
109 141
110 DISALLOW_COPY_AND_ASSIGN(PlatformViewportX11); 142 DISALLOW_COPY_AND_ASSIGN(PlatformViewportX11);
111 }; 143 };
112 144
113 // static 145 // static
114 scoped_ptr<PlatformViewport> PlatformViewport::Create(Delegate* delegate) { 146 scoped_ptr<PlatformViewport> PlatformViewport::Create(Delegate* delegate) {
115 return scoped_ptr<PlatformViewport>(new PlatformViewportX11(delegate)).Pass(); 147 return scoped_ptr<PlatformViewport>(new PlatformViewportX11(delegate)).Pass();
116 } 148 }
117 149
118 } // namespace mojo 150 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/services/html_viewer/blink_input_events_type_converters.cc ('k') | mojo/services/public/cpp/input_events/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698