Commit a2fd175c authored by Tom Anderson's avatar Tom Anderson Committed by Commit Bot

[XProto] Temporarily use libXkb to translate key events

The current key translation code doesn't look at the XKB group encoded
in the modifiers.  This is causing an issue where accelerators don't
work in environments that use groups to support multiple layouts.

This is a minimal fix so that it can be merged back to M87 and M86.  It
temporarily reintroduces an Xlib function.

R=sky

Bug: 1125886, 1136265, 1136248, 1136206
Change-Id: Ic6ac82e2918482652f79b35c5a046f56bf5da760
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2462490
Commit-Queue: Thomas Anderson <thomasanderson@chromium.org>
Reviewed-by: default avatarScott Violet <sky@chromium.org>
Cr-Commit-Position: refs/heads/master@{#815900}
parent 1438edba
...@@ -28,6 +28,33 @@ ...@@ -28,6 +28,33 @@
#include "ui/gfx/x/xproto_internal.h" #include "ui/gfx/x/xproto_internal.h"
#include "ui/gfx/x/xproto_types.h" #include "ui/gfx/x/xproto_types.h"
extern "C" {
typedef struct {
int type;
unsigned long serial;
Bool send_event;
Display* display;
Window window;
Window root;
Window subwindow;
Time time;
int x, y;
int x_root, y_root;
unsigned int state;
unsigned int keycode;
Bool same_screen;
} XKeyEvent;
// This is temporarily required to fix XKB key event processing (bugs 1125886,
// 1136265, 1136248, 1136206). It should be removed and replaced with an
// XProto equivalent.
int XLookupString(XKeyEvent* event_struct,
char* buffer_return,
int bytes_buffer,
::KeySym* keysym_return,
void* status_in_out);
}
namespace x11 { namespace x11 {
namespace { namespace {
...@@ -487,8 +514,16 @@ KeyCode Connection::KeysymToKeycode(KeySym keysym) { ...@@ -487,8 +514,16 @@ KeyCode Connection::KeysymToKeycode(KeySym keysym) {
KeySym Connection::KeycodeToKeysym(uint32_t keycode, unsigned int modifiers) { KeySym Connection::KeycodeToKeysym(uint32_t keycode, unsigned int modifiers) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
auto sym = TranslateKey(keycode, modifiers);
return sym == static_cast<KeySym>(XK_VoidSymbol) ? kNoSymbol : sym; XKeyEvent key_event{
.type = KeyEvent::Press,
.display = display_,
.state = modifiers,
.keycode = keycode,
};
::KeySym keysym;
XLookupString(&key_event, nullptr, 0, &keysym, nullptr);
return static_cast<x11::KeySym>(keysym);
} }
std::unique_ptr<Connection> Connection::Clone() const { std::unique_ptr<Connection> Connection::Clone() const {
......
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