#include "remoting/host/keyboard_layout_monitor.h"
#include <gdk/gdk.h>
#include <optional>
#include "base/files/file_descriptor_watcher_posix.h"
#include "base/functional/bind.h"
#include "base/functional/callback.h"
#include "base/logging.h"
#include "base/memory/raw_ptr.h"
#include "base/memory/weak_ptr.h"
#include "base/strings/utf_string_conversion_utils.h"
#include "base/task/sequenced_task_runner.h"
#include "base/task/single_thread_task_runner.h"
#include "remoting/host/linux/keyboard_layout_monitor_utils.h"
#include "remoting/host/linux/keyboard_layout_monitor_wayland.h"
#include "remoting/host/linux/wayland_utils.h"
#include "remoting/proto/control.pb.h"
#include "ui/base/glib/scoped_gsignal.h"
#include "ui/events/keycodes/dom/dom_code.h"
#include "ui/events/keycodes/dom/keycode_converter.h"
#include "ui/gfx/x/connection.h"
#include "ui/gfx/x/event.h"
#include "ui/gfx/x/future.h"
#include "ui/gfx/x/xkb.h"
#include "ui/gfx/x/xproto.h"
#include "ui/gfx/x/xproto_types.h"
namespace remoting {
namespace {
class KeyboardLayoutMonitorLinux;
class GtkThreadDeleter { … };
class GdkLayoutMonitorOnGtkThread : public x11::EventObserver { … };
class KeyboardLayoutMonitorLinux : public KeyboardLayoutMonitor { … };
template <typename T>
void GtkThreadDeleter::operator()(T* p) const { … }
template <typename T>
gboolean GtkThreadDeleter::DeleteOnGtkThread(gpointer p) { … }
GdkLayoutMonitorOnGtkThread::GdkLayoutMonitorOnGtkThread(
scoped_refptr<base::SequencedTaskRunner> task_runner,
base::WeakPtr<KeyboardLayoutMonitorLinux> weak_ptr)
: … { … }
GdkLayoutMonitorOnGtkThread::~GdkLayoutMonitorOnGtkThread() { … }
void GdkLayoutMonitorOnGtkThread::Start() { … }
void GdkLayoutMonitorOnGtkThread::OnEvent(const x11::Event& event) { … }
void GdkLayoutMonitorOnGtkThread::QueryLayout() { … }
void GdkLayoutMonitorOnGtkThread::OnKeysChanged(GdkKeymap* keymap) { … }
KeyboardLayoutMonitorLinux::KeyboardLayoutMonitorLinux(
base::RepeatingCallback<void(const protocol::KeyboardLayout&)> callback)
: … { … }
KeyboardLayoutMonitorLinux::~KeyboardLayoutMonitorLinux() = default;
void KeyboardLayoutMonitorLinux::Start() { … }
void KeyboardLayoutMonitorLinux::OnLayoutChanged(
const protocol::KeyboardLayout& new_layout) { … }
gboolean KeyboardLayoutMonitorLinux::StartLayoutMonitorOnGtkThread(
gpointer gdk_layout_monitor) { … }
}
std::unique_ptr<KeyboardLayoutMonitor> KeyboardLayoutMonitor::Create(
base::RepeatingCallback<void(const protocol::KeyboardLayout&)> callback,
scoped_refptr<base::SingleThreadTaskRunner> input_task_runner) { … }
}