Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9)

Side by Side Diff: ui/ozone/platform/wayland/wayland_display.cc

Issue 1841083003: ozone/platform/wayland: Implement keyboard handling Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/ozone/platform/wayland/wayland_display.h" 5 #include "ui/ozone/platform/wayland/wayland_display.h"
6 6
7 #include <xdg-shell-unstable-v5-client-protocol.h> 7 #include <xdg-shell-unstable-v5-client-protocol.h>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/message_loop/message_loop.h" 11 #include "base/message_loop/message_loop.h"
12 #include "ui/events/ozone/layout/keyboard_layout_engine_manager.h"
12 #include "ui/ozone/platform/wayland/wayland_object.h" 13 #include "ui/ozone/platform/wayland/wayland_object.h"
13 #include "ui/ozone/platform/wayland/wayland_window.h" 14 #include "ui/ozone/platform/wayland/wayland_window.h"
14 15
16 #if defined(USE_XKBCOMMON)
17 #include "ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.h"
18 #else
19 #include "ui/events/ozone/layout/stub/stub_keyboard_layout_engine.h"
20 #endif
21
15 static_assert(XDG_SHELL_VERSION_CURRENT == 5, "Unsupported xdg-shell version"); 22 static_assert(XDG_SHELL_VERSION_CURRENT == 5, "Unsupported xdg-shell version");
16 23
17 namespace ui { 24 namespace ui {
18 namespace { 25 namespace {
19 const uint32_t kMaxCompositorVersion = 4; 26 const uint32_t kMaxCompositorVersion = 4;
20 const uint32_t kMaxSeatVersion = 4; 27 const uint32_t kMaxSeatVersion = 4;
21 const uint32_t kMaxShmVersion = 1; 28 const uint32_t kMaxShmVersion = 1;
22 const uint32_t kMaxXdgShellVersion = 1; 29 const uint32_t kMaxXdgShellVersion = 1;
23 } // namespace 30 } // namespace
24 31
25 WaylandDisplay::WaylandDisplay() {} 32 WaylandDisplay::WaylandDisplay() {
33 #if defined(USE_XKBCOMMON)
34 KeyboardLayoutEngineManager::SetKeyboardLayoutEngine(
35 make_scoped_ptr(new XkbKeyboardLayoutEngine(codes_)));
36 #else
37 KeyboardLayoutEngineManager::SetKeyboardLayoutEngine(
38 make_scoped_ptr(new StubKeyboardLayoutEngine));
39 #endif
40 }
26 41
27 WaylandDisplay::~WaylandDisplay() {} 42 WaylandDisplay::~WaylandDisplay() {}
28 43
29 bool WaylandDisplay::Initialize() { 44 bool WaylandDisplay::Initialize() {
30 static const wl_registry_listener registry_listener = { 45 static const wl_registry_listener registry_listener = {
31 &WaylandDisplay::Global, &WaylandDisplay::GlobalRemove, 46 &WaylandDisplay::Global, &WaylandDisplay::GlobalRemove,
32 }; 47 };
33 48
34 display_.reset(wl_display_connect(nullptr)); 49 display_.reset(wl_display_connect(nullptr));
35 if (!display_) { 50 if (!display_) {
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 LOG(ERROR) << "Failed to get wl_pointer from seat"; 207 LOG(ERROR) << "Failed to get wl_pointer from seat";
193 return; 208 return;
194 } 209 }
195 display->pointer_ = make_scoped_ptr(new WaylandPointer( 210 display->pointer_ = make_scoped_ptr(new WaylandPointer(
196 pointer, base::Bind(&WaylandDisplay::DispatchUiEvent, 211 pointer, base::Bind(&WaylandDisplay::DispatchUiEvent,
197 base::Unretained(display)))); 212 base::Unretained(display))));
198 } 213 }
199 } else if (display->pointer_) { 214 } else if (display->pointer_) {
200 display->pointer_.reset(); 215 display->pointer_.reset();
201 } 216 }
217 if (capabilities & WL_SEAT_CAPABILITY_KEYBOARD) {
218 if (!display->keyboard_) {
219 wl_keyboard* keyboard = wl_seat_get_keyboard(display->seat_.get());
220 if (!keyboard) {
221 LOG(ERROR) << "Failed to get wl_keyboard from seat";
222 return;
223 }
224 display->keyboard_ = make_scoped_ptr(new WaylandKeyboard(
225 keyboard, base::Bind(&WaylandDisplay::DispatchUiEvent,
226 base::Unretained(display))));
227 }
228 } else if (display->keyboard_) {
229 display->keyboard_.reset();
230 }
202 display->ScheduleFlush(); 231 display->ScheduleFlush();
203 } 232 }
204 233
205 // static 234 // static
206 void WaylandDisplay::Name(void* data, wl_seat* seat, const char* name) {} 235 void WaylandDisplay::Name(void* data, wl_seat* seat, const char* name) {}
207 236
208 // static 237 // static
209 void WaylandDisplay::Ping(void* data, xdg_shell* shell, uint32_t serial) { 238 void WaylandDisplay::Ping(void* data, xdg_shell* shell, uint32_t serial) {
210 WaylandDisplay* display = static_cast<WaylandDisplay*>(data); 239 WaylandDisplay* display = static_cast<WaylandDisplay*>(data);
211 xdg_shell_pong(shell, serial); 240 xdg_shell_pong(shell, serial);
212 display->ScheduleFlush(); 241 display->ScheduleFlush();
213 } 242 }
214 243
215 } // namespace ui 244 } // namespace ui
OLDNEW
« no previous file with comments | « ui/ozone/platform/wayland/wayland_display.h ('k') | ui/ozone/platform/wayland/wayland_keyboard.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698