summaryrefslogtreecommitdiffstats
path: root/xrdp
diff options
context:
space:
mode:
authorjsorg71 <jsorg71>2005-01-15 20:53:02 +0000
committerjsorg71 <jsorg71>2005-01-15 20:53:02 +0000
commitcf3e17cb73984b093ac8e3138a6e3d98171c5253 (patch)
treebc5d3ff0ed6994710aa2b38af6dc4782c160416b /xrdp
parent520301d70aafd53287b0f4d153a2b27dc025ea76 (diff)
downloadxrdp-proprietary-cf3e17cb73984b093ac8e3138a6e3d98171c5253.tar.gz
xrdp-proprietary-cf3e17cb73984b093ac8e3138a6e3d98171c5253.zip
changed the way the palette works in 8 bpp and changed some parameter passing
Diffstat (limited to 'xrdp')
-rw-r--r--xrdp/xrdp.h23
-rw-r--r--xrdp/xrdp_bitmap.c35
-rw-r--r--xrdp/xrdp_cache.c8
-rw-r--r--xrdp/xrdp_defines.h6
-rw-r--r--xrdp/xrdp_iso.c28
-rw-r--r--xrdp/xrdp_login_wnd.c57
-rw-r--r--xrdp/xrdp_mcs.c10
-rw-r--r--xrdp/xrdp_orders.c6
-rw-r--r--xrdp/xrdp_painter.c1094
-rw-r--r--xrdp/xrdp_process.c6
-rw-r--r--xrdp/xrdp_rdp.c4
-rw-r--r--xrdp/xrdp_sec.c5
-rw-r--r--xrdp/xrdp_tcp.c19
-rw-r--r--xrdp/xrdp_types.h1
-rw-r--r--xrdp/xrdp_wm.c167
15 files changed, 807 insertions, 662 deletions
diff --git a/xrdp/xrdp.h b/xrdp/xrdp.h
index 3d8652a5..62295954 100644
--- a/xrdp/xrdp.h
+++ b/xrdp/xrdp.h
@@ -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);
diff --git a/xrdp/xrdp_bitmap.c b/xrdp/xrdp_bitmap.c
index 3b74db34..d157700d 100644
--- a/xrdp/xrdp_bitmap.c
+++ b/xrdp/xrdp_bitmap.c
@@ -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);
}
/*****************************************************************************/
diff --git a/xrdp/xrdp_cache.c b/xrdp/xrdp_cache.c
index 644b98c2..031563f6 100644
--- a/xrdp/xrdp_cache.c
+++ b/xrdp/xrdp_cache.c
@@ -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++)
diff --git a/xrdp/xrdp_defines.h b/xrdp/xrdp_defines.h
index dfc98919..8c754c9c 100644
--- a/xrdp/xrdp_defines.h
+++ b/xrdp/xrdp_defines.h
@@ -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))
diff --git a/xrdp/xrdp_iso.c b/xrdp/xrdp_iso.c
index d9147de4..131fefde 100644
--- a/xrdp/xrdp_iso.c
+++ b/xrdp/xrdp_iso.c
@@ -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;
}
diff --git a/xrdp/xrdp_login_wnd.c b/xrdp/xrdp_login_wnd.c
index 59480195..02499548 100644
--- a/xrdp/xrdp_login_wnd.c
+++ b/xrdp/xrdp_login_wnd.c
@@ -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;
- g_memcpy(wm->palette, palette, 256 * sizeof(int));
- xrdp_cache_add_palette(wm->cache, palette);
+ if (g_memcmp(wm->palette, palette, 255 * sizeof(int)) != 0)
+ {
+ g_memcpy(wm->palette, palette, 256 * sizeof(int));
+ 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;
diff --git a/xrdp/xrdp_mcs.c b/xrdp/xrdp_mcs.c
index 035e5497..e47a36f3 100644
--- a/xrdp/xrdp_mcs.c
+++ b/xrdp/xrdp_mcs.c
@@ -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;
}
diff --git a/xrdp/xrdp_orders.c b/xrdp/xrdp_orders.c
index aeb10bb2..85c7c9ee 100644
--- a/xrdp/xrdp_orders.c
+++ b/xrdp/xrdp_orders.c
@@ -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;
diff --git a/xrdp/xrdp_painter.c b/xrdp/xrdp_painter.c
index 08be1aca..cc585b75 100644
--- a/xrdp/xrdp_painter.c
+++ b/xrdp/xrdp_painter.c
@@ -1,546 +1,548 @@
-/*
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- xrdp: A Remote Desktop Protocol server.
- Copyright (C) Jay Sorg 2004-2005
-
- painter, gc
-
-*/
-
-#include "xrdp.h"
-
-/*****************************************************************************/
-struct xrdp_painter* xrdp_painter_create(struct xrdp_wm* wm)
-{
- struct xrdp_painter* self;
-
- self = (struct xrdp_painter*)g_malloc(sizeof(struct xrdp_painter), 1);
- self->wm = wm;
- self->orders = wm->orders;
- self->rop = 0xcc; /* copy */
- self->font = xrdp_font_create(wm);
- self->clip_children = 1;
- return self;
-}
-
-/*****************************************************************************/
-void xrdp_painter_delete(struct xrdp_painter* self)
-{
- if (self == 0)
- {
- return;
- }
- xrdp_font_delete(self->font);
- g_free(self);
-}
-
-/*****************************************************************************/
-int xrdp_painter_begin_update(struct xrdp_painter* self)
-{
- xrdp_orders_init(self->orders);
- return 0;
-}
-
-/*****************************************************************************/
-int xrdp_painter_end_update(struct xrdp_painter* self)
-{
- xrdp_orders_send(self->orders);
- return 0;
-}
-
-/*****************************************************************************/
-/* returns boolean, true if there is something to draw */
-int xrdp_painter_clip_adj(struct xrdp_painter* self, int* x, int* y,
- int* cx, int* cy)
-{
- int dx;
- int dy;
-
- if (!self->use_clip)
- {
- return 1;
- }
- if (self->clip.left > *x)
- {
- dx = self->clip.left - *x;
- }
- else
- {
- dx = 0;
- }
- if (self->clip.top > *y)
- {
- dy = self->clip.top - *y;
- }
- else
- {
- dy = 0;
- }
- if (*x + *cx > self->clip.right)
- {
- *cx = *cx - ((*x + *cx) - self->clip.right);
- }
- if (*y + *cy > self->clip.bottom)
- {
- *cy = *cy - ((*y + *cy) - self->clip.bottom);
- }
- *cx = *cx - dx;
- *cy = *cy - dy;
- if (*cx <= 0)
- {
- return 0;
- }
- if (*cy <= 0)
- {
- return 0;
- }
- *x = *x + dx;
- *y = *y + dy;
- return 1;
-}
-
-/*****************************************************************************/
-int xrdp_painter_set_clip(struct xrdp_painter* self,
- int x, int y, int cx, int cy)
-{
- self->use_clip = 1;
- self->clip.left = x;
- self->clip.top = y;
- self->clip.right = x + cx;
- self->clip.bottom = y + cy;
- return 0;
-}
-
-/*****************************************************************************/
-int xrdp_painter_clr_clip(struct xrdp_painter* self)
-{
- self->use_clip = 0;
- return 0;
-}
-
-/*****************************************************************************/
-int xrdp_painter_rop(int rop, int src, int dst)
-{
- switch (rop & 0x0f)
- {
- case 0x0: return 0;
- case 0x1: return ~(src | dst);
- case 0x2: return (~src) & dst;
- case 0x3: return ~src;
- case 0x4: return src & (~dst);
- case 0x5: return ~(dst);
- case 0x6: return src ^ dst;
- case 0x7: return ~(src & dst);
- case 0x8: return src & dst;
- case 0x9: return ~(src) ^ dst;
- case 0xa: return dst;
- case 0xb: return (~src) | dst;
- case 0xc: return src;
- case 0xd: return src | (~dst);
- case 0xe: return src | dst;
- case 0xf: return ~0;
- }
- return dst;
-}
-
-/*****************************************************************************/
-/* fill in an area of the screen with one color */
-int xrdp_painter_fill_rect(struct xrdp_painter* self,
- struct xrdp_bitmap* bitmap,
- int x, int y, int cx, int cy)
-{
- int i;
- struct xrdp_region* region;
- struct xrdp_rect rect;
-
- if (!check_bounds(bitmap, &x, &y, &cx, &cy))
- {
- return 0;
- }
- if (!xrdp_painter_clip_adj(self, &x, &y, &cx, &cy))
- {
- return 0;
- }
-
- /* todo data */
-
- if (bitmap->type == WND_TYPE_BITMAP) /* 0 */
- {
- return 0;
- }
- region = xrdp_region_create(self->wm);
- xrdp_wm_get_vis_region(self->wm, bitmap, x, y, cx, cy, region,
- self->clip_children);
- i = 0;
- while (xrdp_region_get_rect(region, i, &rect) == 0)
- {
- if (!ISRECTEMPTY(rect))
- {
- DEBUG(("sending rect order %d %d %d %d\n\r",
- rect.left, rect.top,
- rect.right, rect.bottom));
- xrdp_orders_rect(self->orders, rect.left, rect.top,
- rect.right - rect.left,
- rect.bottom - rect.top,
- self->fg_color, 0);
- }
- i++;
- }
- xrdp_region_delete(region);
- return 0;
-}
-
-/*****************************************************************************/
-/* fill in an area of the screen with opcodes and patterns */
-/* todo, this needs work */
-int xrdp_painter_fill_rect2(struct xrdp_painter* self,
- struct xrdp_bitmap* bitmap,
- int x, int y, int cx, int cy)
-{
- int i;
- struct xrdp_region* region;
- struct xrdp_rect rect;
-
- if (!check_bounds(bitmap, &x, &y, &cx, &cy))
- {
- return 0;
- }
- if (!xrdp_painter_clip_adj(self, &x, &y, &cx, &cy))
- {
- return 0;
- }
-
- /* todo data */
-
- if (bitmap->type == WND_TYPE_BITMAP) /* 0 */
- {
- return 0;
- }
- region = xrdp_region_create(self->wm);
- xrdp_wm_get_vis_region(self->wm, bitmap, x, y, cx, cy, region,
- self->clip_children);
- i = 0;
- while (xrdp_region_get_rect(region, i, &rect) == 0)
- {
- if (!ISRECTEMPTY(rect))
- {
- DEBUG(("sending rect2 order %d %d %d %d\n\r",
- rect.left, rect.top,
- rect.right, rect.bottom));
- xrdp_orders_pat_blt(self->orders, rect.left, rect.top,
- rect.right - rect.left,
- rect.bottom - rect.top,
- self->rop, self->bg_color, self->fg_color,
- &self->brush, 0);
- }
- i++;
- }
- xrdp_region_delete(region);
- return 0;
-}
-
-#define SSW 64
-#define SSH 63
-
-/*****************************************************************************/
-int xrdp_painter_draw_bitmap(struct xrdp_painter* self,
- struct xrdp_bitmap* bitmap,
- struct xrdp_bitmap* to_draw,
- int x, int y, int cx, int cy)
-{
- int i;
- int j;
- int k;
- int w;
- int h;
- int x1;
- int y1;
- int ok;
- int srcx;
- int srcy;
- int bitmap_id;
- int cache_id;
- int cache_idx;
- int palette_id;
- struct xrdp_region* region;
- struct xrdp_rect rect;
- struct xrdp_rect rect1;
- struct xrdp_rect rect2;
- struct xrdp_bitmap* b;
-
- /* todo data */
-
- if (bitmap->type == WND_TYPE_BITMAP)
- {
- return 0;
- }
- region = xrdp_region_create(self->wm);
- xrdp_wm_get_vis_region(self->wm, bitmap, x, y, cx, cy, region,
- self->clip_children);
- b = bitmap;
- while (b != 0)
- {
- x = x + b->left;
- y = y + b->top;
- b = b->parent;
- }
- if (self->wm->client_info->use_bitmap_cache)
- {
- palette_id = xrdp_cache_add_palette(self->wm->cache, self->wm->palette);
- j = 0;
- while (j < to_draw->height)
- {
- i = 0;
- while (i < to_draw->width)
- {
- x1 = x + i;
- 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);
-#ifdef USE_CRC
- xrdp_bitmap_copy_box_with_crc(to_draw, b, i, j, w, h);
-#else
- xrdp_bitmap_copy_box(to_draw, b, i, j, w, h);
-#endif
- bitmap_id = xrdp_cache_add_bitmap(self->wm->cache, b);
- cache_id = HIWORD(bitmap_id);
- cache_idx = LOWORD(bitmap_id);
- k = 0;
- while (xrdp_region_get_rect(region, k, &rect) == 0)
- {
- if (!ISRECTEMPTY(rect))
- {
- MAKERECT(rect1, x1, y1, w, h);
- if (rect_intersect(&rect, &rect1, &rect2))
- {
- ok = 1;
- if (self->use_clip)
- {
- rect = self->clip;
- RECTOFFSET(rect, x, y);
- if (!rect_intersect(&rect2, &rect, &rect1))
- {
- ok = 0;
- }
- }
- else
- {
- rect1 = rect2;
- }
- if (ok)
- {
- rect1.right--;
- rect1.bottom--;
- /* check these so ms client don't crash */
- if (x1 + w >= self->wm->screen->width)
- {
- w = self->wm->screen->width - x1;
- }
- if (y1 + h >= self->wm->screen->height)
- {
- h = self->wm->screen->height - y1;
- }
- if (w > 0 && h > 0 && x1 + w > 0 && y1 + h > 0)
- {
- srcx = 0;
- srcy = 0;
- if (x1 < 0)
- {
- w = w + x1;
- srcx = srcx - x1;
- x1 = 0;
- }
- if (y1 < 0)
- {
- h = h + y1;
- srcy = srcy - y1;
- y1 = 0;
- }
- xrdp_orders_mem_blt(self->orders, cache_id, palette_id,
- x1, y1, w, h, self->rop, srcx, srcy,
- cache_idx, &rect1);
- }
- }
- }
- }
- k++;
- }
- i += SSW;
- }
- j += SSH;
- }
- }
- else /* no bitmap cache */
- {
- xrdp_orders_force_send(self->orders);
- k = 0;
- while (xrdp_region_get_rect(region, k, &rect) == 0)
- {
- x1 = rect.left;
- y1 = rect.top;
- w = rect.right - rect.left;
- h = rect.bottom - rect.top;
- b = xrdp_bitmap_create(w, h, self->wm->screen->bpp, 0);
- 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);
- k++;
- }
- }
- xrdp_region_delete(region);
- return 0;
-}
-
-/*****************************************************************************/
-int xrdp_painter_text_width(struct xrdp_painter* self, char* text)
-{
- int index;
- int rv;
- int len;
- struct xrdp_font_item* font_item;
-
- rv = 0;
- len = g_strlen(text);
- for (index = 0; index < len; index++)
- {
- font_item = self->font->font_items + (unsigned char)text[index];
- rv = rv + font_item->incby;
- }
- return rv;
-}
-
-/*****************************************************************************/
-int xrdp_painter_text_height(struct xrdp_painter* self, char* text)
-{
- int index;
- int rv;
- int len;
- struct xrdp_font_item* font_item;
-
- rv = 0;
- len = g_strlen(text);
- for (index = 0; index < len; index++)
- {
- font_item = self->font->font_items + (unsigned char)text[index];
- rv = MAX(rv, font_item->height);
- }
- return rv;
-}
-
-/*****************************************************************************/
-int xrdp_painter_draw_text(struct xrdp_painter* self,
- struct xrdp_bitmap* bitmap,
- int x, int y, char* text)
-{
- int i;
- int f;
- int c;
- int k;
- int x1;
- int y1;
- int flags;
- int len;
- int index;
- int total_width;
- int total_height;
- char* data;
- struct xrdp_region* region;
- struct xrdp_rect rect;
- struct xrdp_rect clip_rect;
- struct xrdp_rect draw_rect;
- struct xrdp_bitmap* b;
- struct xrdp_font* font;
- struct xrdp_font_item* font_item;
-
- len = g_strlen(text);
- if (len < 1)
- {
- return 0;
- }
-
- /* todo data */
-
- if (bitmap->type == 0)
- {
- return 0;
- }
- font = self->font;
- f = 0;
- k = 0;
- total_width = 0;
- total_height = 0;
- data = (char*)g_malloc(len * 4, 1);
- for (index = 0; index < len; index++)
- {
- font_item = font->font_items + (unsigned char)text[index];
- i = xrdp_cache_add_char(self->wm->cache, font_item);
- f = HIWORD(i);
- c = LOWORD(i);
- data[index * 2] = c;
- data[index * 2 + 1] = k;
- k = font_item->incby;
- total_width += k;
- total_height = MAX(total_height, font_item->height);
- }
- region = xrdp_region_create(self->wm);
- xrdp_wm_get_vis_region(self->wm, bitmap, x, y, total_width, total_height,
- region, self->clip_children);
- b = bitmap;
- while (b != 0)
- {
- x = x + b->left;
- y = y + b->top;
- b = b->parent;
- }
- if (self->use_clip)
- {
- clip_rect = self->clip;
- }
- else
- {
- MAKERECT(clip_rect, 0, 0, bitmap->width, bitmap->height);
- }
- b = bitmap;
- while (b != 0)
- {
- RECTOFFSET(clip_rect, b->left, b->top);
- b = b->parent;
- }
- k = 0;
- while (xrdp_region_get_rect(region, k, &rect) == 0)
- {
- if (!ISRECTEMPTY(rect))
- {
- if (rect_intersect(&rect, &clip_rect, &draw_rect))
- {
- x1 = x;
- y1 = y + total_height;
- draw_rect.right--;
- draw_rect.bottom--;
- flags = 0x03; /* 0x73; TEXT2_IMPLICIT_X and something else */
- xrdp_orders_text(self->orders, f, flags, 0,
- font->color, 0,
- x, y, x + total_width, y + total_height,
- 0, 0, 0, 0, x1, y1, data, len * 2, &draw_rect);
- }
- }
- k++;
- }
- xrdp_region_delete(region);
- g_free(data);
- return 0;
-}
+/*
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ xrdp: A Remote Desktop Protocol server.
+ Copyright (C) Jay Sorg 2004-2005
+
+ painter, gc
+
+*/
+
+#include "xrdp.h"
+
+/*****************************************************************************/
+struct xrdp_painter* xrdp_painter_create(struct xrdp_wm* wm)
+{
+ struct xrdp_painter* self;
+
+ self = (struct xrdp_painter*)g_malloc(sizeof(struct xrdp_painter), 1);
+ self->wm = wm;
+ self->orders = wm->orders;
+ self->rop = 0xcc; /* copy */
+ self->font = xrdp_font_create(wm);
+ self->clip_children = 1;
+ return self;
+}
+
+/*****************************************************************************/
+void xrdp_painter_delete(struct xrdp_painter* self)
+{
+ if (self == 0)
+ {
+ return;
+ }
+ xrdp_font_delete(self->font);
+ g_free(self);
+}
+
+/*****************************************************************************/
+int xrdp_painter_begin_update(struct xrdp_painter* self)
+{
+ xrdp_orders_init(self->orders);
+ return 0;
+}
+
+/*****************************************************************************/
+int xrdp_painter_end_update(struct xrdp_painter* self)
+{
+ xrdp_orders_send(self->orders);
+ return 0;
+}
+
+/*****************************************************************************/
+/* returns boolean, true if there is something to draw */
+int xrdp_painter_clip_adj(struct xrdp_painter* self, int* x, int* y,
+ int* cx, int* cy)
+{
+ int dx;
+ int dy;
+
+ if (!self->use_clip)
+ {
+ return 1;
+ }
+ if (self->clip.left > *x)
+ {
+ dx = self->clip.left - *x;
+ }
+ else
+ {
+ dx = 0;
+ }
+ if (self->clip.top > *y)
+ {
+ dy = self->clip.top - *y;
+ }
+ else
+ {
+ dy = 0;
+ }
+ if (*x + *cx > self->clip.right)
+ {
+ *cx = *cx - ((*x + *cx) - self->clip.right);
+ }
+ if (*y + *cy > self->clip.bottom)
+ {
+ *cy = *cy - ((*y + *cy) - self->clip.bottom);
+ }
+ *cx = *cx - dx;
+ *cy = *cy - dy;
+ if (*cx <= 0)
+ {
+ return 0;
+ }
+ if (*cy <= 0)
+ {
+ return 0;
+ }
+ *x = *x + dx;
+ *y = *y + dy;
+ return 1;
+}
+
+/*****************************************************************************/
+int xrdp_painter_set_clip(struct xrdp_painter* self,
+ int x, int y, int cx, int cy)
+{
+ self->use_clip = 1;
+ self->clip.left = x;
+ self->clip.top = y;
+ self->clip.right = x + cx;
+ self->clip.bottom = y + cy;
+ return 0;
+}
+
+/*****************************************************************************/
+int xrdp_painter_clr_clip(struct xrdp_painter* self)
+{
+ self->use_clip = 0;
+ return 0;
+}
+
+/*****************************************************************************/
+int xrdp_painter_rop(int rop, int src, int dst)
+{
+ switch (rop & 0x0f)
+ {
+ case 0x0: return 0;
+ case 0x1: return ~(src | dst);
+ case 0x2: return (~src) & dst;
+ case 0x3: return ~src;
+ case 0x4: return src & (~dst);
+ case 0x5: return ~(dst);
+ case 0x6: return src ^ dst;
+ case 0x7: return ~(src & dst);
+ case 0x8: return src & dst;
+ case 0x9: return ~(src) ^ dst;
+ case 0xa: return dst;
+ case 0xb: return (~src) | dst;
+ case 0xc: return src;
+ case 0xd: return src | (~dst);
+ case 0xe: return src | dst;
+ case 0xf: return ~0;
+ }
+ return dst;
+}
+
+/*****************************************************************************/
+/* fill in an area of the screen with one color */
+int xrdp_painter_fill_rect(struct xrdp_painter* self,
+ struct xrdp_bitmap* bitmap,
+ int x, int y, int cx, int cy)
+{
+ int i;
+ struct xrdp_region* region;
+ struct xrdp_rect rect;
+
+ if (!check_bounds(bitmap, &x, &y, &cx, &cy))
+ {
+ return 0;
+ }
+ if (!xrdp_painter_clip_adj(self, &x, &y, &cx, &cy))
+ {
+ return 0;
+ }
+
+ /* todo data */
+
+ if (bitmap->type == WND_TYPE_BITMAP) /* 0 */
+ {
+ return 0;
+ }
+ region = xrdp_region_create(self->wm);
+ xrdp_wm_get_vis_region(self->wm, bitmap, x, y, cx, cy, region,
+ self->clip_children);
+ i = 0;
+ while (xrdp_region_get_rect(region, i, &rect) == 0)
+ {
+ if (!ISRECTEMPTY(rect))
+ {
+ DEBUG(("sending rect order %d %d %d %d\n\r",
+ rect.left, rect.top,
+ rect.right, rect.bottom));
+ xrdp_orders_rect(self->orders, rect.left, rect.top,
+ rect.right - rect.left,
+ rect.bottom - rect.top,
+ self->fg_color, 0);
+ }
+ i++;
+ }
+ xrdp_region_delete(region);
+ return 0;
+}
+
+/*****************************************************************************/
+/* fill in an area of the screen with opcodes and patterns */
+/* todo, this needs work */
+int xrdp_painter_fill_rect2(struct xrdp_painter* self,
+ struct xrdp_bitmap* bitmap,
+ int x, int y, int cx, int cy)
+{
+ int i;
+ struct xrdp_region* region;
+ struct xrdp_rect rect;
+
+ if (!check_bounds(bitmap, &x, &y, &cx, &cy))
+ {
+ return 0;
+ }
+ if (!xrdp_painter_clip_adj(self, &x, &y, &cx, &cy))
+ {
+ return 0;
+ }
+
+ /* todo data */
+
+ if (bitmap->type == WND_TYPE_BITMAP) /* 0 */
+ {
+ return 0;
+ }
+ region = xrdp_region_create(self->wm);
+ xrdp_wm_get_vis_region(self->wm, bitmap, x, y, cx, cy, region,
+ self->clip_children);
+ i = 0;
+ while (xrdp_region_get_rect(region, i, &rect) == 0)
+ {
+ if (!ISRECTEMPTY(rect))
+ {
+ DEBUG(("sending rect2 order %d %d %d %d\n\r",
+ rect.left, rect.top,
+ rect.right, rect.bottom));
+ xrdp_orders_pat_blt(self->orders, rect.left, rect.top,
+ rect.right - rect.left,
+ rect.bottom - rect.top,
+ self->rop, self->bg_color, self->fg_color,
+ &self->brush, 0);
+ }
+ i++;
+ }
+ xrdp_region_delete(region);
+ return 0;
+}
+
+#define SSW 64
+#define SSH 63
+
+/*****************************************************************************/
+int xrdp_painter_draw_bitmap(struct xrdp_painter* self,
+ struct xrdp_bitmap* bitmap,
+ struct xrdp_bitmap* to_draw,
+ int x, int y, int cx, int cy)
+{
+ int i;
+ int j;
+ int k;
+ int w;
+ int h;
+ int x1;
+ int y1;
+ int ok;
+ int srcx;
+ int srcy;
+ int bitmap_id;
+ int cache_id;
+ int cache_idx;
+ int palette_id;
+ struct xrdp_region* region;
+ struct xrdp_rect rect;
+ struct xrdp_rect rect1;
+ struct xrdp_rect rect2;
+ struct xrdp_bitmap* b;
+
+ /* todo data */
+
+ if (bitmap->type == WND_TYPE_BITMAP)
+ {
+ return 0;
+ }
+ region = xrdp_region_create(self->wm);
+ xrdp_wm_get_vis_region(self->wm, bitmap, x, y, cx, cy, region,
+ self->clip_children);
+ b = bitmap;
+ while (b != 0)
+ {
+ x = x + b->left;
+ y = y + b->top;
+ b = b->parent;
+ }
+ if (self->wm->client_info->use_bitmap_cache)
+ {
+ /*palette_id = xrdp_cache_add_palette(self->wm->cache, self->wm->palette);*/
+ palette_id = 0;
+ j = 0;
+ while (j < to_draw->height)
+ {
+ i = 0;
+ while (i < to_draw->width)
+ {
+ x1 = x + i;
+ 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, self->wm);
+#ifdef USE_CRC
+ xrdp_bitmap_copy_box_with_crc(to_draw, b, i, j, w, h);
+#else
+ xrdp_bitmap_copy_box(to_draw, b, i, j, w, h);
+#endif
+ bitmap_id = xrdp_cache_add_bitmap(self->wm->cache, b);
+ cache_id = HIWORD(bitmap_id);
+ cache_idx = LOWORD(bitmap_id);
+ k = 0;
+ while (xrdp_region_get_rect(region, k, &rect) == 0)
+ {
+ if (!ISRECTEMPTY(rect))
+ {
+ MAKERECT(rect1, x1, y1, w, h);
+ if (rect_intersect(&rect, &rect1, &rect2))
+ {
+ ok = 1;
+ if (self->use_clip)
+ {
+ rect = self->clip;
+ RECTOFFSET(rect, x, y);
+ if (!rect_intersect(&rect2, &rect, &rect1))
+ {
+ ok = 0;
+ }
+ }
+ else
+ {
+ rect1 = rect2;
+ }
+ if (ok)
+ {
+ rect1.right--;
+ rect1.bottom--;
+ /* check these so ms client don't crash */
+ if (x1 + w >= self->wm->screen->width)
+ {
+ w = self->wm->screen->width - x1;
+ }
+ if (y1 + h >= self->wm->screen->height)
+ {
+ h = self->wm->screen->height - y1;
+ }
+ if (w > 0 && h > 0 && x1 + w > 0 && y1 + h > 0)
+ {
+ srcx = 0;
+ srcy = 0;
+ if (x1 < 0)
+ {
+ w = w + x1;
+ srcx = srcx - x1;
+ x1 = 0;
+ }
+ if (y1 < 0)
+ {
+ h = h + y1;
+ srcy = srcy - y1;
+ y1 = 0;
+ }
+ xrdp_orders_mem_blt(self->orders, cache_id, palette_id,
+ x1, y1, w, h, self->rop, srcx, srcy,
+ cache_idx, &rect1);
+ }
+ }
+ }
+ }
+ k++;
+ }
+ i += SSW;
+ }
+ j += SSH;
+ }
+ }
+ 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)
+ {
+ x1 = rect.left;
+ y1 = rect.top;
+ w = rect.right - rect.left;
+ h = rect.bottom - rect.top;
+ 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);
+ k++;
+ }
+ }
+ xrdp_region_delete(region);
+ return 0;
+}
+
+/*****************************************************************************/
+int xrdp_painter_text_width(struct xrdp_painter* self, char* text)
+{
+ int index;
+ int rv;
+ int len;
+ struct xrdp_font_item* font_item;
+
+ rv = 0;
+ len = g_strlen(text);
+ for (index = 0; index < len; index++)
+ {
+ font_item = self->font->font_items + (unsigned char)text[index];
+ rv = rv + font_item->incby;
+ }
+ return rv;
+}
+
+/*****************************************************************************/
+int xrdp_painter_text_height(struct xrdp_painter* self, char* text)
+{
+ int index;
+ int rv;
+ int len;
+ struct xrdp_font_item* font_item;
+
+ rv = 0;
+ len = g_strlen(text);
+ for (index = 0; index < len; index++)
+ {
+ font_item = self->font->font_items + (unsigned char)text[index];
+ rv = MAX(rv, font_item->height);
+ }
+ return rv;
+}
+
+/*****************************************************************************/
+int xrdp_painter_draw_text(struct xrdp_painter* self,
+ struct xrdp_bitmap* bitmap,
+ int x, int y, char* text)
+{
+ int i;
+ int f;
+ int c;
+ int k;
+ int x1;
+ int y1;
+ int flags;
+ int len;
+ int index;
+ int total_width;
+ int total_height;
+ char* data;
+ struct xrdp_region* region;
+ struct xrdp_rect rect;
+ struct xrdp_rect clip_rect;
+ struct xrdp_rect draw_rect;
+ struct xrdp_bitmap* b;
+ struct xrdp_font* font;
+ struct xrdp_font_item* font_item;
+
+ len = g_strlen(text);
+ if (len < 1)
+ {
+ return 0;
+ }
+
+ /* todo data */
+
+ if (bitmap->type == 0)
+ {
+ return 0;
+ }
+ font = self->font;
+ f = 0;
+ k = 0;
+ total_width = 0;
+ total_height = 0;
+ data = (char*)g_malloc(len * 4, 1);
+ for (index = 0; index < len; index++)
+ {
+ font_item = font->font_items + (unsigned char)text[index];
+ i = xrdp_cache_add_char(self->wm->cache, font_item);
+ f = HIWORD(i);
+ c = LOWORD(i);
+ data[index * 2] = c;
+ data[index * 2 + 1] = k;
+ k = font_item->incby;
+ total_width += k;
+ total_height = MAX(total_height, font_item->height);
+ }
+ region = xrdp_region_create(self->wm);
+ xrdp_wm_get_vis_region(self->wm, bitmap, x, y, total_width, total_height,
+ region, self->clip_children);
+ b = bitmap;
+ while (b != 0)
+ {
+ x = x + b->left;
+ y = y + b->top;
+ b = b->parent;
+ }
+ if (self->use_clip)
+ {
+ clip_rect = self->clip;
+ }
+ else
+ {
+ MAKERECT(clip_rect, 0, 0, bitmap->width, bitmap->height);
+ }
+ b = bitmap;
+ while (b != 0)
+ {
+ RECTOFFSET(clip_rect, b->left, b->top);
+ b = b->parent;
+ }
+ k = 0;
+ while (xrdp_region_get_rect(region, k, &rect) == 0)
+ {
+ if (!ISRECTEMPTY(rect))
+ {
+ if (rect_intersect(&rect, &clip_rect, &draw_rect))
+ {
+ x1 = x;
+ y1 = y + total_height;
+ draw_rect.right--;
+ draw_rect.bottom--;
+ flags = 0x03; /* 0x73; TEXT2_IMPLICIT_X and something else */
+ xrdp_orders_text(self->orders, f, flags, 0,
+ font->color, 0,
+ x, y, x + total_width, y + total_height,
+ 0, 0, 0, 0, x1, y1, data, len * 2, &draw_rect);
+ }
+ }
+ k++;
+ }
+ xrdp_region_delete(region);
+ g_free(data);
+ return 0;
+}
diff --git a/xrdp/xrdp_process.c b/xrdp/xrdp_process.c
index d64f44d1..d619b074 100644
--- a/xrdp/xrdp_process.c
+++ b/xrdp/xrdp_process.c
@@ -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);
}
}
diff --git a/xrdp/xrdp_rdp.c b/xrdp/xrdp_rdp.c
index a9e1f7f1..64929366 100644
--- a/xrdp/xrdp_rdp.c
+++ b/xrdp/xrdp_rdp.c
@@ -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;
diff --git a/xrdp/xrdp_sec.c b/xrdp/xrdp_sec.c
index 15766449..b5a69de9 100644
--- a/xrdp/xrdp_sec.c
+++ b/xrdp/xrdp_sec.c
@@ -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;
}
diff --git a/xrdp/xrdp_tcp.c b/xrdp/xrdp_tcp.c
index 020bf9f1..479b3ae6 100644
--- a/xrdp/xrdp_tcp.c
+++ b/xrdp/xrdp_tcp.c
@@ -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;
}
diff --git a/xrdp/xrdp_types.h b/xrdp/xrdp_types.h
index 16c0f248..db61a603 100644
--- a/xrdp/xrdp_types.h
+++ b/xrdp/xrdp_types.h
@@ -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;
diff --git a/xrdp/xrdp_wm.c b/xrdp/xrdp_wm.c
index 004631f6..23593b64 100644
--- a/xrdp/xrdp_wm.c
+++ b/xrdp/xrdp_wm.c
@@ -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,9 +335,13 @@ 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,12 +605,18 @@ 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,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_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,9 +1035,13 @@ 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) &&
@@ -959,7 +1051,9 @@ 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)
{
@@ -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,9 +1136,13 @@ 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)
@@ -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;