11 #include "Connection.h" 14 #include "SeatInputProcessing.h" 15 #include "ShellSurface.h" 17 #include "WindowDecorationHandler.h" 18 #include "threads/CriticalSection.h" 19 #include "threads/Event.h" 20 #include "utils/ActorProtocol.h" 21 #include "windowing/WinSystem.h" 31 #include <wayland-client.hpp> 32 #include <wayland-cursor.hpp> 33 #include <wayland-extra-protocols.hpp> 45 class CWindowDecorator;
56 const std::string GetName()
override {
return "wayland"; }
58 bool InitWindowSystem()
override;
59 bool DestroyWindowSystem()
override;
61 bool CreateNewWindow(
const std::string& name,
65 bool DestroyWindow()
override;
67 bool ResizeWindow(
int newWidth,
int newHeight,
int newLeft,
int newTop)
override;
68 bool SetFullScreen(
bool fullScreen,
RESOLUTION_INFO& res,
bool blankOtherDisplays)
override;
69 void FinishModeChange(RESOLUTION res)
override;
70 void FinishWindowResize(
int newWidth,
int newHeight)
override;
72 bool UseLimitedColor()
override;
74 void UpdateResolutions()
override;
76 bool CanDoWindowed()
override;
77 bool Minimize()
override;
79 bool HasCursor()
override;
80 void ShowOSMouse(
bool show)
override;
82 std::string GetClipboardText()
override;
84 float GetSyncOutputRefreshRate();
92 using PresentationFeedbackHandler = std::function<void(timespec , std::uint32_t , std::uint32_t ,
float , std::uint64_t )>;
93 CSignalRegistration RegisterOnPresentationFeedback(
const PresentationFeedbackHandler& handler);
95 std::vector<std::string> GetConnectedOutputs()
override;
98 bool MessagePump()
override;
101 std::unique_ptr<KODI::WINDOWING::IOSScreenSaver> GetOSScreenSaverImpl()
override;
106 std::unique_ptr<CConnection>
const& GetConnection()
110 wayland::surface_t GetMainSurface()
114 IShellSurface* GetShellSurface() {
return m_shellSurface.get(); }
116 void PrepareFramePresentation();
117 void FinishFramePresentation();
118 virtual void SetContextSize(
CSizeInt size) = 0;
119 virtual IShellSurface* CreateShellSurface(
const std::string& name);
122 void OnConfigure(std::uint32_t serial,
CSizeInt size, IShellSurface::StateBitset state)
override;
123 void OnClose()
override;
127 void OnEnter(InputType type)
override;
128 void OnLeave(InputType type)
override;
129 void OnEvent(InputType type,
XBMC_Event& event)
override;
130 void OnSetCursor(std::uint32_t seatGlobalName, std::uint32_t serial)
override;
133 void OnWindowMove(
const wayland::seat_t& seat, std::uint32_t serial)
override;
134 void OnWindowResize(
const wayland::seat_t& seat, std::uint32_t serial, wayland::shell_surface_resize edge)
override;
135 void OnWindowShowContextMenu(
const wayland::seat_t& seat, std::uint32_t serial,
CPointInt position)
override;
136 void OnWindowClose()
override;
137 void OnWindowMaximize()
override;
138 void OnWindowMinimize()
override;
141 void OnSeatAdded(std::uint32_t name, wayland::proxy_t&& seat);
142 void OnSeatRemoved(std::uint32_t name);
143 void OnOutputAdded(std::uint32_t name, wayland::proxy_t&& output);
144 void OnOutputRemoved(std::uint32_t name);
146 void LoadDefaultCursor();
147 void SendFocusChange(
bool focus);
148 bool SetResolutionExternal(
bool fullScreen,
RESOLUTION_INFO const& res);
149 void SetResolutionInternal(
CSizeInt size,
int scale, IShellSurface::StateBitset state,
bool sizeIncludesDecoration,
bool mustAck =
false, std::uint32_t configureSerial = 0u);
156 Sizes CalculateSizes(
CSizeInt size,
int scale, IShellSurface::StateBitset state,
bool sizeIncludesDecoration);
157 struct SizeUpdateInformation
159 bool surfaceSizeChanged : 1;
160 bool bufferSizeChanged : 1;
161 bool configuredSizeChanged : 1;
162 bool bufferScaleChanged : 1;
164 SizeUpdateInformation UpdateSizeVariables(
CSizeInt size,
int scale, IShellSurface::StateBitset state,
bool sizeIncludesDecoration);
165 void ApplySizeUpdate(SizeUpdateInformation update);
166 void ApplyNextState();
168 std::string UserFriendlyOutputName(std::shared_ptr<COutput>
const& output);
169 std::shared_ptr<COutput> FindOutputByUserFriendlyName(std::string
const& name);
170 std::shared_ptr<COutput> FindOutputByWaylandOutput(wayland::output_t
const& output);
174 void OnOutputDone(std::uint32_t name);
175 void UpdateBufferScale();
176 void ApplyBufferScale();
177 void ApplyOpaqueRegion();
178 void ApplyWindowGeometry();
179 void UpdateTouchDpi();
180 void ApplyShellSurfaceState(IShellSurface::StateBitset state);
182 void ProcessMessages();
183 void AckConfigure(std::uint32_t serial);
185 timespec GetPresentationClockTime();
189 std::unique_ptr<CConnection> m_connection;
190 std::unique_ptr<CRegistry> m_registry;
197 std::unique_ptr<CRegistry> m_seatRegistry;
198 wayland::compositor_t m_compositor;
199 wayland::shm_t m_shm;
200 wayland::presentation_t m_presentation;
202 std::unique_ptr<IShellSurface> m_shellSurface;
206 wayland::callback_t m_frameCallback;
207 CEvent m_frameCallbackEvent;
211 std::map<std::uint32_t, CSeat> m_seats;
212 CCriticalSection m_seatsMutex;
213 std::unique_ptr<CSeatInputProcessing> m_seatInputProcessing;
214 std::map<std::uint32_t, std::shared_ptr<COutput>> m_outputs;
216 std::map<std::uint32_t, std::shared_ptr<COutput>> m_outputsInPreparation;
217 CCriticalSection m_outputsMutex;
221 std::unique_ptr<CWindowDecorator> m_windowDecorator;
225 bool m_osCursorVisible{
true};
226 wayland::cursor_theme_t m_cursorTheme;
227 wayland::buffer_t m_cursorBuffer;
228 wayland::cursor_image_t m_cursorImage;
229 wayland::surface_t m_cursorSurface;
233 clockid_t m_presentationClock;
234 struct SurfaceSubmission
236 timespec submissionTime;
238 wayland::presentation_feedback_t feedback;
239 SurfaceSubmission(timespec
const& submissionTime, wayland::presentation_feedback_t
const& feedback);
241 std::list<SurfaceSubmission> m_surfaceSubmissions;
242 CCriticalSection m_surfaceSubmissionsMutex;
244 std::uint32_t m_syncOutputID;
246 std::atomic<float> m_syncOutputRefreshRate{0.0f};
247 static constexpr
int LATENCY_MOVING_AVERAGE_SIZE{30};
248 std::atomic<float> m_latencyMovingAverage;
251 std::chrono::steady_clock::time_point m_frameStartTime{};
255 std::set<IDispResource*> m_dispResources;
256 CCriticalSection m_dispResourcesMutex;
260 wayland::surface_t m_surface;
261 wayland::output_t m_lastSetOutput;
264 std::set<std::shared_ptr<COutput>> m_surfaceOutputs;
265 CCriticalSection m_surfaceOutputsMutex;
276 IShellSurface::StateBitset m_shellSurfaceState;
278 bool m_shellSurfaceInitializing{
false};
281 bool mustBeAcked{
false};
282 std::uint32_t configureSerial{};
285 IShellSurface::StateBitset shellSurfaceState;
287 bool m_waitingForApply{
false};
296 bool m_firstSerialAcked{
false};
297 std::uint32_t m_lastAckedSerial{0u};
299 bool m_isInitialSetFullScreen{
true};
This is an Event class built from a ConditionVariable.
Definition: Event.h:35
Definition: WinSystemWayland.h:47
Definition: ShellSurface.h:81
Definition: ActorProtocol.h:73
Definition: WinSystem.h:49
Definition: DispResource.h:14
Provide info of a resolution.
Definition: Resolution.h:66
float GetFrameLatencyAdjustment() override
Get time that should be subtracted from the display latency for this frame in milliseconds.
Definition: WinSystemWayland.cpp:1442
Definition: AudioDecoder.h:18
Definition: VideoReferenceClock.h:19
Abstraction for shell surfaces to support multiple protocols such as wl_shell (for compatibility) and...
Definition: ShellSurface.h:34
Definition: XBMC_events.h:114
float GetDisplayLatency() override
Get average display latency.
Definition: WinSystemWayland.cpp:1449
Handler for reacting to events originating in window decorations, such as moving the window by clicki...
Definition: WindowDecorationHandler.h:26