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" #include "os_calls.h"
/* xrdp_tcp.c */ /* 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); void xrdp_tcp_delete(struct xrdp_tcp* self);
int xrdp_tcp_init(struct xrdp_tcp* self, struct stream* s); 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_recv(struct xrdp_tcp* self, struct stream* s, int len);
int xrdp_tcp_send(struct xrdp_tcp* self, struct stream* s); int xrdp_tcp_send(struct xrdp_tcp* self, struct stream* s);
/* xrdp_iso.c */ /* 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); void xrdp_iso_delete(struct xrdp_iso* self);
int xrdp_iso_init(struct xrdp_iso* self, struct stream* s); int xrdp_iso_init(struct xrdp_iso* self, struct stream* s);
int xrdp_iso_recv(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); int xrdp_iso_incoming(struct xrdp_iso* self);
/* xrdp_mcs.c */ /* 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); void xrdp_mcs_delete(struct xrdp_mcs* self);
int xrdp_mcs_init(struct xrdp_mcs* self, struct stream* s); int xrdp_mcs_init(struct xrdp_mcs* self, struct stream* s);
int xrdp_mcs_recv(struct xrdp_mcs* self, struct stream* s, int* chan); 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); int xrdp_mcs_disconnect(struct xrdp_mcs* self);
/* xrdp_sec.c */ /* 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); void xrdp_sec_delete(struct xrdp_sec* self);
int xrdp_sec_init(struct xrdp_sec* self, struct stream* s); int xrdp_sec_init(struct xrdp_sec* self, struct stream* s);
int xrdp_sec_recv(struct xrdp_sec* self, struct stream* s, int* chan); 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); int xrdp_sec_disconnect(struct xrdp_sec* self);
/* xrdp_rdp.c */ /* 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); void xrdp_rdp_delete(struct xrdp_rdp* self);
int xrdp_rdp_init(struct xrdp_rdp* self, struct stream* s); int xrdp_rdp_init(struct xrdp_rdp* self, struct stream* s);
int xrdp_rdp_init_data(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); int xrdp_rdp_disconnect(struct xrdp_rdp* self);
/* xrdp_orders.c */ /* 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); void xrdp_orders_delete(struct xrdp_orders* self);
int xrdp_orders_init(struct xrdp_orders* self); int xrdp_orders_init(struct xrdp_orders* self);
int xrdp_orders_send(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); struct xrdp_font_item* font_item);
/* xrdp_wm.c */ /* 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); void xrdp_wm_delete(struct xrdp_wm* self);
int xrdp_wm_send_palette(struct xrdp_wm* self); int xrdp_wm_send_palette(struct xrdp_wm* self);
int xrdp_wm_init(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 */ /* xrdp_bitmap.c */
struct xrdp_bitmap* xrdp_bitmap_create(int width, int height, int bpp, 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, 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); void xrdp_bitmap_delete(struct xrdp_bitmap* self);
struct xrdp_bitmap* xrdp_bitmap_get_child_by_id(struct xrdp_bitmap* self, struct xrdp_bitmap* xrdp_bitmap_get_child_by_id(struct xrdp_bitmap* self,
int id); int id);

@ -80,7 +80,7 @@ int g_crc_table[256] =
/*****************************************************************************/ /*****************************************************************************/
struct xrdp_bitmap* xrdp_bitmap_create(int width, int height, int bpp, struct xrdp_bitmap* xrdp_bitmap_create(int width, int height, int bpp,
int type) int type, struct xrdp_wm* wm)
{ {
struct xrdp_bitmap* self; struct xrdp_bitmap* self;
int Bpp; 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 = xrdp_list_create();
self->data_list->auto_free = 1; self->data_list->auto_free = 1;
} }
self->wm = wm;
return self; return self;
} }
/*****************************************************************************/ /*****************************************************************************/
struct xrdp_bitmap* xrdp_bitmap_create_with_data(int width, int height, 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; struct xrdp_bitmap* self;
@ -129,6 +131,7 @@ struct xrdp_bitmap* xrdp_bitmap_create_with_data(int width, int height,
self->bpp = bpp; self->bpp = bpp;
self->data = data; self->data = data;
self->do_not_free_data = 1; self->do_not_free_data = 1;
self->wm = wm;
return self; 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 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++) r = (color & 0xff0000) >> 16;
{ g = (color & 0x00ff00) >> 8;
if (color == palette[i]) b = (color & 0x0000ff) >> 0;
{ r = (r >> 5) << 0;
return i; g = (g >> 5) << 3;
} b = (b >> 6) << 6;
} return (b | g | r);
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;
} }
/*****************************************************************************/ /*****************************************************************************/

@ -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 xrdp_cache_add_palette(struct xrdp_cache* self, int* palette)
{ {
int i; int i;
@ -221,11 +223,17 @@ int xrdp_cache_add_palette(struct xrdp_cache* self, int* palette)
int index; int index;
if (self == 0) if (self == 0)
{
return 0; return 0;
}
if (palette == 0) if (palette == 0)
{
return 0; return 0;
}
if (self->wm->screen->bpp > 8) if (self->wm->screen->bpp > 8)
{
return 0; return 0;
}
self->palette_stamp++; self->palette_stamp++;
/* look for match */ /* look for match */
for (i = 0; i < 6; i++) for (i = 0; i < 6; i++)

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

@ -23,13 +23,13 @@
#include "xrdp.h" #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; struct xrdp_iso* self;
self = (struct xrdp_iso*)g_malloc(sizeof(struct xrdp_iso), 1); self = (struct xrdp_iso*)g_malloc(sizeof(struct xrdp_iso), 1);
self->mcs_layer = owner; self->mcs_layer = owner;
self->tcp_layer = xrdp_tcp_create(self); self->tcp_layer = xrdp_tcp_create(self, sck);
return self; return self;
} }
@ -37,7 +37,9 @@ struct xrdp_iso* xrdp_iso_create(struct xrdp_mcs* owner)
void xrdp_iso_delete(struct xrdp_iso* self) void xrdp_iso_delete(struct xrdp_iso* self)
{ {
if (self == 0) if (self == 0)
{
return; return;
}
xrdp_tcp_delete(self->tcp_layer); xrdp_tcp_delete(self->tcp_layer);
g_free(self); g_free(self);
} }
@ -51,20 +53,30 @@ int xrdp_iso_recv_msg(struct xrdp_iso* self, struct stream* s, int* code)
*code = 0; *code = 0;
if (xrdp_tcp_recv(self->tcp_layer, s, 4) != 0) if (xrdp_tcp_recv(self->tcp_layer, s, 4) != 0)
{
return 1; return 1;
}
in_uint8(s, ver); in_uint8(s, ver);
if (ver != 3) if (ver != 3)
{
return 1; return 1;
}
in_uint8s(s, 1); in_uint8s(s, 1);
in_uint16_be(s, len); in_uint16_be(s, len);
if (xrdp_tcp_recv(self->tcp_layer, s, len - 4) != 0) if (xrdp_tcp_recv(self->tcp_layer, s, len - 4) != 0)
{
return 1; return 1;
}
in_uint8s(s, 1); in_uint8s(s, 1);
in_uint8(s, *code); in_uint8(s, *code);
if (*code == ISO_PDU_DT) if (*code == ISO_PDU_DT)
in_uint8s(s, 1) {
in_uint8s(s, 1);
}
else else
{
in_uint8s(s, 5); in_uint8s(s, 5);
}
return 0; return 0;
} }
@ -76,9 +88,13 @@ int xrdp_iso_recv(struct xrdp_iso* self, struct stream* s)
DEBUG((" in xrdp_iso_recv\n\r")); DEBUG((" in xrdp_iso_recv\n\r"));
if (xrdp_iso_recv_msg(self, s, &code) != 0) if (xrdp_iso_recv_msg(self, s, &code) != 0)
{
return 1; return 1;
}
if (code != ISO_PDU_DT) if (code != ISO_PDU_DT)
{
return 1; return 1;
}
DEBUG((" out xrdp_iso_recv\n\r")); DEBUG((" out xrdp_iso_recv\n\r"));
return 0; 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) int xrdp_iso_send_msg(struct xrdp_iso* self, struct stream* s, int code)
{ {
if (xrdp_tcp_init(self->tcp_layer, s) != 0) if (xrdp_tcp_init(self->tcp_layer, s) != 0)
{
return 1; return 1;
}
out_uint8(s, 3); out_uint8(s, 3);
out_uint8(s, 0); out_uint8(s, 0);
out_uint16_be(s, 11); /* length */ 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); out_uint8(s, 0);
s_mark_end(s); s_mark_end(s);
if (xrdp_tcp_send(self->tcp_layer, s) != 0) if (xrdp_tcp_send(self->tcp_layer, s) != 0)
{
return 1; return 1;
}
return 0; 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, ISO_PDU_DT);
out_uint8(s, 0x80); out_uint8(s, 0x80);
if (xrdp_tcp_send(self->tcp_layer, s) != 0) if (xrdp_tcp_send(self->tcp_layer, s) != 0)
{
return 1; return 1;
}
DEBUG((" out xrdp_iso_send\n\r")); DEBUG((" out xrdp_iso_send\n\r"));
return 0; 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; struct xrdp_bitmap* b;
wm = (struct xrdp_wm*)mod->wm; 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_wm_send_bitmap(wm, b, x, y, cx, cy);
xrdp_painter_draw_bitmap((struct xrdp_painter*)mod->painter, xrdp_painter_draw_bitmap((struct xrdp_painter*)mod->painter,
wm->screen, b, x, y, cx, cy); wm->screen, b, x, y, cx, cy);
@ -156,8 +156,11 @@ int server_palette(struct xrdp_mod* mod, int* palette)
struct xrdp_wm* wm; struct xrdp_wm* wm;
wm = (struct xrdp_wm*)mod->wm; wm = (struct xrdp_wm*)mod->wm;
g_memcpy(wm->palette, palette, 256 * sizeof(int)); if (g_memcmp(wm->palette, palette, 255 * sizeof(int)) != 0)
xrdp_cache_add_palette(wm->cache, palette); {
g_memcpy(wm->palette, palette, 256 * sizeof(int));
xrdp_wm_send_palette(wm);
}
return 0; return 0;
} }
@ -178,11 +181,10 @@ int server_error_popup(struct xrdp_mod* mod, char* error, char* caption)
struct xrdp_bitmap* but; struct xrdp_bitmap* but;
wm = (struct xrdp_wm*)mod->wm; 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); xrdp_list_add_item(wm->screen->child_list, (int)wnd);
wnd->parent = wm->screen; wnd->parent = wm->screen;
wnd->owner = wm->screen; wnd->owner = wm->screen;
wnd->wm = wm;
wnd->bg_color = wm->grey; wnd->bg_color = wm->grey;
wnd->left = wm->screen->width / 2 - wnd->width / 2; wnd->left = wm->screen->width / 2 - wnd->width / 2;
wnd->top = wm->screen->height / 2 - wnd->height / 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); g_strcpy(wnd->caption, caption);
/* button */ /* 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); xrdp_list_add_item(wnd->child_list, (int)but);
but->parent = wnd; but->parent = wnd;
but->owner = wnd; but->owner = wnd;
but->wm = wm;
but->left = 180; but->left = 180;
but->top = 160; but->top = 160;
but->id = 1; but->id = 1;
@ -287,23 +288,21 @@ int xrdp_wm_login_notify(struct xrdp_bitmap* wnd,
if (sender->id == 1) /* help button */ if (sender->id == 1) /* help button */
{ {
/* create help screen */ /* 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); xrdp_list_insert_item(wnd->wm->screen->child_list, 0, (int)help);
help->parent = wnd->wm->screen; help->parent = wnd->wm->screen;
help->owner = wnd; help->owner = wnd;
wnd->modal_dialog = help; wnd->modal_dialog = help;
help->wm = wnd->wm;
help->bg_color = wnd->wm->grey; help->bg_color = wnd->wm->grey;
help->left = wnd->wm->screen->width / 2 - help->width / 2; help->left = wnd->wm->screen->width / 2 - help->width / 2;
help->top = wnd->wm->screen->height / 2 - help->height / 2; help->top = wnd->wm->screen->height / 2 - help->height / 2;
help->notify = xrdp_wm_login_help_notify; help->notify = xrdp_wm_login_help_notify;
g_strcpy(help->caption, "Login help"); g_strcpy(help->caption, "Login help");
/* ok button */ /* 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); xrdp_list_insert_item(help->child_list, 0, (int)but);
but->parent = help; but->parent = help;
but->owner = help; but->owner = help;
but->wm = wnd->wm;
but->left = 120; but->left = 120;
but->top = 260; but->top = 260;
but->id = 1; but->id = 1;
@ -485,11 +484,10 @@ int xrdp_login_wnd_create(struct xrdp_wm* self)
/* draw login window */ /* draw login window */
self->login_window = xrdp_bitmap_create(400, 200, self->screen->bpp, 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); xrdp_list_add_item(self->screen->child_list, (int)self->login_window);
self->login_window->parent = self->screen; self->login_window->parent = self->screen;
self->login_window->owner = self->screen; self->login_window->owner = self->screen;
self->login_window->wm = self;
self->login_window->bg_color = self->grey; self->login_window->bg_color = self->grey;
self->login_window->left = self->screen->width / 2 - self->login_window->left = self->screen->width / 2 -
self->login_window->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"); g_strcpy(self->login_window->caption, "Login to xrdp");
/* image */ /* 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); xrdp_bitmap_load(but, "xrdp256.bmp", self->palette);
but->parent = self->screen; but->parent = self->screen;
but->owner = self->screen; but->owner = self->screen;
but->wm = self;
but->left = self->screen->width - but->width; but->left = self->screen->width - but->width;
but->top = self->screen->height - but->height; but->top = self->screen->height - but->height;
xrdp_list_add_item(self->screen->child_list, (int)but); xrdp_list_add_item(self->screen->child_list, (int)but);
/* image */ /* 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); xrdp_bitmap_load(but, "ad256.bmp", self->palette);
but->parent = self->login_window; but->parent = self->login_window;
but->owner = self->login_window; but->owner = self->login_window;
but->wm = self;
but->left = 10; but->left = 10;
but->top = 30; but->top = 30;
xrdp_list_add_item(self->login_window->child_list, (int)but); xrdp_list_add_item(self->login_window->child_list, (int)but);
/* label */ /* 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); xrdp_list_add_item(self->login_window->child_list, (int)but);
but->parent = self->login_window; but->parent = self->login_window;
but->owner = self->login_window; but->owner = self->login_window;
but->wm = self;
but->left = 155; but->left = 155;
but->top = 50; but->top = 50;
g_strcpy(but->caption, "Username"); g_strcpy(but->caption, "Username");
/* edit */ /* 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); xrdp_list_add_item(self->login_window->child_list, (int)but);
but->parent = self->login_window; but->parent = self->login_window;
but->owner = self->login_window; but->owner = self->login_window;
but->wm = self;
but->left = 220; but->left = 220;
but->top = 50; but->top = 50;
but->id = 4; but->id = 4;
@ -542,21 +536,19 @@ int xrdp_login_wnd_create(struct xrdp_wm* self)
self->login_window->focused_control = but; self->login_window->focused_control = but;
/* label */ /* 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); xrdp_list_add_item(self->login_window->child_list, (int)but);
but->parent = self->login_window; but->parent = self->login_window;
but->owner = self->login_window; but->owner = self->login_window;
but->wm = self;
but->left = 155; but->left = 155;
but->top = 80; but->top = 80;
g_strcpy(but->caption, "Password"); g_strcpy(but->caption, "Password");
/* edit */ /* 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); xrdp_list_add_item(self->login_window->child_list, (int)but);
but->parent = self->login_window; but->parent = self->login_window;
but->owner = self->login_window; but->owner = self->login_window;
but->wm = self;
but->left = 220; but->left = 220;
but->top = 80; but->top = 80;
but->id = 5; but->id = 5;
@ -565,21 +557,19 @@ int xrdp_login_wnd_create(struct xrdp_wm* self)
but->password_char = '*'; but->password_char = '*';
/* label */ /* 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); xrdp_list_add_item(self->login_window->child_list, (int)but);
but->parent = self->login_window; but->parent = self->login_window;
but->owner = self->login_window; but->owner = self->login_window;
but->wm = self;
but->left = 155; but->left = 155;
but->top = 110; but->top = 110;
g_strcpy(but->caption, "Module"); g_strcpy(but->caption, "Module");
/* combo */ /* 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); xrdp_list_add_item(self->login_window->child_list, (int)but);
but->parent = self->login_window; but->parent = self->login_window;
but->owner = self->login_window; but->owner = self->login_window;
but->wm = self;
but->left = 220; but->left = 220;
but->top = 110; but->top = 110;
but->id = 6; but->id = 6;
@ -587,11 +577,10 @@ int xrdp_login_wnd_create(struct xrdp_wm* self)
xrdp_wm_login_fill_in_combo(self, but); xrdp_wm_login_fill_in_combo(self, but);
/* button */ /* 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); xrdp_list_add_item(self->login_window->child_list, (int)but);
but->parent = self->login_window; but->parent = self->login_window;
but->owner = self->login_window; but->owner = self->login_window;
but->wm = self;
but->left = 180; but->left = 180;
but->top = 160; but->top = 160;
but->id = 3; but->id = 3;
@ -599,11 +588,10 @@ int xrdp_login_wnd_create(struct xrdp_wm* self)
but->tab_stop = 1; but->tab_stop = 1;
/* button */ /* 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); xrdp_list_add_item(self->login_window->child_list, (int)but);
but->parent = self->login_window; but->parent = self->login_window;
but->owner = self->login_window; but->owner = self->login_window;
but->wm = self;
but->left = 250; but->left = 250;
but->top = 160; but->top = 160;
but->id = 2; but->id = 2;
@ -611,11 +599,10 @@ int xrdp_login_wnd_create(struct xrdp_wm* self)
but->tab_stop = 1; but->tab_stop = 1;
/* button */ /* 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); xrdp_list_add_item(self->login_window->child_list, (int)but);
but->parent = self->login_window; but->parent = self->login_window;
but->owner = self->login_window; but->owner = self->login_window;
but->wm = self;
but->left = 320; but->left = 320;
but->top = 160; but->top = 160;
but->id = 1; but->id = 1;

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

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

File diff suppressed because it is too large Load Diff

@ -55,7 +55,7 @@ int xrdp_process_main_loop(struct xrdp_process* self)
make_stream(s); make_stream(s);
self->status = 1; 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); g_tcp_set_non_blocking(self->sck);
if (xrdp_rdp_incoming(self->rdp_layer) == 0) 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 */ /* only do this once */
DEBUG(("xrdp_process_main_loop up and running\n\r")); DEBUG(("xrdp_process_main_loop up and running\n\r"));
self->orders = xrdp_orders_create(self); self->orders = xrdp_orders_create(self, self->rdp_layer);
self->wm = xrdp_wm_create(self); self->wm = xrdp_wm_create(self, &self->rdp_layer->client_info);
xrdp_wm_init(self->wm); 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; struct xrdp_rdp* self;
self = (struct xrdp_rdp*)g_malloc(sizeof(struct xrdp_rdp), 1); self = (struct xrdp_rdp*)g_malloc(sizeof(struct xrdp_rdp), 1);
self->pro_layer = owner; self->pro_layer = owner;
self->share_id = 66538; self->share_id = 66538;
self->sec_layer = xrdp_sec_create(self); self->sec_layer = xrdp_sec_create(self, sck);
/* read ini settings */ /* read ini settings */
xrdp_rdp_read_config(&self->client_info); xrdp_rdp_read_config(&self->client_info);
return self; return self;

@ -113,7 +113,7 @@ char lic2[20] =
0x28, 0x14, 0x00, 0x00 }; 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; 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->decrypt_rc4_info = g_rc4_info_create();
self->encrypt_rc4_info = g_rc4_info_create(); self->encrypt_rc4_info = g_rc4_info_create();
g_random(self->server_random, 32); 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; return self;
} }

@ -23,14 +23,13 @@
#include "xrdp.h" #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; struct xrdp_tcp* self;
self = (struct xrdp_tcp*)g_malloc(sizeof(struct xrdp_tcp), 1); self = (struct xrdp_tcp*)g_malloc(sizeof(struct xrdp_tcp), 1);
self->iso_layer = owner; self->iso_layer = owner;
/* get sck from xrdp_process */ self->sck = sck;
self->sck = owner->mcs_layer->sec_layer->rdp_layer->pro_layer->sck;
return self; return self;
} }
@ -99,31 +98,37 @@ int xrdp_tcp_send(struct xrdp_tcp* self, struct stream* s)
int sent; int sent;
len = s->end - s->data; 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; total = 0;
while (total < len) while (total < len)
{ {
if (g_is_term()) if (g_is_term())
{
return 1; return 1;
}
sent = g_tcp_send(self->sck, s->data + total, len - total, 0); sent = g_tcp_send(self->sck, s->data + total, len - total, 0);
if (sent == -1) if (sent == -1)
{ {
if (g_tcp_last_error_would_block(self->sck)) if (g_tcp_last_error_would_block(self->sck))
{
g_sleep(1); g_sleep(1);
}
else 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; return 1;
} }
} }
else if (sent == 0) 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; return 1;
} }
else else
{
total = total + sent; 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; return 0;
} }

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

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

Loading…
Cancel
Save