From 68e7c74779641a2e56c07fbb9c32326c36081987 Mon Sep 17 00:00:00 2001 From: jsorg71 Date: Tue, 14 Sep 2004 04:29:07 +0000 Subject: [PATCH] use standard cur files for cursors --- xrdp/cursor0.cur | Bin 3216 -> 326 bytes xrdp/cursor1.cur | Bin 3216 -> 326 bytes xrdp/xrdp_wm.c | 113 +++++++++++++++++++++++++++++++++++++---------- 3 files changed, 89 insertions(+), 24 deletions(-) diff --git a/xrdp/cursor0.cur b/xrdp/cursor0.cur index c7801f6b6c771e80ed63dd4eee913cf9eed2daec..a8ae3a1b59c51742fe69d44b77555b86153eeb3c 100644 GIT binary patch literal 326 zcmb8pArits429vB!VD5rZC4_DgWY4{c7X~c!wIn50?REp2BOpOx0N-JoiCF-la(r& zLeNyLNj1|R0SU$%t4w{_+Upau~c>|?gV23s_U$oK*%c74_W literal 3216 zcmeH@K@Nj33)r-JfT0}X?(kfO0d*u6=7^yD7o3v60?aX(Uu}LVcC_H31kA9 zKqin0NCNA>I;8}|I&Jx+fzP6Oy8+6Yb+)V#?OPDb z*970W?O3xB|3o|eMhO0y8d&%KRD73AHu2fWNx^o4;{hP|gOe|}-1+`6 a^j$1NW;i_v6&4O1G)h>c*y_%{{txgQ~&=zDHx^?WCk7p0BRV4$N&HU literal 3216 zcmeHGK?;B{4BHR%3I4>V`BnXe2ccFv!`SSc_29u4idmP05?LQY=(&g3{PFSxJOM2M zN{Ttji8RThIU9nnVGs-e3qxB@aAgMK$#MX*l_q3o@z)41=k8w*(DV5)A3Q67`ZDde zVkkdXROO`Itz>4-Af$5)4FKDUVRkeay2KOsPXg(Cxx`CHG{;^?qHU`8!8!Sd_NI0c C>>)$| diff --git a/xrdp/xrdp_wm.c b/xrdp/xrdp_wm.c index 2bff2f1b..4488974b 100644 --- a/xrdp/xrdp_wm.c +++ b/xrdp/xrdp_wm.c @@ -271,44 +271,111 @@ int xrdp_set_cursor(struct xrdp_wm* self, int cache_idx) return 0; } +//****************************************************************************** +int xrdp_wm_get_pixel(char* data, int x, int y, int width, int bpp) +{ + int start; + int shift; + + if (bpp == 1) + { + width = (width + 7) / 8; + start = (y * width) + x / 8; + shift = x % 8; + return (data[start] & (0x80 >> shift)) != 0; + } + else if (bpp == 4) + { + width = (width + 1) / 2; + start = y * width + x / 2; + shift = x % 2; + if (shift == 0) + return (data[start] & 0xf0) >> 4; + else + return data[start] & 0x0f; + } + return 0; +} + + /*****************************************************************************/ /* send a cursor from a file */ int xrdp_send_cursor(struct xrdp_wm* self, char* file_name, int cache_idx) { - int v; int fd; int w; int h; + int x; + int y; + int bpp; + int i; + int j; + int rv; + int pixel; + int palette[16]; struct stream* s; + rv = 1; s = (struct stream*)g_malloc(sizeof(struct stream), 1); init_stream(s, 8001); fd = g_file_open(file_name); g_file_read(fd, s->data, 8000); g_file_close(fd); - xrdp_rdp_init_data(self->rdp_layer, 8000); - out_uint16_le(self->out_s, RDP_POINTER_COLOR); - out_uint16_le(self->out_s, 0); /* pad */ - out_uint16_le(self->out_s, cache_idx); /* cache_idx */ - in_uint32_le(s, v); - out_uint16_le(self->out_s, v); /* x */ - in_uint32_le(s, v); - out_uint16_le(self->out_s, v); /* y */ - in_uint32_le(s, w); - out_uint16_le(self->out_s, w); /* width */ - in_uint32_le(s, h); - out_uint16_le(self->out_s, h); /* height */ - v = (w * h) / 8; - out_uint16_le(self->out_s, v); /* mask len */ - v = (w * h) * 3; - out_uint16_le(self->out_s, v); /* data len */ - v = ((w * h) / 8) + ((w * h) * 3); - out_uint8a(self->out_s, s->p, v); - s_mark_end(self->out_s); - xrdp_rdp_send_data(self->rdp_layer, RDP_DATA_PDU_POINTER); + in_uint8s(s, 6); + in_uint8(s, w); + in_uint8(s, h); + in_uint8s(s, 2); + in_uint16_le(s, x); + in_uint16_le(s, y); + in_uint8s(s, 22); + in_uint8(s, bpp); + in_uint8s(s, 25); + if (w == 32 && h == 32) + { + xrdp_rdp_init_data(self->rdp_layer, 8000); + out_uint16_le(self->out_s, RDP_POINTER_COLOR); + out_uint16_le(self->out_s, 0); /* pad */ + out_uint16_le(self->out_s, cache_idx); /* cache_idx */ + out_uint16_le(self->out_s, x); + out_uint16_le(self->out_s, y); + out_uint16_le(self->out_s, w); + out_uint16_le(self->out_s, h); + out_uint16_le(self->out_s, 128); + out_uint16_le(self->out_s, 3072); + if (bpp == 1) + { + in_uint8a(s, palette, 8); + for (i = 0; i < 32; i++) + for (j = 0; j < 32; j++) + { + pixel = palette[xrdp_wm_get_pixel(s->p, j, i, 32, 1)]; + out_uint8(self->out_s, pixel); + out_uint8(self->out_s, pixel >> 8); + out_uint8(self->out_s, pixel >> 16); + } + in_uint8s(s, 128); + } + else if (bpp == 4) + { + in_uint8a(s, palette, 64); + for (i = 0; i < 32; i++) + for (j = 0; j < 32; j++) + { + pixel = palette[xrdp_wm_get_pixel(s->p, j, i, 32, 4)]; + out_uint8(self->out_s, pixel); + out_uint8(self->out_s, pixel >> 8); + out_uint8(self->out_s, pixel >> 16); + } + in_uint8s(s, 512); + } + out_uint8a(self->out_s, s->p, 128); /* mask */ + s_mark_end(self->out_s); + xrdp_rdp_send_data(self->rdp_layer, RDP_DATA_PDU_POINTER); + rv = 0; + } g_free(s->data); g_free(s); - return 0; + return rv; } /*****************************************************************************/ @@ -454,8 +521,6 @@ int xrdp_wm_init(struct xrdp_wm* self) xrdp_send_cursor(self, "cursor1.cur", 1); xrdp_send_cursor(self, "cursor0.cur", 0); - //xrdp_set_cursor(self, 1); - return 0; }