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 forceOriginalDisplay=false)
 
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 837 of file sdl_context.cpp.

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

◆ 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 357 of file sdl_context.cpp.

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

1296{
1297 return _cursor;
1298}

◆ drawToWindow()

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

Definition at line 777 of file sdl_context.cpp.

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

◆ drawToWindows()

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

Definition at line 1191 of file sdl_context.cpp.

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

◆ exitCode()

int SdlContext::exitCode ( ) const

Definition at line 827 of file sdl_context.cpp.

828{
829 return _exitCode;
830}

◆ getClipboardChannelContext()

sdlClip & SdlContext::getClipboardChannelContext ( )

Definition at line 890 of file sdl_context.cpp.

891{
892 return _clip;
893}

◆ getDialog()

SdlConnectionDialogWrapper & SdlContext::getDialog ( )

Definition at line 895 of file sdl_context.cpp.

896{
897 return _dialog;
898}

◆ getDisplayChannelContext()

sdlDispContext & SdlContext::getDisplayChannelContext ( )

Definition at line 880 of file sdl_context.cpp.

881{
882 return _disp;
883}

◆ getFirstWindow()

SdlWindow * SdlContext::getFirstWindow ( )

Definition at line 873 of file sdl_context.cpp.

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

◆ getInputChannelContext()

sdlInput & SdlContext::getInputChannelContext ( )

Definition at line 885 of file sdl_context.cpp.

886{
887 return _input;
888}

◆ getWindowForId() [1/2]

SdlWindow * SdlContext::getWindowForId ( SDL_WindowID  id)

Definition at line 865 of file sdl_context.cpp.

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

◆ getWindowForId() [2/2]

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

Definition at line 857 of file sdl_context.cpp.

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

◆ getWLog()

wLog * SdlContext::getWLog ( )

Definition at line 900 of file sdl_context.cpp.

901{
902 return _log;
903}

◆ grabKeyboard()

bool SdlContext::grabKeyboard ( ) const

Definition at line 1416 of file sdl_context.cpp.

1417{
1418 return _grabKeyboard;
1419}

◆ grabMouse()

bool SdlContext::grabMouse ( ) const

Definition at line 1400 of file sdl_context.cpp.

1401{
1402 return _grabMouse;
1403}

◆ handleEvent()

bool SdlContext::handleEvent ( const SDL_Event &  ev)

Definition at line 1134 of file sdl_context.cpp.

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

◆ 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 1267 of file sdl_context.cpp.

1268{
1269 return _connected;
1270}

◆ 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 820 of file sdl_context.cpp.

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

◆ monitorId()

int64_t SdlContext::monitorId ( uint32_t  index) const

Definition at line 1356 of file sdl_context.cpp.

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

◆ monitorIds()

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

Definition at line 1351 of file sdl_context.cpp.

1352{
1353 return _monitorIds;
1354}

◆ moveMouseTo()

bool SdlContext::moveMouseTo ( const SDL_FPoint &  pos)

Definition at line 905 of file sdl_context.cpp.

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

◆ pixelFormat()

SDL_PixelFormat SdlContext::pixelFormat ( ) const

Definition at line 832 of file sdl_context.cpp.

833{
834 return _sdlPixelFormat;
835}

◆ pixelToScreen() [1/2]

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

Definition at line 1110 of file sdl_context.cpp.

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

◆ pixelToScreen() [2/2]

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

Definition at line 1127 of file sdl_context.cpp.

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

◆ pop()

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

Definition at line 1371 of file sdl_context.cpp.

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

◆ push()

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

Definition at line 1365 of file sdl_context.cpp.

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

◆ redraw()

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

Definition at line 1252 of file sdl_context.cpp.

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

◆ removeDisplay()

bool SdlContext::removeDisplay ( SDL_DisplayID  id)

Definition at line 847 of file sdl_context.cpp.

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

◆ restoreCursor()

bool SdlContext::restoreCursor ( )

Definition at line 1300 of file sdl_context.cpp.

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

◆ screenToPixel()

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

Definition at line 1092 of file sdl_context.cpp.

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

◆ setConnected()

void SdlContext::setConnected ( bool  val)

Definition at line 1262 of file sdl_context.cpp.

1263{
1264 _connected = val;
1265}

◆ setCursor() [1/2]

bool SdlContext::setCursor ( CursorType  type)

Definition at line 1283 of file sdl_context.cpp.

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

◆ setCursor() [2/2]

bool SdlContext::setCursor ( rdpPointer *  cursor)

Definition at line 1289 of file sdl_context.cpp.

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

◆ setFullscreen()

bool SdlContext::setFullscreen ( bool  enter,
bool  forceOriginalDisplay = false 
)

Definition at line 1383 of file sdl_context.cpp.

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

◆ setGrabKeyboard()

bool SdlContext::setGrabKeyboard ( bool  enter)

Definition at line 1426 of file sdl_context.cpp.

1427{
1428 _grabKeyboard = enter;
1429 return true;
1430}

◆ setGrabMouse()

bool SdlContext::setGrabMouse ( bool  enter)

Definition at line 1410 of file sdl_context.cpp.

1411{
1412 _grabMouse = enter;
1413 return true;
1414}

◆ 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 1395 of file sdl_context.cpp.

1396{
1397 return sdl_push_user_event(SDL_EVENT_USER_WINDOW_MINIMIZE);
1398}

◆ setMonitorIds()

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

Definition at line 1342 of file sdl_context.cpp.

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

◆ setResizeable()

bool SdlContext::setResizeable ( bool  enable)

Definition at line 1432 of file sdl_context.cpp.

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

◆ 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 1464 of file sdl_context.cpp.

1465{
1466 return setFullscreen(!fullscreen());
1467}

◆ toggleGrabKeyboard()

bool SdlContext::toggleGrabKeyboard ( )

Definition at line 1421 of file sdl_context.cpp.

1422{
1423 return setGrabKeyboard(!grabKeyboard());
1424}

◆ toggleGrabMouse()

bool SdlContext::toggleGrabMouse ( )

Definition at line 1405 of file sdl_context.cpp.

1406{
1407 return setGrabMouse(!grabMouse());
1408}

◆ toggleResizeable()

bool SdlContext::toggleResizeable ( )

Definition at line 1454 of file sdl_context.cpp.

1455{
1456 return setResizeable(!resizeable());
1457}

◆ 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 430 of file sdl_context.cpp.

431{
432 std::vector<rdpMonitor> list;
433 list.reserve(_windows.size());
434 for (const auto& win : _windows)
435 list.push_back(win.second.monitor(_windows.size() == 1));
436
437 return freerdp_settings_set_monitor_def_array_sorted(context()->settings, list.data(),
438 list.size());
439}
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: