changed the way the palette works in 8 bpp and changed some parameter passing

ulab-original
jsorg71 20 years ago
parent 520301d70a
commit cf3e17cb73

@ -29,14 +29,14 @@
#include "os_calls.h"
/* xrdp_tcp.c */
struct xrdp_tcp* xrdp_tcp_create(struct xrdp_iso* owner);
struct xrdp_tcp* xrdp_tcp_create(struct xrdp_iso* owner, int sck);
void xrdp_tcp_delete(struct xrdp_tcp* self);
int xrdp_tcp_init(struct xrdp_tcp* self, struct stream* s);
int xrdp_tcp_recv(struct xrdp_tcp* self, struct stream* s, int len);
int xrdp_tcp_send(struct xrdp_tcp* self, struct stream* s);
/* xrdp_iso.c */
struct xrdp_iso* xrdp_iso_create(struct xrdp_mcs* owner);
struct xrdp_iso* xrdp_iso_create(struct xrdp_mcs* owner, int sck);
void xrdp_iso_delete(struct xrdp_iso* self);
int xrdp_iso_init(struct xrdp_iso* self, struct stream* s);
int xrdp_iso_recv(struct xrdp_iso* self, struct stream* s);
@ -44,7 +44,9 @@ int xrdp_iso_send(struct xrdp_iso* self, struct stream* s);
int xrdp_iso_incoming(struct xrdp_iso* self);
/* xrdp_mcs.c */
struct xrdp_mcs* xrdp_mcs_create(struct xrdp_sec* owner);
struct xrdp_mcs* xrdp_mcs_create(struct xrdp_sec* owner, int sck,
struct stream* client_mcs_data,
struct stream* server_mcs_data);
void xrdp_mcs_delete(struct xrdp_mcs* self);
int xrdp_mcs_init(struct xrdp_mcs* self, struct stream* s);
int xrdp_mcs_recv(struct xrdp_mcs* self, struct stream* s, int* chan);
@ -53,7 +55,7 @@ int xrdp_mcs_incoming(struct xrdp_mcs* self);
int xrdp_mcs_disconnect(struct xrdp_mcs* self);
/* xrdp_sec.c */
struct xrdp_sec* xrdp_sec_create(struct xrdp_rdp* owner);
struct xrdp_sec* xrdp_sec_create(struct xrdp_rdp* owner, int sck);
void xrdp_sec_delete(struct xrdp_sec* self);
int xrdp_sec_init(struct xrdp_sec* self, struct stream* s);
int xrdp_sec_recv(struct xrdp_sec* self, struct stream* s, int* chan);
@ -62,7 +64,7 @@ int xrdp_sec_incoming(struct xrdp_sec* self);
int xrdp_sec_disconnect(struct xrdp_sec* self);
/* xrdp_rdp.c */
struct xrdp_rdp* xrdp_rdp_create(struct xrdp_process* owner);
struct xrdp_rdp* xrdp_rdp_create(struct xrdp_process* owner, int sck);
void xrdp_rdp_delete(struct xrdp_rdp* self);
int xrdp_rdp_init(struct xrdp_rdp* self, struct stream* s);
int xrdp_rdp_init_data(struct xrdp_rdp* self, struct stream* s);
@ -77,7 +79,8 @@ int xrdp_rdp_process_data(struct xrdp_rdp* self, struct stream* s);
int xrdp_rdp_disconnect(struct xrdp_rdp* self);
/* xrdp_orders.c */
struct xrdp_orders* xrdp_orders_create(struct xrdp_process* owner);
struct xrdp_orders* xrdp_orders_create(struct xrdp_process* owner,
struct xrdp_rdp* rdp_layer);
void xrdp_orders_delete(struct xrdp_orders* self);
int xrdp_orders_init(struct xrdp_orders* self);
int xrdp_orders_send(struct xrdp_orders* self);
@ -135,7 +138,8 @@ int xrdp_cache_add_char(struct xrdp_cache* self,
struct xrdp_font_item* font_item);
/* xrdp_wm.c */
struct xrdp_wm* xrdp_wm_create(struct xrdp_process* owner);
struct xrdp_wm* xrdp_wm_create(struct xrdp_process* owner,
struct xrdp_client_info* client_info);
void xrdp_wm_delete(struct xrdp_wm* self);
int xrdp_wm_send_palette(struct xrdp_wm* self);
int xrdp_wm_init(struct xrdp_wm* self);
@ -177,9 +181,10 @@ int xrdp_region_get_rect(struct xrdp_region* self, int index,
/* xrdp_bitmap.c */
struct xrdp_bitmap* xrdp_bitmap_create(int width, int height, int bpp,
int type);
int type, struct xrdp_wm* wm);
struct xrdp_bitmap* xrdp_bitmap_create_with_data(int width, int height,
int bpp, char* data);
int bpp, char* data,
struct xrdp_wm* wm);
void xrdp_bitmap_delete(struct xrdp_bitmap* self);
struct xrdp_bitmap* xrdp_bitmap_get_child_by_id(struct xrdp_bitmap* self,
int id);

@ -80,7 +80,7 @@ int g_crc_table[256] =
/*****************************************************************************/
struct xrdp_bitmap* xrdp_bitmap_create(int width, int height, int bpp,
int type)
int type, struct xrdp_wm* wm)
{
struct xrdp_bitmap* self;
int Bpp;
@ -113,12 +113,14 @@ struct xrdp_bitmap* xrdp_bitmap_create(int width, int height, int bpp,
self->data_list = xrdp_list_create();
self->data_list->auto_free = 1;
}
self->wm = wm;
return self;
}
/*****************************************************************************/
struct xrdp_bitmap* xrdp_bitmap_create_with_data(int width, int height,
int bpp, char* data)
int bpp, char* data,
struct xrdp_wm* wm)
{
struct xrdp_bitmap* self;
@ -129,6 +131,7 @@ struct xrdp_bitmap* xrdp_bitmap_create_with_data(int width, int height,
self->bpp = bpp;
self->data = data;
self->do_not_free_data = 1;
self->wm = wm;
return self;
}
@ -254,25 +257,17 @@ int xrdp_bitmap_set_focus(struct xrdp_bitmap* self, int focused)
/*****************************************************************************/
int xrdp_bitmap_get_index(struct xrdp_bitmap* self, int* palette, int color)
{
int i;
int r;
int g;
int b;
for (i = 0; i < 256; i++)
{
if (color == palette[i])
{
return i;
}
}
for (i = 1; i < 256; i++)
{
if (palette[i] == 0)
{
palette[i] = color;
return i;
}
}
g_printf("color %8.8x not found\n\r", color);
return 255;
r = (color & 0xff0000) >> 16;
g = (color & 0x00ff00) >> 8;
b = (color & 0x0000ff) >> 0;
r = (r >> 5) << 0;
g = (g >> 5) << 3;
b = (b >> 6) << 6;
return (b | g | r);
}
/*****************************************************************************/

@ -214,6 +214,8 @@ int xrdp_cache_add_bitmap(struct xrdp_cache* self, struct xrdp_bitmap* bitmap)
}
/*****************************************************************************/
/* not used */
/* not sure how to use a palette in rdp */
int xrdp_cache_add_palette(struct xrdp_cache* self, int* palette)
{
int i;
@ -221,11 +223,17 @@ int xrdp_cache_add_palette(struct xrdp_cache* self, int* palette)
int index;
if (self == 0)
{
return 0;
}
if (palette == 0)
{
return 0;
}
if (self->wm->screen->bpp > 8)
{
return 0;
}
self->palette_stamp++;
/* look for match */
for (i = 0; i < 6; i++)

@ -46,6 +46,12 @@
(*(((unsigned short*)d) + ((y) * (w) + (x))) = (v))
#define SETPIXEL32(d, x, y, w, v) \
(*(((unsigned long*)d) + ((y) * (w) + (x))) = (v))
#define COLOR8(r, g, b) \
( \
(((r) >> 5) << 0) | \
(((g) >> 5) << 3) | \
(((b) >> 6) << 6) \
)
#define COLOR15(r, g, b) ((((r) >> 3) << 10) | (((g) >> 3) << 5) | ((b) >> 3))
#define COLOR16(r, g, b) ((((r) >> 3) << 11) | (((g) >> 2) << 5) | ((b) >> 3))
#define COLOR24(r, g, b) ((r) | ((g) << 8) | ((b) << 16))

@ -23,13 +23,13 @@
#include "xrdp.h"
/*****************************************************************************/
struct xrdp_iso* xrdp_iso_create(struct xrdp_mcs* owner)
struct xrdp_iso* xrdp_iso_create(struct xrdp_mcs* owner, int sck)
{
struct xrdp_iso* self;
self = (struct xrdp_iso*)g_malloc(sizeof(struct xrdp_iso), 1);
self->mcs_layer = owner;
self->tcp_layer = xrdp_tcp_create(self);
self->tcp_layer = xrdp_tcp_create(self, sck);
return self;
}
@ -37,7 +37,9 @@ struct xrdp_iso* xrdp_iso_create(struct xrdp_mcs* owner)
void xrdp_iso_delete(struct xrdp_iso* self)
{
if (self == 0)
{
return;
}
xrdp_tcp_delete(self->tcp_layer);
g_free(self);
}
@ -51,20 +53,30 @@ int xrdp_iso_recv_msg(struct xrdp_iso* self, struct stream* s, int* code)
*code = 0;
if (xrdp_tcp_recv(self->tcp_layer, s, 4) != 0)
{
return 1;
}
in_uint8(s, ver);
if (ver != 3)
{
return 1;
}
in_uint8s(s, 1);
in_uint16_be(s, len);
if (xrdp_tcp_recv(self->tcp_layer, s, len - 4) != 0)
{
return 1;
}
in_uint8s(s, 1);
in_uint8(s, *code);
if (*code == ISO_PDU_DT)
in_uint8s(s, 1)
{
in_uint8s(s, 1);
}
else
{
in_uint8s(s, 5);
}
return 0;
}
@ -76,9 +88,13 @@ 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)
{
return 1;
}
if (code != ISO_PDU_DT)
{
return 1;
}
DEBUG((" out xrdp_iso_recv\n\r"));
return 0;
}
@ -87,7 +103,9 @@ int xrdp_iso_recv(struct xrdp_iso* self, struct stream* s)
int xrdp_iso_send_msg(struct xrdp_iso* self, struct stream* s, int code)
{
if (xrdp_tcp_init(self->tcp_layer, s) != 0)
{
return 1;
}
out_uint8(s, 3);
out_uint8(s, 0);
out_uint16_be(s, 11); /* length */
@ -98,7 +116,9 @@ int xrdp_iso_send_msg(struct xrdp_iso* self, struct stream* s, int code)
out_uint8(s, 0);
s_mark_end(s);
if (xrdp_tcp_send(self->tcp_layer, s) != 0)
{
return 1;
}
return 0;
}
@ -157,7 +177,9 @@ int xrdp_iso_send(struct xrdp_iso* self, struct stream* s)
out_uint8(s, ISO_PDU_DT);
out_uint8(s, 0x80);
if (xrdp_tcp_send(self->tcp_layer, s) != 0)
{
return 1;
}
DEBUG((" out xrdp_iso_send\n\r"));
return 0;
}

@ -131,7 +131,7 @@ int server_paint_rect(struct xrdp_mod* mod, int x, int y, int cx, int cy,
struct xrdp_bitmap* b;
wm = (struct xrdp_wm*)mod->wm;
b = xrdp_bitmap_create_with_data(cx, cy, wm->screen->bpp, data);
b = xrdp_bitmap_create_with_data(cx, cy, wm->screen->bpp, data, wm);
//xrdp_wm_send_bitmap(wm, b, x, y, cx, cy);
xrdp_painter_draw_bitmap((struct xrdp_painter*)mod->painter,
wm->screen, b, x, y, cx, cy);
@ -156,8 +156,11 @@ int server_palette(struct xrdp_mod* mod, int* palette)
struct xrdp_wm* wm;
wm = (struct xrdp_wm*)mod->wm;
if (g_memcmp(wm->palette, palette, 255 * sizeof(int)) != 0)
{
g_memcpy(wm->palette, palette, 256 * sizeof(int));
xrdp_cache_add_palette(wm->cache, palette);
xrdp_wm_send_palette(wm);
}
return 0;
}
@ -178,11 +181,10 @@ int server_error_popup(struct xrdp_mod* mod, char* error, char* caption)
struct xrdp_bitmap* but;
wm = (struct xrdp_wm*)mod->wm;
wnd = xrdp_bitmap_create(400, 200, wm->screen->bpp, WND_TYPE_WND);
wnd = xrdp_bitmap_create(400, 200, wm->screen->bpp, WND_TYPE_WND, wm);
xrdp_list_add_item(wm->screen->child_list, (int)wnd);
wnd->parent = wm->screen;
wnd->owner = wm->screen;
wnd->wm = wm;
wnd->bg_color = wm->grey;
wnd->left = wm->screen->width / 2 - wnd->width / 2;
wnd->top = wm->screen->height / 2 - wnd->height / 2;
@ -190,11 +192,10 @@ int server_error_popup(struct xrdp_mod* mod, char* error, char* caption)
g_strcpy(wnd->caption, caption);
/* button */
but = xrdp_bitmap_create(60, 25, wm->screen->bpp, WND_TYPE_BUTTON);
but = xrdp_bitmap_create(60, 25, wm->screen->bpp, WND_TYPE_BUTTON, wm);
xrdp_list_add_item(wnd->child_list, (int)but);
but->parent = wnd;
but->owner = wnd;
but->wm = wm;
but->left = 180;
but->top = 160;
but->id = 1;
@ -287,23 +288,21 @@ int xrdp_wm_login_notify(struct xrdp_bitmap* wnd,
if (sender->id == 1) /* help button */
{
/* create help screen */
help = xrdp_bitmap_create(300, 300, wnd->wm->screen->bpp, 1);
help = xrdp_bitmap_create(300, 300, wnd->wm->screen->bpp, 1, wnd->wm);
xrdp_list_insert_item(wnd->wm->screen->child_list, 0, (int)help);
help->parent = wnd->wm->screen;
help->owner = wnd;
wnd->modal_dialog = help;
help->wm = wnd->wm;
help->bg_color = wnd->wm->grey;
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");
/* ok button */
but = xrdp_bitmap_create(60, 25, wnd->wm->screen->bpp, 3);
but = xrdp_bitmap_create(60, 25, wnd->wm->screen->bpp, 3, wnd->wm);
xrdp_list_insert_item(help->child_list, 0, (int)but);
but->parent = help;
but->owner = help;
but->wm = wnd->wm;
but->left = 120;
but->top = 260;
but->id = 1;
@ -485,11 +484,10 @@ int xrdp_login_wnd_create(struct xrdp_wm* self)
/* draw login window */
self->login_window = xrdp_bitmap_create(400, 200, self->screen->bpp,
WND_TYPE_WND);
WND_TYPE_WND, self);
xrdp_list_add_item(self->screen->child_list, (int)self->login_window);
self->login_window->parent = self->screen;
self->login_window->owner = self->screen;
self->login_window->wm = self;
self->login_window->bg_color = self->grey;
self->login_window->left = self->screen->width / 2 -
self->login_window->width / 2;
@ -499,41 +497,37 @@ int xrdp_login_wnd_create(struct xrdp_wm* self)
g_strcpy(self->login_window->caption, "Login to xrdp");
/* image */
but = xrdp_bitmap_create(4, 4, self->screen->bpp, WND_TYPE_IMAGE);
but = xrdp_bitmap_create(4, 4, self->screen->bpp, WND_TYPE_IMAGE, self);
xrdp_bitmap_load(but, "xrdp256.bmp", self->palette);
but->parent = self->screen;
but->owner = self->screen;
but->wm = self;
but->left = self->screen->width - but->width;
but->top = self->screen->height - but->height;
xrdp_list_add_item(self->screen->child_list, (int)but);
/* image */
but = xrdp_bitmap_create(4, 4, self->screen->bpp, WND_TYPE_IMAGE);
but = xrdp_bitmap_create(4, 4, self->screen->bpp, WND_TYPE_IMAGE, self);
xrdp_bitmap_load(but, "ad256.bmp", self->palette);
but->parent = self->login_window;
but->owner = self->login_window;
but->wm = self;
but->left = 10;
but->top = 30;
xrdp_list_add_item(self->login_window->child_list, (int)but);
/* label */
but = xrdp_bitmap_create(60, 20, self->screen->bpp, WND_TYPE_LABEL);
but = xrdp_bitmap_create(60, 20, self->screen->bpp, WND_TYPE_LABEL, self);
xrdp_list_add_item(self->login_window->child_list, (int)but);
but->parent = self->login_window;
but->owner = self->login_window;
but->wm = self;
but->left = 155;
but->top = 50;
g_strcpy(but->caption, "Username");
/* edit */
but = xrdp_bitmap_create(140, 20, self->screen->bpp, WND_TYPE_EDIT);
but = xrdp_bitmap_create(140, 20, self->screen->bpp, WND_TYPE_EDIT, self);
xrdp_list_add_item(self->login_window->child_list, (int)but);
but->parent = self->login_window;
but->owner = self->login_window;
but->wm = self;
but->left = 220;
but->top = 50;
but->id = 4;
@ -542,21 +536,19 @@ int xrdp_login_wnd_create(struct xrdp_wm* self)
self->login_window->focused_control = but;
/* label */
but = xrdp_bitmap_create(60, 20, self->screen->bpp, WND_TYPE_LABEL);
but = xrdp_bitmap_create(60, 20, self->screen->bpp, WND_TYPE_LABEL, self);
xrdp_list_add_item(self->login_window->child_list, (int)but);
but->parent = self->login_window;
but->owner = self->login_window;
but->wm = self;
but->left = 155;
but->top = 80;
g_strcpy(but->caption, "Password");
/* edit */
but = xrdp_bitmap_create(140, 20, self->screen->bpp, WND_TYPE_EDIT);
but = xrdp_bitmap_create(140, 20, self->screen->bpp, WND_TYPE_EDIT, self);
xrdp_list_add_item(self->login_window->child_list, (int)but);
but->parent = self->login_window;
but->owner = self->login_window;
but->wm = self;
but->left = 220;
but->top = 80;
but->id = 5;
@ -565,21 +557,19 @@ int xrdp_login_wnd_create(struct xrdp_wm* self)
but->password_char = '*';
/* label */
but = xrdp_bitmap_create(60, 20, self->screen->bpp, WND_TYPE_LABEL);
but = xrdp_bitmap_create(60, 20, self->screen->bpp, WND_TYPE_LABEL, self);
xrdp_list_add_item(self->login_window->child_list, (int)but);
but->parent = self->login_window;
but->owner = self->login_window;
but->wm = self;
but->left = 155;
but->top = 110;
g_strcpy(but->caption, "Module");
/* combo */
but = xrdp_bitmap_create(140, 20, self->screen->bpp, WND_TYPE_COMBO);
but = xrdp_bitmap_create(140, 20, self->screen->bpp, WND_TYPE_COMBO, self);
xrdp_list_add_item(self->login_window->child_list, (int)but);
but->parent = self->login_window;
but->owner = self->login_window;
but->wm = self;
but->left = 220;
but->top = 110;
but->id = 6;
@ -587,11 +577,10 @@ int xrdp_login_wnd_create(struct xrdp_wm* self)
xrdp_wm_login_fill_in_combo(self, but);
/* button */
but = xrdp_bitmap_create(60, 25, self->screen->bpp, WND_TYPE_BUTTON);
but = xrdp_bitmap_create(60, 25, self->screen->bpp, WND_TYPE_BUTTON, self);
xrdp_list_add_item(self->login_window->child_list, (int)but);
but->parent = self->login_window;
but->owner = self->login_window;
but->wm = self;
but->left = 180;
but->top = 160;
but->id = 3;
@ -599,11 +588,10 @@ int xrdp_login_wnd_create(struct xrdp_wm* self)
but->tab_stop = 1;
/* button */
but = xrdp_bitmap_create(60, 25, self->screen->bpp, WND_TYPE_BUTTON);
but = xrdp_bitmap_create(60, 25, self->screen->bpp, WND_TYPE_BUTTON, self);
xrdp_list_add_item(self->login_window->child_list, (int)but);
but->parent = self->login_window;
but->owner = self->login_window;
but->wm = self;
but->left = 250;
but->top = 160;
but->id = 2;
@ -611,11 +599,10 @@ int xrdp_login_wnd_create(struct xrdp_wm* self)
but->tab_stop = 1;
/* button */
but = xrdp_bitmap_create(60, 25, self->screen->bpp, WND_TYPE_BUTTON);
but = xrdp_bitmap_create(60, 25, self->screen->bpp, WND_TYPE_BUTTON, self);
xrdp_list_add_item(self->login_window->child_list, (int)but);
but->parent = self->login_window;
but->owner = self->login_window;
but->wm = self;
but->left = 320;
but->top = 160;
but->id = 1;

@ -23,7 +23,9 @@
#include "xrdp.h"
/*****************************************************************************/
struct xrdp_mcs* xrdp_mcs_create(struct xrdp_sec* owner)
struct xrdp_mcs* xrdp_mcs_create(struct xrdp_sec* owner, int sck,
struct stream* client_mcs_data,
struct stream* server_mcs_data)
{
struct xrdp_mcs* self;
@ -31,9 +33,9 @@ struct xrdp_mcs* xrdp_mcs_create(struct xrdp_sec* owner)
self->sec_layer = owner;
self->userid = 1;
self->chanid = 1001;
self->client_mcs_data = &owner->client_mcs_data;
self->server_mcs_data = &owner->server_mcs_data;
self->iso_layer = xrdp_iso_create(self);
self->client_mcs_data = client_mcs_data;
self->server_mcs_data = server_mcs_data;
self->iso_layer = xrdp_iso_create(self, sck);
return self;
}

@ -23,13 +23,14 @@
#include "xrdp.h"
/*****************************************************************************/
struct xrdp_orders* xrdp_orders_create(struct xrdp_process* owner)
struct xrdp_orders* xrdp_orders_create(struct xrdp_process* owner,
struct xrdp_rdp* rdp_layer)
{
struct xrdp_orders* self;
self = (struct xrdp_orders*)g_malloc(sizeof(struct xrdp_orders), 1);
self->pro_layer = owner;
self->rdp_layer = owner->rdp_layer;
self->rdp_layer = rdp_layer;
make_stream(self->out_s);
init_stream(self->out_s, 8192);
return self;
@ -1329,7 +1330,6 @@ int xrdp_orders_send_palette(struct xrdp_orders* self, int* palette,
int len;
int i;
xrdp_wm_send_palette(self->pro_layer->wm);
xrdp_orders_check(self, 2000);
self->order_count++;
order_flags = RDP_ORDER_STANDARD | RDP_ORDER_SECONDARY;

@ -299,7 +299,8 @@ int xrdp_painter_draw_bitmap(struct xrdp_painter* self,
}
if (self->wm->client_info->use_bitmap_cache)
{
palette_id = xrdp_cache_add_palette(self->wm->cache, self->wm->palette);
/*palette_id = xrdp_cache_add_palette(self->wm->cache, self->wm->palette);*/
palette_id = 0;
j = 0;
while (j < to_draw->height)
{
@ -310,7 +311,7 @@ int xrdp_painter_draw_bitmap(struct xrdp_painter* self,
y1 = y + j;
w = MIN(SSW, to_draw->width - i);
h = MIN(SSH, to_draw->height - j);
b = xrdp_bitmap_create(w, h, self->wm->screen->bpp, 0);
b = xrdp_bitmap_create(w, h, self->wm->screen->bpp, 0, self->wm);
#ifdef USE_CRC
xrdp_bitmap_copy_box_with_crc(to_draw, b, i, j, w, h);
#else
@ -386,6 +387,7 @@ int xrdp_painter_draw_bitmap(struct xrdp_painter* self,
}
else /* no bitmap cache */
{
/* make sure there is no waiting orders */
xrdp_orders_force_send(self->orders);
k = 0;
while (xrdp_region_get_rect(region, k, &rect) == 0)
@ -394,7 +396,7 @@ int xrdp_painter_draw_bitmap(struct xrdp_painter* self,
y1 = rect.top;
w = rect.right - rect.left;
h = rect.bottom - rect.top;
b = xrdp_bitmap_create(w, h, self->wm->screen->bpp, 0);
b = xrdp_bitmap_create(w, h, self->wm->screen->bpp, 0, self->wm);
xrdp_bitmap_copy_box(to_draw, b, x1 - x, y1 - y, w, h);
xrdp_wm_send_bitmap(self->wm, b, x1, y1, w, h);
xrdp_bitmap_delete(b);

@ -55,7 +55,7 @@ int xrdp_process_main_loop(struct xrdp_process* self)
make_stream(s);
self->status = 1;
self->rdp_layer = xrdp_rdp_create(self);
self->rdp_layer = xrdp_rdp_create(self, self->sck);
g_tcp_set_non_blocking(self->sck);
if (xrdp_rdp_incoming(self->rdp_layer) == 0)
{
@ -108,8 +108,8 @@ int xrdp_process_main_loop(struct xrdp_process* self)
{
/* only do this once */
DEBUG(("xrdp_process_main_loop up and running\n\r"));
self->orders = xrdp_orders_create(self);
self->wm = xrdp_wm_create(self);
self->orders = xrdp_orders_create(self, self->rdp_layer);
self->wm = xrdp_wm_create(self, &self->rdp_layer->client_info);
xrdp_wm_init(self->wm);
}
}

@ -91,14 +91,14 @@ int xrdp_rdp_read_config(struct xrdp_client_info* client_info)
}
/*****************************************************************************/
struct xrdp_rdp* xrdp_rdp_create(struct xrdp_process* owner)
struct xrdp_rdp* xrdp_rdp_create(struct xrdp_process* owner, int sck)
{
struct xrdp_rdp* self;
self = (struct xrdp_rdp*)g_malloc(sizeof(struct xrdp_rdp), 1);
self->pro_layer = owner;
self->share_id = 66538;
self->sec_layer = xrdp_sec_create(self);
self->sec_layer = xrdp_sec_create(self, sck);
/* read ini settings */
xrdp_rdp_read_config(&self->client_info);
return self;

@ -113,7 +113,7 @@ char lic2[20] =
0x28, 0x14, 0x00, 0x00 };
/*****************************************************************************/
struct xrdp_sec* xrdp_sec_create(struct xrdp_rdp* owner)
struct xrdp_sec* xrdp_sec_create(struct xrdp_rdp* owner, int sck)
{
struct xrdp_sec* self;
@ -123,7 +123,8 @@ struct xrdp_sec* xrdp_sec_create(struct xrdp_rdp* owner)
self->decrypt_rc4_info = g_rc4_info_create();
self->encrypt_rc4_info = g_rc4_info_create();
g_random(self->server_random, 32);
self->mcs_layer = xrdp_mcs_create(self);
self->mcs_layer = xrdp_mcs_create(self, sck, &self->client_mcs_data,
&self->server_mcs_data);
return self;
}

@ -23,14 +23,13 @@
#include "xrdp.h"
/*****************************************************************************/
struct xrdp_tcp* xrdp_tcp_create(struct xrdp_iso* owner)
struct xrdp_tcp* xrdp_tcp_create(struct xrdp_iso* owner, int sck)
{
struct xrdp_tcp* self;
self = (struct xrdp_tcp*)g_malloc(sizeof(struct xrdp_tcp), 1);
self->iso_layer = owner;
/* get sck from xrdp_process */
self->sck = owner->mcs_layer->sec_layer->rdp_layer->pro_layer->sck;
self->sck = sck;
return self;
}
@ -99,31 +98,37 @@ int xrdp_tcp_send(struct xrdp_tcp* self, struct stream* s)
int sent;
len = s->end - s->data;
DEBUG((" in xrdp_tcp_send, gota send %d bytes\n\r", len))
DEBUG((" in xrdp_tcp_send, gota send %d bytes\n\r", len));
total = 0;
while (total < len)
{
if (g_is_term())
{
return 1;
}
sent = g_tcp_send(self->sck, s->data + total, len - total, 0);
if (sent == -1)
{
if (g_tcp_last_error_would_block(self->sck))
{
g_sleep(1);
}
else
{
DEBUG((" error = -1 in xrdp_tcp_send socket %d\n\r", self->sck))
DEBUG((" error = -1 in xrdp_tcp_send socket %d\n\r", self->sck));
return 1;
}
}
else if (sent == 0)
{
DEBUG((" error = 0 in xrdp_tcp_send socket %d\n\r", self->sck))
DEBUG((" error = 0 in xrdp_tcp_send socket %d\n\r", self->sck));
return 1;
}
else
{
total = total + sent;
}
DEBUG((" out xrdp_tcp_send, sent %d bytes ok\n\r", len))
}
DEBUG((" out xrdp_tcp_send, sent %d bytes ok\n\r", len));
return 0;
}

@ -203,6 +203,7 @@ struct xrdp_orders
struct stream* out_s;
struct xrdp_rdp* rdp_layer;
struct xrdp_process* pro_layer; /* owner */
struct xrdp_wm* wm;
char* order_count_ptr; /* pointer to count, set when sending */
int order_count;

@ -23,16 +23,17 @@
#include "xrdp.h"
/*****************************************************************************/
struct xrdp_wm* xrdp_wm_create(struct xrdp_process* owner)
struct xrdp_wm* xrdp_wm_create(struct xrdp_process* owner,
struct xrdp_client_info* client_info)
{
struct xrdp_wm* self;
self = (struct xrdp_wm*)g_malloc(sizeof(struct xrdp_wm), 1);
self->client_info = &owner->rdp_layer->client_info;
self->screen = xrdp_bitmap_create(self->client_info->width,
self->client_info->height,
self->client_info->bpp,
WND_TYPE_SCREEN);
self->client_info = client_info;
self->screen = xrdp_bitmap_create(client_info->width,
client_info->height,
client_info->bpp,
WND_TYPE_SCREEN, self);
self->screen->wm = self;
self->pro_layer = owner;
self->orders = owner->orders;
@ -75,6 +76,11 @@ int xrdp_wm_send_palette(struct xrdp_wm* self)
int color;
struct stream* s;
if (self->client_info->bpp > 8)
{
return 0;
}
xrdp_orders_force_send(self->orders);
make_stream(s);
init_stream(s, 8192);
xrdp_rdp_init_data(self->rdp_layer, s);
@ -92,6 +98,9 @@ int xrdp_wm_send_palette(struct xrdp_wm* self)
s_mark_end(s);
xrdp_rdp_send_data(self->rdp_layer, s, RDP_DATA_PDU_UPDATE);
free_stream(s);
xrdp_orders_init(self->orders);
xrdp_orders_send_palette(self->orders, self->palette, 0);
xrdp_orders_send(self->orders);
return 0;
}
@ -131,7 +140,9 @@ int xrdp_wm_send_bitmap(struct xrdp_wm* self, struct xrdp_bitmap* bitmap,
init_stream(temp_s, 65536);
i = 0;
if (cy <= bitmap->height)
{
i = cy;
}
while (i > 0)
{
total_bufsize = 0;
@ -263,9 +274,13 @@ int xrdp_wm_set_focused(struct xrdp_wm* self, struct xrdp_bitmap* wnd)
struct xrdp_bitmap* focus_in_control;
if (self == 0)
{
return 0;
}
if (self->focused_window == wnd)
{
return 0;
}
focus_out_control = 0;
focus_in_control = 0;
if (self->focused_window != 0)
@ -320,10 +335,14 @@ int xrdp_wm_get_pixel(char* data, int x, int y, int width, int bpp)
start = y * width + x / 2;
shift = x % 2;
if (shift == 0)
{
return (data[start] & 0xf0) >> 4;
}
else
{
return data[start] & 0x0f;
}
}
return 0;
}
@ -447,27 +466,35 @@ int xrdp_wm_init(struct xrdp_wm* self)
char mask[32 * (32 / 8)];
int x;
int y;
int bindex;
int gindex;
int rindex;
if (self->screen->bpp == 8)
{
/* rgb */
self->palette[249] = 0x0000007f;
self->palette[250] = 0x00ff0000;
self->palette[251] = 0x0000ff00;
self->palette[252] = 0x00c0c0c0;
self->palette[253] = 0x00808080;
self->palette[254] = 0x000000ff;
self->palette[255] = 0x00ffffff;
self->black = 0;
self->grey = 252;
self->dark_grey = 253;
self->blue = 254;
self->dark_blue = 249;
self->white = 255;
self->red = 250;
self->green = 251;
/* rgb332 */
for (bindex = 0; bindex < 4; bindex++)
{
for (gindex = 0; gindex < 8; gindex++)
{
for (rindex = 0; rindex < 8; rindex++)
{
self->palette[(bindex << 6) | (gindex << 3) | rindex] =
(((rindex << 5) | (rindex << 2) | (rindex >> 1)) << 16) |
(((gindex << 5) | (gindex << 2) | (gindex >> 1)) << 8) |
((bindex << 6) | (bindex << 4) | (bindex << 2) | (bindex));
}
}
}
self->black = COLOR8(0, 0, 0);
self->grey = COLOR8(0xc0, 0xc0, 0xc0);
self->dark_grey = COLOR8(0x80, 0x80, 0x80);
self->blue = COLOR8(0x00, 0x00, 0xff);
self->dark_blue = COLOR8(0x00, 0x00, 0x7f);
self->white = COLOR8(0xff, 0xff, 0xff);
self->red = COLOR8(0xff, 0x00, 0x00);
self->green = COLOR8(0x00, 0xff, 0x00);
xrdp_wm_send_palette(self);
}
else if (self->screen->bpp == 15)
{
@ -551,7 +578,9 @@ int xrdp_wm_get_vis_region(struct xrdp_wm* self, struct xrdp_bitmap* bitmap,
{
p = (struct xrdp_bitmap*)xrdp_list_get_item(self->screen->child_list, i);
if (p == bitmap || p == bitmap->parent)
{
return 0;
}
MAKERECT(b, p->left, p->top, p->width, p->height);
xrdp_region_subtract_rect(region, &b);
}
@ -576,14 +605,20 @@ struct xrdp_bitmap* xrdp_wm_at_pos(struct xrdp_bitmap* wnd, int x, int y,
y < p->top + p->height)
{
if (wnd1 != 0)
{
*wnd1 = p;
}
q = xrdp_wm_at_pos(p, x - p->left, y - p->top, 0);
if (q == 0)
{
return p;
}
else
{
return q;
}
}
}
return 0;
}
@ -669,13 +704,21 @@ int xrdp_wm_is_rect_vis(struct xrdp_wm* self, struct xrdp_bitmap* wnd,
/* if rect is part off screen */
if (rect->left < 0)
{
return 0;
}
if (rect->top < 0)
{
return 0;
}
if (rect->right >= self->screen->width)
{
return 0;
}
if (rect->bottom >= self->screen->height)
{
return 0;
}
i = xrdp_list_index_of(self->screen->child_list, (int)wnd);
i--;
@ -684,7 +727,9 @@ int xrdp_wm_is_rect_vis(struct xrdp_wm* self, struct xrdp_bitmap* wnd,
b = (struct xrdp_bitmap*)xrdp_list_get_item(self->screen->child_list, i);
MAKERECT(wnd_rect, b->left, b->top, b->width, b->height);
if (rect_intersect(rect, &wnd_rect, 0))
{
return 0;
}
i--;
}
return 1;
@ -739,15 +784,25 @@ int xrdp_wm_mouse_move(struct xrdp_wm* self, int x, int y)
int boxy;
if (self == 0)
{
return 0;
}
if (x < 0)
{
x = 0;
}
if (y < 0)
{
y = 0;
}
if (x >= self->screen->width)
{
x = self->screen->width;
}
if (y >= self->screen->height)
{
y = self->screen->height;
}
self->mouse_x = x;
self->mouse_y = y;
if (self->dragging)
@ -756,7 +811,9 @@ int xrdp_wm_mouse_move(struct xrdp_wm* self, int x, int y)
boxx = self->draggingx - self->draggingdx;
boxy = self->draggingy - self->draggingdy;
if (self->draggingxorstate)
{
xrdp_wm_xor_pat(self, boxx, boxy, self->draggingcx, self->draggingcy);
}
self->draggingx = x;
self->draggingy = y;
boxx = self->draggingx - self->draggingdx;
@ -803,10 +860,14 @@ int xrdp_wm_mouse_move(struct xrdp_wm* self, int x, int y)
xrdp_bitmap_from_screenx(b, x),
xrdp_bitmap_from_screeny(b, y));
if (self->button_down == 0)
{
if (b->notify != 0)
{
b->notify(b->owner, b, 2, x, y);
}
}
}
}
return 0;
}
@ -844,15 +905,25 @@ int xrdp_wm_mouse_click(struct xrdp_wm* self, int x, int y, int but, int down)
int oldy;
if (self == 0)
{
return 0;
}
if (x < 0)
{
x = 0;
}
if (y < 0)
{
y = 0;
}
if (x >= self->screen->width)
{
x = self->screen->width;
}
if (y >= self->screen->height)
{
y = self->screen->height;
}
if (self->dragging && but == 1 && !down && self->dragging_window != 0)
{ /* if done dragging */
self->draggingx = x;
@ -863,7 +934,9 @@ int xrdp_wm_mouse_click(struct xrdp_wm* self, int x, int y, int but, int down)
oldy = self->dragging_window->top;
/* draw xor box one more time */
if (self->draggingxorstate)
{
xrdp_wm_xor_pat(self, newx, newy, self->draggingcx, self->draggingcy);
}
self->draggingxorstate = 0;
/* move screen to new location */
xrdp_wm_move_window(self, self->dragging_window, newx - oldx, newy - oldy);
@ -879,17 +952,29 @@ int xrdp_wm_mouse_click(struct xrdp_wm* self, int x, int y, int but, int down)
if (self->mod->mod_event != 0)
{
if (but == 1 && down)
{
self->mod->mod_event(self->mod, WM_LBUTTONDOWN, x, y);
}
else if (but == 1 && !down)
{
self->mod->mod_event(self->mod, WM_LBUTTONUP, x, y);
}
if (but == 2 && down)
{
self->mod->mod_event(self->mod, WM_RBUTTONDOWN, x, y);
}
else if (but == 2 && !down)
{
self->mod->mod_event(self->mod, WM_RBUTTONUP, x, y);
}
if (but == 3 && down)
{
self->mod->mod_event(self->mod, WM_BUTTON3DOWN, x, y);
}
else if (but == 3 && !down)
{
self->mod->mod_event(self->mod, WM_BUTTON3UP, x, y);
}
if (but == 4)
{
self->mod->mod_event(self->mod, WM_BUTTON4DOWN,
@ -928,9 +1013,12 @@ int xrdp_wm_mouse_click(struct xrdp_wm* self, int x, int y, int but, int down)
if (wnd != 0)
{
if (wnd->modal_dialog != 0) /* if window has a modal dialog */
{
return 0;
}
if (control == wnd)
;
{
}
else if (control->tab_stop)
{
focus_out_control = wnd->focused_control;
@ -947,10 +1035,14 @@ int xrdp_wm_mouse_click(struct xrdp_wm* self, int x, int y, int but, int down)
control->state = 0;
xrdp_bitmap_invalidate(control, 0);
if (control->parent != 0)
{
if (control->parent->notify != 0)
{
/* control can be invalid after this */
control->parent->notify(control->owner, control, 1, x, y);
}
}
}
else if ((control->type == WND_TYPE_BUTTON ||
control->type == WND_TYPE_COMBO) &&
but == 1 && down)
@ -959,8 +1051,10 @@ int xrdp_wm_mouse_click(struct xrdp_wm* self, int x, int y, int but, int down)
control->state = 1;
xrdp_bitmap_invalidate(control, 0);
if (control->type == WND_TYPE_COMBO)
{
xrdp_wm_pu(self, control);
}
}
else if (but == 1 && down)
{
if (self->popup_wnd == 0)
@ -973,8 +1067,10 @@ int xrdp_wm_mouse_click(struct xrdp_wm* self, int x, int y, int but, int down)
newx = self->draggingx - self->draggingdx;
newy = self->draggingy - self->draggingdy;
if (self->draggingxorstate)
{
xrdp_wm_xor_pat(self, newx, newy,
self->draggingcx, self->draggingcy);
}
self->draggingxorstate = 0;
}
self->dragging = 1;
@ -992,12 +1088,14 @@ int xrdp_wm_mouse_click(struct xrdp_wm* self, int x, int y, int but, int down)
}
}
else
{
xrdp_wm_set_focused(self, 0);
}
/* no matter what, mouse is up, reset button_down */
if (but == 1 && !down && self->button_down != 0)
{
self->button_down = 0;
}
return 0;
}
@ -1038,11 +1136,15 @@ int xrdp_wm_key(struct xrdp_wm* self, int device_flags, int scan_code)
self->num_lock,
self->scroll_lock);
if (c != 0)
{
self->mod->mod_event(self->mod, msg, c, 0xffff);
}
else
{
self->mod->mod_event(self->mod, msg, scan_code, device_flags);
}
}
}
else if (self->focused_window != 0)
{
xrdp_bitmap_def_proc(self->focused_window,
@ -1059,11 +1161,17 @@ int xrdp_wm_key_sync(struct xrdp_wm* self, int device_flags, int key_flags)
self->scroll_lock = 0;
self->caps_lock = 0;
if (key_flags & 1)
{
self->scroll_lock = 1;
}
if (key_flags & 2)
{
self->num_lock = 1;
}
if (key_flags & 4)
{
self->caps_lock = 1;
}
return 0;
}
@ -1074,16 +1182,19 @@ int xrdp_wm_pu(struct xrdp_wm* self, struct xrdp_bitmap* control)
int y;
if (self == 0)
{
return 0;
}
if (control == 0)
{
return 0;
}
self->popup_wnd = xrdp_bitmap_create(control->width, 100,
self->screen->bpp,
WND_TYPE_SPECIAL);
WND_TYPE_SPECIAL, self);
self->popup_wnd->popped_from = control;
self->popup_wnd->parent = self->screen;
self->popup_wnd->owner = self->screen;
self->popup_wnd->wm = self;
x = xrdp_bitmap_to_screenx(control, 0);
y = xrdp_bitmap_to_screeny(control, 0);
self->popup_wnd->left = x;

Loading…
Cancel
Save