Commit 4ed55578 authored by Joe Downing's avatar Joe Downing Committed by Commit Bot

[KeyboardMap] Updating Windows impl to prioritize current layout

The API used to retrieve the list of layouts does not reflect the
order of the layouts in the control panel.  I don't see another
Win32 API which would give us that ordering so I am now grabbing
the current layout and swapping it with the first element to ensure
it is evaluated first.

BUG=832811

Change-Id: Icef22303e38be4b2680ad8636ba408fcb81239a2
Reviewed-on: https://chromium-review.googlesource.com/1130455Reviewed-by: default avatarGary Kacmarcik <garykac@chromium.org>
Commit-Queue: Joe Downing <joedow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#573537}
parent 6ad1cbd1
......@@ -6,6 +6,7 @@
#include <cstdint>
#include <string>
#include <utility>
#include <vector>
#include "base/containers/flat_map.h"
......@@ -61,6 +62,16 @@ uint32_t DomKeyboardLayoutMapWin::GetKeyboardLayoutCount() {
}
DCHECK_EQ(keyboard_layout_count, copy_count);
// The set of layouts returned from GetKeyboardLayoutList does not follow the
// the order of the layouts in the control panel so we use GetKeyboardLayout
// to retrieve the current layout and swap (if needed) to ensure it is always
// evaluated first.
auto iter = std::find(keyboard_layout_handles_.begin(),
keyboard_layout_handles_.end(), GetKeyboardLayout(0));
if (iter != keyboard_layout_handles_.begin() &&
iter != keyboard_layout_handles_.end())
std::iter_swap(keyboard_layout_handles_.begin(), iter);
return keyboard_layout_handles_.size();
}
......
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