#include "ui/ozone/platform/wayland/host/wayland_keyboard.h"
#include <keyboard-extension-unstable-v1-client-protocol.h>
#include <keyboard-shortcuts-inhibit-unstable-v1-client-protocol.h>
#include <sys/mman.h>
#include <cstddef>
#include <cstring>
#include <utility>
#include "base/logging.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/ref_counted_memory.h"
#include "base/unguessable_token.h"
#include "ui/base/buildflags.h"
#include "ui/events/base_event_utils.h"
#include "ui/events/event.h"
#include "ui/events/keycodes/dom/dom_code.h"
#include "ui/events/keycodes/dom/dom_key.h"
#include "ui/events/keycodes/dom/keycode_converter.h"
#include "ui/events/keycodes/keyboard_codes_posix.h"
#include "ui/events/ozone/keyboard/event_auto_repeat_handler.h"
#include "ui/events/ozone/layout/keyboard_layout_engine.h"
#include "ui/events/ozone/layout/keyboard_layout_engine_manager.h"
#include "ui/events/types/event_type.h"
#include "ui/ozone/platform/wayland/common/wayland_util.h"
#include "ui/ozone/platform/wayland/host/wayland_connection.h"
#include "ui/ozone/platform/wayland/host/wayland_seat.h"
#include "ui/ozone/platform/wayland/host/wayland_serial_tracker.h"
#include "ui/ozone/platform/wayland/host/wayland_window.h"
#include "ui/ozone/public/platform_keyboard_hook.h"
#if BUILDFLAG(USE_XKBCOMMON)
#include "ui/events/ozone/layout/xkb/xkb_keyboard_layout_engine.h"
#endif
namespace ui {
namespace {
bool IsModifierKey(int key) { … }
class WaylandKeyboardHook final : public PlatformKeyboardHook { … };
}
class WaylandKeyboard::ZCRExtendedKeyboard { … };
WaylandKeyboard::WaylandKeyboard(
wl_keyboard* keyboard,
zcr_keyboard_extension_v1* keyboard_extension_v1,
WaylandConnection* connection,
KeyboardLayoutEngine* layout_engine,
Delegate* delegate)
: … { … }
WaylandKeyboard::~WaylandKeyboard() { … }
void WaylandKeyboard::OnUnhandledKeyEvent(const KeyEvent& key_event) { … }
std::unique_ptr<PlatformKeyboardHook> WaylandKeyboard::CreateKeyboardHook(
WaylandWindow* window,
std::optional<base::flat_set<DomCode>> dom_codes,
PlatformKeyboardHook::KeyEventCallback callback) { … }
wl::Object<zwp_keyboard_shortcuts_inhibitor_v1>
WaylandKeyboard::CreateShortcutsInhibitor(WaylandWindow* window) { … }
void WaylandKeyboard::OnKeymap(void* data,
wl_keyboard* keyboard,
uint32_t format,
int32_t fd,
uint32_t size) { … }
void WaylandKeyboard::OnEnter(void* data,
wl_keyboard* keyboard,
uint32_t serial,
wl_surface* surface,
wl_array* keys) { … }
void WaylandKeyboard::OnLeave(void* data,
wl_keyboard* keyboard,
uint32_t serial,
wl_surface* surface) { … }
void WaylandKeyboard::OnKey(void* data,
wl_keyboard* keyboard,
uint32_t serial,
uint32_t time,
uint32_t key,
uint32_t state) { … }
void WaylandKeyboard::OnModifiers(void* data,
wl_keyboard* keyboard,
uint32_t serial,
uint32_t depressed,
uint32_t latched,
uint32_t locked,
uint32_t group) { … }
void WaylandKeyboard::OnRepeatInfo(void* data,
wl_keyboard* keyboard,
int32_t rate,
int32_t delay) { … }
void WaylandKeyboard::OnSyncDone(void* data,
struct wl_callback* callback,
uint32_t time) { … }
void WaylandKeyboard::FlushInput(base::OnceClosure closure) { … }
void WaylandKeyboard::DispatchKey(unsigned int key,
unsigned int scan_code,
bool down,
bool repeat,
base::TimeTicks timestamp,
int device_id,
int flags) { … }
void WaylandKeyboard::ProcessKey(uint32_t serial,
uint32_t time,
uint32_t key,
uint32_t state,
KeyEventKind kind) { … }
void WaylandKeyboard::DispatchKey(unsigned int key,
unsigned int scan_code,
bool down,
bool repeat,
std::optional<uint32_t> serial,
base::TimeTicks timestamp,
int device_id,
int flags,
KeyEventKind kind) { … }
}