From 534338524f8c22104b39a3aef2bd409827b666ef Mon Sep 17 00:00:00 2001 From: "xji@chromium.org" Date: Thu, 10 Jun 2010 22:05:18 +0000 Subject: Same issue as in omnibox, keyboard layout change inside DefWindowProc() in NativeTextfieldWin::HandleKeystroke(). Restore keyboard layout after DefWindowProc(). BUG=14049 TEST=open find-in-page, type in pure Hebrew, press HOME/END/shift-HOME/shift-END, keyboard layout should not be changed. Review URL: http://codereview.chromium.org/2738008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49455 0039d316-1c4b-4281-b951-d872f2087c98 --- views/controls/textfield/native_textfield_win.cc | 25 ++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'views') diff --git a/views/controls/textfield/native_textfield_win.cc b/views/controls/textfield/native_textfield_win.cc index a981b79..75c8325 100644 --- a/views/controls/textfield/native_textfield_win.cc +++ b/views/controls/textfield/native_textfield_win.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -774,7 +774,28 @@ void NativeTextfieldWin::HandleKeystroke(UINT message, if (!handled) { OnBeforePossibleChange(); - DefWindowProc(message, key, MAKELPARAM(repeat_count, flags)); + + if (key == base::VKEY_HOME || key == base::VKEY_END) { + // DefWindowProc() might reset the keyboard layout when it receives a + // keydown event for VKEY_HOME or VKEY_END. When the window was created + // with WS_EX_LAYOUTRTL and the current keyboard layout is not a RTL one, + // if the input text is pure LTR text, the layout changes to the first RTL + // keyboard layout in keyboard layout queue; if the input text is + // bidirectional text, the layout changes to the keyboard layout of the + // first RTL character in input text. When the window was created without + // WS_EX_LAYOUTRTL and the current keyboard layout is not a LTR one, if + // the input text is pure RTL text, the layout changes to English; if the + // input text is bidirectional text, the layout changes to the keyboard + // layout of the first LTR character in input text. Such keyboard layout + // change behavior is surprising and inconsistent with keyboard behavior + // elsewhere, so reset the layout in this case. + HKL layout = GetKeyboardLayout(0); + DefWindowProc(message, key, MAKELPARAM(repeat_count, flags)); + ActivateKeyboardLayout(layout, KLF_REORDER); + } else { + DefWindowProc(message, key, MAKELPARAM(repeat_count, flags)); + } + OnAfterPossibleChange(); } } -- cgit v1.1