[XProto] Remove usage of all Xlib headers
This CL removes <X11/Xlib.h> from //ui/gfx/x/x11.h. What was provided
by Xlib.h is now provided with inline declarations. The intent is
that I'll incrementally remove declarations from x11.h until there's
nothing left, at which point the dependency on Xlib will be removed and
therefore x11.h can be removed. Doing it this way will ensure no
additional usages of Xlib are introduced, and it gives a nice way of
tracking progress as usages are removed.
* All Xlib macros are now gone, so it's safe to remove the XProto
"undef" files.
* For some usages of Xlib (events in particular), it's easier to port
to XProto now rather than add declarations to x11.h.
* ui/gfx/x/keysyms/keysyms.h is added in its own directory because
it's needed by xkbcommon code, which is also built on ChromeOS, but
ui/gfx/x/BUIDL.gn asserts that the platform is desktop Linux.
BUG=1066670
R=sky
Change-Id: If8679721548d45bdea48bcd8a898191b3f87eb10
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2392140
Auto-Submit: Thomas Anderson <[email protected]>
Commit-Queue: Scott Violet <[email protected]>
Reviewed-by: Scott Violet <[email protected]>
Reviewed-by: Nick Yamane <[email protected]>
Reviewed-by: Zhenyao Mo <[email protected]>
Cr-Commit-Position: refs/heads/master@{#805533}
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index 92ad822..2676d9c 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -456,43 +456,6 @@
(),
),
(
- r'/XSelectInput|CWEventMask|XCB_CW_EVENT_MASK',
- (
- 'Chrome clients wishing to select events on X windows should use',
- 'ui::XScopedEventSelector. It is safe to ignore this warning only if',
- 'you are selecting events from the GPU process, or if you are using',
- 'an XDisplay other than gfx::GetXDisplay().',
- ),
- True,
- (
- r"^ui[\\/]events[\\/]x[\\/].*\.cc$",
- r"^ui[\\/]gl[\\/].*\.cc$",
- r"^media[\\/]gpu[\\/].*\.cc$",
- r"^gpu[\\/].*\.cc$",
- r"^ui[\\/]base[\\/]x[\\/]xwmstartupcheck[\\/]xwmstartupcheck\.cc$",
- ),
- ),
- (
- r'/\WX?(((Width|Height)(MM)?OfScreen)|(Display(Width|Height)))\(',
- (
- 'Use the corresponding fields in x11::Screen instead.',
- ),
- True,
- (),
- ),
- (
- r'/XInternAtom|xcb_intern_atom',
- (
- 'Use gfx::GetAtom() instead of interning atoms directly.',
- ),
- True,
- (
- r"^gpu[\\/]ipc[\\/]service[\\/]gpu_watchdog_thread\.cc$",
- r"^remoting[\\/]host[\\/]linux[\\/]x_server_clipboard\.cc$",
- r"^ui[\\/]gfx[\\/]x[\\/]x11_atom_cache\.cc$",
- ),
- ),
- (
'setMatrixClip',
(
'Overriding setMatrixClip() is prohibited; ',
@@ -846,6 +809,14 @@
[_THIRD_PARTY_EXCEPT_BLINK], # Not an error in third_party folders.
),
(
+ r'/\b#include <X11/',
+ (
+ 'Do not use Xlib. Use xproto (from //ui/gfx/x:xproto) instead.',
+ ),
+ True,
+ [_THIRD_PARTY_EXCEPT_BLINK], # Not an error in third_party folders.
+ ),
+ (
r'/\bstd::ratio\b',
(
'std::ratio is banned by the Google Style Guide.',
diff --git a/chrome/test/chromedriver/keycode_text_conversion_x.cc b/chrome/test/chromedriver/keycode_text_conversion_x.cc
index 2c22457..a99fa79 100644
--- a/chrome/test/chromedriver/keycode_text_conversion_x.cc
+++ b/chrome/test/chromedriver/keycode_text_conversion_x.cc
@@ -14,6 +14,8 @@
#include "chrome/test/chromedriver/chrome/ui_events.h"
#include "ui/base/x/x11_util.h"
#include "ui/events/keycodes/keyboard_code_conversion_x.h"
+#include "ui/gfx/x/connection.h"
+#include "ui/gfx/x/keysyms/keysyms.h"
#include "ui/gfx/x/x11.h"
namespace {
@@ -109,7 +111,8 @@
for (int mod_index = 0; mod_index <= 8; ++mod_index) {
for (int key_index = 0; key_index < max_mod_keys; ++key_index) {
int key = mod_map->modifiermap[mod_index * max_mod_keys + key_index];
- int keysym = XkbKeycodeToKeysym(display, key, 0, 0);
+ int keysym =
+ static_cast<int>(x11::Connection::Get()->KeycodeToKeysym(key, 0));
if (modifier == kAltKeyModifierMask)
found = keysym == XK_Alt_L || keysym == XK_Alt_R;
else if (modifier == kMetaKeyModifierMask)
diff --git a/gpu/tools/compositor_model_bench/compositor_model_bench.cc b/gpu/tools/compositor_model_bench/compositor_model_bench.cc
index a92909d..a34d957 100644
--- a/gpu/tools/compositor_model_bench/compositor_model_bench.cc
+++ b/gpu/tools/compositor_model_bench/compositor_model_bench.cc
@@ -34,7 +34,10 @@
#include "gpu/tools/compositor_model_bench/render_model_utils.h"
#include "gpu/tools/compositor_model_bench/render_models.h"
#include "gpu/tools/compositor_model_bench/render_tree.h"
+#include "ui/gfx/x/connection.h"
#include "ui/gfx/x/x11.h"
+#include "ui/gfx/x/xproto.h"
+#include "ui/gfx/x/xproto_util.h"
#include "ui/gl/init/gl_factory.h"
using base::TimeTicks;
@@ -123,19 +126,16 @@
void ProcessEvents() {
// Consume all the X events.
- while (XPending(display_)) {
- XEvent e;
- XNextEvent(display_, &e);
- switch (e.type) {
- case Expose:
- UpdateLoop();
- break;
- case ConfigureNotify:
- Resize(e.xconfigure.width, e.xconfigure.height);
- break;
- default:
- break;
- }
+ connection_->Flush();
+ connection_->ReadResponses();
+ auto& events = connection_->events();
+ while (!events.empty()) {
+ auto event = std::move(events.front());
+ events.pop_front();
+ if (event.As<x11::ExposeEvent>())
+ UpdateLoop();
+ else if (auto* configure = event.As<x11::ConfigureNotifyEvent>())
+ Resize(configure->width, configure->height);
}
}
@@ -148,26 +148,21 @@
// Initialize X11. Returns true if successful. This method creates the
// X11 window. Further initialization is done in X11VideoRenderer.
bool InitX11() {
- display_ = XOpenDisplay(nullptr);
+ connection_ = std::make_unique<x11::Connection>();
+ display_ = connection_->display();
if (!display_) {
LOG(FATAL) << "Cannot open display";
return false;
}
// Get properties of the screen.
- int screen = DefaultScreen(display_);
- int root_window = XRootWindow(display_, screen);
+ int screen = XDefaultScreen(display_);
+ int root_window = XDefaultRootWindow(display_);
// Creates the window.
- window_ = XCreateSimpleWindow(display_,
- root_window,
- 1,
- 1,
- window_width_,
- window_height_,
- 0,
- BlackPixel(display_, screen),
- BlackPixel(display_, screen));
+ window_ = XCreateSimpleWindow(
+ display_, root_window, 1, 1, window_width_, window_height_, 0,
+ XBlackPixel(display_, screen), XBlackPixel(display_, screen));
XStoreName(display_, window_, "Compositor Model Bench");
XSelectInput(display_, window_,
@@ -191,9 +186,9 @@
XVisualInfo visual_info_template;
visual_info_template.visualid = XVisualIDFromVisual(attributes.visual);
int visual_info_count = 0;
- XVisualInfo* visual_info_list = XGetVisualInfo(display_, VisualIDMask,
- &visual_info_template,
- &visual_info_count);
+ constexpr int kVisualIdMask = 1;
+ XVisualInfo* visual_info_list = XGetVisualInfo(
+ display_, kVisualIdMask, &visual_info_template, &visual_info_count);
for (int i = 0; i < visual_info_count && !gl_context_; ++i) {
gl_context_ = glXCreateContext(display_, visual_info_list + i, 0,
@@ -246,10 +241,13 @@
glXSwapBuffers(display_, window_);
- XExposeEvent ev = { Expose, 0, 1, display_, window_,
- 0, 0, WINDOW_WIDTH, WINDOW_HEIGHT, 0 };
- XSendEvent(display_, window_, x11::False, ExposureMask,
- reinterpret_cast<XEvent*>(&ev));
+ auto window = static_cast<x11::Window>(window_);
+ x11::ExposeEvent ev{
+ .window = window,
+ .width = WINDOW_WIDTH,
+ .height = WINDOW_HEIGHT,
+ };
+ x11::SendEvent(ev, window, x11::EventMask::Exposure);
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE,
@@ -334,6 +332,7 @@
// Amount of time to run each simulation
int seconds_per_test_;
// GUI data
+ std::unique_ptr<x11::Connection> connection_;
Display* display_;
Window window_;
GLXContext gl_context_;
diff --git a/gpu/vulkan/x/BUILD.gn b/gpu/vulkan/x/BUILD.gn
index 4a8206d..f6eddd8 100644
--- a/gpu/vulkan/x/BUILD.gn
+++ b/gpu/vulkan/x/BUILD.gn
@@ -8,10 +8,6 @@
assert(enable_vulkan)
assert(use_x11 || use_ozone)
-config("vulkan_x11") {
- defines = [ "VK_USE_PLATFORM_XLIB_KHR" ]
-}
-
component("x") {
output_name = "vulkan_x11"
@@ -24,8 +20,6 @@
defines = [ "IS_VULKAN_X11_IMPL" ]
- public_configs = [ ":vulkan_x11" ]
-
deps = [
"//ui/base/x",
"//ui/events/platform/x11",
diff --git a/gpu/vulkan/x/vulkan_implementation_x11.cc b/gpu/vulkan/x/vulkan_implementation_x11.cc
index 52b26b9..2965a1d 100644
--- a/gpu/vulkan/x/vulkan_implementation_x11.cc
+++ b/gpu/vulkan/x/vulkan_implementation_x11.cc
@@ -18,6 +18,7 @@
#include "gpu/vulkan/x/vulkan_surface_x11.h"
#include "ui/gfx/gpu_fence.h"
#include "ui/gfx/gpu_memory_buffer.h"
+#include "ui/gfx/x/x11.h"
#include "ui/gfx/x/x11_types.h"
namespace gpu {
@@ -141,7 +142,7 @@
XDisplay* display = gfx::GetXDisplay();
return vkGetPhysicalDeviceXlibPresentationSupportKHR(
device, queue_family_index, display,
- XVisualIDFromVisual(DefaultVisual(display, DefaultScreen(display))));
+ XVisualIDFromVisual(XDefaultVisual(display, XDefaultScreen(display))));
}
std::vector<const char*>
diff --git a/gpu/vulkan/x/vulkan_surface_x11.cc b/gpu/vulkan/x/vulkan_surface_x11.cc
index 16ffdfb..86de02b 100644
--- a/gpu/vulkan/x/vulkan_surface_x11.cc
+++ b/gpu/vulkan/x/vulkan_surface_x11.cc
@@ -11,6 +11,7 @@
#include "ui/gfx/native_widget_types.h"
#include "ui/gfx/x/connection.h"
#include "ui/gfx/x/xproto.h"
+#include "ui/gfx/x/xproto_util.h"
namespace gpu {
@@ -124,7 +125,7 @@
void VulkanSurfaceX11::ForwardXExposeEvent(const x11::Event* event) {
auto forwarded_event = *event->As<x11::ExposeEvent>();
forwarded_event.window = parent_window_;
- ui::SendEvent(forwarded_event, parent_window_, x11::EventMask::Exposure);
+ x11::SendEvent(forwarded_event, parent_window_, x11::EventMask::Exposure);
x11::Connection::Get()->Flush();
}
diff --git a/media/base/user_input_monitor_linux.cc b/media/base/user_input_monitor_linux.cc
index 397bae2..7c80a06 100644
--- a/media/base/user_input_monitor_linux.cc
+++ b/media/base/user_input_monitor_linux.cc
@@ -179,7 +179,7 @@
// Register OnConnectionData() to be called every time there is something to
// read from |connection_|.
watch_controller_ = base::FileDescriptorWatcher::WatchReadable(
- ConnectionNumber(connection_->display()),
+ XConnectionNumber(connection_->display()),
base::BindRepeating(&UserInputMonitorLinuxCore::OnConnectionData,
base::Unretained(this)));
diff --git a/remoting/host/clipboard_x11.cc b/remoting/host/clipboard_x11.cc
index b63443c..f3d4669 100644
--- a/remoting/host/clipboard_x11.cc
+++ b/remoting/host/clipboard_x11.cc
@@ -77,7 +77,7 @@
base::Unretained(this)));
x_connection_watch_controller_ = base::FileDescriptorWatcher::WatchReadable(
- ConnectionNumber(connection_->display()),
+ XConnectionNumber(connection_->display()),
base::BindRepeating(&ClipboardX11::PumpXEvents, base::Unretained(this)));
PumpXEvents();
}
diff --git a/remoting/host/input_injector_x11.cc b/remoting/host/input_injector_x11.cc
index 9ee1736..926e597 100644
--- a/remoting/host/input_injector_x11.cc
+++ b/remoting/host/input_injector_x11.cc
@@ -29,8 +29,10 @@
#include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h"
#include "ui/events/keycodes/dom/dom_code.h"
#include "ui/events/keycodes/dom/keycode_converter.h"
+#include "ui/gfx/x/keysyms/keysyms.h"
#include "ui/gfx/x/x11.h"
#include "ui/gfx/x/xinput.h"
+#include "ui/gfx/x/xkb.h"
#include "ui/gfx/x/xproto.h"
#include "ui/gfx/x/xtest.h"
@@ -166,7 +168,7 @@
// X11 graphics context.
x11::Connection connection_;
Display* display_ = connection_.display();
- Window root_window_ = BadValue;
+ Window root_window_ = x11::None;
// Number of buttons we support.
// Left, Right, Middle, VScroll Up/Down, HScroll Left/Right, back, forward.
@@ -241,8 +243,8 @@
task_runner_->PostTask(FROM_HERE,
base::BindOnce(&Core::InitClipboard, this));
- root_window_ = XRootWindow(display_, DefaultScreen(display_));
- if (root_window_ == BadValue) {
+ root_window_ = XDefaultRootWindow(display_);
+ if (!root_window_) {
LOG(ERROR) << "Unable to get the root window";
return false;
}
@@ -371,27 +373,27 @@
}
bool InputInjectorX11::Core::IsAutoRepeatEnabled() {
- XKeyboardState state;
- if (!XGetKeyboardControl(display_, &state)) {
- LOG(ERROR) << "Failed to get keyboard auto-repeat status, assuming ON.";
- return true;
- }
- return state.global_auto_repeat == AutoRepeatModeOn;
+ if (auto reply = connection_.GetKeyboardControl({}).Sync())
+ return reply->global_auto_repeat == x11::AutoRepeatMode::On;
+ LOG(ERROR) << "Failed to get keyboard auto-repeat status, assuming ON.";
+ return true;
}
void InputInjectorX11::Core::SetAutoRepeatEnabled(bool mode) {
- XKeyboardControl control;
- control.auto_repeat_mode = mode ? AutoRepeatModeOn : AutoRepeatModeOff;
- XChangeKeyboardControl(display_, KBAutoRepeatMode, &control);
- XFlush(display_);
+ connection_.ChangeKeyboardControl(
+ {.auto_repeat_mode =
+ mode ? x11::AutoRepeatMode::On : x11::AutoRepeatMode::Off});
+ connection_.Flush();
}
bool InputInjectorX11::Core::IsLockKey(KeyCode keycode) {
- XkbStateRec state;
+ auto state = connection_.xkb().GetState({}).Sync();
+ if (!state)
+ return false;
+ auto mods = state->baseMods | state->latchedMods | state->lockedMods;
KeySym keysym;
- if (XkbGetState(display_, XkbUseCoreKbd, &state) == x11::Success &&
- XkbLookupKeySym(display_, keycode, XkbStateMods(&state), nullptr,
- &keysym) == x11::True) {
+ if (state && XkbLookupKeySym(display_, keycode, static_cast<unsigned>(mods),
+ nullptr, &keysym) == x11::True) {
return keysym == XK_Caps_Lock || keysym == XK_Num_Lock;
} else {
return false;
@@ -422,7 +424,8 @@
}
if (update_mask) {
- XkbLockModifiers(display_, XkbUseCoreKbd, update_mask, lock_values);
+ XkbLockModifiers(display_, static_cast<unsigned>(x11::Xkb::Id::UseCoreKbd),
+ update_mask, lock_values);
}
}
@@ -581,14 +584,12 @@
// Instead, try to work around it by reversing the mapping.
// Note that if a user has a global mapping that completely disables a button
// (by assigning 0 to it), we won't be able to inject it.
- int num_buttons = XGetPointerMapping(display_, nullptr, 0);
- std::unique_ptr<unsigned char[]> pointer_mapping(
- new unsigned char[num_buttons]);
- num_buttons =
- XGetPointerMapping(display_, pointer_mapping.get(), num_buttons);
+ std::vector<uint8_t> pointer_mapping;
+ if (auto reply = connection_.GetPointerMapping({}).Sync())
+ pointer_mapping = std::move(reply->map);
for (int& i : pointer_button_map_)
i = -1;
- for (int i = 0; i < num_buttons; i++) {
+ for (size_t i = 0; i < pointer_mapping.size(); i++) {
// Reverse the mapping.
if (pointer_mapping[i] > 0 && pointer_mapping[i] <= kNumPointerButtons)
pointer_button_map_[pointer_mapping[i] - 1] = i + 1;
diff --git a/remoting/host/input_monitor/local_hotkey_input_monitor_x11.cc b/remoting/host/input_monitor/local_hotkey_input_monitor_x11.cc
index 169f587..4b2ee0e2 100644
--- a/remoting/host/input_monitor/local_hotkey_input_monitor_x11.cc
+++ b/remoting/host/input_monitor/local_hotkey_input_monitor_x11.cc
@@ -20,6 +20,7 @@
#include "base/single_thread_task_runner.h"
#include "ui/events/devices/x11/xinput_util.h"
#include "ui/gfx/x/connection.h"
+#include "ui/gfx/x/keysyms/keysyms.h"
#include "ui/gfx/x/x11.h"
#include "ui/gfx/x/xinput.h"
@@ -161,7 +162,7 @@
// Register OnConnectionData() to be called every time there is
// something to read from |connection_|.
controller_ = base::FileDescriptorWatcher::WatchReadable(
- ConnectionNumber(connection_->display()),
+ XConnectionNumber(connection_->display()),
base::BindRepeating(&Core::OnConnectionData, base::Unretained(this)));
// Fetch pending events if any.
diff --git a/remoting/host/input_monitor/local_mouse_input_monitor_x11.cc b/remoting/host/input_monitor/local_mouse_input_monitor_x11.cc
index 3f1487c..a0ef345b 100644
--- a/remoting/host/input_monitor/local_mouse_input_monitor_x11.cc
+++ b/remoting/host/input_monitor/local_mouse_input_monitor_x11.cc
@@ -156,7 +156,7 @@
// Register OnConnectionData() to be called every time there is
// something to read from |connection_|.
controller_ = base::FileDescriptorWatcher::WatchReadable(
- ConnectionNumber(connection_->display()),
+ XConnectionNumber(connection_->display()),
base::BindRepeating(&Core::OnConnectionData, base::Unretained(this)));
// Fetch pending events if any.
diff --git a/remoting/host/keyboard_layout_monitor_linux.cc b/remoting/host/keyboard_layout_monitor_linux.cc
index f4adfcbb..a394a9c 100644
--- a/remoting/host/keyboard_layout_monitor_linux.cc
+++ b/remoting/host/keyboard_layout_monitor_linux.cc
@@ -8,6 +8,7 @@
#include "base/bind.h"
#include "base/callback.h"
+#include "base/files/file_descriptor_watcher_posix.h"
#include "base/logging.h"
#include "base/memory/weak_ptr.h"
#include "base/optional.h"
@@ -40,32 +41,31 @@
// Can be constructed on any thread, but must be started and destroyed on the
// main GTK+ thread (i.e., the GLib global default main context).
-class GdkLayoutMonitorOnGtkThread {
+class GdkLayoutMonitorOnGtkThread : public x11::Connection::Delegate {
public:
GdkLayoutMonitorOnGtkThread(
scoped_refptr<base::SequencedTaskRunner> task_runner,
base::WeakPtr<KeyboardLayoutMonitorLinux> weak_ptr);
// Must be called on GTK Thread
- ~GdkLayoutMonitorOnGtkThread();
+ ~GdkLayoutMonitorOnGtkThread() override;
void Start();
private:
+ // x11::Connection::Delegate:
+ bool ShouldContinueStream() const override;
+ void DispatchXEvent(x11::Event* event) override;
+
void QueryLayout();
- static GdkFilterReturn OnXEventThunk(GdkXEvent* xevent,
- GdkEvent* event,
- gpointer data);
- GdkFilterReturn OnXEvent(XEvent* xevent, GdkEvent* event);
+ void OnConnectionData();
CHROMEG_CALLBACK_0(GdkLayoutMonitorOnGtkThread,
void,
OnKeysChanged,
GdkKeymap*);
scoped_refptr<base::SequencedTaskRunner> task_runner_;
base::WeakPtr<KeyboardLayoutMonitorLinux> weak_ptr_;
- // xkb_event_type_ is initialized in Start(). It is only used by OnXEvent,
- // which is only registered as a callback after xkb_event_type_ has been
- // initialized.
- int xkb_event_type_;
+ std::unique_ptr<x11::Connection> connection_;
+ std::unique_ptr<base::FileDescriptorWatcher::Controller> controller_;
GdkDisplay* display_ = nullptr;
GdkKeymap* keymap_ = nullptr;
int current_group_ = 0;
@@ -119,10 +119,8 @@
GdkLayoutMonitorOnGtkThread::~GdkLayoutMonitorOnGtkThread() {
DCHECK(g_main_context_is_owner(g_main_context_default()));
- if (handler_id_) {
+ if (handler_id_)
g_signal_handler_disconnect(keymap_, handler_id_);
- gdk_window_remove_filter(nullptr, OnXEventThunk, this);
- }
}
void GdkLayoutMonitorOnGtkThread::Start() {
@@ -144,16 +142,28 @@
// when switching between groups with different writing directions. As a
// result, we have to use Xkb directly to get and monitor that information,
// which is a pain.
- auto* connection = x11::Connection::Get();
- if (connection->xkb()
- .UseExtension({x11::Xkb::major_version, x11::Xkb::minor_version})
+ connection_ = std::make_unique<x11::Connection>();
+ auto& xkb = connection_->xkb();
+ if (xkb.UseExtension({x11::Xkb::major_version, x11::Xkb::minor_version})
.Sync()) {
- xkb_event_type_ = connection->xkb().first_event();
- auto req = connection->xkb().GetState(
+ auto req = xkb.GetState(
{static_cast<x11::Xkb::DeviceSpec>(x11::Xkb::Id::UseCoreKbd)});
if (auto reply = req.Sync()) {
current_group_ = static_cast<int>(reply->group);
- gdk_window_add_filter(nullptr, OnXEventThunk, this);
+ constexpr auto kXkbAllStateComponentsMask =
+ static_cast<x11::Xkb::StatePart>(0x3fff);
+ xkb.SelectEvents({
+ .deviceSpec =
+ static_cast<x11::Xkb::DeviceSpec>(x11::Xkb::Id::UseCoreKbd),
+ .affectWhich = x11::Xkb::EventType::StateNotify,
+ .affectState = kXkbAllStateComponentsMask,
+ .stateDetails = x11::Xkb::StatePart::GroupState,
+ });
+ connection_->Flush();
+ controller_ = base::FileDescriptorWatcher::WatchReadable(
+ XConnectionNumber(connection_->display()),
+ base::BindRepeating(&GdkLayoutMonitorOnGtkThread::OnConnectionData,
+ base::Unretained(this)));
}
}
@@ -163,6 +173,21 @@
QueryLayout();
}
+bool GdkLayoutMonitorOnGtkThread::ShouldContinueStream() const {
+ return true;
+}
+
+void GdkLayoutMonitorOnGtkThread::DispatchXEvent(x11::Event* event) {
+ if (auto* notify = event->As<x11::Xkb::StateNotifyEvent>()) {
+ int new_group = notify->baseGroup + notify->latchedGroup +
+ static_cast<int16_t>(notify->lockedGroup);
+ if (new_group != current_group_) {
+ current_group_ = new_group;
+ QueryLayout();
+ }
+ }
+}
+
void GdkLayoutMonitorOnGtkThread::QueryLayout() {
protocol::KeyboardLayout layout_message;
@@ -272,30 +297,8 @@
weak_ptr_, std::move(layout_message)));
}
-// static
-GdkFilterReturn GdkLayoutMonitorOnGtkThread::OnXEventThunk(GdkXEvent* xevent,
- GdkEvent* event,
- gpointer data) {
- // GdkXEvent is documented to be castable to the window-system event type
- // XEvent in this case.
- return static_cast<GdkLayoutMonitorOnGtkThread*>(data)->OnXEvent(
- static_cast<XEvent*>(xevent), event);
-}
-
-GdkFilterReturn GdkLayoutMonitorOnGtkThread::OnXEvent(XEvent* xevent,
- GdkEvent* event) {
- if (xevent->type == xkb_event_type_) {
- XkbEvent* xkb_event = reinterpret_cast<XkbEvent*>(xevent);
- if (xkb_event->any.xkb_type == XkbStateNotify) {
- int new_group = XkbStateGroup(&xkb_event->state);
- if (new_group != current_group_) {
- current_group_ = new_group;
- QueryLayout();
- }
- }
- }
- // GDK also needs to process this event.
- return GDK_FILTER_CONTINUE;
+void GdkLayoutMonitorOnGtkThread::OnConnectionData() {
+ connection_->Dispatch(this);
}
void GdkLayoutMonitorOnGtkThread::OnKeysChanged(GdkKeymap* keymap) {
diff --git a/remoting/host/linux/unicode_to_keysym.cc b/remoting/host/linux/unicode_to_keysym.cc
index 7d6e9638..06316d9 100644
--- a/remoting/host/linux/unicode_to_keysym.cc
+++ b/remoting/host/linux/unicode_to_keysym.cc
@@ -7,6 +7,7 @@
#include <algorithm>
#include "base/stl_util.h"
+#include "ui/gfx/x/keysyms/keysyms.h"
#include "ui/gfx/x/x11.h"
namespace remoting {
diff --git a/remoting/host/linux/x11_keyboard_impl.cc b/remoting/host/linux/x11_keyboard_impl.cc
index c55bf17..42dffce3 100644
--- a/remoting/host/linux/x11_keyboard_impl.cc
+++ b/remoting/host/linux/x11_keyboard_impl.cc
@@ -9,6 +9,7 @@
#include "remoting/host/linux/unicode_to_keysym.h"
#include "ui/gfx/x/x11.h"
#include "ui/gfx/x/x11_types.h"
+#include "ui/gfx/x/xkb.h"
#include "ui/gfx/x/xtest.h"
namespace {
@@ -80,12 +81,14 @@
}
void X11KeyboardImpl::PressKey(uint32_t keycode, uint32_t modifiers) {
- XkbLockModifiers(display_, XkbUseCoreKbd, modifiers, modifiers);
+ XkbLockModifiers(display_, static_cast<unsigned>(x11::Xkb::Id::UseCoreKbd),
+ modifiers, modifiers);
connection_->xtest().FakeInput({x11::KeyEvent::Press, keycode});
connection_->xtest().FakeInput({x11::KeyEvent::Release, keycode});
- XkbLockModifiers(display_, XkbUseCoreKbd, modifiers, 0);
+ XkbLockModifiers(display_, static_cast<unsigned>(x11::Xkb::Id::UseCoreKbd),
+ modifiers, 0);
}
bool X11KeyboardImpl::FindKeycode(uint32_t code_point,
diff --git a/remoting/host/linux/x_server_clipboard.cc b/remoting/host/linux/x_server_clipboard.cc
index c93db7f..4eb75711 100644
--- a/remoting/host/linux/x_server_clipboard.cc
+++ b/remoting/host/linux/x_server_clipboard.cc
@@ -12,11 +12,12 @@
#include "ui/gfx/x/extension_manager.h"
#include "ui/gfx/x/x11.h"
#include "ui/gfx/x/xproto.h"
+#include "ui/gfx/x/xproto_util.h"
namespace remoting {
XServerClipboard::XServerClipboard()
- : clipboard_window_(BadValue),
+ : clipboard_window_(x11::None),
clipboard_atom_(x11::None),
large_selection_atom_(x11::None),
selection_string_atom_(x11::None),
@@ -52,7 +53,7 @@
clipboard_window_ =
XCreateSimpleWindow(connection_->display(),
- DefaultRootWindow(connection_->display()), 0, 0, 1,
+ XDefaultRootWindow(connection_->display()), 0, 0, 1,
1, // x, y, width, height
0, 0, 0);
@@ -88,7 +89,7 @@
const std::string& data) {
DCHECK(connection_->display());
- if (clipboard_window_ == BadValue)
+ if (clipboard_window_ == x11::None)
return;
// Currently only UTF-8 is supported.
@@ -106,7 +107,7 @@
}
void XServerClipboard::ProcessXEvent(const x11::Event& event) {
- if (clipboard_window_ == BadValue ||
+ if (clipboard_window_ == x11::None ||
event.window() != static_cast<x11::Window>(clipboard_window_)) {
return;
}
@@ -211,33 +212,34 @@
void XServerClipboard::OnSelectionRequest(
const x11::SelectionRequestEvent& event) {
- XSelectionEvent selection_event;
- selection_event.type = SelectionNotify;
- selection_event.display = connection_->display();
- selection_event.requestor = static_cast<uint32_t>(event.requestor);
- selection_event.selection = static_cast<uint32_t>(event.selection);
- selection_event.time = static_cast<uint32_t>(event.time);
- selection_event.target = static_cast<uint32_t>(event.target);
+ x11::SelectionNotifyEvent selection_event;
+ selection_event.requestor = event.requestor;
+ selection_event.selection = event.selection;
+ selection_event.time = event.time;
+ selection_event.target = event.target;
auto property =
event.property == x11::Atom::None ? event.target : event.property;
- if (!IsSelectionOwner(selection_event.selection)) {
- selection_event.property = x11::None;
+ if (!IsSelectionOwner(static_cast<uint32_t>(selection_event.selection))) {
+ selection_event.property = x11::Atom::None;
} else {
- selection_event.property = static_cast<uint32_t>(property);
- if (selection_event.target == targets_atom_) {
- SendTargetsResponse(selection_event.requestor, selection_event.property);
- } else if (selection_event.target == timestamp_atom_) {
- SendTimestampResponse(selection_event.requestor,
- selection_event.property);
- } else if (selection_event.target == utf8_string_atom_ ||
- selection_event.target ==
- static_cast<uint32_t>(x11::Atom::STRING)) {
- SendStringResponse(selection_event.requestor, selection_event.property,
- selection_event.target);
+ selection_event.property = property;
+ if (selection_event.target == static_cast<x11::Atom>(targets_atom_)) {
+ SendTargetsResponse(static_cast<uint32_t>(selection_event.requestor),
+ static_cast<uint32_t>(selection_event.property));
+ } else if (selection_event.target ==
+ static_cast<x11::Atom>(timestamp_atom_)) {
+ SendTimestampResponse(static_cast<uint32_t>(selection_event.requestor),
+ static_cast<uint32_t>(selection_event.property));
+ } else if (selection_event.target ==
+ static_cast<x11::Atom>(utf8_string_atom_) ||
+ selection_event.target == x11::Atom::STRING) {
+ SendStringResponse(static_cast<uint32_t>(selection_event.requestor),
+ static_cast<uint32_t>(selection_event.property),
+ static_cast<uint32_t>(selection_event.target));
}
}
- XSendEvent(connection_->display(), selection_event.requestor, x11::False, 0,
- reinterpret_cast<XEvent*>(&selection_event));
+ x11::SendEvent(selection_event, selection_event.requestor,
+ x11::EventMask::NoEvent, connection_);
}
void XServerClipboard::OnSelectionClear(const x11::SelectionClearEvent& event) {
diff --git a/third_party/khronos/EGL/eglplatform.h b/third_party/khronos/EGL/eglplatform.h
index cf2ce0c4..af5ef0c 100644
--- a/third_party/khronos/EGL/eglplatform.h
+++ b/third_party/khronos/EGL/eglplatform.h
@@ -102,8 +102,10 @@
#elif defined(__unix__)
/* X11 (tentative) */
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
+typedef unsigned long XID;
+typedef XID Pixmap;
+typedef XID Window;
+typedef struct _XDisplay Display;
typedef Display *EGLNativeDisplayType;
typedef Pixmap EGLNativePixmapType;
diff --git a/third_party/khronos/README.chromium b/third_party/khronos/README.chromium
index 1a2c737..775ab95 100644
--- a/third_party/khronos/README.chromium
+++ b/third_party/khronos/README.chromium
@@ -32,6 +32,7 @@
EGL/eglplatform.h
- Added EGLNative*Type for Mac.
- Added EGLNative*Type for native linux framebuffers.
+ - Forward declare Xlib types instead of including Xlib headers.
EGL/eglext.h
- Added support for EGL_EXT_image_flush_external extension
- Added support for EGL_ANGLE_stream_producer_d3d_texture
diff --git a/third_party/xcbproto/patch.diff b/third_party/xcbproto/patch.diff
index 07e441c..d68df533 100644
--- a/third_party/xcbproto/patch.diff
+++ b/third_party/xcbproto/patch.diff
@@ -1,6 +1,71 @@
+diff -ru xcbproto/src/glx.xml src/src/glx.xml
+--- xcbproto/src/glx.xml 2020-09-04 10:01:19.893846873 -0700
++++ src/src/glx.xml 2020-09-04 10:00:42.997648219 -0700
+@@ -214,27 +214,27 @@
+
+ <!-- Enum for CopyContext: mask -->
+ <enum name="GC">
+- <item name="GL_CURRENT_BIT"><bit>0</bit></item>
+- <item name="GL_POINT_BIT"><bit>1</bit></item>
+- <item name="GL_LINE_BIT"><bit>2</bit></item>
+- <item name="GL_POLYGON_BIT"><bit>3</bit></item>
+- <item name="GL_POLYGON_STIPPLE_BIT"><bit>4</bit></item>
+- <item name="GL_PIXEL_MODE_BIT"><bit>5</bit></item>
+- <item name="GL_LIGHTING_BIT"><bit>6</bit></item>
+- <item name="GL_FOG_BIT"><bit>7</bit></item>
+- <item name="GL_DEPTH_BUFFER_BIT"><bit>8</bit></item>
+- <item name="GL_ACCUM_BUFFER_BIT"><bit>9</bit></item>
+- <item name="GL_STENCIL_BUFFER_BIT"><bit>10</bit></item>
+- <item name="GL_VIEWPORT_BIT"><bit>11</bit></item>
+- <item name="GL_TRANSFORM_BIT"><bit>12</bit></item>
+- <item name="GL_ENABLE_BIT"><bit>13</bit></item>
+- <item name="GL_COLOR_BUFFER_BIT"><bit>14</bit></item>
+- <item name="GL_HINT_BIT"><bit>15</bit></item>
+- <item name="GL_EVAL_BIT"><bit>16</bit></item>
+- <item name="GL_LIST_BIT"><bit>17</bit></item>
+- <item name="GL_TEXTURE_BIT"><bit>18</bit></item>
+- <item name="GL_SCISSOR_BIT"><bit>19</bit></item>
+- <item name="GL_ALL_ATTRIB_BITS"><value>16777215<!--0x000ffffff--></value></item>
++ <item name="XPROTO_GL_CURRENT_BIT"><bit>0</bit></item>
++ <item name="XPROTO_GL_POINT_BIT"><bit>1</bit></item>
++ <item name="XPROTO_GL_LINE_BIT"><bit>2</bit></item>
++ <item name="XPROTO_GL_POLYGON_BIT"><bit>3</bit></item>
++ <item name="XPROTO_GL_POLYGON_STIPPLE_BIT"><bit>4</bit></item>
++ <item name="XPROTO_GL_PIXEL_MODE_BIT"><bit>5</bit></item>
++ <item name="XPROTO_GL_LIGHTING_BIT"><bit>6</bit></item>
++ <item name="XPROTO_GL_FOG_BIT"><bit>7</bit></item>
++ <item name="XPROTO_GL_DEPTH_BUFFER_BIT"><bit>8</bit></item>
++ <item name="XPROTO_GL_ACCUM_BUFFER_BIT"><bit>9</bit></item>
++ <item name="XPROTO_GL_STENCIL_BUFFER_BIT"><bit>10</bit></item>
++ <item name="XPROTO_GL_VIEWPORT_BIT"><bit>11</bit></item>
++ <item name="XPROTO_GL_TRANSFORM_BIT"><bit>12</bit></item>
++ <item name="XPROTO_GL_ENABLE_BIT"><bit>13</bit></item>
++ <item name="XPROTO_GL_COLOR_BUFFER_BIT"><bit>14</bit></item>
++ <item name="XPROTO_GL_HINT_BIT"><bit>15</bit></item>
++ <item name="XPROTO_GL_EVAL_BIT"><bit>16</bit></item>
++ <item name="XPROTO_GL_LIST_BIT"><bit>17</bit></item>
++ <item name="XPROTO_GL_TEXTURE_BIT"><bit>18</bit></item>
++ <item name="XPROTO_GL_SCISSOR_BIT"><bit>19</bit></item>
++ <item name="XPROTO_GL_ALL_ATTRIB_BITS"><value>16777215<!--0x000ffffff--></value></item>
+ </enum>
+
+ <request name="SwapBuffers" opcode="11">
+@@ -594,9 +594,9 @@
+ </request>
+
+ <enum name="RM">
+- <item name="GL_RENDER"><value>7168</value></item>
+- <item name="GL_FEEDBACK"><value>7169</value></item>
+- <item name="GL_SELECT"><value>7170</value></item>
++ <item name="XPROTO_GL_RENDER"><value>7168</value></item>
++ <item name="XPROTO_GL_FEEDBACK"><value>7169</value></item>
++ <item name="XPROTO_GL_SELECT"><value>7170</value></item>
+ </enum>
+
+ <request name="Finish" opcode="108">
diff -ru xcbproto/src/randr.xml src/src/randr.xml
---- xcbproto/src/randr.xml 2020-08-13 11:56:17.249075684 -0700
-+++ src/src/randr.xml 2020-08-03 10:33:29.428868544 -0700
+--- xcbproto/src/randr.xml 2020-09-04 10:01:19.893846873 -0700
++++ src/src/randr.xml 2020-07-07 18:37:12.793121218 -0700
@@ -803,64 +803,6 @@
<item name="Lease"> <value>6</value></item>
</enum>
@@ -174,8 +239,8 @@
</event>
</xcb>
diff -ru xcbproto/src/shm.xml src/src/shm.xml
---- xcbproto/src/shm.xml 2020-08-13 11:56:17.253075706 -0700
-+++ src/src/shm.xml 2020-08-13 11:54:58.612654139 -0700
+--- xcbproto/src/shm.xml 2020-09-04 10:01:19.897846895 -0700
++++ src/src/shm.xml 2020-08-24 11:14:24.865499307 -0700
@@ -78,7 +78,7 @@
<field type="INT16" name="dst_x" />
<field type="INT16" name="dst_y" />
@@ -186,8 +251,8 @@
<pad bytes="1" />
<field type="SEG" name="shmseg" />
diff -ru xcbproto/src/xinput.xml src/src/xinput.xml
---- xcbproto/src/xinput.xml 2020-08-13 11:56:17.253075706 -0700
-+++ src/src/xinput.xml 2020-08-13 11:15:42.336096659 -0700
+--- xcbproto/src/xinput.xml 2020-09-04 10:01:19.897846895 -0700
++++ src/src/xinput.xml 2020-08-24 11:14:24.865499307 -0700
@@ -200,7 +200,12 @@
<list type="STR" name="names">
<fieldref>devices_len</fieldref>
@@ -213,8 +278,8 @@
<item name="AllMaster"> <value>1</value> </item>
</enum>
diff -ru xcbproto/src/xproto.xml src/src/xproto.xml
---- xcbproto/src/xproto.xml 2020-08-13 11:56:17.253075706 -0700
-+++ src/src/xproto.xml 2020-08-03 10:33:29.428868544 -0700
+--- xcbproto/src/xproto.xml 2020-09-04 10:01:19.897846895 -0700
++++ src/src/xproto.xml 2020-07-30 12:03:48.681938397 -0700
@@ -4686,7 +4686,7 @@
<field type="CARD8" name="left_pad" />
<field type="CARD8" name="depth" />
@@ -233,3 +298,10 @@
<op op="*">
<fieldref>length</fieldref>
<value>4</value>
+Only in src/xcbgen: align.pyc
+Only in src/xcbgen: error.pyc
+Only in src/xcbgen: expr.pyc
+Only in src/xcbgen: __init__.pyc
+Only in src/xcbgen: matcher.pyc
+Only in src/xcbgen: state.pyc
+Only in src/xcbgen: xtypes.pyc
diff --git a/third_party/xcbproto/src/src/glx.xml b/third_party/xcbproto/src/src/glx.xml
index 2e50aea..802b2b3 100644
--- a/third_party/xcbproto/src/src/glx.xml
+++ b/third_party/xcbproto/src/src/glx.xml
@@ -214,27 +214,27 @@
<!-- Enum for CopyContext: mask -->
<enum name="GC">
- <item name="GL_CURRENT_BIT"><bit>0</bit></item>
- <item name="GL_POINT_BIT"><bit>1</bit></item>
- <item name="GL_LINE_BIT"><bit>2</bit></item>
- <item name="GL_POLYGON_BIT"><bit>3</bit></item>
- <item name="GL_POLYGON_STIPPLE_BIT"><bit>4</bit></item>
- <item name="GL_PIXEL_MODE_BIT"><bit>5</bit></item>
- <item name="GL_LIGHTING_BIT"><bit>6</bit></item>
- <item name="GL_FOG_BIT"><bit>7</bit></item>
- <item name="GL_DEPTH_BUFFER_BIT"><bit>8</bit></item>
- <item name="GL_ACCUM_BUFFER_BIT"><bit>9</bit></item>
- <item name="GL_STENCIL_BUFFER_BIT"><bit>10</bit></item>
- <item name="GL_VIEWPORT_BIT"><bit>11</bit></item>
- <item name="GL_TRANSFORM_BIT"><bit>12</bit></item>
- <item name="GL_ENABLE_BIT"><bit>13</bit></item>
- <item name="GL_COLOR_BUFFER_BIT"><bit>14</bit></item>
- <item name="GL_HINT_BIT"><bit>15</bit></item>
- <item name="GL_EVAL_BIT"><bit>16</bit></item>
- <item name="GL_LIST_BIT"><bit>17</bit></item>
- <item name="GL_TEXTURE_BIT"><bit>18</bit></item>
- <item name="GL_SCISSOR_BIT"><bit>19</bit></item>
- <item name="GL_ALL_ATTRIB_BITS"><value>16777215<!--0x000ffffff--></value></item>
+ <item name="XPROTO_GL_CURRENT_BIT"><bit>0</bit></item>
+ <item name="XPROTO_GL_POINT_BIT"><bit>1</bit></item>
+ <item name="XPROTO_GL_LINE_BIT"><bit>2</bit></item>
+ <item name="XPROTO_GL_POLYGON_BIT"><bit>3</bit></item>
+ <item name="XPROTO_GL_POLYGON_STIPPLE_BIT"><bit>4</bit></item>
+ <item name="XPROTO_GL_PIXEL_MODE_BIT"><bit>5</bit></item>
+ <item name="XPROTO_GL_LIGHTING_BIT"><bit>6</bit></item>
+ <item name="XPROTO_GL_FOG_BIT"><bit>7</bit></item>
+ <item name="XPROTO_GL_DEPTH_BUFFER_BIT"><bit>8</bit></item>
+ <item name="XPROTO_GL_ACCUM_BUFFER_BIT"><bit>9</bit></item>
+ <item name="XPROTO_GL_STENCIL_BUFFER_BIT"><bit>10</bit></item>
+ <item name="XPROTO_GL_VIEWPORT_BIT"><bit>11</bit></item>
+ <item name="XPROTO_GL_TRANSFORM_BIT"><bit>12</bit></item>
+ <item name="XPROTO_GL_ENABLE_BIT"><bit>13</bit></item>
+ <item name="XPROTO_GL_COLOR_BUFFER_BIT"><bit>14</bit></item>
+ <item name="XPROTO_GL_HINT_BIT"><bit>15</bit></item>
+ <item name="XPROTO_GL_EVAL_BIT"><bit>16</bit></item>
+ <item name="XPROTO_GL_LIST_BIT"><bit>17</bit></item>
+ <item name="XPROTO_GL_TEXTURE_BIT"><bit>18</bit></item>
+ <item name="XPROTO_GL_SCISSOR_BIT"><bit>19</bit></item>
+ <item name="XPROTO_GL_ALL_ATTRIB_BITS"><value>16777215<!--0x000ffffff--></value></item>
</enum>
<request name="SwapBuffers" opcode="11">
@@ -594,9 +594,9 @@
</request>
<enum name="RM">
- <item name="GL_RENDER"><value>7168</value></item>
- <item name="GL_FEEDBACK"><value>7169</value></item>
- <item name="GL_SELECT"><value>7170</value></item>
+ <item name="XPROTO_GL_RENDER"><value>7168</value></item>
+ <item name="XPROTO_GL_FEEDBACK"><value>7169</value></item>
+ <item name="XPROTO_GL_SELECT"><value>7170</value></item>
</enum>
<request name="Finish" opcode="108">
diff --git a/ui/aura/BUILD.gn b/ui/aura/BUILD.gn
index c1dbce0d..0db9a6a 100644
--- a/ui/aura/BUILD.gn
+++ b/ui/aura/BUILD.gn
@@ -255,7 +255,6 @@
sources += [
"test/ui_controls_aurax11.cc",
"test/ui_controls_aurax11.h",
- "test/x11_event_sender.cc",
"test/x11_event_sender.h",
]
diff --git a/ui/aura/test/ui_controls_aurax11.cc b/ui/aura/test/ui_controls_aurax11.cc
index c0ef179..e81995f 100644
--- a/ui/aura/test/ui_controls_aurax11.cc
+++ b/ui/aura/test/ui_controls_aurax11.cc
@@ -4,6 +4,10 @@
#include "ui/aura/test/ui_controls_aurax11.h"
+#include "ui/gfx/x/connection.h"
+#include "ui/gfx/x/keysyms/keysyms.h"
+#include "ui/gfx/x/xproto.h"
+
namespace aura {
namespace test {
namespace {
@@ -42,9 +46,9 @@
bool alt,
bool command,
base::OnceClosure closure) {
- XEvent xevent;
- xevent.xkey = {};
- xevent.xkey.type = x11::KeyEvent::Press;
+ x11::KeyEvent xevent;
+ xevent.detail = {};
+ xevent.opcode = x11::KeyEvent::Press;
if (control)
SetKeycodeAndSendThenMask(&xevent, XK_Control_L, ControlMask);
if (shift)
@@ -53,13 +57,13 @@
SetKeycodeAndSendThenMask(&xevent, XK_Alt_L, Mod1Mask);
if (command)
SetKeycodeAndSendThenMask(&xevent, XK_Meta_L, Mod4Mask);
- xevent.xkey.keycode = XKeysymToKeycode(
- gfx::GetXDisplay(), ui::XKeysymForWindowsKeyCode(key, shift));
- PostEventToWindowTreeHost(xevent, host_);
+ xevent.detail = x11::Connection::Get()->KeysymToKeycode(
+ static_cast<x11::KeySym>(ui::XKeysymForWindowsKeyCode(key, shift)));
+ PostEventToWindowTreeHost(host_, &xevent);
// Send key release events.
- xevent.xkey.type = x11::KeyEvent::Release;
- PostEventToWindowTreeHost(xevent, host_);
+ xevent.opcode = x11::KeyEvent::Release;
+ PostEventToWindowTreeHost(host_, &xevent);
if (alt)
UnmaskAndSetKeycodeThenSend(&xevent, Mod1Mask, XK_Alt_L);
if (shift)
@@ -68,7 +72,7 @@
UnmaskAndSetKeycodeThenSend(&xevent, ControlMask, XK_Control_L);
if (command)
UnmaskAndSetKeycodeThenSend(&xevent, Mod4Mask, XK_Meta_L);
- DCHECK(!xevent.xkey.state);
+ DCHECK_EQ(xevent.state, x11::KeyButMask{});
RunClosureAfterAllPendingUIEvents(std::move(closure));
return true;
}
@@ -96,16 +100,14 @@
// current mouse position as a result of XGrabPointer()
host_->window()->MoveCursorTo(root_location);
} else {
- XEvent xevent;
- xevent.xmotion = {};
- XMotionEvent* xmotion = &xevent.xmotion;
- xmotion->type = MotionNotify;
- xmotion->x = root_location.x();
- xmotion->y = root_location.y();
- xmotion->state = button_down_mask;
- xmotion->same_screen = x11::True;
+ x11::MotionNotifyEvent xevent{
+ .event_x = root_location.x(),
+ .event_y = root_location.y(),
+ .state = static_cast<x11::KeyButMask>(button_down_mask),
+ .same_screen = true,
+ };
// WindowTreeHost will take care of other necessary fields.
- PostEventToWindowTreeHost(xevent, host_);
+ PostEventToWindowTreeHost(host_, &xevent);
}
RunClosureAfterAllPendingUIEvents(std::move(closure));
return true;
@@ -122,53 +124,51 @@
int button_state,
base::OnceClosure closure,
int accelerator_state) {
- XEvent xevent;
- xevent.xbutton = {};
- XButtonEvent* xbutton = &xevent.xbutton;
+ x11::ButtonEvent xevent;
gfx::Point mouse_loc = Env::GetInstance()->last_mouse_location();
aura::client::ScreenPositionClient* screen_position_client =
aura::client::GetScreenPositionClient(host_->window());
if (screen_position_client) {
screen_position_client->ConvertPointFromScreen(host_->window(), &mouse_loc);
}
- xbutton->x = mouse_loc.x();
- xbutton->y = mouse_loc.y();
- xbutton->same_screen = x11::True;
+ xevent.event_x = mouse_loc.x();
+ xevent.event_y = mouse_loc.y();
switch (type) {
case LEFT:
- xbutton->button = 1;
- xbutton->state = Button1Mask;
+ xevent.detail = static_cast<x11::Button>(1);
+ xevent.state = x11::KeyButMask::Button1;
break;
case MIDDLE:
- xbutton->button = 2;
- xbutton->state = Button2Mask;
+ xevent.detail = static_cast<x11::Button>(2);
+ xevent.state = x11::KeyButMask::Button2;
break;
case RIGHT:
- xbutton->button = 3;
- xbutton->state = Button3Mask;
+ xevent.detail = static_cast<x11::Button>(3);
+ xevent.state = x11::KeyButMask::Button3;
break;
}
// Process accelerator key state.
if (accelerator_state & ui_controls::kShift)
- xbutton->state |= ShiftMask;
+ xevent.state = xevent.state | x11::KeyButMask::Shift;
if (accelerator_state & ui_controls::kControl)
- xbutton->state |= ControlMask;
+ xevent.state = xevent.state | x11::KeyButMask::Control;
if (accelerator_state & ui_controls::kAlt)
- xbutton->state |= Mod1Mask;
+ xevent.state = xevent.state | x11::KeyButMask::Mod1;
if (accelerator_state & ui_controls::kCommand)
- xbutton->state |= Mod4Mask;
+ xevent.state = xevent.state | x11::KeyButMask::Mod4;
// WindowEventDispatcher will take care of other necessary fields.
if (button_state & DOWN) {
- xevent.xbutton.type = x11::ButtonEvent::Press;
- PostEventToWindowTreeHost(xevent, host_);
- button_down_mask |= xbutton->state;
+ xevent.opcode = x11::ButtonEvent::Press;
+ PostEventToWindowTreeHost(host_, &xevent);
+ button_down_mask |= static_cast<int>(xevent.state);
}
if (button_state & UP) {
- xevent.xbutton.type = x11::ButtonEvent::Release;
- PostEventToWindowTreeHost(xevent, host_);
- button_down_mask = (button_down_mask | xbutton->state) ^ xbutton->state;
+ xevent.opcode = x11::ButtonEvent::Release;
+ PostEventToWindowTreeHost(host_, &xevent);
+ int state = static_cast<int>(xevent.state);
+ button_down_mask = (button_down_mask | state) ^ state;
}
RunClosureAfterAllPendingUIEvents(std::move(closure));
return true;
@@ -187,20 +187,23 @@
std::move(closure));
}
-void UIControlsX11::SetKeycodeAndSendThenMask(XEvent* xevent,
+void UIControlsX11::SetKeycodeAndSendThenMask(x11::KeyEvent* xevent,
KeySym keysym,
unsigned int mask) {
- xevent->xkey.keycode = XKeysymToKeycode(gfx::GetXDisplay(), keysym);
- PostEventToWindowTreeHost(*xevent, host_);
- xevent->xkey.state |= mask;
+ xevent->detail =
+ x11::Connection::Get()->KeysymToKeycode(static_cast<x11::KeySym>(keysym));
+ PostEventToWindowTreeHost(host_, xevent);
+ xevent->state = xevent->state | static_cast<x11::KeyButMask>(mask);
}
-void UIControlsX11::UnmaskAndSetKeycodeThenSend(XEvent* xevent,
+void UIControlsX11::UnmaskAndSetKeycodeThenSend(x11::KeyEvent* xevent,
unsigned int mask,
KeySym keysym) {
- xevent->xkey.state ^= mask;
- xevent->xkey.keycode = XKeysymToKeycode(gfx::GetXDisplay(), keysym);
- PostEventToWindowTreeHost(*xevent, host_);
+ xevent->state =
+ static_cast<x11::KeyButMask>(static_cast<uint32_t>(xevent->state) ^ mask);
+ xevent->detail =
+ x11::Connection::Get()->KeysymToKeycode(static_cast<x11::KeySym>(keysym));
+ PostEventToWindowTreeHost(host_, xevent);
}
} // namespace test
diff --git a/ui/aura/test/ui_controls_aurax11.h b/ui/aura/test/ui_controls_aurax11.h
index 71cbf13..b6ec2eb8 100644
--- a/ui/aura/test/ui_controls_aurax11.h
+++ b/ui/aura/test/ui_controls_aurax11.h
@@ -64,11 +64,11 @@
void RunClosureAfterAllPendingUIEvents(base::OnceClosure closure);
private:
- void SetKeycodeAndSendThenMask(XEvent* xevent,
+ void SetKeycodeAndSendThenMask(x11::KeyEvent* xevent,
KeySym keysym,
unsigned int mask);
- void UnmaskAndSetKeycodeThenSend(XEvent* xevent,
+ void UnmaskAndSetKeycodeThenSend(x11::KeyEvent* xevent,
unsigned int mask,
KeySym keysym);
WindowTreeHost* const host_;
diff --git a/ui/aura/test/x11_event_sender.cc b/ui/aura/test/x11_event_sender.cc
deleted file mode 100644
index 7c47b65..0000000
--- a/ui/aura/test/x11_event_sender.cc
+++ /dev/null
@@ -1,49 +0,0 @@
-// Copyright 2014 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.
-
-#include "ui/aura/test/x11_event_sender.h"
-
-#include "ui/aura/window_tree_host.h"
-#include "ui/gfx/geometry/point.h"
-#include "ui/gfx/x/x11.h"
-
-namespace aura {
-namespace test {
-
-void PostEventToWindowTreeHost(const XEvent& xevent, WindowTreeHost* host) {
- XDisplay* xdisplay = gfx::GetXDisplay();
- x11::Window xwindow = static_cast<x11::Window>(host->GetAcceleratedWidget());
- XEvent event = xevent;
- event.xany.display = xdisplay;
- event.xany.window = static_cast<uint32_t>(xwindow);
-
- switch (event.type) {
- case x11::CrossingEvent::EnterNotify:
- case x11::CrossingEvent::LeaveNotify:
- case x11::MotionNotifyEvent::opcode:
- case x11::KeyEvent::Press:
- case x11::KeyEvent::Release:
- case x11::ButtonEvent::Press:
- case x11::ButtonEvent::Release: {
- // The fields used below are in the same place for all of events
- // above. Using xmotion from XEvent's unions to avoid repeating
- // the code.
- event.xmotion.root = DefaultRootWindow(event.xany.display);
- event.xmotion.time = x11::CurrentTime;
-
- gfx::Point point(event.xmotion.x, event.xmotion.y);
- host->ConvertDIPToScreenInPixels(&point);
- event.xmotion.x_root = point.x();
- event.xmotion.y_root = point.y();
- break;
- }
- default:
- break;
- }
- XSendEvent(xdisplay, static_cast<uint32_t>(xwindow), x11::False, 0, &event);
- XFlush(xdisplay);
-}
-
-} // namespace test
-} // namespace aura
diff --git a/ui/aura/test/x11_event_sender.h b/ui/aura/test/x11_event_sender.h
index 64720ac..b97d77c4 100644
--- a/ui/aura/test/x11_event_sender.h
+++ b/ui/aura/test/x11_event_sender.h
@@ -5,17 +5,34 @@
#ifndef UI_AURA_TEST_X11_EVENT_SENDER_H_
#define UI_AURA_TEST_X11_EVENT_SENDER_H_
-#include "ui/gfx/x/x11_types.h"
-
-using XEvent = union _XEvent;
+#include "ui/aura/window_tree_host.h"
+#include "ui/base/x/x11_util.h"
+#include "ui/gfx/geometry/point.h"
+#include "ui/gfx/x/connection.h"
+#include "ui/gfx/x/xproto_util.h"
namespace aura {
-class WindowTreeHost;
-
namespace test {
-void PostEventToWindowTreeHost(const XEvent& xevent, WindowTreeHost* host);
+// The root, time, root_x, and root_y fields of |xevent| may be modified.
+template <typename T>
+void PostEventToWindowTreeHost(WindowTreeHost* host, T* xevent) {
+ auto* connection = x11::Connection::Get();
+ x11::Window xwindow = static_cast<x11::Window>(host->GetAcceleratedWidget());
+ xevent->event = xwindow;
+
+ xevent->root = connection->default_root();
+ xevent->time = x11::Time::CurrentTime;
+
+ gfx::Point point(xevent->event_x, xevent->event_y);
+ host->ConvertDIPToScreenInPixels(&point);
+ xevent->root_x = point.x();
+ xevent->root_y = point.y();
+
+ x11::SendEvent(*xevent, xwindow, x11::EventMask::NoEvent);
+ connection->Flush();
+}
} // namespace test
} // namespace aura
diff --git a/ui/base/x/selection_owner.cc b/ui/base/x/selection_owner.cc
index a19d570..0c9804a 100644
--- a/ui/base/x/selection_owner.cc
+++ b/ui/base/x/selection_owner.cc
@@ -15,6 +15,7 @@
#include "ui/gfx/x/x11.h"
#include "ui/gfx/x/x11_atom_cache.h"
#include "ui/gfx/x/xproto.h"
+#include "ui/gfx/x/xproto_util.h"
namespace ui {
@@ -160,7 +161,7 @@
}
// Send off the reply.
- ui::SendEvent(reply, requestor, x11::EventMask::NoEvent);
+ x11::SendEvent(reply, requestor, x11::EventMask::NoEvent);
}
void SelectionOwner::OnSelectionClear(const x11::Event& event) {
diff --git a/ui/base/x/x11_drag_drop_client.cc b/ui/base/x/x11_drag_drop_client.cc
index 3eccf0b..f99af79 100644
--- a/ui/base/x/x11_drag_drop_client.cc
+++ b/ui/base/x/x11_drag_drop_client.cc
@@ -13,6 +13,7 @@
#include "ui/gfx/x/connection.h"
#include "ui/gfx/x/x11_atom_cache.h"
#include "ui/gfx/x/xproto.h"
+#include "ui/gfx/x/xproto_util.h"
// Reading recommended for understanding the implementation in this file:
//
@@ -623,7 +624,7 @@
//
// I'm unsure if I have to jump through those hoops, or if XSendEvent is
// sufficient.
- ui::SendEvent(xev, window, x11::EventMask::NoEvent);
+ x11::SendEvent(xev, window, x11::EventMask::NoEvent);
}
void XDragDropClient::SendXdndEnter(x11::Window dest_window,
diff --git a/ui/base/x/x11_shm_image_pool.cc b/ui/base/x/x11_shm_image_pool.cc
index 1d399cce..940e6fc 100644
--- a/ui/base/x/x11_shm_image_pool.cc
+++ b/ui/base/x/x11_shm_image_pool.cc
@@ -70,7 +70,7 @@
// codepath. It may be possible in contrived cases for there to be a
// false-positive, but in that case we'll just fallback to the non-SHM
// codepath.
- char* display_string = DisplayString(connection->display());
+ char* display_string = XDisplayString(connection->display());
char* host = nullptr;
int display_id = 0;
int screen = 0;
diff --git a/ui/base/x/x11_util.h b/ui/base/x/x11_util.h
index 6710222..ba04096 100644
--- a/ui/base/x/x11_util.h
+++ b/ui/base/x/x11_util.h
@@ -195,23 +195,6 @@
SetArrayProperty(window, name, type, std::vector<T>{value});
}
-template <typename T>
-x11::Future<void> SendEvent(const T& event,
- x11::Window target,
- x11::EventMask mask) {
- static_assert(T::type_id > 0, "T must be an x11::*Event type");
- auto write_buffer = x11::Write(event);
- DCHECK_EQ(write_buffer.GetBuffers().size(), 1ul);
- auto& first_buffer = write_buffer.GetBuffers()[0];
- DCHECK_LE(first_buffer->size(), 32ul);
- std::vector<uint8_t> event_bytes(32);
- memcpy(event_bytes.data(), first_buffer->data(), first_buffer->size());
-
- x11::SendEventRequest send_event{false, target, mask};
- std::copy(event_bytes.begin(), event_bytes.end(), send_event.event.begin());
- return x11::Connection::Get()->SendEvent(send_event);
-}
-
COMPONENT_EXPORT(UI_BASE_X)
void DeleteProperty(x11::Window window, x11::Atom name);
diff --git a/ui/base/x/x11_window.cc b/ui/base/x/x11_window.cc
index 7a1d549e..28ff5ac0 100644
--- a/ui/base/x/x11_window.cc
+++ b/ui/base/x/x11_window.cc
@@ -40,6 +40,7 @@
#include "ui/gfx/x/xfixes.h"
#include "ui/gfx/x/xinput.h"
#include "ui/gfx/x/xproto.h"
+#include "ui/gfx/x/xproto_util.h"
#include "ui/platform_window/common/platform_window_defaults.h"
namespace ui {
@@ -1160,9 +1161,9 @@
} else if (protocol == gfx::GetAtom("_NET_WM_PING")) {
x11::ClientMessageEvent reply_event = *client;
reply_event.window = x_root_window_;
- SendEvent(reply_event, x_root_window_,
- x11::EventMask::SubstructureNotify |
- x11::EventMask::SubstructureRedirect);
+ x11::SendEvent(reply_event, x_root_window_,
+ x11::EventMask::SubstructureNotify |
+ x11::EventMask::SubstructureRedirect);
} else if (protocol == gfx::GetAtom("_NET_WM_SYNC_REQUEST")) {
pending_counter_value_ =
client->data.data32[2] +
diff --git a/ui/base/x/xwmstartupcheck/xwmstartupcheck.cc b/ui/base/x/xwmstartupcheck/xwmstartupcheck.cc
index 3a18a8e..3c55fbc 100644
--- a/ui/base/x/xwmstartupcheck/xwmstartupcheck.cc
+++ b/ui/base/x/xwmstartupcheck/xwmstartupcheck.cc
@@ -57,7 +57,7 @@
connection.MapWindow({dummy_window});
connection.Flush();
- int display_fd = ConnectionNumber(connection.display());
+ int display_fd = XConnectionNumber(connection.display());
// Set deadline as 30s.
struct timespec now, deadline;
diff --git a/ui/compositor/test/test_compositor_host_x11.cc b/ui/compositor/test/test_compositor_host_x11.cc
index cff7ee7..50ab8f7 100644
--- a/ui/compositor/test/test_compositor_host_x11.cc
+++ b/ui/compositor/test/test_compositor_host_x11.cc
@@ -30,7 +30,7 @@
XSetWindowAttributes swa;
swa.override_redirect = x11::True;
window_ = static_cast<x11::Window>(XCreateWindow(
- display, XRootWindow(display, DefaultScreen(display)), // parent
+ display, XDefaultRootWindow(display), // parent
bounds_.x(), bounds_.y(), bounds_.width(), bounds_.height(),
0, // border width
static_cast<int>(x11::WindowClass::CopyFromParent), // depth
diff --git a/ui/events/blink/web_input_event_unittest.cc b/ui/events/blink/web_input_event_unittest.cc
index fa2a62e..c5efbf15 100644
--- a/ui/events/blink/web_input_event_unittest.cc
+++ b/ui/events/blink/web_input_event_unittest.cc
@@ -26,6 +26,7 @@
#include "ui/events/test/events_test_utils_x11.h" // nogncheck
#include "ui/events/x/x11_event_translation.h" // nogncheck
#include "ui/gfx/x/event.h" // nogncheck
+#include "ui/gfx/x/keysyms/keysyms.h" // nogncheck
#include "ui/gfx/x/x11.h" // nogncheck
#include "ui/gfx/x/x11_types.h" // nogncheck
#include "ui/gfx/x/xproto.h" // nogncheck
diff --git a/ui/events/keycodes/BUILD.gn b/ui/events/keycodes/BUILD.gn
index 12f3abf..4aae406 100644
--- a/ui/events/keycodes/BUILD.gn
+++ b/ui/events/keycodes/BUILD.gn
@@ -14,16 +14,15 @@
"xkb_keysym.h",
]
- public_deps = [ "//ui/base:buildflags" ]
+ public_deps = [
+ "//ui/base:buildflags",
+ "//ui/gfx/x/keysyms",
+ ]
deps = [
"//base",
"//ui/events:dom_keycode_converter",
]
-
- if (!use_xkbcommon) {
- public_deps += [ "//ui/gfx/x" ]
- }
}
if (use_x11 || ozone_platform_x11) {
diff --git a/ui/events/keycodes/keyboard_code_conversion_x.cc b/ui/events/keycodes/keyboard_code_conversion_x.cc
index 36714ac..4a99e29 100644
--- a/ui/events/keycodes/keyboard_code_conversion_x.cc
+++ b/ui/events/keycodes/keyboard_code_conversion_x.cc
@@ -17,6 +17,8 @@
#include "ui/events/keycodes/keyboard_code_conversion_xkb.h"
#include "ui/events/keycodes/keyboard_codes_posix.h"
#include "ui/events/keycodes/keysym_to_unicode.h"
+#include "ui/events/keycodes/xkb_keysym.h"
+#include "ui/gfx/x/keysyms/keysyms.h"
#include "ui/gfx/x/x11.h"
#include "ui/gfx/x/xinput.h"
#include "ui/gfx/x/xproto.h"
diff --git a/ui/events/keycodes/keyboard_code_conversion_xkb.cc b/ui/events/keycodes/keyboard_code_conversion_xkb.cc
index 4b95e75..cd1135e 100644
--- a/ui/events/keycodes/keyboard_code_conversion_xkb.cc
+++ b/ui/events/keycodes/keyboard_code_conversion_xkb.cc
@@ -6,10 +6,8 @@
#include "build/build_config.h"
#include "ui/events/keycodes/dom/dom_key.h"
-
-#ifndef XK_dead_greek
-#define XK_dead_greek 0xfe8c
-#endif
+#include "ui/events/keycodes/keyboard_code_conversion_xkb.h"
+#include "ui/gfx/x/keysyms/keysyms.h"
namespace ui {
diff --git a/ui/events/keycodes/keysym_to_unicode.cc b/ui/events/keycodes/keysym_to_unicode.cc
index 804afa15..72de4717 100644
--- a/ui/events/keycodes/keysym_to_unicode.cc
+++ b/ui/events/keycodes/keysym_to_unicode.cc
@@ -8,6 +8,7 @@
#include "base/lazy_instance.h"
#include "base/stl_util.h"
+#include "ui/gfx/x/keysyms/keysyms.h"
#include "ui/gfx/x/x11.h"
namespace ui {
diff --git a/ui/events/keycodes/xkb_keysym.h b/ui/events/keycodes/xkb_keysym.h
index c2baef31..535b467 100644
--- a/ui/events/keycodes/xkb_keysym.h
+++ b/ui/events/keycodes/xkb_keysym.h
@@ -17,7 +17,7 @@
#else // !BUILDFLAG(USE_XKBCOMMON)
-#include "ui/gfx/x/x11.h" // nogncheck
+#include "ui/gfx/x/keysyms/keysyms.h"
using xkb_keysym_t = uint32_t;
diff --git a/ui/events/platform/x11/x11_event_watcher_fdwatch.cc b/ui/events/platform/x11/x11_event_watcher_fdwatch.cc
index b71d1ca8..d97b6ca 100644
--- a/ui/events/platform/x11/x11_event_watcher_fdwatch.cc
+++ b/ui/events/platform/x11/x11_event_watcher_fdwatch.cc
@@ -22,7 +22,7 @@
DCHECK(event_source_->connection()) << "Unable to get connection to X server";
- int fd = ConnectionNumber(event_source_->connection()->display());
+ int fd = XConnectionNumber(event_source_->connection()->display());
base::CurrentUIThread::Get()->WatchFileDescriptor(
fd, true, base::MessagePumpForUI::WATCH_READ, &watcher_controller_, this);
started_ = true;
diff --git a/ui/events/platform/x11/x11_event_watcher_glib.cc b/ui/events/platform/x11/x11_event_watcher_glib.cc
index 17d73895..9665cf4 100644
--- a/ui/events/platform/x11/x11_event_watcher_glib.cc
+++ b/ui/events/platform/x11/x11_event_watcher_glib.cc
@@ -65,7 +65,7 @@
return;
x_poll_ = std::make_unique<GPollFD>();
- x_poll_->fd = ConnectionNumber(display);
+ x_poll_->fd = XConnectionNumber(display);
x_poll_->events = G_IO_IN;
x_poll_->revents = 0;
diff --git a/ui/events/test/events_test_utils_x11.cc b/ui/events/test/events_test_utils_x11.cc
index 179cd6f..12da0a80 100644
--- a/ui/events/test/events_test_utils_x11.cc
+++ b/ui/events/test/events_test_utils_x11.cc
@@ -116,7 +116,8 @@
event.detail = tracking_id;
event.event_x = ToFp1616(location.x()),
event.event_y = ToFp1616(location.y()),
- event.event = static_cast<x11::Window>(DefaultRootWindow(gfx::GetXDisplay()));
+ event.event =
+ static_cast<x11::Window>(XDefaultRootWindow(gfx::GetXDisplay()));
event.button_mask = {0, 0};
return x11::Event(std::move(event));
}
diff --git a/ui/events/test/x11_event_waiter.cc b/ui/events/test/x11_event_waiter.cc
index 77147826..cb582059 100644
--- a/ui/events/test/x11_event_waiter.cc
+++ b/ui/events/test/x11_event_waiter.cc
@@ -5,29 +5,27 @@
#include "ui/events/test/x11_event_waiter.h"
#include "base/threading/thread_task_runner_handle.h"
+#include "ui/gfx/x/connection.h"
#include "ui/gfx/x/x11.h"
#include "ui/gfx/x/x11_atom_cache.h"
#include "ui/gfx/x/xproto.h"
+#include "ui/gfx/x/xproto_util.h"
namespace ui {
// static
XEventWaiter* XEventWaiter::Create(x11::Window window,
base::OnceClosure callback) {
- Display* display = gfx::GetXDisplay();
- static XEvent* marker_event = nullptr;
- if (!marker_event) {
- marker_event = new XEvent();
- marker_event->xclient.type = ClientMessage;
- marker_event->xclient.display = display;
- marker_event->xclient.window = static_cast<uint32_t>(window);
- marker_event->xclient.format = 8;
- }
- marker_event->xclient.message_type = static_cast<uint32_t>(MarkerEventAtom());
+ auto* connection = x11::Connection::Get();
- XSendEvent(display, static_cast<uint32_t>(window), x11::False, 0,
- marker_event);
- XFlush(display);
+ x11::ClientMessageEvent marker_event{
+ .format = 8,
+ .window = window,
+ .type = MarkerEventAtom(),
+ };
+
+ x11::SendEvent(marker_event, window, x11::EventMask::NoEvent);
+ connection->Flush();
// Will be deallocated when the expected event is received.
return new XEventWaiter(std::move(callback));
diff --git a/ui/gfx/x/BUILD.gn b/ui/gfx/x/BUILD.gn
index 2232d09..6b87f8e 100644
--- a/ui/gfx/x/BUILD.gn
+++ b/ui/gfx/x/BUILD.gn
@@ -65,7 +65,6 @@
foreach(proto, protos) {
sources += [ "$xcbproto_path/src/${proto}.xml" ]
outputs += [
- "$target_gen_dir/${proto}_undef.h",
"$target_gen_dir/${proto}.h",
"$target_gen_dir/${proto}.cc",
]
@@ -85,6 +84,7 @@
"//base:i18n",
"//ui/events/platform",
]
+ public_deps = [ "//ui/gfx/x/keysyms" ]
sources = get_target_outputs(":gen_xprotos") + [
"xproto_internal.h",
"xproto_internal.cc",
diff --git a/ui/gfx/x/connection.cc b/ui/gfx/x/connection.cc
index 0fa7d8a..fda5d1ac 100644
--- a/ui/gfx/x/connection.cc
+++ b/ui/gfx/x/connection.cc
@@ -18,6 +18,7 @@
#include "base/threading/thread_local.h"
#include "ui/gfx/x/bigreq.h"
#include "ui/gfx/x/event.h"
+#include "ui/gfx/x/keysyms/keysyms.h"
#include "ui/gfx/x/randr.h"
#include "ui/gfx/x/x11.h"
#include "ui/gfx/x/x11_switches.h"
@@ -301,7 +302,7 @@
// This is not part of the setup data as the server has no concept of a
// default screen. Instead, it's part of the display name. Eg in
// "localhost:0.0", the screen ID is the second "0".
- return DefaultScreen(display_);
+ return XDefaultScreen(display_);
}
bool Connection::Ready() const {
diff --git a/ui/gfx/x/event.h b/ui/gfx/x/event.h
index 42ef4a3d..44a56013 100644
--- a/ui/gfx/x/event.h
+++ b/ui/gfx/x/event.h
@@ -70,6 +70,10 @@
uint32_t sequence() const { return sequence_; }
x11::Window window() const { return window_ ? *window_ : x11::Window::None; }
+ void set_window(x11::Window window) {
+ if (window_)
+ *window_ = window;
+ }
private:
friend void ReadEvent(Event* event,
diff --git a/ui/gfx/x/gen_xproto.py b/ui/gfx/x/gen_xproto.py
index 0d5c177d..3917794 100644
--- a/ui/gfx/x/gen_xproto.py
+++ b/ui/gfx/x/gen_xproto.py
@@ -236,6 +236,10 @@
('xcb', 'Expose'),
('xcb', 'UnmapNotify'),
('xcb', 'SelectionNotify'),
+ ('xcb', 'MotionNotify'),
+ ('xcb', 'Key'),
+ ('xcb', 'Button'),
+ ('xcb', 'PropertyNotify'),
])
@@ -365,8 +369,6 @@
self.xml_filename = os.path.join(proto_dir, '%s.xml' % proto)
self.header_file = open(os.path.join(gen_dir, '%s.h' % proto), 'w')
self.source_file = open(os.path.join(gen_dir, '%s.cc' % proto), 'w')
- self.undef_file = open(os.path.join(gen_dir, '%s_undef.h' % proto),
- 'w')
# Top-level xcbgen python module
self.xcbgen = xcbgen
@@ -510,12 +512,6 @@
return field
return None
- # Work around conflicts caused by Xlib's liberal use of macros.
- def undef(self, name):
- print('#ifdef %s' % name, file=self.undef_file)
- print('#undef %s' % name, file=self.undef_file)
- print('#endif', file=self.undef_file)
-
def expr(self, expr):
if expr.op == 'popcount':
return 'PopCount(%s)' % self.expr(expr.rhs)
@@ -633,7 +629,11 @@
else:
container_type, container_name = field.parent
assert container_type.is_event
- opcode = container_type.opcodes[container_name]
+ # Extension events require offsetting the opcode, so make
+ # sure this path is only hit for non-extension events for now.
+ assert not self.module.namespace.is_ext
+ opcode = container_type.opcodes.get(container_name,
+ 'obj.opcode')
self.write('%s %s = %s;' % (type_name, name, opcode))
self.copy_primitive(name)
elif name in ('extension', 'error_code', 'event_type'):
@@ -827,10 +827,8 @@
def declare_enum(self, enum):
def declare_enum_entry(name, value):
name = safe_name(name)
- self.undef(name)
self.write('%s = %s,' % (name, value))
- self.undef(enum.name[-1])
with Indent(
self, 'enum class %s : %s {' %
(adjust_type_name(enum.name[-1]), self.enum_types[enum.name][0]
@@ -901,7 +899,6 @@
def declare_event(self, event, name):
event_name = name[-1] + 'Event'
- self.undef(event_name)
with Indent(self, 'struct %s {' % adjust_type_name(event_name), '};'):
self.write('static constexpr int type_id = %d;' % event.type_id)
if len(event.opcodes) == 1:
@@ -912,7 +909,6 @@
items = [(int(x), y)
for (y, x) in event.enum_opcodes.items()]
for opcode, opname in sorted(items):
- self.undef(opname)
self.write('%s = %s,' % (opname, opcode))
self.write('bool send_event{};')
self.declare_fields(event.fields)
@@ -925,7 +921,6 @@
def declare_container(self, struct, struct_name):
name = struct_name[-1] + self.type_suffix(struct)
- self.undef(name)
with Indent(self, 'struct %s {' % adjust_type_name(name), '};'):
self.declare_fields(struct.fields)
self.write()
@@ -1325,7 +1320,6 @@
imports.add(('xproto', 'xproto'))
for direct_import in sorted(list(imports)):
self.write('#include "%s.h"' % direct_import[-1])
- self.write('#include "%s_undef.h"' % self.module.namespace.header)
self.write()
self.write('namespace x11 {')
self.write()
@@ -1338,7 +1332,6 @@
self.declare_type(item, name)
name = self.class_name
- self.undef(name)
with Indent(self, 'class COMPONENT_EXPORT(X11) %s {' % name, '};'):
self.namespace = ['x11', self.class_name]
self.write('public:')
@@ -1452,9 +1445,6 @@
self.write()
self.write('#include "base/component_export.h"')
self.write()
- self.write('// Avoid conflicts caused by the GenericEvent macro.')
- self.write('#include "ui/gfx/x/ge_undef.h"')
- self.write()
self.write('namespace x11 {')
self.write()
self.write('class Connection;')
diff --git a/ui/gfx/x/keysyms/BUILD.gn b/ui/gfx/x/keysyms/BUILD.gn
new file mode 100644
index 0000000..7ebb583
--- /dev/null
+++ b/ui/gfx/x/keysyms/BUILD.gn
@@ -0,0 +1,7 @@
+# Copyright 2020 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.
+
+source_set("keysyms") {
+ public = [ "keysyms.h" ]
+}
diff --git a/ui/gfx/x/keysyms/keysyms.h b/ui/gfx/x/keysyms/keysyms.h
new file mode 100644
index 0000000..4d5fbcb
--- /dev/null
+++ b/ui/gfx/x/keysyms/keysyms.h
@@ -0,0 +1,1161 @@
+// Copyright 2020 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.
+
+#ifndef UI_GFX_X_KEYSYMS_KEYSYMS_H_
+#define UI_GFX_X_KEYSYMS_KEYSYMS_H_
+
+#include <cstdint>
+
+static constexpr uint32_t XK_space = 0x20;
+static constexpr uint32_t XK_exclam = 0x21;
+static constexpr uint32_t XK_quotedbl = 0x22;
+static constexpr uint32_t XK_numbersign = 0x23;
+static constexpr uint32_t XK_dollar = 0x24;
+static constexpr uint32_t XK_percent = 0x25;
+static constexpr uint32_t XK_ampersand = 0x26;
+static constexpr uint32_t XK_quoteright = 0x27;
+static constexpr uint32_t XK_parenleft = 0x28;
+static constexpr uint32_t XK_parenright = 0x29;
+static constexpr uint32_t XK_asterisk = 0x2A;
+static constexpr uint32_t XK_plus = 0x2B;
+static constexpr uint32_t XK_comma = 0x2C;
+static constexpr uint32_t XK_minus = 0x2D;
+static constexpr uint32_t XK_period = 0x2E;
+static constexpr uint32_t XK_slash = 0x2F;
+static constexpr uint32_t XK_0 = 0x30;
+static constexpr uint32_t XK_1 = 0x31;
+static constexpr uint32_t XK_2 = 0x32;
+static constexpr uint32_t XK_3 = 0x33;
+static constexpr uint32_t XK_4 = 0x34;
+static constexpr uint32_t XK_5 = 0x35;
+static constexpr uint32_t XK_6 = 0x36;
+static constexpr uint32_t XK_7 = 0x37;
+static constexpr uint32_t XK_8 = 0x38;
+static constexpr uint32_t XK_9 = 0x39;
+static constexpr uint32_t XK_colon = 0x3A;
+static constexpr uint32_t XK_semicolon = 0x3B;
+static constexpr uint32_t XK_less = 0x3C;
+static constexpr uint32_t XK_equal = 0x3D;
+static constexpr uint32_t XK_greater = 0x3E;
+static constexpr uint32_t XK_question = 0x3F;
+static constexpr uint32_t XK_at = 0x40;
+static constexpr uint32_t XK_A = 0x41;
+static constexpr uint32_t XK_Z = 0x5A;
+static constexpr uint32_t XK_bracketleft = 0x5B;
+static constexpr uint32_t XK_backslash = 0x5C;
+static constexpr uint32_t XK_bracketright = 0x5D;
+static constexpr uint32_t XK_asciicircum = 0x5E;
+static constexpr uint32_t XK_underscore = 0x5F;
+static constexpr uint32_t XK_quoteleft = 0x60;
+static constexpr uint32_t XK_a = 0x61;
+static constexpr uint32_t XK_z = 0x7A;
+static constexpr uint32_t XK_braceleft = 0x7B;
+static constexpr uint32_t XK_bar = 0x7C;
+static constexpr uint32_t XK_braceright = 0x7D;
+static constexpr uint32_t XK_asciitilde = 0x7E;
+static constexpr uint32_t XK_exclamdown = 0xA1;
+static constexpr uint32_t XK_brokenbar = 0xA6;
+static constexpr uint32_t XK_guillemotleft = 0xAB;
+static constexpr uint32_t XK_degree = 0xB0;
+static constexpr uint32_t XK_periodcentered = 0xB7;
+static constexpr uint32_t XK_guillemotright = 0xBB;
+static constexpr uint32_t XK_questiondown = 0xBF;
+static constexpr uint32_t XK_Agrave = 0xC0;
+static constexpr uint32_t XK_Odiaeresis = 0xD6;
+static constexpr uint32_t XK_multiply = 0xD7;
+static constexpr uint32_t XK_Ooblique = 0xD8;
+static constexpr uint32_t XK_Ugrave = 0xD9;
+static constexpr uint32_t XK_Thorn = 0xDE;
+static constexpr uint32_t XK_agrave = 0xE0;
+static constexpr uint32_t XK_odiaeresis = 0xF6;
+static constexpr uint32_t XK_oslash = 0xF8;
+static constexpr uint32_t XK_ugrave = 0xF9;
+static constexpr uint32_t XK_thorn = 0xFE;
+static constexpr uint32_t XK_ydiaeresis = 0xFF;
+static constexpr uint32_t XK_Aogonek = 0x1A1;
+static constexpr uint32_t XK_breve = 0x1A2;
+static constexpr uint32_t XK_Lstroke = 0x1A3;
+static constexpr uint32_t XK_Lcaron = 0x1A5;
+static constexpr uint32_t XK_Sacute = 0x1A6;
+static constexpr uint32_t XK_Scaron = 0x1A9;
+static constexpr uint32_t XK_Scedilla = 0x1AA;
+static constexpr uint32_t XK_Tcaron = 0x1AB;
+static constexpr uint32_t XK_Zacute = 0x1AC;
+static constexpr uint32_t XK_Zcaron = 0x1AE;
+static constexpr uint32_t XK_Zabovedot = 0x1AF;
+static constexpr uint32_t XK_aogonek = 0x1B1;
+static constexpr uint32_t XK_ogonek = 0x1B2;
+static constexpr uint32_t XK_lstroke = 0x1B3;
+static constexpr uint32_t XK_lcaron = 0x1B5;
+static constexpr uint32_t XK_sacute = 0x1B6;
+static constexpr uint32_t XK_caron = 0x1B7;
+static constexpr uint32_t XK_scaron = 0x1B9;
+static constexpr uint32_t XK_scedilla = 0x1BA;
+static constexpr uint32_t XK_tcaron = 0x1BB;
+static constexpr uint32_t XK_zacute = 0x1BC;
+static constexpr uint32_t XK_doubleacute = 0x1BD;
+static constexpr uint32_t XK_zcaron = 0x1BE;
+static constexpr uint32_t XK_zabovedot = 0x1BF;
+static constexpr uint32_t XK_Racute = 0x1C0;
+static constexpr uint32_t XK_Abreve = 0x1C3;
+static constexpr uint32_t XK_Lacute = 0x1C5;
+static constexpr uint32_t XK_Cacute = 0x1C6;
+static constexpr uint32_t XK_Ccaron = 0x1C8;
+static constexpr uint32_t XK_Eogonek = 0x1CA;
+static constexpr uint32_t XK_Ecaron = 0x1CC;
+static constexpr uint32_t XK_Dcaron = 0x1CF;
+static constexpr uint32_t XK_Dstroke = 0x1D0;
+static constexpr uint32_t XK_Nacute = 0x1D1;
+static constexpr uint32_t XK_Ncaron = 0x1D2;
+static constexpr uint32_t XK_Odoubleacute = 0x1D5;
+static constexpr uint32_t XK_Rcaron = 0x1D8;
+static constexpr uint32_t XK_Uring = 0x1D9;
+static constexpr uint32_t XK_Udoubleacute = 0x1DB;
+static constexpr uint32_t XK_Tcedilla = 0x1DE;
+static constexpr uint32_t XK_racute = 0x1E0;
+static constexpr uint32_t XK_abreve = 0x1E3;
+static constexpr uint32_t XK_lacute = 0x1E5;
+static constexpr uint32_t XK_cacute = 0x1E6;
+static constexpr uint32_t XK_ccaron = 0x1E8;
+static constexpr uint32_t XK_eogonek = 0x1EA;
+static constexpr uint32_t XK_ecaron = 0x1EC;
+static constexpr uint32_t XK_dcaron = 0x1EF;
+static constexpr uint32_t XK_dstroke = 0x1F0;
+static constexpr uint32_t XK_nacute = 0x1F1;
+static constexpr uint32_t XK_ncaron = 0x1F2;
+static constexpr uint32_t XK_odoubleacute = 0x1F5;
+static constexpr uint32_t XK_rcaron = 0x1F8;
+static constexpr uint32_t XK_uring = 0x1F9;
+static constexpr uint32_t XK_udoubleacute = 0x1FB;
+static constexpr uint32_t XK_tcedilla = 0x1FE;
+static constexpr uint32_t XK_abovedot = 0x1FF;
+static constexpr uint32_t XK_Hstroke = 0x2A1;
+static constexpr uint32_t XK_Hcircumflex = 0x2A6;
+static constexpr uint32_t XK_Iabovedot = 0x2A9;
+static constexpr uint32_t XK_Gbreve = 0x2AB;
+static constexpr uint32_t XK_Jcircumflex = 0x2AC;
+static constexpr uint32_t XK_hstroke = 0x2B1;
+static constexpr uint32_t XK_hcircumflex = 0x2B6;
+static constexpr uint32_t XK_idotless = 0x2B9;
+static constexpr uint32_t XK_gbreve = 0x2BB;
+static constexpr uint32_t XK_jcircumflex = 0x2BC;
+static constexpr uint32_t XK_Cabovedot = 0x2C5;
+static constexpr uint32_t XK_Ccircumflex = 0x2C6;
+static constexpr uint32_t XK_Gabovedot = 0x2D5;
+static constexpr uint32_t XK_Gcircumflex = 0x2D8;
+static constexpr uint32_t XK_Ubreve = 0x2DD;
+static constexpr uint32_t XK_Scircumflex = 0x2DE;
+static constexpr uint32_t XK_cabovedot = 0x2E5;
+static constexpr uint32_t XK_ccircumflex = 0x2E6;
+static constexpr uint32_t XK_gabovedot = 0x2F5;
+static constexpr uint32_t XK_gcircumflex = 0x2F8;
+static constexpr uint32_t XK_ubreve = 0x2FD;
+static constexpr uint32_t XK_scircumflex = 0x2FE;
+static constexpr uint32_t XK_kra = 0x3A2;
+static constexpr uint32_t XK_Rcedilla = 0x3A3;
+static constexpr uint32_t XK_Itilde = 0x3A5;
+static constexpr uint32_t XK_Lcedilla = 0x3A6;
+static constexpr uint32_t XK_Emacron = 0x3AA;
+static constexpr uint32_t XK_Gcedilla = 0x3AB;
+static constexpr uint32_t XK_Tslash = 0x3AC;
+static constexpr uint32_t XK_rcedilla = 0x3B3;
+static constexpr uint32_t XK_itilde = 0x3B5;
+static constexpr uint32_t XK_lcedilla = 0x3B6;
+static constexpr uint32_t XK_emacron = 0x3BA;
+static constexpr uint32_t XK_gcedilla = 0x3BB;
+static constexpr uint32_t XK_tslash = 0x3BC;
+static constexpr uint32_t XK_ENG = 0x3BD;
+static constexpr uint32_t XK_eng = 0x3BF;
+static constexpr uint32_t XK_Amacron = 0x3C0;
+static constexpr uint32_t XK_Iogonek = 0x3C7;
+static constexpr uint32_t XK_Eabovedot = 0x3CC;
+static constexpr uint32_t XK_Imacron = 0x3CF;
+static constexpr uint32_t XK_Ncedilla = 0x3D1;
+static constexpr uint32_t XK_Omacron = 0x3D2;
+static constexpr uint32_t XK_Kcedilla = 0x3D3;
+static constexpr uint32_t XK_Uogonek = 0x3D9;
+static constexpr uint32_t XK_Utilde = 0x3DD;
+static constexpr uint32_t XK_Umacron = 0x3DE;
+static constexpr uint32_t XK_amacron = 0x3E0;
+static constexpr uint32_t XK_iogonek = 0x3E7;
+static constexpr uint32_t XK_eabovedot = 0x3EC;
+static constexpr uint32_t XK_imacron = 0x3EF;
+static constexpr uint32_t XK_ncedilla = 0x3F1;
+static constexpr uint32_t XK_omacron = 0x3F2;
+static constexpr uint32_t XK_kcedilla = 0x3F3;
+static constexpr uint32_t XK_uogonek = 0x3F9;
+static constexpr uint32_t XK_utilde = 0x3FD;
+static constexpr uint32_t XK_umacron = 0x3FE;
+static constexpr uint32_t XK_overline = 0x47E;
+static constexpr uint32_t XK_kana_fullstop = 0x4A1;
+static constexpr uint32_t XK_kana_openingbracket = 0x4A2;
+static constexpr uint32_t XK_kana_closingbracket = 0x4A3;
+static constexpr uint32_t XK_kana_comma = 0x4A4;
+static constexpr uint32_t XK_kana_conjunctive = 0x4A5;
+static constexpr uint32_t XK_kana_WO = 0x4A6;
+static constexpr uint32_t XK_kana_a = 0x4A7;
+static constexpr uint32_t XK_kana_i = 0x4A8;
+static constexpr uint32_t XK_kana_u = 0x4A9;
+static constexpr uint32_t XK_kana_e = 0x4AA;
+static constexpr uint32_t XK_kana_o = 0x4AB;
+static constexpr uint32_t XK_kana_ya = 0x4AC;
+static constexpr uint32_t XK_kana_yu = 0x4AD;
+static constexpr uint32_t XK_kana_yo = 0x4AE;
+static constexpr uint32_t XK_kana_tsu = 0x4AF;
+static constexpr uint32_t XK_prolongedsound = 0x4B0;
+static constexpr uint32_t XK_kana_A = 0x4B1;
+static constexpr uint32_t XK_kana_I = 0x4B2;
+static constexpr uint32_t XK_kana_U = 0x4B3;
+static constexpr uint32_t XK_kana_E = 0x4B4;
+static constexpr uint32_t XK_kana_O = 0x4B5;
+static constexpr uint32_t XK_kana_KA = 0x4B6;
+static constexpr uint32_t XK_kana_KI = 0x4B7;
+static constexpr uint32_t XK_kana_KU = 0x4B8;
+static constexpr uint32_t XK_kana_KE = 0x4B9;
+static constexpr uint32_t XK_kana_KO = 0x4BA;
+static constexpr uint32_t XK_kana_SA = 0x4BB;
+static constexpr uint32_t XK_kana_SHI = 0x4BC;
+static constexpr uint32_t XK_kana_SU = 0x4BD;
+static constexpr uint32_t XK_kana_SE = 0x4BE;
+static constexpr uint32_t XK_kana_SO = 0x4BF;
+static constexpr uint32_t XK_kana_TA = 0x4C0;
+static constexpr uint32_t XK_kana_CHI = 0x4C1;
+static constexpr uint32_t XK_kana_TSU = 0x4C2;
+static constexpr uint32_t XK_kana_TE = 0x4C3;
+static constexpr uint32_t XK_kana_TO = 0x4C4;
+static constexpr uint32_t XK_kana_NA = 0x4C5;
+static constexpr uint32_t XK_kana_NI = 0x4C6;
+static constexpr uint32_t XK_kana_NU = 0x4C7;
+static constexpr uint32_t XK_kana_NE = 0x4C8;
+static constexpr uint32_t XK_kana_NO = 0x4C9;
+static constexpr uint32_t XK_kana_HA = 0x4CA;
+static constexpr uint32_t XK_kana_HI = 0x4CB;
+static constexpr uint32_t XK_kana_FU = 0x4CC;
+static constexpr uint32_t XK_kana_HE = 0x4CD;
+static constexpr uint32_t XK_kana_HO = 0x4CE;
+static constexpr uint32_t XK_kana_MA = 0x4CF;
+static constexpr uint32_t XK_kana_MI = 0x4D0;
+static constexpr uint32_t XK_kana_MU = 0x4D1;
+static constexpr uint32_t XK_kana_ME = 0x4D2;
+static constexpr uint32_t XK_kana_MO = 0x4D3;
+static constexpr uint32_t XK_kana_YA = 0x4D4;
+static constexpr uint32_t XK_kana_YU = 0x4D5;
+static constexpr uint32_t XK_kana_YO = 0x4D6;
+static constexpr uint32_t XK_kana_RA = 0x4D7;
+static constexpr uint32_t XK_kana_RI = 0x4D8;
+static constexpr uint32_t XK_kana_RU = 0x4D9;
+static constexpr uint32_t XK_kana_RE = 0x4DA;
+static constexpr uint32_t XK_kana_RO = 0x4DB;
+static constexpr uint32_t XK_kana_WA = 0x4DC;
+static constexpr uint32_t XK_kana_N = 0x4DD;
+static constexpr uint32_t XK_voicedsound = 0x4DE;
+static constexpr uint32_t XK_semivoicedsound = 0x4DF;
+static constexpr uint32_t XK_Arabic_comma = 0x5AC;
+static constexpr uint32_t XK_Arabic_semicolon = 0x5BB;
+static constexpr uint32_t XK_Arabic_question_mark = 0x5BF;
+static constexpr uint32_t XK_Arabic_hamza = 0x5C1;
+static constexpr uint32_t XK_Arabic_maddaonalef = 0x5C2;
+static constexpr uint32_t XK_Arabic_hamzaonalef = 0x5C3;
+static constexpr uint32_t XK_Arabic_hamzaonwaw = 0x5C4;
+static constexpr uint32_t XK_Arabic_hamzaunderalef = 0x5C5;
+static constexpr uint32_t XK_Arabic_hamzaonyeh = 0x5C6;
+static constexpr uint32_t XK_Arabic_alef = 0x5C7;
+static constexpr uint32_t XK_Arabic_beh = 0x5C8;
+static constexpr uint32_t XK_Arabic_tehmarbuta = 0x5C9;
+static constexpr uint32_t XK_Arabic_teh = 0x5CA;
+static constexpr uint32_t XK_Arabic_theh = 0x5CB;
+static constexpr uint32_t XK_Arabic_jeem = 0x5CC;
+static constexpr uint32_t XK_Arabic_hah = 0x5CD;
+static constexpr uint32_t XK_Arabic_khah = 0x5CE;
+static constexpr uint32_t XK_Arabic_dal = 0x5CF;
+static constexpr uint32_t XK_Arabic_thal = 0x5D0;
+static constexpr uint32_t XK_Arabic_ra = 0x5D1;
+static constexpr uint32_t XK_Arabic_zain = 0x5D2;
+static constexpr uint32_t XK_Arabic_seen = 0x5D3;
+static constexpr uint32_t XK_Arabic_sheen = 0x5D4;
+static constexpr uint32_t XK_Arabic_sad = 0x5D5;
+static constexpr uint32_t XK_Arabic_dad = 0x5D6;
+static constexpr uint32_t XK_Arabic_tah = 0x5D7;
+static constexpr uint32_t XK_Arabic_zah = 0x5D8;
+static constexpr uint32_t XK_Arabic_ain = 0x5D9;
+static constexpr uint32_t XK_Arabic_ghain = 0x5DA;
+static constexpr uint32_t XK_Arabic_tatweel = 0x5E0;
+static constexpr uint32_t XK_Arabic_feh = 0x5E1;
+static constexpr uint32_t XK_Arabic_qaf = 0x5E2;
+static constexpr uint32_t XK_Arabic_kaf = 0x5E3;
+static constexpr uint32_t XK_Arabic_lam = 0x5E4;
+static constexpr uint32_t XK_Arabic_meem = 0x5E5;
+static constexpr uint32_t XK_Arabic_noon = 0x5E6;
+static constexpr uint32_t XK_Arabic_ha = 0x5E7;
+static constexpr uint32_t XK_Arabic_waw = 0x5E8;
+static constexpr uint32_t XK_Arabic_alefmaksura = 0x5E9;
+static constexpr uint32_t XK_Arabic_yeh = 0x5EA;
+static constexpr uint32_t XK_Arabic_fathatan = 0x5EB;
+static constexpr uint32_t XK_Arabic_dammatan = 0x5EC;
+static constexpr uint32_t XK_Arabic_kasratan = 0x5ED;
+static constexpr uint32_t XK_Arabic_fatha = 0x5EE;
+static constexpr uint32_t XK_Arabic_damma = 0x5EF;
+static constexpr uint32_t XK_Arabic_kasra = 0x5F0;
+static constexpr uint32_t XK_Arabic_shadda = 0x5F1;
+static constexpr uint32_t XK_Arabic_sukun = 0x5F2;
+static constexpr uint32_t XK_Serbian_dje = 0x6A1;
+static constexpr uint32_t XK_Macedonia_gje = 0x6A2;
+static constexpr uint32_t XK_Cyrillic_io = 0x6A3;
+static constexpr uint32_t XK_Ukrainian_ie = 0x6A4;
+static constexpr uint32_t XK_Macedonia_dse = 0x6A5;
+static constexpr uint32_t XK_Ukrainian_i = 0x6A6;
+static constexpr uint32_t XK_Ukrainian_yi = 0x6A7;
+static constexpr uint32_t XK_Cyrillic_je = 0x6A8;
+static constexpr uint32_t XK_Cyrillic_lje = 0x6A9;
+static constexpr uint32_t XK_Cyrillic_nje = 0x6AA;
+static constexpr uint32_t XK_Serbian_tshe = 0x6AB;
+static constexpr uint32_t XK_Macedonia_kje = 0x6AC;
+static constexpr uint32_t XK_Ukrainian_ghe_with_upturn = 0x6AD;
+static constexpr uint32_t XK_Byelorussian_shortu = 0x6AE;
+static constexpr uint32_t XK_Cyrillic_dzhe = 0x6AF;
+static constexpr uint32_t XK_Serbian_dze = 0x6AF;
+static constexpr uint32_t XK_numerosign = 0x6B0;
+static constexpr uint32_t XK_Serbian_DJE = 0x6B1;
+static constexpr uint32_t XK_Macedonia_GJE = 0x6B2;
+static constexpr uint32_t XK_Cyrillic_IO = 0x6B3;
+static constexpr uint32_t XK_Ukrainian_IE = 0x6B4;
+static constexpr uint32_t XK_Macedonia_DSE = 0x6B5;
+static constexpr uint32_t XK_Ukrainian_I = 0x6B6;
+static constexpr uint32_t XK_Ukrainian_YI = 0x6B7;
+static constexpr uint32_t XK_Cyrillic_JE = 0x6B8;
+static constexpr uint32_t XK_Cyrillic_LJE = 0x6B9;
+static constexpr uint32_t XK_Cyrillic_NJE = 0x6BA;
+static constexpr uint32_t XK_Serbian_TSHE = 0x6BB;
+static constexpr uint32_t XK_Macedonia_KJE = 0x6BC;
+static constexpr uint32_t XK_Ukrainian_GHE_WITH_UPTURN = 0x6BD;
+static constexpr uint32_t XK_Byelorussian_SHORTU = 0x6BE;
+static constexpr uint32_t XK_Cyrillic_DZHE = 0x6BF;
+static constexpr uint32_t XK_Serbian_DZE = 0x6BF;
+static constexpr uint32_t XK_Cyrillic_yu = 0x6C0;
+static constexpr uint32_t XK_Cyrillic_a = 0x6C1;
+static constexpr uint32_t XK_Cyrillic_be = 0x6C2;
+static constexpr uint32_t XK_Cyrillic_tse = 0x6C3;
+static constexpr uint32_t XK_Cyrillic_de = 0x6C4;
+static constexpr uint32_t XK_Cyrillic_ie = 0x6C5;
+static constexpr uint32_t XK_Cyrillic_ef = 0x6C6;
+static constexpr uint32_t XK_Cyrillic_ghe = 0x6C7;
+static constexpr uint32_t XK_Cyrillic_ha = 0x6C8;
+static constexpr uint32_t XK_Cyrillic_i = 0x6C9;
+static constexpr uint32_t XK_Cyrillic_shorti = 0x6CA;
+static constexpr uint32_t XK_Cyrillic_ka = 0x6CB;
+static constexpr uint32_t XK_Cyrillic_el = 0x6CC;
+static constexpr uint32_t XK_Cyrillic_em = 0x6CD;
+static constexpr uint32_t XK_Cyrillic_en = 0x6CE;
+static constexpr uint32_t XK_Cyrillic_o = 0x6CF;
+static constexpr uint32_t XK_Cyrillic_pe = 0x6D0;
+static constexpr uint32_t XK_Cyrillic_ya = 0x6D1;
+static constexpr uint32_t XK_Cyrillic_er = 0x6D2;
+static constexpr uint32_t XK_Cyrillic_es = 0x6D3;
+static constexpr uint32_t XK_Cyrillic_te = 0x6D4;
+static constexpr uint32_t XK_Cyrillic_u = 0x6D5;
+static constexpr uint32_t XK_Cyrillic_zhe = 0x6D6;
+static constexpr uint32_t XK_Cyrillic_ve = 0x6D7;
+static constexpr uint32_t XK_Cyrillic_softsign = 0x6D8;
+static constexpr uint32_t XK_Cyrillic_yeru = 0x6D9;
+static constexpr uint32_t XK_Cyrillic_ze = 0x6DA;
+static constexpr uint32_t XK_Cyrillic_sha = 0x6DB;
+static constexpr uint32_t XK_Cyrillic_e = 0x6DC;
+static constexpr uint32_t XK_Cyrillic_shcha = 0x6DD;
+static constexpr uint32_t XK_Cyrillic_che = 0x6DE;
+static constexpr uint32_t XK_Cyrillic_hardsign = 0x6DF;
+static constexpr uint32_t XK_Cyrillic_YU = 0x6E0;
+static constexpr uint32_t XK_Cyrillic_A = 0x6E1;
+static constexpr uint32_t XK_Cyrillic_BE = 0x6E2;
+static constexpr uint32_t XK_Cyrillic_TSE = 0x6E3;
+static constexpr uint32_t XK_Cyrillic_DE = 0x6E4;
+static constexpr uint32_t XK_Cyrillic_IE = 0x6E5;
+static constexpr uint32_t XK_Cyrillic_EF = 0x6E6;
+static constexpr uint32_t XK_Cyrillic_GHE = 0x6E7;
+static constexpr uint32_t XK_Cyrillic_HA = 0x6E8;
+static constexpr uint32_t XK_Cyrillic_I = 0x6E9;
+static constexpr uint32_t XK_Cyrillic_SHORTI = 0x6EA;
+static constexpr uint32_t XK_Cyrillic_KA = 0x6EB;
+static constexpr uint32_t XK_Cyrillic_EL = 0x6EC;
+static constexpr uint32_t XK_Cyrillic_EM = 0x6ED;
+static constexpr uint32_t XK_Cyrillic_EN = 0x6EE;
+static constexpr uint32_t XK_Cyrillic_O = 0x6EF;
+static constexpr uint32_t XK_Cyrillic_PE = 0x6F0;
+static constexpr uint32_t XK_Cyrillic_YA = 0x6F1;
+static constexpr uint32_t XK_Cyrillic_ER = 0x6F2;
+static constexpr uint32_t XK_Cyrillic_ES = 0x6F3;
+static constexpr uint32_t XK_Cyrillic_TE = 0x6F4;
+static constexpr uint32_t XK_Cyrillic_U = 0x6F5;
+static constexpr uint32_t XK_Cyrillic_ZHE = 0x6F6;
+static constexpr uint32_t XK_Cyrillic_VE = 0x6F7;
+static constexpr uint32_t XK_Cyrillic_SOFTSIGN = 0x6F8;
+static constexpr uint32_t XK_Cyrillic_YERU = 0x6F9;
+static constexpr uint32_t XK_Cyrillic_ZE = 0x6FA;
+static constexpr uint32_t XK_Cyrillic_SHA = 0x6FB;
+static constexpr uint32_t XK_Cyrillic_E = 0x6FC;
+static constexpr uint32_t XK_Cyrillic_SHCHA = 0x6FD;
+static constexpr uint32_t XK_Cyrillic_CHE = 0x6FE;
+static constexpr uint32_t XK_Cyrillic_HARDSIGN = 0x6FF;
+static constexpr uint32_t XK_Greek_ALPHAaccent = 0x7A1;
+static constexpr uint32_t XK_Greek_EPSILONaccent = 0x7A2;
+static constexpr uint32_t XK_Greek_ETAaccent = 0x7A3;
+static constexpr uint32_t XK_Greek_IOTAaccent = 0x7A4;
+static constexpr uint32_t XK_Greek_IOTAdiaeresis = 0x7A5;
+static constexpr uint32_t XK_Greek_IOTAdieresis = 0x7A5;
+static constexpr uint32_t XK_Greek_OMICRONaccent = 0x7A7;
+static constexpr uint32_t XK_Greek_UPSILONaccent = 0x7A8;
+static constexpr uint32_t XK_Greek_UPSILONdieresis = 0x7A9;
+static constexpr uint32_t XK_Greek_OMEGAaccent = 0x7AB;
+static constexpr uint32_t XK_Greek_accentdieresis = 0x7AE;
+static constexpr uint32_t XK_Greek_horizbar = 0x7AF;
+static constexpr uint32_t XK_Greek_alphaaccent = 0x7B1;
+static constexpr uint32_t XK_Greek_epsilonaccent = 0x7B2;
+static constexpr uint32_t XK_Greek_etaaccent = 0x7B3;
+static constexpr uint32_t XK_Greek_iotaaccent = 0x7B4;
+static constexpr uint32_t XK_Greek_iotadieresis = 0x7B5;
+static constexpr uint32_t XK_Greek_iotaaccentdieresis = 0x7B6;
+static constexpr uint32_t XK_Greek_omicronaccent = 0x7B7;
+static constexpr uint32_t XK_Greek_upsilonaccent = 0x7B8;
+static constexpr uint32_t XK_Greek_upsilondieresis = 0x7B9;
+static constexpr uint32_t XK_Greek_upsilonaccentdieresis = 0x7BA;
+static constexpr uint32_t XK_Greek_omegaaccent = 0x7BB;
+static constexpr uint32_t XK_Greek_ALPHA = 0x7C1;
+static constexpr uint32_t XK_Greek_BETA = 0x7C2;
+static constexpr uint32_t XK_Greek_GAMMA = 0x7C3;
+static constexpr uint32_t XK_Greek_DELTA = 0x7C4;
+static constexpr uint32_t XK_Greek_EPSILON = 0x7C5;
+static constexpr uint32_t XK_Greek_ZETA = 0x7C6;
+static constexpr uint32_t XK_Greek_ETA = 0x7C7;
+static constexpr uint32_t XK_Greek_THETA = 0x7C8;
+static constexpr uint32_t XK_Greek_IOTA = 0x7C9;
+static constexpr uint32_t XK_Greek_KAPPA = 0x7CA;
+static constexpr uint32_t XK_Greek_LAMBDA = 0x7CB;
+static constexpr uint32_t XK_Greek_LAMDA = 0x7CB;
+static constexpr uint32_t XK_Greek_MU = 0x7CC;
+static constexpr uint32_t XK_Greek_NU = 0x7CD;
+static constexpr uint32_t XK_Greek_XI = 0x7CE;
+static constexpr uint32_t XK_Greek_OMICRON = 0x7CF;
+static constexpr uint32_t XK_Greek_PI = 0x7D0;
+static constexpr uint32_t XK_Greek_RHO = 0x7D1;
+static constexpr uint32_t XK_Greek_SIGMA = 0x7D2;
+static constexpr uint32_t XK_Greek_TAU = 0x7D4;
+static constexpr uint32_t XK_Greek_UPSILON = 0x7D5;
+static constexpr uint32_t XK_Greek_PHI = 0x7D6;
+static constexpr uint32_t XK_Greek_CHI = 0x7D7;
+static constexpr uint32_t XK_Greek_PSI = 0x7D8;
+static constexpr uint32_t XK_Greek_OMEGA = 0x7D9;
+static constexpr uint32_t XK_Greek_alpha = 0x7E1;
+static constexpr uint32_t XK_Greek_beta = 0x7E2;
+static constexpr uint32_t XK_Greek_gamma = 0x7E3;
+static constexpr uint32_t XK_Greek_delta = 0x7E4;
+static constexpr uint32_t XK_Greek_epsilon = 0x7E5;
+static constexpr uint32_t XK_Greek_zeta = 0x7E6;
+static constexpr uint32_t XK_Greek_eta = 0x7E7;
+static constexpr uint32_t XK_Greek_theta = 0x7E8;
+static constexpr uint32_t XK_Greek_iota = 0x7E9;
+static constexpr uint32_t XK_Greek_kappa = 0x7EA;
+static constexpr uint32_t XK_Greek_lambda = 0x7EB;
+static constexpr uint32_t XK_Greek_lamda = 0x7EB;
+static constexpr uint32_t XK_Greek_mu = 0x7EC;
+static constexpr uint32_t XK_Greek_nu = 0x7ED;
+static constexpr uint32_t XK_Greek_xi = 0x7EE;
+static constexpr uint32_t XK_Greek_omicron = 0x7EF;
+static constexpr uint32_t XK_Greek_pi = 0x7F0;
+static constexpr uint32_t XK_Greek_rho = 0x7F1;
+static constexpr uint32_t XK_Greek_sigma = 0x7F2;
+static constexpr uint32_t XK_Greek_finalsmallsigma = 0x7F3;
+static constexpr uint32_t XK_Greek_tau = 0x7F4;
+static constexpr uint32_t XK_Greek_upsilon = 0x7F5;
+static constexpr uint32_t XK_Greek_phi = 0x7F6;
+static constexpr uint32_t XK_Greek_chi = 0x7F7;
+static constexpr uint32_t XK_Greek_psi = 0x7F8;
+static constexpr uint32_t XK_Greek_omega = 0x7F9;
+static constexpr uint32_t XK_leftradical = 0x8A1;
+static constexpr uint32_t XK_topleftradical = 0x8A2;
+static constexpr uint32_t XK_horizconnector = 0x8A3;
+static constexpr uint32_t XK_topintegral = 0x8A4;
+static constexpr uint32_t XK_botintegral = 0x8A5;
+static constexpr uint32_t XK_vertconnector = 0x8A6;
+static constexpr uint32_t XK_topleftsqbracket = 0x8A7;
+static constexpr uint32_t XK_botleftsqbracket = 0x8A8;
+static constexpr uint32_t XK_toprightsqbracket = 0x8A9;
+static constexpr uint32_t XK_botrightsqbracket = 0x8AA;
+static constexpr uint32_t XK_topleftparens = 0x8AB;
+static constexpr uint32_t XK_botleftparens = 0x8AC;
+static constexpr uint32_t XK_toprightparens = 0x8AD;
+static constexpr uint32_t XK_botrightparens = 0x8AE;
+static constexpr uint32_t XK_leftmiddlecurlybrace = 0x8AF;
+static constexpr uint32_t XK_rightmiddlecurlybrace = 0x8B0;
+static constexpr uint32_t XK_lessthanequal = 0x8BC;
+static constexpr uint32_t XK_notequal = 0x8BD;
+static constexpr uint32_t XK_greaterthanequal = 0x8BE;
+static constexpr uint32_t XK_integral = 0x8BF;
+static constexpr uint32_t XK_therefore = 0x8C0;
+static constexpr uint32_t XK_variation = 0x8C1;
+static constexpr uint32_t XK_infinity = 0x8C2;
+static constexpr uint32_t XK_nabla = 0x8C5;
+static constexpr uint32_t XK_approximate = 0x8C8;
+static constexpr uint32_t XK_similarequal = 0x8C9;
+static constexpr uint32_t XK_ifonlyif = 0x8CD;
+static constexpr uint32_t XK_implies = 0x8CE;
+static constexpr uint32_t XK_identical = 0x8CF;
+static constexpr uint32_t XK_radical = 0x8D6;
+static constexpr uint32_t XK_includedin = 0x8DA;
+static constexpr uint32_t XK_includes = 0x8DB;
+static constexpr uint32_t XK_intersection = 0x8DC;
+static constexpr uint32_t XK_union = 0x8DD;
+static constexpr uint32_t XK_logicaland = 0x8DE;
+static constexpr uint32_t XK_logicalor = 0x8DF;
+static constexpr uint32_t XK_partialderivative = 0x8EF;
+static constexpr uint32_t XK_function = 0x8F6;
+static constexpr uint32_t XK_leftarrow = 0x8FB;
+static constexpr uint32_t XK_uparrow = 0x8FC;
+static constexpr uint32_t XK_rightarrow = 0x8FD;
+static constexpr uint32_t XK_downarrow = 0x8FE;
+static constexpr uint32_t XK_soliddiamond = 0x9E0;
+static constexpr uint32_t XK_checkerboard = 0x9E1;
+static constexpr uint32_t XK_ht = 0x9E2;
+static constexpr uint32_t XK_ff = 0x9E3;
+static constexpr uint32_t XK_cr = 0x9E4;
+static constexpr uint32_t XK_lf = 0x9E5;
+static constexpr uint32_t XK_nl = 0x9E8;
+static constexpr uint32_t XK_vt = 0x9E9;
+static constexpr uint32_t XK_lowrightcorner = 0x9EA;
+static constexpr uint32_t XK_uprightcorner = 0x9EB;
+static constexpr uint32_t XK_upleftcorner = 0x9EC;
+static constexpr uint32_t XK_lowleftcorner = 0x9ED;
+static constexpr uint32_t XK_crossinglines = 0x9EE;
+static constexpr uint32_t XK_horizlinescan1 = 0x9EF;
+static constexpr uint32_t XK_horizlinescan3 = 0x9F0;
+static constexpr uint32_t XK_horizlinescan5 = 0x9F1;
+static constexpr uint32_t XK_horizlinescan7 = 0x9F2;
+static constexpr uint32_t XK_horizlinescan9 = 0x9F3;
+static constexpr uint32_t XK_leftt = 0x9F4;
+static constexpr uint32_t XK_rightt = 0x9F5;
+static constexpr uint32_t XK_bott = 0x9F6;
+static constexpr uint32_t XK_topt = 0x9F7;
+static constexpr uint32_t XK_vertbar = 0x9F8;
+static constexpr uint32_t XK_emspace = 0xAA1;
+static constexpr uint32_t XK_enspace = 0xAA2;
+static constexpr uint32_t XK_em3space = 0xAA3;
+static constexpr uint32_t XK_em4space = 0xAA4;
+static constexpr uint32_t XK_digitspace = 0xAA5;
+static constexpr uint32_t XK_punctspace = 0xAA6;
+static constexpr uint32_t XK_thinspace = 0xAA7;
+static constexpr uint32_t XK_hairspace = 0xAA8;
+static constexpr uint32_t XK_emdash = 0xAA9;
+static constexpr uint32_t XK_endash = 0xAAA;
+static constexpr uint32_t XK_signifblank = 0xAAC;
+static constexpr uint32_t XK_ellipsis = 0xAAE;
+static constexpr uint32_t XK_doubbaselinedot = 0xAAF;
+static constexpr uint32_t XK_onethird = 0xAB0;
+static constexpr uint32_t XK_twothirds = 0xAB1;
+static constexpr uint32_t XK_onefifth = 0xAB2;
+static constexpr uint32_t XK_twofifths = 0xAB3;
+static constexpr uint32_t XK_threefifths = 0xAB4;
+static constexpr uint32_t XK_fourfifths = 0xAB5;
+static constexpr uint32_t XK_onesixth = 0xAB6;
+static constexpr uint32_t XK_fivesixths = 0xAB7;
+static constexpr uint32_t XK_careof = 0xAB8;
+static constexpr uint32_t XK_figdash = 0xABB;
+static constexpr uint32_t XK_leftanglebracket = 0xABC;
+static constexpr uint32_t XK_decimalpoint = 0xABD;
+static constexpr uint32_t XK_rightanglebracket = 0xABE;
+static constexpr uint32_t XK_oneeighth = 0xAC3;
+static constexpr uint32_t XK_threeeighths = 0xAC4;
+static constexpr uint32_t XK_fiveeighths = 0xAC5;
+static constexpr uint32_t XK_seveneighths = 0xAC6;
+static constexpr uint32_t XK_trademark = 0xAC9;
+static constexpr uint32_t XK_signaturemark = 0xACA;
+static constexpr uint32_t XK_leftopentriangle = 0xACC;
+static constexpr uint32_t XK_rightopentriangle = 0xACD;
+static constexpr uint32_t XK_emopencircle = 0xACE;
+static constexpr uint32_t XK_emopenrectangle = 0xACF;
+static constexpr uint32_t XK_leftsinglequotemark = 0xAD0;
+static constexpr uint32_t XK_rightsinglequotemark = 0xAD1;
+static constexpr uint32_t XK_leftdoublequotemark = 0xAD2;
+static constexpr uint32_t XK_rightdoublequotemark = 0xAD3;
+static constexpr uint32_t XK_prescription = 0xAD4;
+static constexpr uint32_t XK_minutes = 0xAD6;
+static constexpr uint32_t XK_seconds = 0xAD7;
+static constexpr uint32_t XK_latincross = 0xAD9;
+static constexpr uint32_t XK_filledrectbullet = 0xADB;
+static constexpr uint32_t XK_filledlefttribullet = 0xADC;
+static constexpr uint32_t XK_filledrighttribullet = 0xADD;
+static constexpr uint32_t XK_emfilledcircle = 0xADE;
+static constexpr uint32_t XK_emfilledrect = 0xADF;
+static constexpr uint32_t XK_enopencircbullet = 0xAE0;
+static constexpr uint32_t XK_enopensquarebullet = 0xAE1;
+static constexpr uint32_t XK_openrectbullet = 0xAE2;
+static constexpr uint32_t XK_opentribulletup = 0xAE3;
+static constexpr uint32_t XK_opentribulletdown = 0xAE4;
+static constexpr uint32_t XK_openstar = 0xAE5;
+static constexpr uint32_t XK_enfilledcircbullet = 0xAE6;
+static constexpr uint32_t XK_enfilledsqbullet = 0xAE7;
+static constexpr uint32_t XK_filledtribulletup = 0xAE8;
+static constexpr uint32_t XK_filledtribulletdown = 0xAE9;
+static constexpr uint32_t XK_leftpointer = 0xAEA;
+static constexpr uint32_t XK_rightpointer = 0xAEB;
+static constexpr uint32_t XK_club = 0xAEC;
+static constexpr uint32_t XK_diamond = 0xAED;
+static constexpr uint32_t XK_heart = 0xAEE;
+static constexpr uint32_t XK_maltesecross = 0xAF0;
+static constexpr uint32_t XK_dagger = 0xAF1;
+static constexpr uint32_t XK_doubledagger = 0xAF2;
+static constexpr uint32_t XK_checkmark = 0xAF3;
+static constexpr uint32_t XK_ballotcross = 0xAF4;
+static constexpr uint32_t XK_musicalsharp = 0xAF5;
+static constexpr uint32_t XK_musicalflat = 0xAF6;
+static constexpr uint32_t XK_malesymbol = 0xAF7;
+static constexpr uint32_t XK_femalesymbol = 0xAF8;
+static constexpr uint32_t XK_telephone = 0xAF9;
+static constexpr uint32_t XK_telephonerecorder = 0xAFA;
+static constexpr uint32_t XK_phonographcopyright = 0xAFB;
+static constexpr uint32_t XK_caret = 0xAFC;
+static constexpr uint32_t XK_singlelowquotemark = 0xAFD;
+static constexpr uint32_t XK_doublelowquotemark = 0xAFE;
+static constexpr uint32_t XK_leftcaret = 0xBA3;
+static constexpr uint32_t XK_rightcaret = 0xBA6;
+static constexpr uint32_t XK_downcaret = 0xBA8;
+static constexpr uint32_t XK_upcaret = 0xBA9;
+static constexpr uint32_t XK_overbar = 0xBC0;
+static constexpr uint32_t XK_downtack = 0xBC2;
+static constexpr uint32_t XK_upshoe = 0xBC3;
+static constexpr uint32_t XK_downstile = 0xBC4;
+static constexpr uint32_t XK_underbar = 0xBC6;
+static constexpr uint32_t XK_jot = 0xBCA;
+static constexpr uint32_t XK_quad = 0xBCC;
+static constexpr uint32_t XK_uptack = 0xBCE;
+static constexpr uint32_t XK_circle = 0xBCF;
+static constexpr uint32_t XK_upstile = 0xBD3;
+static constexpr uint32_t XK_downshoe = 0xBD6;
+static constexpr uint32_t XK_rightshoe = 0xBD8;
+static constexpr uint32_t XK_leftshoe = 0xBDA;
+static constexpr uint32_t XK_lefttack = 0xBDC;
+static constexpr uint32_t XK_righttack = 0xBFC;
+static constexpr uint32_t XK_hebrew_doublelowline = 0xCDF;
+static constexpr uint32_t XK_hebrew_aleph = 0xCE0;
+static constexpr uint32_t XK_hebrew_bet = 0xCE1;
+static constexpr uint32_t XK_hebrew_gimel = 0xCE2;
+static constexpr uint32_t XK_hebrew_dalet = 0xCE3;
+static constexpr uint32_t XK_hebrew_he = 0xCE4;
+static constexpr uint32_t XK_hebrew_waw = 0xCE5;
+static constexpr uint32_t XK_hebrew_zain = 0xCE6;
+static constexpr uint32_t XK_hebrew_chet = 0xCE7;
+static constexpr uint32_t XK_hebrew_tet = 0xCE8;
+static constexpr uint32_t XK_hebrew_yod = 0xCE9;
+static constexpr uint32_t XK_hebrew_finalkaph = 0xCEA;
+static constexpr uint32_t XK_hebrew_kaph = 0xCEB;
+static constexpr uint32_t XK_hebrew_lamed = 0xCEC;
+static constexpr uint32_t XK_hebrew_finalmem = 0xCED;
+static constexpr uint32_t XK_hebrew_mem = 0xCEE;
+static constexpr uint32_t XK_hebrew_finalnun = 0xCEF;
+static constexpr uint32_t XK_hebrew_nun = 0xCF0;
+static constexpr uint32_t XK_hebrew_samech = 0xCF1;
+static constexpr uint32_t XK_hebrew_ayin = 0xCF2;
+static constexpr uint32_t XK_hebrew_finalpe = 0xCF3;
+static constexpr uint32_t XK_hebrew_pe = 0xCF4;
+static constexpr uint32_t XK_hebrew_finalzade = 0xCF5;
+static constexpr uint32_t XK_hebrew_zade = 0xCF6;
+static constexpr uint32_t XK_hebrew_qoph = 0xCF7;
+static constexpr uint32_t XK_hebrew_resh = 0xCF8;
+static constexpr uint32_t XK_hebrew_shin = 0xCF9;
+static constexpr uint32_t XK_hebrew_taw = 0xCFA;
+static constexpr uint32_t XK_Thai_kokai = 0xDA1;
+static constexpr uint32_t XK_Thai_khokhai = 0xDA2;
+static constexpr uint32_t XK_Thai_khokhuat = 0xDA3;
+static constexpr uint32_t XK_Thai_khokhwai = 0xDA4;
+static constexpr uint32_t XK_Thai_khokhon = 0xDA5;
+static constexpr uint32_t XK_Thai_khorakhang = 0xDA6;
+static constexpr uint32_t XK_Thai_ngongu = 0xDA7;
+static constexpr uint32_t XK_Thai_chochan = 0xDA8;
+static constexpr uint32_t XK_Thai_choching = 0xDA9;
+static constexpr uint32_t XK_Thai_chochang = 0xDAA;
+static constexpr uint32_t XK_Thai_soso = 0xDAB;
+static constexpr uint32_t XK_Thai_chochoe = 0xDAC;
+static constexpr uint32_t XK_Thai_yoying = 0xDAD;
+static constexpr uint32_t XK_Thai_dochada = 0xDAE;
+static constexpr uint32_t XK_Thai_topatak = 0xDAF;
+static constexpr uint32_t XK_Thai_thothan = 0xDB0;
+static constexpr uint32_t XK_Thai_thonangmontho = 0xDB1;
+static constexpr uint32_t XK_Thai_thophuthao = 0xDB2;
+static constexpr uint32_t XK_Thai_nonen = 0xDB3;
+static constexpr uint32_t XK_Thai_dodek = 0xDB4;
+static constexpr uint32_t XK_Thai_totao = 0xDB5;
+static constexpr uint32_t XK_Thai_thothung = 0xDB6;
+static constexpr uint32_t XK_Thai_thothahan = 0xDB7;
+static constexpr uint32_t XK_Thai_thothong = 0xDB8;
+static constexpr uint32_t XK_Thai_nonu = 0xDB9;
+static constexpr uint32_t XK_Thai_bobaimai = 0xDBA;
+static constexpr uint32_t XK_Thai_popla = 0xDBB;
+static constexpr uint32_t XK_Thai_phophung = 0xDBC;
+static constexpr uint32_t XK_Thai_fofa = 0xDBD;
+static constexpr uint32_t XK_Thai_phophan = 0xDBE;
+static constexpr uint32_t XK_Thai_fofan = 0xDBF;
+static constexpr uint32_t XK_Thai_phosamphao = 0xDC0;
+static constexpr uint32_t XK_Thai_moma = 0xDC1;
+static constexpr uint32_t XK_Thai_yoyak = 0xDC2;
+static constexpr uint32_t XK_Thai_rorua = 0xDC3;
+static constexpr uint32_t XK_Thai_ru = 0xDC4;
+static constexpr uint32_t XK_Thai_loling = 0xDC5;
+static constexpr uint32_t XK_Thai_lu = 0xDC6;
+static constexpr uint32_t XK_Thai_wowaen = 0xDC7;
+static constexpr uint32_t XK_Thai_sosala = 0xDC8;
+static constexpr uint32_t XK_Thai_sorusi = 0xDC9;
+static constexpr uint32_t XK_Thai_sosua = 0xDCA;
+static constexpr uint32_t XK_Thai_hohip = 0xDCB;
+static constexpr uint32_t XK_Thai_lochula = 0xDCC;
+static constexpr uint32_t XK_Thai_oang = 0xDCD;
+static constexpr uint32_t XK_Thai_honokhuk = 0xDCE;
+static constexpr uint32_t XK_Thai_paiyannoi = 0xDCF;
+static constexpr uint32_t XK_Thai_saraa = 0xDD0;
+static constexpr uint32_t XK_Thai_maihanakat = 0xDD1;
+static constexpr uint32_t XK_Thai_saraaa = 0xDD2;
+static constexpr uint32_t XK_Thai_saraam = 0xDD3;
+static constexpr uint32_t XK_Thai_sarai = 0xDD4;
+static constexpr uint32_t XK_Thai_saraii = 0xDD5;
+static constexpr uint32_t XK_Thai_saraue = 0xDD6;
+static constexpr uint32_t XK_Thai_sarauee = 0xDD7;
+static constexpr uint32_t XK_Thai_sarau = 0xDD8;
+static constexpr uint32_t XK_Thai_sarauu = 0xDD9;
+static constexpr uint32_t XK_Thai_phinthu = 0xDDA;
+static constexpr uint32_t XK_Thai_baht = 0xDDF;
+static constexpr uint32_t XK_Thai_sarae = 0xDE0;
+static constexpr uint32_t XK_Thai_saraae = 0xDE1;
+static constexpr uint32_t XK_Thai_sarao = 0xDE2;
+static constexpr uint32_t XK_Thai_saraaimaimuan = 0xDE3;
+static constexpr uint32_t XK_Thai_saraaimaimalai = 0xDE4;
+static constexpr uint32_t XK_Thai_lakkhangyao = 0xDE5;
+static constexpr uint32_t XK_Thai_maiyamok = 0xDE6;
+static constexpr uint32_t XK_Thai_maitaikhu = 0xDE7;
+static constexpr uint32_t XK_Thai_maiek = 0xDE8;
+static constexpr uint32_t XK_Thai_maitho = 0xDE9;
+static constexpr uint32_t XK_Thai_maitri = 0xDEA;
+static constexpr uint32_t XK_Thai_maichattawa = 0xDEB;
+static constexpr uint32_t XK_Thai_thanthakhat = 0xDEC;
+static constexpr uint32_t XK_Thai_nikhahit = 0xDED;
+static constexpr uint32_t XK_Thai_leksun = 0xDF0;
+static constexpr uint32_t XK_Thai_leknung = 0xDF1;
+static constexpr uint32_t XK_Thai_leksong = 0xDF2;
+static constexpr uint32_t XK_Thai_leksam = 0xDF3;
+static constexpr uint32_t XK_Thai_leksi = 0xDF4;
+static constexpr uint32_t XK_Thai_lekha = 0xDF5;
+static constexpr uint32_t XK_Thai_lekhok = 0xDF6;
+static constexpr uint32_t XK_Thai_lekchet = 0xDF7;
+static constexpr uint32_t XK_Thai_lekpaet = 0xDF8;
+static constexpr uint32_t XK_Thai_lekkao = 0xDF9;
+static constexpr uint32_t XK_Hangul_Kiyeog = 0xEA1;
+static constexpr uint32_t XK_Hangul_SsangKiyeog = 0xEA2;
+static constexpr uint32_t XK_Hangul_KiyeogSios = 0xEA3;
+static constexpr uint32_t XK_Hangul_Nieun = 0xEA4;
+static constexpr uint32_t XK_Hangul_NieunJieuj = 0xEA5;
+static constexpr uint32_t XK_Hangul_NieunHieuh = 0xEA6;
+static constexpr uint32_t XK_Hangul_Dikeud = 0xEA7;
+static constexpr uint32_t XK_Hangul_SsangDikeud = 0xEA8;
+static constexpr uint32_t XK_Hangul_Rieul = 0xEA9;
+static constexpr uint32_t XK_Hangul_RieulKiyeog = 0xEAA;
+static constexpr uint32_t XK_Hangul_RieulMieum = 0xEAB;
+static constexpr uint32_t XK_Hangul_RieulPieub = 0xEAC;
+static constexpr uint32_t XK_Hangul_RieulSios = 0xEAD;
+static constexpr uint32_t XK_Hangul_RieulTieut = 0xEAE;
+static constexpr uint32_t XK_Hangul_RieulPhieuf = 0xEAF;
+static constexpr uint32_t XK_Hangul_RieulHieuh = 0xEB0;
+static constexpr uint32_t XK_Hangul_Mieum = 0xEB1;
+static constexpr uint32_t XK_Hangul_Pieub = 0xEB2;
+static constexpr uint32_t XK_Hangul_SsangPieub = 0xEB3;
+static constexpr uint32_t XK_Hangul_PieubSios = 0xEB4;
+static constexpr uint32_t XK_Hangul_Sios = 0xEB5;
+static constexpr uint32_t XK_Hangul_SsangSios = 0xEB6;
+static constexpr uint32_t XK_Hangul_Ieung = 0xEB7;
+static constexpr uint32_t XK_Hangul_Jieuj = 0xEB8;
+static constexpr uint32_t XK_Hangul_SsangJieuj = 0xEB9;
+static constexpr uint32_t XK_Hangul_Cieuc = 0xEBA;
+static constexpr uint32_t XK_Hangul_Khieuq = 0xEBB;
+static constexpr uint32_t XK_Hangul_Tieut = 0xEBC;
+static constexpr uint32_t XK_Hangul_Phieuf = 0xEBD;
+static constexpr uint32_t XK_Hangul_Hieuh = 0xEBE;
+static constexpr uint32_t XK_Hangul_A = 0xEBF;
+static constexpr uint32_t XK_Hangul_AE = 0xEC0;
+static constexpr uint32_t XK_Hangul_YA = 0xEC1;
+static constexpr uint32_t XK_Hangul_YAE = 0xEC2;
+static constexpr uint32_t XK_Hangul_EO = 0xEC3;
+static constexpr uint32_t XK_Hangul_E = 0xEC4;
+static constexpr uint32_t XK_Hangul_YEO = 0xEC5;
+static constexpr uint32_t XK_Hangul_YE = 0xEC6;
+static constexpr uint32_t XK_Hangul_O = 0xEC7;
+static constexpr uint32_t XK_Hangul_WA = 0xEC8;
+static constexpr uint32_t XK_Hangul_WAE = 0xEC9;
+static constexpr uint32_t XK_Hangul_OE = 0xECA;
+static constexpr uint32_t XK_Hangul_YO = 0xECB;
+static constexpr uint32_t XK_Hangul_U = 0xECC;
+static constexpr uint32_t XK_Hangul_WEO = 0xECD;
+static constexpr uint32_t XK_Hangul_WE = 0xECE;
+static constexpr uint32_t XK_Hangul_WI = 0xECF;
+static constexpr uint32_t XK_Hangul_YU = 0xED0;
+static constexpr uint32_t XK_Hangul_EU = 0xED1;
+static constexpr uint32_t XK_Hangul_YI = 0xED2;
+static constexpr uint32_t XK_Hangul_I = 0xED3;
+static constexpr uint32_t XK_Hangul_J_Kiyeog = 0xED4;
+static constexpr uint32_t XK_Hangul_J_SsangKiyeog = 0xED5;
+static constexpr uint32_t XK_Hangul_J_KiyeogSios = 0xED6;
+static constexpr uint32_t XK_Hangul_J_Nieun = 0xED7;
+static constexpr uint32_t XK_Hangul_J_NieunJieuj = 0xED8;
+static constexpr uint32_t XK_Hangul_J_NieunHieuh = 0xED9;
+static constexpr uint32_t XK_Hangul_J_Dikeud = 0xEDA;
+static constexpr uint32_t XK_Hangul_J_Rieul = 0xEDB;
+static constexpr uint32_t XK_Hangul_J_RieulKiyeog = 0xEDC;
+static constexpr uint32_t XK_Hangul_J_RieulMieum = 0xEDD;
+static constexpr uint32_t XK_Hangul_J_RieulPieub = 0xEDE;
+static constexpr uint32_t XK_Hangul_J_RieulSios = 0xEDF;
+static constexpr uint32_t XK_Hangul_J_RieulTieut = 0xEE0;
+static constexpr uint32_t XK_Hangul_J_RieulPhieuf = 0xEE1;
+static constexpr uint32_t XK_Hangul_J_RieulHieuh = 0xEE2;
+static constexpr uint32_t XK_Hangul_J_Mieum = 0xEE3;
+static constexpr uint32_t XK_Hangul_J_Pieub = 0xEE4;
+static constexpr uint32_t XK_Hangul_J_PieubSios = 0xEE5;
+static constexpr uint32_t XK_Hangul_J_Sios = 0xEE6;
+static constexpr uint32_t XK_Hangul_J_SsangSios = 0xEE7;
+static constexpr uint32_t XK_Hangul_J_Ieung = 0xEE8;
+static constexpr uint32_t XK_Hangul_J_Jieuj = 0xEE9;
+static constexpr uint32_t XK_Hangul_J_Cieuc = 0xEEA;
+static constexpr uint32_t XK_Hangul_J_Khieuq = 0xEEB;
+static constexpr uint32_t XK_Hangul_J_Tieut = 0xEEC;
+static constexpr uint32_t XK_Hangul_J_Phieuf = 0xEED;
+static constexpr uint32_t XK_Hangul_J_Hieuh = 0xEEE;
+static constexpr uint32_t XK_Hangul_RieulYeorinHieuh = 0xEEF;
+static constexpr uint32_t XK_Hangul_SunkyeongeumMieum = 0xEF0;
+static constexpr uint32_t XK_Hangul_SunkyeongeumPieub = 0xEF1;
+static constexpr uint32_t XK_Hangul_PanSios = 0xEF2;
+static constexpr uint32_t XK_Hangul_KkogjiDalrinIeung = 0xEF3;
+static constexpr uint32_t XK_Hangul_SunkyeongeumPhieuf = 0xEF4;
+static constexpr uint32_t XK_Hangul_YeorinHieuh = 0xEF5;
+static constexpr uint32_t XK_Hangul_AraeA = 0xEF6;
+static constexpr uint32_t XK_Hangul_AraeAE = 0xEF7;
+static constexpr uint32_t XK_Hangul_J_PanSios = 0xEF8;
+static constexpr uint32_t XK_Hangul_J_KkogjiDalrinIeung = 0xEF9;
+static constexpr uint32_t XK_Hangul_J_YeorinHieuh = 0xEFA;
+static constexpr uint32_t XK_Korean_Won = 0xEFF;
+static constexpr uint32_t XK_OE = 0x13BC;
+static constexpr uint32_t XK_oe = 0x13BD;
+static constexpr uint32_t XK_Ydiaeresis = 0x13BE;
+static constexpr uint32_t XK_EuroSign = 0x20AC;
+static constexpr uint32_t XK_3270_Duplicate = 0xFD01;
+static constexpr uint32_t XK_3270_FieldMark = 0xFD02;
+static constexpr uint32_t XK_3270_Right2 = 0xFD03;
+static constexpr uint32_t XK_3270_Left2 = 0xFD04;
+static constexpr uint32_t XK_3270_BackTab = 0xFD05;
+static constexpr uint32_t XK_3270_EraseEOF = 0xFD06;
+static constexpr uint32_t XK_3270_EraseInput = 0xFD07;
+static constexpr uint32_t XK_3270_Reset = 0xFD08;
+static constexpr uint32_t XK_3270_Quit = 0xFD09;
+static constexpr uint32_t XK_3270_PA1 = 0xFD0A;
+static constexpr uint32_t XK_3270_PA2 = 0xFD0B;
+static constexpr uint32_t XK_3270_PA3 = 0xFD0C;
+static constexpr uint32_t XK_3270_Test = 0xFD0D;
+static constexpr uint32_t XK_3270_Attn = 0xFD0E;
+static constexpr uint32_t XK_3270_CursorBlink = 0xFD0F;
+static constexpr uint32_t XK_3270_AltCursor = 0xFD10;
+static constexpr uint32_t XK_3270_KeyClick = 0xFD11;
+static constexpr uint32_t XK_3270_Jump = 0xFD12;
+static constexpr uint32_t XK_3270_Ident = 0xFD13;
+static constexpr uint32_t XK_3270_Rule = 0xFD14;
+static constexpr uint32_t XK_3270_Copy = 0xFD15;
+static constexpr uint32_t XK_3270_Play = 0xFD16;
+static constexpr uint32_t XK_3270_Setup = 0xFD17;
+static constexpr uint32_t XK_3270_Record = 0xFD18;
+static constexpr uint32_t XK_3270_ChangeScreen = 0xFD19;
+static constexpr uint32_t XK_3270_DeleteWord = 0xFD1A;
+static constexpr uint32_t XK_3270_ExSelect = 0xFD1B;
+static constexpr uint32_t XK_3270_CursorSelect = 0xFD1C;
+static constexpr uint32_t XK_3270_PrintScreen = 0xFD1D;
+static constexpr uint32_t XK_3270_Enter = 0xFD1E;
+static constexpr uint32_t XK_ISO_Lock = 0xFE01;
+static constexpr uint32_t XK_ISO_Level3_Shift = 0xFE03;
+static constexpr uint32_t XK_ISO_Level3_Latch = 0xFE04;
+static constexpr uint32_t XK_ISO_Next_Group = 0xFE08;
+static constexpr uint32_t XK_ISO_Next_Group_Lock = 0xFE09;
+static constexpr uint32_t XK_ISO_Prev_Group = 0xFE0A;
+static constexpr uint32_t XK_ISO_Prev_Group_Lock = 0xFE0B;
+static constexpr uint32_t XK_ISO_First_Group = 0xFE0C;
+static constexpr uint32_t XK_ISO_First_Group_Lock = 0xFE0D;
+static constexpr uint32_t XK_ISO_Last_Group = 0xFE0E;
+static constexpr uint32_t XK_ISO_Last_Group_Lock = 0xFE0F;
+static constexpr uint32_t XK_ISO_Level5_Shift = 0xFE11;
+static constexpr uint32_t XK_ISO_Level5_Lock = 0xFE13;
+static constexpr uint32_t XK_ISO_Left_Tab = 0xFE20;
+static constexpr uint32_t XK_ISO_Enter = 0xFE34;
+static constexpr uint32_t XK_dead_grave = 0xFE50;
+static constexpr uint32_t XK_dead_acute = 0xFE51;
+static constexpr uint32_t XK_dead_circumflex = 0xFE52;
+static constexpr uint32_t XK_dead_tilde = 0xFE53;
+static constexpr uint32_t XK_dead_macron = 0xFE54;
+static constexpr uint32_t XK_dead_breve = 0xFE55;
+static constexpr uint32_t XK_dead_abovedot = 0xFE56;
+static constexpr uint32_t XK_dead_diaeresis = 0xFE57;
+static constexpr uint32_t XK_dead_abovering = 0xFE58;
+static constexpr uint32_t XK_dead_doubleacute = 0xFE59;
+static constexpr uint32_t XK_dead_caron = 0xFE5A;
+static constexpr uint32_t XK_dead_cedilla = 0xFE5B;
+static constexpr uint32_t XK_dead_ogonek = 0xFE5C;
+static constexpr uint32_t XK_dead_iota = 0xFE5D;
+static constexpr uint32_t XK_dead_voiced_sound = 0xFE5E;
+static constexpr uint32_t XK_dead_semivoiced_sound = 0xFE5F;
+static constexpr uint32_t XK_dead_belowdot = 0xFE60;
+static constexpr uint32_t XK_dead_hook = 0xFE61;
+static constexpr uint32_t XK_dead_horn = 0xFE62;
+static constexpr uint32_t XK_dead_stroke = 0xFE63;
+static constexpr uint32_t XK_dead_abovecomma = 0xFE64;
+static constexpr uint32_t XK_dead_abovereversedcomma = 0xFE65;
+static constexpr uint32_t XK_dead_doublegrave = 0xFE66;
+static constexpr uint32_t XK_dead_belowring = 0xFE67;
+static constexpr uint32_t XK_dead_belowmacron = 0xFE68;
+static constexpr uint32_t XK_dead_belowcircumflex = 0xFE69;
+static constexpr uint32_t XK_dead_belowtilde = 0xFE6A;
+static constexpr uint32_t XK_dead_belowbreve = 0xFE6B;
+static constexpr uint32_t XK_dead_belowdiaeresis = 0xFE6C;
+static constexpr uint32_t XK_dead_invertedbreve = 0xFE6D;
+static constexpr uint32_t XK_dead_belowcomma = 0xFE6E;
+static constexpr uint32_t XK_dead_currency = 0xFE6F;
+static constexpr uint32_t XK_dead_greek = 0xFE8C;
+static constexpr uint32_t XK_Next_Virtual_Screen = 0xFED2;
+static constexpr uint32_t XK_BackSpace = 0xFF08;
+static constexpr uint32_t XK_Tab = 0xFF09;
+static constexpr uint32_t XK_Linefeed = 0xFF0A;
+static constexpr uint32_t XK_Clear = 0xFF0B;
+static constexpr uint32_t XK_Return = 0xFF0D;
+static constexpr uint32_t XK_Pause = 0xFF13;
+static constexpr uint32_t XK_Scroll_Lock = 0xFF14;
+static constexpr uint32_t XK_Sys_Req = 0xFF15;
+static constexpr uint32_t XK_Escape = 0xFF1B;
+static constexpr uint32_t XK_Multi_key = 0xFF20;
+static constexpr uint32_t XK_Kanji = 0xFF21;
+static constexpr uint32_t XK_Muhenkan = 0xFF22;
+static constexpr uint32_t XK_Henkan = 0xFF23;
+static constexpr uint32_t XK_Henkan_Mode = 0xFF23;
+static constexpr uint32_t XK_Romaji = 0xFF24;
+static constexpr uint32_t XK_Hiragana = 0xFF25;
+static constexpr uint32_t XK_Katakana = 0xFF26;
+static constexpr uint32_t XK_Hiragana_Katakana = 0xFF27;
+static constexpr uint32_t XK_Zenkaku = 0xFF28;
+static constexpr uint32_t XK_Hankaku = 0xFF29;
+static constexpr uint32_t XK_Zenkaku_Hankaku = 0xFF2A;
+static constexpr uint32_t XK_Kana_Lock = 0xFF2D;
+static constexpr uint32_t XK_Kana_Shift = 0xFF2E;
+static constexpr uint32_t XK_Eisu_Shift = 0xFF2F;
+static constexpr uint32_t XK_Eisu_toggle = 0xFF30;
+static constexpr uint32_t XK_Hangul = 0xFF31;
+static constexpr uint32_t XK_Hangul_Start = 0xFF32;
+static constexpr uint32_t XK_Hangul_End = 0xFF33;
+static constexpr uint32_t XK_Hangul_Hanja = 0xFF34;
+static constexpr uint32_t XK_Hangul_Jamo = 0xFF35;
+static constexpr uint32_t XK_Hangul_Romaja = 0xFF36;
+static constexpr uint32_t XK_Codeinput = 0xFF37;
+static constexpr uint32_t XK_Hangul_Jeonja = 0xFF38;
+static constexpr uint32_t XK_Hangul_Banja = 0xFF39;
+static constexpr uint32_t XK_Hangul_PreHanja = 0xFF3A;
+static constexpr uint32_t XK_Hangul_PostHanja = 0xFF3B;
+static constexpr uint32_t XK_SingleCandidate = 0xFF3C;
+static constexpr uint32_t XK_MultipleCandidate = 0xFF3D;
+static constexpr uint32_t XK_PreviousCandidate = 0xFF3E;
+static constexpr uint32_t XK_Hangul_Special = 0xFF3F;
+static constexpr uint32_t XK_Home = 0xFF50;
+static constexpr uint32_t XK_Left = 0xFF51;
+static constexpr uint32_t XK_Up = 0xFF52;
+static constexpr uint32_t XK_Right = 0xFF53;
+static constexpr uint32_t XK_Down = 0xFF54;
+static constexpr uint32_t XK_Page_Up = 0xFF55;
+static constexpr uint32_t XK_Prior = 0xFF55;
+static constexpr uint32_t XK_Next = 0xFF56;
+static constexpr uint32_t XK_Page_Down = 0xFF56;
+static constexpr uint32_t XK_End = 0xFF57;
+static constexpr uint32_t XK_Select = 0xFF60;
+static constexpr uint32_t XK_Print = 0xFF61;
+static constexpr uint32_t XK_Execute = 0xFF62;
+static constexpr uint32_t XK_Insert = 0xFF63;
+static constexpr uint32_t XK_Undo = 0xFF65;
+static constexpr uint32_t XK_Redo = 0xFF66;
+static constexpr uint32_t XK_Menu = 0xFF67;
+static constexpr uint32_t XK_Find = 0xFF68;
+static constexpr uint32_t XK_Cancel = 0xFF69;
+static constexpr uint32_t XK_Help = 0xFF6A;
+static constexpr uint32_t XK_Break = 0xFF6B;
+static constexpr uint32_t XK_Mode_switch = 0xFF7E;
+static constexpr uint32_t XK_Num_Lock = 0xFF7F;
+static constexpr uint32_t XK_KP_Space = 0xFF80;
+static constexpr uint32_t XK_KP_Tab = 0xFF89;
+static constexpr uint32_t XK_KP_Enter = 0xFF8D;
+static constexpr uint32_t XK_KP_F1 = 0xFF91;
+static constexpr uint32_t XK_KP_F2 = 0xFF92;
+static constexpr uint32_t XK_KP_F3 = 0xFF93;
+static constexpr uint32_t XK_KP_F4 = 0xFF94;
+static constexpr uint32_t XK_KP_Home = 0xFF95;
+static constexpr uint32_t XK_KP_Left = 0xFF96;
+static constexpr uint32_t XK_KP_Up = 0xFF97;
+static constexpr uint32_t XK_KP_Right = 0xFF98;
+static constexpr uint32_t XK_KP_Down = 0xFF99;
+static constexpr uint32_t XK_KP_Page_Up = 0xFF9A;
+static constexpr uint32_t XK_KP_Prior = 0xFF9A;
+static constexpr uint32_t XK_KP_Next = 0xFF9B;
+static constexpr uint32_t XK_KP_Page_Down = 0xFF9B;
+static constexpr uint32_t XK_KP_End = 0xFF9C;
+static constexpr uint32_t XK_KP_Begin = 0xFF9D;
+static constexpr uint32_t XK_KP_Insert = 0xFF9E;
+static constexpr uint32_t XK_KP_Delete = 0xFF9F;
+static constexpr uint32_t XK_KP_Multiply = 0xFFAA;
+static constexpr uint32_t XK_KP_Add = 0xFFAB;
+static constexpr uint32_t XK_KP_Separator = 0xFFAC;
+static constexpr uint32_t XK_KP_Subtract = 0xFFAD;
+static constexpr uint32_t XK_KP_Decimal = 0xFFAE;
+static constexpr uint32_t XK_KP_Divide = 0xFFAF;
+static constexpr uint32_t XK_KP_0 = 0xFFB0;
+static constexpr uint32_t XK_KP_1 = 0xFFB1;
+static constexpr uint32_t XK_KP_2 = 0xFFB2;
+static constexpr uint32_t XK_KP_3 = 0xFFB3;
+static constexpr uint32_t XK_KP_4 = 0xFFB4;
+static constexpr uint32_t XK_KP_5 = 0xFFB5;
+static constexpr uint32_t XK_KP_6 = 0xFFB6;
+static constexpr uint32_t XK_KP_7 = 0xFFB7;
+static constexpr uint32_t XK_KP_8 = 0xFFB8;
+static constexpr uint32_t XK_KP_9 = 0xFFB9;
+static constexpr uint32_t XK_KP_Equal = 0xFFBD;
+static constexpr uint32_t XK_F1 = 0xFFBE;
+static constexpr uint32_t XK_F2 = 0xFFBF;
+static constexpr uint32_t XK_F3 = 0xFFC0;
+static constexpr uint32_t XK_F4 = 0xFFC1;
+static constexpr uint32_t XK_F5 = 0xFFC2;
+static constexpr uint32_t XK_F6 = 0xFFC3;
+static constexpr uint32_t XK_F7 = 0xFFC4;
+static constexpr uint32_t XK_F8 = 0xFFC5;
+static constexpr uint32_t XK_F9 = 0xFFC6;
+static constexpr uint32_t XK_F10 = 0xFFC7;
+static constexpr uint32_t XK_F11 = 0xFFC8;
+static constexpr uint32_t XK_F12 = 0xFFC9;
+static constexpr uint32_t XK_F13 = 0xFFCA;
+static constexpr uint32_t XK_F14 = 0xFFCB;
+static constexpr uint32_t XK_F15 = 0xFFCC;
+static constexpr uint32_t XK_F16 = 0xFFCD;
+static constexpr uint32_t XK_F17 = 0xFFCE;
+static constexpr uint32_t XK_F18 = 0xFFCF;
+static constexpr uint32_t XK_F19 = 0xFFD0;
+static constexpr uint32_t XK_F20 = 0xFFD1;
+static constexpr uint32_t XK_F21 = 0xFFD2;
+static constexpr uint32_t XK_F22 = 0xFFD3;
+static constexpr uint32_t XK_F23 = 0xFFD4;
+static constexpr uint32_t XK_F24 = 0xFFD5;
+static constexpr uint32_t XK_F25 = 0xFFD6;
+static constexpr uint32_t XK_F26 = 0xFFD7;
+static constexpr uint32_t XK_F27 = 0xFFD8;
+static constexpr uint32_t XK_F28 = 0xFFD9;
+static constexpr uint32_t XK_F29 = 0xFFDA;
+static constexpr uint32_t XK_F30 = 0xFFDB;
+static constexpr uint32_t XK_F31 = 0xFFDC;
+static constexpr uint32_t XK_F32 = 0xFFDD;
+static constexpr uint32_t XK_F33 = 0xFFDE;
+static constexpr uint32_t XK_F34 = 0xFFDF;
+static constexpr uint32_t XK_F35 = 0xFFE0;
+static constexpr uint32_t XK_Shift_L = 0xFFE1;
+static constexpr uint32_t XK_Shift_R = 0xFFE2;
+static constexpr uint32_t XK_Control_L = 0xFFE3;
+static constexpr uint32_t XK_Control_R = 0xFFE4;
+static constexpr uint32_t XK_Caps_Lock = 0xFFE5;
+static constexpr uint32_t XK_Shift_Lock = 0xFFE6;
+static constexpr uint32_t XK_Meta_L = 0xFFE7;
+static constexpr uint32_t XK_Meta_R = 0xFFE8;
+static constexpr uint32_t XK_Alt_L = 0xFFE9;
+static constexpr uint32_t XK_Alt_R = 0xFFEA;
+static constexpr uint32_t XK_Super_L = 0xFFEB;
+static constexpr uint32_t XK_Super_R = 0xFFEC;
+static constexpr uint32_t XK_Hyper_L = 0xFFED;
+static constexpr uint32_t XK_Hyper_R = 0xFFEE;
+static constexpr uint32_t XK_Delete = 0xFFFF;
+static constexpr uint32_t XK_VoidSymbol = 0xFFFFFF;
+static constexpr uint32_t SunXK_Props = 0x1005FF70;
+static constexpr uint32_t SunXK_Copy = 0x1005FF72;
+static constexpr uint32_t SunXK_Open = 0x1005FF73;
+static constexpr uint32_t SunXK_Paste = 0x1005FF74;
+static constexpr uint32_t SunXK_Cut = 0x1005FF75;
+static constexpr uint32_t XF86XK_ClearGrab = 0x1008FE21;
+static constexpr uint32_t XF86XK_Next_VMode = 0x1008FE22;
+static constexpr uint32_t XF86XK_MonBrightnessUp = 0x1008FF02;
+static constexpr uint32_t XF86XK_MonBrightnessDown = 0x1008FF03;
+static constexpr uint32_t XF86XK_KbdBrightnessUp = 0x1008FF05;
+static constexpr uint32_t XF86XK_KbdBrightnessDown = 0x1008FF06;
+static constexpr uint32_t XF86XK_Standby = 0x1008FF10;
+static constexpr uint32_t XF86XK_AudioLowerVolume = 0x1008FF11;
+static constexpr uint32_t XF86XK_AudioMute = 0x1008FF12;
+static constexpr uint32_t XF86XK_AudioRaiseVolume = 0x1008FF13;
+static constexpr uint32_t XF86XK_AudioPlay = 0x1008FF14;
+static constexpr uint32_t XF86XK_AudioStop = 0x1008FF15;
+static constexpr uint32_t XF86XK_AudioPrev = 0x1008FF16;
+static constexpr uint32_t XF86XK_AudioNext = 0x1008FF17;
+static constexpr uint32_t XF86XK_HomePage = 0x1008FF18;
+static constexpr uint32_t XF86XK_Mail = 0x1008FF19;
+static constexpr uint32_t XF86XK_Search = 0x1008FF1B;
+static constexpr uint32_t XF86XK_AudioRecord = 0x1008FF1C;
+static constexpr uint32_t XF86XK_Calculator = 0x1008FF1D;
+static constexpr uint32_t XF86XK_Calendar = 0x1008FF20;
+static constexpr uint32_t XF86XK_Back = 0x1008FF26;
+static constexpr uint32_t XF86XK_Forward = 0x1008FF27;
+static constexpr uint32_t XF86XK_Stop = 0x1008FF28;
+static constexpr uint32_t XF86XK_Refresh = 0x1008FF29;
+static constexpr uint32_t XF86XK_PowerOff = 0x1008FF2A;
+static constexpr uint32_t XF86XK_WakeUp = 0x1008FF2B;
+static constexpr uint32_t XF86XK_Eject = 0x1008FF2C;
+static constexpr uint32_t XF86XK_ScreenSaver = 0x1008FF2D;
+static constexpr uint32_t XF86XK_WWW = 0x1008FF2E;
+static constexpr uint32_t XF86XK_Sleep = 0x1008FF2F;
+static constexpr uint32_t XF86XK_Favorites = 0x1008FF30;
+static constexpr uint32_t XF86XK_AudioPause = 0x1008FF31;
+static constexpr uint32_t XF86XK_AudioMedia = 0x1008FF32;
+static constexpr uint32_t XF86XK_MyComputer = 0x1008FF33;
+static constexpr uint32_t XF86XK_OpenURL = 0x1008FF38;
+static constexpr uint32_t XF86XK_AudioRewind = 0x1008FF3E;
+static constexpr uint32_t XF86XK_BackForward = 0x1008FF3F;
+static constexpr uint32_t XF86XK_Launch5 = 0x1008FF45;
+static constexpr uint32_t XF86XK_Launch6 = 0x1008FF46;
+static constexpr uint32_t XF86XK_Launch7 = 0x1008FF47;
+static constexpr uint32_t XF86XK_Launch8 = 0x1008FF48;
+static constexpr uint32_t XF86XK_Launch9 = 0x1008FF49;
+static constexpr uint32_t XF86XK_LaunchA = 0x1008FF4A;
+static constexpr uint32_t XF86XK_LaunchB = 0x1008FF4B;
+static constexpr uint32_t XF86XK_CD = 0x1008FF53;
+static constexpr uint32_t XF86XK_Clear = 0x1008FF55;
+static constexpr uint32_t XF86XK_Close = 0x1008FF56;
+static constexpr uint32_t XF86XK_Copy = 0x1008FF57;
+static constexpr uint32_t XF86XK_Cut = 0x1008FF58;
+static constexpr uint32_t XF86XK_Display = 0x1008FF59;
+static constexpr uint32_t XF86XK_Excel = 0x1008FF5C;
+static constexpr uint32_t XF86XK_Explorer = 0x1008FF5D;
+static constexpr uint32_t XF86XK_LogOff = 0x1008FF61;
+static constexpr uint32_t XF86XK_MenuKB = 0x1008FF65;
+static constexpr uint32_t XF86XK_MenuPB = 0x1008FF66;
+static constexpr uint32_t XF86XK_New = 0x1008FF68;
+static constexpr uint32_t XF86XK_News = 0x1008FF69;
+static constexpr uint32_t XF86XK_OfficeHome = 0x1008FF6A;
+static constexpr uint32_t XF86XK_Open = 0x1008FF6B;
+static constexpr uint32_t XF86XK_Paste = 0x1008FF6D;
+static constexpr uint32_t XF86XK_Reply = 0x1008FF72;
+static constexpr uint32_t XF86XK_Reload = 0x1008FF73;
+static constexpr uint32_t XF86XK_Save = 0x1008FF77;
+static constexpr uint32_t XF86XK_ScrollUp = 0x1008FF78;
+static constexpr uint32_t XF86XK_ScrollDown = 0x1008FF79;
+static constexpr uint32_t XF86XK_Send = 0x1008FF7B;
+static constexpr uint32_t XF86XK_Spell = 0x1008FF7C;
+static constexpr uint32_t XF86XK_SplitScreen = 0x1008FF7D;
+static constexpr uint32_t XF86XK_Tools = 0x1008FF81;
+static constexpr uint32_t XF86XK_Video = 0x1008FF87;
+static constexpr uint32_t XF86XK_Word = 0x1008FF89;
+static constexpr uint32_t XF86XK_ZoomIn = 0x1008FF8B;
+static constexpr uint32_t XF86XK_ZoomOut = 0x1008FF8C;
+static constexpr uint32_t XF86XK_WebCam = 0x1008FF8F;
+static constexpr uint32_t XF86XK_MailForward = 0x1008FF90;
+static constexpr uint32_t XF86XK_Music = 0x1008FF92;
+static constexpr uint32_t XF86XK_WLAN = 0x1008FF95;
+static constexpr uint32_t XF86XK_AudioForward = 0x1008FF97;
+static constexpr uint32_t XF86XK_AudioRandomPlay = 0x1008FF99;
+static constexpr uint32_t XF86XK_Subtitle = 0x1008FF9A;
+static constexpr uint32_t XF86XK_Select = 0x1008FFA0;
+static constexpr uint32_t XF86XK_Suspend = 0x1008FFA7;
+static constexpr uint32_t XF86XK_Hibernate = 0x1008FFA8;
+
+#endif // UI_GFX_X_KEYSYMS_KEYSYMS_H_
diff --git a/ui/gfx/x/x11.h b/ui/gfx/x/x11.h
index 6abc5808..6b36d48 100644
--- a/ui/gfx/x/x11.h
+++ b/ui/gfx/x/x11.h
@@ -2,99 +2,387 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-// This header file replaces includes of X11 system includes while
-// preventing them from redefining and making a mess of commonly used
-// keywords like "None" and "Status". Instead those are placed inside
-// an X11 namespace where they will not clash with other code.
+// This header file replaces <X11/Xlib.h>. https://crbug.com/1066670 is
+// tracking removing usage of Xlib altogether. Do not add more Xlib
+// declarations here. The intention is to incrementally remove declarations
+// until there is nothing left, at which point this file will be removed.
-#ifndef UI_GFX_X_X11
-#define UI_GFX_X_X11
-
-extern "C" {
-// Xlib.h defines base types so it must be included before the less
-// central X11 headers can be included.
-#include <X11/Xlib.h>
-
-// And the rest so that nobody needs to include them manually...
-#include <X11/XKBlib.h>
-#include <X11/Xlib-xcb.h>
-
-// Define XK_xxx before the #include of <X11/keysym.h> so that <X11/keysym.h>
-// defines all KeySyms we need.
-#define XK_3270 // For XK_3270_BackTab in particular.
-#define XK_MISCELLANY
-#define XK_LATIN1
-#define XK_LATIN2
-#define XK_LATIN3
-#define XK_LATIN4
-#define XK_LATIN8
-#define XK_LATIN9
-#define XK_KATAKANA
-#define XK_ARABIC
-#define XK_CYRILLIC
-#define XK_GREEK
-#define XK_TECHNICAL
-#define XK_SPECIAL
-#define XK_PUBLISHING
-#define XK_APL
-#define XK_HEBREW
-#define XK_THAI
-#define XK_KOREAN
-#define XK_ARMENIAN
-#define XK_GEORGIAN
-#define XK_CAUCASUS
-#define XK_VIETNAMESE
-#define XK_CURRENCY
-#define XK_MATHEMATICAL
-#define XK_BRAILLE
-#define XK_SINHALA
-#define XK_XKB_KEYS
-
-#ifndef XK_dead_greek
-#define XK_dead_greek 0xfe8c
-#endif
-
-#include <X11/Sunkeysym.h>
-#include <X11/XF86keysym.h>
-#include <X11/keysym.h>
-}
-
-#include "ui/gfx/x/xproto_undef.h"
+#ifndef UI_GFX_X_X11_H_
+#define UI_GFX_X_X11_H_
#include "ui/gfx/x/connection.h"
-// These commonly used names are undefined and if necessary recreated
-// in the x11 namespace below. This is the main purpose of this header
-// file.
+// Temporarily declare Xlib symbols we require. Do not add more Xlib
+// declarations here and do not include anything from <X11/*>.
-// Not using common words is extra important for jumbo builds
-// where cc files are merged. Those merged filed get to see many more
-// headers than initially expected, including system headers like
-// those from X11.
+extern "C" {
-#undef Status // Defined by X11/Xlib.h to int
-#undef Bool // Defined by X11/Xlib.h to int
-#undef RootWindow // Defined by X11/Xlib.h
-#undef DestroyAll // Defined by X11/X.h to 0
-#undef Always // Defined by X11/X.h to 2
-#undef FocusIn // Defined by X.h to 9
-#undef FocusOut // Defined by X.h to 10
-#undef None // Defined by X11/X.h to 0L
-#undef True // Defined by X11/Xlib.h to 1
-#undef False // Defined by X11/Xlib.h to 0
-#undef CurrentTime // Defined by X11/X.h to 0L
-#undef Success // Defined by X11/X.h to 0
+static constexpr auto GrabModeAsync = 1;
-// The x11 namespace allows to scope X11 constants and types that
-// would be problematic at the default preprocessor level.
+static constexpr auto ShiftMask = 1 << 0;
+static constexpr auto LockMask = 1 << 1;
+static constexpr auto ControlMask = 1 << 2;
+static constexpr auto Mod1Mask = 1 << 3;
+static constexpr auto Mod2Mask = 1 << 4;
+static constexpr auto Mod3Mask = 1 << 5;
+static constexpr auto Mod4Mask = 1 << 6;
+static constexpr auto Mod5Mask = 1 << 7;
+
+static constexpr auto NoEventMask = 0L;
+static constexpr auto KeyPressMask = 1L << 0;
+static constexpr auto KeyReleaseMask = 1L << 1;
+static constexpr auto ButtonPressMask = 1L << 2;
+static constexpr auto ButtonReleaseMask = 1L << 3;
+static constexpr auto EnterWindowMask = 1L << 4;
+static constexpr auto LeaveWindowMask = 1L << 5;
+static constexpr auto PointerMotionMask = 1L << 6;
+static constexpr auto PointerMotionHintMask = 1L << 7;
+static constexpr auto Button1MotionMask = 1L << 8;
+static constexpr auto Button2MotionMask = 1L << 9;
+static constexpr auto Button3MotionMask = 1L << 10;
+static constexpr auto Button4MotionMask = 1L << 11;
+static constexpr auto Button5MotionMask = 1L << 12;
+static constexpr auto ButtonMotionMask = 1L << 13;
+static constexpr auto KeymapStateMask = 1L << 14;
+static constexpr auto ExposureMask = 1L << 15;
+static constexpr auto VisibilityChangeMask = 1L << 16;
+static constexpr auto StructureNotifyMask = 1L << 17;
+static constexpr auto ResizeRedirectMask = 1L << 18;
+static constexpr auto SubstructureNotifyMask = 1L << 19;
+static constexpr auto SubstructureRedirectMask = 1L << 20;
+static constexpr auto FocusChangeMask = 1L << 21;
+static constexpr auto PropertyChangeMask = 1L << 22;
+static constexpr auto ColormapChangeMask = 1L << 23;
+static constexpr auto OwnerGrabButtonMask = 1L << 24;
+
+static constexpr auto CWBackPixmap = 1L << 0;
+static constexpr auto CWBackPixel = 1L << 1;
+static constexpr auto CWBorderPixmap = 1L << 2;
+static constexpr auto CWBorderPixel = 1L << 3;
+static constexpr auto CWBitGravity = 1L << 4;
+static constexpr auto CWWinGravity = 1L << 5;
+static constexpr auto CWBackingStore = 1L << 6;
+static constexpr auto CWBackingPlanes = 1L << 7;
+static constexpr auto CWBackingPixel = 1L << 8;
+static constexpr auto CWOverrideRedirect = 1L << 9;
+static constexpr auto CWSaveUnder = 1L << 10;
+static constexpr auto CWEventMask = 1L << 11;
+static constexpr auto CWDontPropagate = 1L << 12;
+static constexpr auto CWColormap = 1L << 13;
+static constexpr auto CWCursor = 1L << 14;
+
+static constexpr auto ForgetGravity = 0;
+static constexpr auto NorthWestGravity = 1;
+static constexpr auto NorthGravity = 2;
+static constexpr auto NorthEastGravity = 3;
+static constexpr auto WestGravity = 4;
+static constexpr auto CenterGravity = 5;
+static constexpr auto EastGravity = 6;
+static constexpr auto SouthWestGravity = 7;
+static constexpr auto SouthGravity = 8;
+static constexpr auto SouthEastGravity = 9;
+static constexpr auto StaticGravity = 10;
+
+static constexpr auto Button1Mask = 1 << 8;
+static constexpr auto Button2Mask = 1 << 9;
+static constexpr auto Button3Mask = 1 << 10;
+static constexpr auto Button4Mask = 1 << 11;
+static constexpr auto Button5Mask = 1 << 12;
+
+static constexpr auto CWX = 1 << 0;
+static constexpr auto CWY = 1 << 1;
+static constexpr auto CWWidth = 1 << 2;
+static constexpr auto CWHeight = 1 << 3;
+static constexpr auto CWBorderWidth = 1 << 4;
+static constexpr auto CWSibling = 1 << 5;
+static constexpr auto CWStackMode = 1 << 6;
+
+static constexpr auto NotifyNormal = 0;
+static constexpr auto NotifyGrab = 1;
+static constexpr auto NotifyUngrab = 2;
+static constexpr auto NotifyWhileGrabbed = 3;
+
+static constexpr auto NotifyAncestor = 0;
+static constexpr auto NotifyVirtual = 1;
+static constexpr auto NotifyInferior = 2;
+static constexpr auto NotifyNonlinear = 3;
+static constexpr auto NotifyNonlinearVirtual = 4;
+static constexpr auto NotifyPointer = 5;
+static constexpr auto NotifyPointerRoot = 6;
+static constexpr auto NotifyDetailNone = 7;
+
+static constexpr auto PropModeReplace = 0;
+static constexpr auto PropModePrepend = 1;
+static constexpr auto PropModeAppend = 2;
+
+static constexpr auto AnyPropertyType = 0L;
+
+static constexpr auto NoSymbol = 0L;
+
+using Status = int;
+using Bool = int;
+using XID = unsigned long;
+using KeySym = XID;
+using KeyCode = unsigned char;
+using Window = XID;
+using Pixmap = XID;
+using Font = XID;
+using VisualID = unsigned long;
+using XPointer = char*;
+using Colormap = XID;
+using Cursor = XID;
+using Atom = unsigned long;
+using Time = unsigned long;
+using GC = struct _XGC*;
+using Display = struct _XDisplay;
+using xcb_connection_t = struct xcb_connection_t;
+
+enum XEventQueueOwner { XlibOwnsEventQueue = 0, XCBOwnsEventQueue };
+
+using XErrorEvent = struct {
+ int type;
+ Display* display;
+ XID resourceid;
+ unsigned long serial;
+ unsigned char error_code;
+ unsigned char request_code;
+ unsigned char minor_code;
+};
+
+using XRectangle = struct {
+ short x, y;
+ unsigned short width, height;
+};
+
+using XExtData = struct _XExtData {
+ int number;
+ struct _XExtData* next;
+ int (*free_private)(struct _XExtData* extension);
+ XPointer private_data;
+};
+
+using Visual = struct {
+ XExtData* ext_data;
+ VisualID visualid;
+ int c_class;
+ unsigned long red_mask, green_mask, blue_mask;
+ int bits_per_rgb;
+ int map_entries;
+};
+
+using XVisualInfo = struct {
+ Visual* visual;
+ VisualID visualid;
+ int screen;
+ int depth;
+ int c_class;
+ unsigned long red_mask;
+ unsigned long green_mask;
+ unsigned long blue_mask;
+ int colormap_size;
+ int bits_per_rgb;
+};
+
+using Depth = struct {
+ int depth;
+ int nvisuals;
+ Visual* visuals;
+};
+
+using Screen = struct {
+ XExtData* ext_data;
+ struct _XDisplay* display;
+ Window root;
+ int width, height;
+ int mwidth, mheight;
+ int ndepths;
+ Depth* depths;
+ int root_depth;
+ Visual* root_visual;
+ GC default_gc;
+ Colormap cmap;
+ unsigned long white_pixel;
+ unsigned long black_pixel;
+ int max_maps, min_maps;
+ int backing_store;
+ Bool save_unders;
+ long root_input_mask;
+};
+
+using XSetWindowAttributes = struct {
+ Pixmap background_pixmap;
+ unsigned long background_pixel;
+ Pixmap border_pixmap;
+ unsigned long border_pixel;
+ int bit_gravity;
+ int win_gravity;
+ int backing_store;
+ unsigned long backing_planes;
+ unsigned long backing_pixel;
+ Bool save_under;
+ long event_mask;
+ long do_not_propagate_mask;
+ Bool override_redirect;
+ Colormap colormap;
+ Cursor cursor;
+};
+
+using XWindowAttributes = struct {
+ int x, y;
+ int width, height;
+ int border_width;
+ int depth;
+ Visual* visual;
+ Window root;
+ int c_class;
+ int bit_gravity;
+ int win_gravity;
+ int backing_store;
+ unsigned long backing_planes;
+ unsigned long backing_pixel;
+ Bool save_under;
+ Colormap colormap;
+ Bool map_installed;
+ int map_state;
+ long all_event_masks;
+ long your_event_mask;
+ long do_not_propagate_mask;
+ Bool override_redirect;
+ Screen* screen;
+};
+
+using XWindowChanges = struct {
+ int x, y;
+ int width, height;
+ int border_width;
+ Window sibling;
+ int stack_mode;
+};
+
+using XModifierKeymap = struct {
+ int max_keypermod;
+ KeyCode* modifiermap;
+};
+
+using XErrorHandler = int (*)(Display*, XErrorEvent*);
+using XIOErrorHandler = int (*)(Display*);
+
+Status XInitThreads(void);
+Display* XOpenDisplay(const char*);
+int XCloseDisplay(Display*);
+char* XDisplayString(Display*);
+int XFlush(Display*);
+xcb_connection_t* XGetXCBConnection(Display* dpy);
+void XSetEventQueueOwner(Display* dpy, enum XEventQueueOwner owner);
+int XDefaultScreen(Display*);
+Window XDefaultRootWindow(Display*);
+Visual* XDefaultVisual(Display*, int);
+unsigned long XLastKnownRequestProcessed(Display*);
+int (*XSynchronize(Display*, Bool))(Display*);
+int XGetErrorDatabaseText(Display*,
+ const char*,
+ const char*,
+ const char*,
+ char*,
+ int);
+int XGetErrorText(Display*, int, char*, int);
+Bool XQueryExtension(Display*, const char*, int*, int*, int*);
+int XSync(Display*, Bool);
+XErrorHandler XSetErrorHandler(XErrorHandler);
+XIOErrorHandler XSetIOErrorHandler(XIOErrorHandler);
+void XLockDisplay(Display*);
+extern void XUnlockDisplay(Display*);
+int XConnectionNumber(Display*);
+int XGrabKey(Display*, int, unsigned int, Window, Bool, int, int);
+int XUngrabKey(Display*, int, unsigned int, Window);
+int XSelectInput(Display*, Window, long);
+int XSetWindowBackgroundPixmap(Display*, Window, Pixmap);
+Window XCreateWindow(Display*,
+ Window,
+ int,
+ int,
+ unsigned int,
+ unsigned int,
+ unsigned int,
+ int,
+ unsigned int,
+ Visual*,
+ unsigned long,
+ XSetWindowAttributes*);
+Window XCreateSimpleWindow(Display*,
+ Window,
+ int,
+ int,
+ unsigned int,
+ unsigned int,
+ unsigned int,
+ unsigned long,
+ unsigned long);
+int XDestroyWindow(Display*, Window);
+Status XGetWindowAttributes(Display*, Window, XWindowAttributes*);
+VisualID XVisualIDFromVisual(Visual*);
+int XResizeWindow(Display*, Window, unsigned int, unsigned int);
+int XMapWindow(Display*, Window);
+KeyCode XKeysymToKeycode(Display*, KeySym);
+char* XKeysymToString(KeySym);
+XModifierKeymap* XGetModifierMapping(Display*);
+int XFreeModifiermap(XModifierKeymap*);
+int XGrabServer(Display*);
+int XUngrabServer(Display*);
+unsigned long XBlackPixel(Display*, int);
+int XStoreName(Display*, Window, const char*);
+Status XIconifyWindow(Display*, Window, int);
+int XConfigureWindow(Display*, Window, unsigned int, XWindowChanges*);
+XVisualInfo* XGetVisualInfo(Display*, long, XVisualInfo*, int*);
+int XFree(void*);
+int XConvertSelection(Display*, Atom, Atom, Atom, Window, Time);
+Window XGetSelectionOwner(Display*, Atom);
+int XSetSelectionOwner(Display*, Atom, Window, Time);
+int XChangeProperty(Display*,
+ Window,
+ Atom,
+ Atom,
+ int,
+ int,
+ const unsigned char*,
+ int);
+int XGetWindowProperty(Display*,
+ Window,
+ Atom,
+ long,
+ long,
+ Bool,
+ Atom,
+ Atom*,
+ int*,
+ unsigned long*,
+ unsigned long*,
+ unsigned char**);
+Status XInternAtoms(Display*, char**, int, Bool, Atom*);
+int XDisplayKeycodes(Display*, int*, int*);
+KeySym* XGetKeyboardMapping(Display*, KeyCode, int, int*);
+KeySym XStringToKeysym(const char*);
+int XChangeKeyboardMapping(Display*, int, int, KeySym*, int);
+Bool XkbLookupKeySym(Display*, KeyCode, unsigned int, unsigned int*, KeySym*);
+Bool XkbLockModifiers(Display*, unsigned int, unsigned int, unsigned int);
+unsigned int XkbKeysymToModifiers(Display*, KeySym);
+}
+
+inline int XkbGroupForCoreState(int s) {
+ return (s >> 13) & 0x3;
+}
+
+inline int XkbBuildCoreState(int m, int g) {
+ return ((g & 0x3) << 13) | (m & 0xff);
+}
+
+// Deprecated.
namespace x11 {
static constexpr unsigned long None = 0L;
static constexpr long CurrentTime = 0L;
static constexpr int False = 0;
static constexpr int True = 1;
static constexpr int Success = 0;
-typedef int Bool;
-typedef int Status;
} // namespace x11
-#endif // UI_GFX_X_X11
+#endif // UI_GFX_X_X11_H_
diff --git a/ui/gfx/x/x11_types.cc b/ui/gfx/x/x11_types.cc
index 7bdea78..79b23c9 100644
--- a/ui/gfx/x/x11_types.cc
+++ b/ui/gfx/x/x11_types.cc
@@ -20,7 +20,7 @@
}
XDisplay* CloneXDisplay(XDisplay* display) {
- return XOpenDisplay(DisplayString(display));
+ return XOpenDisplay(XDisplayString(display));
}
} // namespace gfx
diff --git a/ui/gfx/x/xproto_types.cc b/ui/gfx/x/xproto_types.cc
index 62303be..839d546 100644
--- a/ui/gfx/x/xproto_types.cc
+++ b/ui/gfx/x/xproto_types.cc
@@ -9,6 +9,7 @@
#include "base/memory/scoped_refptr.h"
#include "ui/gfx/x/connection.h"
#include "ui/gfx/x/xproto_internal.h"
+#include "ui/gfx/x/xproto_util.h"
namespace x11 {
diff --git a/ui/gfx/x/xproto_types.h b/ui/gfx/x/xproto_types.h
index 971d8cd..37799e7 100644
--- a/ui/gfx/x/xproto_types.h
+++ b/ui/gfx/x/xproto_types.h
@@ -12,12 +12,12 @@
#include "base/bind.h"
#include "base/callback.h"
+#include "base/component_export.h"
#include "base/files/scoped_file.h"
#include "base/memory/free_deleter.h"
#include "base/memory/ref_counted_memory.h"
#include "base/memory/scoped_refptr.h"
#include "base/optional.h"
-#include "ui/gfx/x/xproto_util.h"
typedef struct _XDisplay XDisplay;
diff --git a/ui/gfx/x/xproto_util.h b/ui/gfx/x/xproto_util.h
index 2179803..3a2486e 100644
--- a/ui/gfx/x/xproto_util.h
+++ b/ui/gfx/x/xproto_util.h
@@ -8,9 +8,31 @@
#include <cstdint>
#include "base/component_export.h"
+#include "ui/gfx/x/connection.h"
+#include "ui/gfx/x/xproto.h"
+#include "ui/gfx/x/xproto_types.h"
namespace x11 {
+template <typename T>
+x11::Future<void> SendEvent(
+ const T& event,
+ x11::Window target,
+ x11::EventMask mask,
+ x11::Connection* connection = x11::Connection::Get()) {
+ static_assert(T::type_id > 0, "T must be an x11::*Event type");
+ auto write_buffer = x11::Write(event);
+ DCHECK_EQ(write_buffer.GetBuffers().size(), 1ul);
+ auto& first_buffer = write_buffer.GetBuffers()[0];
+ DCHECK_LE(first_buffer->size(), 32ul);
+ std::vector<uint8_t> event_bytes(32);
+ memcpy(event_bytes.data(), first_buffer->data(), first_buffer->size());
+
+ x11::SendEventRequest send_event{false, target, mask};
+ std::copy(event_bytes.begin(), event_bytes.end(), send_event.event.begin());
+ return connection->SendEvent(send_event);
+}
+
COMPONENT_EXPORT(X11)
void LogErrorEventDescription(unsigned long serial,
uint8_t error_code,
diff --git a/ui/gl/gl_bindings.cc b/ui/gl/gl_bindings.cc
index 3406fc7..6dfbab9d 100644
--- a/ui/gl/gl_bindings.cc
+++ b/ui/gl/gl_bindings.cc
@@ -74,7 +74,7 @@
#if defined(USE_GLX)
std::string DriverGLX::GetPlatformExtensions() {
Display* display = gfx::GetXDisplay();
- const int screen = (display == EGL_NO_DISPLAY ? 0 : DefaultScreen(display));
+ const int screen = (display == EGL_NO_DISPLAY ? 0 : XDefaultScreen(display));
const char* str = glXQueryExtensionsString(display, screen);
return str ? std::string(str) : "";
}
diff --git a/ui/gl/gl_bindings.h b/ui/gl/gl_bindings.h
index d6a0203..bb5a294 100644
--- a/ui/gl/gl_bindings.h
+++ b/ui/gl/gl_bindings.h
@@ -16,17 +16,6 @@
#if defined(OS_POSIX) && !defined(__STDC_FORMAT_MACROS)
#define __STDC_FORMAT_MACROS
#endif
-#if defined(USE_GLX)
-// Must be included before GL headers or they might pollute the global
-// namespace with X11 macros indirectly.
-#include "ui/gfx/x/x11.h"
-
-// GL headers expect Bool and Status this to be defined but we avoid
-// defining them since they clash with too much code. Instead we have
-// to add them temporarily here and undef them again below.
-#define Bool int
-#define Status int
-#endif // USE_GLX
#include <GL/gl.h>
#include <GL/glext.h>
@@ -48,12 +37,19 @@
#elif defined(OS_APPLE)
#include <OpenGL/OpenGL.h>
#elif defined(USE_GLX)
-#include <GL/glx.h>
-#include <GL/glxext.h>
+using XID = unsigned long;
+using GLXPixmap = XID;
+using GLXWindow = XID;
+using GLXDrawable = XID;
+using GLXPbuffer = XID;
+using GLXContextID = XID;
+using GLXContext = struct __GLXcontextRec*;
+using GLXFBConfig = struct __GLXFBConfigRec*;
-// Done with these temporary macros now
-#undef Bool
-#undef Status
+#include "ui/gfx/x/x11.h"
+
+#include <GL/glxext.h>
+#include <GL/glxtokens.h>
#endif
// GLES2 defines not part of Desktop GL
diff --git a/ui/gl/gl_context_glx_unittest.cc b/ui/gl/gl_context_glx_unittest.cc
index 32081e51..cfa1727e 100644
--- a/ui/gl/gl_context_glx_unittest.cc
+++ b/ui/gl/gl_context_glx_unittest.cc
@@ -36,7 +36,7 @@
swa.background_pixmap = 0;
swa.override_redirect = x11::True;
auto xwindow = static_cast<x11::Window>(XCreateWindow(
- xdisplay, DefaultRootWindow(xdisplay), 0, 0, 10,
+ xdisplay, XDefaultRootWindow(xdisplay), 0, 0, 10,
10, // x, y, width, height
0, // border width
static_cast<int>(x11::WindowClass::CopyFromParent), // depth
diff --git a/ui/gl/gl_glx_api_implementation.cc b/ui/gl/gl_glx_api_implementation.cc
index 0f3f2ae..870ec7c 100644
--- a/ui/gl/gl_glx_api_implementation.cc
+++ b/ui/gl/gl_glx_api_implementation.cc
@@ -110,7 +110,7 @@
bool GetGLWindowSystemBindingInfoGLX(const GLVersionInfo& gl_info,
GLWindowSystemBindingInfo* info) {
Display* display = glXGetCurrentDisplay();
- const int screen = (display ? DefaultScreen(display) : 0);
+ const int screen = (display ? XDefaultScreen(display) : 0);
const char* vendor = glXQueryServerString(display, screen, GLX_VENDOR);
const char* version = glXQueryServerString(display, screen, GLX_VERSION);
const char* extensions = glXQueryExtensionsString(display, screen);
diff --git a/ui/gl/gl_image_glx.cc b/ui/gl/gl_image_glx.cc
index 289585a..d236c8e 100644
--- a/ui/gl/gl_image_glx.cc
+++ b/ui/gl/gl_image_glx.cc
@@ -47,7 +47,7 @@
int attrs[] = {GLX_FBCONFIG_ID, static_cast<uint32_t>(fbconfig_id), 0};
int nitems;
gfx::XScopedPtr<GLXFBConfig> configs(
- glXChooseFBConfig(display, DefaultScreen(display), attrs, &nitems));
+ glXChooseFBConfig(display, XDefaultScreen(display), attrs, &nitems));
if (!nitems)
return false;
diff --git a/ui/gl/gl_surface_egl_x11.cc b/ui/gl/gl_surface_egl_x11.cc
index b01f8062..f801cd3 100644
--- a/ui/gl/gl_surface_egl_x11.cc
+++ b/ui/gl/gl_surface_egl_x11.cc
@@ -10,6 +10,7 @@
#include "ui/gfx/x/randr.h"
#include "ui/gfx/x/x11.h"
#include "ui/gfx/x/xproto.h"
+#include "ui/gfx/x/xproto_util.h"
#include "ui/gl/egl_util.h"
namespace gl {
@@ -117,7 +118,7 @@
auto expose_copy = *expose;
auto window = static_cast<x11::Window>(window_);
expose_copy.window = window;
- ui::SendEvent(expose_copy, window, x11::EventMask::Exposure);
+ x11::SendEvent(expose_copy, window, x11::EventMask::Exposure);
x11::Connection::Get()->Flush();
return true;
}
diff --git a/ui/gl/gl_surface_egl_x11_gles2.cc b/ui/gl/gl_surface_egl_x11_gles2.cc
index 593c5d8..354a99b 100644
--- a/ui/gl/gl_surface_egl_x11_gles2.cc
+++ b/ui/gl/gl_surface_egl_x11_gles2.cc
@@ -6,6 +6,7 @@
#include "ui/base/x/x11_util.h"
#include "ui/gfx/x/x11.h"
+#include "ui/gfx/x/xproto_util.h"
#include "ui/gl/egl_util.h"
using ui::GetLastEGLErrorString;
@@ -153,7 +154,7 @@
auto expose_copy = *expose;
expose_copy.window = parent_window_;
- ui::SendEvent(expose_copy, parent_window_, x11::EventMask::Exposure);
+ x11::SendEvent(expose_copy, parent_window_, x11::EventMask::Exposure);
x11::Connection::Get()->Flush();
return true;
}
diff --git a/ui/gl/gl_surface_glx.cc b/ui/gl/gl_surface_glx.cc
index d3fd81a..ad5839a 100644
--- a/ui/gl/gl_surface_glx.cc
+++ b/ui/gl/gl_surface_glx.cc
@@ -34,6 +34,7 @@
#include "ui/gfx/x/x11_types.h"
#include "ui/gfx/x/xf86vidmode.h"
#include "ui/gfx/x/xproto.h"
+#include "ui/gfx/x/xproto_util.h"
#include "ui/gl/gl_bindings.h"
#include "ui/gl/gl_context.h"
#include "ui/gl/gl_implementation.h"
@@ -93,7 +94,7 @@
int num_elements = 0;
gfx::XScopedPtr<GLXFBConfig> configs(
- glXGetFBConfigs(display, DefaultScreen(display), &num_elements));
+ glXGetFBConfigs(display, XDefaultScreen(display), &num_elements));
if (!configs.get()) {
LOG(ERROR) << "glXGetFBConfigs failed.";
return nullptr;
@@ -601,7 +602,7 @@
// static
std::string GLSurfaceGLX::QueryGLXExtensions() {
Display* display = gfx::GetXDisplay();
- const int screen = (display ? DefaultScreen(display) : 0);
+ const int screen = (display ? XDefaultScreen(display) : 0);
const char* extensions = glXQueryExtensionsString(display, screen);
if (extensions) {
return std::string(extensions);
@@ -882,7 +883,7 @@
auto forwarded_event = *event->As<x11::ExposeEvent>();
auto window = static_cast<x11::Window>(parent_window_);
forwarded_event.window = window;
- ui::SendEvent(forwarded_event, window, x11::EventMask::Exposure);
+ x11::SendEvent(forwarded_event, window, x11::EventMask::Exposure);
x11::Connection::Get()->Flush();
}
diff --git a/ui/gtk/select_file_dialog_impl_kde.cc b/ui/gtk/select_file_dialog_impl_kde.cc
index 464aa72..5b5a139 100644
--- a/ui/gtk/select_file_dialog_impl_kde.cc
+++ b/ui/gtk/select_file_dialog_impl_kde.cc
@@ -2,10 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include <gdk/gdkx.h>
-#include <gtk/gtk.h>
-#include <stddef.h>
-
+#include <cstddef>
#include <memory>
#include <set>
diff --git a/ui/gtk/x/gtk_event_loop_x11.cc b/ui/gtk/x/gtk_event_loop_x11.cc
index efec73e..3629dadc 100644
--- a/ui/gtk/x/gtk_event_loop_x11.cc
+++ b/ui/gtk/x/gtk_event_loop_x11.cc
@@ -5,7 +5,6 @@
#include "ui/gtk/x/gtk_event_loop_x11.h"
#include <gdk/gdk.h>
-#include <gdk/gdkx.h>
#include <gtk/gtk.h>
#include <xcb/xcb.h>
#include <xcb/xproto.h>
@@ -15,6 +14,10 @@
#include "ui/gfx/x/event.h"
#include "ui/gfx/x/x11.h"
+extern "C" {
+Window gdk_x11_window_get_xid(GdkWindow* window);
+}
+
namespace ui {
namespace {
@@ -80,8 +83,8 @@
: x11::KeyEvent::Release;
if (gdk_event_key.send_event)
key_event->response_type |= x11::kSendEventMask;
- key_event->event = GDK_WINDOW_XID(gdk_event_key.window);
- key_event->root = DefaultRootWindow(display);
+ key_event->event = gdk_x11_window_get_xid(gdk_event_key.window);
+ key_event->root = XDefaultRootWindow(display);
key_event->time = gdk_event_key.time;
key_event->detail = gdk_event_key.hardware_keycode;
key_event->same_screen = true;
diff --git a/ui/gtk/x/gtk_ui_delegate_x11.cc b/ui/gtk/x/gtk_ui_delegate_x11.cc
index 70b1839..88c6e46 100644
--- a/ui/gtk/x/gtk_ui_delegate_x11.cc
+++ b/ui/gtk/x/gtk_ui_delegate_x11.cc
@@ -4,13 +4,8 @@
#include "ui/gtk/x/gtk_ui_delegate_x11.h"
-#include <gdk/gdkx.h>
#include <gtk/gtk.h>
-// gdkx.h includes Xlib.h directly, so we need to manually undef any macros
-// that conflict with the below includes.
-#undef None
-
#include "base/check.h"
#include "ui/base/x/x11_util.h"
#include "ui/events/platform/x11/x11_event_source.h"
@@ -20,6 +15,16 @@
#include "ui/platform_window/x11/x11_window.h"
#include "ui/platform_window/x11/x11_window_manager.h"
+extern "C" {
+GdkWindow* gdk_x11_window_foreign_new_for_display(GdkDisplay* display,
+ Window window);
+
+GdkWindow* gdk_x11_window_lookup_for_display(GdkDisplay* display,
+ Window window);
+
+Window gdk_x11_window_get_xid(GdkWindow* window);
+}
+
namespace ui {
GtkUiDelegateX11::GtkUiDelegateX11(x11::Connection* connection)
@@ -53,13 +58,13 @@
bool GtkUiDelegateX11::SetGdkWindowTransientFor(GdkWindow* window,
gfx::AcceleratedWidget parent) {
- SetProperty(static_cast<x11::Window>(GDK_WINDOW_XID(window)),
- x11::Atom::WM_TRANSIENT_FOR, x11::Atom::WINDOW, parent);
+ auto x11_window = static_cast<x11::Window>(gdk_x11_window_get_xid(window));
+ SetProperty(x11_window, x11::Atom::WM_TRANSIENT_FOR, x11::Atom::WINDOW,
+ parent);
ui::X11Window* parent_window =
ui::X11WindowManager::GetInstance()->GetWindow(parent);
- parent_window->SetTransientWindow(
- static_cast<x11::Window>(gdk_x11_window_get_xid(window)));
+ parent_window->SetTransientWindow(x11_window);
return true;
}
diff --git a/ui/ozone/platform/x11/x11_clipboard_ozone.cc b/ui/ozone/platform/x11/x11_clipboard_ozone.cc
index 16a0476..9cc7e1bc 100644
--- a/ui/ozone/platform/x11/x11_clipboard_ozone.cc
+++ b/ui/ozone/platform/x11/x11_clipboard_ozone.cc
@@ -16,6 +16,7 @@
#include "ui/gfx/x/x11_atom_cache.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/gfx/x/xproto.h"
+#include "ui/gfx/x/xproto_util.h"
using base::Contains;
@@ -183,8 +184,8 @@
.target = event.target,
.property = event.property,
};
- SendEvent(selection_event, selection_event.requestor,
- x11::EventMask::NoEvent);
+ x11::SendEvent(selection_event, selection_event.requestor,
+ x11::EventMask::NoEvent);
return true;
}
diff --git a/ui/platform_window/x11/test/x11_event_translation_unittest.cc b/ui/platform_window/x11/test/x11_event_translation_unittest.cc
index 2358b07..9a7eaab 100644
--- a/ui/platform_window/x11/test/x11_event_translation_unittest.cc
+++ b/ui/platform_window/x11/test/x11_event_translation_unittest.cc
@@ -23,6 +23,7 @@
#include "ui/events/types/event_type.h"
#include "ui/gfx/x/connection.h"
#include "ui/gfx/x/event.h"
+#include "ui/gfx/x/keysyms/keysyms.h"
#include "ui/gfx/x/x11.h"
#include "ui/gfx/x/x11_types.h"
#include "ui/gfx/x/xproto.h"
diff --git a/ui/platform_window/x11/test/x11_window_unittest.cc b/ui/platform_window/x11/test/x11_window_unittest.cc
index abf7034..e8e69d8 100644
--- a/ui/platform_window/x11/test/x11_window_unittest.cc
+++ b/ui/platform_window/x11/test/x11_window_unittest.cc
@@ -20,6 +20,8 @@
#include "ui/gfx/transform.h"
#include "ui/gfx/x/x11.h"
#include "ui/gfx/x/x11_atom_cache.h"
+#include "ui/gfx/x/xproto.h"
+#include "ui/gfx/x/xproto_util.h"
#include "ui/platform_window/extensions/x11_extension_delegate.h"
namespace ui {
@@ -386,21 +388,10 @@
// Emulate the window manager exiting fullscreen via a window manager
// accelerator key.
{
- XEvent xclient;
- memset(&xclient, 0, sizeof(xclient));
- xclient.type = ClientMessage;
- xclient.xclient.window = static_cast<uint32_t>(x11_window);
- xclient.xclient.message_type =
- static_cast<uint32_t>(gfx::GetAtom("_NET_WM_STATE"));
- xclient.xclient.format = 32;
- xclient.xclient.data.l[0] = 0;
- xclient.xclient.data.l[1] =
- static_cast<uint32_t>(gfx::GetAtom("_NET_WM_STATE_FULLSCREEN"));
- xclient.xclient.data.l[2] = 0;
- xclient.xclient.data.l[3] = 1;
- xclient.xclient.data.l[4] = 0;
- XSendEvent(display, DefaultRootWindow(display), x11::False,
- SubstructureRedirectMask | SubstructureNotifyMask, &xclient);
+ ui::SendClientMessage(
+ x11_window, ui::GetX11RootWindow(), gfx::GetAtom("_NET_WM_STATE"),
+ {0, static_cast<uint32_t>(gfx::GetAtom("_NET_WM_STATE_FULLSCREEN")), 0,
+ 1, 0});
WMStateWaiter waiter(x11_window, "_NET_WM_STATE_FULLSCREEN", false);
waiter.Wait();
@@ -448,7 +439,6 @@
ui::X11EventSource::GetInstance()->DispatchXEvents();
x11::Window x11_window = window->window();
- Display* display = gfx::GetXDisplay();
// Minimize by sending _NET_WM_STATE_HIDDEN
{
@@ -456,18 +446,14 @@
atom_list.push_back(gfx::GetAtom("_NET_WM_STATE_HIDDEN"));
ui::SetAtomArrayProperty(x11_window, "_NET_WM_STATE", "ATOM", atom_list);
- XEvent xevent;
- memset(&xevent, 0, sizeof(xevent));
- xevent.type = PropertyNotify;
- xevent.xproperty.type = PropertyNotify;
- xevent.xproperty.send_event = 1;
- xevent.xproperty.display = display;
- xevent.xproperty.window = static_cast<uint32_t>(x11_window);
- xevent.xproperty.atom =
- static_cast<uint32_t>(gfx::GetAtom("_NET_WM_STATE"));
- xevent.xproperty.state = 0;
- XSendEvent(display, DefaultRootWindow(display), x11::False,
- SubstructureRedirectMask | SubstructureNotifyMask, &xevent);
+ x11::PropertyNotifyEvent xevent{
+ .send_event = true,
+ .window = x11_window,
+ .atom = gfx::GetAtom("_NET_WM_STATE"),
+ };
+ x11::SendEvent(xevent, ui::GetX11RootWindow(),
+ x11::EventMask::SubstructureNotify |
+ x11::EventMask::SubstructureRedirect);
WMStateWaiter waiter(x11_window, "_NET_WM_STATE_HIDDEN", true);
waiter.Wait();
@@ -481,18 +467,14 @@
atom_list.push_back(gfx::GetAtom("_NET_WM_STATE_FOCUSED"));
ui::SetAtomArrayProperty(x11_window, "_NET_WM_STATE", "ATOM", atom_list);
- XEvent xevent;
- memset(&xevent, 0, sizeof(xevent));
- xevent.type = PropertyNotify;
- xevent.xproperty.type = PropertyNotify;
- xevent.xproperty.send_event = 1;
- xevent.xproperty.display = display;
- xevent.xproperty.window = static_cast<uint32_t>(x11_window);
- xevent.xproperty.atom =
- static_cast<uint32_t>(gfx::GetAtom("_NET_WM_STATE"));
- xevent.xproperty.state = 0;
- XSendEvent(display, DefaultRootWindow(display), x11::False,
- SubstructureRedirectMask | SubstructureNotifyMask, &xevent);
+ x11::PropertyNotifyEvent xevent{
+ .send_event = true,
+ .window = x11_window,
+ .atom = gfx::GetAtom("_NET_WM_STATE"),
+ };
+ x11::SendEvent(xevent, ui::GetX11RootWindow(),
+ x11::EventMask::SubstructureNotify |
+ x11::EventMask::SubstructureRedirect);
WMStateWaiter waiter(x11_window, "_NET_WM_STATE_FOCUSED", true);
waiter.Wait();
diff --git a/ui/views/test/ui_controls_factory_desktop_aurax11.cc b/ui/views/test/ui_controls_factory_desktop_aurax11.cc
index 2d80939..a669d1e 100644
--- a/ui/views/test/ui_controls_factory_desktop_aurax11.cc
+++ b/ui/views/test/ui_controls_factory_desktop_aurax11.cc
@@ -24,8 +24,11 @@
#include "ui/compositor/dip_util.h"
#include "ui/events/keycodes/keyboard_code_conversion_x.h"
#include "ui/events/test/x11_event_waiter.h"
+#include "ui/gfx/x/connection.h"
+#include "ui/gfx/x/keysyms/keysyms.h"
#include "ui/gfx/x/x11.h"
#include "ui/gfx/x/x11_types.h"
+#include "ui/gfx/x/xproto.h"
#include "ui/views/test/test_desktop_screen_x11.h"
#include "ui/views/widget/desktop_aura/desktop_window_tree_host_linux.h"
@@ -44,42 +47,15 @@
// Mask of the buttons currently down.
unsigned button_down_mask = 0;
-// Restore Xlib constants that were #undef'ed by gen/ui/gfx/x/xproto.h.
-constexpr int CopyFromParent = 0;
-constexpr int InputOnly = 2;
-constexpr int KeyPress = 2;
-constexpr int KeyRelease = 3;
-constexpr int ButtonPress = 4;
-constexpr int ButtonRelease = 5;
-constexpr int Button1 = 1;
-constexpr int Button2 = 2;
-constexpr int Button3 = 3;
-
class UIControlsDesktopX11 : public UIControlsAura {
public:
UIControlsDesktopX11()
- : x_display_(gfx::GetXDisplay()),
+ : connection_(x11::Connection::Get()),
x_root_window_(ui::GetX11RootWindow()),
- x_window_(static_cast<x11::Window>(
- XCreateWindow(x_display_,
- static_cast<uint32_t>(x_root_window_),
- -100, // x
- -100, // y
- 10, // width
- 10, // height
- 0, // border width
- CopyFromParent, // depth
- InputOnly,
- reinterpret_cast<Visual*>(CopyFromParent),
- 0,
- nullptr))) {
- XStoreName(x_display_, static_cast<uint32_t>(x_window_),
- "Chromium UIControlsDesktopX11 Window");
- }
+ x_window_(
+ ui::CreateDummyWindow("Chromium UIControlsDesktopX11 Window")) {}
- ~UIControlsDesktopX11() override {
- XDestroyWindow(x_display_, static_cast<uint32_t>(x_window_));
- }
+ ~UIControlsDesktopX11() override { connection_->DestroyWindow({x_window_}); }
bool SendKeyPress(gfx::NativeWindow window,
ui::KeyboardCode key,
@@ -103,9 +79,8 @@
aura::WindowTreeHost* host = window->GetHost();
- XEvent xevent;
- xevent.xkey = {};
- xevent.xkey.type = KeyPress;
+ x11::KeyEvent xevent;
+ xevent.opcode = x11::KeyEvent::Press;
if (control) {
SetKeycodeAndSendThenMask(host, &xevent, XK_Control_L, ControlMask);
}
@@ -113,21 +88,20 @@
SetKeycodeAndSendThenMask(host, &xevent, XK_Shift_L, ShiftMask);
if (alt)
SetKeycodeAndSendThenMask(host, &xevent, XK_Alt_L, Mod1Mask);
- xevent.xkey.keycode =
- XKeysymToKeycode(x_display_, ui::XKeysymForWindowsKeyCode(key, shift));
- aura::test::PostEventToWindowTreeHost(xevent, host);
+ xevent.detail = x11::Connection::Get()->KeysymToKeycode(
+ static_cast<x11::KeySym>(ui::XKeysymForWindowsKeyCode(key, shift)));
+ aura::test::PostEventToWindowTreeHost(host, &xevent);
// Send key release events.
- xevent.xkey.type = KeyRelease;
- aura::test::PostEventToWindowTreeHost(xevent, host);
+ xevent.opcode = x11::KeyEvent::Release;
+ aura::test::PostEventToWindowTreeHost(host, &xevent);
if (alt)
UnmaskAndSetKeycodeThenSend(host, &xevent, Mod1Mask, XK_Alt_L);
if (shift)
UnmaskAndSetKeycodeThenSend(host, &xevent, ShiftMask, XK_Shift_L);
- if (control) {
+ if (control)
UnmaskAndSetKeycodeThenSend(host, &xevent, ControlMask, XK_Control_L);
- }
- DCHECK(!xevent.xkey.state);
+ DCHECK_EQ(xevent.state, x11::KeyButMask{});
RunClosureAfterAllPendingUIEvents(std::move(closure));
return true;
}
@@ -163,16 +137,14 @@
// current mouse position as a result of XGrabPointer()
root_window->MoveCursorTo(root_location);
} else {
- XEvent xevent;
- xevent.xmotion = {};
- XMotionEvent* xmotion = &xevent.xmotion;
- xmotion->type = MotionNotify;
- xmotion->x = root_location.x();
- xmotion->y = root_location.y();
- xmotion->state = button_down_mask;
- xmotion->same_screen = x11::True;
+ x11::MotionNotifyEvent xevent{
+ .event_x = root_location.x(),
+ .event_y = root_location.y(),
+ .state = static_cast<x11::KeyButMask>(button_down_mask),
+ .same_screen = true,
+ };
// RootWindow will take care of other necessary fields.
- aura::test::PostEventToWindowTreeHost(xevent, host);
+ aura::test::PostEventToWindowTreeHost(host, &xevent);
}
RunClosureAfterAllPendingUIEvents(std::move(closure));
return true;
@@ -187,52 +159,51 @@
int button_state,
base::OnceClosure closure,
int accelerator_state) override {
- XEvent xevent;
- xevent.xbutton = {};
- XButtonEvent* xbutton = &xevent.xbutton;
+ x11::ButtonEvent xevent;
gfx::Point mouse_loc = aura::Env::GetInstance()->last_mouse_location();
aura::Window* root_window = RootWindowForPoint(mouse_loc);
aura::client::ScreenPositionClient* screen_position_client =
aura::client::GetScreenPositionClient(root_window);
if (screen_position_client)
screen_position_client->ConvertPointFromScreen(root_window, &mouse_loc);
- xbutton->x = mouse_loc.x();
- xbutton->y = mouse_loc.y();
- xbutton->same_screen = x11::True;
+ xevent.event_x = mouse_loc.x();
+ xevent.event_y = mouse_loc.y();
switch (type) {
case LEFT:
- xbutton->button = Button1;
- xbutton->state = Button1Mask;
+ xevent.detail = static_cast<x11::Button>(1);
+ xevent.state = x11::KeyButMask::Button1;
break;
case MIDDLE:
- xbutton->button = Button2;
- xbutton->state = Button2Mask;
+ xevent.detail = static_cast<x11::Button>(2);
+ xevent.state = x11::KeyButMask::Button2;
break;
case RIGHT:
- xbutton->button = Button3;
- xbutton->state = Button3Mask;
+ xevent.detail = static_cast<x11::Button>(3);
+ xevent.state = x11::KeyButMask::Button3;
break;
}
- // Process the accelerator key state.
+
+ // Process accelerator key state.
if (accelerator_state & ui_controls::kShift)
- xbutton->state |= ShiftMask;
+ xevent.state = xevent.state | x11::KeyButMask::Shift;
if (accelerator_state & ui_controls::kControl)
- xbutton->state |= ControlMask;
+ xevent.state = xevent.state | x11::KeyButMask::Control;
if (accelerator_state & ui_controls::kAlt)
- xbutton->state |= Mod1Mask;
+ xevent.state = xevent.state | x11::KeyButMask::Mod1;
if (accelerator_state & ui_controls::kCommand)
- xbutton->state |= Mod4Mask;
+ xevent.state = xevent.state | x11::KeyButMask::Mod4;
// RootWindow will take care of other necessary fields.
if (button_state & DOWN) {
- xevent.xbutton.type = ButtonPress;
- aura::test::PostEventToWindowTreeHost(xevent, root_window->GetHost());
- button_down_mask |= xbutton->state;
+ xevent.opcode = x11::ButtonEvent::Press;
+ aura::test::PostEventToWindowTreeHost(root_window->GetHost(), &xevent);
+ button_down_mask |= static_cast<int>(xevent.state);
}
if (button_state & UP) {
- xevent.xbutton.type = ButtonRelease;
- aura::test::PostEventToWindowTreeHost(xevent, root_window->GetHost());
- button_down_mask = (button_down_mask | xbutton->state) ^ xbutton->state;
+ xevent.opcode = x11::ButtonEvent::Release;
+ aura::test::PostEventToWindowTreeHost(root_window->GetHost(), &xevent);
+ int state = static_cast<int>(xevent.state);
+ button_down_mask = (button_down_mask | state) ^ state;
}
RunClosureAfterAllPendingUIEvents(std::move(closure));
return true;
@@ -266,25 +237,28 @@
}
void SetKeycodeAndSendThenMask(aura::WindowTreeHost* host,
- XEvent* xevent,
+ x11::KeyEvent* xevent,
KeySym keysym,
unsigned int mask) {
- xevent->xkey.keycode = XKeysymToKeycode(x_display_, keysym);
- aura::test::PostEventToWindowTreeHost(*xevent, host);
- xevent->xkey.state |= mask;
+ xevent->detail = x11::Connection::Get()->KeysymToKeycode(
+ static_cast<x11::KeySym>(keysym));
+ aura::test::PostEventToWindowTreeHost(host, xevent);
+ xevent->state = xevent->state | static_cast<x11::KeyButMask>(mask);
}
void UnmaskAndSetKeycodeThenSend(aura::WindowTreeHost* host,
- XEvent* xevent,
+ x11::KeyEvent* xevent,
unsigned int mask,
KeySym keysym) {
- xevent->xkey.state ^= mask;
- xevent->xkey.keycode = XKeysymToKeycode(x_display_, keysym);
- aura::test::PostEventToWindowTreeHost(*xevent, host);
+ xevent->state = static_cast<x11::KeyButMask>(
+ static_cast<uint32_t>(xevent->state) ^ mask);
+ xevent->detail = x11::Connection::Get()->KeysymToKeycode(
+ static_cast<x11::KeySym>(keysym));
+ aura::test::PostEventToWindowTreeHost(host, xevent);
}
// Our X11 state.
- Display* x_display_;
+ x11::Connection* connection_;
x11::Window x_root_window_;
// Input-only window used for events.
diff --git a/ui/views/widget/desktop_aura/desktop_window_tree_host_linux_interactive_uitest.cc b/ui/views/widget/desktop_aura/desktop_window_tree_host_linux_interactive_uitest.cc
index 222cd87..f625d73c 100644
--- a/ui/views/widget/desktop_aura/desktop_window_tree_host_linux_interactive_uitest.cc
+++ b/ui/views/widget/desktop_aura/desktop_window_tree_host_linux_interactive_uitest.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "ui/gfx/x/xproto.h"
#include "ui/views/widget/desktop_aura/desktop_window_tree_host_linux.h"
#include "ui/aura/client/aura_constants.h"
@@ -71,7 +72,7 @@
xcb_generic_event_t ge;
memset(&ge, 0, sizeof(ge));
auto* xev = reinterpret_cast<xcb_motion_notify_event_t*>(&ge);
- xev->response_type = MotionNotify;
+ xev->response_type = x11::MotionNotifyEvent::opcode;
xev->event = static_cast<uint32_t>(desktop_host->GetAcceleratedWidget());
xev->root = static_cast<uint32_t>(connection->default_screen().root);
xev->child = 0;