summaryrefslogtreecommitdiffstats
path: root/xbmc/windowing/wayland/SeatInputProcessing.cpp
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 18:07:22 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 18:07:22 +0000
commitc04dcc2e7d834218ef2d4194331e383402495ae1 (patch)
tree7333e38d10d75386e60f336b80c2443c1166031d /xbmc/windowing/wayland/SeatInputProcessing.cpp
parentInitial commit. (diff)
downloadkodi-c04dcc2e7d834218ef2d4194331e383402495ae1.tar.xz
kodi-c04dcc2e7d834218ef2d4194331e383402495ae1.zip
Adding upstream version 2:20.4+dfsg.upstream/2%20.4+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'xbmc/windowing/wayland/SeatInputProcessing.cpp')
-rw-r--r--xbmc/windowing/wayland/SeatInputProcessing.cpp83
1 files changed, 83 insertions, 0 deletions
diff --git a/xbmc/windowing/wayland/SeatInputProcessing.cpp b/xbmc/windowing/wayland/SeatInputProcessing.cpp
new file mode 100644
index 0000000..6430aad
--- /dev/null
+++ b/xbmc/windowing/wayland/SeatInputProcessing.cpp
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2018 Team Kodi
+ * This file is part of Kodi - https://kodi.tv
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ * See LICENSES/README.md for more information.
+ */
+
+#include "SeatInputProcessing.h"
+
+#include <cassert>
+
+using namespace KODI::WINDOWING::WAYLAND;
+
+CSeatInputProcessing::CSeatInputProcessing(wayland::surface_t const& inputSurface, IInputHandler& handler)
+: m_inputSurface{inputSurface}, m_handler{handler}
+{
+}
+
+void CSeatInputProcessing::AddSeat(CSeat* seat)
+{
+ assert(m_seats.find(seat->GetGlobalName()) == m_seats.end());
+ auto& seatState = m_seats.emplace(seat->GetGlobalName(), seat).first->second;
+
+ seatState.keyboardProcessor.reset(new CInputProcessorKeyboard(*this));
+ seat->AddRawInputHandlerKeyboard(seatState.keyboardProcessor.get());
+ seatState.pointerProcessor.reset(new CInputProcessorPointer(m_inputSurface, *this));
+ seat->AddRawInputHandlerPointer(seatState.pointerProcessor.get());
+ seatState.touchProcessor.reset(new CInputProcessorTouch(m_inputSurface));
+ seat->AddRawInputHandlerTouch(seatState.touchProcessor.get());
+}
+
+void CSeatInputProcessing::RemoveSeat(CSeat* seat)
+{
+ auto seatStateI = m_seats.find(seat->GetGlobalName());
+ if (seatStateI != m_seats.end())
+ {
+ seat->RemoveRawInputHandlerKeyboard(seatStateI->second.keyboardProcessor.get());
+ seat->RemoveRawInputHandlerPointer(seatStateI->second.pointerProcessor.get());
+ seat->RemoveRawInputHandlerTouch(seatStateI->second.touchProcessor.get());
+ m_seats.erase(seatStateI);
+ }
+}
+
+void CSeatInputProcessing::OnPointerEnter(std::uint32_t seatGlobalName, std::uint32_t serial)
+{
+ m_handler.OnSetCursor(seatGlobalName, serial);
+ m_handler.OnEnter(InputType::POINTER);
+}
+
+void CSeatInputProcessing::OnPointerLeave()
+{
+ m_handler.OnLeave(InputType::POINTER);
+}
+
+void CSeatInputProcessing::OnPointerEvent(XBMC_Event& event)
+{
+ m_handler.OnEvent(InputType::POINTER, event);
+}
+
+void CSeatInputProcessing::OnKeyboardEnter()
+{
+ m_handler.OnEnter(InputType::KEYBOARD);
+}
+
+void CSeatInputProcessing::OnKeyboardLeave()
+{
+ m_handler.OnLeave(InputType::KEYBOARD);
+}
+
+void CSeatInputProcessing::OnKeyboardEvent(XBMC_Event& event)
+{
+ m_handler.OnEvent(InputType::KEYBOARD, event);
+}
+
+void CSeatInputProcessing::SetCoordinateScale(std::int32_t scale)
+{
+ for (auto& seatPair : m_seats)
+ {
+ seatPair.second.touchProcessor->SetCoordinateScale(scale);
+ seatPair.second.pointerProcessor->SetCoordinateScale(scale);
+ }
+}