organization and optimazation

This commit is contained in:
jsorg71 2004-10-06 03:35:59 +00:00
parent eeaff18512
commit 82eb62e0cc
11 changed files with 216 additions and 165 deletions

View File

@ -397,3 +397,16 @@
#define RDP_ORDER_FONTCACHE 3
#define RDP_ORDER_RAW_BMPCACHE2 4
#define RDP_ORDER_BMPCACHE2 5
/* drawable types */
#define WND_TYPE_BITMAP 0
#define WND_TYPE_WND 1
#define WND_TYPE_SCREEN 2
#define WND_TYPE_BUTTON 3
#define WND_TYPE_IMAGE 4
#define WND_TYPE_EDIT 5
#define WND_TYPE_LABEL 6
/* button states */
#define BUTTON_STATE_UP 0
#define BUTTON_STATE_DOWN 1

View File

@ -61,15 +61,6 @@ int rect_intersect(struct xrdp_rect* in1, struct xrdp_rect* in2,
return rv;
}
/*****************************************************************************/
int color15(int r, int g, int b)
{
r = r >> 3;
g = g >> 3;
b = b >> 3;
return (r << 10) | (g << 5) | b;
}
/*****************************************************************************/
int color16(int r, int g, int b)
{
@ -84,3 +75,33 @@ int color24(int r, int g, int b)
{
return r | (g << 8) | (b << 16);
}
/*****************************************************************************/
/* adjust the bounds to fit in the bitmap */
/* return false if there is nothing to draw else return true */
int check_bounds(struct xrdp_bitmap* b, int* x, int* y, int* cx, int* cy)
{
if (*x >= b->width)
return 0;
if (*y >= b->height)
return 0;
if (*x < 0)
{
*cx += *x;
*x = 0;
}
if (*y < 0)
{
*cy += *y;
*y = 0;
}
if (*cx <= 0)
return 0;
if (*cy <= 0)
return 0;
if (*x + *cx > b->width)
*cx = b->width - *x;
if (*y + *cy > b->height)
*cy = b->height - *y;
return 1;
}

View File

@ -56,7 +56,7 @@ struct stream
#define make_stream(s) \
{ \
s = (struct stream*)g_malloc(sizeof(struct stream), 1); \
} \
}
/******************************************************************************/
#define init_stream(s, v) \

View File

@ -29,9 +29,9 @@ static struct xrdp_listen* g_listen = 0;
void* xrdp_listen_run(void* in_val)
{
DEBUG(("listener started\n"))
DEBUG(("listener started\n\r"));
xrdp_listen_main_loop(g_listen);
DEBUG(("listener done\n"))
DEBUG(("listener done\n\r"));
return 0;
}

View File

@ -43,36 +43,28 @@
#define DEBUG(args)
#endif
/* other macros */
#undef MIN
#define MIN(x1, x2) ((x1) < (x2) ? (x1) : (x2))
#undef MAX
#define MAX(x1, x2) ((x1) > (x2) ? (x1) : (x2))
#undef HIWORD
#define HIWORD(in) (((in) & 0xffff0000) >> 16)
#undef LOWORD
#define LOWORD(in) ((in) & 0x0000ffff)
#undef MAKELONG
#define MAKELONG(hi, lo) ((((hi) & 0xffff) << 16) | ((lo) & 0xffff))
#undef MAKERECT
#define MAKERECT(r, x, y, cx, cy) \
{ (r).left = x; (r).top = y; (r).right = (x) + (cx); (r).bottom = (y) + (cy); }
#undef ISRECTEMPTY
#define ISRECTEMPTY(r) (((r).right <= (r).left) || ((r).bottom <= (r).top))
#undef RECTOFFSET
#define RECTOFFSET(r, dx, dy) \
{ (r).left += dx; (r).top += dy; (r).right += dx; (r).bottom += dy; }
#undef GETPIXEL8
#define GETPIXEL8(d, x, y, w) (*(((unsigned char*)d) + ((y) * (w) + (x))))
#undef GETPIXEL16
#define GETPIXEL16(d, x, y, w) (*(((unsigned short*)d) + ((y) * (w) + (x))))
#undef GETPIXEL32
#define GETPIXEL32(d, x, y, w) (*(((unsigned long*)d) + ((y) * (w) + (x))))
#undef SETPIXEL8
#define SETPIXEL8(d, x, y, w, v) (*(((unsigned char*)d) + ((y) * (w) + (x))) = (v))
#undef SETPIXEL16
#define SETPIXEL16(d, x, y, w, v) (*(((unsigned short*)d) + ((y) * (w) + (x))) = (v))
#undef SETPIXEL32
#define SETPIXEL32(d, x, y, w, v) (*(((unsigned long*)d) + ((y) * (w) + (x))) = (v))
#define SETPIXEL8(d, x, y, w, v) \
(*(((unsigned char*)d) + ((y) * (w) + (x))) = (v))
#define SETPIXEL16(d, x, y, w, v) \
(*(((unsigned short*)d) + ((y) * (w) + (x))) = (v))
#define SETPIXEL32(d, x, y, w, v) \
(*(((unsigned long*)d) + ((y) * (w) + (x))) = (v))
#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))
/* font macros */
#define FONT_DATASIZE(f) ((((f)->height * (((f)->width + 7) / 8)) + 3) & ~3);
@ -322,6 +314,4 @@ int xrdp_font_item_compare(struct xrdp_font_item* font1,
int rect_contains_pt(struct xrdp_rect* in, int x, int y);
int rect_intersect(struct xrdp_rect* in1, struct xrdp_rect* in2,
struct xrdp_rect* out);
int color15(int r, int g, int b);
int color16(int r, int g, int b);
int color24(int r, int g, int b);
int check_bounds(struct xrdp_bitmap* b, int* x, int* y, int* cx, int* cy);

View File

@ -1,4 +1,3 @@
/*
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
@ -72,13 +71,15 @@ void xrdp_bitmap_delete(struct xrdp_bitmap* self)
}
/*****************************************************************************/
/* if focused is true focus this window else unfocus it */
/* returns error */
int xrdp_bitmap_set_focus(struct xrdp_bitmap* self, int focused)
{
struct xrdp_painter* painter;
if (self == 0)
return 0;
if (self->type != 1)
if (self->type != WND_TYPE_WND) /* 1 */
return 0;
self->focused = focused;
painter = xrdp_painter_create(self->wm);
@ -210,15 +211,15 @@ int xrdp_bitmap_load(struct xrdp_bitmap* self, char* filename, int* palette)
if (self->bpp == 8)
color = xrdp_bitmap_get_index(self, palette, color);
else if (self->bpp == 15)
color = color15((color & 0xff0000) >> 16,
color = COLOR15((color & 0xff0000) >> 16,
(color & 0x00ff00) >> 8,
(color & 0x0000ff) >> 0);
else if (self->bpp == 16)
color = color16((color & 0xff0000) >> 16,
color = COLOR16((color & 0xff0000) >> 16,
(color & 0x00ff00) >> 8,
(color & 0x0000ff) >> 0);
else if (self->bpp == 24)
color = color24((color & 0xff0000) >> 16,
color = COLOR24((color & 0xff0000) >> 16,
(color & 0x00ff00) >> 8,
(color & 0x0000ff) >> 0);
xrdp_bitmap_set_pixel(self, j, i, color);
@ -270,37 +271,55 @@ int xrdp_bitmap_set_pixel(struct xrdp_bitmap* self, int x, int y, int pixel)
}
/*****************************************************************************/
/* copy part of self at x, y to 0, o in dest */
/* returns error */
int xrdp_bitmap_copy_box(struct xrdp_bitmap* self, struct xrdp_bitmap* dest,
int x, int y, int cx, int cy)
{
int i;
int j;
int destx;
int desty;
if (self == 0)
return 0;
return 1;
if (dest == 0)
return 0;
return 1;
if (self->type != WND_TYPE_BITMAP && self->type != WND_TYPE_IMAGE)
return 1;
if (dest->type != WND_TYPE_BITMAP && dest->type != WND_TYPE_IMAGE)
return 1;
if (self->bpp != dest->bpp)
return 0;
return 1;
destx = 0;
desty = 0;
if (!check_bounds(self, &x, &y, &cx, &cy))
return 1;
if (!check_bounds(dest, &destx, &desty, &cx, &cy))
return 1;
if (self->bpp == 24)
{
for (i = 0; i < cy; i++)
for (j = 0; j < cx; j++)
SETPIXEL32(dest->data, j, i, dest->width,
SETPIXEL32(dest->data, j + destx, i + desty, dest->width,
GETPIXEL32(self->data, j + x, i + y, self->width));
}
else
else if (self->bpp == 15 || self->bpp == 16)
{
for (i = 0; i < cy; i++)
{
for (j = 0; j < cx; j++)
{
xrdp_bitmap_set_pixel(dest, j, i,
xrdp_bitmap_get_pixel(self, j + x, i + y));
}
}
SETPIXEL16(dest->data, j + destx, i + desty, dest->width,
GETPIXEL16(self->data, j + x, i + y, self->width));
}
else if (self->bpp == 8)
{
for (i = 0; i < cy; i++)
for (j = 0; j < cx; j++)
SETPIXEL8(dest->data, j + destx, i + desty, dest->width,
GETPIXEL8(self->data, j + x, i + y, self->width));
}
else
return 1;
return 0;
}
@ -325,6 +344,7 @@ int xrdp_bitmap_compare(struct xrdp_bitmap* self, struct xrdp_bitmap* b)
/*****************************************************************************/
/* nil for rect means the whole thing */
/* returns error */
int xrdp_bitmap_invalidate(struct xrdp_bitmap* self, struct xrdp_rect* rect)
{
int i;
@ -337,7 +357,7 @@ int xrdp_bitmap_invalidate(struct xrdp_bitmap* self, struct xrdp_rect* rect)
if (self == 0) /* if no bitmap */
return 0;
if (self->type == 0) /* if bitmap, leave */
if (self->type == WND_TYPE_BITMAP) /* if 0, bitmap, leave */
return 0;
painter = xrdp_painter_create(self->wm);
painter->rop = 0xcc; /* copy */
@ -354,7 +374,7 @@ int xrdp_bitmap_invalidate(struct xrdp_bitmap* self, struct xrdp_rect* rect)
painter->use_clip = 1;
}
xrdp_painter_begin_update(painter);
if (self->type == 1) /* normal window */
if (self->type == WND_TYPE_WND) /* 1 */
{
/* draw grey background */
painter->fg_color = self->bg_color;
@ -397,14 +417,14 @@ int xrdp_bitmap_invalidate(struct xrdp_bitmap* self, struct xrdp_rect* rect)
}
xrdp_painter_draw_text(painter, self, 4, 4, self->title);
}
else if (self->type == 2) /* screen */
else if (self->type == WND_TYPE_SCREEN) /* 2 */
{
painter->fg_color = self->bg_color;
xrdp_painter_fill_rect(painter, self, 0, 0, self->width, self->height);
}
else if (self->type == 3) /* button */
else if (self->type == WND_TYPE_BUTTON) /* 3 */
{
if (self->state == 0) /* button up */
if (self->state == BUTTON_STATE_UP) /* 0 */
{
/* gray box */
painter->fg_color = self->wm->grey;
@ -435,7 +455,7 @@ int xrdp_bitmap_invalidate(struct xrdp_bitmap* self, struct xrdp_rect* rect)
xrdp_painter_draw_text(painter, self, self->width / 2 - w / 2,
self->height / 2 - h / 2, self->title);
}
else if (self->state == 1) /* button down */
else if (self->state == BUTTON_STATE_DOWN) /* 1 */
{
/* gray box */
painter->fg_color = self->wm->grey;
@ -473,12 +493,12 @@ int xrdp_bitmap_invalidate(struct xrdp_bitmap* self, struct xrdp_rect* rect)
(self->height / 2 - h / 2) + 1, self->title);
}
}
else if (self->type == 4) /* image */
else if (self->type == WND_TYPE_IMAGE) /* 4 */
{
xrdp_painter_draw_bitmap(painter, self, self, 0, 0, self->width,
self->height);
}
else if (self->type == 5) /* edit */
else if (self->type == WND_TYPE_EDIT) /* 5 */
{
/* draw gray box */
painter->fg_color = self->wm->grey;
@ -506,7 +526,7 @@ int xrdp_bitmap_invalidate(struct xrdp_bitmap* self, struct xrdp_rect* rect)
painter->fg_color = self->wm->black;
xrdp_painter_fill_rect(painter, self, 1, 1, self->width - 2, 1);
}
else if (self->type == 6) /* label */
else if (self->type == WND_TYPE_LABEL) /* 6 */
{
painter->font->color = self->wm->black;
xrdp_painter_draw_text(painter, self, 0, 0, self->title);

View File

@ -1,4 +1,3 @@
/*
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
@ -60,11 +59,12 @@ int xrdp_cache_add_bitmap(struct xrdp_cache* self, struct xrdp_bitmap* bitmap)
{
int i;
int j;
int min_use;
int oldest;
int cache_id;
int cache_idx;
struct xrdp_bitmap* b;
self->bitmap_stamp++;
/* look for match */
for (i = 0; i < 3; i++)
{
@ -72,35 +72,35 @@ int xrdp_cache_add_bitmap(struct xrdp_cache* self, struct xrdp_bitmap* bitmap)
{
if (xrdp_bitmap_compare(self->bitmap_items[i][j].bitmap, bitmap))
{
self->bitmap_items[i][j].use_count++;
DEBUG(("found bitmap at %d %d\n", i, j));
self->bitmap_items[i][j].stamp = self->bitmap_stamp;
DEBUG(("found bitmap at %d %d\n\r", i, j));
return MAKELONG(i, j);
}
}
}
/* look for least used */
/* look for oldest */
cache_id = 0;
cache_idx = 0;
min_use = 999999;
oldest = 0x7fffffff;
for (i = 0; i < 3; i++)
{
for (j = 0; j < 600; j++)
{
if (self->bitmap_items[i][j].use_count < min_use)
if (self->bitmap_items[i][j].stamp < oldest)
{
min_use = self->bitmap_items[i][j].use_count;
oldest = self->bitmap_items[i][j].stamp;
cache_id = i;
cache_idx = j;
}
}
}
DEBUG(("adding bitmap at %d %d\n", cache_id, cache_idx));
DEBUG(("adding bitmap at %d %d\n\r", cache_id, cache_idx));
/* set, send bitmap and return */
xrdp_bitmap_delete(self->bitmap_items[cache_id][cache_idx].bitmap);
b = xrdp_bitmap_create(bitmap->width, bitmap->height, bitmap->bpp, 0);
xrdp_bitmap_copy_box(bitmap, b, 0, 0, bitmap->width, bitmap->height);
self->bitmap_items[cache_id][cache_idx].bitmap = b;
self->bitmap_items[cache_id][cache_idx].use_count++;
self->bitmap_items[cache_id][cache_idx].stamp = self->bitmap_stamp;
xrdp_orders_send_raw_bitmap(self->orders, b, cache_id, cache_idx);
return MAKELONG(cache_id, cache_idx);
}
@ -109,8 +109,8 @@ int xrdp_cache_add_bitmap(struct xrdp_cache* self, struct xrdp_bitmap* bitmap)
int xrdp_cache_add_palette(struct xrdp_cache* self, int* palette)
{
int i;
int min_use;
int min_use_index;
int oldest;
int index;
if (self == 0)
return 0;
@ -118,33 +118,33 @@ int xrdp_cache_add_palette(struct xrdp_cache* self, int* palette)
return 0;
if (self->wm->screen->bpp > 8)
return 0;
self->palette_stamp++;
/* look for match */
for (i = 0; i < 6; i++)
{
if (g_memcmp(palette, self->palette_items[i].palette,
256 * sizeof(int)) == 0)
{
self->palette_items[i].use_count++;
self->palette_items[i].stamp = self->palette_stamp;
return i;
}
}
/* look for least used */
min_use_index = 0;
min_use = 999999;
/* look for oldest */
index = 0;
oldest = 0x7fffffff;
for (i = 0; i < 6; i++)
{
if (self->palette_items[i].use_count < min_use)
if (self->palette_items[i].stamp < oldest)
{
min_use = self->palette_items[i].use_count;
min_use_index = i;
oldest = self->palette_items[i].stamp;
index = i;
}
}
/* set, send palette and return */
g_memcpy(self->palette_items[min_use_index].palette, palette,
256 * sizeof(int));
self->palette_items[min_use_index].use_count++;
xrdp_orders_send_palette(self->orders, palette, min_use_index);
return min_use_index;
g_memcpy(self->palette_items[index].palette, palette, 256 * sizeof(int));
self->palette_items[index].stamp = self->palette_stamp;
xrdp_orders_send_palette(self->orders, palette, index);
return index;
}
/*****************************************************************************/
@ -153,12 +153,13 @@ int xrdp_cache_add_char(struct xrdp_cache* self,
{
int i;
int j;
int min_use;
int oldest;
int f;
int c;
int datasize;
struct xrdp_font_item* fi;
self->char_stamp++;
/* look for match */
for (i = 7; i < 12; i++)
{
@ -166,23 +167,23 @@ int xrdp_cache_add_char(struct xrdp_cache* self,
{
if (xrdp_font_item_compare(&self->char_items[i][j].font_item, font_item))
{
self->char_items[i][j].use_count++;
self->char_items[i][j].stamp = self->char_stamp;
DEBUG(("found font at %d %d\n\r", i, j));
return MAKELONG(i, j);
}
}
}
/* look for least used */
/* look for oldest */
f = 0;
c = 0;
min_use = 999999;
oldest = 0x7fffffff;
for (i = 7; i < 12; i++)
{
for (j = 0; j < 250; j++)
{
if (self->char_items[i][j].use_count < min_use)
if (self->char_items[i][j].stamp < oldest)
{
min_use = self->char_items[i][j].use_count;
oldest = self->char_items[i][j].stamp;
f = i;
c = j;
}
@ -199,7 +200,7 @@ int xrdp_cache_add_char(struct xrdp_cache* self,
fi->baseline = font_item->baseline;
fi->width = font_item->width;
fi->height = font_item->height;
self->char_items[f][c].use_count++;
self->char_items[f][c].stamp = self->char_stamp;
xrdp_orders_send_font(self->orders, fi, f, c);
return MAKELONG(f, c);
}

View File

@ -1,4 +1,3 @@
/*
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

View File

@ -1,4 +1,3 @@
/*
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
@ -60,6 +59,7 @@ int xrdp_painter_end_update(struct xrdp_painter* self)
}
/*****************************************************************************/
/* 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)
{
@ -145,19 +145,14 @@ int xrdp_painter_fill_rect(struct xrdp_painter* self,
struct xrdp_region* region;
struct xrdp_rect rect;
if (x >= bitmap->width) return 0;
if (y >= bitmap->height) return 0;
if (x < 0) { cx += x; x = 0; }
if (y < 0) { cy += y; y = 0; }
if (cx <= 0) return 0;
if (cy <= 0) return 0;
if (x + cx > bitmap->width) cx = bitmap->width - x;
if (y + cy > bitmap->height) cy = bitmap->height - y;
if (!check_bounds(bitmap, &x, &y, &cx, &cy))
return 0;
if (!xrdp_painter_clip_adj(self, &x, &y, &cx, &cy))
return 0;
if (bitmap->type == 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);
@ -187,26 +182,21 @@ int xrdp_painter_fill_rect2(struct xrdp_painter* self,
struct xrdp_region* region;
struct xrdp_rect rect;
if (x >= bitmap->width) return 0;
if (y >= bitmap->height) return 0;
if (x < 0) { cx += x; x = 0; }
if (y < 0) { cy += y; y = 0; }
if (cx <= 0) return 0;
if (cy <= 0) return 0;
if (x + cx > bitmap->width) cx = bitmap->width - x;
if (y + cy > bitmap->height) cy = bitmap->height - y;
if (!check_bounds(bitmap, &x, &y, &cx, &cy))
return 0;
if (!xrdp_painter_clip_adj(self, &x, &y, &cx, &cy))
return 0;
if (bitmap->type == 0) /* bitmap */
/* 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);
i = 0;
while (xrdp_region_get_rect(region, i, &rect) == 0)
{
DEBUG(("sending rect order %d %d %d %d\n\r", rect.left, rect.top,
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,
@ -216,7 +206,6 @@ int xrdp_painter_fill_rect2(struct xrdp_painter* self,
i++;
}
xrdp_region_delete(region);
return 0;
}
@ -250,7 +239,7 @@ int xrdp_painter_draw_bitmap(struct xrdp_painter* self,
/* todo data */
if (bitmap->type == 0)
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);
@ -435,7 +424,9 @@ int xrdp_painter_draw_text(struct xrdp_painter* self,
if (self->use_clip)
clip_rect = self->clip;
else
{
MAKERECT(clip_rect, 0, 0, bitmap->width, bitmap->height);
}
b = bitmap;
while (b != 0)
{

View File

@ -239,13 +239,13 @@ struct xrdp_orders
struct xrdp_palette_item
{
int use_count;
int stamp;
int palette[256];
};
struct xrdp_bitmap_item
{
int use_count;
int stamp;
struct xrdp_bitmap* bitmap;
};
@ -261,7 +261,7 @@ struct xrdp_font_item
struct xrdp_char_item
{
int use_count;
int stamp;
struct xrdp_font_item font_item;
};
@ -270,8 +270,11 @@ struct xrdp_cache
{
struct xrdp_wm* wm; /* owner */
struct xrdp_orders* orders;
int palette_stamp;
struct xrdp_palette_item palette_items[6];
int bitmap_stamp;
struct xrdp_bitmap_item bitmap_items[3][600];
int char_stamp;
struct xrdp_char_item char_items[12][256];
};

View File

@ -1,4 +1,3 @@
/*
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
@ -211,6 +210,8 @@ int xrdp_wm_login_notify(struct xrdp_bitmap* wnd,
struct xrdp_rect rect;
int i;
if (wnd->modal_dialog != 0 && msg != 100)
return 0;
if (msg == 1) /* click */
{
if (sender->id == 1) /* help button */
@ -427,33 +428,33 @@ int xrdp_wm_init(struct xrdp_wm* self)
}
else if (self->screen->bpp == 15)
{
self->black = color15(0, 0, 0);
self->grey = color15(0xc0, 0xc0, 0xc0);
self->dark_grey = color15(0x80, 0x80, 0x80);
self->blue = color15(0x00, 0x00, 0xff);
self->white = color15(0xff, 0xff, 0xff);
self->red = color15(0xff, 0x00, 0x00);
self->green = color15(0x00, 0xff, 0x00);
self->black = COLOR15(0, 0, 0);
self->grey = COLOR15(0xc0, 0xc0, 0xc0);
self->dark_grey = COLOR15(0x80, 0x80, 0x80);
self->blue = COLOR15(0x00, 0x00, 0xff);
self->white = COLOR15(0xff, 0xff, 0xff);
self->red = COLOR15(0xff, 0x00, 0x00);
self->green = COLOR15(0x00, 0xff, 0x00);
}
else if (self->screen->bpp == 16)
{
self->black = color16(0, 0, 0);
self->grey = color16(0xc0, 0xc0, 0xc0);
self->dark_grey = color16(0x80, 0x80, 0x80);
self->blue = color16(0x00, 0x00, 0xff);
self->white = color16(0xff, 0xff, 0xff);
self->red = color16(0xff, 0x00, 0x00);
self->green = color16(0x00, 0xff, 0x00);
self->black = COLOR16(0, 0, 0);
self->grey = COLOR16(0xc0, 0xc0, 0xc0);
self->dark_grey = COLOR16(0x80, 0x80, 0x80);
self->blue = COLOR16(0x00, 0x00, 0xff);
self->white = COLOR16(0xff, 0xff, 0xff);
self->red = COLOR16(0xff, 0x00, 0x00);
self->green = COLOR16(0x00, 0xff, 0x00);
}
else if (self->screen->bpp == 24)
{
self->black = color24(0, 0, 0);
self->grey = color24(0xc0, 0xc0, 0xc0);
self->dark_grey = color24(0x80, 0x80, 0x80);
self->blue = color24(0x00, 0x00, 0xff);
self->white = color24(0xff, 0xff, 0xff);
self->red = color24(0xff, 0x00, 0x00);
self->green = color24(0x00, 0xff, 0x00);
self->black = COLOR24(0, 0, 0);
self->grey = COLOR24(0xc0, 0xc0, 0xc0);
self->dark_grey = COLOR24(0x80, 0x80, 0x80);
self->blue = COLOR24(0x00, 0x00, 0xff);
self->white = COLOR24(0xff, 0xff, 0xff);
self->red = COLOR24(0xff, 0x00, 0x00);
self->green = COLOR24(0x00, 0xff, 0x00);
}
/* draw login window */
self->login_window = xrdp_bitmap_create(400, 200, self->screen->bpp, 1);
@ -489,6 +490,7 @@ int xrdp_wm_init(struct xrdp_wm* self)
but->top = 30;
xrdp_list_add_item(self->login_window->child_list, (int)but);
/* button */
but = xrdp_bitmap_create(60, 25, self->screen->bpp, 3);
xrdp_list_add_item(self->login_window->child_list, (int)but);
but->parent = self->login_window;
@ -499,6 +501,7 @@ int xrdp_wm_init(struct xrdp_wm* self)
but->id = 1;
g_strcpy(but->title, "Help");
/* button */
but = xrdp_bitmap_create(60, 25, self->screen->bpp, 3);
xrdp_list_add_item(self->login_window->child_list, (int)but);
but->parent = self->login_window;
@ -509,6 +512,7 @@ int xrdp_wm_init(struct xrdp_wm* self)
but->id = 2;
g_strcpy(but->title, "Cancel");
/* button */
but = xrdp_bitmap_create(60, 25, self->screen->bpp, 3);
xrdp_list_add_item(self->login_window->child_list, (int)but);
but->parent = self->login_window;
@ -519,7 +523,8 @@ int xrdp_wm_init(struct xrdp_wm* self)
but->id = 3;
g_strcpy(but->title, "OK");
but = xrdp_bitmap_create(50, 20, self->screen->bpp, 6); /* label */
/* label */
but = xrdp_bitmap_create(60, 20, self->screen->bpp, 6); /* label */
xrdp_list_add_item(self->login_window->child_list, (int)but);
but->parent = self->login_window;
but->owner = self->login_window;
@ -528,6 +533,7 @@ int xrdp_wm_init(struct xrdp_wm* self)
but->top = 50;
g_strcpy(but->title, "Username");
/* edit */
but = xrdp_bitmap_create(140, 20, self->screen->bpp, 5);
xrdp_list_add_item(self->login_window->child_list, (int)but);
but->parent = self->login_window;
@ -538,7 +544,8 @@ int xrdp_wm_init(struct xrdp_wm* self)
but->id = 4;
but->cursor = 1;
but = xrdp_bitmap_create(50, 20, self->screen->bpp, 6); /* label */
/* label */
but = xrdp_bitmap_create(60, 20, self->screen->bpp, 6); /* label */
xrdp_list_add_item(self->login_window->child_list, (int)but);
but->parent = self->login_window;
but->owner = self->login_window;
@ -547,6 +554,7 @@ int xrdp_wm_init(struct xrdp_wm* self)
but->top = 80;
g_strcpy(but->title, "Password");
/* edit */
but = xrdp_bitmap_create(140, 20, self->screen->bpp, 5);
xrdp_list_add_item(self->login_window->child_list, (int)but);
but->parent = self->login_window;
@ -846,8 +854,8 @@ int xrdp_wm_mouse_move(struct xrdp_wm* self, int x, int y)
/*****************************************************************************/
int xrdp_wm_mouse_click(struct xrdp_wm* self, int x, int y, int but, int down)
{
struct xrdp_bitmap* b;
struct xrdp_bitmap* b1;
struct xrdp_bitmap* control;
struct xrdp_bitmap* wnd;
int newx;
int newy;
int oldx;
@ -880,29 +888,34 @@ int xrdp_wm_mouse_click(struct xrdp_wm* self, int x, int y, int but, int down)
self->dragging_window = 0;
self->dragging = 0;
}
b = xrdp_wm_at_pos(self->screen, x, y, &b1);
if (b != 0)
wnd = 0;
control = xrdp_wm_at_pos(self->screen, x, y, &wnd);
if (control != 0)
{
if (b->type == 3 && but == 1 && !down && self->button_down == b)
if (wnd != 0)
if (wnd->modal_dialog != 0) /* if window has a modal dialog */
return 0;
if (control->type == 3 && but == 1 &&
!down && self->button_down == control)
{ /* if clicking up on a button that was clicked down */
self->button_down = 0;
b->state = 0;
xrdp_bitmap_invalidate(b, 0);
if (b->parent != 0)
if (b->parent->notify != 0)
/* b can be invalid after this */
b->parent->notify(b->owner, b, 1, x, y);
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 (b->type == 3 && but == 1 && down)
else if (control->type == 3 && but == 1 && down)
{ /* if clicking down on a button */
self->button_down = b;
b->state = 1;
xrdp_bitmap_invalidate(b, 0);
self->button_down = control;
control->state = 1;
xrdp_bitmap_invalidate(control, 0);
}
else if (but == 1 && down)
{
xrdp_wm_set_focused(self, b1);
if (b->type == 1 && y < (b->top + 21))
xrdp_wm_set_focused(self, wnd);
if (control->type == 1 && y < (control->top + 21))
{ /* if dragging */
if (self->dragging) /* rarely happens */
{
@ -914,15 +927,15 @@ int xrdp_wm_mouse_click(struct xrdp_wm* self, int x, int y, int but, int down)
self->draggingxorstate = 0;
}
self->dragging = 1;
self->dragging_window = b;
self->draggingorgx = b->left;
self->draggingorgy = b->top;
self->dragging_window = control;
self->draggingorgx = control->left;
self->draggingorgy = control->top;
self->draggingx = x;
self->draggingy = y;
self->draggingdx = x - b->left;
self->draggingdy = y - b->top;
self->draggingcx = b->width;
self->draggingcy = b->height;
self->draggingdx = x - control->left;
self->draggingdy = y - control->top;
self->draggingcx = control->width;
self->draggingcy = control->height;
}
}
}