Commit bb308a3b authored by erg's avatar erg Committed by Commit bot

mandoline: Fix character entry in html_viewer on Linux.

This reverts my previous change (https://codereview.chromium.org/1232703006),
which fixed the double character insertion in the mandoline omnibox, but
broke all text entry in the html_viewer. The correct change was to make
sure we're using an InputMethodMandoline.

In https://codereview.chromium.org/1155013005/, InputMethodMandoline
appears to have been removed by accident while removing
InputMethodEventFilter. However, at least on Linux, we need to *not* use
InputMethodAuraLinux, which operates on a stream of X11 events, instead
of a stream of events that is designed to look like Windows events on
all platforms.

We don't see these problems on Windows because InputMethodWin is already
expecting a stream of events that looks like what Windows natively sends.

BUG=none

Review URL: https://codereview.chromium.org/1234623004

Cr-Commit-Position: refs/heads/master@{#339672}
parent ef3d9b3a
......@@ -278,6 +278,39 @@ void DefaultDisplayManager::DispatchEvent(ui::Event* event) {
default:
break;
}
#if defined(USE_X11)
// We want to emulate the WM_CHAR generation behaviour of Windows.
//
// On Linux, we've previously inserted characters by having
// InputMethodAuraLinux take all key down events and send a character event
// to the TextInputClient. This causes a mismatch in code that has to be
// shared between Windows and Linux, including blink code. Now that we're
// trying to have one way of doing things, we need to standardize on and
// emulate Windows character events.
//
// This is equivalent to what we're doing in the current Linux port, but
// done once instead of done multiple times in different places.
if (event->type() == ui::ET_KEY_PRESSED) {
ui::KeyEvent* key_press_event = static_cast<ui::KeyEvent*>(event);
ui::KeyEvent char_event(key_press_event->GetCharacter(),
key_press_event->key_code(),
key_press_event->flags());
DCHECK_EQ(key_press_event->GetCharacter(), char_event.GetCharacter());
DCHECK_EQ(key_press_event->key_code(), char_event.key_code());
DCHECK_EQ(key_press_event->flags(), char_event.flags());
char_event.SetExtendedKeyEventData(
make_scoped_ptr(new mojo::MojoExtendedKeyEventData(
key_press_event->GetLocatedWindowsKeyboardCode(),
key_press_event->GetText(),
key_press_event->GetUnmodifiedText())));
char_event.set_platform_keycode(key_press_event->platform_keycode());
delegate_->OnEvent(mojo::Event::From(char_event));
}
#endif
}
void DefaultDisplayManager::OnCloseRequest() {
......
......@@ -5,6 +5,7 @@
#include "mandoline/ui/aura/window_tree_host_mojo.h"
#include "components/view_manager/public/cpp/view_manager.h"
#include "mandoline/ui/aura/input_method_mandoline.h"
#include "mandoline/ui/aura/surface_context_factory.h"
#include "mojo/application/public/interfaces/shell.mojom.h"
#include "mojo/converters/geometry/geometry_type_converters.h"
......@@ -33,6 +34,9 @@ WindowTreeHostMojo::WindowTreeHostMojo(mojo::Shell* shell, mojo::View* view)
CreateCompositor(GetAcceleratedWidget());
aura::Env::GetInstance()->set_context_factory(default_context_factory);
DCHECK_EQ(context_factory_.get(), compositor()->context_factory());
input_method_.reset(new InputMethodMandoline(this));
SetSharedInputMethod(input_method_.get());
}
WindowTreeHostMojo::~WindowTreeHostMojo() {
......
......@@ -23,6 +23,7 @@ class Shell;
namespace mandoline {
class InputMethodMandoline;
class SurfaceContextFactory;
class WindowTreeHostMojo : public aura::WindowTreeHost,
......@@ -61,6 +62,8 @@ class WindowTreeHostMojo : public aura::WindowTreeHost,
gfx::Rect bounds_;
scoped_ptr<InputMethodMandoline> input_method_;
scoped_ptr<SurfaceContextFactory> context_factory_;
DISALLOW_COPY_AND_ASSIGN(WindowTreeHostMojo);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment