53 SdlRail(
const SdlRail&) =
delete;
54 SdlRail(SdlRail&&) =
delete;
55 SdlRail& operator=(
const SdlRail&) =
delete;
56 SdlRail& operator=(SdlRail&&) =
delete;
58 bool init(RailClientContext* rail);
59 bool uninit(RailClientContext* rail);
61 [[nodiscard]]
bool enabled()
const
68 [[nodiscard]]
bool desktopMayShow();
70 void noteLogonPrompt();
74 bool paint(SDL_Surface* primary, SDL_PixelFormat fallbackFormat,
75 const std::vector<SDL_Rect>& damage);
78 UINT updateWindowFromSurface(gdiGfxSurface* surface);
81 static UINT UpdateWindowFromSurface(RdpgfxClientContext* context, gdiGfxSurface* surface);
84 [[nodiscard]]
bool ownsWindow(SDL_WindowID
id);
86 void invalidateWindow(SDL_WindowID
id);
88 void handleMaximized(SDL_WindowID
id);
89 void handleMinimized(SDL_WindowID
id);
90 void handleRestored(SDL_WindowID
id);
91 void handleClose(SDL_WindowID
id);
93 void handleFocus(SDL_WindowID
id,
bool gained);
94 void handleDisplayChanged(SDL_WindowID
id, SDL_DisplayID display);
95 void noteUsableBoundsChanged(SDL_DisplayID display);
96 void updateCoordinates();
98 void ensureActive(SDL_WindowID
id);
101 void inputWindows(SDL_WindowID
id, std::vector<SdlInputWindow>& windows,
102 std::optional<size_t>& source);
103 void notePopupMoved(SDL_WindowID
id);
105 void noteLeftPress(
float x,
float y)
107 _lastPressServer = {
static_cast<int>(x),
static_cast<int>(y) };
108 _lastPointerServer = _lastPressServer;
111 void noteServerPointer(
float x,
float y)
113 _lastPointerServer = {
static_cast<int>(x),
static_cast<int>(y) };
116 [[nodiscard]] uint32_t pointerEpoch()
const
118 return _pointerEpoch;
121 bool dragActive(SDL_WindowID
id);
123 bool suppressServerMotion(SDL_WindowID
id);
126 void handleLocalMoveRequested(uint32_t windowId, uint16_t moveType);
128 void noteDragResize(SDL_WindowID
id,
int w,
int h);
130 void syncGeometry(SDL_WindowID
id);
132 void completeLocalMoveIfPending();
135 void completeWaylandResize(
bool definitive =
false);
137 void noteResizeGrab(SDL_WindowID
id);
138 void settleWaylandResize();
140 void pollDragRelease();
144 [[nodiscard]]
bool windowGeometry(uint64_t
id, SDL_Window*& window,
int& width,
int& height);
147 void queueScreenSaverUpdate();
148 void updateScreenSaver();
150 [[nodiscard]] SDL_Window* beginLocalMove(uint32_t windowId, uint16_t moveType);
153 [[nodiscard]]
SdlRailWindow* getWindowBySdlId(SDL_WindowID
id);
155 [[nodiscard]] SDL_Point inputLayoutPosition(
SdlRailWindow* appWindow);
157 void sendClientActivate(uint32_t wid,
bool enabled);
161 [[nodiscard]]
SdlRailWindow* resolveParent(uint64_t ownerId);
163 [[nodiscard]]
bool isShadowFrame(
const SdlRailWindow& popup);
165 void enableRemoteAppMode(
bool enable);
168 void sendWorkArea(
const SDL_Rect& local);
172 void clampIntoDesktop(
const SdlRailWindow& appWindow,
int& x,
int& y,
int w,
int h)
const;
174 void sendSystemCommand(
SdlRailWindow* appWindow, uint16_t command);
179 SDL_Rect _sessionMargins = { 0, 0, 0, 0 };
180 SDL_Point _lastPressServer = { 0, 0 };
181 SDL_Point _lastPointerServer = { 0, 0 };
184 SDL_Point _displayShift = { 0, 0 };
185 SDL_Point _localShift = { 0, 0 };
188 static UINT server_app_id(RailClientContext* context,
190 static UINT server_execute_result(RailClientContext* context,
192 static UINT server_local_move_size(RailClientContext* context,
194 static UINT server_min_max_info(RailClientContext* context,
196 static UINT server_power_display_request(RailClientContext* context,
200 void registerUpdateCallbacks(rdpUpdate* update);
201 static BOOL window_common(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
212 static BOOL window_cached_icon(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
214 static BOOL window_delete(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo);
215 static BOOL monitored_desktop(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
217 static BOOL non_monitored_desktop(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo);
219 static SdlRail* get(rdpContext* context);
223 void reportAndAdopt(
SdlRailWindow* appWindow,
int x,
int y,
int w,
int h);
225 void sendClientWindowMove(
SdlRailWindow* appWindow,
const SDL_Rect& serverRect);
228 void moveToDisplay(
SdlRailWindow* appWindow, SDL_DisplayID display);
229 [[nodiscard]]
bool monitorRect(SDL_DisplayID display, SDL_Rect& rect)
const;
233 [[nodiscard]]
SdlRailIcon* iconCacheLookup(uint32_t cacheId, uint32_t cacheEntry);
237 static void redrawDuringSizeMove(
void* userdata);
239 static void nativeResize(
void* userdata, SDL_WindowID
id,
int moveType,
bool end);
241 RailClientContext* _rail =
nullptr;
243 std::atomic<bool> _enabled =
false;
244 std::atomic<uint32_t> _pointerEpoch = 0;
245 bool _refreshSent =
false;
246 std::atomic<bool> _appStarted =
false;
248 std::atomic<bool> _desktopReleased =
false;
249 std::atomic<uint64_t> _desktopHoldUntil = 0;
250 std::atomic<bool> _displayRequested =
false;
251 uint32_t _sizeMoveRedraws = 0;
252 SDL_WindowID _nativeResizeId = 0;
254 SDL_Rect _sentWorkArea = { 0, 0, 0, 0 };
257 mutable std::mutex _windowsLock;
258 std::map<uint64_t, SdlRailWindow> _windows;
260 std::multimap<uint64_t, SdlRailWindow> _deadWindows;
266 SDL_Point anchor = { 0, 0 };
267 SDL_Point pointer = { 0, 0 };
270 bool sawResize =
false;
271 Uint64 lastResize = 0;
274 bool serverEnded =
false;
276 bool wmSized =
false;
277 SDL_Point wmSize = { 0, 0 };
279 LocalMove _localMove;
284 SDL_DisplayID display = 0;
287 uint64_t _focusedAppId = 0;
289 std::vector<uint32_t> _zOrder;
290 std::vector<uint32_t> _appliedZOrder;
291 uint32_t _clientActiveId = 0;
292 bool _zOrderDirty =
false;
294 std::vector<SdlRailIcon> _iconCache;
296 uint32_t _iconCacheEntries = 0;