FreeRDP
Loading...
Searching...
No Matches
SdlContext Class Reference

#include <sdl_context.hpp>

Collaboration diagram for SdlContext:

Public Types

enum  CursorType { CURSOR_NULL , CURSOR_DEFAULT , CURSOR_IMAGE }
 

Public Member Functions

 SdlContext (rdpContext *context)
 
 SdlContext (const SdlContext &other)=delete
 
 SdlContext (SdlContext &&other)=delete
 
SdlContextoperator= (const SdlContext &other)=delete
 
SdlContextoperator= (SdlContext &&other)=delete
 
BOOL update_resizeable (BOOL enable)
 
BOOL update_fullscreen (BOOL enter)
 
BOOL update_minimize ()
 
rdpContext * context () const
 
rdpClientContext * common () const
 
 SdlContext (rdpContext *context)
 
 SdlContext (const SdlContext &other)=delete
 
 SdlContext (SdlContext &&other)=delete
 
SdlContextoperator= (const SdlContext &other)=delete
 
SdlContextoperator= (SdlContext &&other)=delete
 
bool redraw (bool suppress=false) const
 
void setConnected (bool val)
 
bool isConnected () const
 
void cleanup ()
 
bool resizeable () const
 
bool toggleResizeable ()
 
bool setResizeable (bool enable)
 
bool fullscreen () const
 
bool toggleFullscreen ()
 
bool setFullscreen (bool enter)
 
bool setMinimized ()
 
bool grabMouse () const
 
bool toggleGrabMouse ()
 
bool setGrabMouse (bool enter)
 
bool grabKeyboard () const
 
bool toggleGrabKeyboard ()
 
bool setGrabKeyboard (bool enter)
 
rdpContext * context () const
 
rdpClientContext * common () const
 
bool setCursor (CursorType type)
 
bool setCursor (rdpPointer *cursor)
 
rdpPointer * cursor () const
 
bool restoreCursor ()
 
void setMonitorIds (const std::vector< SDL_DisplayID > &ids)
 
const std::vector< SDL_DisplayID > & monitorIds () const
 
int64_t monitorId (uint32_t index) const
 
void push (std::vector< SDL_Rect > &&rects)
 
std::vector< SDL_Rect > pop ()
 
void setHasCursor (bool val)
 
bool hasCursor () const
 
void setMetadata ()
 
int start ()
 
int join ()
 
bool shallAbort (bool ignoreDialogs=false)
 
bool createWindows ()
 
bool updateWindowList ()
 
bool drawToWindows (const std::vector< SDL_Rect > &rects={})
 
bool drawToWindow (SdlWindow &window, const std::vector< SDL_Rect > &rects={})
 
bool minimizeAllWindows ()
 
int exitCode () const
 
SDL_PixelFormat pixelFormat () const
 
const SdlWindowgetWindowForId (SDL_WindowID id) const
 
SdlWindowgetWindowForId (SDL_WindowID id)
 
SdlWindowgetFirstWindow ()
 
bool addDisplayWindow (SDL_DisplayID id)
 
bool removeDisplay (SDL_DisplayID id)
 
sdlDispContextgetDisplayChannelContext ()
 
sdlInputgetInputChannelContext ()
 
sdlClipgetClipboardChannelContext ()
 
SdlConnectionDialogWrappergetDialog ()
 
wLog * getWLog ()
 
bool moveMouseTo (const SDL_FPoint &pos)
 
SDL_FPoint screenToPixel (SDL_WindowID id, const SDL_FPoint &pos)
 
SDL_FPoint pixelToScreen (SDL_WindowID id, const SDL_FPoint &pos)
 
SDL_FRect pixelToScreen (SDL_WindowID id, const SDL_FRect &pos)
 
bool handleEvent (const SDL_Event &ev)
 

Data Fields

wLog * log
 
bool fullscreen = false
 
bool resizeable = false
 
bool grab_mouse = false
 
bool grab_kbd = false
 
bool grab_kbd_enabled = true
 
std::map< Uint32, SdlWindowwindows
 
CriticalSection critical
 
std::thread thread
 
WinPREvent initialize
 
WinPREvent initialized
 
WinPREvent update_complete
 
WinPREvent windows_created
 
int exit_code = -1
 
sdlDispContext disp
 
sdlInput input
 
SDLSurfacePtr primary
 
SDLPixelFormatPtr primary_format
 
Uint32 sdl_pixel_format = 0
 
std::unique_ptr< SDLConnectionDialogconnection_dialog
 
std::atomic< bool > rdp_thread_running
 

Detailed Description

FreeRDP: A Remote Desktop Protocol Implementation SDL Client

Copyright 2022 Armin Novak armin.nosp@m..nov.nosp@m.ak@th.nosp@m.inca.nosp@m.st.co.nosp@m.m

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Definition at line 46 of file SDL2/sdl_freerdp.hpp.

Member Enumeration Documentation

◆ CursorType

enum SdlContext::CursorType

Definition at line 46 of file sdl_context.hpp.

47 {
48 CURSOR_NULL,
49 CURSOR_DEFAULT,
50 CURSOR_IMAGE
51 };

Constructor & Destructor Documentation

◆ SdlContext()

SdlContext::SdlContext ( rdpContext *  context)
explicit

FreeRDP: A Remote Desktop Protocol Implementation SDL Client

Copyright 2022 Armin Novak armin.nosp@m..nov.nosp@m.ak@th.nosp@m.inca.nosp@m.st.co.nosp@m.m

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Definition at line 1761 of file SDL2/sdl_freerdp.cpp.

1762 : _context(context), log(WLog_Get(SDL_TAG)), update_complete(true), disp(this), input(this),
1763 primary(nullptr, SDL_FreeSurface), primary_format(nullptr, SDL_FreeFormat),
1764 rdp_thread_running(false)
1765{
1766 WINPR_ASSERT(context);
1767 grab_kbd_enabled = freerdp_settings_get_bool(context->settings, FreeRDP_GrabKeyboard);
1768}
WINPR_ATTR_NODISCARD FREERDP_API BOOL freerdp_settings_get_bool(const rdpSettings *settings, FreeRDP_Settings_Keys_Bool id)
Returns a boolean settings value.

References freerdp_settings_get_bool().

Here is the call graph for this function:

Member Function Documentation

◆ addDisplayWindow()

bool SdlContext::addDisplayWindow ( SDL_DisplayID  id)

Definition at line 836 of file sdl_context.cpp.

837{
838 const auto flags =
839 SDL_WINDOW_HIGH_PIXEL_DENSITY | SDL_WINDOW_FULLSCREEN | SDL_WINDOW_BORDERLESS;
840 auto title = sdl::utils::windowTitle(context()->settings);
841 auto w = SdlWindow::create(id, title, flags);
842 _windows.emplace(w.id(), std::move(w));
843 return true;
844}

◆ cleanup()

void SdlContext::cleanup ( )

Definition at line 108 of file sdl_context.cpp.

109{
110 std::unique_lock lock(_critical);
111 _windows.clear();
112 _dialog.destroy();
113 _primary.reset();
114}

◆ common()

rdpClientContext * SdlContext::common ( ) const

Definition at line 1775 of file SDL2/sdl_freerdp.cpp.

1776{
1777 return reinterpret_cast<rdpClientContext*>(_context);
1778}

◆ context()

rdpContext * SdlContext::context ( ) const

Definition at line 1770 of file SDL2/sdl_freerdp.cpp.

1771{
1772 return _context;
1773}

◆ createWindows()

bool SdlContext::createWindows ( )

Definition at line 356 of file sdl_context.cpp.

357{
358 auto settings = context()->settings;
359 const auto& title = windowTitle();
360
361 ScopeGuard guard1([&]() { _windowsCreatedEvent.set(); });
362
363 UINT32 windowCount = freerdp_settings_get_uint32(settings, FreeRDP_MonitorCount);
364
365 Sint32 originX = 0;
366 Sint32 originY = 0;
367 for (UINT32 x = 0; x < windowCount; x++)
368 {
369 auto id = monitorId(x);
370 if (id < 0)
371 return false;
372
373 auto monitor = static_cast<rdpMonitor*>(
374 freerdp_settings_get_pointer_array_writable(settings, FreeRDP_MonitorDefArray, x));
375
376 originX = std::min<Sint32>(monitor->x, originX);
377 originY = std::min<Sint32>(monitor->y, originY);
378 }
379
380 for (UINT32 x = 0; x < windowCount; x++)
381 {
382 auto id = monitorId(x);
383 if (id < 0)
384 return false;
385
386 auto monitor = static_cast<rdpMonitor*>(
387 freerdp_settings_get_pointer_array_writable(settings, FreeRDP_MonitorDefArray, x));
388
389 auto w = WINPR_ASSERTING_INT_CAST(Uint32, monitor->width);
390 auto h = WINPR_ASSERTING_INT_CAST(Uint32, monitor->height);
391 if (!(freerdp_settings_get_bool(settings, FreeRDP_UseMultimon) ||
392 freerdp_settings_get_bool(settings, FreeRDP_Fullscreen)))
393 {
394 w = freerdp_settings_get_uint32(settings, FreeRDP_DesktopWidth);
395 h = freerdp_settings_get_uint32(settings, FreeRDP_DesktopHeight);
396 }
397
398 Uint32 flags = SDL_WINDOW_HIGH_PIXEL_DENSITY;
399
400 if (freerdp_settings_get_bool(settings, FreeRDP_Fullscreen) &&
401 !freerdp_settings_get_bool(settings, FreeRDP_UseMultimon))
402 {
403 flags |= SDL_WINDOW_FULLSCREEN;
404 }
405
406 if (freerdp_settings_get_bool(settings, FreeRDP_UseMultimon))
407 {
408 flags |= SDL_WINDOW_BORDERLESS;
409 }
410
411 if (!freerdp_settings_get_bool(settings, FreeRDP_Decorations))
412 flags |= SDL_WINDOW_BORDERLESS;
413
414 auto did = WINPR_ASSERTING_INT_CAST(SDL_DisplayID, id);
415 auto window = SdlWindow::create(did, title, flags, w, h);
416
417 if (freerdp_settings_get_bool(settings, FreeRDP_UseMultimon))
418 {
419 window.setOffsetX(originX - monitor->x);
420 window.setOffsetY(originY - monitor->y);
421 }
422
423 _windows.insert({ window.id(), std::move(window) });
424 }
425
426 return true;
427}
WINPR_ATTR_NODISCARD FREERDP_API UINT32 freerdp_settings_get_uint32(const rdpSettings *settings, FreeRDP_Settings_Keys_UInt32 id)
Returns a UINT32 settings value.

◆ cursor()

rdpPointer * SdlContext::cursor ( ) const

Definition at line 1294 of file sdl_context.cpp.

1295{
1296 return _cursor;
1297}

◆ drawToWindow()

bool SdlContext::drawToWindow ( SdlWindow window,
const std::vector< SDL_Rect > &  rects = {} 
)

Definition at line 776 of file sdl_context.cpp.

777{
778 if (!isConnected())
779 return true;
780
781 auto gdi = context()->gdi;
782 WINPR_ASSERT(gdi);
783
784 auto size = window.rect();
785
786 std::unique_lock lock(_critical);
787 auto surface = _primary.get();
788 if (freerdp_settings_get_bool(context()->settings, FreeRDP_SmartSizing))
789 {
790 window.setOffsetX(0);
791 window.setOffsetY(0);
792 if (gdi->width < size.w)
793 {
794 window.setOffsetX((size.w - gdi->width) / 2);
795 }
796 if (gdi->height < size.h)
797 {
798 window.setOffsetY((size.h - gdi->height) / 2);
799 }
800
801 _localScale = { static_cast<float>(size.w) / static_cast<float>(gdi->width),
802 static_cast<float>(size.h) / static_cast<float>(gdi->height) };
803 if (!window.drawScaledRects(surface, _localScale, rects))
804 return false;
805 }
806 else
807 {
808 SDL_Point offset{ 0, 0 };
809 if (freerdp_settings_get_bool(context()->settings, FreeRDP_UseMultimon))
810 offset = { window.offsetX(), window.offsetY() };
811 if (!window.drawRects(surface, offset, rects))
812 return false;
813 }
814
815 window.updateSurface();
816 return true;
817}

◆ drawToWindows()

bool SdlContext::drawToWindows ( const std::vector< SDL_Rect > &  rects = {})

Definition at line 1190 of file sdl_context.cpp.

1191{
1192 for (auto& window : _windows)
1193 {
1194 if (!drawToWindow(window.second, rects))
1195 return FALSE;
1196 }
1197
1198 return TRUE;
1199}

◆ exitCode()

int SdlContext::exitCode ( ) const

Definition at line 826 of file sdl_context.cpp.

827{
828 return _exitCode;
829}

◆ getClipboardChannelContext()

sdlClip & SdlContext::getClipboardChannelContext ( )

Definition at line 889 of file sdl_context.cpp.

890{
891 return _clip;
892}

◆ getDialog()

SdlConnectionDialogWrapper & SdlContext::getDialog ( )

Definition at line 894 of file sdl_context.cpp.

895{
896 return _dialog;
897}

◆ getDisplayChannelContext()

sdlDispContext & SdlContext::getDisplayChannelContext ( )

Definition at line 879 of file sdl_context.cpp.

880{
881 return _disp;
882}

◆ getFirstWindow()

SdlWindow * SdlContext::getFirstWindow ( )

Definition at line 872 of file sdl_context.cpp.

873{
874 if (_windows.empty())
875 return nullptr;
876 return &_windows.begin()->second;
877}

◆ getInputChannelContext()

sdlInput & SdlContext::getInputChannelContext ( )

Definition at line 884 of file sdl_context.cpp.

885{
886 return _input;
887}

◆ getWindowForId() [1/2]

SdlWindow * SdlContext::getWindowForId ( SDL_WindowID  id)

Definition at line 864 of file sdl_context.cpp.

865{
866 auto it = _windows.find(id);
867 if (it == _windows.end())
868 return nullptr;
869 return &it->second;
870}

◆ getWindowForId() [2/2]

const SdlWindow * SdlContext::getWindowForId ( SDL_WindowID  id) const

Definition at line 856 of file sdl_context.cpp.

857{
858 auto it = _windows.find(id);
859 if (it == _windows.end())
860 return nullptr;
861 return &it->second;
862}

◆ getWLog()

wLog * SdlContext::getWLog ( )

Definition at line 899 of file sdl_context.cpp.

900{
901 return _log;
902}

◆ grabKeyboard()

bool SdlContext::grabKeyboard ( ) const

Definition at line 1414 of file sdl_context.cpp.

1415{
1416 return _grabKeyboard;
1417}

◆ grabMouse()

bool SdlContext::grabMouse ( ) const

Definition at line 1398 of file sdl_context.cpp.

1399{
1400 return _grabMouse;
1401}

◆ handleEvent()

bool SdlContext::handleEvent ( const SDL_Event &  ev)

Definition at line 1133 of file sdl_context.cpp.

1134{
1135 if ((ev.type >= SDL_EVENT_DISPLAY_FIRST) && (ev.type <= SDL_EVENT_DISPLAY_LAST))
1136 {
1137 const auto& dev = ev.display;
1138 return handleEvent(dev);
1139 }
1140 if ((ev.type >= SDL_EVENT_WINDOW_FIRST) && (ev.type <= SDL_EVENT_WINDOW_LAST))
1141 {
1142 const auto& wev = ev.window;
1143 return handleEvent(wev);
1144 }
1145 switch (ev.type)
1146 {
1147 case SDL_EVENT_FINGER_DOWN:
1148 case SDL_EVENT_FINGER_UP:
1149 case SDL_EVENT_FINGER_MOTION:
1150 {
1151 const auto& cev = ev.tfinger;
1152 return handleEvent(cev);
1153 }
1154 case SDL_EVENT_MOUSE_MOTION:
1155 {
1156 const auto& cev = ev.motion;
1157 return handleEvent(cev);
1158 }
1159 case SDL_EVENT_MOUSE_BUTTON_DOWN:
1160 case SDL_EVENT_MOUSE_BUTTON_UP:
1161 {
1162 const auto& cev = ev.button;
1163 return handleEvent(cev);
1164 }
1165 case SDL_EVENT_MOUSE_WHEEL:
1166 {
1167 const auto& cev = ev.wheel;
1168 return handleEvent(cev);
1169 }
1170 case SDL_EVENT_CLIPBOARD_UPDATE:
1171 {
1172 const auto& cev = ev.clipboard;
1173 return getClipboardChannelContext().handleEvent(cev);
1174 }
1175 case SDL_EVENT_KEY_DOWN:
1176 case SDL_EVENT_KEY_UP:
1177 {
1178 const auto& cev = ev.key;
1179 return getInputChannelContext().handleEvent(cev);
1180 }
1181 case SDL_EVENT_RENDER_TARGETS_RESET:
1182 case SDL_EVENT_RENDER_DEVICE_RESET:
1183 case SDL_EVENT_WILL_ENTER_FOREGROUND:
1184 return redraw();
1185 default:
1186 return true;
1187 }
1188}

◆ hasCursor()

bool SdlContext::hasCursor ( ) const

Definition at line 70 of file sdl_context.cpp.

71{
72 return _cursor_visible;
73}

◆ isConnected()

bool SdlContext::isConnected ( ) const

Definition at line 1266 of file sdl_context.cpp.

1267{
1268 return _connected;
1269}

◆ join()

int SdlContext::join ( )

Definition at line 96 of file sdl_context.cpp.

97{
98 /* We do not want to use freerdp_abort_connect_context here.
99 * It would change the exit code and we do not want that. */
100 HANDLE event = freerdp_abort_event(context());
101 if (!SetEvent(event))
102 return -1;
103
104 _thread.join();
105 return 0;
106}

◆ minimizeAllWindows()

bool SdlContext::minimizeAllWindows ( )

Definition at line 819 of file sdl_context.cpp.

820{
821 for (auto& w : _windows)
822 w.second.minimize();
823 return true;
824}

◆ monitorId()

int64_t SdlContext::monitorId ( uint32_t  index) const

Definition at line 1355 of file sdl_context.cpp.

1356{
1357 if (index >= _monitorIds.size())
1358 {
1359 return -1;
1360 }
1361 return _monitorIds[index];
1362}

◆ monitorIds()

const std::vector< SDL_DisplayID > & SdlContext::monitorIds ( ) const

Definition at line 1350 of file sdl_context.cpp.

1351{
1352 return _monitorIds;
1353}

◆ moveMouseTo()

bool SdlContext::moveMouseTo ( const SDL_FPoint &  pos)

Definition at line 904 of file sdl_context.cpp.

905{
906 auto window = SDL_GetMouseFocus();
907 if (!window)
908 return true;
909
910 const auto id = SDL_GetWindowID(window);
911 const auto spos = pixelToScreen(id, pos);
912 SDL_WarpMouseInWindow(window, spos.x, spos.y);
913 return true;
914}

◆ pixelFormat()

SDL_PixelFormat SdlContext::pixelFormat ( ) const

Definition at line 831 of file sdl_context.cpp.

832{
833 return _sdlPixelFormat;
834}

◆ pixelToScreen() [1/2]

SDL_FPoint SdlContext::pixelToScreen ( SDL_WindowID  id,
const SDL_FPoint &  pos 
)

Definition at line 1109 of file sdl_context.cpp.

1110{
1111 auto w = getWindowForId(id);
1112 if (!w)
1113 return {};
1114
1115 /* Ignore errors here, sometimes SDL has no renderer */
1116 auto renderer = SDL_GetRenderer(w->window());
1117 if (!renderer)
1118 return pos;
1119
1120 SDL_FPoint rpos{};
1121 if (!SDL_RenderCoordinatesToWindow(renderer, pos.x, pos.y, &rpos.x, &rpos.y))
1122 return {};
1123 return applyLocalScaling(rpos);
1124}

◆ pixelToScreen() [2/2]

SDL_FRect SdlContext::pixelToScreen ( SDL_WindowID  id,
const SDL_FRect &  pos 
)

Definition at line 1126 of file sdl_context.cpp.

1127{
1128 const auto fpos = pixelToScreen(id, SDL_FPoint{ pos.x, pos.y });
1129 const auto size = pixelToScreen(id, SDL_FPoint{ pos.w, pos.h });
1130 return { fpos.x, fpos.y, size.x, size.y };
1131}

◆ pop()

std::vector< SDL_Rect > SdlContext::pop ( )

Definition at line 1370 of file sdl_context.cpp.

1371{
1372 std::unique_lock lock(_queue_mux);
1373 if (_queue.empty())
1374 {
1375 return {};
1376 }
1377 auto val = std::move(_queue.front());
1378 _queue.pop();
1379 return val;
1380}

◆ push()

void SdlContext::push ( std::vector< SDL_Rect > &&  rects)

Definition at line 1364 of file sdl_context.cpp.

1365{
1366 std::unique_lock lock(_queue_mux);
1367 _queue.emplace(std::move(rects));
1368}

◆ redraw()

bool SdlContext::redraw ( bool  suppress = false) const

Definition at line 1251 of file sdl_context.cpp.

1252{
1253 if (!_connected)
1254 return true;
1255
1256 auto gdi = context()->gdi;
1257 WINPR_ASSERT(gdi);
1258 return gdi_send_suppress_output(gdi, suppress);
1259}

◆ removeDisplay()

bool SdlContext::removeDisplay ( SDL_DisplayID  id)

Definition at line 846 of file sdl_context.cpp.

847{
848 for (auto& w : _windows)
849 {
850 if (w.second.displayIndex() == id)
851 _windows.erase(w.first);
852 }
853 return true;
854}

◆ restoreCursor()

bool SdlContext::restoreCursor ( )

Definition at line 1299 of file sdl_context.cpp.

1300{
1301 WLog_Print(getWLog(), WLOG_DEBUG, "restore cursor: %d", _cursorType);
1302 switch (_cursorType)
1303 {
1304 case CURSOR_NULL:
1305 if (!SDL_HideCursor())
1306 {
1307 WLog_Print(getWLog(), WLOG_ERROR, "SDL_HideCursor failed");
1308 return false;
1309 }
1310
1311 setHasCursor(false);
1312 return true;
1313
1314 case CURSOR_DEFAULT:
1315 {
1316 auto def = SDL_GetDefaultCursor();
1317 if (!SDL_SetCursor(def))
1318 {
1319 WLog_Print(getWLog(), WLOG_ERROR, "SDL_SetCursor(default=%p) failed",
1320 static_cast<void*>(def));
1321 return false;
1322 }
1323 if (!SDL_ShowCursor())
1324 {
1325 WLog_Print(getWLog(), WLOG_ERROR, "SDL_ShowCursor failed");
1326 return false;
1327 }
1328 setHasCursor(true);
1329 return true;
1330 }
1331 case CURSOR_IMAGE:
1332 setHasCursor(true);
1333 return sdl_Pointer_Set_Process(this);
1334 default:
1335 WLog_Print(getWLog(), WLOG_ERROR, "Unknown cursorType %s",
1336 sdl::utils::toString(_cursorType).c_str());
1337 return false;
1338 }
1339}

◆ screenToPixel()

SDL_FPoint SdlContext::screenToPixel ( SDL_WindowID  id,
const SDL_FPoint &  pos 
)

Definition at line 1091 of file sdl_context.cpp.

1092{
1093 auto w = getWindowForId(id);
1094 if (!w)
1095 return {};
1096
1097 /* Ignore errors here, sometimes SDL has no renderer */
1098 auto renderer = SDL_GetRenderer(w->window());
1099 if (!renderer)
1100 return pos;
1101
1102 SDL_FPoint rpos{};
1103 if (!SDL_RenderCoordinatesFromWindow(renderer, pos.x, pos.y, &rpos.x, &rpos.y))
1104 return {};
1105 removeLocalScaling(rpos.x, rpos.y);
1106 return rpos;
1107}

◆ setConnected()

void SdlContext::setConnected ( bool  val)

Definition at line 1261 of file sdl_context.cpp.

1262{
1263 _connected = val;
1264}

◆ setCursor() [1/2]

bool SdlContext::setCursor ( CursorType  type)

Definition at line 1282 of file sdl_context.cpp.

1283{
1284 _cursorType = type;
1285 return restoreCursor();
1286}

◆ setCursor() [2/2]

bool SdlContext::setCursor ( rdpPointer *  cursor)

Definition at line 1288 of file sdl_context.cpp.

1289{
1290 _cursor = cursor;
1291 return setCursor(CURSOR_IMAGE);
1292}

◆ setFullscreen()

bool SdlContext::setFullscreen ( bool  enter)

Definition at line 1382 of file sdl_context.cpp.

1383{
1384 for (const auto& window : _windows)
1385 {
1386 if (!sdl_push_user_event(SDL_EVENT_USER_WINDOW_FULLSCREEN, &window.second, enter))
1387 return false;
1388 }
1389 _fullscreen = enter;
1390 return true;
1391}

◆ setGrabKeyboard()

bool SdlContext::setGrabKeyboard ( bool  enter)

Definition at line 1424 of file sdl_context.cpp.

1425{
1426 _grabKeyboard = enter;
1427 return true;
1428}

◆ setGrabMouse()

bool SdlContext::setGrabMouse ( bool  enter)

Definition at line 1408 of file sdl_context.cpp.

1409{
1410 _grabMouse = enter;
1411 return true;
1412}

◆ setHasCursor()

void SdlContext::setHasCursor ( bool  val)

Definition at line 65 of file sdl_context.cpp.

66{
67 this->_cursor_visible = val;
68}

◆ setMetadata()

void SdlContext::setMetadata ( )

Definition at line 75 of file sdl_context.cpp.

76{
77 auto wmclass = freerdp_settings_get_string(_context->settings, FreeRDP_WmClass);
78 if (!wmclass || (strlen(wmclass) == 0))
79 wmclass = SDL_CLIENT_UUID;
80
81 SDL_SetAppMetadataProperty(SDL_PROP_APP_METADATA_IDENTIFIER_STRING, wmclass);
82 SDL_SetAppMetadataProperty(SDL_PROP_APP_METADATA_NAME_STRING, SDL_CLIENT_NAME);
83 SDL_SetAppMetadataProperty(SDL_PROP_APP_METADATA_VERSION_STRING, SDL_CLIENT_VERSION);
84 SDL_SetAppMetadataProperty(SDL_PROP_APP_METADATA_CREATOR_STRING, SDL_CLIENT_VENDOR);
85 SDL_SetAppMetadataProperty(SDL_PROP_APP_METADATA_COPYRIGHT_STRING, SDL_CLIENT_COPYRIGHT);
86 SDL_SetAppMetadataProperty(SDL_PROP_APP_METADATA_URL_STRING, SDL_CLIENT_URL);
87 SDL_SetAppMetadataProperty(SDL_PROP_APP_METADATA_TYPE_STRING, SDL_CLIENT_TYPE);
88}
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.

◆ setMinimized()

bool SdlContext::setMinimized ( )

Definition at line 1393 of file sdl_context.cpp.

1394{
1395 return sdl_push_user_event(SDL_EVENT_USER_WINDOW_MINIMIZE);
1396}

◆ setMonitorIds()

void SdlContext::setMonitorIds ( const std::vector< SDL_DisplayID > &  ids)

Definition at line 1341 of file sdl_context.cpp.

1342{
1343 _monitorIds.clear();
1344 for (auto id : ids)
1345 {
1346 _monitorIds.push_back(id);
1347 }
1348}

◆ setResizeable()

bool SdlContext::setResizeable ( bool  enable)

Definition at line 1430 of file sdl_context.cpp.

1431{
1432 const auto settings = context()->settings;
1433 const bool dyn = freerdp_settings_get_bool(settings, FreeRDP_DynamicResolutionUpdate);
1434 const bool smart = freerdp_settings_get_bool(settings, FreeRDP_SmartSizing);
1435 bool use = (dyn && enable) || smart;
1436
1437 for (const auto& window : _windows)
1438 {
1439 if (!sdl_push_user_event(SDL_EVENT_USER_WINDOW_RESIZEABLE, &window.second, use))
1440 return false;
1441 }
1442 _resizeable = use;
1443
1444 return true;
1445}

◆ shallAbort()

bool SdlContext::shallAbort ( bool  ignoreDialogs = false)

Definition at line 116 of file sdl_context.cpp.

117{
118 std::unique_lock lock(_critical);
119 if (freerdp_shall_disconnect_context(context()))
120 {
121 if (ignoreDialogs)
122 return true;
123 if (_rdpThreadRunning)
124 return false;
125 return !getDialog().isRunning();
126 }
127 return false;
128}

◆ start()

int SdlContext::start ( )

Definition at line 90 of file sdl_context.cpp.

91{
92 _thread = std::thread(rdpThreadRun, this);
93 return 0;
94}

◆ toggleFullscreen()

bool SdlContext::toggleFullscreen ( )

Definition at line 1462 of file sdl_context.cpp.

1463{
1464 return setFullscreen(!fullscreen());
1465}

◆ toggleGrabKeyboard()

bool SdlContext::toggleGrabKeyboard ( )

Definition at line 1419 of file sdl_context.cpp.

1420{
1421 return setGrabKeyboard(!grabKeyboard());
1422}

◆ toggleGrabMouse()

bool SdlContext::toggleGrabMouse ( )

Definition at line 1403 of file sdl_context.cpp.

1404{
1405 return setGrabMouse(!grabMouse());
1406}

◆ toggleResizeable()

bool SdlContext::toggleResizeable ( )

Definition at line 1452 of file sdl_context.cpp.

1453{
1454 return setResizeable(!resizeable());
1455}

◆ update_fullscreen()

BOOL SdlContext::update_fullscreen ( BOOL  enter)

Definition at line 1724 of file SDL2/sdl_freerdp.cpp.

1725{
1726 std::scoped_lock lock(critical);
1727 for (const auto& window : windows)
1728 {
1729 if (!sdl_push_user_event(SDL_USEREVENT_WINDOW_FULLSCREEN, &window.second, enter))
1730 return FALSE;
1731 }
1732 fullscreen = enter;
1733 return TRUE;
1734}

◆ update_minimize()

BOOL SdlContext::update_minimize ( )

Definition at line 1736 of file SDL2/sdl_freerdp.cpp.

1737{
1738 std::scoped_lock lock(critical);
1739 return sdl_push_user_event(SDL_USEREVENT_WINDOW_MINIMIZE);
1740}

◆ update_resizeable()

BOOL SdlContext::update_resizeable ( BOOL  enable)

Definition at line 1742 of file SDL2/sdl_freerdp.cpp.

1743{
1744 std::scoped_lock lock(critical);
1745
1746 const auto settings = context()->settings;
1747 const BOOL dyn = freerdp_settings_get_bool(settings, FreeRDP_DynamicResolutionUpdate);
1748 const BOOL smart = freerdp_settings_get_bool(settings, FreeRDP_SmartSizing);
1749 BOOL use = (dyn && enable) || smart;
1750
1751 for (const auto& window : windows)
1752 {
1753 if (!sdl_push_user_event(SDL_USEREVENT_WINDOW_RESIZEABLE, &window.second, use))
1754 return FALSE;
1755 }
1756 resizeable = use;
1757
1758 return TRUE;
1759}

◆ updateWindowList()

bool SdlContext::updateWindowList ( )

Definition at line 429 of file sdl_context.cpp.

430{
431 std::vector<rdpMonitor> list;
432 list.reserve(_windows.size());
433 for (const auto& win : _windows)
434 list.push_back(win.second.monitor(_windows.size() == 1));
435
436 return freerdp_settings_set_monitor_def_array_sorted(context()->settings, list.data(),
437 list.size());
438}
WINPR_ATTR_NODISCARD FREERDP_API BOOL freerdp_settings_set_monitor_def_array_sorted(rdpSettings *settings, const rdpMonitor *monitors, size_t count)
Sort monitor array according to:

Field Documentation

◆ connection_dialog

std::unique_ptr<SDLConnectionDialog> SdlContext::connection_dialog

Definition at line 88 of file SDL2/sdl_freerdp.hpp.

◆ critical

CriticalSection SdlContext::critical

Definition at line 72 of file SDL2/sdl_freerdp.hpp.

◆ disp

sdlDispContext SdlContext::disp

Definition at line 80 of file SDL2/sdl_freerdp.hpp.

◆ exit_code

int SdlContext::exit_code = -1

Definition at line 78 of file SDL2/sdl_freerdp.hpp.

◆ fullscreen

bool SdlContext::fullscreen = false

Definition at line 64 of file SDL2/sdl_freerdp.hpp.

◆ grab_kbd

bool SdlContext::grab_kbd = false

Definition at line 67 of file SDL2/sdl_freerdp.hpp.

◆ grab_kbd_enabled

bool SdlContext::grab_kbd_enabled = true

Definition at line 68 of file SDL2/sdl_freerdp.hpp.

◆ grab_mouse

bool SdlContext::grab_mouse = false

Definition at line 66 of file SDL2/sdl_freerdp.hpp.

◆ initialize

WinPREvent SdlContext::initialize

Definition at line 74 of file SDL2/sdl_freerdp.hpp.

◆ initialized

WinPREvent SdlContext::initialized

Definition at line 75 of file SDL2/sdl_freerdp.hpp.

◆ input

sdlInput SdlContext::input

Definition at line 81 of file SDL2/sdl_freerdp.hpp.

◆ log

wLog* SdlContext::log

Definition at line 61 of file SDL2/sdl_freerdp.hpp.

◆ primary

SDLSurfacePtr SdlContext::primary

Definition at line 83 of file SDL2/sdl_freerdp.hpp.

◆ primary_format

SDLPixelFormatPtr SdlContext::primary_format

Definition at line 84 of file SDL2/sdl_freerdp.hpp.

◆ rdp_thread_running

std::atomic<bool> SdlContext::rdp_thread_running

Definition at line 90 of file SDL2/sdl_freerdp.hpp.

◆ resizeable

bool SdlContext::resizeable = false

Definition at line 65 of file SDL2/sdl_freerdp.hpp.

◆ sdl_pixel_format

Uint32 SdlContext::sdl_pixel_format = 0

Definition at line 86 of file SDL2/sdl_freerdp.hpp.

◆ thread

std::thread SdlContext::thread

Definition at line 73 of file SDL2/sdl_freerdp.hpp.

◆ update_complete

WinPREvent SdlContext::update_complete

Definition at line 76 of file SDL2/sdl_freerdp.hpp.

◆ windows

std::map<Uint32, SdlWindow> SdlContext::windows

Definition at line 70 of file SDL2/sdl_freerdp.hpp.

◆ windows_created

WinPREvent SdlContext::windows_created

Definition at line 77 of file SDL2/sdl_freerdp.hpp.


The documentation for this class was generated from the following files: