Index: ui/ozone/platform/wayland/wayland_display.cc |
diff --git a/ui/ozone/platform/wayland/wayland_display.cc b/ui/ozone/platform/wayland/wayland_display.cc |
index a34abe266a528dbed5a8064e31a14436f431111f..7f261876869bf8f541e81385cbcf6b8e8b95ac65 100644 |
--- a/ui/ozone/platform/wayland/wayland_display.cc |
+++ b/ui/ozone/platform/wayland/wayland_display.cc |
@@ -9,9 +9,16 @@ |
#include "base/bind.h" |
#include "base/logging.h" |
#include "base/message_loop/message_loop.h" |
+#include "ui/events/ozone/layout/keyboard_layout_engine_manager.h" |
#include "ui/ozone/platform/wayland/wayland_object.h" |
#include "ui/ozone/platform/wayland/wayland_window.h" |
+#if defined(USE_XKBCOMMON) |
+#include "ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.h" |
+#else |
+#include "ui/events/ozone/layout/stub/stub_keyboard_layout_engine.h" |
+#endif |
+ |
static_assert(XDG_SHELL_VERSION_CURRENT == 5, "Unsupported xdg-shell version"); |
namespace ui { |
@@ -22,7 +29,15 @@ const uint32_t kMaxShmVersion = 1; |
const uint32_t kMaxXdgShellVersion = 1; |
} // namespace |
-WaylandDisplay::WaylandDisplay() {} |
+WaylandDisplay::WaylandDisplay() { |
+#if defined(USE_XKBCOMMON) |
+ KeyboardLayoutEngineManager::SetKeyboardLayoutEngine( |
+ make_scoped_ptr(new XkbKeyboardLayoutEngine(codes_))); |
+#else |
+ KeyboardLayoutEngineManager::SetKeyboardLayoutEngine( |
+ make_scoped_ptr(new StubKeyboardLayoutEngine)); |
+#endif |
+} |
WaylandDisplay::~WaylandDisplay() {} |
@@ -199,6 +214,20 @@ void WaylandDisplay::Capabilities(void* data, |
} else if (display->pointer_) { |
display->pointer_.reset(); |
} |
+ if (capabilities & WL_SEAT_CAPABILITY_KEYBOARD) { |
+ if (!display->keyboard_) { |
+ wl_keyboard* keyboard = wl_seat_get_keyboard(display->seat_.get()); |
+ if (!keyboard) { |
+ LOG(ERROR) << "Failed to get wl_keyboard from seat"; |
+ return; |
+ } |
+ display->keyboard_ = make_scoped_ptr(new WaylandKeyboard( |
+ keyboard, base::Bind(&WaylandDisplay::DispatchUiEvent, |
+ base::Unretained(display)))); |
+ } |
+ } else if (display->keyboard_) { |
+ display->keyboard_.reset(); |
+ } |
display->ScheduleFlush(); |
} |