diff options
author | jsorg71 <jsorg71> | 2004-10-01 23:48:09 +0000 |
---|---|---|
committer | jsorg71 <jsorg71> | 2004-10-01 23:48:09 +0000 |
commit | eeaff1851220ab7179c2c0f6c4cc3425a80afb91 (patch) | |
tree | bf782bf450753bdcc546f24c7418361521b62fd5 | |
parent | 5d8d552ebab10176880163dc6453a28a6fb7c6bd (diff) | |
download | xrdp-proprietary-eeaff1851220ab7179c2c0f6c4cc3425a80afb91.tar.gz xrdp-proprietary-eeaff1851220ab7179c2c0f6c4cc3425a80afb91.zip |
some oganization and macros
-rw-r--r-- | xrdp/Makefile | 8 | ||||
-rw-r--r-- | xrdp/funcs.c | 86 | ||||
-rw-r--r-- | xrdp/xrdp.h | 37 | ||||
-rw-r--r-- | xrdp/xrdp_bitmap.c | 61 | ||||
-rw-r--r-- | xrdp/xrdp_painter.c | 42 | ||||
-rw-r--r-- | xrdp/xrdp_rdp.c | 2 | ||||
-rw-r--r-- | xrdp/xrdp_wm.c | 155 |
7 files changed, 220 insertions, 171 deletions
diff --git a/xrdp/Makefile b/xrdp/Makefile index 9898415a..9bc95767 100644 --- a/xrdp/Makefile +++ b/xrdp/Makefile @@ -1,16 +1,18 @@ XRDPOBJ = xrdp.o os_calls.o xrdp_tcp.o xrdp_iso.o xrdp_mcs.o xrdp_sec.o xrdp_rdp.o \ xrdp_process.o xrdp_listen.o xrdp_orders.o xrdp_bitmap.o xrdp_wm.o \ - xrdp_painter.o xrdp_list.o xrdp_region.o xrdp_cache.o xrdp_font.o + xrdp_painter.o xrdp_list.o xrdp_region.o xrdp_cache.o xrdp_font.o \ + funcs.o #CFLAGS = -Wall -O2 -DXRDP_DEBUG CFLAGS = -Wall -O2 -LDFLAGS = -L /usr/gnu/lib -lpthread -lcrypto +LDFLAGS = -L /usr/gnu/lib +LIBS = -lpthread -lcrypto CC = gcc all: xrdp xrdp: $(XRDPOBJ) - $(CC) $(LDFLAGS) -o xrdp $(XRDPOBJ) + $(CC) $(LDFLAGS) -o xrdp $(XRDPOBJ) $(LIBS) clean: rm -f *.o xrdp diff --git a/xrdp/funcs.c b/xrdp/funcs.c new file mode 100644 index 00000000..4dcc7c06 --- /dev/null +++ b/xrdp/funcs.c @@ -0,0 +1,86 @@ + +/* + 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 + + simple functions + +*/ + +#include "xrdp.h" + +/*****************************************************************************/ +int rect_contains_pt(struct xrdp_rect* in, int x, int y) +{ + if (x < in->left) + return 0; + if (y < in->top) + return 0; + if (x >= in->right) + return 0; + if (y >= in->bottom) + return 0; + return 1; +} + +/*****************************************************************************/ +int rect_intersect(struct xrdp_rect* in1, struct xrdp_rect* in2, + struct xrdp_rect* out) +{ + int rv; + struct xrdp_rect dumby; + + if (out == 0) + out = &dumby; + *out = *in1; + if (in2->left > in1->left) + out->left = in2->left; + if (in2->top > in1->top) + out->top = in2->top; + if (in2->right < in1->right) + out->right = in2->right; + if (in2->bottom < in1->bottom) + out->bottom = in2->bottom; + rv = !ISRECTEMPTY(*out); + if (!rv) + g_memset(out, 0, sizeof(struct xrdp_rect)); + 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) +{ + r = r >> 3; + g = g >> 2; + b = b >> 3; + return (r << 11) | (g << 5) | b; +} + +/*****************************************************************************/ +int color24(int r, int g, int b) +{ + return r | (g << 8) | (b << 16); +} diff --git a/xrdp/xrdp.h b/xrdp/xrdp.h index 75b19282..bc4f60bf 100644 --- a/xrdp/xrdp.h +++ b/xrdp/xrdp.h @@ -53,6 +53,26 @@ #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)) /* font macros */ #define FONT_DATASIZE(f) ((((f)->height * (((f)->width + 7) / 8)) + 3) & ~3); @@ -222,15 +242,6 @@ int xrdp_wm_get_vis_region(struct xrdp_wm* self, struct xrdp_bitmap* bitmap, struct xrdp_region* region); 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); -int xrdp_wm_rect(struct xrdp_rect* r, int x, int y, int cx, int cy); -int xrdp_wm_rect_is_empty(struct xrdp_rect* in); -int xrdp_wm_rect_contains_pt(struct xrdp_rect* in, int x, int y); -int xrdp_wm_rect_intersect(struct xrdp_rect* in1, struct xrdp_rect* in2, - struct xrdp_rect* out); -int xrdp_wm_rect_offset(struct xrdp_rect* in, int dx, int dy); -int xrdp_wm_color15(int r, int g, int b); -int xrdp_wm_color16(int r, int g, int b); -int xrdp_wm_color24(int r, int g, int b); /* xrdp_process.c */ struct xrdp_process* xrdp_process_create(struct xrdp_listen* owner); @@ -306,3 +317,11 @@ struct xrdp_font* xrdp_font_create(struct xrdp_wm* wm); void xrdp_font_delete(struct xrdp_font* self); int xrdp_font_item_compare(struct xrdp_font_item* font1, struct xrdp_font_item* font2); + +/* funcs.c */ +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); diff --git a/xrdp/xrdp_bitmap.c b/xrdp/xrdp_bitmap.c index 3b8cff33..597cd218 100644 --- a/xrdp/xrdp_bitmap.c +++ b/xrdp/xrdp_bitmap.c @@ -210,17 +210,17 @@ 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 = xrdp_wm_color15((color & 0xff0000) >> 16, - (color & 0x00ff00) >> 8, - (color & 0x0000ff) >> 0); + color = color15((color & 0xff0000) >> 16, + (color & 0x00ff00) >> 8, + (color & 0x0000ff) >> 0); else if (self->bpp == 16) - color = xrdp_wm_color16((color & 0xff0000) >> 16, - (color & 0x00ff00) >> 8, - (color & 0x0000ff) >> 0); + color = color16((color & 0xff0000) >> 16, + (color & 0x00ff00) >> 8, + (color & 0x0000ff) >> 0); else if (self->bpp == 24) - color = xrdp_wm_color24((color & 0xff0000) >> 16, - (color & 0x00ff00) >> 8, - (color & 0x0000ff) >> 0); + color = color24((color & 0xff0000) >> 16, + (color & 0x00ff00) >> 8, + (color & 0x0000ff) >> 0); xrdp_bitmap_set_pixel(self, j, i, color); } } @@ -241,11 +241,11 @@ int xrdp_bitmap_get_pixel(struct xrdp_bitmap* self, int x, int y) if (x >= 0 && x < self->width && y >= 0 && y < self->height) { if (self->bpp == 8) - return self->data[y * self->width + x]; + return GETPIXEL8(self->data, x, y, self->width); else if (self->bpp == 15 || self->bpp == 16) - return ((short*)self->data)[y * self->width + x]; + return GETPIXEL16(self->data, x, y, self->width); else if (self->bpp == 24) - return ((int*)self->data)[y * self->width + x]; + return GETPIXEL32(self->data, x, y, self->width); } return 0; } @@ -253,14 +253,18 @@ int xrdp_bitmap_get_pixel(struct xrdp_bitmap* self, int x, int y) /*****************************************************************************/ int xrdp_bitmap_set_pixel(struct xrdp_bitmap* self, int x, int y, int pixel) { + if (self == 0) + return 0; + if (self->data == 0) + return 0; if (x >= 0 && x < self->width && y >= 0 && y < self->height) { if (self->bpp == 8) - self->data[y * self->width + x] = pixel; + SETPIXEL8(self->data, x, y, self->width, pixel); else if (self->bpp == 15 || self->bpp == 16) - ((short*)(self->data))[y * self->width + x] = pixel; + SETPIXEL16(self->data, x, y, self->width, pixel); else if (self->bpp == 24) - ((int*)(self->data))[y * self->width + x] = pixel; + SETPIXEL32(self->data, x, y, self->width, pixel); } return 0; } @@ -278,12 +282,23 @@ int xrdp_bitmap_copy_box(struct xrdp_bitmap* self, struct xrdp_bitmap* dest, return 0; if (self->bpp != dest->bpp) return 0; - for (i = 0; i < cy; i++) + + if (self->bpp == 24) { - for (j = 0; j < cx; j++) + for (i = 0; i < cy; i++) + for (j = 0; j < cx; j++) + SETPIXEL32(dest->data, j, i, dest->width, + GETPIXEL32(self->data, j + x, i + y, self->width)); + } + else + { + for (i = 0; i < cy; i++) { - xrdp_bitmap_set_pixel(dest, j, i, - xrdp_bitmap_get_pixel(self, j + x, i + y)); + for (j = 0; j < cx; j++) + { + xrdp_bitmap_set_pixel(dest, j, i, + xrdp_bitmap_get_pixel(self, j + x, i + y)); + } } } return 0; @@ -330,7 +345,7 @@ int xrdp_bitmap_invalidate(struct xrdp_bitmap* self, struct xrdp_rect* rect) painter->use_clip = 0; else { - if (xrdp_wm_rect_is_empty(rect)) + if (ISRECTEMPTY(*rect)) { xrdp_painter_delete(painter); return 0; @@ -507,10 +522,10 @@ int xrdp_bitmap_invalidate(struct xrdp_bitmap* self, struct xrdp_rect* rect) xrdp_bitmap_invalidate(b, 0); else { - xrdp_wm_rect(&r1, b->left, b->top, b->width, b->height); - if (xrdp_wm_rect_intersect(rect, &r1, &r2)) + MAKERECT(r1, b->left, b->top, b->width, b->height); + if (rect_intersect(rect, &r1, &r2)) { - xrdp_wm_rect_offset(&r2, -(b->left), -(b->top)); + RECTOFFSET(r2, -(b->left), -(b->top)); xrdp_bitmap_invalidate(b, &r2); } } diff --git a/xrdp/xrdp_painter.c b/xrdp/xrdp_painter.c index 731a94c0..020f7771 100644 --- a/xrdp/xrdp_painter.c +++ b/xrdp/xrdp_painter.c @@ -280,15 +280,15 @@ int xrdp_painter_draw_bitmap(struct xrdp_painter* self, k = 0; while (xrdp_region_get_rect(region, k, &rect) == 0) { - xrdp_wm_rect(&rect1, x1, y1, w, h); - if (xrdp_wm_rect_intersect(&rect, &rect1, &rect2)) + MAKERECT(rect1, x1, y1, w, h); + if (rect_intersect(&rect, &rect1, &rect2)) { ok = 1; if (self->use_clip) { rect = self->clip; - xrdp_wm_rect_offset(&rect, x, y); - if (!xrdp_wm_rect_intersect(&rect2, &rect, &rect1)) + RECTOFFSET(rect, x, y); + if (!rect_intersect(&rect2, &rect, &rect1)) ok = 0; } else @@ -390,6 +390,8 @@ int xrdp_painter_draw_text(struct xrdp_painter* self, 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; @@ -430,19 +432,31 @@ int xrdp_painter_draw_text(struct xrdp_painter* self, 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) { - x1 = x; - y1 = y; - rect.right--; - rect.bottom--; - flags = 0x03; /* 0x73; TEXT2_IMPLICIT_X and something else */ - xrdp_orders_text(self->orders, f, flags, 0, - font->color, 0, - x1, y1, x1 + total_width, y1 + total_height, - 0, 0, 0, 0, - x1, y1 + total_height, data, len * 2, &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); diff --git a/xrdp/xrdp_rdp.c b/xrdp/xrdp_rdp.c index 2da9de87..e878aaa8 100644 --- a/xrdp/xrdp_rdp.c +++ b/xrdp/xrdp_rdp.c @@ -546,7 +546,7 @@ int xrdp_rdp_process_screen_update(struct xrdp_rdp* self, struct stream* s) in_uint16_le(s, top); in_uint16_le(s, right); in_uint16_le(s, bottom); - xrdp_wm_rect(&rect, left, top, (right - left) + 1, (bottom - top) + 1); + MAKERECT(rect, left, top, (right - left) + 1, (bottom - top) + 1); if (self->up_and_running && self->pro_layer->wm != 0) xrdp_bitmap_invalidate(self->pro_layer->wm->screen, &rect); return 0; diff --git a/xrdp/xrdp_wm.c b/xrdp/xrdp_wm.c index a5176d83..29949984 100644 --- a/xrdp/xrdp_wm.c +++ b/xrdp/xrdp_wm.c @@ -132,30 +132,6 @@ int xrdp_wm_send_bitmap(struct xrdp_wm* self, struct xrdp_bitmap* bitmap, } /*****************************************************************************/ -int xrdp_wm_color15(int r, int g, int b) -{ - r = r >> 3; - g = g >> 3; - b = b >> 3; - return (r << 10) | (g << 5) | b; -} - -/*****************************************************************************/ -int xrdp_wm_color16(int r, int g, int b) -{ - r = r >> 3; - g = g >> 2; - b = b >> 3; - return (r << 11) | (g << 5) | b; -} - -/*****************************************************************************/ -int xrdp_wm_color24(int r, int g, int b) -{ - return r | (g << 8) | (b << 16); -} - -/*****************************************************************************/ /* all login help screen events go here */ int xrdp_wm_login_help_notify(struct xrdp_bitmap* wnd, struct xrdp_bitmap* sender, @@ -284,7 +260,7 @@ int xrdp_wm_login_notify(struct xrdp_bitmap* wnd, b = (struct xrdp_bitmap*) xrdp_list_get_item(wnd->wm->screen->child_list, i); xrdp_list_remove_item(sender->wm->screen->child_list, i); - xrdp_wm_rect(&rect, b->left, b->top, b->width, b->height); + MAKERECT(rect, b->left, b->top, b->width, b->height); xrdp_bitmap_invalidate(wnd->wm->screen, &rect); xrdp_bitmap_delete(sender); wnd->modal_dialog = 0; @@ -451,33 +427,33 @@ int xrdp_wm_init(struct xrdp_wm* self) } else if (self->screen->bpp == 15) { - self->black = xrdp_wm_color15(0, 0, 0); - self->grey = xrdp_wm_color15(0xc0, 0xc0, 0xc0); - self->dark_grey = xrdp_wm_color15(0x80, 0x80, 0x80); - self->blue = xrdp_wm_color15(0x00, 0x00, 0xff); - self->white = xrdp_wm_color15(0xff, 0xff, 0xff); - self->red = xrdp_wm_color15(0xff, 0x00, 0x00); - self->green = xrdp_wm_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 = xrdp_wm_color16(0, 0, 0); - self->grey = xrdp_wm_color16(0xc0, 0xc0, 0xc0); - self->dark_grey = xrdp_wm_color16(0x80, 0x80, 0x80); - self->blue = xrdp_wm_color16(0x00, 0x00, 0xff); - self->white = xrdp_wm_color16(0xff, 0xff, 0xff); - self->red = xrdp_wm_color16(0xff, 0x00, 0x00); - self->green = xrdp_wm_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 = xrdp_wm_color24(0, 0, 0); - self->grey = xrdp_wm_color24(0xc0, 0xc0, 0xc0); - self->dark_grey = xrdp_wm_color24(0x80, 0x80, 0x80); - self->blue = xrdp_wm_color24(0x00, 0x00, 0xff); - self->white = xrdp_wm_color24(0xff, 0xff, 0xff); - self->red = xrdp_wm_color24(0xff, 0x00, 0x00); - self->green = xrdp_wm_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); @@ -606,30 +582,29 @@ int xrdp_wm_get_vis_region(struct xrdp_wm* self, struct xrdp_bitmap* bitmap, struct xrdp_rect b; /* area we are drawing */ - xrdp_wm_rect(&a, bitmap->left + x, bitmap->top + y, cx, cy); - + MAKERECT(a, bitmap->left + x, bitmap->top + y, cx, cy); p = bitmap->parent; while (p != 0) { - xrdp_wm_rect_offset(&a, p->left, p->top); + RECTOFFSET(a, p->left, p->top); p = p->parent; } - + a.left = MAX(self->screen->left, a.left); + a.top = MAX(self->screen->top, a.top); + a.right = MIN(self->screen->left + self->screen->width, a.right); + a.bottom = MIN(self->screen->top + self->screen->height, a.bottom); xrdp_region_add_rect(region, &a); - if (bitmap == self->screen) return 0; - /* loop through all windows in z order */ for (i = 0; i < self->screen->child_list->count; i++) { p = (struct xrdp_bitmap*)xrdp_list_get_item(self->screen->child_list, i); if (p == bitmap || p == bitmap->parent) return 0; - xrdp_wm_rect(&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); } - return 0; } @@ -735,8 +710,7 @@ int xrdp_wm_bitblt(struct xrdp_wm* self, int xrdp_wm_is_rect_vis(struct xrdp_wm* self, struct xrdp_bitmap* wnd, struct xrdp_rect* rect) { - struct xrdp_rect rect1; - struct xrdp_rect rect2; + struct xrdp_rect wnd_rect; struct xrdp_bitmap* b; int i;; @@ -755,8 +729,8 @@ int xrdp_wm_is_rect_vis(struct xrdp_wm* self, struct xrdp_bitmap* wnd, while (i >= 0) { b = (struct xrdp_bitmap*)xrdp_list_get_item(self->screen->child_list, i); - xrdp_wm_rect(&rect1, b->left, b->top, b->width, b->height); - if (xrdp_wm_rect_intersect(rect, &rect1, &rect2)) + MAKERECT(wnd_rect, b->left, b->top, b->width, b->height); + if (rect_intersect(rect, &wnd_rect, 0)) return 0; i--; } @@ -772,11 +746,11 @@ int xrdp_wm_move_window(struct xrdp_wm* self, struct xrdp_bitmap* wnd, struct xrdp_region* r; int i; - xrdp_wm_rect(&rect1, wnd->left, wnd->top, wnd->width, wnd->height); + MAKERECT(rect1, wnd->left, wnd->top, wnd->width, wnd->height); if (xrdp_wm_is_rect_vis(self, wnd, &rect1)) { rect2 = rect1; - xrdp_wm_rect_offset(&rect2, dx, dy); + RECTOFFSET(rect2, dx, dy); if (xrdp_wm_is_rect_vis(self, wnd, &rect2)) { /* if both src and dst are unobscured, we can do a bitblt move */ xrdp_wm_bitblt(self, self->screen, wnd->left + dx, wnd->top + dy, @@ -805,67 +779,6 @@ int xrdp_wm_move_window(struct xrdp_wm* self, struct xrdp_bitmap* wnd, } /*****************************************************************************/ -int xrdp_wm_rect(struct xrdp_rect* r, int x, int y, int cx, int cy) -{ - r->left = x; - r->top = y; - r->right = x + cx; - r->bottom = y + cy; - return 0; -} - -/*****************************************************************************/ -int xrdp_wm_rect_is_empty(struct xrdp_rect* in) -{ - return (in->right <= in->left) || (in->bottom <= in->top); -} - -/*****************************************************************************/ -int xrdp_wm_rect_contains_pt(struct xrdp_rect* in, int x, int y) -{ - if (x < in->left) - return 0; - if (y < in->top) - return 0; - if (x >= in->right) - return 0; - if (y >= in->bottom) - return 0; - return 1; -} - -/*****************************************************************************/ -int xrdp_wm_rect_intersect(struct xrdp_rect* in1, struct xrdp_rect* in2, - struct xrdp_rect* out) -{ - int rv; - - *out = *in1; - if (in2->left > in1->left) - out->left = in2->left; - if (in2->top > in1->top) - out->top = in2->top; - if (in2->right < in1->right) - out->right = in2->right; - if (in2->bottom < in1->bottom) - out->bottom = in2->bottom; - rv = !xrdp_wm_rect_is_empty(out); - if (!rv) - g_memset(out, 0, sizeof(struct xrdp_rect)); - return rv; -} - -/*****************************************************************************/ -int xrdp_wm_rect_offset(struct xrdp_rect* in, int dx, int dy) -{ - in->left += dx; - in->right += dx; - in->top += dy; - in->bottom += dy; - return 0; -} - -/*****************************************************************************/ int xrdp_wm_mouse_move(struct xrdp_wm* self, int x, int y) { struct xrdp_bitmap* b; |