added pointer cache, some debug messages and some other fixes

ulab-original
jsorg71 20 years ago
parent b2741d1ed2
commit f0c7bdb304

@ -751,7 +751,9 @@ int g_file_lock(int fd, int start, int len)
lock.l_start = start;
lock.l_len = len;
if (fcntl(fd, F_SETLK, &lock) == -1)
{
return 0;
}
return 1;
#endif
}
@ -759,12 +761,25 @@ int g_file_lock(int fd, int start, int len)
/*****************************************************************************/
int g_strlen(char* text)
{
if (text == 0)
{
return 0;
}
return strlen(text);
}
/*****************************************************************************/
char* g_strcpy(char* dest, char* src)
{
if (src == 0 && dest != 0)
{
dest[0] = 0;
return dest;
}
if (dest == 0 || src == 0)
{
return 0;
}
return strcpy(dest, src);
}
@ -773,6 +788,15 @@ char* g_strncpy(char* dest, char* src, int len)
{
char* rv;
if (src == 0 && dest != 0)
{
dest[0] = 0;
return dest;
}
if (dest == 0 || src == 0)
{
return 0;
}
rv = strncpy(dest, src, len);
dest[len] = 0;
return rv;
@ -781,6 +805,10 @@ char* g_strncpy(char* dest, char* src, int len)
/*****************************************************************************/
char* g_strcat(char* dest, char* src)
{
if (dest == 0 || src == 0)
{
return 0;
}
return strcat(dest, src);
}
@ -791,7 +819,9 @@ char* g_strdup(char* in)
char* p;
if (in == 0)
{
return 0;
}
len = g_strlen(in);
p = (char*)g_malloc(len + 1, 0);
g_strcpy(p, in);
@ -814,7 +844,9 @@ int g_load_library(char* in)
int g_free_library(int lib)
{
if (lib == 0)
{
return 0;
}
return dlclose((void*)lib);
}
@ -823,7 +855,9 @@ int g_free_library(int lib)
void* g_get_proc_address(int lib, char* name)
{
if (lib == 0)
{
return 0;
}
return dlsym((void*)lib, name);
}

@ -285,7 +285,9 @@ int add_char_at(char* text, char ch, int index)
return 0;
}
for (i = len - 1; i >= index; i--)
{
text[i + 1] = text[i];
}
text[i + 1] = ch;
text[len + 1] = 0;
return 0;
@ -301,14 +303,18 @@ int remove_char_at(char* text, int index)
len = g_strlen(text);
if (len <= 0)
{
return 0;
}
if (index >= len - 1 || index < 0)
{
text[len - 1] = 0;
return 0;
}
for (i = index; i < len - 1; i++)
{
text[i] = text[i + 1];
}
text[len - 1] = 0;
return 0;
}
@ -317,7 +323,9 @@ int remove_char_at(char* text, int index)
int set_string(char** in_str, char* in)
{
if (in_str == 0)
{
return 0;
}
g_free(*in_str);
*in_str = g_strdup(in);
return 0;

@ -14,6 +14,6 @@ int server_end_update(void);
int server_fill_rect(int x, int y, int cx, int cy, int color);
int server_screen_blt(int x, int y, int cx, int cy, int srcx, int srcy);
int server_paint_rect(int x, int y, int cx, int cy, char* data);
int server_set_cursor(int x, int y, char* data, char* mask);
int server_set_pointer(int x, int y, char* data, char* mask);
int server_palette(int* palette);

@ -136,6 +136,8 @@ int xrdp_cache_add_bitmap(struct xrdp_cache* self, struct xrdp_bitmap* bitmap);
int xrdp_cache_add_palette(struct xrdp_cache* self, int* palette);
int xrdp_cache_add_char(struct xrdp_cache* self,
struct xrdp_font_item* font_item);
int xrdp_cache_add_pointer(struct xrdp_cache* self,
struct xrdp_pointer_item* pointer_item);
/* xrdp_wm.c */
struct xrdp_wm* xrdp_wm_create(struct xrdp_process* owner,
@ -145,6 +147,7 @@ int xrdp_wm_send_palette(struct xrdp_wm* self);
int xrdp_wm_init(struct xrdp_wm* self);
int xrdp_wm_send_bitmap(struct xrdp_wm* self, struct xrdp_bitmap* bitmap,
int x, int y, int cx, int cy);
int xrdp_wm_set_pointer(struct xrdp_wm* self, int cache_idx);
int xrdp_wm_set_focused(struct xrdp_wm* self, struct xrdp_bitmap* wnd);
int xrdp_wm_get_vis_region(struct xrdp_wm* self, struct xrdp_bitmap* bitmap,
int x, int y, int cx, int cy,
@ -154,8 +157,9 @@ int xrdp_wm_mouse_click(struct xrdp_wm* self, int x, int y, int but, int down);
int xrdp_wm_key(struct xrdp_wm* self, int device_flags, int scan_code);
int xrdp_wm_key_sync(struct xrdp_wm* self, int device_flags, int key_flags);
int xrdp_wm_pu(struct xrdp_wm* self, struct xrdp_bitmap* control);
int xrdp_wm_send_cursor(struct xrdp_wm* self, int cache_idx,
int xrdp_wm_send_pointer(struct xrdp_wm* self, int cache_idx,
char* data, char* mask, int x, int y);
int xrdp_wm_pointer(struct xrdp_wm* self, char* data, char* mask, int x, int y);
/* xrdp_process.c */
struct xrdp_process* xrdp_process_create(struct xrdp_listen* owner);
@ -285,7 +289,7 @@ int server_screen_blt(struct xrdp_mod* mod, int x, int y, int cx, int cy,
int srcx, int srcy);
int server_paint_rect(struct xrdp_mod* mod, int x, int y, int cx, int cy,
char* data);
int server_set_cursor(struct xrdp_mod* mod, int x, int y,
int server_set_pointer(struct xrdp_mod* mod, int x, int y,
char* data, char* mask);
int server_palette(struct xrdp_mod* mod, int* palette);
int server_error_popup(struct xrdp_mod* mod, char* error, char* caption);

@ -99,7 +99,7 @@ struct xrdp_bitmap* xrdp_bitmap_create(int width, int height, int bpp,
}
if (self->type == WND_TYPE_SCREEN || self->type == WND_TYPE_BITMAP)
{
self->data = (char*)g_malloc(width * height * Bpp, 1);
self->data = (char*)g_malloc(width * height * Bpp, 0);
}
if (self->type != WND_TYPE_BITMAP)
{
@ -196,6 +196,7 @@ void xrdp_bitmap_delete(struct xrdp_bitmap* self)
{
g_free(self->data);
}
g_free(self->caption1);
g_free(self);
}
@ -249,7 +250,7 @@ int xrdp_bitmap_set_focus(struct xrdp_bitmap* self, int focused)
xrdp_painter_fill_rect(painter, self, 3, 3, self->width - 5, 18);
painter->font->color = self->wm->black;
}
xrdp_painter_draw_text(painter, self, 4, 4, self->caption);
xrdp_painter_draw_text(painter, self, 4, 4, self->caption1);
xrdp_painter_end_update(painter);
xrdp_painter_delete(painter);
return 0;
@ -884,7 +885,7 @@ int xrdp_bitmap_invalidate(struct xrdp_bitmap* self, struct xrdp_rect* rect)
xrdp_painter_fill_rect(painter, self, 3, 3, self->width - 5, 18);
painter->font->color = self->wm->black;
}
xrdp_painter_draw_text(painter, self, 4, 4, self->caption);
xrdp_painter_draw_text(painter, self, 4, 4, self->caption1);
}
else if (self->type == WND_TYPE_SCREEN) /* 2 */
{
@ -913,11 +914,11 @@ int xrdp_bitmap_invalidate(struct xrdp_bitmap* self, struct xrdp_rect* rect)
{
xrdp_bitmap_draw_button(self, painter, 0, 0,
self->width, self->height, 0);
w = xrdp_painter_text_width(painter, self->caption);
h = xrdp_painter_text_height(painter, self->caption);
w = xrdp_painter_text_width(painter, self->caption1);
h = xrdp_painter_text_height(painter, self->caption1);
painter->font->color = self->wm->black;
xrdp_painter_draw_text(painter, self, self->width / 2 - w / 2,
self->height / 2 - h / 2, self->caption);
self->height / 2 - h / 2, self->caption1);
if (self->parent != 0)
if (self->wm->focused_window == self->parent)
if (self->parent->focused_control == self)
@ -928,11 +929,11 @@ int xrdp_bitmap_invalidate(struct xrdp_bitmap* self, struct xrdp_rect* rect)
{
xrdp_bitmap_draw_button(self, painter, 0, 0,
self->width, self->height, 1);
w = xrdp_painter_text_width(painter, self->caption);
h = xrdp_painter_text_height(painter, self->caption);
w = xrdp_painter_text_width(painter, self->caption1);
h = xrdp_painter_text_height(painter, self->caption1);
painter->font->color = self->wm->black;
xrdp_painter_draw_text(painter, self, (self->width / 2 - w / 2) + 1,
(self->height / 2 - h / 2) + 1, self->caption);
(self->height / 2 - h / 2) + 1, self->caption1);
if (self->parent != 0)
if (self->wm->focused_window == self->parent)
if (self->parent->focused_control == self)
@ -976,13 +977,13 @@ int xrdp_bitmap_invalidate(struct xrdp_bitmap* self, struct xrdp_rect* rect)
painter->fg_color = self->wm->black;
if (self->password_char != 0)
{
i = g_strlen(self->caption);
i = g_strlen(self->caption1);
g_memset(text, self->password_char, i);
text[i] = 0;
xrdp_painter_draw_text(painter, self, 4, 2, text);
}
else
xrdp_painter_draw_text(painter, self, 4, 2, self->caption);
xrdp_painter_draw_text(painter, self, 4, 2, self->caption1);
/* draw xor box(cursor) */
if (self->parent != 0)
{
@ -994,7 +995,7 @@ int xrdp_bitmap_invalidate(struct xrdp_bitmap* self, struct xrdp_rect* rect)
text[self->edit_pos] = 0;
}
else
g_strncpy(text, self->caption, self->edit_pos);
g_strncpy(text, self->caption1, self->edit_pos);
w = xrdp_painter_text_width(painter, text);
painter->fg_color = self->wm->black;
painter->rop = 0x5a;
@ -1007,7 +1008,7 @@ int xrdp_bitmap_invalidate(struct xrdp_bitmap* self, struct xrdp_rect* rect)
else if (self->type == WND_TYPE_LABEL) /* 6 */
{
painter->font->color = self->wm->black;
xrdp_painter_draw_text(painter, self, 0, 0, self->caption);
xrdp_painter_draw_text(painter, self, 0, 0, self->caption1);
}
else if (self->type == WND_TYPE_COMBO) /* 7 combo box */
{
@ -1205,7 +1206,7 @@ int xrdp_bitmap_def_proc(struct xrdp_bitmap* self, int msg,
else if ((scan_code == 77 || scan_code == 80) &&
(ext || self->wm->num_lock == 0))
{
if (self->edit_pos < g_strlen(self->caption))
if (self->edit_pos < g_strlen(self->caption1))
{
self->edit_pos++;
xrdp_bitmap_invalidate(self, 0);
@ -1214,13 +1215,13 @@ int xrdp_bitmap_def_proc(struct xrdp_bitmap* self, int msg,
/* backspace */
else if (scan_code == 14)
{
n = g_strlen(self->caption);
n = g_strlen(self->caption1);
if (n > 0)
{
if (self->edit_pos > 0)
{
self->edit_pos--;
remove_char_at(self->caption, self->edit_pos);
remove_char_at(self->caption1, self->edit_pos);
xrdp_bitmap_invalidate(self, 0);
}
}
@ -1229,12 +1230,12 @@ int xrdp_bitmap_def_proc(struct xrdp_bitmap* self, int msg,
else if (scan_code == 83 &&
(ext || self->wm->num_lock == 0))
{
n = g_strlen(self->caption);
n = g_strlen(self->caption1);
if (n > 0)
{
if (self->edit_pos < n)
{
remove_char_at(self->caption, self->edit_pos);
remove_char_at(self->caption1, self->edit_pos);
xrdp_bitmap_invalidate(self, 0);
}
}
@ -1243,7 +1244,7 @@ int xrdp_bitmap_def_proc(struct xrdp_bitmap* self, int msg,
else if (scan_code == 79 &&
(ext || self->wm->num_lock == 0))
{
n = g_strlen(self->caption);
n = g_strlen(self->caption1);
if (self->edit_pos < n)
{
self->edit_pos = n;
@ -1268,7 +1269,7 @@ int xrdp_bitmap_def_proc(struct xrdp_bitmap* self, int msg,
self->wm->scroll_lock);
if (c != 0)
{
add_char_at(self->caption, c, self->edit_pos);
add_char_at(self->caption1, c, self->edit_pos);
self->edit_pos++;
xrdp_bitmap_invalidate(self, 0);
}

@ -39,6 +39,7 @@ struct xrdp_cache* xrdp_cache_create(struct xrdp_wm* owner,
self->cache2_size = client_info->cache2_size;
self->cache3_entries = client_info->cache3_entries;
self->cache3_size = client_info->cache3_size;
self->pointer_cache_entries = client_info->pointer_cache_entries;
return self;
}
@ -320,3 +321,63 @@ int xrdp_cache_add_char(struct xrdp_cache* self,
xrdp_orders_send_font(self->orders, fi, f, c);
return MAKELONG(f, c);
}
/*****************************************************************************/
/* added the pointer to the cache and send it to client, it also sets the
client if it finds it
returns the index in the cache
does not take ownership of pointer_item */
int xrdp_cache_add_pointer(struct xrdp_cache* self,
struct xrdp_pointer_item* pointer_item)
{
int i;
int oldest;
int index;
if (self == 0)
{
return 0;
}
self->pointer_stamp++;
/* look for match */
for (i = 0; i < self->pointer_cache_entries; i++)
{
if (self->pointer_items[i].x == pointer_item->x &&
self->pointer_items[i].y == pointer_item->y &&
g_memcmp(self->pointer_items[i].data,
pointer_item->data, 32 * 32 * 3) == 0 &&
g_memcmp(self->pointer_items[i].mask,
pointer_item->mask, 32 * 32 / 8) == 0)
{
self->pointer_items[i].stamp = self->pointer_stamp;
xrdp_wm_set_pointer(self->wm, i);
DEBUG(("found pointer at %d\n\r", i));
return i;
}
}
/* look for oldest */
index = 0;
oldest = 0x7fffffff;
for (i = 0; i < self->pointer_cache_entries; i++)
{
if (self->pointer_items[i].stamp < oldest)
{
oldest = self->pointer_items[i].stamp;
index = i;
}
}
self->pointer_items[index].x = pointer_item->x;
self->pointer_items[index].y = pointer_item->y;
g_memcpy(self->pointer_items[index].data,
pointer_item->data, 32 * 32 * 3);
g_memcpy(self->pointer_items[index].mask,
pointer_item->mask, 32 * 32 / 8);
self->pointer_items[index].stamp = self->pointer_stamp;
xrdp_wm_send_pointer(self->wm, index,
self->pointer_items[index].data,
self->pointer_items[index].mask,
self->pointer_items[index].x,
self->pointer_items[index].y);
DEBUG(("adding pointer at %d\n\r", index));
return index;
}

@ -190,12 +190,12 @@ int server_paint_rect(int x, int y, int cx, int cy, char* data)
}
/*****************************************************************************/
int server_set_cursor(int x, int y, char* data, char* mask)
int server_set_pointer(int x, int y, char* data, char* mask)
{
struct xrdp_wm* wm;
wm = (struct xrdp_wm*)g_mod.wm;
xrdp_wm_send_cursor(wm, 2, data, mask, x, y);
xrdp_wm_pointer(wm, data, mask, x, y);
return 0;
}
@ -283,13 +283,13 @@ int server_paint_rect(struct xrdp_mod* mod, int x, int y, int cx, int cy,
}
/*****************************************************************************/
int server_set_cursor(struct xrdp_mod* mod, int x, int y,
int server_set_pointer(struct xrdp_mod* mod, int x, int y,
char* data, char* mask)
{
struct xrdp_wm* wm;
wm = (struct xrdp_wm*)mod->wm;
xrdp_wm_send_cursor(wm, 2, data, mask, x, y);
xrdp_wm_pointer(wm, data, mask, x, y);
return 0;
}

@ -89,10 +89,12 @@ int xrdp_iso_recv(struct xrdp_iso* self, struct stream* s)
DEBUG((" in xrdp_iso_recv\n\r"));
if (xrdp_iso_recv_msg(self, s, &code) != 0)
{
DEBUG((" out xrdp_iso_recv xrdp_iso_recv_msg return non zero\n\r"));
return 1;
}
if (code != ISO_PDU_DT)
{
DEBUG((" out xrdp_iso_recv code != ISO_PDU_DT\n\r"));
return 1;
}
DEBUG((" out xrdp_iso_recv\n\r"));

@ -107,7 +107,7 @@ int xrdp_wm_setup_mod(struct xrdp_wm* self,
self->mod->server_fill_rect = server_fill_rect;
self->mod->server_screen_blt = server_screen_blt;
self->mod->server_paint_rect = server_paint_rect;
self->mod->server_set_cursor = server_set_cursor;
self->mod->server_set_pointer = server_set_pointer;
self->mod->server_palette = server_palette;
self->mod->server_error_popup= server_error_popup;
}
@ -167,7 +167,7 @@ int xrdp_wm_login_notify(struct xrdp_bitmap* wnd,
help->left = wnd->wm->screen->width / 2 - help->width / 2;
help->top = wnd->wm->screen->height / 2 - help->height / 2;
help->notify = xrdp_wm_login_help_notify;
g_strcpy(help->caption, "Login help");
set_string(&help->caption1, "Login help");
/* ok button */
but = xrdp_bitmap_create(60, 25, wnd->wm->screen->bpp, 3, wnd->wm);
xrdp_list_insert_item(help->child_list, 0, (int)but);
@ -177,7 +177,7 @@ int xrdp_wm_login_notify(struct xrdp_bitmap* wnd,
but->top = 260;
but->id = 1;
but->tab_stop = 1;
g_strcpy(but->caption, "OK");
set_string(&but->caption1, "OK");
/* draw it */
help->focused_control = but;
//wnd->wm->focused_window = help;
@ -207,7 +207,7 @@ int xrdp_wm_login_notify(struct xrdp_bitmap* wnd,
edit = xrdp_bitmap_get_child_by_id(wnd, 4);
if (edit != 0)
{
g_strcpy(con_mod.username, edit->caption);
g_strcpy(con_mod.username, edit->caption1);
}
}
if (g_strcmp(con_mod.password, "ask") == 0)
@ -215,7 +215,7 @@ int xrdp_wm_login_notify(struct xrdp_bitmap* wnd,
edit = xrdp_bitmap_get_child_by_id(wnd, 5);
if (edit != 0)
{
g_strcpy(con_mod.password, edit->caption);
g_strcpy(con_mod.password, edit->caption1);
}
}
if (xrdp_wm_setup_mod(wm, mod) == 0)
@ -364,7 +364,7 @@ int xrdp_login_wnd_create(struct xrdp_wm* self)
self->login_window->top = self->screen->height / 2 -
self->login_window->height / 2;
self->login_window->notify = xrdp_wm_login_notify;
g_strcpy(self->login_window->caption, "Login to xrdp");
set_string(&self->login_window->caption1, "Login to xrdp");
/* image */
but = xrdp_bitmap_create(4, 4, self->screen->bpp, WND_TYPE_IMAGE, self);
@ -391,7 +391,7 @@ int xrdp_login_wnd_create(struct xrdp_wm* self)
but->owner = self->login_window;
but->left = 155;
but->top = 50;
g_strcpy(but->caption, "Username");
set_string(&but->caption1, "Username");
/* edit */
but = xrdp_bitmap_create(140, 20, self->screen->bpp, WND_TYPE_EDIT, self);
@ -401,8 +401,9 @@ int xrdp_login_wnd_create(struct xrdp_wm* self)
but->left = 220;
but->top = 50;
but->id = 4;
but->cursor = 1;
but->pointer = 1;
but->tab_stop = 1;
but->caption1 = g_malloc(256, 1);
self->login_window->focused_control = but;
/* label */
@ -412,7 +413,7 @@ int xrdp_login_wnd_create(struct xrdp_wm* self)
but->owner = self->login_window;
but->left = 155;
but->top = 80;
g_strcpy(but->caption, "Password");
set_string(&but->caption1, "Password");
/* edit */
but = xrdp_bitmap_create(140, 20, self->screen->bpp, WND_TYPE_EDIT, self);
@ -422,8 +423,9 @@ int xrdp_login_wnd_create(struct xrdp_wm* self)
but->left = 220;
but->top = 80;
but->id = 5;
but->cursor = 1;
but->pointer = 1;
but->tab_stop = 1;
but->caption1 = g_malloc(256, 1);
but->password_char = '*';
/* label */
@ -433,7 +435,7 @@ int xrdp_login_wnd_create(struct xrdp_wm* self)
but->owner = self->login_window;
but->left = 155;
but->top = 110;
g_strcpy(but->caption, "Module");
set_string(&but->caption1, "Module");
/* combo */
but = xrdp_bitmap_create(140, 20, self->screen->bpp, WND_TYPE_COMBO, self);
@ -454,7 +456,7 @@ int xrdp_login_wnd_create(struct xrdp_wm* self)
but->left = 180;
but->top = 160;
but->id = 3;
g_strcpy(but->caption, "OK");
set_string(&but->caption1, "OK");
but->tab_stop = 1;
/* button */
@ -465,7 +467,7 @@ int xrdp_login_wnd_create(struct xrdp_wm* self)
but->left = 250;
but->top = 160;
but->id = 2;
g_strcpy(but->caption, "Cancel");
set_string(&but->caption1, "Cancel");
but->tab_stop = 1;
/* button */
@ -476,7 +478,7 @@ int xrdp_login_wnd_create(struct xrdp_wm* self)
but->left = 320;
but->top = 160;
but->id = 1;
g_strcpy(but->caption, "Help");
set_string(&but->caption1, "Help");
but->tab_stop = 1;
return 0;

@ -91,12 +91,14 @@ int xrdp_mcs_recv(struct xrdp_mcs* self, struct stream* s, int* chan)
{
if (xrdp_iso_recv(self->iso_layer, s) != 0)
{
DEBUG((" out xrdp_mcs_recv xrdp_iso_recv returned non zero\n\r"));
return 1;
}
in_uint8(s, opcode);
appid = opcode >> 2;
if (appid == MCS_DPUM)
{
DEBUG((" out xrdp_mcs_recv appid != MCS_DPUM\n\r"));
return 1;
}
if (appid == MCS_CJRQ)
@ -141,7 +143,9 @@ int xrdp_mcs_ber_parse_header(struct xrdp_mcs* self, struct stream* s,
in_uint8(s, tag);
}
if (tag != tag_val)
{
return 1;
}
in_uint8(s, l);
if (l & 0x80)
{

@ -380,6 +380,7 @@ int xrdp_painter_draw_bitmap(struct xrdp_painter* self,
srcy = srcy - y1;
y1 = 0;
}
//g_printf("%d %d %d %d %d %d\n", x1, y1, w, h, srcx, srcy);
xrdp_orders_mem_blt(self->orders, cache_id, palette_id,
x1, y1, w, h, self->rop, srcx, srcy,
cache_idx, &rect1);
@ -425,6 +426,10 @@ int xrdp_painter_text_width(struct xrdp_painter* self, char* text)
struct xrdp_font_item* font_item;
xrdp_painter_font_needed(self);
if (text == 0)
{
return 0;
}
rv = 0;
len = g_strlen(text);
for (index = 0; index < len; index++)
@ -444,6 +449,10 @@ int xrdp_painter_text_height(struct xrdp_painter* self, char* text)
struct xrdp_font_item* font_item;
xrdp_painter_font_needed(self);
if (text == 0)
{
return 0;
}
rv = 0;
len = g_strlen(text);
for (index = 0; index < len; index++)

@ -120,7 +120,10 @@ int xrdp_process_main_loop(struct xrdp_process* self)
if (i & 1)
{
init_stream(s, 8192);
xrdp_process_loop(self, s);
if (xrdp_process_loop(self, s) != 0)
{
break;
}
}
if (i & 2) /* mod socket fired */
{

@ -138,6 +138,7 @@ int xrdp_rdp_init_data(struct xrdp_rdp* self, struct stream* s)
}
/*****************************************************************************/
/* returns erros */
int xrdp_rdp_recv(struct xrdp_rdp* self, struct stream* s, int* code)
{
int error;
@ -145,6 +146,7 @@ int xrdp_rdp_recv(struct xrdp_rdp* self, struct stream* s, int* code)
int pdu_code;
int chan;
DEBUG(("in xrdp_rdp_recv\n\r"));
if (s->next_packet == 0 || s->next_packet >= s->end)
{
chan = 0;
@ -153,18 +155,21 @@ int xrdp_rdp_recv(struct xrdp_rdp* self, struct stream* s, int* code)
{
s->next_packet = 0;
*code = -1;
DEBUG(("out xrdp_rdp_recv\n\r"));
return 0;
}
if (error != 0)
{
DEBUG(("out xrdp_rdp_recv error\n\r"));
return 1;
}
if (chan != MCS_GLOBAL_CHANNEL && chan > 0)
{
s->next_packet = 0;
*code = 0;
DEBUG(("out xrdp_rdp_recv\n\r"));
return 0;
}
if (error != 0)
{
return 1;
}
s->next_packet = s->p;
}
else
@ -176,12 +181,14 @@ int xrdp_rdp_recv(struct xrdp_rdp* self, struct stream* s, int* code)
{
s->next_packet += 8;
*code = 0;
DEBUG(("out xrdp_rdp_recv\n\r"));
return 0;
}
in_uint16_le(s, pdu_code);
*code = pdu_code & 0xf;
in_uint8s(s, 2); /* mcs user id */
s->next_packet += len;
DEBUG(("out xrdp_rdp_recv\n\r"));
return 0;
}
@ -198,6 +205,7 @@ int xrdp_rdp_send(struct xrdp_rdp* self, struct stream* s, int pdu_type)
out_uint16_le(s, self->mcs_channel);
if (xrdp_sec_send(self->sec_layer, s, 0) != 0)
{
DEBUG(("out xrdp_rdp_send error\n\r"));
return 1;
}
DEBUG(("out xrdp_rdp_send\n\r"));
@ -225,6 +233,7 @@ int xrdp_rdp_send_data(struct xrdp_rdp* self, struct stream* s,
out_uint16_le(s, 0);
if (xrdp_sec_send(self->sec_layer, s, 0) != 0)
{
DEBUG(("out xrdp_rdp_send_data error\n\r"));
return 1;
}
DEBUG(("out xrdp_rdp_send_data\n\r"));
@ -440,6 +449,21 @@ int xrdp_process_capset_bmpcache(struct xrdp_rdp* self, struct stream* s,
return 0;
}
/*****************************************************************************/
int xrdp_process_capset_pointercache(struct xrdp_rdp* self, struct stream* s,
int len)
{
int i;
//g_hexdump(s->p, len);
in_uint8s(s, 2); /* color pointer */
in_uint16_le(s, i);
i = MIN(i, 32);
self->client_info.pointer_cache_entries = i;
//g_printf("%d\n", self->client_info.pointer_cache_entries);
return 0;
}
/*****************************************************************************/
int xrdp_rdp_process_confirm_active(struct xrdp_rdp* self, struct stream* s)
{
@ -469,6 +493,9 @@ int xrdp_rdp_process_confirm_active(struct xrdp_rdp* self, struct stream* s)
case RDP_CAPSET_BMPCACHE:
xrdp_process_capset_bmpcache(self, s, len);
break;
case RDP_CAPSET_POINTER:
xrdp_process_capset_pointercache(self, s, len);
break;
}
s->p = p + len;
}

@ -430,6 +430,7 @@ int xrdp_sec_recv(struct xrdp_sec* self, struct stream* s, int* chan)
DEBUG((" in xrdp_sec_recv\n\r"));
if (xrdp_mcs_recv(self->mcs_layer, s, chan) != 0)
{
DEBUG((" out xrdp_sec_recv error\n\r"));
return 1;
}
in_uint32_le(s, flags);

@ -54,12 +54,13 @@ int xrdp_tcp_recv(struct xrdp_tcp* self, struct stream* s, int len)
{
int rcvd;
DEBUG((" in xrdp_tcp_recv, gota get %d bytes\n", len))
DEBUG((" in xrdp_tcp_recv, gota get %d bytes\n\r", len));
init_stream(s, len);
while (len > 0)
{
if (g_is_term())
{
DEBUG((" out xrdp_tcp_recv, g_is_term is true\n\r"));
return 1;
}
rcvd = g_tcp_recv(self->sck, s->end, len, 0);
@ -71,13 +72,13 @@ int xrdp_tcp_recv(struct xrdp_tcp* self, struct stream* s, int len)
}
else
{
DEBUG((" error = -1 in xrdp_tcp_recv socket %d\n", self->sck))
DEBUG((" error = -1 in xrdp_tcp_recv socket %d\n\r", self->sck));
return 1;
}
}
else if (rcvd == 0)
{
DEBUG((" error = 0 in xrdp_tcp_recv socket %d\n", self->sck))
DEBUG((" error = 0 in xrdp_tcp_recv socket %d\n\r", self->sck));
return 1;
}
else
@ -86,6 +87,7 @@ int xrdp_tcp_recv(struct xrdp_tcp* self, struct stream* s, int len)
len -= rcvd;
}
}
DEBUG((" out xrdp_tcp_recv\n\r"));
return 0;
}

@ -42,7 +42,7 @@ struct xrdp_mod
int srcx, int srcy);
int (*server_paint_rect)(struct xrdp_mod* v, int x, int y, int cx, int cy,
char* data);
int (*server_set_cursor)(struct xrdp_mod* v, int x, int y, char* data, char* mask);
int (*server_set_pointer)(struct xrdp_mod* v, int x, int y, char* data, char* mask);
int (*server_palette)(struct xrdp_mod* v, int* palette);
int (*server_error_popup)(struct xrdp_mod* v, char* error, char* caption);
int d2[92];
@ -181,6 +181,7 @@ struct xrdp_client_info
int cache2_size;
int cache3_entries;
int cache3_size;
int pointer_cache_entries;
int use_bitmap_comp;
int use_bitmap_cache;
int op1; /* use smaller bitmap header, todo */
@ -314,17 +315,26 @@ struct xrdp_char_item
struct xrdp_font_item font_item;
};
struct xrdp_pointer_item
{
int stamp;
int x; /* hotspot */
int y;
char data[32 * 32 * 3];
char mask[32 * 32 / 8];
};
/* differnce caches */
struct xrdp_cache
{
struct xrdp_wm* wm; /* owner */
struct xrdp_orders* orders;
/* palette */
int palette_stamp;
struct xrdp_palette_item palette_items[6];
/* bitmap */
int bitmap_stamp;
struct xrdp_bitmap_item bitmap_items[3][600];
int char_stamp;
struct xrdp_char_item char_items[12][256];
int use_bitmap_comp;
int cache1_entries;
int cache1_size;
@ -332,6 +342,13 @@ struct xrdp_cache
int cache2_size;
int cache3_entries;
int cache3_size;
/* font */
int char_stamp;
struct xrdp_char_item char_items[12][256];
/* pointer */
int pointer_stamp;
struct xrdp_pointer_item pointer_items[32];
int pointer_cache_entries;
};
/* the window manager */
@ -372,8 +389,8 @@ struct xrdp_wm
struct xrdp_bitmap* popup_wnd;
/* focused window */
struct xrdp_bitmap* focused_window;
/* cursor */
int current_cursor;
/* pointer */
int current_pointer;
int mouse_x;
int mouse_y;
/* keyboard info */
@ -458,11 +475,11 @@ struct xrdp_bitmap
/* for all but bitmap */
int left;
int top;
int cursor;
int pointer;
int bg_color;
int tab_stop;
int id;
char caption[256];
char* caption1;
/* for window or screen */
struct xrdp_bitmap* modal_dialog;
struct xrdp_bitmap* focused_control;

@ -299,23 +299,6 @@ int xrdp_wm_set_focused(struct xrdp_wm* self, struct xrdp_bitmap* wnd)
return 0;
}
/*****************************************************************************/
int xrdp_set_cursor(struct xrdp_wm* self, int cache_idx)
{
struct stream* s;
make_stream(s);
init_stream(s, 8192);
xrdp_rdp_init_data(self->rdp_layer, s);
out_uint16_le(s, RDP_POINTER_CACHED);
out_uint16_le(s, 0); /* pad */
out_uint16_le(s, cache_idx); /* cache_idx */
s_mark_end(s);
xrdp_rdp_send_data(self->rdp_layer, s, RDP_DATA_PDU_POINTER);
free_stream(s);
return 0;
}
//******************************************************************************
int xrdp_wm_get_pixel(char* data, int x, int y, int width, int bpp)
{
@ -347,7 +330,22 @@ int xrdp_wm_get_pixel(char* data, int x, int y, int width, int bpp)
}
/*****************************************************************************/
int xrdp_wm_load_cursor(struct xrdp_wm* self, char* file_name, char* data,
int xrdp_wm_pointer(struct xrdp_wm* self, char* data, char* mask, int x, int y)
{
struct xrdp_pointer_item pointer_item;
g_memset(&pointer_item, 0, sizeof(struct xrdp_pointer_item));
pointer_item.x = x;
pointer_item.y = y;
g_memcpy(pointer_item.data, data, 32 * 32 * 3);
g_memcpy(pointer_item.mask, mask, 32 * 32 / 8);
xrdp_cache_add_pointer(self->cache, &pointer_item);
return 0;
}
/*****************************************************************************/
int xrdp_wm_load_pointer(struct xrdp_wm* self, char* file_name, char* data,
char* mask, int* x, int* y)
{
int fd;
@ -419,7 +417,7 @@ int xrdp_wm_load_cursor(struct xrdp_wm* self, char* file_name, char* data,
}
/*****************************************************************************/
int xrdp_wm_send_cursor(struct xrdp_wm* self, int cache_idx,
int xrdp_wm_send_pointer(struct xrdp_wm* self, int cache_idx,
char* data, char* mask, int x, int y)
{
struct stream* s;
@ -459,6 +457,24 @@ int xrdp_wm_send_cursor(struct xrdp_wm* self, int cache_idx,
return 0;
}
/*****************************************************************************/
int xrdp_wm_set_pointer(struct xrdp_wm* self, int cache_idx)
{
struct stream* s;
make_stream(s);
init_stream(s, 8192);
xrdp_rdp_init_data(self->rdp_layer, s);
out_uint16_le(s, RDP_POINTER_CACHED);
out_uint16_le(s, 0); /* pad */
out_uint16_le(s, cache_idx); /* cache_idx */
//g_printf("%d\n", cache_idx);
s_mark_end(s);
xrdp_rdp_send_data(self->rdp_layer, s, RDP_DATA_PDU_POINTER);
free_stream(s);
return 0;
}
/*****************************************************************************/
int xrdp_wm_init(struct xrdp_wm* self)
{
@ -537,10 +553,10 @@ int xrdp_wm_init(struct xrdp_wm* self)
xrdp_wm_set_focused(self, self->login_window);
xrdp_wm_load_cursor(self, "cursor1.cur", data, mask, &x, &y);
xrdp_wm_send_cursor(self, 1, data, mask, x, y);
xrdp_wm_load_cursor(self, "cursor0.cur", data, mask, &x, &y);
xrdp_wm_send_cursor(self, 0, data, mask, x, y);
xrdp_wm_load_pointer(self, "cursor1.cur", data, mask, &x, &y);
xrdp_wm_send_pointer(self, 1, data, mask, x, y);
xrdp_wm_load_pointer(self, "cursor0.cur", data, mask, &x, &y);
xrdp_wm_send_pointer(self, 0, data, mask, x, y);
#endif
return 0;
}
@ -850,10 +866,10 @@ int xrdp_wm_mouse_move(struct xrdp_wm* self, int x, int y)
{
if (!self->dragging)
{
if (b->cursor != self->current_cursor)
if (b->pointer != self->current_pointer)
{
xrdp_set_cursor(self, b->cursor);
self->current_cursor = b->cursor;
xrdp_wm_set_pointer(self, b->pointer);
self->current_pointer = b->pointer;
}
xrdp_bitmap_def_proc(b, WM_MOUSEMOVE,
xrdp_bitmap_from_screenx(b, x),

Loading…
Cancel
Save