From 06186b0b75d9fa2b87e278b74b43ccff181230c8 Mon Sep 17 00:00:00 2001 From: jsorg71 Date: Sat, 20 Jan 2007 05:14:11 +0000 Subject: moved orders state to one struct --- libxrdp/libxrdp.h | 27 +-- libxrdp/xrdp_orders.c | 494 +++++++++++++++++++++++++------------------------- 2 files changed, 260 insertions(+), 261 deletions(-) (limited to 'libxrdp') diff --git a/libxrdp/libxrdp.h b/libxrdp/libxrdp.h index a4a4a299..12d3c944 100644 --- a/libxrdp/libxrdp.h +++ b/libxrdp/libxrdp.h @@ -116,18 +116,9 @@ struct xrdp_rdp struct xrdp_client_info client_info; }; -/* orders */ -struct xrdp_orders +/* state */ +struct xrdp_orders_state { - struct stream* out_s; - struct xrdp_rdp* rdp_layer; - struct xrdp_session* session; - struct xrdp_wm* wm; - - char* order_count_ptr; /* pointer to count, set when sending */ - int order_count; - int order_level; /* inc for every call to xrdp_orders_init */ - int last_order; /* last order sent */ int clip_left; /* RDP_ORDER_BOUNDS, RDP_ORDER_LASTBOUNDS */ @@ -204,6 +195,20 @@ struct xrdp_orders char* text_data; }; +/* orders */ +struct xrdp_orders +{ + struct stream* out_s; + struct xrdp_rdp* rdp_layer; + struct xrdp_session* session; + struct xrdp_wm* wm; + + char* order_count_ptr; /* pointer to count, set when sending */ + int order_count; + int order_level; /* inc for every call to xrdp_orders_init */ + struct xrdp_orders_state orders_state; +}; + /* xrdp_tcp.c */ struct xrdp_tcp* APP_CC xrdp_tcp_create(struct xrdp_iso* owner, int sck); diff --git a/libxrdp/xrdp_orders.c b/libxrdp/xrdp_orders.c index 7b2994b0..daad906e 100644 --- a/libxrdp/xrdp_orders.c +++ b/libxrdp/xrdp_orders.c @@ -33,8 +33,8 @@ xrdp_orders_create(struct xrdp_session* session, struct xrdp_rdp* rdp_layer) self->rdp_layer = rdp_layer; make_stream(self->out_s); init_stream(self->out_s, 16384); - self->clip_right = 1; /* silly rdp right clip */ - self->clip_bottom = 1; /* silly rdp bottom clip */ + self->orders_state.clip_right = 1; /* silly rdp right clip */ + self->orders_state.clip_bottom = 1; /* silly rdp bottom clip */ return self; } @@ -47,6 +47,7 @@ xrdp_orders_delete(struct xrdp_orders* self) return; } free_stream(self->out_s); + g_free(self->orders_state.text_data); g_free(self); } @@ -56,29 +57,17 @@ xrdp_orders_delete(struct xrdp_orders* self) int APP_CC xrdp_orders_reset(struct xrdp_orders* self) { - struct stream* out_s; - struct xrdp_rdp* rdp_layer; - struct xrdp_session* session; - struct xrdp_wm* wm; - if (xrdp_orders_force_send(self) != 0) { return 1; } - /* save these */ - out_s = self->out_s; - rdp_layer = self->rdp_layer; - session = self->session; - wm = self->wm; - /* set whole struct to zero */ - g_memset(self, 0, sizeof(struct xrdp_orders)); - /* set some stuff back */ - self->out_s = out_s; - self->rdp_layer = rdp_layer; - self->session = session; - self->wm = wm; - self->clip_right = 1; /* silly rdp right clip */ - self->clip_bottom = 1; /* silly rdp bottom clip */ + g_free(self->orders_state.text_data); + g_memset(&(self->orders_state), 0, sizeof(self->orders_state)); + self->order_count_ptr = 0; + self->order_count = 0; + self->order_level = 0; + self->orders_state.clip_right = 1; /* silly rdp right clip */ + self->orders_state.clip_bottom = 1; /* silly rdp bottom clip */ return 0; } @@ -207,10 +196,10 @@ xrdp_orders_last_bounds(struct xrdp_orders* self, struct xrdp_rect* rect) { return 0; } - if (rect->left == self->clip_left && - rect->top == self->clip_top && - rect->right == self->clip_right && - rect->bottom == self->clip_bottom) + if (rect->left == self->orders_state.clip_left && + rect->top == self->orders_state.clip_top && + rect->right == self->orders_state.clip_right && + rect->bottom == self->orders_state.clip_bottom) { return 1; } @@ -247,10 +236,10 @@ xrdp_orders_out_bounds(struct xrdp_orders* self, struct xrdp_rect* rect) bounds_flags_ptr = self->out_s->p; out_uint8s(self->out_s, 1); /* left */ - if (rect->left == self->clip_left) + if (rect->left == self->orders_state.clip_left) { } - else if (g_abs(rect->left - self->clip_left) < 128) + else if (g_abs(rect->left - self->orders_state.clip_left) < 128) { bounds_flags |= 0x10; } @@ -259,10 +248,10 @@ xrdp_orders_out_bounds(struct xrdp_orders* self, struct xrdp_rect* rect) bounds_flags |= 0x01; } /* top */ - if (rect->top == self->clip_top) + if (rect->top == self->orders_state.clip_top) { } - else if (g_abs(rect->top - self->clip_top) < 128) + else if (g_abs(rect->top - self->orders_state.clip_top) < 128) { bounds_flags |= 0x20; } @@ -271,10 +260,10 @@ xrdp_orders_out_bounds(struct xrdp_orders* self, struct xrdp_rect* rect) bounds_flags |= 0x02; } /* right */ - if (rect->right == self->clip_right) + if (rect->right == self->orders_state.clip_right) { } - else if (g_abs(rect->right - self->clip_right) < 128) + else if (g_abs(rect->right - self->orders_state.clip_right) < 128) { bounds_flags |= 0x40; } @@ -283,10 +272,10 @@ xrdp_orders_out_bounds(struct xrdp_orders* self, struct xrdp_rect* rect) bounds_flags |= 0x04; } /* bottom */ - if (rect->bottom == self->clip_bottom) + if (rect->bottom == self->orders_state.clip_bottom) { } - else if (g_abs(rect->bottom - self->clip_bottom) < 128) + else if (g_abs(rect->bottom - self->orders_state.clip_bottom) < 128) { bounds_flags |= 0x80; } @@ -301,9 +290,9 @@ xrdp_orders_out_bounds(struct xrdp_orders* self, struct xrdp_rect* rect) } else if (bounds_flags & 0x10) { - out_uint8(self->out_s, rect->left - self->clip_left); + out_uint8(self->out_s, rect->left - self->orders_state.clip_left); } - self->clip_left = rect->left; + self->orders_state.clip_left = rect->left; /* top */ if (bounds_flags & 0x02) { @@ -311,9 +300,9 @@ xrdp_orders_out_bounds(struct xrdp_orders* self, struct xrdp_rect* rect) } else if (bounds_flags & 0x20) { - out_uint8(self->out_s, rect->top - self->clip_top); + out_uint8(self->out_s, rect->top - self->orders_state.clip_top); } - self->clip_top = rect->top; + self->orders_state.clip_top = rect->top; /* right */ if (bounds_flags & 0x04) { @@ -321,9 +310,9 @@ xrdp_orders_out_bounds(struct xrdp_orders* self, struct xrdp_rect* rect) } else if (bounds_flags & 0x40) { - out_uint8(self->out_s, rect->right - self->clip_right); + out_uint8(self->out_s, rect->right - self->orders_state.clip_right); } - self->clip_right = rect->right; + self->orders_state.clip_right = rect->right; /* bottom */ if (bounds_flags & 0x08) { @@ -331,9 +320,9 @@ xrdp_orders_out_bounds(struct xrdp_orders* self, struct xrdp_rect* rect) } else if (bounds_flags & 0x80) { - out_uint8(self->out_s, rect->bottom - self->clip_bottom); + out_uint8(self->out_s, rect->bottom - self->orders_state.clip_bottom); } - self->clip_bottom = rect->bottom; + self->orders_state.clip_bottom = rect->bottom; /* set flags */ *bounds_flags_ptr = bounds_flags; return 0; @@ -355,11 +344,11 @@ xrdp_orders_rect(struct xrdp_orders* self, int x, int y, int cx, int cy, xrdp_orders_check(self, 23); self->order_count++; order_flags = RDP_ORDER_STANDARD; - if (self->last_order != RDP_ORDER_RECT) + if (self->orders_state.last_order != RDP_ORDER_RECT) { order_flags |= RDP_ORDER_CHANGE; } - self->last_order = RDP_ORDER_RECT; + self->orders_state.last_order = RDP_ORDER_RECT; if (rect != 0) { /* if clip is present, still check if its needed */ @@ -374,13 +363,13 @@ xrdp_orders_rect(struct xrdp_orders* self, int x, int y, int cx, int cy, } } vals[0] = x; - vals[1] = self->rect_x; + vals[1] = self->orders_state.rect_x; vals[2] = y; - vals[3] = self->rect_y; + vals[3] = self->orders_state.rect_y; vals[4] = cx; - vals[5] = self->rect_cx; + vals[5] = self->orders_state.rect_cx; vals[6] = cy; - vals[7] = self->rect_cy; + vals[7] = self->orders_state.rect_cy; if (xrdp_orders_send_delta(self, vals, 8)) { order_flags |= RDP_ORDER_DELTA; @@ -388,7 +377,7 @@ xrdp_orders_rect(struct xrdp_orders* self, int x, int y, int cx, int cy, out_uint8(self->out_s, order_flags) if (order_flags & RDP_ORDER_CHANGE) { - out_uint8(self->out_s, self->last_order); + out_uint8(self->out_s, self->orders_state.last_order); } present = 0; present_ptr = self->out_s->p; /* hold 1 byte present pointer */ @@ -398,74 +387,77 @@ xrdp_orders_rect(struct xrdp_orders* self, int x, int y, int cx, int cy, { xrdp_orders_out_bounds(self, rect); } - if (x != self->rect_x) + if (x != self->orders_state.rect_x) { present |= 0x01; if (order_flags & RDP_ORDER_DELTA) { - out_uint8(self->out_s, x - self->rect_x); + out_uint8(self->out_s, x - self->orders_state.rect_x); } else { out_uint16_le(self->out_s, x); } - self->rect_x = x; + self->orders_state.rect_x = x; } - if (y != self->rect_y) + if (y != self->orders_state.rect_y) { present |= 0x02; if (order_flags & RDP_ORDER_DELTA) { - out_uint8(self->out_s, y - self->rect_y); + out_uint8(self->out_s, y - self->orders_state.rect_y); } else { out_uint16_le(self->out_s, y); } - self->rect_y = y; + self->orders_state.rect_y = y; } - if (cx != self->rect_cx) + if (cx != self->orders_state.rect_cx) { present |= 0x04; if (order_flags & RDP_ORDER_DELTA) { - out_uint8(self->out_s, cx - self->rect_cx); + out_uint8(self->out_s, cx - self->orders_state.rect_cx); } else { out_uint16_le(self->out_s, cx); } - self->rect_cx = cx; + self->orders_state.rect_cx = cx; } - if (cy != self->rect_cy) + if (cy != self->orders_state.rect_cy) { present |= 0x08; if (order_flags & RDP_ORDER_DELTA) { - out_uint8(self->out_s, cy - self->rect_cy); + out_uint8(self->out_s, cy - self->orders_state.rect_cy); } else { out_uint16_le(self->out_s, cy); } - self->rect_cy = cy; + self->orders_state.rect_cy = cy; } - if ((color & 0xff) != (self->rect_color & 0xff)) + if ((color & 0xff) != (self->orders_state.rect_color & 0xff)) { present |= 0x10; - self->rect_color = (self->rect_color & 0xffff00) | (color & 0xff); + self->orders_state.rect_color = + (self->orders_state.rect_color & 0xffff00) | (color & 0xff); out_uint8(self->out_s, color); } - if ((color & 0xff00) != (self->rect_color & 0xff00)) + if ((color & 0xff00) != (self->orders_state.rect_color & 0xff00)) { present |= 0x20; - self->rect_color = (self->rect_color & 0xff00ff) | (color & 0xff00); + self->orders_state.rect_color = + (self->orders_state.rect_color & 0xff00ff) | (color & 0xff00); out_uint8(self->out_s, color >> 8); } - if ((color & 0xff0000) != (self->rect_color & 0xff0000)) + if ((color & 0xff0000) != (self->orders_state.rect_color & 0xff0000)) { present |= 0x40; - self->rect_color = (self->rect_color & 0x00ffff) | (color & 0xff0000); + self->orders_state.rect_color = + (self->orders_state.rect_color & 0x00ffff) | (color & 0xff0000); out_uint8(self->out_s, color >> 16); } present_ptr[0] = present; @@ -489,11 +481,11 @@ xrdp_orders_screen_blt(struct xrdp_orders* self, int x, int y, xrdp_orders_check(self, 25); self->order_count++; order_flags = RDP_ORDER_STANDARD; - if (self->last_order != RDP_ORDER_SCREENBLT) + if (self->orders_state.last_order != RDP_ORDER_SCREENBLT) { order_flags |= RDP_ORDER_CHANGE; } - self->last_order = RDP_ORDER_SCREENBLT; + self->orders_state.last_order = RDP_ORDER_SCREENBLT; if (rect != 0) { /* if clip is present, still check if its needed */ @@ -508,17 +500,17 @@ xrdp_orders_screen_blt(struct xrdp_orders* self, int x, int y, } } vals[0] = x; - vals[1] = self->scr_blt_x; + vals[1] = self->orders_state.scr_blt_x; vals[2] = y; - vals[3] = self->scr_blt_y; + vals[3] = self->orders_state.scr_blt_y; vals[4] = cx; - vals[5] = self->scr_blt_cx; + vals[5] = self->orders_state.scr_blt_cx; vals[6] = cy; - vals[7] = self->scr_blt_cy; + vals[7] = self->orders_state.scr_blt_cy; vals[8] = srcx; - vals[9] = self->scr_blt_srcx; + vals[9] = self->orders_state.scr_blt_srcx; vals[10] = srcy; - vals[11] = self->scr_blt_srcy; + vals[11] = self->orders_state.scr_blt_srcy; if (xrdp_orders_send_delta(self, vals, 12)) { order_flags |= RDP_ORDER_DELTA; @@ -526,7 +518,7 @@ xrdp_orders_screen_blt(struct xrdp_orders* self, int x, int y, out_uint8(self->out_s, order_flags); if (order_flags & RDP_ORDER_CHANGE) { - out_uint8(self->out_s, self->last_order); + out_uint8(self->out_s, self->orders_state.last_order); } present = 0; present_ptr = self->out_s->p; /* hold 1 byte present pointer */ @@ -536,89 +528,89 @@ xrdp_orders_screen_blt(struct xrdp_orders* self, int x, int y, { xrdp_orders_out_bounds(self, rect); } - if (x != self->scr_blt_x) + if (x != self->orders_state.scr_blt_x) { present |= 0x01; if (order_flags & RDP_ORDER_DELTA) { - out_uint8(self->out_s, x - self->scr_blt_x); + out_uint8(self->out_s, x - self->orders_state.scr_blt_x); } else { out_uint16_le(self->out_s, x); } - self->scr_blt_x = x; + self->orders_state.scr_blt_x = x; } - if (y != self->scr_blt_y) + if (y != self->orders_state.scr_blt_y) { present |= 0x02; if (order_flags & RDP_ORDER_DELTA) { - out_uint8(self->out_s, y - self->scr_blt_y); + out_uint8(self->out_s, y - self->orders_state.scr_blt_y); } else { out_uint16_le(self->out_s, y); } - self->scr_blt_y = y; + self->orders_state.scr_blt_y = y; } - if (cx != self->scr_blt_cx) + if (cx != self->orders_state.scr_blt_cx) { present |= 0x04; if (order_flags & RDP_ORDER_DELTA) { - out_uint8(self->out_s, cx - self->scr_blt_cx); + out_uint8(self->out_s, cx - self->orders_state.scr_blt_cx); } else { out_uint16_le(self->out_s, cx); } - self->scr_blt_cx = cx; + self->orders_state.scr_blt_cx = cx; } - if (cy != self->scr_blt_cy) + if (cy != self->orders_state.scr_blt_cy) { present |= 0x08; if (order_flags & RDP_ORDER_DELTA) { - out_uint8(self->out_s, cy - self->scr_blt_cy); + out_uint8(self->out_s, cy - self->orders_state.scr_blt_cy); } else { out_uint16_le(self->out_s, cy); } - self->scr_blt_cy = cy; + self->orders_state.scr_blt_cy = cy; } - if (rop != self->scr_blt_rop) + if (rop != self->orders_state.scr_blt_rop) { present |= 0x10; out_uint8(self->out_s, rop); - self->scr_blt_rop = rop; + self->orders_state.scr_blt_rop = rop; } - if (srcx != self->scr_blt_srcx) + if (srcx != self->orders_state.scr_blt_srcx) { present |= 0x20; if (order_flags & RDP_ORDER_DELTA) { - out_uint8(self->out_s, srcx - self->scr_blt_srcx); + out_uint8(self->out_s, srcx - self->orders_state.scr_blt_srcx); } else { out_uint16_le(self->out_s, srcx); } - self->scr_blt_srcx = srcx; + self->orders_state.scr_blt_srcx = srcx; } - if (srcy != self->scr_blt_srcy) + if (srcy != self->orders_state.scr_blt_srcy) { present |= 0x40; if (order_flags & RDP_ORDER_DELTA) { - out_uint8(self->out_s, srcy - self->scr_blt_srcy) + out_uint8(self->out_s, srcy - self->orders_state.scr_blt_srcy) } else { out_uint16_le(self->out_s, srcy) } - self->scr_blt_srcy = srcy; + self->orders_state.scr_blt_srcy = srcy; } present_ptr[0] = present; return 0; @@ -643,11 +635,11 @@ xrdp_orders_pat_blt(struct xrdp_orders* self, int x, int y, xrdp_orders_check(self, 39); self->order_count++; order_flags = RDP_ORDER_STANDARD; - if (self->last_order != RDP_ORDER_PATBLT) + if (self->orders_state.last_order != RDP_ORDER_PATBLT) { order_flags |= RDP_ORDER_CHANGE; } - self->last_order = RDP_ORDER_PATBLT; + self->orders_state.last_order = RDP_ORDER_PATBLT; if (rect != 0) { /* if clip is present, still check if its needed */ @@ -662,13 +654,13 @@ xrdp_orders_pat_blt(struct xrdp_orders* self, int x, int y, } } vals[0] = x; - vals[1] = self->pat_blt_x; + vals[1] = self->orders_state.pat_blt_x; vals[2] = y; - vals[3] = self->pat_blt_y; + vals[3] = self->orders_state.pat_blt_y; vals[4] = cx; - vals[5] = self->pat_blt_cx; + vals[5] = self->orders_state.pat_blt_cx; vals[6] = cy; - vals[7] = self->pat_blt_cy; + vals[7] = self->orders_state.pat_blt_cy; if (xrdp_orders_send_delta(self, vals, 8)) { order_flags |= RDP_ORDER_DELTA; @@ -676,7 +668,7 @@ xrdp_orders_pat_blt(struct xrdp_orders* self, int x, int y, out_uint8(self->out_s, order_flags); if (order_flags & RDP_ORDER_CHANGE) { - out_uint8(self->out_s, self->last_order); + out_uint8(self->out_s, self->orders_state.last_order); } present = 0; present_ptr = self->out_s->p; /* hold 2 byte present pointer, todo */ @@ -687,115 +679,117 @@ xrdp_orders_pat_blt(struct xrdp_orders* self, int x, int y, { xrdp_orders_out_bounds(self, rect); } - if (x != self->pat_blt_x) + if (x != self->orders_state.pat_blt_x) { present |= 0x0001; if (order_flags & RDP_ORDER_DELTA) { - out_uint8(self->out_s, x - self->pat_blt_x); + out_uint8(self->out_s, x - self->orders_state.pat_blt_x); } else { out_uint16_le(self->out_s, x); } - self->pat_blt_x = x; + self->orders_state.pat_blt_x = x; } - if (y != self->pat_blt_y) + if (y != self->orders_state.pat_blt_y) { present |= 0x0002; if (order_flags & RDP_ORDER_DELTA) { - out_uint8(self->out_s, y - self->pat_blt_y); + out_uint8(self->out_s, y - self->orders_state.pat_blt_y); } else { out_uint16_le(self->out_s, y); } - self->pat_blt_y = y; + self->orders_state.pat_blt_y = y; } - if (cx != self->pat_blt_cx) + if (cx != self->orders_state.pat_blt_cx) { present |= 0x0004; if (order_flags & RDP_ORDER_DELTA) { - out_uint8(self->out_s, cx - self->pat_blt_cx); + out_uint8(self->out_s, cx - self->orders_state.pat_blt_cx); } else { out_uint16_le(self->out_s, cx); } - self->pat_blt_cx = cx; + self->orders_state.pat_blt_cx = cx; } - if (cy != self->pat_blt_cy) + if (cy != self->orders_state.pat_blt_cy) { present |= 0x0008; if (order_flags & RDP_ORDER_DELTA) { - out_uint8(self->out_s, cy - self->pat_blt_cy); + out_uint8(self->out_s, cy - self->orders_state.pat_blt_cy); } else { out_uint16_le(self->out_s, cy); } - self->pat_blt_cy = cy; + self->orders_state.pat_blt_cy = cy; } - if (rop != self->pat_blt_rop) + if (rop != self->orders_state.pat_blt_rop) { present |= 0x0010; /* PATCOPY PATPAINT PATINVERT DSTINVERT BLACKNESS WHITENESS */ out_uint8(self->out_s, rop); - self->pat_blt_rop = rop; + self->orders_state.pat_blt_rop = rop; } - if (bg_color != self->pat_blt_bg_color) + if (bg_color != self->orders_state.pat_blt_bg_color) { present |= 0x0020; out_uint8(self->out_s, bg_color); out_uint8(self->out_s, bg_color >> 8); out_uint8(self->out_s, bg_color >> 16); - self->pat_blt_bg_color = bg_color; + self->orders_state.pat_blt_bg_color = bg_color; } - if (fg_color != self->pat_blt_fg_color) + if (fg_color != self->orders_state.pat_blt_fg_color) { present |= 0x0040; out_uint8(self->out_s, fg_color); out_uint8(self->out_s, fg_color >> 8); out_uint8(self->out_s, fg_color >> 16); - self->pat_blt_fg_color = fg_color; + self->orders_state.pat_blt_fg_color = fg_color; } if (brush == 0) /* if nil use blank one */ { /* todo can we just set style to zero */ g_memset(&blank_brush, 0, sizeof(struct xrdp_brush)); brush = &blank_brush; } - if (brush->x_orgin != self->pat_blt_brush.x_orgin) + if (brush->x_orgin != self->orders_state.pat_blt_brush.x_orgin) { present |= 0x0080; out_uint8(self->out_s, brush->x_orgin); - self->pat_blt_brush.x_orgin = brush->x_orgin; + self->orders_state.pat_blt_brush.x_orgin = brush->x_orgin; } - if (brush->y_orgin != self->pat_blt_brush.y_orgin) + if (brush->y_orgin != self->orders_state.pat_blt_brush.y_orgin) { present |= 0x0100; out_uint8(self->out_s, brush->y_orgin); - self->pat_blt_brush.y_orgin = brush->y_orgin; + self->orders_state.pat_blt_brush.y_orgin = brush->y_orgin; } - if (brush->style != self->pat_blt_brush.style) + if (brush->style != self->orders_state.pat_blt_brush.style) { present |= 0x0200; out_uint8(self->out_s, brush->style); - self->pat_blt_brush.style = brush->style; + self->orders_state.pat_blt_brush.style = brush->style; } - if (brush->pattern[0] != self->pat_blt_brush.pattern[0]) + if (brush->pattern[0] != self->orders_state.pat_blt_brush.pattern[0]) { present |= 0x0400; out_uint8(self->out_s, brush->pattern[0]); - self->pat_blt_brush.pattern[0] = brush->pattern[0]; + self->orders_state.pat_blt_brush.pattern[0] = brush->pattern[0]; } - if (g_memcmp(brush->pattern + 1, self->pat_blt_brush.pattern + 1, 7) != 0) + if (g_memcmp(brush->pattern + 1, + self->orders_state.pat_blt_brush.pattern + 1, 7) != 0) { present |= 0x0800; out_uint8a(self->out_s, brush->pattern + 1, 7); - g_memcpy(self->pat_blt_brush.pattern + 1, brush->pattern + 1, 7); + g_memcpy(self->orders_state.pat_blt_brush.pattern + 1, + brush->pattern + 1, 7); } present_ptr[0] = present; present_ptr[1] = present >> 8; @@ -819,11 +813,11 @@ xrdp_orders_dest_blt(struct xrdp_orders* self, int x, int y, xrdp_orders_check(self, 21); self->order_count++; order_flags = RDP_ORDER_STANDARD; - if (self->last_order != RDP_ORDER_DESTBLT) + if (self->orders_state.last_order != RDP_ORDER_DESTBLT) { order_flags |= RDP_ORDER_CHANGE; } - self->last_order = RDP_ORDER_DESTBLT; + self->orders_state.last_order = RDP_ORDER_DESTBLT; if (rect != 0) { /* if clip is present, still check if its needed */ @@ -838,13 +832,13 @@ xrdp_orders_dest_blt(struct xrdp_orders* self, int x, int y, } } vals[0] = x; - vals[1] = self->dest_blt_x; + vals[1] = self->orders_state.dest_blt_x; vals[2] = y; - vals[3] = self->dest_blt_y; + vals[3] = self->orders_state.dest_blt_y; vals[4] = cx; - vals[5] = self->dest_blt_cx; + vals[5] = self->orders_state.dest_blt_cx; vals[6] = cy; - vals[7] = self->dest_blt_cy; + vals[7] = self->orders_state.dest_blt_cy; if (xrdp_orders_send_delta(self, vals, 8)) { order_flags |= RDP_ORDER_DELTA; @@ -852,7 +846,7 @@ xrdp_orders_dest_blt(struct xrdp_orders* self, int x, int y, out_uint8(self->out_s, order_flags); if (order_flags & RDP_ORDER_CHANGE) { - out_uint8(self->out_s, self->last_order) + out_uint8(self->out_s, self->orders_state.last_order) } present = 0; present_ptr = self->out_s->p; /* hold 1 byte present pointer */ @@ -862,63 +856,63 @@ xrdp_orders_dest_blt(struct xrdp_orders* self, int x, int y, { xrdp_orders_out_bounds(self, rect); } - if (x != self->dest_blt_x) + if (x != self->orders_state.dest_blt_x) { present |= 0x01; if (order_flags & RDP_ORDER_DELTA) { - out_uint8(self->out_s, x - self->dest_blt_x); + out_uint8(self->out_s, x - self->orders_state.dest_blt_x); } else { out_uint16_le(self->out_s, x); } - self->dest_blt_x = x; + self->orders_state.dest_blt_x = x; } - if (y != self->dest_blt_y) + if (y != self->orders_state.dest_blt_y) { present |= 0x02; if (order_flags & RDP_ORDER_DELTA) { - out_uint8(self->out_s, y - self->dest_blt_y); + out_uint8(self->out_s, y - self->orders_state.dest_blt_y); } else { out_uint16_le(self->out_s, y); } - self->dest_blt_y = y; + self->orders_state.dest_blt_y = y; } - if (cx != self->dest_blt_cx) + if (cx != self->orders_state.dest_blt_cx) { present |= 0x04; if (order_flags & RDP_ORDER_DELTA) { - out_uint8(self->out_s, cx - self->dest_blt_cx); + out_uint8(self->out_s, cx - self->orders_state.dest_blt_cx); } else { out_uint16_le(self->out_s, cx); } - self->dest_blt_cx = cx; + self->orders_state.dest_blt_cx = cx; } - if (cy != self->dest_blt_cy) + if (cy != self->orders_state.dest_blt_cy) { present |= 0x08; if (order_flags & RDP_ORDER_DELTA) { - out_uint8(self->out_s, cy - self->dest_blt_cy); + out_uint8(self->out_s, cy - self->orders_state.dest_blt_cy); } else { out_uint16_le(self->out_s, cy); } - self->dest_blt_cy = cy; + self->orders_state.dest_blt_cy = cy; } - if (rop != self->dest_blt_rop) + if (rop != self->orders_state.dest_blt_rop) { present |= 0x10; out_uint8(self->out_s, rop); - self->dest_blt_rop = rop; + self->orders_state.dest_blt_rop = rop; } present_ptr[0] = present; return 0; @@ -944,11 +938,11 @@ xrdp_orders_line(struct xrdp_orders* self, int mix_mode, xrdp_orders_check(self, 32); self->order_count++; order_flags = RDP_ORDER_STANDARD; - if (self->last_order != RDP_ORDER_LINE) + if (self->orders_state.last_order != RDP_ORDER_LINE) { order_flags |= RDP_ORDER_CHANGE; } - self->last_order = RDP_ORDER_LINE; + self->orders_state.last_order = RDP_ORDER_LINE; if (rect != 0) { /* if clip is present, still check if its needed */ @@ -965,13 +959,13 @@ xrdp_orders_line(struct xrdp_orders* self, int mix_mode, } } vals[0] = startx; - vals[1] = self->line_startx; + vals[1] = self->orders_state.line_startx; vals[2] = starty; - vals[3] = self->line_starty; + vals[3] = self->orders_state.line_starty; vals[4] = endx; - vals[5] = self->line_endx; + vals[5] = self->orders_state.line_endx; vals[6] = endy; - vals[7] = self->line_endy; + vals[7] = self->orders_state.line_endy; if (xrdp_orders_send_delta(self, vals, 8)) { order_flags |= RDP_ORDER_DELTA; @@ -979,7 +973,7 @@ xrdp_orders_line(struct xrdp_orders* self, int mix_mode, out_uint8(self->out_s, order_flags); if (order_flags & RDP_ORDER_CHANGE) { - out_uint8(self->out_s, self->last_order); + out_uint8(self->out_s, self->orders_state.last_order); } present = 0; present_ptr = self->out_s->p; /* hold 2 byte present pointer */ @@ -989,102 +983,102 @@ xrdp_orders_line(struct xrdp_orders* self, int mix_mode, { xrdp_orders_out_bounds(self, rect); } - if (mix_mode != self->line_mix_mode) + if (mix_mode != self->orders_state.line_mix_mode) { present |= 0x0001; out_uint16_le(self->out_s, mix_mode) - self->line_mix_mode = mix_mode; + self->orders_state.line_mix_mode = mix_mode; } - if (startx != self->line_startx) + if (startx != self->orders_state.line_startx) { present |= 0x0002; if (order_flags & RDP_ORDER_DELTA) { - out_uint8(self->out_s, startx - self->line_startx); + out_uint8(self->out_s, startx - self->orders_state.line_startx); } else { out_uint16_le(self->out_s, startx); } - self->line_startx = startx; + self->orders_state.line_startx = startx; } - if (starty != self->line_starty) + if (starty != self->orders_state.line_starty) { present |= 0x0004; if (order_flags & RDP_ORDER_DELTA) { - out_uint8(self->out_s, starty - self->line_starty); + out_uint8(self->out_s, starty - self->orders_state.line_starty); } else { out_uint16_le(self->out_s, starty); } - self->line_starty = starty; + self->orders_state.line_starty = starty; } - if (endx != self->line_endx) + if (endx != self->orders_state.line_endx) { present |= 0x0008; if (order_flags & RDP_ORDER_DELTA) { - out_uint8(self->out_s, endx - self->line_endx); + out_uint8(self->out_s, endx - self->orders_state.line_endx); } else { out_uint16_le(self->out_s, endx); } - self->line_endx = endx; + self->orders_state.line_endx = endx; } - if (endy != self->line_endy) + if (endy != self->orders_state.line_endy) { present |= 0x0010; if (order_flags & RDP_ORDER_DELTA) { - out_uint8(self->out_s, endy - self->line_endy); + out_uint8(self->out_s, endy - self->orders_state.line_endy); } else { out_uint16_le(self->out_s, endy); } - self->line_endy = endy; + self->orders_state.line_endy = endy; } - if (bg_color != self->line_bg_color) + if (bg_color != self->orders_state.line_bg_color) { present |= 0x0020; out_uint8(self->out_s, bg_color) out_uint8(self->out_s, bg_color >> 8) out_uint8(self->out_s, bg_color >> 16) - self->line_bg_color = bg_color; + self->orders_state.line_bg_color = bg_color; } - if (rop != self->line_rop) + if (rop != self->orders_state.line_rop) { present |= 0x0040; out_uint8(self->out_s, rop) - self->line_rop = rop; + self->orders_state.line_rop = rop; } if (pen == 0) { g_memset(&blank_pen, 0, sizeof(struct xrdp_pen)); pen = &blank_pen; } - if (pen->style != self->line_pen.style) + if (pen->style != self->orders_state.line_pen.style) { present |= 0x0080; out_uint8(self->out_s, pen->style) - self->line_pen.style = pen->style; + self->orders_state.line_pen.style = pen->style; } - if (pen->width != self->line_pen.width) + if (pen->width != self->orders_state.line_pen.width) { present |= 0x0100; out_uint8(self->out_s, pen->width) - self->line_pen.width = pen->width; + self->orders_state.line_pen.width = pen->width; } - if (pen->color != self->line_pen.color) + if (pen->color != self->orders_state.line_pen.color) { present |= 0x0200; out_uint8(self->out_s, pen->color) out_uint8(self->out_s, pen->color >> 8) out_uint8(self->out_s, pen->color >> 16) - self->line_pen.color = pen->color; + self->orders_state.line_pen.color = pen->color; } present_ptr[0] = present; present_ptr[1] = present >> 8; @@ -1109,11 +1103,11 @@ xrdp_orders_mem_blt(struct xrdp_orders* self, int cache_id, xrdp_orders_check(self, 30); self->order_count++; order_flags = RDP_ORDER_STANDARD; - if (self->last_order != RDP_ORDER_MEMBLT) + if (self->orders_state.last_order != RDP_ORDER_MEMBLT) { order_flags |= RDP_ORDER_CHANGE; } - self->last_order = RDP_ORDER_MEMBLT; + self->orders_state.last_order = RDP_ORDER_MEMBLT; if (rect != 0) { /* if clip is present, still check if its needed */ @@ -1128,17 +1122,17 @@ xrdp_orders_mem_blt(struct xrdp_orders* self, int cache_id, } } vals[0] = x; - vals[1] = self->mem_blt_x; + vals[1] = self->orders_state.mem_blt_x; vals[2] = y; - vals[3] = self->mem_blt_y; + vals[3] = self->orders_state.mem_blt_y; vals[4] = cx; - vals[5] = self->mem_blt_cx; + vals[5] = self->orders_state.mem_blt_cx; vals[6] = cy; - vals[7] = self->mem_blt_cy; + vals[7] = self->orders_state.mem_blt_cy; vals[8] = srcx; - vals[9] = self->mem_blt_srcx; + vals[9] = self->orders_state.mem_blt_srcx; vals[10] = srcy; - vals[11] = self->mem_blt_srcy; + vals[11] = self->orders_state.mem_blt_srcy; if (xrdp_orders_send_delta(self, vals, 12)) { order_flags |= RDP_ORDER_DELTA; @@ -1146,7 +1140,7 @@ xrdp_orders_mem_blt(struct xrdp_orders* self, int cache_id, out_uint8(self->out_s, order_flags); if (order_flags & RDP_ORDER_CHANGE) { - out_uint8(self->out_s, self->last_order) + out_uint8(self->out_s, self->orders_state.last_order) } present = 0; present_ptr = self->out_s->p; /* hold 2 byte present pointer, todo */ @@ -1157,104 +1151,104 @@ xrdp_orders_mem_blt(struct xrdp_orders* self, int cache_id, { xrdp_orders_out_bounds(self, rect); } - if (cache_id != self->mem_blt_cache_id || - color_table != self->mem_blt_color_table) + if (cache_id != self->orders_state.mem_blt_cache_id || + color_table != self->orders_state.mem_blt_color_table) { present |= 0x0001; out_uint8(self->out_s, cache_id); out_uint8(self->out_s, color_table); - self->mem_blt_cache_id = cache_id; - self->mem_blt_color_table = color_table; + self->orders_state.mem_blt_cache_id = cache_id; + self->orders_state.mem_blt_color_table = color_table; } - if (x != self->mem_blt_x) + if (x != self->orders_state.mem_blt_x) { present |= 0x0002; if (order_flags & RDP_ORDER_DELTA) { - out_uint8(self->out_s, x - self->mem_blt_x); + out_uint8(self->out_s, x - self->orders_state.mem_blt_x); } else { out_uint16_le(self->out_s, x); } - self->mem_blt_x = x; + self->orders_state.mem_blt_x = x; } - if (y != self->mem_blt_y) + if (y != self->orders_state.mem_blt_y) { present |= 0x0004; if (order_flags & RDP_ORDER_DELTA) { - out_uint8(self->out_s, y - self->mem_blt_y); + out_uint8(self->out_s, y - self->orders_state.mem_blt_y); } else { out_uint16_le(self->out_s, y); } - self->mem_blt_y = y; + self->orders_state.mem_blt_y = y; } - if (cx != self->mem_blt_cx) + if (cx != self->orders_state.mem_blt_cx) { present |= 0x0008; if (order_flags & RDP_ORDER_DELTA) { - out_uint8(self->out_s, cx - self->mem_blt_cx); + out_uint8(self->out_s, cx - self->orders_state.mem_blt_cx); } else { out_uint16_le(self->out_s, cx); } - self->mem_blt_cx = cx; + self->orders_state.mem_blt_cx = cx; } - if (cy != self->mem_blt_cy) + if (cy != self->orders_state.mem_blt_cy) { present |= 0x0010; if (order_flags & RDP_ORDER_DELTA) { - out_uint8(self->out_s, cy - self->mem_blt_cy); + out_uint8(self->out_s, cy - self->orders_state.mem_blt_cy); } else { out_uint16_le(self->out_s, cy); } - self->mem_blt_cy = cy; + self->orders_state.mem_blt_cy = cy; } - if (rop != self->mem_blt_rop) + if (rop != self->orders_state.mem_blt_rop) { present |= 0x0020; out_uint8(self->out_s, rop); - self->mem_blt_rop = rop; + self->orders_state.mem_blt_rop = rop; } - if (srcx != self->mem_blt_srcx) + if (srcx != self->orders_state.mem_blt_srcx) { present |= 0x0040; if (order_flags & RDP_ORDER_DELTA) { - out_uint8(self->out_s, srcx - self->mem_blt_srcx); + out_uint8(self->out_s, srcx - self->orders_state.mem_blt_srcx); } else { out_uint16_le(self->out_s, srcx); } - self->mem_blt_srcx = srcx; + self->orders_state.mem_blt_srcx = srcx; } - if (srcy != self->mem_blt_srcy) + if (srcy != self->orders_state.mem_blt_srcy) { present |= 0x0080; if (order_flags & RDP_ORDER_DELTA) { - out_uint8(self->out_s, srcy - self->mem_blt_srcy); + out_uint8(self->out_s, srcy - self->orders_state.mem_blt_srcy); } else { out_uint16_le(self->out_s, srcy); } - self->mem_blt_srcy = srcy; + self->orders_state.mem_blt_srcy = srcy; } - if (cache_idx != self->mem_blt_cache_idx) + if (cache_idx != self->orders_state.mem_blt_cache_idx) { present |= 0x0100; out_uint16_le(self->out_s, cache_idx); - self->mem_blt_cache_idx = cache_idx; + self->orders_state.mem_blt_cache_idx = cache_idx; } present_ptr[0] = present; present_ptr[1] = present >> 8; @@ -1281,11 +1275,11 @@ xrdp_orders_text(struct xrdp_orders* self, xrdp_orders_check(self, 100); self->order_count++; order_flags = RDP_ORDER_STANDARD; - if (self->last_order != RDP_ORDER_TEXT2) + if (self->orders_state.last_order != RDP_ORDER_TEXT2) { order_flags |= RDP_ORDER_CHANGE; } - self->last_order = RDP_ORDER_TEXT2; + self->orders_state.last_order = RDP_ORDER_TEXT2; if (rect != 0) { /* if clip is present, still check if its needed */ @@ -1309,7 +1303,7 @@ xrdp_orders_text(struct xrdp_orders* self, out_uint8(self->out_s, order_flags); if (order_flags & RDP_ORDER_CHANGE) { - out_uint8(self->out_s, self->last_order); + out_uint8(self->out_s, self->orders_state.last_order); } present = 0; present_ptr = self->out_s->p; /* hold 3 byte present pointer, todo */ @@ -1320,100 +1314,100 @@ xrdp_orders_text(struct xrdp_orders* self, { xrdp_orders_out_bounds(self, rect); } - if (font != self->text_font) + if (font != self->orders_state.text_font) { present |= 0x000001; out_uint8(self->out_s, font); - self->text_font = font; + self->orders_state.text_font = font; } - if (flags != self->text_flags) + if (flags != self->orders_state.text_flags) { present |= 0x000002; out_uint8(self->out_s, flags); - self->text_flags = flags; + self->orders_state.text_flags = flags; } /* unknown */ - if (mixmode != self->text_mixmode) + if (mixmode != self->orders_state.text_mixmode) { present |= 0x000008; out_uint8(self->out_s, mixmode); - self->text_mixmode = mixmode; + self->orders_state.text_mixmode = mixmode; } - if (fg_color != self->text_fg_color) + if (fg_color != self->orders_state.text_fg_color) { present |= 0x000010; out_uint8(self->out_s, fg_color) out_uint8(self->out_s, fg_color >> 8) out_uint8(self->out_s, fg_color >> 16) - self->text_fg_color = fg_color; + self->orders_state.text_fg_color = fg_color; } - if (bg_color != self->text_bg_color) + if (bg_color != self->orders_state.text_bg_color) { present |= 0x000020; out_uint8(self->out_s, bg_color) out_uint8(self->out_s, bg_color >> 8) out_uint8(self->out_s, bg_color >> 16) - self->text_bg_color = bg_color; + self->orders_state.text_bg_color = bg_color; } - if (clip_left != self->text_clip_left) + if (clip_left != self->orders_state.text_clip_left) { present |= 0x000040; out_uint16_le(self->out_s, clip_left); - self->text_clip_left = clip_left; + self->orders_state.text_clip_left = clip_left; } - if (clip_top != self->text_clip_top) + if (clip_top != self->orders_state.text_clip_top) { present |= 0x000080; out_uint16_le(self->out_s, clip_top); - self->text_clip_top = clip_top; + self->orders_state.text_clip_top = clip_top; } - if (clip_right != self->text_clip_right) + if (clip_right != self->orders_state.text_clip_right) { present |= 0x000100; out_uint16_le(self->out_s, clip_right); - self->text_clip_right = clip_right; + self->orders_state.text_clip_right = clip_right; } - if (clip_bottom != self->text_clip_bottom) + if (clip_bottom != self->orders_state.text_clip_bottom) { present |= 0x000200; out_uint16_le(self->out_s, clip_bottom); - self->text_clip_bottom = clip_bottom; + self->orders_state.text_clip_bottom = clip_bottom; } - if (box_left != self->text_box_left) + if (box_left != self->orders_state.text_box_left) { present |= 0x000400; out_uint16_le(self->out_s, box_left); - self->text_box_left = box_left; + self->orders_state.text_box_left = box_left; } - if (box_top != self->text_box_top) + if (box_top != self->orders_state.text_box_top) { present |= 0x000800; out_uint16_le(self->out_s, box_top); - self->text_box_top = box_top; + self->orders_state.text_box_top = box_top; } - if (box_right != self->text_box_right) + if (box_right != self->orders_state.text_box_right) { present |= 0x001000; out_uint16_le(self->out_s, box_right); - self->text_box_right = box_right; + self->orders_state.text_box_right = box_right; } - if (box_bottom != self->text_box_bottom) + if (box_bottom != self->orders_state.text_box_bottom) { present |= 0x002000; out_uint16_le(self->out_s, box_bottom); - self->text_box_bottom = box_bottom; + self->orders_state.text_box_bottom = box_bottom; } - if (x != self->text_x) + if (x != self->orders_state.text_x) { present |= 0x080000; out_uint16_le(self->out_s, x); - self->text_x = x; + self->orders_state.text_x = x; } - if (y != self->text_y) + if (y != self->orders_state.text_y) { present |= 0x100000; out_uint16_le(self->out_s, y); - self->text_y = y; + self->orders_state.text_y = y; } { /* always send text */ -- cgit v1.2.1