24#include <winpr/assert.h>
25#include <winpr/platform.h>
26#include <winpr/cast.h>
28#include <freerdp/freerdp.h>
29#include <freerdp/log.h>
30#include <freerdp/codec/color.h>
31#include <freerdp/codec/region.h>
32#include <freerdp/client/rail.h>
34#include "sdl_rail.hpp"
35#include "sdl_context.hpp"
36#include "sdl_rail_platform.hpp"
37#include "sdl_types.hpp"
38#include "sdl_utils.hpp"
39#include "sdl_wayland.hpp"
42#define TAG CLIENT_TAG("sdl.rail")
44SdlRail::SdlRail(
SdlContext* context) : _context(context)
48SdlRail::~SdlRail() =
default;
50SdlRail* SdlRail::get(rdpContext* context)
52 auto sdl = get_context(context);
55 return &
sdl->getRailChannelContext();
60 auto it = _windows.find(
id);
61 return (it == _windows.end()) ? nullptr : &it->second;
68 for (
auto& it : _windows)
70 if (it.second.sdlId() ==
id)
77static bool adjoinsOutside(
const SDL_Rect& popup,
const SDL_Rect& win)
80 if (SDL_GetRectIntersection(&popup, &win, &hit))
82 const SDL_Rect grown = { win.x - 1, win.y - 1, win.w + 2, win.h + 2 };
83 return SDL_GetRectIntersection(&popup, &grown, &hit);
89 return (!w.isPopup() || w.isFullscreen()) && (w.window() !=
nullptr);
94 auto* owner = getWindow(ownerId);
95 if (owner && canParentPopup(*owner))
107 const SDL_Rect pr = popup.windowRect();
108 const SDL_Point origin = { pr.x, pr.y };
109 for (uint32_t
id : _zOrder)
111 auto* w = getWindow(
id);
112 if (!w || !canParentPopup(*w))
114 const SDL_Rect wr = w->windowRect();
115 if (SDL_PointInRect(&origin, &wr))
123 for (
auto& other : _windows)
125 auto& w = other.second;
126 if (!canParentPopup(w))
128 const SDL_Rect wr = w.windowRect();
129 if (SDL_PointInRect(&origin, &wr))
138 chosen = resolveParent(_focusedAppId);
141 for (
auto& other : _windows)
143 auto& w = other.second;
144 if (canParentPopup(w))
157 if (!popup.isLayered())
159 const SDL_Rect pr = popup.windowRect();
160 for (
auto& other : _windows)
162 auto& w = other.second;
163 if (canParentPopup(w) && adjoinsOutside(pr, w.windowRect()))
169bool SdlRail::ownsWindow(SDL_WindowID
id)
171 std::unique_lock lock(_windowsLock);
172 return getWindowBySdlId(
id) !=
nullptr;
175void SdlRail::invalidateWindow(SDL_WindowID
id)
177 std::unique_lock lock(_windowsLock);
178 auto* appWindow = getWindowBySdlId(
id);
181 appWindow->invalidateAll();
183 (void)sdl_push_user_event(SDL_EVENT_USER_UPDATE);
187void SdlRail::sendSystemCommand(
SdlRailWindow* appWindow, uint16_t command)
189 if (!_rail || !_rail->ClientSystemCommand)
192 syscommand.windowId =
static_cast<UINT32
>(appWindow->id());
193 syscommand.command = command;
194 std::ignore = _rail->ClientSystemCommand(_rail, &syscommand);
197void SdlRail::sendWorkArea(
const SDL_Rect& area)
199 if (!_rail || !_rail->ClientSystemParam || (area.w <= 0) || (area.h <= 0))
201 if (SDL_RectsEqual(&area, &_sentWorkArea))
206 param.params = SPI_MASK_SET_WORK_AREA;
207 param.workArea.left = WINPR_ASSERTING_INT_CAST(UINT16, area.x);
208 param.workArea.top = WINPR_ASSERTING_INT_CAST(UINT16, area.y);
209 param.workArea.right = WINPR_ASSERTING_INT_CAST(UINT16, area.x + area.w);
210 param.workArea.bottom = WINPR_ASSERTING_INT_CAST(UINT16, area.y + area.h);
211 if (_rail->ClientSystemParam(_rail, ¶m) == CHANNEL_RC_OK)
212 _sentWorkArea = area;
215void SdlRail::handleMaximized(SDL_WindowID
id)
217 std::unique_lock lock(_windowsLock);
218 auto* appWindow = getWindowBySdlId(
id);
219 if (!appWindow || appWindow->isPopup() || !appWindow->window())
222 if (appWindow->railMaximized())
224 WLog_DBG(TAG,
"local maximize skipped id=0x%08" PRIx32
" (already rail-maximized)",
225 static_cast<UINT32
>(appWindow->id()));
228 appWindow->setRailMaximized(
true);
230 appWindow->invalidateAll();
232 if (appWindow->loopEndPending())
234 appWindow->deferMaximize();
235 WLog_DBG(TAG,
"local maximize deferred id=0x%08" PRIx32
" (modal loop open)",
236 static_cast<UINT32
>(appWindow->id()));
240 WLog_DBG(TAG,
"local maximize id=0x%08" PRIx32
" -> SC_MAXIMIZE",
241 static_cast<UINT32
>(appWindow->id()));
242 sendSystemCommand(appWindow, SC_MAXIMIZE);
245 (void)sdl_push_user_event(SDL_EVENT_USER_UPDATE);
248void SdlRail::handleMinimized(SDL_WindowID
id)
250 std::unique_lock lock(_windowsLock);
251 auto* appWindow = getWindowBySdlId(
id);
252 if (!appWindow || appWindow->isPopup() || !appWindow->window())
254 if (appWindow->railMinimized())
256 appWindow->setRailMinimized(
true);
257 WLog_DBG(TAG,
"local minimize id=0x%08" PRIx32
" -> SC_MINIMIZE",
258 static_cast<UINT32
>(appWindow->id()));
259 sendSystemCommand(appWindow, SC_MINIMIZE);
262void SdlRail::handleClose(SDL_WindowID
id)
264 std::unique_lock lock(_windowsLock);
265 auto* appWindow = getWindowBySdlId(
id);
266 if (!appWindow || !appWindow->window())
268 WLog_DBG(TAG,
"local close id=0x%08" PRIx32
" -> SC_CLOSE",
269 static_cast<UINT32
>(appWindow->id()));
270 sendSystemCommand(appWindow, SC_CLOSE);
273void SdlRail::handleRestored(SDL_WindowID
id)
275 std::unique_lock lock(_windowsLock);
276 auto* appWindow = getWindowBySdlId(
id);
277 if (!appWindow || appWindow->isPopup() || !appWindow->window())
280 if (appWindow->railMinimized())
281 appWindow->setRailMinimized(
false);
282 else if (appWindow->railMaximized())
283 appWindow->setRailMaximized(
false);
286 WLog_DBG(TAG,
"local restore id=0x%08" PRIx32
" -> SC_RESTORE",
287 static_cast<UINT32
>(appWindow->id()));
288 appWindow->invalidateAll();
289 sendSystemCommand(appWindow, SC_RESTORE);
291 (void)sdl_push_user_event(SDL_EVENT_USER_UPDATE);
294void SdlRail::handleFocus(SDL_WindowID
id,
bool gained)
296 std::unique_lock lock(_windowsLock);
297 auto appWindow = getWindowBySdlId(
id);
298 if (!appWindow || (appWindow->isPopup() && !appWindow->isFullscreen()) || !appWindow->window())
303 if (!gained && (_localMove.id ==
static_cast<uint32_t
>(appWindow->id())))
308 _focusedAppId = appWindow->id();
323 const auto* active = getWindow(_clientActiveId);
324 if (active && (active != appWindow) &&
325 (active->owner() ==
static_cast<uint32_t
>(appWindow->id())))
329 const auto wid =
static_cast<uint32_t
>(appWindow->id());
330 sendClientActivate(wid,
true);
334void SdlRail::sendClientActivate(uint32_t wid,
bool enabled)
336 if (!_rail || !_rail->ClientActivate)
339 _clientActiveId = wid;
341 activate.windowId = wid;
342 activate.enabled = enabled;
343 std::ignore = _rail->ClientActivate(_rail, &activate);
347void SdlRail::ensureActive(SDL_WindowID
id)
349 std::unique_lock lock(_windowsLock);
350 auto* appWindow = getWindowBySdlId(
id);
351 if (!appWindow || (appWindow->isPopup() && !appWindow->isFullscreen()) || !appWindow->window())
353 const auto wid =
static_cast<uint32_t
>(appWindow->id());
354 if (wid == _clientActiveId)
356 sendClientActivate(wid,
true);
359bool SdlRail::translateToServer(SDL_WindowID
id,
float& x,
float& y)
361 std::unique_lock lock(_windowsLock);
362 auto* appWindow = getWindowBySdlId(
id);
365 SDL_FPoint rpos = { x, y };
366 if (
auto* renderer = appWindow->renderer())
367 (void)SDL_RenderCoordinatesFromWindow(renderer, x, y, &rpos.x, &rpos.y);
369 const SDL_Point origin = appWindow->serverOrigin();
370 x = rpos.x +
static_cast<float>(origin.x);
371 y = rpos.y +
static_cast<float>(origin.y);
375SdlRailWindow* SdlRail::addWindow(uint64_t
id,
const SDL_Rect& rect)
378 auto it = _windows.find(
id);
379 if ((it != _windows.end()) && it->second.isDeleted())
381 WLog_DBG(TAG,
"window recreate id=0x%08" PRIx32
" reused a deleted entry",
382 static_cast<uint32_t
>(
id));
383 _deadWindows.insert(_windows.extract(it));
386 auto res = _windows.emplace(std::piecewise_construct, std::forward_as_tuple(
id),
387 std::forward_as_tuple(
id, rect));
388 return &res.first->second;
391void SdlRail::enableRemoteAppMode(
bool enable)
396bool SdlRail::paint(SDL_Surface* primary, SDL_PixelFormat fallbackFormat,
397 const std::vector<SDL_Rect>& damage)
402 std::unique_lock lock(_windowsLock);
405 if (_sentWorkArea.w == 0)
408 if (SDL_GetDisplayUsableBounds(SDL_GetPrimaryDisplay(), &usable))
409 sendWorkArea(usable);
413 for (
auto& [wid, win] : _windows)
415 if (win.isDeleted() || !win.window())
417 for (SDL_Window* p = SDL_GetWindowParent(win.window()); p; p = SDL_GetWindowParent(p))
419 auto* owner = getWindowBySdlId(SDL_GetWindowID(p));
420 if (!owner || owner->isDeleted())
429 std::vector<std::pair<size_t, uint64_t>> dead;
430 for (
auto& [wid, win] : _windows)
432 if (!win.isDeleted())
435 for (SDL_Window* p = win.window() ? SDL_GetWindowParent(win.window()) : nullptr; p;
436 p = SDL_GetWindowParent(p))
438 dead.emplace_back(depth, wid);
440 std::sort(dead.begin(), dead.end(),
441 [](
const auto& a,
const auto& b) { return a.first > b.first; });
442 for (
const auto& [depth, wid] : dead)
445 _deadWindows.clear();
448 for (
auto& it : _windows)
450 auto& win = it.second;
454 SDL_Window* parent =
nullptr;
455 SDL_Rect parentRect{};
456 auto* owner = resolveParent(win.owner());
457 if (owner && (owner != &win))
459 parent = owner->window();
460 parentRect = owner->outerRect();
462 win.paint(primary, fallbackFormat, damage, parent, parentRect);
464 SDL_Rect refusedOuter{};
465 if (win.takeWmOverride(refusedOuter))
467 const SDL_Rect rect = win.serverRect(refusedOuter);
468 const SDL_Rect cur = win.windowRect();
470 "wm-refused adopt id=0x%08" PRIx32
471 " outer=%dx%d -> srv=%d,%d %dx%d (was %dx%d)",
472 static_cast<uint32_t
>(win.id()), refusedOuter.w, refusedOuter.h, rect.x,
473 rect.y, rect.w, rect.h, cur.w, cur.h);
474 if (!SDL_RectsEqual(&rect, &cur))
475 sendClientWindowMove(&win, rect);
476 win.adoptLocalGeometry(rect);
483 for (
auto& it : _windows)
485 if (it.second.isPopup() || !it.second.window())
487 auto* ctx = &_context->common()->context;
488 const auto dw =
static_cast<UINT16
>(
490 const auto dh =
static_cast<UINT16
>(
493 if (ctx->update && ctx->update->RefreshRect)
494 (void)ctx->update->RefreshRect(ctx, 1, &all);
496 WLog_DBG(TAG,
"refresh-rect sent (first app window realized)");
501 for (
auto& it : _windows)
503 auto& popup = it.second;
504 if (!popup.isPopup())
508 if (!popup.isFrame() && isShadowFrame(popup))
509 popup.setFrame(
true);
512 if (popup.isLayered())
514 constexpr int reach = 48;
515 const SDL_Rect sr = popup.windowRect();
516 bool anchored =
false;
517 for (
auto& other : _windows)
519 auto& cand = other.second;
520 if ((&cand == &popup) || !cand.isPopup() || cand.isLayered() || !cand.window() ||
521 ((SDL_GetWindowFlags(cand.window()) & SDL_WINDOW_HIDDEN) != 0))
523 SDL_Rect zone = cand.windowRect();
530 const bool inside = (sr.x >= zone.x) && (sr.y >= zone.y) &&
531 (sr.x + sr.w <= zone.x + zone.w) &&
532 (sr.y + sr.h <= zone.y + zone.h);
539 popup.setShadowAnchored(anchored);
544 if (
auto* pw = popup.window())
546 SDL_Window* p = SDL_GetWindowParent(pw);
547 chosen = p ? getWindowBySdlId(SDL_GetWindowID(p)) : nullptr;
551 chosen = resolvePopupParent(popup);
553 WLog_DBG(TAG,
"popup id=0x%08" PRIx32
" has no parent app window",
554 static_cast<UINT32
>(popup.id()));
557 SDL_Window* parent =
nullptr;
558 SDL_Rect parentRect{};
561 parent = chosen->window();
562 parentRect = chosen->outerRect();
564 popup.paint(primary, fallbackFormat, damage, parent, parentRect);
573void SdlRail::applyZOrder()
578 if (!railPlatformCaps().supportsRestack)
580 _zOrderDirty =
false;
584 if (_localMove.id != 0)
586 WLog_VRB(TAG,
"zorder apply deferred: local move 0x%08" PRIx32
" active", _localMove.id);
590 std::vector<SDL_Window*> stack;
591 std::vector<uint32_t> applied;
592 stack.reserve(_zOrder.size());
593 applied.reserve(_zOrder.size());
594 for (uint32_t
id : _zOrder)
596 auto* w = getWindow(
id);
597 if (w && !w->isPopup() && w->window() &&
598 ((SDL_GetWindowFlags(w->window()) & SDL_WINDOW_HIDDEN) == 0))
600 stack.push_back(w->window());
601 applied.push_back(
id);
605 if (applied == _appliedZOrder)
607 _zOrderDirty =
false;
610 if (stack.size() >= 2)
612 std::ignore = sdl_x11_restack_windows(stack);
615 _appliedZOrder = std::move(applied);
616 _zOrderDirty =
false;
619UINT SdlRail::updateWindowFromSurface(gdiGfxSurface* surface)
622 return CHANNEL_RC_OK;
624 std::unique_lock lock(_windowsLock);
625 auto appWindow = getWindow(surface->windowId);
629 WLog_VRB(TAG,
"gfx surface for untracked id=0x%08" PRIx64, surface->windowId);
630 return CHANNEL_RC_OK;
635 std::min(surface->mappedWidth ? surface->mappedWidth : surface->width, surface->width);
637 std::min(surface->mappedHeight ? surface->mappedHeight : surface->height, surface->height);
641 const RECTANGLE_16* rects = region16_rects(&surface->invalidRegion, &nbRects);
643 const bool remapped = appWindow->takeSurfaceChange(surface->surfaceId);
644 if ((nbRects == 0) && !remapped)
645 return CHANNEL_RC_OK;
646 appWindow->updateGfxSurface(surface->data, surface->scanline, w, h, rects, nbRects,
648 region16_clear(&surface->invalidRegion);
650 (void)sdl_push_user_event(SDL_EVENT_USER_UPDATE);
651 return CHANNEL_RC_OK;
654UINT SdlRail::UpdateWindowFromSurface(RdpgfxClientContext* context, gdiGfxSurface* surface)
656 WINPR_ASSERT(context);
657 auto gdi =
static_cast<rdpGdi*
>(context->custom);
658 if (!gdi || !gdi->context)
659 return CHANNEL_RC_OK;
660 auto sdl = get_context(gdi->context);
662 return CHANNEL_RC_OK;
663 return sdl->getRailChannelContext().updateWindowFromSurface(surface);
666bool SdlRail::init(RailClientContext* rail)
672 registerUpdateCallbacks(_context->context()->update);
675 std::unique_lock lock(_windowsLock);
677 for (
auto it = _windows.begin(); it != _windows.end();)
680 _deadWindows.insert(_windows.extract(cur));
682 auto* settings = _context->context()->settings;
683 const uint32_t caches =
687 _iconCache.assign(
static_cast<size_t>(caches) * _iconCacheEntries, {});
691 rail->ServerExecuteResult = SdlRail::server_execute_result;
693 rail->ServerLocalMoveSize = SdlRail::server_local_move_size;
694 rail->ServerMinMaxInfo = SdlRail::server_min_max_info;
697 WLog_WARN(TAG,
"RemoteApp/RAIL support in the SDL client is experimental");
699 WLog_DBG(TAG,
"RAIL channel initialized: driver=%s positionsReadable=%d transparentWindows=%d",
700 sdl::utils::isWaylandDriver() ?
"wayland"
701 : (
sdl::utils::isX11Driver() ?
"x11" :
"other"),
702 caps.positionsReadable ? 1 : 0, caps.supportsTransparentWindows ? 1 : 0);
703#if SDL_VERSION_ATLEAST(3, 4, 10)
705 if (sdl::utils::isX11Driver())
706 SDL_SetHint(SDL_HINT_VIDEO_X11_ENABLE_XSYNC_EXT,
"1");
711bool SdlRail::uninit(WINPR_ATTR_UNUSED RailClientContext* rail)
716 std::unique_lock lock(_windowsLock);
717 _refreshSent =
false;
720 _sessionMargins = {};
725 _appliedZOrder.clear();
726 _zOrderDirty =
false;
730 WLog_DBG(TAG,
"RAIL channel uninit, marking %zu windows for main-thread teardown",
732 for (
auto& kv : _windows)
733 kv.second.markDeleted();
737 (void)sdl_push_user_event(SDL_EVENT_USER_UPDATE);
741void SdlRail::registerUpdateCallbacks(rdpUpdate* update)
743 WINPR_ASSERT(update);
744 auto window = update->window;
745 WINPR_ASSERT(window);
747 window->WindowCreate = SdlRail::window_common;
748 window->WindowUpdate = SdlRail::window_common;
749 window->WindowIcon = SdlRail::window_icon;
750 window->WindowCachedIcon = SdlRail::window_cached_icon;
751 window->WindowDelete = SdlRail::window_delete;
752 window->MonitoredDesktop = SdlRail::monitored_desktop;
753 window->NonMonitoredDesktop = SdlRail::non_monitored_desktop;
758UINT SdlRail::server_execute_result(RailClientContext* context,
761 WINPR_ASSERT(context);
762 WINPR_ASSERT(execResult);
763 auto rail =
static_cast<SdlRail*
>(context->custom);
766 if (execResult->execResult != RAIL_EXEC_S_OK)
768 WLog_ERR(TAG,
"RAIL exec error: execResult=0x%04" PRIx16
" rawResult=0x%08" PRIx32,
769 execResult->execResult, execResult->rawResult);
770 freerdp_abort_connect_context(rail->_context->context());
774 WLog_DBG(TAG,
"RemoteApp exec OK, enabling RAIL mode");
775 rail->enableRemoteAppMode(
true);
777 return CHANNEL_RC_OK;
780UINT SdlRail::server_local_move_size(RailClientContext* context,
783 WINPR_ASSERT(context);
784 WINPR_ASSERT(localMoveSize);
787 if (localMoveSize->isMoveSizeStart && (localMoveSize->moveSizeType >= RAIL_WMSZ_LEFT) &&
788 (localMoveSize->moveSizeType <= RAIL_WMSZ_MOVE))
790 WLog_DBG(TAG,
"server move/size start id=0x%08" PRIx32
" type=%" PRIu16
" pos=%d,%d",
791 localMoveSize->windowId, localMoveSize->moveSizeType, localMoveSize->posX,
792 localMoveSize->posY);
793 (void)sdl_push_user_event(SDL_EVENT_USER_RAIL_MOVE, localMoveSize->windowId,
794 static_cast<int>(localMoveSize->moveSizeType));
796 else if (!localMoveSize->isMoveSizeStart)
798 WLog_DBG(TAG,
"server move/size end id=0x%08" PRIx32, localMoveSize->windowId);
800 auto rail =
static_cast<SdlRail*
>(context->custom);
803 std::unique_lock lock(rail->_windowsLock);
805 const bool ownedByWaylandResize = rail->_localMove.wayland &&
806 (rail->_localMove.id == localMoveSize->windowId) &&
807 rail->_localMove.sawResize;
808 if (!ownedByWaylandResize)
810 if (
auto* appWindow = rail->getWindow(localMoveSize->windowId))
811 appWindow->setLocalMoveActive(
false);
812 if (rail->_localMove.id == localMoveSize->windowId)
814 if (rail->_localMove.wayland)
817 rail->_localMove = {};
818 if (
auto* appWindow = rail->getWindow(localMoveSize->windowId))
819 appWindow->invalidateAll();
820 (void)sdl_push_user_event(SDL_EVENT_USER_UPDATE);
825 rail->_localMove.serverEnded =
true;
830 auto* appWindow = rail->getWindow(localMoveSize->windowId);
831 if (appWindow && appWindow->loopEndPending())
833 const auto actions = appWindow->takeLoopEnd();
834 if (actions.maximize && appWindow->railMaximized())
836 WLog_DBG(TAG,
"deferred SC_MAXIMIZE id=0x%08" PRIx32, localMoveSize->windowId);
837 rail->sendSystemCommand(appWindow, SC_MAXIMIZE);
842 WLog_DBG(TAG,
"deferred snap resize id=0x%08" PRIx32
" rect=%d,%d %dx%d",
843 localMoveSize->windowId, actions.snapRect.x, actions.snapRect.y,
844 actions.snapRect.w, actions.snapRect.h);
845 rail->sendClientWindowMove(appWindow, actions.snapRect);
850 if (appWindow->window() && !appWindow->effectivelyMaximized() &&
851 !appWindow->localMoveSizeChanged())
853 const SDL_WindowID sdlId = appWindow->sdlId();
855 rail->syncGeometry(sdlId);
860 return CHANNEL_RC_OK;
864bool SdlRail::suppressServerInput(SDL_WindowID
id)
866 std::unique_lock lock(_windowsLock);
867 if (_localMove.id == 0)
869 auto* appWindow = getWindowBySdlId(
id);
870 return appWindow && appWindow->localMoveActive() && !_localMove.wayland;
873bool SdlRail::suppressServerMotion(SDL_WindowID
id)
875 std::unique_lock lock(_windowsLock);
876 if (_localMove.id == 0)
878 auto* appWindow = getWindowBySdlId(
id);
880 return appWindow && appWindow->localMoveActive();
884static int railToNetDirection(uint16_t moveType)
888 case RAIL_WMSZ_TOPLEFT:
892 case RAIL_WMSZ_TOPRIGHT:
894 case RAIL_WMSZ_RIGHT:
896 case RAIL_WMSZ_BOTTOMRIGHT:
898 case RAIL_WMSZ_BOTTOM:
900 case RAIL_WMSZ_BOTTOMLEFT:
911static constexpr struct
916 { RAIL_WMSZ_TOP, 1 }, { RAIL_WMSZ_BOTTOM, 2 }, { RAIL_WMSZ_LEFT, 4 },
917 { RAIL_WMSZ_TOPLEFT, 5 }, { RAIL_WMSZ_BOTTOMLEFT, 6 }, { RAIL_WMSZ_RIGHT, 8 },
918 { RAIL_WMSZ_TOPRIGHT, 9 }, { RAIL_WMSZ_BOTTOMRIGHT, 10 },
922static uint32_t railToXdgEdge(uint16_t moveType)
924 for (
const auto& e : kRailXdgEdges)
925 if (e.rail == moveType)
938static RailEdges railEdges(uint16_t t)
940 return { (t == RAIL_WMSZ_TOPLEFT) || (t == RAIL_WMSZ_LEFT) || (t == RAIL_WMSZ_BOTTOMLEFT),
941 (t == RAIL_WMSZ_TOPRIGHT) || (t == RAIL_WMSZ_RIGHT) || (t == RAIL_WMSZ_BOTTOMRIGHT),
942 (t == RAIL_WMSZ_TOPLEFT) || (t == RAIL_WMSZ_TOP) || (t == RAIL_WMSZ_TOPRIGHT),
943 (t == RAIL_WMSZ_BOTTOMLEFT) || (t == RAIL_WMSZ_BOTTOM) ||
944 (t == RAIL_WMSZ_BOTTOMRIGHT) };
947void SdlRail::handleLocalMoveRequested(uint32_t windowId, uint16_t moveType)
949 const bool wayland = sdl::utils::isWaylandDriver();
950 const bool x11 = sdl::utils::isX11Driver();
951 if (!wayland && !x11)
954 std::unique_lock lock(_windowsLock);
955 auto appWindow = getWindow(windowId);
956 if (!appWindow || !appWindow->window() || appWindow->isPopup())
959 const bool isMove = (moveType == RAIL_WMSZ_MOVE);
960 WLog_DBG(TAG,
"local move start id=0x%08" PRIx32
" driver=%s type=%" PRIu16
" %s", windowId,
961 wayland ?
"wayland" :
"x11", moveType, isMove ?
"move" :
"resize");
962 bool started =
false;
967 started = sdl_wayland_begin_move(appWindow->window());
969 started = sdl_wayland_begin_resize(appWindow->window(), railToXdgEdge(moveType));
970 if (started && !isMove)
973 _localMove.id = windowId;
974 _localMove.wayland =
true;
975 _localMove.type = moveType;
981 started = sdl_x11_begin_move_size(appWindow->window(), railToNetDirection(moveType));
985 _localMove.id = windowId;
986 _localMove.type = moveType;
988 _localMove.anchor = _lastPressServer;
989 _localMove.pointer = _lastPointerServer;
991 appWindow->clearLoopEnd();
993 const RailEdges e = railEdges(moveType);
994 const int row = e.top ? 2 : (e.bottom ? 0 : 1);
995 const int col = e.left ? 2 : (e.right ? 0 : 1);
996 (void)sdl_x11_set_bit_gravity(appWindow->window(), row * 3 + col + 1);
1000 if (started && (!wayland || !isMove))
1002 appWindow->setLocalMoveActive(
true);
1006 const RailEdges e = railEdges(moveType);
1007 appWindow->setResizeAnchor(e.left, e.top);
1012 WLog_WARN(TAG,
"WM move failed for RAIL window 0x%08" PRIx32, windowId);
1018void SdlRail::sendClientWindowMove(
SdlRailWindow* appWindow,
const SDL_Rect& serverRect)
1020 const SDL_Rect fm = appWindow->frameMargins();
1022 move.windowId =
static_cast<UINT32
>(appWindow->id());
1023 move.left = WINPR_ASSERTING_INT_CAST(INT16, serverRect.x - fm.x);
1024 move.top = WINPR_ASSERTING_INT_CAST(INT16, serverRect.y - fm.y);
1025 move.right = WINPR_ASSERTING_INT_CAST(INT16, serverRect.x + serverRect.w + fm.w);
1026 move.bottom = WINPR_ASSERTING_INT_CAST(INT16, serverRect.y + serverRect.h + fm.h);
1027 if (_rail && _rail->ClientWindowMove &&
1028 (_rail->ClientWindowMove(_rail, &move) != CHANNEL_RC_OK))
1029 WLog_WARN(TAG,
"ClientWindowMove failed for RAIL window 0x%08" PRIx32, move.windowId);
1033void SdlRail::reportAndAdopt(
SdlRailWindow* appWindow,
int x,
int y,
int w,
int h)
1036 const SDL_Rect rect = appWindow->serverRect({ x, y, w, h });
1038 const bool maximized = appWindow->effectivelyMaximized();
1040 const SDL_Rect cur = appWindow->windowRect();
1041 const bool unchanged = SDL_RectsEqual(&rect, &cur);
1042 if (!maximized && !unchanged)
1043 sendClientWindowMove(appWindow, rect);
1047 appWindow->setLocalMoveActive(
false);
1049 appWindow->adoptLocalGeometry(rect);
1051 (void)sdl_push_user_event(SDL_EVENT_USER_UPDATE);
1054void SdlRail::clampIntoDesktop(
int& x,
int& y,
int w,
int h)
const
1056 auto* settings = _context->context()->settings;
1059 x = std::clamp(x, 0, std::max(0, dw - w));
1060 y = std::clamp(y, 0, std::max(0, dh - h));
1063void SdlRail::noteDragResize(SDL_WindowID
id,
int w,
int h)
1065 std::unique_lock lock(_windowsLock);
1066 if ((_localMove.id == 0) || _localMove.wayland || (_localMove.type != RAIL_WMSZ_MOVE))
1068 auto* appWindow = getWindowBySdlId(
id);
1069 if (!appWindow || (
static_cast<uint32_t
>(appWindow->id()) != _localMove.id))
1072 if (appWindow->localMoveSizeChanged())
1074 const SDL_Rect outer = appWindow->outerRect();
1075 if ((w == outer.w) && (h == outer.h))
1078 _localMove.wmSized =
true;
1079 _localMove.wmSize = { w, h };
1083void SdlRail::reportMaximizedWorkArea(
SdlRailWindow* appWindow)
1087 SDL_GetWindowSize(appWindow->window(), &w, &h);
1088 if ((w <= 0) || (h <= 0))
1092 if (railPlatformCaps().positionsReadable)
1093 SDL_GetWindowPosition(appWindow->window(), &x, &y);
1097 if (!SDL_GetDisplayBounds(SDL_GetPrimaryDisplay(), &primary))
1099 const SDL_Rect area = { x, y, w, h };
1101 if (!SDL_GetRectIntersection(&area, &primary, &overlap) || !SDL_RectsEqual(&overlap, &area))
1106void SdlRail::syncGeometry(SDL_WindowID
id)
1108 std::unique_lock lock(_windowsLock);
1109 auto* w = getWindowBySdlId(
id);
1110 if (!w || !w->window() || w->isDeleted() || w->isPopup())
1114 if (w->effectivelyMaximized())
1116 reportMaximizedWorkArea(w);
1119 if (w->railMinimized())
1122 const auto wid =
static_cast<uint32_t
>(w->id());
1124 if (w->localMoveActive() || (_localMove.id == wid) || w->loopEndPending() ||
1125 w->stateTransitionPending() || w->awaitingRestoreRect())
1130 SDL_GetWindowSize(w->window(), &lw, &lh);
1131 if ((lw <= 0) || (lh <= 0))
1135 const SDL_Rect ins = w->insets();
1136 if (((lw - ins.x - ins.w) <= 0) || ((lh - ins.y - ins.h) <= 0))
1138 WLog_DBG(TAG,
"geometry sync id=0x%08" PRIx32
" %dx%d dropped (content collapsed)", wid, lw,
1143 const SDL_Rect vis = w->outerRect();
1144 const bool posKnown = railPlatformCaps().positionsReadable;
1148 SDL_GetWindowPosition(w->window(), &lx, &ly);
1150 clampIntoDesktop(lx, ly, lw, lh);
1153 if ((lw == vis.w) && (lh == vis.h) && (!posKnown || ((lx == vis.x) && (ly == vis.y))))
1155 w->clearGeomApplyPending();
1160 if (w->geomApplyPending())
1163 const bool overtaken = !posKnown && ((lw > vis.w) || (lh > vis.h));
1166 w->clearGeomApplyPending();
1169 WLog_DBG(TAG,
"geometry sync id=0x%08" PRIx32
" local=%d,%d %dx%d (sync)", wid, lx, ly, lw, lh);
1170 reportAndAdopt(w, lx, ly, lw, lh);
1173void SdlRail::noteResizeGrab(SDL_WindowID
id)
1175 std::unique_lock lock(_windowsLock);
1176 if (_localMove.id == 0)
1178 auto* appWindow = getWindowBySdlId(
id);
1180 if (appWindow && (
static_cast<uint32_t
>(appWindow->id()) == _localMove.id) &&
1182 _localMove.sawResize =
true;
1185void SdlRail::handleWaylandResize(SDL_WindowID
id)
1187 if (!sdl::utils::isWaylandDriver())
1189 std::unique_lock lock(_windowsLock);
1190 auto* appWindow = getWindowBySdlId(
id);
1191 if (!appWindow || appWindow->isPopup() || !appWindow->window())
1194 if (
static_cast<uint32_t
>(appWindow->id()) == _localMove.id)
1196 if (_localMove.wayland)
1197 _localMove.sawResize =
true;
1203 SDL_GetWindowSize(appWindow->window(), &w, &h);
1204 if ((w <= 0) || (h <= 0))
1208 const SDL_Rect vis = appWindow->outerRect();
1209 if ((w == vis.w) && (h == vis.h))
1217void SdlRail::completeWaylandResize(
bool definitive)
1219 std::unique_lock lock(_windowsLock);
1220 if ((_localMove.id == 0) || !_localMove.wayland)
1223 if (!_localMove.sawResize)
1227 if (
auto* appWindow = getWindow(_localMove.id))
1229 appWindow->setLocalMoveActive(
false);
1232 appWindow->invalidateAll();
1233 (void)sdl_push_user_event(SDL_EVENT_USER_UPDATE);
1241 const LocalMove drag = _localMove;
1244 auto appWindow = getWindow(drag.id);
1245 if (!appWindow || !appWindow->window())
1248 (void)SDL_SyncWindow(appWindow->window());
1251 SDL_GetWindowSize(appWindow->window(), &w, &h);
1254 const SDL_Rect start = appWindow->windowRect();
1255 const RailEdges e = railEdges(drag.type);
1256 int x = e.left ? (start.x + start.w - w) : start.x;
1257 int y = e.top ? (start.y + start.h - h) : start.y;
1258 clampIntoDesktop(x, y, w, h);
1259 reportAndAdopt(appWindow, x, y, w, h);
1262void SdlRail::completeLocalMoveIfPending()
1264 std::unique_lock lock(_windowsLock);
1265 if (_localMove.id == 0)
1268 if (_localMove.wayland)
1272 const LocalMove drag = _localMove;
1275 auto appWindow = getWindow(drag.id);
1276 if (!appWindow || !appWindow->window() || appWindow->isDeleted())
1280 if ((SDL_GetMouseState(
nullptr,
nullptr) & SDL_BUTTON_LMASK) &&
1281 !(SDL_GetGlobalMouseState(
nullptr,
nullptr) & SDL_BUTTON_LMASK))
1282 (void)sdl_x11_send_left_button_release(appWindow->window());
1285 (void)SDL_SyncWindow(appWindow->window());
1291 SDL_GetWindowSize(appWindow->window(), &w, &h);
1292 SDL_GetWindowPosition(appWindow->window(), &x, &y);
1293 const bool isMove = (drag.type == RAIL_WMSZ_MOVE);
1294 const SDL_Rect start = appWindow->outerRect();
1299 if (!appWindow->effectivelyMaximized() && drag.wmSized &&
1300 !appWindow->localMoveSizeChanged())
1305 appWindow->deferSnap(appWindow->serverRect({ x, y, w, h }));
1314 if (!drag.serverEnded)
1316 int px = drag.anchor.x;
1317 int py = drag.anchor.y;
1318 if (isMove && appWindow->localMoveSizeChanged())
1321 const SDL_Point sp = appWindow->localMoveServerPos();
1322 const SDL_Rect ii = appWindow->insets();
1323 px = drag.pointer.x + (x + ii.x) - sp.x;
1324 py = drag.pointer.y + (y + ii.y) - sp.y;
1326 else if (!appWindow->effectivelyMaximized())
1328 const RailEdges e = railEdges(drag.type);
1329 if (isMove || e.left)
1332 px += (x + w) - (start.x + start.w);
1333 if (isMove || e.top)
1336 py += (y + h) - (start.y + start.h);
1338 (void)freerdp_client_send_button_event(_context->common(), FALSE, PTR_FLAGS_BUTTON1, px,
1341 appWindow->armLoopEnd();
1344 const SDL_Rect rect = appWindow->serverRect({ x, y, w, h });
1345 const bool restoredMidDrag = appWindow->localMoveSizeChanged();
1346 appWindow->adoptLocalGeometry(rect);
1348 if (restoredMidDrag)
1349 appWindow->markGeometryDirty();
1350 (void)sdl_push_user_event(SDL_EVENT_USER_UPDATE);
1355 clampIntoDesktop(x, y, w, h);
1356 reportAndAdopt(appWindow, x, y, w, h);
1359 (void)sdl_x11_set_bit_gravity(appWindow->window(), 0 );
1362UINT SdlRail::server_min_max_info(RailClientContext* context,
1365 WINPR_ASSERT(context);
1366 WINPR_ASSERT(minMaxInfo);
1367 auto rail =
static_cast<SdlRail*
>(context->custom);
1370 std::unique_lock lock(rail->_windowsLock);
1371 auto appWindow = rail->getWindow(minMaxInfo->windowId);
1374 WLog_VRB(TAG,
"server minmax id=0x%08" PRIx32
" min=%dx%d max=%dx%d", minMaxInfo->windowId,
1375 minMaxInfo->minTrackWidth, minMaxInfo->minTrackHeight, minMaxInfo->maxTrackWidth,
1376 minMaxInfo->maxTrackHeight);
1377 appWindow->setMinMaxSize({ minMaxInfo->minTrackWidth, minMaxInfo->minTrackHeight },
1378 { minMaxInfo->maxTrackWidth, minMaxInfo->maxTrackHeight });
1380 (void)sdl_push_user_event(SDL_EVENT_USER_UPDATE);
1382 return CHANNEL_RC_OK;
1388static bool marginsSet(
const SDL_Rect& m)
1390 return m.x || m.y || m.w || m.h;
1397 const UINT32 fieldFlags = orderInfo->fieldFlags;
1398 SDL_Rect m = appWindow->frameMargins();
1399 if (fieldFlags & WINDOW_ORDER_FIELD_RESIZE_MARGIN_X)
1401 m.x =
static_cast<int>(state->resizeMarginLeft);
1402 m.w =
static_cast<int>(state->resizeMarginRight);
1404 if (fieldFlags & WINDOW_ORDER_FIELD_RESIZE_MARGIN_Y)
1406 m.y =
static_cast<int>(state->resizeMarginTop);
1407 m.h =
static_cast<int>(state->resizeMarginBottom);
1410 appWindow->setFrameMargins(m);
1411 SDL_Rect& sm = _sessionMargins;
1412 if (marginsSet(m) && !marginsSet(sm))
1416 for (
auto& [
id, w] : _windows)
1417 if (!marginsSet(w.resizeMargins()))
1418 w.setResizeMargins(m.x, m.y, m.w, m.h);
1420 const SDL_Rect bandSrc = marginsSet(m) ? m : sm;
1421 appWindow->setResizeMargins(bandSrc.x, bandSrc.y, bandSrc.w, bandSrc.h);
1422 WLog_DBG(TAG,
"margins id=0x%08" PRIx32
" raw L%d T%d R%d B%d", orderInfo->windowId, m.x, m.y,
1430 WLog_DBG(TAG,
"server showState id=0x%08" PRIx32
" state=0x%02" PRIx32, orderInfo->windowId,
1432 appWindow->setVisible(state->showState != WINDOW_HIDE);
1433 switch (state->showState)
1435 case WINDOW_SHOW_MAXIMIZED:
1436 appWindow->setServerMaximized(
true);
1437 appWindow->setServerMinimized(
false);
1439 case WINDOW_SHOW_MINIMIZED:
1440 appWindow->setServerMinimized(
true);
1443 appWindow->setServerMaximized(
false);
1444 appWindow->setServerMinimized(
false);
1455 std::vector<SDL_Rect> rects;
1456 rects.reserve(state->numVisibilityRects);
1457 for (UINT32 i = 0; i < state->numVisibilityRects; i++)
1460 rects.push_back({ r.left, r.top, r.right - r.left, r.bottom - r.top });
1463 WLog_DBG(TAG,
"visrects id=0x%08" PRIx32
" n=0", orderInfo->windowId);
1465 WLog_DBG(TAG,
"visrects id=0x%08" PRIx32
" n=%zu first=%dx%d+%d+%d", orderInfo->windowId,
1466 rects.size(), rects.at(0).w, rects.at(0).h, rects.at(0).x, rects.at(0).y);
1467 appWindow->setVisibilityRects(std::move(rects));
1470BOOL SdlRail::window_common(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
1473 WINPR_ASSERT(orderInfo);
1474 WINPR_ASSERT(windowState);
1475 auto rail = SdlRail::get(context);
1479 const UINT32 fieldFlags = orderInfo->fieldFlags;
1480 std::unique_lock lock(rail->_windowsLock);
1481 auto appWindow = rail->getWindow(orderInfo->windowId);
1483 if (fieldFlags & WINDOW_ORDER_STATE_NEW)
1485 const SDL_Rect rect = {
static_cast<int>(windowState->windowOffsetX),
1486 static_cast<int>(windowState->windowOffsetY),
1487 static_cast<int>(windowState->windowWidth),
1488 static_cast<int>(windowState->windowHeight) };
1489 appWindow = rail->addWindow(orderInfo->windowId, rect);
1494 "window create id=0x%08" PRIx32
" %dx%d+%d+%d style=0x%08" PRIx32
1495 " ex=0x%08" PRIx32
" owner=0x%08" PRIx32,
1496 orderInfo->windowId, rect.w, rect.h, rect.x, rect.y, windowState->style,
1497 windowState->extendedStyle, windowState->ownerWindowId);
1499 const SDL_Rect& sm = rail->_sessionMargins;
1501 appWindow->setResizeMargins(sm.x, sm.y, sm.w, sm.h);
1508 if (fieldFlags & (WINDOW_ORDER_FIELD_WND_OFFSET | WINDOW_ORDER_FIELD_WND_SIZE))
1510 SDL_Rect r = appWindow->windowRect();
1511 if (fieldFlags & WINDOW_ORDER_FIELD_WND_OFFSET)
1513 r.x =
static_cast<int>(windowState->windowOffsetX);
1514 r.y =
static_cast<int>(windowState->windowOffsetY);
1516 if (fieldFlags & WINDOW_ORDER_FIELD_WND_SIZE)
1518 r.w =
static_cast<int>(windowState->windowWidth);
1519 r.h =
static_cast<int>(windowState->windowHeight);
1521 WLog_VRB(TAG,
"server geom id=0x%08" PRIx32
" rect=%d,%d %dx%d", orderInfo->windowId, r.x,
1523 appWindow->updateWindowRect(r);
1525 if (fieldFlags & WINDOW_ORDER_FIELD_OWNER)
1526 appWindow->setOwner(windowState->ownerWindowId);
1527 if (fieldFlags & (WINDOW_ORDER_FIELD_RESIZE_MARGIN_X | WINDOW_ORDER_FIELD_RESIZE_MARGIN_Y))
1528 rail->updateMargins(appWindow, orderInfo, windowState);
1529 if (fieldFlags & WINDOW_ORDER_FIELD_STYLE)
1530 appWindow->setStyle(windowState->style, windowState->extendedStyle);
1531 if (fieldFlags & WINDOW_ORDER_FIELD_TITLE)
1533 char* title = rail_string_to_utf8_string(&windowState->titleInfo);
1536 appWindow->setTitle(title);
1541 if (fieldFlags & WINDOW_ORDER_FIELD_SHOW)
1542 updateShowState(appWindow, orderInfo, windowState);
1544 if (fieldFlags & WINDOW_ORDER_FIELD_VIS_OFFSET)
1546 WLog_DBG(TAG,
"visoff id=0x%08" PRIx32
" %d,%d", orderInfo->windowId,
1547 windowState->visibleOffsetX, windowState->visibleOffsetY);
1548 appWindow->setVisibleOffset({
static_cast<int>(windowState->visibleOffsetX),
1549 static_cast<int>(windowState->visibleOffsetY) });
1551 if (fieldFlags & WINDOW_ORDER_FIELD_VISIBILITY)
1552 updateVisRects(appWindow, orderInfo, windowState);
1555 (void)sdl_push_user_event(SDL_EVENT_USER_UPDATE);
1559SdlRailIcon* SdlRail::iconCacheLookup(uint32_t cacheId, uint32_t cacheEntry)
1561 if (cacheId == 0xFF)
1562 return &_iconScratch;
1563 const size_t idx =
static_cast<size_t>(cacheId) * _iconCacheEntries + cacheEntry;
1564 if ((_iconCacheEntries == 0) || (cacheEntry >= _iconCacheEntries) || (idx >= _iconCache.size()))
1566 return &_iconCache.at(idx);
1572 icon.w = info->width;
1573 icon.h = info->height;
1574 icon.bgra.assign(4ULL * info->width * info->height, 0);
1575 return freerdp_image_copy_from_icon_data(
1576 icon.bgra.data(), PIXEL_FORMAT_BGRA32, 0, 0, 0,
1577 WINPR_ASSERTING_INT_CAST(UINT16, info->width),
1578 WINPR_ASSERTING_INT_CAST(UINT16, info->height), info->bitsColor,
1579 WINPR_ASSERTING_INT_CAST(UINT16, info->cbBitsColor), info->bitsMask,
1580 WINPR_ASSERTING_INT_CAST(UINT16, info->cbBitsMask), info->colorTable,
1581 WINPR_ASSERTING_INT_CAST(UINT16, info->cbColorTable), info->bpp) == TRUE;
1584BOOL SdlRail::window_icon(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
1587 WINPR_ASSERT(orderInfo);
1588 WINPR_ASSERT(windowIcon);
1589 WINPR_ASSERT(windowIcon->iconInfo);
1590 auto rail = SdlRail::get(context);
1594 std::unique_lock lock(rail->_windowsLock);
1595 auto appWindow = rail->getWindow(orderInfo->windowId);
1600 const ICON_INFO* info = windowIcon->iconInfo;
1601 auto* icon = rail->iconCacheLookup(info->cacheId, info->cacheEntry);
1602 if (!icon || !convertRailIcon(info, *icon))
1604 WLog_WARN(TAG,
"failed to decode icon %02" PRIX32
":%04" PRIX32
" for window 0x%08" PRIx32,
1605 info->cacheId, info->cacheEntry, orderInfo->windowId);
1608 appWindow->setIcon(*icon);
1610 (void)sdl_push_user_event(SDL_EVENT_USER_UPDATE);
1614BOOL SdlRail::window_cached_icon(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
1617 WINPR_ASSERT(orderInfo);
1618 WINPR_ASSERT(windowCachedIcon);
1619 auto rail = SdlRail::get(context);
1623 std::unique_lock lock(rail->_windowsLock);
1624 auto appWindow = rail->getWindow(orderInfo->windowId);
1629 auto* icon = rail->iconCacheLookup(cached.cacheId, cached.cacheEntry);
1630 if (!icon || icon->bgra.empty())
1633 "cached icon %02" PRIX32
":%04" PRIX32
" not in cache (window 0x%08" PRIx32
")",
1634 cached.cacheId, cached.cacheEntry, orderInfo->windowId);
1637 appWindow->setIcon(*icon);
1639 (void)sdl_push_user_event(SDL_EVENT_USER_UPDATE);
1643BOOL SdlRail::window_delete(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo)
1645 WINPR_ASSERT(orderInfo);
1646 auto rail = SdlRail::get(context);
1651 std::unique_lock lock(rail->_windowsLock);
1652 auto appWindow = rail->getWindow(orderInfo->windowId);
1655 WLog_DBG(TAG,
"window delete id=0x%08" PRIx32, orderInfo->windowId);
1656 appWindow->markDeleted();
1660 if (rail->_localMove.id == orderInfo->windowId)
1661 rail->_localMove = {};
1662 if (rail->_clientActiveId == orderInfo->windowId)
1663 rail->_clientActiveId = 0;
1664 if (rail->_focusedAppId == orderInfo->windowId)
1665 rail->_focusedAppId = 0;
1668 (void)sdl_push_user_event(SDL_EVENT_USER_UPDATE);
1672BOOL SdlRail::monitored_desktop(rdpContext* context,
const WINDOW_ORDER_INFO* orderInfo,
1675 WINPR_ASSERT(orderInfo);
1676 WINPR_ASSERT(monitoredDesktop);
1677 auto rail = SdlRail::get(context);
1682 if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_DESKTOP_ARC_COMPLETED)
1684 rail->enableRemoteAppMode(
true);
1687 if (app && (strnlen(app, 1) > 0))
1689 WLog_DBG(TAG,
"RAIL mode enabled (monitored desktop); launching '%s'", app);
1690 if (client_rail_server_start_cmd(rail->_rail) != CHANNEL_RC_OK)
1692 WLog_ERR(TAG,
"client_rail_server_start_cmd failed for '%s'", app);
1699 if (orderInfo->fieldFlags &
1700 (WINDOW_ORDER_FIELD_DESKTOP_ZORDER | WINDOW_ORDER_FIELD_DESKTOP_ACTIVE_WND))
1702 std::unique_lock lock(rail->_windowsLock);
1703 if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_DESKTOP_ACTIVE_WND)
1707 rail->_clientActiveId = monitoredDesktop->activeWindowId;
1709 if (orderInfo->fieldFlags & WINDOW_ORDER_FIELD_DESKTOP_ZORDER)
1711 if (monitoredDesktop->windowIds && (monitoredDesktop->numWindowIds > 0))
1712 rail->_zOrder.assign(monitoredDesktop->windowIds,
1713 monitoredDesktop->windowIds + monitoredDesktop->numWindowIds);
1715 rail->_zOrder.clear();
1716 rail->_zOrderDirty =
true;
1718 (void)sdl_push_user_event(SDL_EVENT_USER_UPDATE);
1724BOOL SdlRail::non_monitored_desktop(rdpContext* context,
1727 WINPR_ASSERT(orderInfo);
1728 auto rail = SdlRail::get(context);
1731 WLog_DBG(TAG,
"RAIL mode disabled (non-monitored desktop)");
1732 rail->enableRemoteAppMode(
false);
WINPR_ATTR_NODISCARD FREERDP_API const char * freerdp_settings_get_string(const rdpSettings *settings, FreeRDP_Settings_Keys_String id)
Returns a immutable string settings value.
WINPR_ATTR_NODISCARD FREERDP_API UINT32 freerdp_settings_get_uint32(const rdpSettings *settings, FreeRDP_Settings_Keys_UInt32 id)
Returns a UINT32 settings value.