1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_EXO_WAYLAND_WAYLAND_KEYBOARD_DELEGATE_H_
#define COMPONENTS_EXO_WAYLAND_WAYLAND_KEYBOARD_DELEGATE_H_
#include "base/containers/flat_map.h"
#include "base/memory/raw_ptr.h"
#include "base/time/time.h"
#include "build/buildflag.h"
#include "components/exo/keyboard_delegate.h"
#include "components/exo/keyboard_modifiers.h"
#include "components/exo/wayland/server_util.h"
#include "components/exo/wayland/wayland_input_delegate.h"
#include "ui/base/buildflags.h"
#include "ui/events/keycodes/dom/keycode_converter.h"
struct wl_client;
struct wl_resource;
namespace exo {
namespace wayland {
class SerialTracker;
// Keyboard delegate class that accepts events for surfaces owned by the same
// client as a keyboard resource.
class WaylandKeyboardDelegate : public WaylandInputDelegate,
public KeyboardDelegate {
#if BUILDFLAG(USE_XKBCOMMON)
public:
WaylandKeyboardDelegate(wl_resource* keyboard_resource,
SerialTracker* serial_tracker);
WaylandKeyboardDelegate(const WaylandKeyboardDelegate&) = delete;
WaylandKeyboardDelegate& operator=(const WaylandKeyboardDelegate) = delete;
~WaylandKeyboardDelegate() override;
// Overridden from KeyboardDelegate:
bool CanAcceptKeyboardEventsForSurface(Surface* surface) const override;
void OnKeyboardEnter(
Surface* surface,
const base::flat_map<ui::DomCode, KeyState>& pressed_keys) override;
void OnKeyboardLeave(Surface* surface) override;
uint32_t OnKeyboardKey(base::TimeTicks time_stamp,
ui::DomCode key,
bool pressed) override;
void OnKeyboardModifiers(const KeyboardModifiers& modifiers) override;
void OnKeyRepeatSettingsChanged(bool enabled,
base::TimeDelta delay,
base::TimeDelta interval) override;
void OnKeyboardLayoutUpdated(base::StringPiece keymap) override;
private:
// Sends the current modifiers to the client.
void SendKeyboardModifiers();
// The client who own this keyboard instance.
wl_client* client() const;
// The keyboard resource associated with the keyboard.
const raw_ptr<wl_resource, ExperimentalAsh> keyboard_resource_;
// Owned by Server, which always outlives this delegate.
const raw_ptr<SerialTracker, ExperimentalAsh> serial_tracker_;
// Tracks the latest modifiers.
KeyboardModifiers current_modifiers_{};
#endif
};
// Exposed for testing.
int32_t GetWaylandRepeatRateForTesting(bool enabled, base::TimeDelta interval);
} // namespace wayland
} // namespace exo
#endif // COMPONENTS_EXO_WAYLAND_WAYLAND_KEYBOARD_DELEGATE_H_
|