Skip to content

Commit 8dc0267

Browse files
committed
support NULL cursors and large mono cursors
1 parent d901c5b commit 8dc0267

File tree

1 file changed

+72
-77
lines changed

1 file changed

+72
-77
lines changed

module/rdpCursor.c

+72-77
Original file line numberDiff line numberDiff line change
@@ -258,14 +258,6 @@ rdpSpriteSetCursorCon(rdpClientCon *clientCon,
258258
LLOGLN(10, ("rdpSpriteSetCursorCon: suppress_output set"));
259259
return;
260260
}
261-
if (pCurs == NULL)
262-
{
263-
return;
264-
}
265-
if (pCurs->bits == NULL)
266-
{
267-
return;
268-
}
269261
if (clientCon->client_info.size == 0)
270262
{
271263
return;
@@ -286,85 +278,98 @@ rdpSpriteSetCursorCon(rdpClientCon *clientCon,
286278
#else
287279
can_do_large = 0;
288280
#endif
289-
if (can_do_new || can_do_large)
281+
if ((pCurs == NULL) || (pCurs->bits == NULL))
290282
{
291-
if (pCurs->bits->argb != NULL)
292-
{
293-
sending_bpp = 32;
294-
}
283+
/* None cursor */
284+
sending_width = 32;
285+
sending_height = 32;
286+
xhot = 0;
287+
yhot = 0;
288+
memset(cur_data, 0, 96 * 96 * 4);
289+
memset(cur_mask, 0xFF, 96 * 96 / 8);
295290
}
296-
server_width = pCurs->bits->width;
297-
server_height = pCurs->bits->height;
298-
if ((server_width > 32) || (server_height > 32))
291+
else
299292
{
300-
if (sending_bpp == 32)
293+
if (can_do_new || can_do_large)
294+
{
295+
if (pCurs->bits->argb != NULL)
296+
{
297+
sending_bpp = 32;
298+
}
299+
}
300+
server_width = pCurs->bits->width;
301+
server_height = pCurs->bits->height;
302+
if ((server_width > 32) || (server_height > 32))
301303
{
302304
if (can_do_large)
303305
{
304306
client_max_width = 96;
305307
client_max_height = 96;
306308
}
307309
}
308-
}
309-
sending_width = server_width > 32 ? client_max_width : 32;
310-
sending_height = server_height > 32 ? client_max_height : 32;
311-
LLOGLN(10, ("rdpSpriteSetCursorCon: sending_width %d sending_height %d "
312-
"server_width %d server_height %d sending_bpp %d",
313-
sending_width, sending_height, server_width, server_height,
314-
sending_bpp));
315-
if (sending_bpp == 32)
316-
{
317-
paddedRowBytes = PixmapBytePad(server_width, 32);
318-
xhot = pCurs->bits->xhot;
319-
yhot = pCurs->bits->yhot;
320-
data = (uint8_t *)(pCurs->bits->argb);
321-
memset(cur_data, 0, 96 * 96 * 4);
322-
memset(cur_mask, 0, 96 * 96 / 8);
323-
for (jndex = 0; jndex < sending_height; jndex++)
310+
sending_width = server_width > 32 ? client_max_width : 32;
311+
sending_height = server_height > 32 ? client_max_height : 32;
312+
LLOGLN(10, ("rdpSpriteSetCursorCon: sending_width %d "
313+
"sending_height %d server_width %d server_height %d "
314+
"sending_bpp %d", sending_width, sending_height,
315+
server_width, server_height, sending_bpp));
316+
if (sending_bpp == 32)
324317
{
325-
for (index = 0; index < sending_width; index++)
318+
paddedRowBytes = PixmapBytePad(server_width, 32);
319+
xhot = pCurs->bits->xhot;
320+
yhot = pCurs->bits->yhot;
321+
data = (uint8_t *)(pCurs->bits->argb);
322+
memset(cur_data, 0, 96 * 96 * 4);
323+
memset(cur_mask, 0, 96 * 96 / 8);
324+
for (jndex = 0; jndex < sending_height; jndex++)
326325
{
327-
pixel = get_pixel_safe(data, index, jndex, paddedRowBytes / 4,
328-
server_height, 32);
329-
set_pixel_safe(cur_data, index, (sending_height - 1) - jndex,
330-
sending_width, sending_height, 32, pixel);
326+
for (index = 0; index < sending_width; index++)
327+
{
328+
pixel = get_pixel_safe(data, index, jndex,
329+
paddedRowBytes / 4,
330+
server_height, 32);
331+
set_pixel_safe(cur_data, index,
332+
(sending_height - 1) - jndex,
333+
sending_width, sending_height, 32, pixel);
334+
}
331335
}
332336
}
333-
}
334-
else
335-
{
336-
paddedRowBytes = PixmapBytePad(server_width, 1);
337-
xhot = pCurs->bits->xhot;
338-
yhot = pCurs->bits->yhot;
339-
data = (uint8_t *)(pCurs->bits->source);
340-
mask = (uint8_t *)(pCurs->bits->mask);
341-
fgcolor = (((pCurs->foreRed >> 8) & 0xff) << 16) |
342-
(((pCurs->foreGreen >> 8) & 0xff) << 8) |
343-
((pCurs->foreBlue >> 8) & 0xff);
344-
bgcolor = (((pCurs->backRed >> 8) & 0xff) << 16) |
345-
(((pCurs->backGreen >> 8) & 0xff) << 8) |
346-
((pCurs->backBlue >> 8) & 0xff);
347-
memset(cur_data, 0, 96 * 96 * 4);
348-
memset(cur_mask, 0, 96 * 96 / 8);
349-
for (jndex = 0; jndex < sending_height; jndex++)
337+
else
350338
{
351-
for (index = 0; index < sending_width; index++)
339+
paddedRowBytes = PixmapBytePad(server_width, 1);
340+
xhot = pCurs->bits->xhot;
341+
yhot = pCurs->bits->yhot;
342+
data = (uint8_t *)(pCurs->bits->source);
343+
mask = (uint8_t *)(pCurs->bits->mask);
344+
fgcolor = (((pCurs->foreRed >> 8) & 0xff) << 16) |
345+
(((pCurs->foreGreen >> 8) & 0xff) << 8) |
346+
((pCurs->foreBlue >> 8) & 0xff);
347+
bgcolor = (((pCurs->backRed >> 8) & 0xff) << 16) |
348+
(((pCurs->backGreen >> 8) & 0xff) << 8) |
349+
((pCurs->backBlue >> 8) & 0xff);
350+
memset(cur_data, 0, 96 * 96 * 4);
351+
memset(cur_mask, 0, 96 * 96 / 8);
352+
for (jndex = 0; jndex < sending_height; jndex++)
352353
{
353-
pixel = get_pixel_safe(mask, index, jndex,
354-
paddedRowBytes * 8,
355-
server_height, 1);
356-
set_pixel_safe(cur_mask, index,
357-
(sending_height - 1) - jndex,
358-
sending_width, sending_height, 1, !pixel);
359-
if (pixel != 0)
354+
for (index = 0; index < sending_width; index++)
360355
{
361-
pixel = get_pixel_safe(data, index, jndex,
356+
pixel = get_pixel_safe(mask, index, jndex,
362357
paddedRowBytes * 8,
363358
server_height, 1);
364-
pixel = pixel ? fgcolor : bgcolor;
365-
set_pixel_safe(cur_data, index,
359+
set_pixel_safe(cur_mask, index,
366360
(sending_height - 1) - jndex,
367-
sending_width, sending_height, 24, pixel);
361+
sending_width, sending_height, 1, !pixel);
362+
if (pixel != 0)
363+
{
364+
pixel = get_pixel_safe(data, index, jndex,
365+
paddedRowBytes * 8,
366+
server_height, 1);
367+
pixel = pixel ? fgcolor : bgcolor;
368+
set_pixel_safe(cur_data, index,
369+
(sending_height - 1) - jndex,
370+
sending_width, sending_height,
371+
24, pixel);
372+
}
368373
}
369374
}
370375
}
@@ -394,16 +399,6 @@ rdpSpriteSetCursor(DeviceIntPtr pDev, ScreenPtr pScr, CursorPtr pCurs,
394399
rdpClientCon *clientCon;
395400

396401
LLOGLN(10, ("rdpSpriteSetCursor:"));
397-
if (pCurs == 0)
398-
{
399-
return;
400-
}
401-
402-
if (pCurs->bits == 0)
403-
{
404-
return;
405-
}
406-
407402
dev = rdpGetDevFromScreen(pScr);
408403
clientCon = dev->clientConHead;
409404
while (clientCon != NULL)

0 commit comments

Comments
 (0)