51 SdlRail(
const SdlRail&) =
delete;
52 SdlRail(SdlRail&&) =
delete;
53 SdlRail& operator=(
const SdlRail&) =
delete;
54 SdlRail& operator=(SdlRail&&) =
delete;
56 bool init(RailClientContext* rail);
57 bool uninit(RailClientContext* rail);
59 [[nodiscard]]
bool enabled()
const
66 [[nodiscard]]
bool desktopMayShow();
68 void noteLogonPrompt();
72 bool paint(SDL_Surface* primary, SDL_PixelFormat fallbackFormat,
73 const std::vector<SDL_Rect>& damage);
76 UINT updateWindowFromSurface(gdiGfxSurface* surface);
79 static UINT UpdateWindowFromSurface(RdpgfxClientContext* context, gdiGfxSurface* surface);
82 [[nodiscard]]
bool ownsWindow(SDL_WindowID
id);
84 void invalidateWindow(SDL_WindowID
id);
86 void handleMaximized(SDL_WindowID
id);
87 void handleMinimized(SDL_WindowID
id);
88 void handleRestored(SDL_WindowID
id);
89 void handleClose(SDL_WindowID
id);
91 void handleFocus(SDL_WindowID
id,
bool gained);
92 void handleDisplayChanged(SDL_WindowID
id, SDL_DisplayID display);
93 void noteUsableBoundsChanged(SDL_DisplayID display);
94 void updateCoordinates();
96 void ensureActive(SDL_WindowID
id);
98 bool translateToServer(SDL_WindowID
id,
float& x,
float& y);
99 void notePopupMoved(SDL_WindowID
id);
101 void noteLeftPress(
float x,
float y)
103 _lastPressServer = {
static_cast<int>(x),
static_cast<int>(y) };
104 _lastPointerServer = _lastPressServer;
107 void noteServerPointer(
float x,
float y)
109 _lastPointerServer = {
static_cast<int>(x),
static_cast<int>(y) };
112 [[nodiscard]] uint32_t pointerEpoch()
const
114 return _pointerEpoch;
117 bool dragActive(SDL_WindowID
id);
119 bool suppressServerMotion(SDL_WindowID
id);
122 void handleLocalMoveRequested(uint32_t windowId, uint16_t moveType);
124 void noteDragResize(SDL_WindowID
id,
int w,
int h);
126 void syncGeometry(SDL_WindowID
id);
128 void completeLocalMoveIfPending();
131 void completeWaylandResize(
bool definitive =
false);
133 void noteResizeGrab(SDL_WindowID
id);
134 void settleWaylandResize();
136 void pollDragRelease();
140 [[nodiscard]]
bool windowGeometry(uint64_t
id, SDL_Window*& window,
int& width,
int& height);
143 void queueScreenSaverUpdate();
144 void updateScreenSaver();
146 [[nodiscard]] SDL_Window* beginLocalMove(uint32_t windowId, uint16_t moveType);
149 [[nodiscard]]
SdlRailWindow* getWindowBySdlId(SDL_WindowID
id);
151 void sendClientActivate(uint32_t wid,
bool enabled);
155 [[nodiscard]]
SdlRailWindow* resolveParent(uint64_t ownerId);
157 [[nodiscard]]
bool isShadowFrame(
const SdlRailWindow& popup);
159 void enableRemoteAppMode(
bool enable);
162 void sendWorkArea(
const SDL_Rect& local);
166 void clampIntoDesktop(
const SdlRailWindow& appWindow,
int& x,
int& y,
int w,
int h)
const;
168 void sendSystemCommand(
SdlRailWindow* appWindow, uint16_t command);
173 SDL_Rect _sessionMargins = { 0, 0, 0, 0 };
174 SDL_Point _lastPressServer = { 0, 0 };
175 SDL_Point _lastPointerServer = { 0, 0 };
178 SDL_Point _displayShift = { 0, 0 };
179 SDL_Point _localShift = { 0, 0 };
180 SDL_Point _inputOrigin = { 0, 0 };
183 static UINT server_app_id(RailClientContext* context,
185 static UINT server_execute_result(RailClientContext* context,
187 static UINT server_local_move_size(RailClientContext* context,
189 static UINT server_min_max_info(RailClientContext* context,
191 static UINT server_power_display_request(RailClientContext* context,
195 void registerUpdateCallbacks(rdpUpdate* update);
196 static BOOL window_common(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
207 static BOOL window_cached_icon(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
209 static BOOL window_delete(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo);
210 static BOOL monitored_desktop(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
212 static BOOL non_monitored_desktop(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo);
214 static SdlRail* get(rdpContext* context);
218 void reportAndAdopt(
SdlRailWindow* appWindow,
int x,
int y,
int w,
int h);
220 void sendClientWindowMove(
SdlRailWindow* appWindow,
const SDL_Rect& serverRect);
223 void moveToDisplay(
SdlRailWindow* appWindow, SDL_DisplayID display);
224 [[nodiscard]]
bool monitorRect(SDL_DisplayID display, SDL_Rect& rect)
const;
228 [[nodiscard]]
SdlRailIcon* iconCacheLookup(uint32_t cacheId, uint32_t cacheEntry);
232 static void redrawDuringSizeMove(
void* userdata);
234 static void nativeResize(
void* userdata, SDL_WindowID
id,
int moveType,
bool end);
236 RailClientContext* _rail =
nullptr;
238 std::atomic<bool> _enabled =
false;
239 std::atomic<uint32_t> _pointerEpoch = 0;
240 bool _refreshSent =
false;
241 std::atomic<bool> _appStarted =
false;
243 std::atomic<bool> _desktopReleased =
false;
244 std::atomic<uint64_t> _desktopHoldUntil = 0;
245 std::atomic<bool> _displayRequested =
false;
246 uint32_t _sizeMoveRedraws = 0;
247 SDL_WindowID _nativeResizeId = 0;
249 SDL_Rect _sentWorkArea = { 0, 0, 0, 0 };
252 mutable std::mutex _windowsLock;
253 std::map<uint64_t, SdlRailWindow> _windows;
255 std::multimap<uint64_t, SdlRailWindow> _deadWindows;
261 SDL_Point anchor = { 0, 0 };
262 SDL_Point pointer = { 0, 0 };
265 bool sawResize =
false;
266 Uint64 lastResize = 0;
269 bool serverEnded =
false;
271 bool wmSized =
false;
272 SDL_Point wmSize = { 0, 0 };
274 LocalMove _localMove;
279 SDL_DisplayID display = 0;
282 uint64_t _focusedAppId = 0;
284 std::vector<uint32_t> _zOrder;
285 std::vector<uint32_t> _appliedZOrder;
286 uint32_t _clientActiveId = 0;
287 bool _zOrderDirty =
false;
289 std::vector<SdlRailIcon> _iconCache;
291 uint32_t _iconCacheEntries = 0;