FreeRDP
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Modules Pages
shadow_input.c
1
19#include <freerdp/config.h>
20
21#include "shadow.h"
22
23static BOOL shadow_input_synchronize_event(rdpInput* input, UINT32 flags)
24{
25 rdpShadowClient* client = (rdpShadowClient*)input->context;
26 rdpShadowSubsystem* subsystem = client->server->subsystem;
27
28 if (!client->mayInteract)
29 return TRUE;
30
31 return IFCALLRESULT(TRUE, subsystem->SynchronizeEvent, subsystem, client, flags);
32}
33
34static BOOL shadow_input_keyboard_event(rdpInput* input, UINT16 flags, UINT8 code)
35{
36 rdpShadowClient* client = (rdpShadowClient*)input->context;
37 rdpShadowSubsystem* subsystem = client->server->subsystem;
38
39 if (!client->mayInteract)
40 return TRUE;
41
42 return IFCALLRESULT(TRUE, subsystem->KeyboardEvent, subsystem, client, flags, code);
43}
44
45static BOOL shadow_input_unicode_keyboard_event(rdpInput* input, UINT16 flags, UINT16 code)
46{
47 rdpShadowClient* client = (rdpShadowClient*)input->context;
48 rdpShadowSubsystem* subsystem = client->server->subsystem;
49
50 if (!client->mayInteract)
51 return TRUE;
52
53 return IFCALLRESULT(TRUE, subsystem->UnicodeKeyboardEvent, subsystem, client, flags, code);
54}
55
56static BOOL shadow_input_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
57{
58 rdpShadowClient* client = (rdpShadowClient*)input->context;
59 rdpShadowSubsystem* subsystem = client->server->subsystem;
60
61 if (client->server->shareSubRect)
62 {
63 x += client->server->subRect.left;
64 y += client->server->subRect.top;
65 }
66
67 if (!(flags & PTR_FLAGS_WHEEL))
68 {
69 client->pointerX = x;
70 client->pointerY = y;
71
72 if ((client->pointerX == subsystem->pointerX) && (client->pointerY == subsystem->pointerY))
73 {
74 flags &= ~PTR_FLAGS_MOVE;
75
76 if (!(flags & (PTR_FLAGS_BUTTON1 | PTR_FLAGS_BUTTON2 | PTR_FLAGS_BUTTON3)))
77 return TRUE;
78 }
79 }
80
81 if (!client->mayInteract)
82 return TRUE;
83
84 return IFCALLRESULT(TRUE, subsystem->MouseEvent, subsystem, client, flags, x, y);
85}
86
87static BOOL shadow_input_extended_mouse_event(rdpInput* input, UINT16 flags, UINT16 x, UINT16 y)
88{
89 rdpShadowClient* client = (rdpShadowClient*)input->context;
90 rdpShadowSubsystem* subsystem = client->server->subsystem;
91
92 if (client->server->shareSubRect)
93 {
94 x += client->server->subRect.left;
95 y += client->server->subRect.top;
96 }
97
98 client->pointerX = x;
99 client->pointerY = y;
100
101 if (!client->mayInteract)
102 return TRUE;
103
104 return IFCALLRESULT(TRUE, subsystem->ExtendedMouseEvent, subsystem, client, flags, x, y);
105}
106
107void shadow_input_register_callbacks(rdpInput* input)
108{
109 input->SynchronizeEvent = shadow_input_synchronize_event;
110 input->KeyboardEvent = shadow_input_keyboard_event;
111 input->UnicodeKeyboardEvent = shadow_input_unicode_keyboard_event;
112 input->MouseEvent = shadow_input_mouse_event;
113 input->ExtendedMouseEvent = shadow_input_extended_mouse_event;
114}