20#include <freerdp/config.h>
22#include <winpr/assert.h>
24#include <freerdp/client/rail.h>
25#include <freerdp/client/cliprdr.h>
26#include <freerdp/client/disp.h>
27#include <freerdp/client/rdpgfx.h>
28#include <freerdp/channels/rdpgfx.h>
29#include <freerdp/channels/rdpewa.h>
31#include "sdl_channels.hpp"
32#include "sdl_context.hpp"
33#include "sdl_disp.hpp"
35void sdl_OnChannelConnectedEventHandler(
void* context,
const ChannelConnectedEventArgs* e)
37 auto sdl = get_context(context);
42 if (strcmp(e->name, RAIL_SVC_CHANNEL_NAME) == 0)
44 auto rail =
reinterpret_cast<RailClientContext*
>(e->pInterface);
47 if (!
sdl->getRailChannelContext().init(rail))
48 WLog_Print(
sdl->getWLog(), WLOG_WARN,
"Failed to initialize RAIL channel");
50 else if (strcmp(e->name, CLIPRDR_SVC_CHANNEL_NAME) == 0)
52 auto clip =
reinterpret_cast<CliprdrClientContext*
>(e->pInterface);
55 if (!
sdl->getClipboardChannelContext().init(clip))
56 WLog_Print(
sdl->getWLog(), WLOG_WARN,
"Failed to initialize clipboard channel");
58 else if (strcmp(e->name, DISP_DVC_CHANNEL_NAME) == 0)
60 auto disp =
reinterpret_cast<DispClientContext*
>(e->pInterface);
63 if (!
sdl->getDisplayChannelContext().init(disp))
64 WLog_Print(
sdl->getWLog(), WLOG_WARN,
"Failed to initialize display channel");
66 else if (strcmp(e->name, RDPGFX_DVC_CHANNEL_NAME) == 0)
70 freerdp_client_OnChannelConnectedEventHandler(context, e);
71 auto gfx =
reinterpret_cast<RdpgfxClientContext*
>(e->pInterface);
72 auto ctx =
static_cast<rdpContext*
>(context);
74 gfx->UpdateWindowFromSurface = SdlRail::UpdateWindowFromSurface;
77 freerdp_client_OnChannelConnectedEventHandler(context, e);
80void sdl_OnChannelDisconnectedEventHandler(
void* context,
const ChannelDisconnectedEventArgs* e)
82 auto sdl = get_context(context);
88 if (strcmp(e->name, RAIL_SVC_CHANNEL_NAME) == 0)
90 auto rail =
reinterpret_cast<RailClientContext*
>(e->pInterface);
92 sdl->getRailChannelContext().uninit(rail);
93 rail->custom =
nullptr;
95 else if (strcmp(e->name, CLIPRDR_SVC_CHANNEL_NAME) == 0)
97 auto clip =
reinterpret_cast<CliprdrClientContext*
>(e->pInterface);
100 if (!
sdl->getClipboardChannelContext().uninit(clip))
101 WLog_Print(
sdl->getWLog(), WLOG_WARN,
"Failed to uninitialize clipboard channel");
102 clip->custom =
nullptr;
104 else if (strcmp(e->name, DISP_DVC_CHANNEL_NAME) == 0)
106 auto disp =
reinterpret_cast<DispClientContext*
>(e->pInterface);
109 if (!
sdl->getDisplayChannelContext().uninit(disp))
110 WLog_Print(
sdl->getWLog(), WLOG_WARN,
"Failed to uninitialize display channel");
111 disp->custom =
nullptr;
114 freerdp_client_OnChannelDisconnectedEventHandler(context, e);
117void sdl_OnUserNotificationEventHandler(
void* context,
const UserNotificationEventArgs* e)
119 WINPR_UNUSED(context);
121 WINPR_ASSERT(e->e.Sender);
123 if (strcmp(e->e.Sender, RDPEWA_CHANNEL_NAME) != 0)
126 if (e->cancelPreviousNotification)
133 uint32_t timeoutMS = 0;
136 auto ud =
new struct userdata;
138 ud->message = e->message;
140 ud->sender = e->e.Sender;
141 ud->timeoutMS = e->timeoutMS;
146 auto ed =
static_cast<struct userdata*
>(userdata);
148 auto parent = SDL_GetMouseFocus();
150 parent = SDL_GetKeyboardFocus();
151 SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, ed->sender.c_str(),
152 ed->message.c_str(), parent);
WINPR_ATTR_NODISCARD FREERDP_API BOOL freerdp_settings_get_bool(const rdpSettings *settings, FreeRDP_Settings_Keys_Bool id)
Returns a boolean settings value.