Rabbit Remote Control 0.0.30
Loading...
Searching...
No Matches
CursorFreeRDP.cpp
1// Author: Kang Lin <kl222@126.com>
3#include <QImage>
4#include "ConnectFreeRDP.h"
5#include <freerdp/gdi/gdi.h>
6
7CCursorFreeRDP::CCursorFreeRDP(CConnectFreeRDP *parent) : QObject(parent),
8 m_pConnect(parent),
9 m_Logger("FreeRDP.Cursor")
10{}
11
12int CCursorFreeRDP::RegisterPointer(rdpGraphics *graphics)
13{
14 rdpPointer* pointer = NULL;
15 if (!(pointer = (rdpPointer*)calloc(1, sizeof(rdpPointer))))
16 return -1;
17
18 pointer->size = sizeof(_Pointer);
19 pointer->New = cb_Pointer_New;
20 pointer->Free = cb_Pointer_Free;
21 pointer->Set = cb_Pointer_Set;
22 pointer->SetNull = cb_Pointer_SetNull;
23 pointer->SetDefault = cb_Pointer_SetDefault;
24 pointer->SetPosition = cb_Pointer_SetPosition;
25 graphics_register_pointer(graphics, pointer);
26 free(pointer);
27
28 return 0;
29}
30
31BOOL CCursorFreeRDP::cb_Pointer_New(rdpContext *context, rdpPointer *pointer)
32{
33 //qDebug(m_Logger) << "cb_Pointer_New";
34 CConnectFreeRDP* pThis = ((CConnectFreeRDP::ClientContext*)context)->pThis;
35 return pThis->m_Cursor.onNew(context, pointer);
36}
37
38void CCursorFreeRDP::cb_Pointer_Free(rdpContext* context, rdpPointer* pointer)
39{
40 //qDebug(m_Logger) << "cb_Pointer_Free";
41 CConnectFreeRDP* pThis = ((CConnectFreeRDP::ClientContext*)context)->pThis;
42 pThis->m_Cursor.onFree(context, pointer);
43}
44
45BOOL CCursorFreeRDP::cb_Pointer_Set(rdpContext *context,
46 #if FreeRDP_VERSION_MAJOR >= 3
47 rdpPointer* pointer
48 #else
49 const rdpPointer *pointer
50 #endif
51 )
52{
53 //qDebug(m_Logger) << "cb_Pointer_Set";
54 CConnectFreeRDP* pThis = ((CConnectFreeRDP::ClientContext*)context)->pThis;
55 return pThis->m_Cursor.onSet(context, pointer);
56}
57
58BOOL CCursorFreeRDP::cb_Pointer_SetNull(rdpContext *context)
59{
60 //qDebug(m_Logger) << "cb_Pointer_SetNull";
61 CConnectFreeRDP* pThis = ((CConnectFreeRDP::ClientContext*)context)->pThis;
62 return pThis->m_Cursor.onSetNull(context);
63}
64
65BOOL CCursorFreeRDP::cb_Pointer_SetDefault(rdpContext *context)
66{
67 //qDebug(m_Logger) << "cb_Pointer_SetDefault";
68 CConnectFreeRDP* pThis = ((CConnectFreeRDP::ClientContext*)context)->pThis;
69 return pThis->m_Cursor.onSetDefault(context);
70 return TRUE;
71}
72
73BOOL CCursorFreeRDP::cb_Pointer_SetPosition(rdpContext *context, UINT32 x, UINT32 y)
74{
75 //qDebug(m_Logger) << "cb_Pointer_SetPosition";
76 CConnectFreeRDP* pThis = ((CConnectFreeRDP::ClientContext*)context)->pThis;
77 return pThis->m_Cursor.onSetPosition(context, x, y);
78 return TRUE;
79}
80
81BOOL CCursorFreeRDP::onNew(rdpContext *context, rdpPointer *pointer)
82{
83 return TRUE;
84 BOOL bRet = TRUE;
85 QImage cursor(pointer->width, pointer->height, QImage::Format_ARGB32);
93 bRet = freerdp_image_copy_from_pointer_data(cursor.bits(),
94 CConnectFreeRDP::GetImageFormat(cursor.format()),
95 0,
96 0, 0, cursor.width(), cursor.height(),
97 pointer->xorMaskData,
98 pointer->lengthXorMask,
99 pointer->andMaskData,
100 pointer->lengthAndMask,
101 pointer->xorBpp,
102 &context->gdi->palette);
103 if(bRet)
104 {
105 m_Cursor = cursor;
106 emit m_pConnect->sigUpdateCursor(QCursor(QPixmap::fromImage(m_Cursor),
107 pointer->xPos, pointer->yPos));
108 }
109 return bRet;
110}
111
112void CCursorFreeRDP::onFree(rdpContext* context, rdpPointer* pointer)
113{}
114
115BOOL CCursorFreeRDP::onSet(rdpContext *context, const rdpPointer *pointer)
116{
117 BOOL bRet = TRUE;
118 QImage cursor(pointer->width, pointer->height, QImage::Format_ARGB32);
126 bRet = freerdp_image_copy_from_pointer_data(cursor.bits(),
127 CConnectFreeRDP::GetImageFormat(cursor.format()),
128 0,
129 0, 0, cursor.width(), cursor.height(),
130 pointer->xorMaskData,
131 pointer->lengthXorMask,
132 pointer->andMaskData,
133 pointer->lengthAndMask,
134 pointer->xorBpp,
135 &context->gdi->palette);
136 if(bRet)
137 {
138 m_Cursor = cursor;
139 emit m_pConnect->sigUpdateCursor(QCursor(QPixmap::fromImage(m_Cursor),
140 pointer->xPos, pointer->yPos));
141 }
142 return bRet;
143}
144
145BOOL CCursorFreeRDP::onSetDefault(rdpContext *context)
146{
147 m_Cursor = QImage();
148 emit m_pConnect->sigUpdateCursor(QCursor());
149 return TRUE;
150}
151
152BOOL CCursorFreeRDP::onSetNull(rdpContext *context)
153{
154 m_Cursor = QImage();
155 emit m_pConnect->sigUpdateCursor(QCursor(Qt::BlankCursor));
156 return TRUE;
157}
158
159BOOL CCursorFreeRDP::onSetPosition(rdpContext *context, UINT32 x, UINT32 y)
160{
161 emit m_pConnect->sigUpdateCursor(QCursor(QPixmap::fromImage(m_Cursor),
162 x, y));
163 return TRUE;
164}
BOOL onNew(rdpContext *context, rdpPointer *pointer)
BOOL onSet(rdpContext *context, const rdpPointer *pointer)