#include "remoting/host/linux/input_injector_wayland.h"
#include <gtk/gtk.h>
#include <stddef.h>
#include <stdint.h>
#include <memory>
#include <optional>
#include <set>
#include <utility>
#include "base/containers/contains.h"
#include "base/containers/queue.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/functional/callback_forward.h"
#include "base/numerics/safe_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversion_utils.h"
#include "base/task/single_thread_task_runner.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "remoting/base/constants.h"
#include "remoting/base/logging.h"
#include "remoting/host/clipboard.h"
#include "remoting/host/input_injector_constants_linux.h"
#include "remoting/host/input_injector_metadata.h"
#include "remoting/host/linux/clipboard_wayland.h"
#include "remoting/host/linux/remote_desktop_portal_injector.h"
#include "remoting/host/linux/unicode_to_keysym.h"
#include "remoting/host/linux/wayland_manager.h"
#include "remoting/proto/internal.pb.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h"
#include "third_party/webrtc/modules/portal/scoped_glib.h"
#include "third_party/webrtc/modules/portal/xdg_desktop_portal_utils.h"
#include "ui/events/keycodes/dom/dom_code.h"
#include "ui/events/keycodes/dom/keycode_converter.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "remoting/host/chromeos/point_transformer.h"
#endif
namespace remoting {
namespace {
ClipboardEvent;
KeyEvent;
MouseEvent;
TextEvent;
TouchEvent;
SessionDetails;
RemoteDesktopPortalInjector;
constexpr int BUTTON_LEFT_KEYCODE = …;
constexpr int BUTTON_RIGHT_KEYCODE = …;
constexpr int BUTTON_MIDDLE_KEYCODE = …;
constexpr int BUTTON_FORWARD_KEYCODE = …;
constexpr int BUTTON_BACK_KEYCODE = …;
constexpr int BUTTON_UNKNOWN_KEYCODE = …;
constexpr int MIN_KEYCODE = …;
constexpr int SHIFT_KEY_CODE = …;
ScrollDirection WheelDeltaToScrollDirection(float num) { … }
bool IsDomModifierKey(ui::DomCode dom_code) { … }
int MouseButtonToEvdevCode(MouseEvent::MouseButton button) { … }
constexpr float kWheelTicksPerPixel = …;
constexpr base::TimeDelta kContinuousScrollTimeout = …;
}
InputInjectorWayland::InputInjectorWayland(
scoped_refptr<base::SingleThreadTaskRunner> task_runner) { … }
InputInjectorWayland::~InputInjectorWayland() = default;
void InputInjectorWayland::InjectClipboardEvent(const ClipboardEvent& event) { … }
void InputInjectorWayland::InjectKeyEvent(const KeyEvent& event) { … }
void InputInjectorWayland::InjectTextEvent(const TextEvent& event) { … }
void InputInjectorWayland::InjectMouseEvent(const MouseEvent& event) { … }
void InputInjectorWayland::InjectTouchEvent(const TouchEvent& event) { … }
void InputInjectorWayland::Start(
std::unique_ptr<protocol::ClipboardStub> client_clipboard) { … }
void InputInjectorWayland::SetMetadata(InputInjectorMetadata metadata) { … }
InputInjectorWayland::Core::Core(
scoped_refptr<base::SingleThreadTaskRunner> input_task_runner)
: … { … }
void InputInjectorWayland::Core::SetCapabilityCallbacks() { … }
void InputInjectorWayland::Core::InjectFakeKeyEvent() { … }
void InputInjectorWayland::Core::InjectFakePointerEvent() { … }
void InputInjectorWayland::Core::SeatAcquiredKeyboardCapability() { … }
void InputInjectorWayland::Core::SeatAcquiredPointerCapability() { … }
void InputInjectorWayland::Core::InjectClipboardEvent(
const ClipboardEvent& event) { … }
void InputInjectorWayland::Core::QueueKeyEvent(
const protocol::KeyEvent& event) { … }
void InputInjectorWayland::Core::QueueMouseEvent(
const protocol::MouseEvent& event) { … }
void InputInjectorWayland::Core::ProcessKeyEvent(
const protocol::KeyEvent& event) { … }
void InputInjectorWayland::Core::ProcessMouseEvent(
const protocol::MouseEvent& event) { … }
void InputInjectorWayland::Core::InjectKeyEvent(const KeyEvent& event) { … }
void InputInjectorWayland::Core::InjectKeyEventHelper(const KeyEvent& event) { … }
void InputInjectorWayland::Core::InjectTextEvent(const TextEvent& event) { … }
InputInjectorWayland::Core::~Core() { … }
void InputInjectorWayland::Core::InjectMouseEvent(const MouseEvent& event) { … }
void InputInjectorWayland::Core::InjectMouseEventHelper(
const MouseEvent& event) { … }
void InputInjectorWayland::Core::InjectPendingEvents(bool libei_succeeded) { … }
void InputInjectorWayland::Core::SetRemoteDesktopSessionDetails(
const SessionDetails& session_details) { … }
void InputInjectorWayland::Core::MaybeFlushPendingEvents() { … }
void InputInjectorWayland::Core::SetClipboardSessionDetails(
const SessionDetails& session_details) { … }
void InputInjectorWayland::Core::InjectMouseButton(unsigned int code,
bool pressed) { … }
void InputInjectorWayland::Core::InjectMouseScroll(unsigned int axis,
int steps) { … }
void InputInjectorWayland::Core::MovePointerTo(int x, int y) { … }
void InputInjectorWayland::Core::MovePointerBy(int delta_x, int delta_y) { … }
void InputInjectorWayland::Core::InjectKeyPress(unsigned int code,
bool pressed,
bool is_code) { … }
void InputInjectorWayland::Core::Start(
std::unique_ptr<protocol::ClipboardStub> client_clipboard) { … }
void InputInjectorWayland::Core::Shutdown() { … }
}