FreeRDP
Loading...
Searching...
No Matches
SDL3/sdl_channels.cpp
1
20#include <freerdp/config.h>
21
22#include <winpr/assert.h>
23
24#include <freerdp/client/rail.h>
25#include <freerdp/client/cliprdr.h>
26#include <freerdp/client/disp.h>
27#include <freerdp/channels/rdpewa.h>
28
29#include "sdl_channels.hpp"
30#include "sdl_context.hpp"
31#include "sdl_disp.hpp"
32
33void sdl_OnChannelConnectedEventHandler(void* context, const ChannelConnectedEventArgs* e)
34{
35 auto sdl = get_context(context);
36
37 WINPR_ASSERT(sdl);
38 WINPR_ASSERT(e);
39
40 if (strcmp(e->name, RAIL_SVC_CHANNEL_NAME) == 0)
41 {
42 }
43 else if (strcmp(e->name, CLIPRDR_SVC_CHANNEL_NAME) == 0)
44 {
45 auto clip = reinterpret_cast<CliprdrClientContext*>(e->pInterface);
46 WINPR_ASSERT(clip);
47
48 if (!sdl->getClipboardChannelContext().init(clip))
49 WLog_Print(sdl->getWLog(), WLOG_WARN, "Failed to initialize clipboard channel");
50 }
51 else if (strcmp(e->name, DISP_DVC_CHANNEL_NAME) == 0)
52 {
53 auto disp = reinterpret_cast<DispClientContext*>(e->pInterface);
54 WINPR_ASSERT(disp);
55
56 if (!sdl->getDisplayChannelContext().init(disp))
57 WLog_Print(sdl->getWLog(), WLOG_WARN, "Failed to initialize display channel");
58 }
59 else
60 freerdp_client_OnChannelConnectedEventHandler(context, e);
61}
62
63void sdl_OnChannelDisconnectedEventHandler(void* context, const ChannelDisconnectedEventArgs* e)
64{
65 auto sdl = get_context(context);
66
67 WINPR_ASSERT(sdl);
68 WINPR_ASSERT(e);
69
70 // TODO: Set resizeable depending on disp channel and /dynamic-resolution
71 if (strcmp(e->name, RAIL_SVC_CHANNEL_NAME) == 0)
72 {
73 }
74 else if (strcmp(e->name, CLIPRDR_SVC_CHANNEL_NAME) == 0)
75 {
76 auto clip = reinterpret_cast<CliprdrClientContext*>(e->pInterface);
77 WINPR_ASSERT(clip);
78
79 if (!sdl->getClipboardChannelContext().uninit(clip))
80 WLog_Print(sdl->getWLog(), WLOG_WARN, "Failed to uninitialize clipboard channel");
81 clip->custom = nullptr;
82 }
83 else if (strcmp(e->name, DISP_DVC_CHANNEL_NAME) == 0)
84 {
85 auto disp = reinterpret_cast<DispClientContext*>(e->pInterface);
86 WINPR_ASSERT(disp);
87
88 if (!sdl->getDisplayChannelContext().uninit(disp))
89 WLog_Print(sdl->getWLog(), WLOG_WARN, "Failed to uninitialize display channel");
90 disp->custom = nullptr;
91 }
92 else
93 freerdp_client_OnChannelDisconnectedEventHandler(context, e);
94}
95
96void sdl_OnUserNotificationEventHandler(void* context, const UserNotificationEventArgs* e)
97{
98 WINPR_UNUSED(context);
99 WINPR_ASSERT(e);
100 WINPR_ASSERT(e->e.Sender);
101
102 if (strcmp(e->e.Sender, RDPEWA_CHANNEL_NAME) != 0)
103 return;
104
105 if (e->cancelPreviousNotification)
106 return;
107
108 WINPR_ASSERT(e->message);
109 auto parent = SDL_GetMouseFocus();
110 if (!parent)
111 parent = SDL_GetKeyboardFocus();
112 SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_INFORMATION, e->e.Sender, e->message, parent);
113}