diff --git a/common/parse.h b/common/parse.h index 3d6a5058..226e246b 100644 --- a/common/parse.h +++ b/common/parse.h @@ -338,7 +338,7 @@ do \ #define xstream_wr_s16_le(_s, _var) TODO #define xstream_wr_s32_le(_s, _var) TODO -#define xstream_rd_u64_le(_s, _v) \ +#define xstream_rd_u64_le(_s, _v) \ do \ { \ _v = \ @@ -353,7 +353,7 @@ do \ _s->p += 8; \ } while (0) -#define xstream_wr_u64_le(_s, _v) \ +#define xstream_wr_u64_le(_s, _v) \ do \ { \ *(((unsigned char *) _s->p) + 0) = (unsigned char) ((_v >> 0) & 0xff); \ @@ -384,16 +384,16 @@ do \ } while (0) #define xstream_rd_string(_dest, _s, _len) \ -do \ -{ \ - g_memcpy((_dest), (_s)->p, (_len)); \ - (_s)->p += (_len); \ +do \ +{ \ + g_memcpy((_dest), (_s)->p, (_len)); \ + (_s)->p += (_len); \ } while (0) -#define xstream_wr_string(_s, _src, _len) \ +#define xstream_wr_string(_s, _src, _len) \ do \ { \ - g_memcpy((_s)->p, (_src), (_len)); \ + g_memcpy((_s)->p, (_src), (_len)); \ (_s)->p += (_len); \ } while (0) diff --git a/common/xrdp_client_info.h b/common/xrdp_client_info.h index 86d0dc25..aefc7119 100644 --- a/common/xrdp_client_info.h +++ b/common/xrdp_client_info.h @@ -91,6 +91,7 @@ struct xrdp_client_info int order_flags_ex; int use_bulk_comp; int pointer_flags; /* 0 color, 1 new, 2 no new */ + int use_fast_path; }; #endif diff --git a/libxrdp/libxrdp.c b/libxrdp/libxrdp.c index 23cf5b09..15e34e91 100644 --- a/libxrdp/libxrdp.c +++ b/libxrdp/libxrdp.c @@ -19,6 +19,7 @@ */ #include "libxrdp.h" +#include "xrdp_orders_rail.h" /******************************************************************************/ struct xrdp_session *EXPORT_CC diff --git a/libxrdp/xrdp_orders.c b/libxrdp/xrdp_orders.c index aa399004..29234173 100644 --- a/libxrdp/xrdp_orders.c +++ b/libxrdp/xrdp_orders.c @@ -212,14 +212,17 @@ xrdp_orders_check(struct xrdp_orders *self, int max_size) } if (size > max_packet_size) { - // this suggests someone calls this function without passing the correct - // max_size so we end up putting more into the buffer than we indicate we can + /* this suggests someone calls this function without passing the + correct max_size so we end up putting more into the buffer + than we indicate we can */ g_writeln("error in xrdp_orders_check, size too big, its %d", size); - // We where getting called with size allready greater than max_packet_size - // Which I suspect was because the sending of text did not include the text len - // to check the buffer size. So attempt to send the data anyway. - // Lets write the data anyway, somewhere else may barf. - // return 1; + /* We where getting called with size already greater than + max_packet_size + Which I suspect was because the sending of text did not include + the text len to check the buffer size. So attempt to send the data + anyway. + Lets write the data anyway, somewhere else may barf. */ + /* return 1; */ } if ((size + max_size + 100) > max_packet_size) @@ -363,7 +366,8 @@ xrdp_orders_out_bounds(struct xrdp_orders *self, struct xrdp_rect *rect) /* right */ if (bounds_flags & 0x04) { - out_uint16_le(self->out_s, rect->right - 1); /* silly rdp right clip */ + /* silly rdp right clip */ + out_uint16_le(self->out_s, rect->right - 1); } else if (bounds_flags & 0x40) { @@ -375,7 +379,8 @@ xrdp_orders_out_bounds(struct xrdp_orders *self, struct xrdp_rect *rect) /* bottom */ if (bounds_flags & 0x08) { - out_uint16_le(self->out_s, rect->bottom - 1); /* silly rdp bottom clip */ + /* silly rdp bottom clip */ + out_uint16_le(self->out_s, rect->bottom - 1); } else if (bounds_flags & 0x80) { @@ -1184,8 +1189,8 @@ xrdp_orders_line(struct xrdp_orders *self, int mix_mode, g_memset(&blank_pen, 0, sizeof(struct xrdp_pen)); - /* if mix mode or rop are out of range, mstsc build 6000+ will parse the orders - wrong */ + /* if mix mode or rop are out of range, mstsc build 6000+ will parse the + orders wrong */ if ((mix_mode < 1) || (mix_mode > 2)) /* TRANSPARENT(1) or OPAQUE(2) */ { mix_mode = 1; @@ -2336,8 +2341,8 @@ xrdp_orders_send_bitmap3(struct xrdp_orders *self, rfx_compose_message(context, fr_s, &rect, 1, (tui8 *)data, width, height, width * 4); bufsize = stream_get_length(fr_s); - xrdp_orders_out_v3(self, cache_id, cache_idx, (char *)(fr_s->data), bufsize, - width, height, bpp, ci->v3_codec_id); + xrdp_orders_out_v3(self, cache_id, cache_idx, (char *)(fr_s->data), + bufsize, width, height, bpp, ci->v3_codec_id); stream_detach(fr_s); stream_free(fr_s); free_stream(xr_s); diff --git a/libxrdp/xrdp_rdp.c b/libxrdp/xrdp_rdp.c index 624b3b5d..82ccdea0 100644 --- a/libxrdp/xrdp_rdp.c +++ b/libxrdp/xrdp_rdp.c @@ -625,8 +625,16 @@ xrdp_rdp_send_demand_active(struct xrdp_rdp *self) out_uint16_le(s, 0x200); /* Protocol version */ out_uint16_le(s, 0); /* pad */ out_uint16_le(s, 0); /* Compression types */ - //out_uint16_le(s, 0); /* pad use 0x40d for rdp packets, 0 for not */ - out_uint16_le(s, 0x40d); /* pad use 0x40d for rdp packets, 0 for not */ + /* NO_BITMAP_COMPRESSION_HDR 0x0400 + FASTPATH_OUTPUT_SUPPORTED 0x0001 */ + if (self->client_info.use_fast_path & 1) + { + out_uint16_le(s, 0x401); + } + else + { + out_uint16_le(s, 0x400); + } out_uint16_le(s, 0); /* Update capability */ out_uint16_le(s, 0); /* Remote unshare capability */ out_uint16_le(s, 0); /* Compression level */ @@ -761,7 +769,17 @@ xrdp_rdp_send_demand_active(struct xrdp_rdp *self) caps_count++; out_uint16_le(s, RDP_CAPSET_INPUT); /* 13(0xd) */ out_uint16_le(s, RDP_CAPLEN_INPUT); /* 88(0x58) */ - out_uint8(s, 1); + if (self->client_info.use_fast_path & 2) + { + /* INPUT_FLAG_SCANCODES 0x0001 + INPUT_FLAG_FASTPATH_INPUT 0x0008 + INPUT_FLAG_FASTPATH_INPUT2 0x0020 */ + out_uint8(s, 1 | 8 | 0x20); + } + else + { + out_uint8(s, 1); + } out_uint8s(s, 83); /* Remote Programs Capability Set */ diff --git a/neutrinordp/xrdp-neutrinordp.c b/neutrinordp/xrdp-neutrinordp.c index ef0e4d4c..f0424c26 100644 --- a/neutrinordp/xrdp-neutrinordp.c +++ b/neutrinordp/xrdp-neutrinordp.c @@ -27,7 +27,7 @@ #ifdef XRDP_DEBUG #define LOG_LEVEL 99 #else -#define LOG_LEVEL 0 +#define LOG_LEVEL 1 #endif #define LLOG(_level, _args) \ @@ -617,14 +617,19 @@ lfreerdp_pat_blt(rdpContext *context, PATBLT_ORDER *patblt) server_bpp = mod->inst->settings->color_depth; client_bpp = mod->bpp; - LLOGLN(0, ("lfreerdp_pat_blt: bpp %d %d", server_bpp, client_bpp)); + LLOGLN(10, ("lfreerdp_pat_blt: bpp %d %d", server_bpp, client_bpp)); fgcolor = convert_color(server_bpp, client_bpp, patblt->foreColor, mod->colormap); bgcolor = convert_color(server_bpp, client_bpp, patblt->backColor, mod->colormap); - if(fgcolor==bgcolor) + LLOGLN(10, ("lfreerdp_pat_blt: nLeftRect %d nTopRect %d " + "nWidth %d nHeight %d fgcolor 0x%8.8x bgcolor 0x%8.8x", + patblt->nLeftRect, patblt->nTopRect, + patblt->nWidth, patblt->nHeight, fgcolor, bgcolor)); + + if (fgcolor == bgcolor) { LLOGLN(0, ("Warning same color on both bg and fg")); } @@ -691,6 +696,10 @@ lfreerdp_opaque_rect(rdpContext *context, OPAQUE_RECT_ORDER *opaque_rect) client_bpp = mod->bpp; fgcolor = convert_color(server_bpp, client_bpp, opaque_rect->color, mod->colormap); + LLOGLN(10, ("lfreerdp_opaque_rect: nLeftRect %d nTopRect %d " + "nWidth %d nHeight %d fgcolor 0x%8.8x", + opaque_rect->nLeftRect, opaque_rect->nTopRect, + opaque_rect->nWidth, opaque_rect->nHeight, fgcolor)); mod->server_set_fgcolor(mod, fgcolor); mod->server_fill_rect(mod, opaque_rect->nLeftRect, opaque_rect->nTopRect, opaque_rect->nWidth, opaque_rect->nHeight); @@ -749,6 +758,10 @@ lfreerdp_glyph_index(rdpContext *context, GLYPH_INDEX_ORDER *glyph_index) int client_bpp; int fgcolor; int bgcolor; + int opLeft; + int opTop; + int opRight; + int opBottom; mod = ((struct mod_context *)context)->modi; LLOGLN(10, ("lfreerdp_glyph_index:")); @@ -758,14 +771,39 @@ lfreerdp_glyph_index(rdpContext *context, GLYPH_INDEX_ORDER *glyph_index) glyph_index->foreColor, mod->colormap); bgcolor = convert_color(server_bpp, client_bpp, glyph_index->backColor, mod->colormap); + LLOGLN(10, ("lfreerdp_glyph_index: " + "bkLeft %d bkTop %d width %d height %d " + "opLeft %d opTop %d width %d height %d " + "cbData %d fgcolor 0x%8.8x bgcolor 0x%8.8x fOpRedundant %d", + glyph_index->bkLeft, glyph_index->bkTop, + glyph_index->bkRight - glyph_index->bkLeft, + glyph_index->bkBottom - glyph_index->bkTop, + glyph_index->opLeft, glyph_index->opTop, + glyph_index->opRight - glyph_index->opLeft, + glyph_index->opBottom - glyph_index->opTop, + glyph_index->cbData, fgcolor, bgcolor, glyph_index->fOpRedundant)); mod->server_set_bgcolor(mod, fgcolor); mod->server_set_fgcolor(mod, bgcolor); + opLeft = glyph_index->opLeft; + opTop = glyph_index->opTop; + opRight = glyph_index->opRight; + opBottom = glyph_index->opBottom; +#if 1 + /* workarounds for freerdp not using fOpRedundant in + glyph.c::update_gdi_glyph_index */ + if (glyph_index->fOpRedundant) + { + opLeft = glyph_index->bkLeft; + opTop = glyph_index->bkTop; + opRight = glyph_index->bkRight; + opBottom =glyph_index->bkBottom; + } +#endif mod->server_draw_text(mod, glyph_index->cacheId, glyph_index->flAccel, glyph_index->fOpRedundant, glyph_index->bkLeft, glyph_index->bkTop, glyph_index->bkRight, glyph_index->bkBottom, - glyph_index->opLeft, glyph_index->opTop, - glyph_index->opRight, glyph_index->opBottom, + opLeft, opTop, opRight, opBottom, glyph_index->x, glyph_index->y, (char *)(glyph_index->data), glyph_index->cbData); } @@ -863,7 +901,7 @@ lfreerdp_cache_bitmapV2(rdpContext *context, if (flags & 0x10) /* CBR2_DO_NOT_CACHE */ { - LLOGLN(0, ("lfreerdp_cache_bitmapV2: CBR2_DO_NOT_CACHE")); + LLOGLN(10, ("lfreerdp_cache_bitmapV2: CBR2_DO_NOT_CACHE")); idx = 4096 - 1; } @@ -1049,6 +1087,13 @@ lfreerdp_get_pixel(void *bits, int width, int height, int bpp, pixel = (src8[start] & (0x80 >> shift)) != 0; return pixel ? 0xffffff : 0; } + else if (bpp == 32) + { + src8 = (tui8 *)bits; + src8 += y * delta + x * 4; + pixel = ((int*)(src8))[0]; + return pixel; + } else { LLOGLN(0, ("lfreerdp_get_pixel: unknown bpp %d", bpp)); @@ -1089,6 +1134,12 @@ lfreerdp_set_pixel(int pixel, void *bits, int width, int height, int bpp, dst8[1] = (pixel >> 8) & 0xff; dst8[2] = (pixel >> 16) & 0xff; } + else if (bpp == 32) + { + dst8 = (tui8 *)bits; + dst8 += y * delta + x * 4; + ((int*)(dst8))[0] = pixel; + } else { LLOGLN(0, ("lfreerdp_set_pixel: unknown bpp %d", bpp)); @@ -1129,6 +1180,8 @@ lfreerdp_pointer_new(rdpContext *context, { struct mod *mod; int index; + int bytes_per_pixel; + int bits_per_pixel; tui8 *dst; tui8 *src; @@ -1143,40 +1196,47 @@ lfreerdp_pointer_new(rdpContext *context, pointer_new->colorPtrAttr.lengthAndMask)); index = pointer_new->colorPtrAttr.cacheIndex; - if(index>=32) + if (index >= 32) { - LLOGLN(0,("pointer index too big")); + LLOGLN(0, ("lfreerdp_pointer_new: pointer index too big")); return ; } - // In this fix we remove the xorBpp check, even if - // the mouse pointers are not correct we can use them. - // Configure your destination not to use windows Aero as pointer scheme - else if ( // pointer_new->xorBpp == 1 && - pointer_new->colorPtrAttr.width == 32 && - pointer_new->colorPtrAttr.height == 32 && - index < 32) + if (pointer_new->xorBpp == 1 && + pointer_new->colorPtrAttr.width == 32 && + pointer_new->colorPtrAttr.height == 32) { + LLOGLN(10, ("lfreerdp_pointer_new:")); mod->pointer_cache[index].hotx = pointer_new->colorPtrAttr.xPos; mod->pointer_cache[index].hoty = pointer_new->colorPtrAttr.yPos; - + mod->pointer_cache[index].bpp = 0; dst = (tui8 *)(mod->pointer_cache[index].data); dst += 32 * 32 * 3 - 32 * 3; src = pointer_new->colorPtrAttr.xorMaskData; lfreerdp_convert_color_image(dst, 32, 32, 24, 32 * -3, src, 32, 32, 1, 32 / 8); - dst = (tui8 *)(mod->pointer_cache[index].mask); dst += ( 32 * 32 / 8) - (32 / 8); src = pointer_new->colorPtrAttr.andMaskData; lfreerdp_convert_color_image(dst, 32, 32, 1, 32 / -8, src, 32, 32, 1, 32 / 8); - - //memcpy(mod->pointer_cache[index].mask, - // pointer_new->colorPtrAttr.andMaskData, 32 * 32 / 8); - - mod->server_set_pointer(mod, mod->pointer_cache[index].hotx, - mod->pointer_cache[index].hoty, mod->pointer_cache[index].data, - mod->pointer_cache[index].mask); + } + else if(pointer_new->xorBpp >= 8 && + pointer_new->colorPtrAttr.width == 32 && + pointer_new->colorPtrAttr.height == 32) + { + bytes_per_pixel = (pointer_new->xorBpp + 7) / 8; + bits_per_pixel = pointer_new->xorBpp; + LLOGLN(10, ("lfreerdp_pointer_new: bpp %d Bpp %d", bits_per_pixel, + bytes_per_pixel)); + mod->pointer_cache[index].hotx = pointer_new->colorPtrAttr.xPos; + mod->pointer_cache[index].hoty = pointer_new->colorPtrAttr.yPos; + mod->pointer_cache[index].bpp = bits_per_pixel; + memcpy(mod->pointer_cache[index].data, + pointer_new->colorPtrAttr.xorMaskData, + 32 * 32 * bytes_per_pixel); + memcpy(mod->pointer_cache[index].mask, + pointer_new->colorPtrAttr.andMaskData, + 32 * (32 / 8)); } else { @@ -1185,6 +1245,12 @@ lfreerdp_pointer_new(rdpContext *context, pointer_new->colorPtrAttr.height,index)); } + mod->server_set_pointer_ex(mod, mod->pointer_cache[index].hotx, + mod->pointer_cache[index].hoty, + mod->pointer_cache[index].data, + mod->pointer_cache[index].mask, + mod->pointer_cache[index].bpp); + free(pointer_new->colorPtrAttr.xorMaskData); pointer_new->colorPtrAttr.xorMaskData = 0; free(pointer_new->colorPtrAttr.andMaskData); @@ -1203,10 +1269,11 @@ lfreerdp_pointer_cached(rdpContext *context, mod = ((struct mod_context *)context)->modi; index = pointer_cached->cacheIndex; LLOGLN(10, ("lfreerdp_pointer_cached:%d", index)); - mod->server_set_pointer(mod, mod->pointer_cache[index].hotx, - mod->pointer_cache[index].hoty, - mod->pointer_cache[index].data, - mod->pointer_cache[index].mask); + mod->server_set_pointer_ex(mod, mod->pointer_cache[index].hotx, + mod->pointer_cache[index].hoty, + mod->pointer_cache[index].data, + mod->pointer_cache[index].mask, + mod->pointer_cache[index].bpp); } static void DEFAULT_CC lfreerdp_polygon_cb(rdpContext* context, POLYGON_CB_ORDER* polygon_cb) @@ -1308,6 +1375,7 @@ lfreerdp_pre_connect(freerdp *instance) instance->settings->draw_nine_grid = 0; instance->settings->glyph_cache = true; + /* GLYPH_SUPPORT_FULL and GLYPH_SUPPORT_PARTIAL seem to be the same */ instance->settings->glyphSupportLevel = GLYPH_SUPPORT_FULL; instance->settings->order_support[NEG_GLYPH_INDEX_INDEX] = 1; instance->settings->order_support[NEG_FAST_GLYPH_INDEX] = 0; diff --git a/neutrinordp/xrdp-neutrinordp.h b/neutrinordp/xrdp-neutrinordp.h index 474c46b7..9cd3a8c3 100644 --- a/neutrinordp/xrdp-neutrinordp.h +++ b/neutrinordp/xrdp-neutrinordp.h @@ -53,8 +53,9 @@ struct pointer_item { int hotx; int hoty; - char data[32 * 32 * 3]; + char data[32 * 32 * 4]; char mask[32 * 32 / 8]; + int bpp; }; #define CURRENT_MOD_VER 2 @@ -148,6 +149,8 @@ struct mod int (*server_monitored_desktop)(struct mod* mod, struct rail_monitored_desktop_order* mdo, int flags); + int (*server_set_pointer_ex)(struct mod* mod, int x, int y, char* data, + char* mask, int bpp); long server_dumby[100 - 37]; /* align, 100 minus the number of server functions above */ diff --git a/sesman/chansrv/chansrv.c b/sesman/chansrv/chansrv.c index bd9c27c5..388d0273 100644 --- a/sesman/chansrv/chansrv.c +++ b/sesman/chansrv/chansrv.c @@ -33,6 +33,7 @@ #include "rail.h" #include "xcommon.h" #include "chansrv_fuse.h" +#include "drdynvc.h" static struct trans *g_lis_trans = 0; static struct trans *g_con_trans = 0; diff --git a/sesman/chansrv/chansrv_fuse.c b/sesman/chansrv/chansrv_fuse.c index 48936910..661d0bca 100644 --- a/sesman/chansrv/chansrv_fuse.c +++ b/sesman/chansrv/chansrv_fuse.c @@ -59,15 +59,15 @@ char g_fuse_clipboard_path[256] = ""; /* for clipboard use */ #include "chansrv_fuse.h" /* dummy calls when XRDP_FUSE is not defined */ -int xfuse_init() {} -int xfuse_deinit() {} -int xfuse_check_wait_objs(void) {} -int xfuse_get_wait_objs(tbus *objs, int *count, int *timeout) {} -int xfuse_clear_clip_dir(void) {} -int xfuse_file_contents_range(int stream_id, char *data, int data_bytes) {} -int xfuse_file_contents_size(int stream_id, int file_size) {} -int xfuse_add_clip_dir_item(char *filename, int flags, int size, int lindex) {} -int xfuse_create_share(tui32 device_id, char *dirname) {} +int xfuse_init() { return 0; } +int xfuse_deinit() { return 0; } +int xfuse_check_wait_objs(void) { return 0; } +int xfuse_get_wait_objs(tbus *objs, int *count, int *timeout) { return 0; } +int xfuse_clear_clip_dir(void) { return 0; } +int xfuse_file_contents_range(int stream_id, char *data, int data_bytes) { return 0; } +int xfuse_file_contents_size(int stream_id, int file_size) { return 0; } +int xfuse_add_clip_dir_item(char *filename, int flags, int size, int lindex) { return 0; } +int xfuse_create_share(tui32 device_id, char *dirname) { return 0; } void xfuse_devredir_cb_open_file(void *vp, tui32 IoStatus, tui32 DeviceId, tui32 FileId) {} void xfuse_devredir_cb_write_file(void *vp, char *buf, size_t length) {} void xfuse_devredir_cb_read_file(void *vp, char *buf, size_t length) {} diff --git a/sesman/chansrv/clipboard.c b/sesman/chansrv/clipboard.c index 89dbdbbb..3aac8dbc 100644 --- a/sesman/chansrv/clipboard.c +++ b/sesman/chansrv/clipboard.c @@ -272,17 +272,6 @@ clipboard_get_server_time(void) return xevent.xproperty.time; } -/*****************************************************************************/ -/* returns time in miliseconds - this is like g_time2 in os_calls, but not miliseconds since machine was - up, something else - this is a time value similar to what the xserver uses */ -static int APP_CC -clipboard_get_local_time(void) -{ - return g_time3(); -} - /*****************************************************************************/ static int APP_CC clipboard_find_format_id(int format_id) diff --git a/sesman/chansrv/devredir.c b/sesman/chansrv/devredir.c index 067738ac..8de28e43 100644 --- a/sesman/chansrv/devredir.c +++ b/sesman/chansrv/devredir.c @@ -296,7 +296,7 @@ dev_redir_check_wait_objs(void) * @brief let client know our capabilities *****************************************************************************/ -void dev_redir_send_server_core_cap_req() +void dev_redir_send_server_core_cap_req(void) { struct stream *s; int bytes; @@ -340,8 +340,8 @@ void dev_redir_send_server_core_cap_req() /* setup file system capability */ xstream_wr_u16_le(s, CAP_DRIVE_TYPE); /* CapabilityType */ xstream_wr_u16_le(s, 8); /* CapabilityLength - len of this */ - /* CAPABILITY_SET in bytes, inc */ - /* the header */ + /* CAPABILITY_SET in bytes, inc */ + /* the header */ xstream_wr_u32_le(s, 2); /* Version */ /* setup smart card capability */ @@ -356,7 +356,7 @@ void dev_redir_send_server_core_cap_req() xstream_free(s); } -void dev_redir_send_server_clientID_confirm() +void dev_redir_send_server_clientID_confirm(void) { struct stream *s; int bytes; @@ -377,7 +377,7 @@ void dev_redir_send_server_clientID_confirm() xstream_free(s); } -void dev_redir_send_server_user_logged_on() +void dev_redir_send_server_user_logged_on(void) { struct stream *s; int bytes; diff --git a/sesman/chansrv/drdynvc.c b/sesman/chansrv/drdynvc.c index 6bcac45e..af86ea57 100644 --- a/sesman/chansrv/drdynvc.c +++ b/sesman/chansrv/drdynvc.c @@ -21,6 +21,18 @@ int g_drdynvc_chan_id; int g_drdynvc_inited = 0; +static int APP_CC drdynvc_send_capability_request(uint16_t version); +static int APP_CC drdynvc_process_capability_response(struct stream* s, + unsigned char cmd); +static int APP_CC drdynvc_process_open_channel_response(struct stream *s, + unsigned char cmd); +static int APP_CC drdynvc_process_close_channel_response(struct stream *s, + unsigned char cmd); +static int APP_CC drdynvc_process_data_first(struct stream* s, unsigned char cmd); +static int APP_CC drdynvc_process_data(struct stream* s, unsigned char cmd); +static int APP_CC drdynvc_insert_uint_124(struct stream *s, uint32_t val); +static int APP_CC drdynvc_get_chan_id(struct stream *s, char cmd, uint32_t *chan_id_p); + /** * bring up dynamic virtual channel * diff --git a/sesman/chansrv/drdynvc.h b/sesman/chansrv/drdynvc.h index fcf46249..15398867 100644 --- a/sesman/chansrv/drdynvc.h +++ b/sesman/chansrv/drdynvc.h @@ -57,31 +57,11 @@ #define CMD_DVC_CAPABILITY 0x50 int APP_CC drdynvc_init(void); - -static int APP_CC drdynvc_send_capability_request(uint16_t version); -static int APP_CC drdynvc_process_capability_response(struct stream* s, - unsigned char cmd); - int APP_CC drdynvc_send_open_channel_request(int chan_pri, unsigned int chan_id, char *chan_name); - -static int APP_CC drdynvc_process_open_channel_response(struct stream *s, - unsigned char cmd); - int APP_CC drdynvc_send_close_channel_request(unsigned int chan_id); - -static int APP_CC drdynvc_process_close_channel_response(struct stream *s, - unsigned char cmd); - int APP_CC drdynvc_write_data(uint32_t chan_id, char *data, int data_size); - int APP_CC drdynvc_data_in(struct stream* s, int chan_id, int chan_flags, int length, int total_length); -static int APP_CC drdynvc_process_data_first(struct stream* s, unsigned char cmd); -static int APP_CC drdynvc_process_data(struct stream* s, unsigned char cmd); - -static int APP_CC drdynvc_insert_uint_124(struct stream *s, uint32_t val); -static int APP_CC drdynvc_get_chan_id(struct stream *s, char cmd, uint32_t *chan_id_p); - #endif diff --git a/sesman/chansrv/irp.c b/sesman/chansrv/irp.c index fcf3e537..2a5209d8 100644 --- a/sesman/chansrv/irp.c +++ b/sesman/chansrv/irp.c @@ -119,7 +119,7 @@ IRP * devredir_irp_clone(IRP *irp) next = new_irp->next; /* copy all members */ - memcpy(new_irp, irp, sizeof(IRP)); + g_memcpy(new_irp, irp, sizeof(IRP)); /* restore link pointers */ new_irp->prev = prev; diff --git a/sesman/chansrv/rail.c b/sesman/chansrv/rail.c index 1ea8d73a..cfa3c5de 100644 --- a/sesman/chansrv/rail.c +++ b/sesman/chansrv/rail.c @@ -101,33 +101,6 @@ static int g_rail_running = 1; /* Perform the default action of the window's system menu. */ #define SC_DEFAULT 0xF160 -/******************************************************************************/ -static int APP_CC -is_window_valid_child_of_root(unsigned int window_id) -{ - int found; - unsigned int i; - unsigned int nchild; - Window r; - Window p; - Window *children; - - found = 0; - XQueryTree(g_display, g_root_window, &r, &p, &children, &nchild); - - for (i = 0; i < nchild; i++) - { - if (window_id == children[i]) - { - found = 1; - break; - } - } - - XFree(children); - return found; -} - /*****************************************************************************/ static int APP_CC rail_send_init(void) @@ -258,7 +231,6 @@ read_uni(struct stream *s, int num_chars) static int APP_CC rail_process_exec(struct stream *s, int size) { - int pid; int flags; int ExeOrFileLength; int WorkingDirLength; @@ -624,13 +596,6 @@ rail_xevent(void *xevent) XEvent *lxevent; XWindowChanges xwc; int rv; - int nchildren_return = 0; - Window root_return; - Window parent_return; - Window *children_return; - Window wreturn; - int revert_to; - XWindowAttributes wnd_attributes; LOG(10, ("chansrv::rail_xevent:")); diff --git a/sesman/chansrv/smartcard.c b/sesman/chansrv/smartcard.c index 3fdb6723..19650be1 100644 --- a/sesman/chansrv/smartcard.c +++ b/sesman/chansrv/smartcard.c @@ -140,8 +140,8 @@ static void scard_send_EstablishContext(IRP *irp); static void scard_send_ListReaders(IRP *irp, int wide); static struct stream *scard_make_new_ioctl(IRP *irp, tui32 ioctl); static int scard_add_new_device(tui32 device_id); -static int scard_get_free_slot(); -static void scard_release_resources(); +static int scard_get_free_slot(void); +static void scard_release_resources(void); /****************************************************************************** ** non static functions ** @@ -488,7 +488,7 @@ static int scard_add_new_device(tui32 device_id) * @return index of first unused entry in smartcards or -1 if smartcards is full *****************************************************************************/ -static int scard_get_free_slot() +static int scard_get_free_slot(void) { int i; @@ -509,7 +509,7 @@ static int scard_get_free_slot() * Release resources prior to shutting down *****************************************************************************/ -static void scard_release_resources() +static void scard_release_resources(void) { int i; diff --git a/sesman/chansrv/sound.c b/sesman/chansrv/sound.c index c4ca8261..9ee3c8c3 100644 --- a/sesman/chansrv/sound.c +++ b/sesman/chansrv/sound.c @@ -194,8 +194,6 @@ sound_process_format(int aindex, int wFormatTag, int nChannels, int nBlockAlign, int wBitsPerSample, int cbSize, char *data) { - int lindex; - LOG(0, ("sound_process_format:")); LOG(0, (" wFormatTag %d", wFormatTag)); LOG(0, (" nChannels %d", nChannels)); @@ -706,7 +704,7 @@ read_raw_audio_data(void *arg) } strans->trans_data_in = sttrans_data_in; - g_snprintf(path, 255, "/tmp/xrdp_chansrv_audio_socket_%d", g_display_num); + g_snprintf(path, 255, CHANSRV_PORT_STR, g_display_num); if (trans_connect(strans, "", path, 100) != 0) { diff --git a/tests/memtest/Makefile b/tests/memtest/Makefile new file mode 100644 index 00000000..c0310ece --- /dev/null +++ b/tests/memtest/Makefile @@ -0,0 +1,13 @@ + +OBJS = libmem.o memtest.o + +#CFLAGS = -O2 -Wall +CFLAGS = -g + +all: memtest + +memtest: $(OBJS) + $(CC) -o memtest $(OBJS) + +clean: + rm -f $(OBJS) librdp.a diff --git a/tests/memtest/libmem.c b/tests/memtest/libmem.c new file mode 100644 index 00000000..2fa0dea7 --- /dev/null +++ b/tests/memtest/libmem.c @@ -0,0 +1,404 @@ + +#include +#include +#include + +#define ALIGN_BY 32 +#define ALIGN_BY_M1 (ALIGN_BY - 1) +#define ALIGN(_in) (((_in) + ALIGN_BY_M1) & (~ALIGN_BY_M1)) + +#define LLOG_LEVEL 1 +#define LLOGLN(_log_level, _params) \ +do { \ + if (_log_level < LLOG_LEVEL) \ + { \ + printf _params ; \ + printf ("\n") ; \ + } \ +} while (0) + +struct mem_item +{ + unsigned int addr; + int bytes; + struct mem_item* next; + struct mem_item* prev; +}; + +struct mem_info +{ + unsigned int addr; + int bytes; + int flags; + struct mem_item* free_head; + struct mem_item* free_tail; + struct mem_item* used_head; + struct mem_item* used_tail; + int total_bytes; +}; + +/*****************************************************************************/ +static int +libmem_free_mem_item(struct mem_info* self, struct mem_item* mi) +{ + if (self == 0 || mi == 0) + { + return 0; + } + if (mi->prev != 0) + { + mi->prev->next = mi->next; + } + if (mi->next != 0) + { + mi->next->prev = mi->prev; + } + if (mi == self->free_head) + { + self->free_head = mi->next; + } + if (mi == self->free_tail) + { + self->free_tail = mi->prev; + } + if (mi == self->used_head) + { + self->used_head = mi->next; + } + if (mi == self->used_tail) + { + self->used_tail = mi->prev; + } + free(mi); + return 0; +} + +/*****************************************************************************/ +void* +libmem_init(unsigned int addr, int bytes) +{ + struct mem_info* self; + struct mem_item* mi; + + self = (struct mem_info*)malloc(sizeof(struct mem_info)); + memset(self, 0, sizeof(struct mem_info)); + self->addr = addr; + self->bytes = bytes; + //self->flags = 1; + mi = (struct mem_item*)malloc(sizeof(struct mem_item)); + memset(mi, 0, sizeof(struct mem_item)); + mi->addr = addr; + mi->bytes = bytes; + self->free_head = mi; + self->free_tail = mi; + return self; +} + +/*****************************************************************************/ +void +libmem_deinit(void* aself) +{ + struct mem_info* self; + + self = (struct mem_info*)aself; + if (self == 0) + { + return; + } + while (self->free_head != 0) + { + libmem_free_mem_item(self, self->free_head); + } + while (self->used_head != 0) + { + libmem_free_mem_item(self, self->used_head); + } + free(self); +} + +/****************************************************************************/ +static int +libmem_add_used_item(struct mem_info* self, unsigned int addr, int bytes) +{ + struct mem_item* mi; + struct mem_item* new_mi; + int added; + + if (self == 0 || addr == 0) + { + return 1; + } + if (self->used_head == 0) + { + /* add first item */ + new_mi = (struct mem_item*)malloc(sizeof(struct mem_item)); + memset(new_mi, 0, sizeof(struct mem_item)); + new_mi->addr = addr; + new_mi->bytes = bytes; + self->used_head = new_mi; + self->used_tail = new_mi; + return 0; + } + added = 0; + mi = self->used_head; + while (mi != 0) + { + if (mi->addr > addr) + { + /* add before */ + new_mi = (struct mem_item*)malloc(sizeof(struct mem_item)); + memset(new_mi, 0, sizeof(struct mem_item)); + new_mi->addr = addr; + new_mi->bytes = bytes; + new_mi->prev = mi->prev; + new_mi->next = mi; + if (mi->prev != 0) + { + mi->prev->next = new_mi; + } + mi->prev = new_mi; + if (self->used_head == mi) + { + self->used_head = new_mi; + } + added = 1; + break; + } + mi = mi->next; + } + if (!added) + { + /* add last */ + new_mi = (struct mem_item*)malloc(sizeof(struct mem_item)); + memset(new_mi, 0, sizeof(struct mem_item)); + new_mi->addr = addr; + new_mi->bytes = bytes; + self->used_tail->next = new_mi; + new_mi->prev = self->used_tail; + self->used_tail = new_mi; + } + return 0; +} + +/****************************************************************************/ +static int +libmem_add_free_item(struct mem_info* self, unsigned int addr, int bytes) +{ + struct mem_item* mi; + struct mem_item* new_mi; + int added; + + if (self == 0 || addr == 0) + { + return 1; + } + if (self->free_head == 0) + { + /* add first item */ + new_mi = (struct mem_item*)malloc(sizeof(struct mem_item)); + memset(new_mi, 0, sizeof(struct mem_item)); + new_mi->addr = addr; + new_mi->bytes = bytes; + self->free_head = new_mi; + self->free_tail = new_mi; + return 0; + } + added = 0; + mi = self->free_head; + while (mi != 0) + { + if (mi->addr > addr) + { + if (mi->prev != 0) + { + if (mi->prev->addr + mi->prev->bytes == addr) + { + /* don't need to add, just make prev bigger */ + mi->prev->bytes += bytes; + if (mi->prev->addr + mi->prev->bytes == mi->addr) + { + /* here we can remove one */ + mi->prev->bytes += mi->bytes; + libmem_free_mem_item(self, mi); + } + return 0; + } + } + if (addr + bytes == mi->addr) + { + /* don't need to add here either */ + mi->addr = addr; + mi->bytes += bytes; + return 0; + } + /* add before */ + new_mi = (struct mem_item*)malloc(sizeof(struct mem_item)); + memset(new_mi, 0, sizeof(struct mem_item)); + new_mi->addr = addr; + new_mi->bytes = bytes; + new_mi->prev = mi->prev; + new_mi->next = mi; + if (mi->prev != 0) + { + mi->prev->next = new_mi; + } + mi->prev = new_mi; + if (self->free_head == mi) + { + self->free_head = new_mi; + } + added = 1; + break; + } + mi = mi->next; + } + if (!added) + { + /* add last */ + new_mi = (struct mem_item*)malloc(sizeof(struct mem_item)); + memset(new_mi, 0, sizeof(struct mem_item)); + new_mi->addr = addr; + new_mi->bytes = bytes; + self->free_tail->next = new_mi; + new_mi->prev = self->free_tail; + self->free_tail = new_mi; + } + return 0; +} + +/*****************************************************************************/ +static int +libmem_print(struct mem_info* self) +{ + struct mem_item* mi; + + LLOGLN(0, ("libmem_print:")); + LLOGLN(0, (" used_head %p", self->used_head)); + LLOGLN(0, (" used_tail %p", self->used_tail)); + mi = self->used_head; + if (mi != 0) + { + LLOGLN(0, (" used list")); + while (mi != 0) + { + LLOGLN(0, (" ptr %p prev %p next %p addr 0x%8.8x bytes %d", + mi, mi->prev, mi->next, mi->addr, mi->bytes)); + mi = mi->next; + } + } + LLOGLN(0, (" free_head %p", self->free_head)); + LLOGLN(0, (" free_tail %p", self->free_tail)); + mi = self->free_head; + if (mi != 0) + { + LLOGLN(0, (" free list")); + while (mi != 0) + { + LLOGLN(0, (" ptr %p prev %p next %p addr 0x%8.8x bytes %d", + mi, mi->prev, mi->next, mi->addr, mi->bytes)); + mi = mi->next; + } + } + return 0; +} + +/*****************************************************************************/ +unsigned int +libmem_alloc(void* obj, int bytes) +{ + struct mem_info* self; + struct mem_item* mi; + unsigned int addr; + + if (bytes < 1) + { + return 0; + } + bytes = ALIGN(bytes); + self = (struct mem_info*)obj; + addr = 0; + mi = self->free_head; + while (mi != 0) + { + if (bytes <= mi->bytes) + { + addr = mi->addr; + mi->bytes -= bytes; + mi->addr += bytes; + if (mi->bytes < 1) + { + libmem_free_mem_item(self, mi); + } + break; + } + mi = mi->next; + } + if (addr != 0) + { + self->total_bytes += bytes; + libmem_add_used_item(self, addr, bytes); + if (self->flags & 1) + { + libmem_print(self); + } + } + else + { + LLOGLN(0, ("libmem_alloc: error")); + } + return addr; +} + +/*****************************************************************************/ +int +libmem_free(void* obj, unsigned int addr) +{ + struct mem_info* self; + struct mem_item* mi; + + if (addr == 0) + { + return 0; + } + self = (struct mem_info*)obj; + mi = self->used_tail; + while (mi != 0) + { + if (mi->addr == addr) + { + self->total_bytes -= mi->bytes; + libmem_add_free_item(self, mi->addr, mi->bytes); + libmem_free_mem_item(self, mi); + if (self->flags & 1) + { + libmem_print(self); + } + return 0; + } + mi = mi->prev; + } + LLOGLN(0, ("libmem_free: error")); + return 1; +} + +/*****************************************************************************/ +int +libmem_set_flags(void* obj, int flags) +{ + struct mem_info* self; + + self = (struct mem_info*)obj; + self->flags |= flags; + return 0; +} + +/*****************************************************************************/ +int +libmem_clear_flags(void* obj, int flags) +{ + struct mem_info* self; + + self = (struct mem_info*)obj; + self->flags &= ~flags; + return 0; +} diff --git a/tests/memtest/libmem.h b/tests/memtest/libmem.h new file mode 100644 index 00000000..4bc4b1ec --- /dev/null +++ b/tests/memtest/libmem.h @@ -0,0 +1,18 @@ + +#ifndef _LIBMEM_C +#define _LIBMEM_C + +void* +libmem_init(unsigned int addr, int bytes); +void +libmem_deinit(void* aself); +unsigned int +libmem_alloc(void* obj, int bytes); +int +libmem_free(void* obj, unsigned int addr); +int +libmem_set_flags(void* obj, int flags); +int +libmem_clear_flags(void* obj, int flags); + +#endif diff --git a/tests/memtest/memtest.c b/tests/memtest/memtest.c new file mode 100644 index 00000000..e7a26045 --- /dev/null +++ b/tests/memtest/memtest.c @@ -0,0 +1,60 @@ + +#include +#include +#include + +#include "libmem.h" + +int main(int argc, char** argv) +{ + void* obj; + unsigned int addr1; + unsigned int addr2; + unsigned int addr3; + unsigned int addr4; + unsigned int addr5; + int index; + int rd; + + srand(time(0)); + obj = libmem_init(0x80000000, 64 * 1024 * 1024); + for (index = 0; index < 256; index++) + { + rd = rand() & 0xffff; + printf("1 rd %d\n", rd); + addr1 = libmem_alloc(obj, rd); + rd = rand() & 0xffff; + printf("2 rd %d\n", rd); + addr2 = libmem_alloc(obj, rd); + rd = rand() & 0xffff; + printf("3 rd %d\n", rd); + addr3 = libmem_alloc(obj, rd); + rd = rand() & 0xffff; + printf("4 rd %d\n", rd); + addr4 = libmem_alloc(obj, rd); + addr5 = libmem_alloc(obj, rd); + libmem_free(obj, addr1); + printf("5\n"); + addr1 = libmem_alloc(obj, 64); + printf("6\n"); + libmem_free(obj, addr3); + printf("7\n"); + addr3 = libmem_alloc(obj, 64 * 1024); + libmem_free(obj, addr5); + addr5 = libmem_alloc(obj, 64 * 1024); + printf("8\n"); + libmem_free(obj, addr1); + printf("9\n"); + libmem_free(obj, addr2); + printf("10\n"); + libmem_free(obj, addr3); + libmem_free(obj, addr4); + if (index == 255) + { + libmem_set_flags(obj, 1); + } + libmem_free(obj, addr5); + } + libmem_deinit(obj); + return 0; +} diff --git a/xorg/server/Makefile b/xorg/server/Makefile new file mode 100644 index 00000000..12548dd9 --- /dev/null +++ b/xorg/server/Makefile @@ -0,0 +1,16 @@ + +all: allmake + +allmake: + cd module; $(MAKE) $(MFLAGS) + cd xrdpdev; $(MAKE) $(MFLAGS) + cd xrdpkeyb; $(MAKE) $(MFLAGS) + cd xrdpmouse; $(MAKE) $(MFLAGS) + +clean: allclean + +allclean: + cd module; $(MAKE) clean + cd xrdpdev; $(MAKE) clean + cd xrdpkeyb; $(MAKE) clean + cd xrdpmouse; $(MAKE) clean diff --git a/xorg/server/module/Makefile b/xorg/server/module/Makefile new file mode 100644 index 00000000..66b09f91 --- /dev/null +++ b/xorg/server/module/Makefile @@ -0,0 +1,22 @@ + +OBJS = rdpDraw.o rdpPri.o rdpGC.o rdpFillSpans.o rdpSetSpans.o rdpPutImage.o \ +rdpCopyArea.o rdpCopyPlane.o rdpPolyPoint.o rdpPolylines.o rdpPolySegment.o \ +rdpPolyRectangle.o rdpPolyArc.o rdpFillPolygon.o rdpPolyFillRect.o \ +rdpPolyFillArc.o rdpPolyText8.o rdpPolyText16.o rdpImageText8.o \ +rdpImageText16.o rdpImageGlyphBlt.o rdpPolyGlyphBlt.o rdpPushPixels.o \ +rdpCursor.o rdpMain.o rdpRandR.o rdpMisc.o rdpReg.o \ +rdpComposite.o rdpGlyphs.o + +CFLAGS = -g -O2 -Wall -fPIC -I/usr/include/xorg -I/usr/include/pixman-1 + +LDFLAGS = + +LIBS = + +all: libxorgxrdp.so + +libxorgxrdp.so: $(OBJS) Makefile + $(CC) -shared -o libxorgxrdp.so $(LDFLAGS) $(OBJS) $(LIBS) + +clean: + rm -f $(OBJS) libxorgxrdp.so diff --git a/xorg/server/module/rdp.h b/xorg/server/module/rdp.h new file mode 100644 index 00000000..085e114f --- /dev/null +++ b/xorg/server/module/rdp.h @@ -0,0 +1,96 @@ +/* +Copyright 2005-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#ifndef _RDP_H +#define _RDP_H + +#include +#include +#include +#include +#include + +#include "rdpPri.h" + +#define PixelDPI 100 +#define PixelToMM(_size) (((_size) * 254 + (PixelDPI) * 5) / ((PixelDPI) * 10)) + +/* move this to common header */ +struct _rdpRec +{ + int width; + int height; + int depth; + int paddedWidthInBytes; + int sizeInBytes; + int num_modes; + int bitsPerPixel; + char *pfbMemory; + ScreenPtr pScreen; + rdpDevPrivateKey privateKeyRecGC; + rdpDevPrivateKey privateKeyRecPixmap; + + CopyWindowProcPtr CopyWindow; + CreateGCProcPtr CreateGC; + CreatePixmapProcPtr CreatePixmap; + DestroyPixmapProcPtr DestroyPixmap; + ModifyPixmapHeaderProcPtr ModifyPixmapHeader; + CloseScreenProcPtr CloseScreen; + CompositeProcPtr Composite; + GlyphsProcPtr Glyphs; + + miPointerScreenFuncPtr pCursorFuncs; + + /* RandR */ + RRSetConfigProcPtr rrSetConfig; + RRGetInfoProcPtr rrGetInfo; + RRScreenSetSizeProcPtr rrScreenSetSize; + RRCrtcSetProcPtr rrCrtcSet; + RRCrtcSetGammaProcPtr rrCrtcSetGamma; + RRCrtcGetGammaProcPtr rrCrtcGetGamma; + RROutputSetPropertyProcPtr rrOutputSetProperty; + RROutputValidateModeProcPtr rrOutputValidateMode; + RRModeDestroyProcPtr rrModeDestroy; + RROutputGetPropertyProcPtr rrOutputGetProperty; + RRGetPanningProcPtr rrGetPanning; + RRSetPanningProcPtr rrSetPanning; + +}; +typedef struct _rdpRec rdpRec; +typedef struct _rdpRec * rdpPtr; +#define XRDPPTR(_p) ((rdpPtr)((_p)->driverPrivate)) + +struct _rdpGCRec +{ + GCFuncs *funcs; + GCOps *ops; +}; +typedef struct _rdpGCRec rdpGCRec; +typedef struct _rdpGCRec * rdpGCPtr; + +struct _rdpPixmapRec +{ + int i1; +}; +typedef struct _rdpPixmapRec rdpPixmapRec; +typedef struct _rdpPixmapRec * rdpPixmapPtr; + +#endif diff --git a/xorg/server/module/rdpComposite.c b/xorg/server/module/rdpComposite.c new file mode 100644 index 00000000..a2c5568e --- /dev/null +++ b/xorg/server/module/rdpComposite.c @@ -0,0 +1,76 @@ +/* +Copyright 2005-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +composite(alpha blending) calls + +*/ + +#include +#include +#include + +/* this should be before all X11 .h files */ +#include + +/* all driver need this */ +#include +#include + +#include + +#include "rdp.h" +#include "rdpComposite.h" + +/******************************************************************************/ +#define LOG_LEVEL 1 +#define LLOGLN(_level, _args) \ + do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0) + +/******************************************************************************/ +static void +rdpCompositeOrg(PictureScreenPtr ps, rdpPtr dev, + CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst, + INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask, INT16 xDst, + INT16 yDst, CARD16 width, CARD16 height) +{ + ps->Composite = dev->Composite; + ps->Composite(op, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask, + xDst, yDst, width, height); + ps->Composite = rdpComposite; +} + +/******************************************************************************/ +void +rdpComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst, + INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask, INT16 xDst, + INT16 yDst, CARD16 width, CARD16 height) +{ + ScreenPtr pScreen; + rdpPtr dev; + ScrnInfoPtr pScrn; + PictureScreenPtr ps; + + LLOGLN(10, ("rdpComposite:")); + pScreen = pSrc->pDrawable->pScreen; + pScrn = xf86Screens[pScreen->myNum]; + dev = XRDPPTR(pScrn); + ps = GetPictureScreen(pScreen); + rdpCompositeOrg(ps, dev, op, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask, + xDst, yDst, width, height); +} diff --git a/xorg/server/module/rdpComposite.h b/xorg/server/module/rdpComposite.h new file mode 100644 index 00000000..8924c1b4 --- /dev/null +++ b/xorg/server/module/rdpComposite.h @@ -0,0 +1,32 @@ +/* +Copyright 2005-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +composite(alpha blending) calls + +*/ + +#ifndef _RDPCOMPOSITE_H +#define _RDPCOMPOSITE_H + +void +rdpComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst, + INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask, INT16 xDst, + INT16 yDst, CARD16 width, CARD16 height); + +#endif diff --git a/xorg/server/module/rdpCopyArea.c b/xorg/server/module/rdpCopyArea.c new file mode 100644 index 00000000..dd32644e --- /dev/null +++ b/xorg/server/module/rdpCopyArea.c @@ -0,0 +1,55 @@ +/* +Copyright 2005-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#include "rdp.h" +#include "rdpDraw.h" + +#define LOG_LEVEL 1 +#define LLOGLN(_level, _args) \ + do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0) + +/******************************************************************************/ +static RegionPtr +rdpCopyAreaOrg(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, + int srcx, int srcy, int w, int h, int dstx, int dsty) +{ + rdpGCPtr priv; + GCFuncs *oldFuncs; + RegionPtr rv; + + GC_OP_PROLOGUE(pGC); + rv = pGC->ops->CopyArea(pSrc, pDst, pGC, srcx, srcy, w, h, dstx, dsty); + GC_OP_EPILOGUE(pGC); + return rv; +} + +/******************************************************************************/ +RegionPtr +rdpCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, + int srcx, int srcy, int w, int h, int dstx, int dsty) +{ + RegionPtr rv; + + LLOGLN(10, ("rdpCopyArea:")); + /* do original call */ + rv = rdpCopyAreaOrg(pSrc, pDst, pGC, srcx, srcy, w, h, dstx, dsty); + return rv; +} diff --git a/xorg/server/module/rdpCopyArea.h b/xorg/server/module/rdpCopyArea.h new file mode 100644 index 00000000..654b6edc --- /dev/null +++ b/xorg/server/module/rdpCopyArea.h @@ -0,0 +1,29 @@ +/* +Copyright 2005-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#ifndef __RDPCOPYAREA_H +#define __RDPCOPYAREA_H + +RegionPtr +rdpCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC, + int srcx, int srcy, int w, int h, int dstx, int dsty); + +#endif diff --git a/xorg/server/module/rdpCopyPlane.c b/xorg/server/module/rdpCopyPlane.c new file mode 100644 index 00000000..9b89125c --- /dev/null +++ b/xorg/server/module/rdpCopyPlane.c @@ -0,0 +1,59 @@ +/* +Copyright 2005-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#include "rdp.h" +#include "rdpDraw.h" + +#define LOG_LEVEL 1 +#define LLOGLN(_level, _args) \ + do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0) + +/******************************************************************************/ +static RegionPtr +rdpCopyPlaneOrg(DrawablePtr pSrc, DrawablePtr pDst, + GCPtr pGC, int srcx, int srcy, int w, int h, + int dstx, int dsty, unsigned long bitPlane) +{ + RegionPtr rv; + rdpGCPtr priv; + GCFuncs *oldFuncs; + + GC_OP_PROLOGUE(pGC); + rv = pGC->ops->CopyPlane(pSrc, pDst, pGC, srcx, srcy, + w, h, dstx, dsty, bitPlane); + GC_OP_EPILOGUE(pGC); + return rv; +} + +/******************************************************************************/ +RegionPtr +rdpCopyPlane(DrawablePtr pSrc, DrawablePtr pDst, + GCPtr pGC, int srcx, int srcy, int w, int h, + int dstx, int dsty, unsigned long bitPlane) +{ + RegionPtr rv; + + LLOGLN(10, ("rdpCopyPlane:")); + /* do original call */ + rv = rdpCopyPlaneOrg(pSrc, pDst, pGC, srcx, srcy, w, h, + dstx, dsty, bitPlane); + return rv; +} diff --git a/xorg/server/module/rdpCopyPlane.h b/xorg/server/module/rdpCopyPlane.h new file mode 100644 index 00000000..85a79e76 --- /dev/null +++ b/xorg/server/module/rdpCopyPlane.h @@ -0,0 +1,30 @@ +/* +Copyright 2005-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#ifndef __RDPCOPYPLANE_H +#define __RDPCOPYPLANE_H + +RegionPtr +rdpCopyPlane(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, + GCPtr pGC, int srcx, int srcy, int width, int height, + int dstx, int dsty, unsigned long bitPlane); + +#endif diff --git a/xorg/server/module/rdpCursor.c b/xorg/server/module/rdpCursor.c new file mode 100644 index 00000000..82aafd78 --- /dev/null +++ b/xorg/server/module/rdpCursor.c @@ -0,0 +1,91 @@ +/* +Copyright 2005-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +cursor + +*/ + +#include +#include +#include + +/* this should be before all X11 .h files */ +#include + +/* all driver need this */ +#include +#include + +#include +#include +#include +#include + +#include "rdp.h" + +/******************************************************************************/ +#define LOG_LEVEL 1 +#define LLOGLN(_level, _args) \ + do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0) + +/******************************************************************************/ +Bool +rdpSpriteRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScr, CursorPtr pCurs) +{ + LLOGLN(0, ("rdpSpriteRealizeCursor:")); + return 1; +} + +/******************************************************************************/ +Bool +rdpSpriteUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScr, CursorPtr pCurs) +{ + LLOGLN(0, ("rdpSpriteUnrealizeCursor:")); + return 1; +} + +/******************************************************************************/ +void +rdpSpriteSetCursor(DeviceIntPtr pDev, ScreenPtr pScr, CursorPtr pCurs, + int x, int y) +{ + LLOGLN(0, ("rdpSpriteSetCursor:")); +} + +/******************************************************************************/ +void +rdpSpriteMoveCursor(DeviceIntPtr pDev, ScreenPtr pScr, int x, int y) +{ + LLOGLN(0, ("rdpSpriteMoveCursor:")); +} + +/******************************************************************************/ +Bool +rdpSpriteDeviceCursorInitialize(DeviceIntPtr pDev, ScreenPtr pScr) +{ + LLOGLN(0, ("rdpSpriteDeviceCursorInitialize:")); + return 1; +} + +/******************************************************************************/ +void +rdpSpriteDeviceCursorCleanup(DeviceIntPtr pDev, ScreenPtr pScr) +{ + LLOGLN(0, ("rdpSpriteDeviceCursorCleanup:")); +} diff --git a/xorg/server/module/rdpCursor.h b/xorg/server/module/rdpCursor.h new file mode 100644 index 00000000..b847d842 --- /dev/null +++ b/xorg/server/module/rdpCursor.h @@ -0,0 +1,44 @@ +/* +Copyright 2005-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +misc draw calls + +*/ + +#ifndef __RDPCURSOR_H +#define __RDPCURSOR_H + +#include +#include + +Bool +rdpSpriteRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScr, CursorPtr pCurs); +Bool +rdpSpriteUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScr, CursorPtr pCurs); +void +rdpSpriteSetCursor(DeviceIntPtr pDev, ScreenPtr pScr, CursorPtr pCurs, + int x, int y); +void +rdpSpriteMoveCursor(DeviceIntPtr pDev, ScreenPtr pScr, int x, int y); +Bool +rdpSpriteDeviceCursorInitialize(DeviceIntPtr pDev, ScreenPtr pScr); +void +rdpSpriteDeviceCursorCleanup(DeviceIntPtr pDev, ScreenPtr pScr); + +#endif diff --git a/xorg/server/module/rdpDraw.c b/xorg/server/module/rdpDraw.c new file mode 100644 index 00000000..7abcb406 --- /dev/null +++ b/xorg/server/module/rdpDraw.c @@ -0,0 +1,148 @@ +/* +Copyright 2005-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +misc draw calls + +*/ + +#include +#include +#include + +/* this should be before all X11 .h files */ +#include + +/* all driver need this */ +#include +#include + +#include +#include +#include +#include + +#include "rdp.h" + +/******************************************************************************/ +#define LOG_LEVEL 1 +#define LLOGLN(_level, _args) \ + do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0) + +/*****************************************************************************/ +PixmapPtr +rdpCreatePixmap(ScreenPtr pScreen, int width, int height, int depth, + unsigned usage_hint) +{ + ScrnInfoPtr pScrn; + rdpPtr dev; + PixmapPtr rv; + + LLOGLN(10, ("rdpCreatePixmap: width %d height %d depth %d", + width, height, depth)); + pScrn = xf86Screens[pScreen->myNum]; + dev = XRDPPTR(pScrn); + pScreen->CreatePixmap = dev->CreatePixmap; + rv = pScreen->CreatePixmap(pScreen, width, height, depth, usage_hint); + pScreen->CreatePixmap = rdpCreatePixmap; + return rv; +} + +/******************************************************************************/ +Bool +rdpDestroyPixmap(PixmapPtr pPixmap) +{ + Bool rv; + ScreenPtr pScreen; + rdpPtr dev; + ScrnInfoPtr pScrn; + + LLOGLN(10, ("rdpDestroyPixmap: refcnt %d", pPixmap->refcnt)); + pScreen = pPixmap->drawable.pScreen; + pScrn = xf86Screens[pScreen->myNum]; + dev = XRDPPTR(pScrn); + pScreen->DestroyPixmap = dev->DestroyPixmap; + rv = pScreen->DestroyPixmap(pPixmap); + pScreen->DestroyPixmap = rdpDestroyPixmap; + return rv; +} + +/******************************************************************************/ +Bool +rdpModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, int depth, + int bitsPerPixel, int devKind, pointer pPixData) +{ + Bool rv; + ScreenPtr pScreen; + rdpPtr dev; + ScrnInfoPtr pScrn; + + LLOGLN(10, ("rdpModifyPixmapHeader:")); + pScreen = pPixmap->drawable.pScreen; + pScrn = xf86Screens[pScreen->myNum]; + dev = XRDPPTR(pScrn); + pScreen->ModifyPixmapHeader = dev->ModifyPixmapHeader; + rv = pScreen->ModifyPixmapHeader(pPixmap, width, height, depth, bitsPerPixel, + devKind, pPixData); + pScreen->ModifyPixmapHeader = rdpModifyPixmapHeader; + return rv; +} + +/*****************************************************************************/ +void +rdpCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr pOldRegion) +{ + ScrnInfoPtr pScrn; + ScreenPtr pScreen; + rdpPtr dev; + + pScreen = pWin->drawable.pScreen; + pScrn = xf86Screens[pScreen->myNum]; + dev = XRDPPTR(pScrn); + dev->pScreen->CopyWindow = dev->CopyWindow; + dev->pScreen->CopyWindow(pWin, ptOldOrg, pOldRegion); + dev->pScreen->CopyWindow = rdpCopyWindow; +} + +/*****************************************************************************/ +Bool +rdpCloseScreen(int index, ScreenPtr pScreen) +{ + ScrnInfoPtr pScrn; + rdpPtr dev; + Bool rv; + + LLOGLN(0, ("rdpCloseScreen:")); + pScrn = xf86Screens[pScreen->myNum]; + dev = XRDPPTR(pScrn); + dev->pScreen->CloseScreen = dev->CloseScreen; + rv = dev->pScreen->CloseScreen(index, pScreen); + dev->pScreen->CloseScreen = rdpCloseScreen; + return rv; +} + +/******************************************************************************/ +WindowPtr +rdpGetRootWindowPtr(ScreenPtr pScreen) +{ +#if XORG_VERSION_CURRENT < (((1) * 10000000) + ((9) * 100000) + ((0) * 1000) + 0) + return WindowTable[pScreen->myNum]; /* in globals.c */ +#else + return pScreen->root; +#endif +} diff --git a/xorg/server/module/rdpDraw.h b/xorg/server/module/rdpDraw.h new file mode 100644 index 00000000..ba696541 --- /dev/null +++ b/xorg/server/module/rdpDraw.h @@ -0,0 +1,70 @@ +/* +Copyright 2005-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +misc draw calls + +*/ + +#ifndef __RDPDRAW_H +#define __RDPDRAW_H + +#include +#include + +/******************************************************************************/ +#define GC_OP_PROLOGUE(_pGC) \ +do { \ + rdpPtr dev; \ + ScreenPtr pScreen; \ + ScrnInfoPtr pScrn; \ + pScreen = (_pGC)->pScreen; \ + pScrn = xf86Screens[pScreen->myNum]; \ + dev = XRDPPTR(pScrn); \ + priv = (rdpGCPtr)rdpGetGCPrivate(_pGC, dev->privateKeyRecGC); \ + oldFuncs = (_pGC)->funcs; \ + (_pGC)->funcs = priv->funcs; \ + (_pGC)->ops = priv->ops; \ +} while (0) + +/******************************************************************************/ +#define GC_OP_EPILOGUE(_pGC) \ +do { \ + priv->ops = (_pGC)->ops; \ + (_pGC)->funcs = oldFuncs; \ + (_pGC)->ops = &g_rdpGCOps; \ +} while (0) + +extern GCOps g_rdpGCOps; /* in rdpGC.c */ + +PixmapPtr +rdpCreatePixmap(ScreenPtr pScreen, int width, int height, int depth, + unsigned usage_hint); +Bool +rdpDestroyPixmap(PixmapPtr pPixmap); +Bool +rdpModifyPixmapHeader(PixmapPtr pPixmap, int width, int height, int depth, + int bitsPerPixel, int devKind, pointer pPixData); +void +rdpCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr pOldRegion); +Bool +rdpCloseScreen(int index, ScreenPtr pScreen); +WindowPtr +rdpGetRootWindowPtr(ScreenPtr pScreen); + +#endif diff --git a/xorg/server/module/rdpFillPolygon.c b/xorg/server/module/rdpFillPolygon.c new file mode 100644 index 00000000..38043c0b --- /dev/null +++ b/xorg/server/module/rdpFillPolygon.c @@ -0,0 +1,52 @@ +/* +Copyright 2005-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#include "rdp.h" +#include "rdpDraw.h" + +#define LOG_LEVEL 1 +#define LLOGLN(_level, _args) \ + do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0) + +/******************************************************************************/ +void +rdpFillPolygonOrg(DrawablePtr pDrawable, GCPtr pGC, + int shape, int mode, int count, + DDXPointPtr pPts) +{ + rdpGCPtr priv; + GCFuncs *oldFuncs; + + GC_OP_PROLOGUE(pGC); + pGC->ops->FillPolygon(pDrawable, pGC, shape, mode, count, pPts); + GC_OP_EPILOGUE(pGC); +} + +/******************************************************************************/ +void +rdpFillPolygon(DrawablePtr pDrawable, GCPtr pGC, + int shape, int mode, int count, + DDXPointPtr pPts) +{ + LLOGLN(10, ("rdpFillPolygon:")); + /* do original call */ + rdpFillPolygonOrg(pDrawable, pGC, shape, mode, count, pPts); +} diff --git a/xorg/server/module/rdpFillPolygon.h b/xorg/server/module/rdpFillPolygon.h new file mode 100644 index 00000000..89da9ae0 --- /dev/null +++ b/xorg/server/module/rdpFillPolygon.h @@ -0,0 +1,30 @@ +/* +Copyright 2005-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#ifndef __RDPFILLPOLYGON_H +#define __RDPFILLPOLYGON_H + +void +rdpFillPolygon(DrawablePtr pDrawable, GCPtr pGC, + int shape, int mode, int count, + DDXPointPtr pPts); + +#endif diff --git a/xorg/server/module/rdpFillSpans.c b/xorg/server/module/rdpFillSpans.c new file mode 100644 index 00000000..dbd4cc1e --- /dev/null +++ b/xorg/server/module/rdpFillSpans.c @@ -0,0 +1,52 @@ +/* +Copyright 2005-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#include "rdp.h" +#include "rdpDraw.h" + +#define LDEBUG 0 + +#define LOG_LEVEL 1 +#define LLOGLN(_level, _args) \ + do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0) + +/******************************************************************************/ +static void +rdpFillSpansOrg(DrawablePtr pDrawable, GCPtr pGC, int nInit, + DDXPointPtr pptInit, int *pwidthInit, int fSorted) +{ + rdpGCPtr priv; + GCFuncs *oldFuncs; + + GC_OP_PROLOGUE(pGC); + pGC->ops->FillSpans(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted); + GC_OP_EPILOGUE(pGC); +} + +/******************************************************************************/ +void +rdpFillSpans(DrawablePtr pDrawable, GCPtr pGC, int nInit, + DDXPointPtr pptInit, int *pwidthInit, int fSorted) +{ + LLOGLN(0, ("rdpFillSpans:")); + /* do original call */ + rdpFillSpansOrg(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted); +} diff --git a/xorg/server/module/rdpFillSpans.h b/xorg/server/module/rdpFillSpans.h new file mode 100644 index 00000000..7e014e6b --- /dev/null +++ b/xorg/server/module/rdpFillSpans.h @@ -0,0 +1,29 @@ +/* +Copyright 2005-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#ifndef __RDPFILLSPANS_H +#define __RDPFILLSPANS_H + +void +rdpFillSpans(DrawablePtr pDrawable, GCPtr pGC, int nInit, + DDXPointPtr pptInit, int* pwidthInit, int fSorted); + +#endif diff --git a/xorg/server/module/rdpGC.c b/xorg/server/module/rdpGC.c new file mode 100644 index 00000000..3a585e2c --- /dev/null +++ b/xorg/server/module/rdpGC.c @@ -0,0 +1,236 @@ +/* +Copyright 2005-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +GC related calls + +*/ + +#include +#include +#include + +/* this should be before all X11 .h files */ +#include + +/* all driver need this */ +#include +#include + +#include +#include +#include +#include + +#include "rdp.h" +#include "rdpFillSpans.h" +#include "rdpSetSpans.h" +#include "rdpPutImage.h" +#include "rdpCopyArea.h" +#include "rdpCopyPlane.h" +#include "rdpPolyPoint.h" +#include "rdpPolylines.h" +#include "rdpPolySegment.h" +#include "rdpPolyRectangle.h" +#include "rdpPolyArc.h" +#include "rdpFillPolygon.h" +#include "rdpPolyFillRect.h" +#include "rdpPolyFillArc.h" +#include "rdpPolyText8.h" +#include "rdpPolyText16.h" +#include "rdpImageText8.h" +#include "rdpImageText16.h" +#include "rdpImageGlyphBlt.h" +#include "rdpPolyGlyphBlt.h" +#include "rdpPushPixels.h" + +/******************************************************************************/ +#define LOG_LEVEL 1 +#define LLOGLN(_level, _args) \ + do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0) + +/******************************************************************************/ +#define GC_FUNC_PROLOGUE(_pGC) \ + do { \ + rdpPtr dev; \ + ScreenPtr pScreen; \ + ScrnInfoPtr pScrn; \ + pScreen = _pGC->pScreen; \ + pScrn = xf86Screens[pScreen->myNum]; \ + dev = XRDPPTR(pScrn); \ + priv = (rdpGCPtr)rdpGetGCPrivate(_pGC, dev->privateKeyRecGC); \ + (_pGC)->funcs = priv->funcs; \ + if (priv->ops != 0) \ + { \ + (_pGC)->ops = priv->ops; \ + } \ + } while (0) + +/******************************************************************************/ +#define GC_FUNC_EPILOGUE(_pGC) \ + do { \ + priv->funcs = (_pGC)->funcs; \ + (_pGC)->funcs = &g_rdpGCFuncs; \ + if (priv->ops != 0) \ + { \ + priv->ops = (_pGC)->ops; \ + (_pGC)->ops = &g_rdpGCOps; \ + } \ + } while (0) + +static void +rdpValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr d); +static void +rdpChangeGC(GCPtr pGC, unsigned long mask); +static void +rdpCopyGC(GCPtr src, unsigned long mask, GCPtr dst); +static void +rdpDestroyGC(GCPtr pGC); +static void +rdpChangeClip(GCPtr pGC, int type, pointer pValue, int nrects); +static void +rdpDestroyClip(GCPtr pGC); +static void +rdpCopyClip(GCPtr dst, GCPtr src); + +GCFuncs g_rdpGCFuncs = +{ + rdpValidateGC, rdpChangeGC, rdpCopyGC, rdpDestroyGC, rdpChangeClip, + rdpDestroyClip, rdpCopyClip +}; + +GCOps g_rdpGCOps = +{ + rdpFillSpans, rdpSetSpans, rdpPutImage, rdpCopyArea, rdpCopyPlane, + rdpPolyPoint, rdpPolylines, rdpPolySegment, rdpPolyRectangle, + rdpPolyArc, rdpFillPolygon, rdpPolyFillRect, rdpPolyFillArc, + rdpPolyText8, rdpPolyText16, rdpImageText8, rdpImageText16, + rdpImageGlyphBlt, rdpPolyGlyphBlt, rdpPushPixels +}; + +/******************************************************************************/ +static void +rdpValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr d) +{ + rdpGCRec *priv; + + LLOGLN(10, ("rdpValidateGC:")); + GC_FUNC_PROLOGUE(pGC); + pGC->funcs->ValidateGC(pGC, changes, d); + priv->ops = pGC->ops; + GC_FUNC_EPILOGUE(pGC); +} + +/******************************************************************************/ +static void +rdpChangeGC(GCPtr pGC, unsigned long mask) +{ + rdpGCRec *priv; + + LLOGLN(10, ("rdpChangeGC:")); + GC_FUNC_PROLOGUE(pGC); + pGC->funcs->ChangeGC(pGC, mask); + GC_FUNC_EPILOGUE(pGC); +} + +/******************************************************************************/ +static void +rdpCopyGC(GCPtr src, unsigned long mask, GCPtr dst) +{ + rdpGCRec *priv; + + LLOGLN(10, ("rdpCopyGC:")); + GC_FUNC_PROLOGUE(dst); + dst->funcs->CopyGC(src, mask, dst); + GC_FUNC_EPILOGUE(dst); +} + +/******************************************************************************/ +static void +rdpDestroyGC(GCPtr pGC) +{ + rdpGCRec *priv; + + LLOGLN(10, ("rdpDestroyGC:")); + GC_FUNC_PROLOGUE(pGC); + pGC->funcs->DestroyGC(pGC); + GC_FUNC_EPILOGUE(pGC); +} + +/******************************************************************************/ +static void +rdpChangeClip(GCPtr pGC, int type, pointer pValue, int nrects) +{ + rdpGCRec *priv; + + LLOGLN(10, ("rdpChangeClip:")); + GC_FUNC_PROLOGUE(pGC); + pGC->funcs->ChangeClip(pGC, type, pValue, nrects); + GC_FUNC_EPILOGUE(pGC); +} + +/******************************************************************************/ +static void +rdpDestroyClip(GCPtr pGC) +{ + rdpGCRec *priv; + + LLOGLN(10, ("rdpDestroyClip:")); + GC_FUNC_PROLOGUE(pGC); + pGC->funcs->DestroyClip(pGC); + GC_FUNC_EPILOGUE(pGC); +} + +/******************************************************************************/ +static void +rdpCopyClip(GCPtr dst, GCPtr src) +{ + rdpGCRec *priv; + + LLOGLN(10, ("rdpCopyClip:")); + GC_FUNC_PROLOGUE(dst); + dst->funcs->CopyClip(dst, src); + GC_FUNC_EPILOGUE(dst); +} + +/*****************************************************************************/ +Bool +rdpCreateGC(GCPtr pGC) +{ + Bool rv; + rdpPtr dev; + ScreenPtr pScreen; + ScrnInfoPtr pScrn; + rdpGCPtr priv; + + LLOGLN(10, ("rdpCreateGC:")); + pScreen = pGC->pScreen; + pScrn = xf86Screens[pScreen->myNum]; + dev = XRDPPTR(pScrn); + priv = (rdpGCPtr)rdpGetGCPrivate(pGC, dev->privateKeyRecGC); + pScreen->CreateGC = dev->CreateGC; + rv = pScreen->CreateGC(pGC); + if (rv) + { + priv->funcs = pGC->funcs; + priv->ops = 0; + pGC->funcs = &g_rdpGCFuncs; + } + pScreen->CreateGC = rdpCreateGC; + return rv; +} diff --git a/xorg/server/module/rdpGC.h b/xorg/server/module/rdpGC.h new file mode 100644 index 00000000..4ad129a2 --- /dev/null +++ b/xorg/server/module/rdpGC.h @@ -0,0 +1,30 @@ +/* +Copyright 2005-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +GC related calls + +*/ + +#ifndef _RDPGC_H +#define _RDPGC_H + +Bool +rdpCreateGC(GCPtr pGC); + +#endif diff --git a/xorg/server/module/rdpGlyphs.c b/xorg/server/module/rdpGlyphs.c new file mode 100644 index 00000000..3a222e79 --- /dev/null +++ b/xorg/server/module/rdpGlyphs.c @@ -0,0 +1,79 @@ +/* +Copyright 2012-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +gylph(font) calls + +*/ + +#include +#include +#include + +/* this should be before all X11 .h files */ +#include + +/* all driver need this */ +#include +#include + +#include +#include + +#include "rdp.h" +#include "rdpGlyphs.h" + +/******************************************************************************/ +#define LOG_LEVEL 1 +#define LLOGLN(_level, _args) \ + do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0) + +/******************************************************************************/ +static void +rdpGlyphsOrg(PictureScreenPtr ps, rdpPtr dev, + CARD8 op, PicturePtr pSrc, PicturePtr pDst, + PictFormatPtr maskFormat, + INT16 xSrc, INT16 ySrc, int nlists, GlyphListPtr lists, + GlyphPtr *glyphs) +{ + ps->Glyphs = dev->Glyphs; + ps->Glyphs(op, pSrc, pDst, maskFormat, xSrc, ySrc, + nlists, lists, glyphs); + ps->Glyphs = rdpGlyphs; +} + +/******************************************************************************/ +void +rdpGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst, + PictFormatPtr maskFormat, + INT16 xSrc, INT16 ySrc, int nlists, GlyphListPtr lists, + GlyphPtr *glyphs) +{ + ScreenPtr pScreen; + rdpPtr dev; + ScrnInfoPtr pScrn; + PictureScreenPtr ps; + + LLOGLN(10, ("rdpGlyphs:")); + pScreen = pSrc->pDrawable->pScreen; + pScrn = xf86Screens[pScreen->myNum]; + dev = XRDPPTR(pScrn); + ps = GetPictureScreen(pScreen); + rdpGlyphsOrg(ps, dev, op, pSrc, pDst, maskFormat, xSrc, ySrc, + nlists, lists, glyphs); +} diff --git a/xorg/server/module/rdpGlyphs.h b/xorg/server/module/rdpGlyphs.h new file mode 100644 index 00000000..d451d9f9 --- /dev/null +++ b/xorg/server/module/rdpGlyphs.h @@ -0,0 +1,33 @@ +/* +Copyright 2012-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +gylph(font) calls + +*/ + +#ifndef _RDPGLYPHS_H +#define _RDPGLYPHS_H + +void +rdpGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst, + PictFormatPtr maskFormat, + INT16 xSrc, INT16 ySrc, int nlists, GlyphListPtr lists, + GlyphPtr *glyphs); + +#endif diff --git a/xorg/server/module/rdpImageGlyphBlt.c b/xorg/server/module/rdpImageGlyphBlt.c new file mode 100644 index 00000000..0b0d7ce8 --- /dev/null +++ b/xorg/server/module/rdpImageGlyphBlt.c @@ -0,0 +1,52 @@ +/* +Copyright 2005-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#include "rdp.h" +#include "rdpDraw.h" + +#define LOG_LEVEL 1 +#define LLOGLN(_level, _args) \ + do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0) + +/******************************************************************************/ +void +rdpImageGlyphBltOrg(DrawablePtr pDrawable, GCPtr pGC, + int x, int y, unsigned int nglyph, + CharInfoPtr *ppci, pointer pglyphBase) +{ + rdpGCPtr priv; + GCFuncs *oldFuncs; + + GC_OP_PROLOGUE(pGC); + pGC->ops->ImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase); + GC_OP_EPILOGUE(pGC); +} + +/******************************************************************************/ +void +rdpImageGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, + int x, int y, unsigned int nglyph, + CharInfoPtr *ppci, pointer pglyphBase) +{ + LLOGLN(10, ("rdpImageGlyphBlt:")); + /* do original call */ + rdpImageGlyphBltOrg(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase); +} diff --git a/xorg/server/module/rdpImageGlyphBlt.h b/xorg/server/module/rdpImageGlyphBlt.h new file mode 100644 index 00000000..c5483c7e --- /dev/null +++ b/xorg/server/module/rdpImageGlyphBlt.h @@ -0,0 +1,30 @@ +/* +Copyright 2005-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#ifndef __RDPIMAGEGLYPHBLT_H +#define __RDPIMAGEGLYPHBLT_H + +void +rdpImageGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, + int x, int y, unsigned int nglyph, + CharInfoPtr* ppci, pointer pglyphBase); + +#endif diff --git a/xorg/server/module/rdpImageText16.c b/xorg/server/module/rdpImageText16.c new file mode 100644 index 00000000..8ddd9bf3 --- /dev/null +++ b/xorg/server/module/rdpImageText16.c @@ -0,0 +1,50 @@ +/* +Copyright 2005-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#include "rdp.h" +#include "rdpDraw.h" + +#define LOG_LEVEL 1 +#define LLOGLN(_level, _args) \ + do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0) + +/******************************************************************************/ +void +rdpImageText16Org(DrawablePtr pDrawable, GCPtr pGC, + int x, int y, int count, unsigned short *chars) +{ + rdpGCPtr priv; + GCFuncs *oldFuncs; + + GC_OP_PROLOGUE(pGC); + pGC->ops->ImageText16(pDrawable, pGC, x, y, count, chars); + GC_OP_EPILOGUE(pGC); +} + +/******************************************************************************/ +void +rdpImageText16(DrawablePtr pDrawable, GCPtr pGC, + int x, int y, int count, unsigned short *chars) +{ + LLOGLN(10, ("rdpImageText16:")); + /* do original call */ + rdpImageText16Org(pDrawable, pGC, x, y, count, chars); +} diff --git a/xorg/server/module/rdpImageText16.h b/xorg/server/module/rdpImageText16.h new file mode 100644 index 00000000..0ffb90f2 --- /dev/null +++ b/xorg/server/module/rdpImageText16.h @@ -0,0 +1,29 @@ +/* +Copyright 2005-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#ifndef __RDPIMAGETEXT16_H +#define __RDPIMAGETEXT16_H + +void +rdpImageText16(DrawablePtr pDrawable, GCPtr pGC, + int x, int y, int count, unsigned short* chars); + +#endif diff --git a/xorg/server/module/rdpImageText8.c b/xorg/server/module/rdpImageText8.c new file mode 100644 index 00000000..ab41753b --- /dev/null +++ b/xorg/server/module/rdpImageText8.c @@ -0,0 +1,51 @@ +/* +Copyright 2005-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#include "rdp.h" +#include "rdpDraw.h" + +#define LOG_LEVEL 1 +#define LLOGLN(_level, _args) \ + do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0) + +/******************************************************************************/ +void +rdpImageText8Org(DrawablePtr pDrawable, GCPtr pGC, + int x, int y, int count, char *chars) +{ + rdpGCPtr priv; + GCFuncs *oldFuncs; + + GC_OP_PROLOGUE(pGC); + pGC->ops->ImageText8(pDrawable, pGC, x, y, count, chars); + GC_OP_EPILOGUE(pGC); +} + +/******************************************************************************/ +void +rdpImageText8(DrawablePtr pDrawable, GCPtr pGC, + int x, int y, int count, char *chars) +{ + LLOGLN(10, ("rdpImageText8:")); + /* do original call */ + rdpImageText8Org(pDrawable, pGC, x, y, count, chars); + return; +} diff --git a/xorg/server/module/rdpImageText8.h b/xorg/server/module/rdpImageText8.h new file mode 100644 index 00000000..dc0c4ec5 --- /dev/null +++ b/xorg/server/module/rdpImageText8.h @@ -0,0 +1,29 @@ +/* +Copyright 2005-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#ifndef __RDPIMAGETEXT8_H +#define __RDPIMAGETEXT8_H + +void +rdpImageText8(DrawablePtr pDrawable, GCPtr pGC, + int x, int y, int count, char* chars); + +#endif diff --git a/xorg/server/module/rdpMain.c b/xorg/server/module/rdpMain.c new file mode 100644 index 00000000..9930764c --- /dev/null +++ b/xorg/server/module/rdpMain.c @@ -0,0 +1,86 @@ +/* +Copyright 2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +rdp module main + +*/ + +#include +#include +#include + +/* this should be before all X11 .h files */ +#include + +/* all driver need this */ +#include +#include + +#include +#include +#include +#include + +#include "rdp.h" + +/******************************************************************************/ +#define LOG_LEVEL 1 +#define LLOGLN(_level, _args) \ + do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0) + +#define XRDP_DRIVER_NAME "XORGXRDP" +#define XRDP_NAME "XORGXRDP" +#define XRDP_VERSION 1000 + +#define PACKAGE_VERSION_MAJOR 1 +#define PACKAGE_VERSION_MINOR 0 +#define PACKAGE_VERSION_PATCHLEVEL 0 + +static int g_initialised = 0; + +/*****************************************************************************/ +static pointer +xorgxrdpSetup(pointer Module, pointer Options, int *ErrorMajor, int *ErrorMinor) +{ + LLOGLN(0, ("xorgxrdpSetup:")); + if (!g_initialised) + { + g_initialised = 1; + } + return (pointer) 1; +} + +static MODULESETUPPROTO(xorgxrdpSetup); +static XF86ModuleVersionInfo RDPVersRec = +{ + XRDP_DRIVER_NAME, + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XORG_VERSION_CURRENT, + PACKAGE_VERSION_MAJOR, + PACKAGE_VERSION_MINOR, + PACKAGE_VERSION_PATCHLEVEL, + ABI_CLASS_VIDEODRV, + ABI_VIDEODRV_VERSION, + 0, + { 0, 0, 0, 0 } +}; + +XF86ModuleData xorgxrdpModuleData = { &RDPVersRec, xorgxrdpSetup, NULL }; diff --git a/xorg/server/module/rdpMisc.c b/xorg/server/module/rdpMisc.c new file mode 100644 index 00000000..34e71110 --- /dev/null +++ b/xorg/server/module/rdpMisc.c @@ -0,0 +1,415 @@ +/* +Copyright 2005-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +the rest + +*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* this should be before all X11 .h files */ +#include + +/* all driver need this */ +#include +#include + +/******************************************************************************/ +int +rdpBitsPerPixel(int depth) +{ + if (depth == 1) + { + return 1; + } + else if (depth <= 8) + { + return 8; + } + else if (depth <= 16) + { + return 16; + } + else + { + return 32; + } +} + +/* the g_ functions from os_calls.c */ + +/*****************************************************************************/ +int +g_tcp_recv(int sck, void *ptr, int len, int flags) +{ + return recv(sck, ptr, len, flags); +} + +/*****************************************************************************/ +void +g_tcp_close(int sck) +{ + if (sck == 0) + { + return; + } + + shutdown(sck, 2); + close(sck); +} + +/*****************************************************************************/ +int +g_tcp_last_error_would_block(int sck) +{ + return (errno == EWOULDBLOCK) || (errno == EINPROGRESS); +} + +/*****************************************************************************/ +void +g_sleep(int msecs) +{ + usleep(msecs * 1000); +} + +/*****************************************************************************/ +int +g_tcp_send(int sck, void *ptr, int len, int flags) +{ + return send(sck, ptr, len, flags); +} + +/*****************************************************************************/ +void * +g_malloc(int size, int zero) +{ + char *rv; + + rv = (char *)malloc(size); + if (zero) + { + if (rv != 0) + { + memset(rv, 0, size); + } + } + return rv; +} + +/*****************************************************************************/ +void +g_free(void *ptr) +{ + if (ptr != 0) + { + free(ptr); + } +} + +/*****************************************************************************/ +void +g_sprintf(char *dest, char *format, ...) +{ + va_list ap; + + va_start(ap, format); + vsprintf(dest, format, ap); + va_end(ap); +} + +/*****************************************************************************/ +int +g_tcp_socket(void) +{ + int rv; + int i; + + i = 1; + rv = socket(PF_INET, SOCK_STREAM, 0); + setsockopt(rv, IPPROTO_TCP, TCP_NODELAY, (void *)&i, sizeof(i)); + setsockopt(rv, SOL_SOCKET, SO_REUSEADDR, (void *)&i, sizeof(i)); + return rv; +} + +/*****************************************************************************/ +int +g_tcp_local_socket_dgram(void) +{ + return socket(AF_UNIX, SOCK_DGRAM, 0); +} + +/*****************************************************************************/ +int +g_tcp_local_socket_stream(void) +{ + return socket(AF_UNIX, SOCK_STREAM, 0); +} + +/*****************************************************************************/ +void +g_memcpy(void *d_ptr, const void *s_ptr, int size) +{ + memcpy(d_ptr, s_ptr, size); +} + +/*****************************************************************************/ +void +g_memset(void *d_ptr, const unsigned char chr, int size) +{ + memset(d_ptr, chr, size); +} + +/*****************************************************************************/ +int +g_tcp_set_no_delay(int sck) +{ + int i; + + i = 1; + setsockopt(sck, IPPROTO_TCP, TCP_NODELAY, (void *)&i, sizeof(i)); + return 0; +} + +/*****************************************************************************/ +int +g_tcp_set_non_blocking(int sck) +{ + unsigned long i; + + i = fcntl(sck, F_GETFL); + i = i | O_NONBLOCK; + fcntl(sck, F_SETFL, i); + return 0; +} + +/*****************************************************************************/ +int +g_tcp_accept(int sck) +{ + struct sockaddr_in s; + unsigned int i; + + i = sizeof(struct sockaddr_in); + memset(&s, 0, i); + return accept(sck, (struct sockaddr *)&s, &i); +} + +/*****************************************************************************/ +int +g_tcp_select(int sck1, int sck2, int sck3) +{ + fd_set rfds; + struct timeval time; + int max; + int rv; + + time.tv_sec = 0; + time.tv_usec = 0; + FD_ZERO(&rfds); + + if (sck1 > 0) + { + FD_SET(((unsigned int)sck1), &rfds); + } + + if (sck2 > 0) + { + FD_SET(((unsigned int)sck2), &rfds); + } + + if (sck3 > 0) + { + FD_SET(((unsigned int)sck3), &rfds); + } + + max = sck1; + + if (sck2 > max) + { + max = sck2; + } + + if (sck3 > max) + { + max = sck3; + } + + rv = select(max + 1, &rfds, 0, 0, &time); + + if (rv > 0) + { + rv = 0; + + if (FD_ISSET(((unsigned int)sck1), &rfds)) + { + rv = rv | 1; + } + + if (FD_ISSET(((unsigned int)sck2), &rfds)) + { + rv = rv | 2; + } + + if (FD_ISSET(((unsigned int)sck3), &rfds)) + { + rv = rv | 4; + } + } + else + { + rv = 0; + } + + return rv; +} + +/*****************************************************************************/ +int +g_tcp_bind(int sck, char *port) +{ + struct sockaddr_in s; + + memset(&s, 0, sizeof(struct sockaddr_in)); + s.sin_family = AF_INET; + s.sin_port = htons(atoi(port)); + s.sin_addr.s_addr = INADDR_ANY; + return bind(sck, (struct sockaddr *)&s, sizeof(struct sockaddr_in)); +} + +/*****************************************************************************/ +int +g_tcp_local_bind(int sck, char *port) +{ + struct sockaddr_un s; + + memset(&s, 0, sizeof(struct sockaddr_un)); + s.sun_family = AF_UNIX; + strcpy(s.sun_path, port); + return bind(sck, (struct sockaddr *)&s, sizeof(struct sockaddr_un)); +} + +/*****************************************************************************/ +int +g_tcp_listen(int sck) +{ + return listen(sck, 2); +} + +/*****************************************************************************/ +/* returns boolean */ +int +g_create_dir(const char *dirname) +{ + return mkdir(dirname, (mode_t) - 1) == 0; +} + +/*****************************************************************************/ +/* returns boolean, non zero if the directory exists */ +int +g_directory_exist(const char *dirname) +{ + struct stat st; + + if (stat(dirname, &st) == 0) + { + return S_ISDIR(st.st_mode); + } + else + { + return 0; + } +} + +/*****************************************************************************/ +/* returns error */ +int +g_chmod_hex(const char *filename, int flags) +{ + int fl; + + fl = 0; + fl |= (flags & 0x4000) ? S_ISUID : 0; + fl |= (flags & 0x2000) ? S_ISGID : 0; + fl |= (flags & 0x1000) ? S_ISVTX : 0; + fl |= (flags & 0x0400) ? S_IRUSR : 0; + fl |= (flags & 0x0200) ? S_IWUSR : 0; + fl |= (flags & 0x0100) ? S_IXUSR : 0; + fl |= (flags & 0x0040) ? S_IRGRP : 0; + fl |= (flags & 0x0020) ? S_IWGRP : 0; + fl |= (flags & 0x0010) ? S_IXGRP : 0; + fl |= (flags & 0x0004) ? S_IROTH : 0; + fl |= (flags & 0x0002) ? S_IWOTH : 0; + fl |= (flags & 0x0001) ? S_IXOTH : 0; + return chmod(filename, fl); +} + +/*****************************************************************************/ +/* produce a hex dump */ +void +g_hexdump(unsigned char *p, unsigned int len) +{ + unsigned char *line; + int i; + int thisline; + int offset; + + offset = 0; + line = p; + + while (offset < len) + { + ErrorF("%04x ", offset); + thisline = len - offset; + + if (thisline > 16) + { + thisline = 16; + } + + for (i = 0; i < thisline; i++) + { + ErrorF("%02x ", line[i]); + } + + for (; i < 16; i++) + { + ErrorF(" "); + } + + for (i = 0; i < thisline; i++) + { + ErrorF("%c", (line[i] >= 0x20 && line[i] < 0x7f) ? line[i] : '.'); + } + + ErrorF("\n"); + offset += thisline; + line += thisline; + } +} diff --git a/xorg/server/module/rdpMisc.h b/xorg/server/module/rdpMisc.h new file mode 100644 index 00000000..8318f7bd --- /dev/null +++ b/xorg/server/module/rdpMisc.h @@ -0,0 +1,78 @@ +/* +Copyright 2005-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +the rest + +*/ + +#ifndef __RDPMISC_H +#define __RDPMISC_H + +int +rdpBitsPerPixel(int depth); +int +g_tcp_recv(int sck, void *ptr, int len, int flags); +void +g_tcp_close(int sck); +int +g_tcp_last_error_would_block(int sck); +void +g_sleep(int msecs); +int +g_tcp_send(int sck, void *ptr, int len, int flags); +void * +g_malloc(int size, int zero); +void +g_free(void *ptr); +void +g_sprintf(char *dest, char *format, ...); +int +g_tcp_socket(void); +int +g_tcp_local_socket_dgram(void); +int +g_tcp_local_socket_stream(void); +void +g_memcpy(void *d_ptr, const void *s_ptr, int size); +void +g_memset(void *d_ptr, const unsigned char chr, int size); +int +g_tcp_set_no_delay(int sck); +int +g_tcp_set_non_blocking(int sck); +int +g_tcp_accept(int sck); +int +g_tcp_select(int sck1, int sck2, int sck3); +int +g_tcp_bind(int sck, char *port); +int +g_tcp_local_bind(int sck, char *port); +int +g_tcp_listen(int sck); +int +g_create_dir(const char *dirname); +int +g_directory_exist(const char *dirname); +int +g_chmod_hex(const char *filename, int flags); +void +g_hexdump(unsigned char *p, unsigned int len); + +#endif diff --git a/xorg/server/module/rdpPolyArc.c b/xorg/server/module/rdpPolyArc.c new file mode 100644 index 00000000..63fc699b --- /dev/null +++ b/xorg/server/module/rdpPolyArc.c @@ -0,0 +1,48 @@ +/* +Copyright 2005-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#include "rdp.h" +#include "rdpDraw.h" + +#define LOG_LEVEL 1 +#define LLOGLN(_level, _args) \ + do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0) + +/******************************************************************************/ +void +rdpPolyArcOrg(DrawablePtr pDrawable, GCPtr pGC, int narcs, xArc *parcs) +{ + rdpGCPtr priv; + GCFuncs *oldFuncs; + + GC_OP_PROLOGUE(pGC); + pGC->ops->PolyArc(pDrawable, pGC, narcs, parcs); + GC_OP_EPILOGUE(pGC); +} + +/******************************************************************************/ +void +rdpPolyArc(DrawablePtr pDrawable, GCPtr pGC, int narcs, xArc *parcs) +{ + LLOGLN(10, ("rdpPolyArc:")); + /* do original call */ + rdpPolyArcOrg(pDrawable, pGC, narcs, parcs); +} diff --git a/xorg/server/module/rdpPolyArc.h b/xorg/server/module/rdpPolyArc.h new file mode 100644 index 00000000..7ebadc35 --- /dev/null +++ b/xorg/server/module/rdpPolyArc.h @@ -0,0 +1,28 @@ +/* +Copyright 2005-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#ifndef __RDPPOLYARC_H +#define __RDPPOLYARC_H + +void +rdpPolyArc(DrawablePtr pDrawable, GCPtr pGC, int narcs, xArc* parcs); + +#endif diff --git a/xorg/server/module/rdpPolyFillArc.c b/xorg/server/module/rdpPolyFillArc.c new file mode 100644 index 00000000..b53a1131 --- /dev/null +++ b/xorg/server/module/rdpPolyFillArc.c @@ -0,0 +1,48 @@ +/* +Copyright 2005-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#include "rdp.h" +#include "rdpDraw.h" + +#define LOG_LEVEL 1 +#define LLOGLN(_level, _args) \ + do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0) + +/******************************************************************************/ +void +rdpPolyFillArcOrg(DrawablePtr pDrawable, GCPtr pGC, int narcs, xArc *parcs) +{ + rdpGCPtr priv; + GCFuncs *oldFuncs; + + GC_OP_PROLOGUE(pGC); + pGC->ops->PolyFillArc(pDrawable, pGC, narcs, parcs); + GC_OP_EPILOGUE(pGC); +} + +/******************************************************************************/ +void +rdpPolyFillArc(DrawablePtr pDrawable, GCPtr pGC, int narcs, xArc *parcs) +{ + LLOGLN(10, ("rdpPolyFillArc:")); + /* do original call */ + rdpPolyFillArcOrg(pDrawable, pGC, narcs, parcs); +} diff --git a/xorg/server/module/rdpPolyFillArc.h b/xorg/server/module/rdpPolyFillArc.h new file mode 100644 index 00000000..9a9846e1 --- /dev/null +++ b/xorg/server/module/rdpPolyFillArc.h @@ -0,0 +1,28 @@ +/* +Copyright 2005-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#ifndef __RDPPOLYFILLARC_H +#define __RDPPOLYFILLARC_H + +void +rdpPolyFillArc(DrawablePtr pDrawable, GCPtr pGC, int narcs, xArc* parcs); + +#endif diff --git a/xorg/server/module/rdpPolyFillRect.c b/xorg/server/module/rdpPolyFillRect.c new file mode 100644 index 00000000..dc929f9f --- /dev/null +++ b/xorg/server/module/rdpPolyFillRect.c @@ -0,0 +1,50 @@ +/* +Copyright 2005-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#include "rdp.h" +#include "rdpDraw.h" + +#define LOG_LEVEL 1 +#define LLOGLN(_level, _args) \ + do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0) + +/******************************************************************************/ +static void +rdpPolyFillRectOrg(DrawablePtr pDrawable, GCPtr pGC, int nrectFill, + xRectangle *prectInit) +{ + rdpGCPtr priv; + GCFuncs *oldFuncs; + + GC_OP_PROLOGUE(pGC); + pGC->ops->PolyFillRect(pDrawable, pGC, nrectFill, prectInit); + GC_OP_EPILOGUE(pGC); +} + +/******************************************************************************/ +void +rdpPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrectFill, + xRectangle *prectInit) +{ + LLOGLN(10, ("rdpPolyFillRect:")); + /* do original call */ + rdpPolyFillRectOrg(pDrawable, pGC, nrectFill, prectInit); +} diff --git a/xorg/server/module/rdpPolyFillRect.h b/xorg/server/module/rdpPolyFillRect.h new file mode 100644 index 00000000..94ac4b59 --- /dev/null +++ b/xorg/server/module/rdpPolyFillRect.h @@ -0,0 +1,29 @@ +/* +Copyright 2005-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#ifndef __RDPPOLYFILLRECT_H +#define __RDPPOLYFILLRECT_H + +void +rdpPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrectFill, + xRectangle* prectInit); + +#endif diff --git a/xorg/server/module/rdpPolyGlyphBlt.c b/xorg/server/module/rdpPolyGlyphBlt.c new file mode 100644 index 00000000..5265ed72 --- /dev/null +++ b/xorg/server/module/rdpPolyGlyphBlt.c @@ -0,0 +1,52 @@ +/* +Copyright 2005-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#include "rdp.h" +#include "rdpDraw.h" + +#define LOG_LEVEL 1 +#define LLOGLN(_level, _args) \ + do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0) + +/******************************************************************************/ +void +rdpPolyGlyphBltOrg(DrawablePtr pDrawable, GCPtr pGC, + int x, int y, unsigned int nglyph, + CharInfoPtr *ppci, pointer pglyphBase) +{ + rdpGCPtr priv; + GCFuncs *oldFuncs; + + GC_OP_PROLOGUE(pGC); + pGC->ops->PolyGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase); + GC_OP_EPILOGUE(pGC); +} + +/******************************************************************************/ +void +rdpPolyGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, + int x, int y, unsigned int nglyph, + CharInfoPtr *ppci, pointer pglyphBase) +{ + LLOGLN(10, ("rdpPolyGlyphBlt:")); + /* do original call */ + rdpPolyGlyphBltOrg(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase); +} diff --git a/xorg/server/module/rdpPolyGlyphBlt.h b/xorg/server/module/rdpPolyGlyphBlt.h new file mode 100644 index 00000000..9c6519d8 --- /dev/null +++ b/xorg/server/module/rdpPolyGlyphBlt.h @@ -0,0 +1,30 @@ +/* +Copyright 2005-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#ifndef __RDPPOLYGLYPHBLT_H +#define __RDPPOLYGLYPHBLT_H + +void +rdpPolyGlyphBlt(DrawablePtr pDrawable, GCPtr pGC, + int x, int y, unsigned int nglyph, + CharInfoPtr* ppci, pointer pglyphBase); + +#endif diff --git a/xorg/server/module/rdpPolyPoint.c b/xorg/server/module/rdpPolyPoint.c new file mode 100644 index 00000000..6c9c77c1 --- /dev/null +++ b/xorg/server/module/rdpPolyPoint.c @@ -0,0 +1,50 @@ +/* +Copyright 2005-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#include "rdp.h" +#include "rdpDraw.h" + +#define LOG_LEVEL 1 +#define LLOGLN(_level, _args) \ + do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0) + +/******************************************************************************/ +void +rdpPolyPointOrg(DrawablePtr pDrawable, GCPtr pGC, int mode, + int npt, DDXPointPtr in_pts) +{ + rdpGCPtr priv; + GCFuncs *oldFuncs; + + GC_OP_PROLOGUE(pGC); + pGC->ops->PolyPoint(pDrawable, pGC, mode, npt, in_pts); + GC_OP_EPILOGUE(pGC); +} + +/******************************************************************************/ +void +rdpPolyPoint(DrawablePtr pDrawable, GCPtr pGC, int mode, + int npt, DDXPointPtr in_pts) +{ + LLOGLN(10, ("rdpPolyPoint:")); + /* do original call */ + rdpPolyPointOrg(pDrawable, pGC, mode, npt, in_pts); +} diff --git a/xorg/server/module/rdpPolyPoint.h b/xorg/server/module/rdpPolyPoint.h new file mode 100644 index 00000000..87bf9459 --- /dev/null +++ b/xorg/server/module/rdpPolyPoint.h @@ -0,0 +1,29 @@ +/* +Copyright 2005-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#ifndef __RDPPOLYPOINT_H +#define __RDPPOLYPOINT_H + +void +rdpPolyPoint(DrawablePtr pDrawable, GCPtr pGC, int mode, + int npt, DDXPointPtr in_pts); + +#endif diff --git a/xorg/server/module/rdpPolyRectangle.c b/xorg/server/module/rdpPolyRectangle.c new file mode 100644 index 00000000..e80b8178 --- /dev/null +++ b/xorg/server/module/rdpPolyRectangle.c @@ -0,0 +1,51 @@ +/* +Copyright 2005-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#include "rdp.h" +#include "rdpDraw.h" + +#define LOG_LEVEL 1 +#define LLOGLN(_level, _args) \ + do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0) + +/******************************************************************************/ +static void +rdpPolyRectangleOrg(DrawablePtr pDrawable, GCPtr pGC, int nrects, + xRectangle *rects) +{ + rdpGCPtr priv; + GCFuncs *oldFuncs; + + GC_OP_PROLOGUE(pGC); + pGC->ops->PolyRectangle(pDrawable, pGC, nrects, rects); + GC_OP_EPILOGUE(pGC); +} + +/******************************************************************************/ +/* tested with pGC->lineWidth = 0, 1, 2, 4 and opcodes 3 and 6 */ +void +rdpPolyRectangle(DrawablePtr pDrawable, GCPtr pGC, int nrects, + xRectangle *rects) +{ + LLOGLN(10, ("rdpPolyRectangle:")); + /* do original call */ + rdpPolyRectangleOrg(pDrawable, pGC, nrects, rects); +} diff --git a/xorg/server/module/rdpPolyRectangle.h b/xorg/server/module/rdpPolyRectangle.h new file mode 100644 index 00000000..d09446d5 --- /dev/null +++ b/xorg/server/module/rdpPolyRectangle.h @@ -0,0 +1,29 @@ +/* +Copyright 2005-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#ifndef __RDPPOLYRECTANGLE_H +#define __RDPPOLYRECTANGLE_H + +void +rdpPolyRectangle(DrawablePtr pDrawable, GCPtr pGC, int nrects, + xRectangle* rects); + +#endif diff --git a/xorg/server/module/rdpPolySegment.c b/xorg/server/module/rdpPolySegment.c new file mode 100644 index 00000000..f4a9d40c --- /dev/null +++ b/xorg/server/module/rdpPolySegment.c @@ -0,0 +1,48 @@ +/* +Copyright 2005-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#include "rdp.h" +#include "rdpDraw.h" + +#define LOG_LEVEL 1 +#define LLOGLN(_level, _args) \ + do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0) + +/******************************************************************************/ +void +rdpPolySegmentOrg(DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment *pSegs) +{ + rdpGCPtr priv; + GCFuncs *oldFuncs; + + GC_OP_PROLOGUE(pGC); + pGC->ops->PolySegment(pDrawable, pGC, nseg, pSegs); + GC_OP_EPILOGUE(pGC); +} + +/******************************************************************************/ +void +rdpPolySegment(DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment *pSegs) +{ + LLOGLN(10, ("rdpPolySegment:")); + /* do original call */ + rdpPolySegmentOrg(pDrawable, pGC, nseg, pSegs); +} diff --git a/xorg/server/module/rdpPolySegment.h b/xorg/server/module/rdpPolySegment.h new file mode 100644 index 00000000..8c5f33ab --- /dev/null +++ b/xorg/server/module/rdpPolySegment.h @@ -0,0 +1,28 @@ +/* +Copyright 2005-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#ifndef __RDPPOLYSEGMENT_H +#define __RDPPOLYSEGMENT_H + +void +rdpPolySegment(DrawablePtr pDrawable, GCPtr pGC, int nseg, xSegment* pSegs); + +#endif diff --git a/xorg/server/module/rdpPolyText16.c b/xorg/server/module/rdpPolyText16.c new file mode 100644 index 00000000..b5eac8c5 --- /dev/null +++ b/xorg/server/module/rdpPolyText16.c @@ -0,0 +1,55 @@ +/* +Copyright 2005-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#include "rdp.h" +#include "rdpDraw.h" + +#define LOG_LEVEL 1 +#define LLOGLN(_level, _args) \ + do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0) + +/******************************************************************************/ +int +rdpPolyText16Org(DrawablePtr pDrawable, GCPtr pGC, + int x, int y, int count, unsigned short *chars) +{ + int rv; + rdpGCPtr priv; + GCFuncs *oldFuncs; + + GC_OP_PROLOGUE(pGC); + rv = pGC->ops->PolyText16(pDrawable, pGC, x, y, count, chars); + GC_OP_EPILOGUE(pGC); + return rv; +} + +/******************************************************************************/ +int +rdpPolyText16(DrawablePtr pDrawable, GCPtr pGC, + int x, int y, int count, unsigned short *chars) +{ + int rv; + + LLOGLN(10, ("rdpPolyText16:")); + /* do original call */ + rv = rdpPolyText16Org(pDrawable, pGC, x, y, count, chars); + return rv; +} diff --git a/xorg/server/module/rdpPolyText16.h b/xorg/server/module/rdpPolyText16.h new file mode 100644 index 00000000..bcfa8379 --- /dev/null +++ b/xorg/server/module/rdpPolyText16.h @@ -0,0 +1,29 @@ +/* +Copyright 2005-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#ifndef __RDPPOLYTEXT16_H +#define __RDPPOLYTEXT16_H + +int +rdpPolyText16(DrawablePtr pDrawable, GCPtr pGC, + int x, int y, int count, unsigned short* chars); + +#endif diff --git a/xorg/server/module/rdpPolyText8.c b/xorg/server/module/rdpPolyText8.c new file mode 100644 index 00000000..8931a4c1 --- /dev/null +++ b/xorg/server/module/rdpPolyText8.c @@ -0,0 +1,55 @@ +/* +Copyright 2005-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#include "rdp.h" +#include "rdpDraw.h" + +#define LOG_LEVEL 1 +#define LLOGLN(_level, _args) \ + do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0) + +/******************************************************************************/ +int +rdpPolyText8Org(DrawablePtr pDrawable, GCPtr pGC, + int x, int y, int count, char *chars) +{ + int rv; + rdpGCPtr priv; + GCFuncs *oldFuncs; + + GC_OP_PROLOGUE(pGC); + rv = pGC->ops->PolyText8(pDrawable, pGC, x, y, count, chars); + GC_OP_EPILOGUE(pGC); + return rv; +} + +/******************************************************************************/ +int +rdpPolyText8(DrawablePtr pDrawable, GCPtr pGC, + int x, int y, int count, char *chars) +{ + int rv; + + LLOGLN(10, ("rdpPolyText8:")); + /* do original call */ + rv = rdpPolyText8Org(pDrawable, pGC, x, y, count, chars); + return rv; +} diff --git a/xorg/server/module/rdpPolyText8.h b/xorg/server/module/rdpPolyText8.h new file mode 100644 index 00000000..95e80412 --- /dev/null +++ b/xorg/server/module/rdpPolyText8.h @@ -0,0 +1,29 @@ +/* +Copyright 2005-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#ifndef __RDPPOLYTEXT8_H +#define __RDPPOLYTEXT8_H + +int +rdpPolyText8(DrawablePtr pDrawable, GCPtr pGC, + int x, int y, int count, char* chars); + +#endif diff --git a/xorg/server/module/rdpPolylines.c b/xorg/server/module/rdpPolylines.c new file mode 100644 index 00000000..b439db28 --- /dev/null +++ b/xorg/server/module/rdpPolylines.c @@ -0,0 +1,50 @@ +/* +Copyright 2005-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#include "rdp.h" +#include "rdpDraw.h" + +#define LOG_LEVEL 1 +#define LLOGLN(_level, _args) \ + do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0) + +/******************************************************************************/ +static void +rdpPolylinesOrg(DrawablePtr pDrawable, GCPtr pGC, int mode, + int npt, DDXPointPtr pptInit) +{ + rdpGCPtr priv; + GCFuncs *oldFuncs; + + GC_OP_PROLOGUE(pGC); + pGC->ops->Polylines(pDrawable, pGC, mode, npt, pptInit); + GC_OP_EPILOGUE(pGC); +} + +/******************************************************************************/ +void +rdpPolylines(DrawablePtr pDrawable, GCPtr pGC, int mode, + int npt, DDXPointPtr pptInit) +{ + LLOGLN(10, ("rdpPolylines:")); + /* do original call */ + rdpPolylinesOrg(pDrawable, pGC, mode, npt, pptInit); +} diff --git a/xorg/server/module/rdpPolylines.h b/xorg/server/module/rdpPolylines.h new file mode 100644 index 00000000..2df3d388 --- /dev/null +++ b/xorg/server/module/rdpPolylines.h @@ -0,0 +1,29 @@ +/* +Copyright 2005-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#ifndef __RDPPOLYLINES_H +#define __RDPPOLYLINES_H + +void +rdpPolylines(DrawablePtr pDrawable, GCPtr pGC, int mode, + int npt, DDXPointPtr pptInit); + +#endif diff --git a/xorg/server/module/rdpPri.c b/xorg/server/module/rdpPri.c new file mode 100644 index 00000000..43f3d883 --- /dev/null +++ b/xorg/server/module/rdpPri.c @@ -0,0 +1,176 @@ +/* +Copyright 2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +to deal with privates changing in xorg versions + +*/ + +#include +#include +#include + +/* this should be before all X11 .h files */ +#include + +/* all driver need this */ +#include +#include + +#include +#include +#include +#include + +#include "rdpPri.h" +#include "rdpMisc.h" + +#if XORG_VERSION_CURRENT < (((1) * 10000000) + ((5) * 100000) + ((0) * 1000) + 0) +/* 1.1, 1.2, 1.3, 1.4 */ +#define XRDP_PRI 1 +#elif XORG_VERSION_CURRENT < (((1) * 10000000) + ((9) * 100000) + ((0) * 1000) + 0) +/* 1.5, 1.6, 1.7, 1.8 */ +#define XRDP_PRI 2 +#else +/* 1.9, 1.10, 1.11, 1.12 */ +#define XRDP_PRI 3 +#endif + +#define PTR2INT(_ptr) ((int) ((long) ((void*) (_ptr)))) +#define INT2PTR(_int) ((void *) ((long) ((int) (_int)))) + +#if XRDP_PRI == 3 +static DevPrivateKeyRec g_privateKeyRecGC; +static DevPrivateKeyRec g_privateKeyRecPixmap; +static DevPrivateKeyRec g_privateKeyRecWindow; +#elif XRDP_PRI == 2 +static int g_privateKeyRecGC = 0; +static int g_privateKeyRecPixmap = 0; +static int g_privateKeyRecWindow = 0; +#endif + +/*****************************************************************************/ +rdpDevPrivateKey +rdpAllocateGCPrivate(ScreenPtr pScreen, int bytes) +{ + rdpDevPrivateKey rv; + +#if XRDP_PRI == 1 + rv = INT2PTR(AllocateGCPrivateIndex()); + AllocateGCPrivate(pScreen, PTR2INT(rv), bytes); +#elif XRDP_PRI == 2 + dixRequestPrivate(&g_privateKeyRecGC, bytes); + rv = &g_privateKeyRecGC; +#else + dixRegisterPrivateKey(&g_privateKeyRecGC, PRIVATE_GC, bytes); + rv = &g_privateKeyRecGC; +#endif + return rv; +} + +/*****************************************************************************/ +rdpDevPrivateKey +rdpAllocatePixmapPrivate(ScreenPtr pScreen, int bytes) +{ + rdpDevPrivateKey rv; + +#if XRDP_PRI == 1 + rv = INT2PTR(AllocatePixmapPrivateIndex()); + AllocatePixmapPrivate(pScreen, PTR2INT(rv), bytes); +#elif XRDP_PRI == 2 + dixRequestPrivate(&g_privateKeyRecPixmap, bytes); + rv = &g_privateKeyRecPixmap; +#else + dixRegisterPrivateKey(&g_privateKeyRecPixmap, PRIVATE_PIXMAP, bytes); + rv = &g_privateKeyRecPixmap; +#endif + return rv; +} + +/*****************************************************************************/ +rdpDevPrivateKey +rdpAllocateWindowPrivate(ScreenPtr pScreen, int bytes) +{ + rdpDevPrivateKey rv; + +#if XRDP_PRI == 1 + rv = INT2PTR(AllocateWindowPrivateIndex()); + AllocateWindowPrivate(pScreen, PTR2INT(rv), bytes); +#elif XRDP_PRI == 2 + dixRequestPrivate(&g_privateKeyRecWindow, bytes); + rv = &g_privateKeyRecWindow; +#else + dixRegisterPrivateKey(&g_privateKeyRecWindow, PRIVATE_WINDOW, bytes); + rv = &g_privateKeyRecWindow; +#endif + return rv; +} + +/*****************************************************************************/ +void * +rdpGetGCPrivate(GCPtr pGC, rdpDevPrivateKey key) +{ + void *rv; + +#if XRDP_PRI == 1 + rv = pGC->devPrivates[PTR2INT(key)].ptr; +#else + rv = dixLookupPrivate(&(pGC->devPrivates), key); +#endif + return rv; +} + +/*****************************************************************************/ +void * +rdpGetPixmapPrivate(PixmapPtr pPixmap, rdpDevPrivateKey key) +{ + void *rv; + +#if XRDP_PRI == 1 + rv = pPixmap->devPrivates[PTR2INT(key)].ptr; +#else + rv = dixLookupPrivate(&(pPixmap->devPrivates), key); +#endif + return rv; +} + +/*****************************************************************************/ +void * +rdpGetWindowPrivate(WindowPtr pWindow, rdpDevPrivateKey key) +{ + void *rv; + +#if XRDP_PRI == 1 + rv = pWindow->devPrivates[PTR2INT(key)].ptr; +#else + rv = dixLookupPrivate(&(pWindow->devPrivates), key); +#endif + return rv; +} + +/*****************************************************************************/ +int +rdpPrivateInit(void) +{ +#if XRDP_PRI == 3 + g_memset(&g_privateKeyRecGC, 0, sizeof(g_privateKeyRecGC)); + g_memset(&g_privateKeyRecWindow, 0, sizeof(g_privateKeyRecWindow)); + g_memset(&g_privateKeyRecPixmap, 0, sizeof(g_privateKeyRecPixmap)); +#endif + return 0; +} diff --git a/xorg/server/module/rdpPri.h b/xorg/server/module/rdpPri.h new file mode 100644 index 00000000..625947a3 --- /dev/null +++ b/xorg/server/module/rdpPri.h @@ -0,0 +1,47 @@ +/* +Copyright 2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +to deal with privates changing in xorg versions + +*/ + +#ifndef _XRDPPRI_H +#define _XRDPPRI_H + +#include +#include + +typedef void* rdpDevPrivateKey; + +rdpDevPrivateKey +rdpAllocateGCPrivate(ScreenPtr pScreen, int bytes); +rdpDevPrivateKey +rdpAllocatePixmapPrivate(ScreenPtr pScreen, int bytes); +rdpDevPrivateKey +rdpAllocateWindowPrivate(ScreenPtr pScreen, int bytes); +void* +rdpGetGCPrivate(GCPtr pGC, rdpDevPrivateKey key); +void* +rdpGetPixmapPrivate(PixmapPtr pPixmap, rdpDevPrivateKey key); +void* +rdpGetWindowPrivate(WindowPtr pWindow, rdpDevPrivateKey key); +int +rdpPrivateInit(void); + +#endif diff --git a/xorg/server/module/rdpPushPixels.c b/xorg/server/module/rdpPushPixels.c new file mode 100644 index 00000000..3491d556 --- /dev/null +++ b/xorg/server/module/rdpPushPixels.c @@ -0,0 +1,50 @@ +/* +Copyright 2005-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#include "rdp.h" +#include "rdpDraw.h" + +#define LOG_LEVEL 1 +#define LLOGLN(_level, _args) \ + do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0) + +/******************************************************************************/ +void +rdpPushPixelsOrg(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDst, + int w, int h, int x, int y) +{ + rdpGCPtr priv; + GCFuncs *oldFuncs; + + GC_OP_PROLOGUE(pGC); + pGC->ops->PushPixels(pGC, pBitMap, pDst, w, h, x, y); + GC_OP_EPILOGUE(pGC); +} + +/******************************************************************************/ +void +rdpPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDst, + int w, int h, int x, int y) +{ + LLOGLN(10, ("rdpPushPixels:")); + /* do original call */ + rdpPushPixelsOrg(pGC, pBitMap, pDst, w, h, x, y); +} diff --git a/xorg/server/module/rdpPushPixels.h b/xorg/server/module/rdpPushPixels.h new file mode 100644 index 00000000..2e0cd1d1 --- /dev/null +++ b/xorg/server/module/rdpPushPixels.h @@ -0,0 +1,29 @@ +/* +Copyright 2005-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#ifndef __RDPPUSHPIXELS_H +#define __RDPPUSHPIXELS_H + +void +rdpPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDst, + int w, int h, int x, int y); + +#endif diff --git a/xorg/server/module/rdpPutImage.c b/xorg/server/module/rdpPutImage.c new file mode 100644 index 00000000..2d9faa89 --- /dev/null +++ b/xorg/server/module/rdpPutImage.c @@ -0,0 +1,51 @@ +/* +Copyright 2005-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#include "rdp.h" +#include "rdpDraw.h" + +#define LOG_LEVEL 1 +#define LLOGLN(_level, _args) \ + do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0) + +/******************************************************************************/ +static void +rdpPutImageOrg(DrawablePtr pDst, GCPtr pGC, int depth, int x, int y, + int w, int h, int leftPad, int format, char *pBits) +{ + rdpGCPtr priv; + GCFuncs *oldFuncs; + + GC_OP_PROLOGUE(pGC); + pGC->ops->PutImage(pDst, pGC, depth, x, y, w, h, leftPad, + format, pBits); + GC_OP_EPILOGUE(pGC); +} + +/******************************************************************************/ +void +rdpPutImage(DrawablePtr pDst, GCPtr pGC, int depth, int x, int y, + int w, int h, int leftPad, int format, char *pBits) +{ + LLOGLN(10, ("rdpPutImage:")); + /* do original call */ + rdpPutImageOrg(pDst, pGC, depth, x, y, w, h, leftPad, format, pBits); +} diff --git a/xorg/server/module/rdpPutImage.h b/xorg/server/module/rdpPutImage.h new file mode 100644 index 00000000..82e27872 --- /dev/null +++ b/xorg/server/module/rdpPutImage.h @@ -0,0 +1,29 @@ +/* +Copyright 2005-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#ifndef __RDPPUTIMAGE_H +#define __RDPPUTIMAGE_H + +void +rdpPutImage(DrawablePtr pDst, GCPtr pGC, int depth, int x, int y, + int w, int h, int leftPad, int format, char* pBits); + +#endif diff --git a/xorg/server/module/rdpRandR.c b/xorg/server/module/rdpRandR.c new file mode 100644 index 00000000..fd080184 --- /dev/null +++ b/xorg/server/module/rdpRandR.c @@ -0,0 +1,309 @@ +/* +Copyright 2011-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +RandR draw calls + +*/ + +#include +#include +#include + +/* this should be before all X11 .h files */ +#include + +/* all driver need this */ +#include +#include + +#include +#include +#include +#include + +#include "rdp.h" +#include "rdpDraw.h" +#include "rdpReg.h" +#include "rdpMisc.h" + +/******************************************************************************/ +#define LOG_LEVEL 1 +#define LLOGLN(_level, _args) \ + do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0) + +/******************************************************************************/ +Bool +rdpRRRegisterSize(ScreenPtr pScreen, int width, int height) +{ + int mmwidth; + int mmheight; + RRScreenSizePtr pSize; + + LLOGLN(0, ("rdpRRRegisterSize: width %d height %d", width, height)); + mmwidth = PixelToMM(width); + mmheight = PixelToMM(height); + pSize = RRRegisterSize(pScreen, width, height, mmwidth, mmheight); + /* Tell RandR what the current config is */ + RRSetCurrentConfig(pScreen, RR_Rotate_0, 0, pSize); + return TRUE; +} + +/******************************************************************************/ +Bool +rdpRRSetConfig(ScreenPtr pScreen, Rotation rotateKind, int rate, + RRScreenSizePtr pSize) +{ + ScrnInfoPtr pScrn; + rdpPtr dev; + rrScrPrivPtr pRRScrPriv; + Bool rv; + + LLOGLN(0, ("rdpRRSetConfig:")); + rv = TRUE; + pScrn = xf86Screens[pScreen->myNum]; + dev = XRDPPTR(pScrn); +#if 0 + pRRScrPriv = rrGetScrPriv(pScreen); + if (pRRScrPriv != 0) + { + if (dev->rrSetConfig != 0) + { + LLOGLN(0, ("rdpRRSetConfig: here")); + pRRScrPriv->rrSetConfig = dev->rrSetConfig; + rv = pRRScrPriv->rrSetConfig(pScreen, rotateKind, rate, pSize); + pRRScrPriv->rrSetConfig = rdpRRSetConfig; + } + } +#endif + return rv; +} + +/******************************************************************************/ +Bool +rdpRRGetInfo(ScreenPtr pScreen, Rotation *pRotations) +{ + int width; + int height; + ScrnInfoPtr pScrn; + rdpPtr dev; + rrScrPrivPtr pRRScrPriv; + Bool rv; + + LLOGLN(0, ("rdpRRGetInfo:")); + rv = TRUE; + pScrn = xf86Screens[pScreen->myNum]; + dev = XRDPPTR(pScrn); +#if 0 + pRRScrPriv = rrGetScrPriv(pScreen); + if (pRRScrPriv != 0) + { + if (dev->rrGetInfo != 0) + { + LLOGLN(0, ("rdpRRGetInfo: here")); + pRRScrPriv->rrGetInfo = dev->rrGetInfo; + rv = pRRScrPriv->rrGetInfo(pScreen, pRotations); + pRRScrPriv->rrGetInfo = rdpRRGetInfo; + } + } +#else + *pRotations = RR_Rotate_0; + width = dev->width; + height = dev->height; + rdpRRRegisterSize(pScreen, width, height); +#endif + return rv; +} + +/******************************************************************************/ +Bool +rdpRRScreenSetSize(ScreenPtr pScreen, CARD16 width, CARD16 height, + CARD32 mmWidth, CARD32 mmHeight) +{ + WindowPtr root; + PixmapPtr screenPixmap; + BoxRec box; + ScrnInfoPtr pScrn; + rdpPtr dev; + + LLOGLN(0, ("rdpRRScreenSetSize: width %d height %d mmWidth %d mmHeight %d", + width, height, (int)mmWidth, (int)mmHeight)); + pScrn = xf86Screens[pScreen->myNum]; + dev = XRDPPTR(pScrn); + root = rdpGetRootWindowPtr(pScreen); + if ((width < 1) || (height < 1)) + { + LLOGLN(10, (" error width %d height %d", width, height)); + return FALSE; + } + dev->width = width; + dev->height = height; + dev->paddedWidthInBytes = PixmapBytePad(dev->width, dev->depth); + dev->sizeInBytes = dev->paddedWidthInBytes * dev->height; + pScreen->width = width; + pScreen->height = height; + pScreen->mmWidth = mmWidth; + pScreen->mmHeight = mmHeight; + screenPixmap = pScreen->GetScreenPixmap(pScreen); + g_free(dev->pfbMemory); + dev->pfbMemory = (char *) g_malloc(dev->sizeInBytes, 1); + if (screenPixmap != 0) + { + pScreen->ModifyPixmapHeader(screenPixmap, width, height, + -1, -1, + dev->paddedWidthInBytes, + dev->pfbMemory); + } + box.x1 = 0; + box.y1 = 0; + box.x2 = width; + box.y2 = height; + rdpRegionInit(&root->winSize, &box, 1); + rdpRegionInit(&root->borderSize, &box, 1); + rdpRegionReset(&root->borderClip, &box); + rdpRegionBreak(&root->clipList); + root->drawable.width = width; + root->drawable.height = height; + ResizeChildrenWinSize(root, 0, 0, 0, 0); + RRGetInfo(pScreen, 1); + LLOGLN(0, (" screen resized to %dx%d", pScreen->width, pScreen->height)); + RRScreenSizeNotify(pScreen); + xf86EnableDisableFBAccess(pScreen->myNum, FALSE); + xf86EnableDisableFBAccess(pScreen->myNum, TRUE); + return TRUE; +} + +/******************************************************************************/ +Bool +rdpRRCrtcSet(ScreenPtr pScreen, RRCrtcPtr crtc, RRModePtr mode, + int x, int y, Rotation rotation, int numOutputs, + RROutputPtr *outputs) +{ + LLOGLN(0, ("rdpRRCrtcSet:")); + return TRUE; +} + +/******************************************************************************/ +Bool +rdpRRCrtcSetGamma(ScreenPtr pScreen, RRCrtcPtr crtc) +{ + LLOGLN(0, ("rdpRRCrtcSetGamma:")); + return TRUE; +} + +/******************************************************************************/ +Bool +rdpRRCrtcGetGamma(ScreenPtr pScreen, RRCrtcPtr crtc) +{ + LLOGLN(0, ("rdpRRCrtcGetGamma: %p %p %p %p", crtc, crtc->gammaRed, + crtc->gammaBlue, crtc->gammaGreen)); + crtc->gammaSize = 1; + if (crtc->gammaRed == NULL) + { + crtc->gammaRed = g_malloc(32, 1); + } + if (crtc->gammaBlue == NULL) + { + crtc->gammaBlue = g_malloc(32, 1); + } + if (crtc->gammaGreen == NULL) + { + crtc->gammaGreen = g_malloc(32, 1); + } + return TRUE; +} + +/******************************************************************************/ +Bool +rdpRROutputSetProperty(ScreenPtr pScreen, RROutputPtr output, Atom property, + RRPropertyValuePtr value) +{ + LLOGLN(0, ("rdpRROutputSetProperty:")); + return TRUE; +} + +/******************************************************************************/ +Bool +rdpRROutputValidateMode(ScreenPtr pScreen, RROutputPtr output, + RRModePtr mode) +{ + LLOGLN(0, ("rdpRROutputValidateMode:")); + return TRUE; +} + +/******************************************************************************/ +void +rdpRRModeDestroy(ScreenPtr pScreen, RRModePtr mode) +{ + LLOGLN(0, ("rdpRRModeDestroy:")); +} + +/******************************************************************************/ +Bool +rdpRROutputGetProperty(ScreenPtr pScreen, RROutputPtr output, Atom property) +{ + LLOGLN(0, ("rdpRROutputGetProperty:")); + return TRUE; +} + +/******************************************************************************/ +Bool +rdpRRGetPanning(ScreenPtr pScreen, RRCrtcPtr crtc, BoxPtr totalArea, + BoxPtr trackingArea, INT16 *border) +{ + ScrnInfoPtr pScrn; + rdpPtr dev; + + LLOGLN(0, ("rdpRRGetPanning: %p", crtc)); + pScrn = xf86Screens[pScreen->myNum]; + dev = XRDPPTR(pScrn); + + if (totalArea != 0) + { + totalArea->x1 = 0; + totalArea->y1 = 0; + totalArea->x2 = dev->width; + totalArea->y2 = dev->height; + } + + if (trackingArea != 0) + { + trackingArea->x1 = 0; + trackingArea->y1 = 0; + trackingArea->x2 = dev->width; + trackingArea->y2 = dev->height; + } + + if (border != 0) + { + border[0] = 0; + border[1] = 0; + border[2] = 0; + border[3] = 0; + } + return TRUE; +} + +/******************************************************************************/ +Bool +rdpRRSetPanning(ScreenPtr pScreen, RRCrtcPtr crtc, BoxPtr totalArea, + BoxPtr trackingArea, INT16 *border) +{ + LLOGLN(0, ("rdpRRSetPanning:")); + return TRUE; +} diff --git a/xorg/server/module/rdpRandR.h b/xorg/server/module/rdpRandR.h new file mode 100644 index 00000000..3aba7e1a --- /dev/null +++ b/xorg/server/module/rdpRandR.h @@ -0,0 +1,60 @@ +/* +Copyright 2011-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#ifndef _RDPRANDR_H +#define _RDPRANDR_H + +Bool +rdpRRRegisterSize(ScreenPtr pScreen, int width, int height); +Bool +rdpRRGetInfo(ScreenPtr pScreen, Rotation* pRotations); +Bool +rdpRRSetConfig(ScreenPtr pScreen, Rotation rotateKind, int rate, + RRScreenSizePtr pSize); +Bool +rdpRRScreenSetSize(ScreenPtr pScreen, CARD16 width, CARD16 height, + CARD32 mmWidth, CARD32 mmHeight); +Bool +rdpRRCrtcSet(ScreenPtr pScreen, RRCrtcPtr crtc, RRModePtr mode, + int x, int y, Rotation rotation, int numOutputs, + RROutputPtr* outputs); +Bool +rdpRRCrtcSetGamma(ScreenPtr pScreen, RRCrtcPtr crtc); +Bool +rdpRRCrtcGetGamma(ScreenPtr pScreen, RRCrtcPtr crtc); +Bool +rdpRROutputSetProperty(ScreenPtr pScreen, RROutputPtr output, Atom property, + RRPropertyValuePtr value); +Bool +rdpRROutputValidateMode(ScreenPtr pScreen, RROutputPtr output, + RRModePtr mode); +void +rdpRRModeDestroy(ScreenPtr pScreen, RRModePtr mode); +Bool +rdpRROutputGetProperty(ScreenPtr pScreen, RROutputPtr output, Atom property); +Bool +rdpRRGetPanning(ScreenPtr pScrn, RRCrtcPtr crtc, BoxPtr totalArea, + BoxPtr trackingArea, INT16* border); +Bool +rdpRRSetPanning(ScreenPtr pScrn, RRCrtcPtr crtc, BoxPtr totalArea, + BoxPtr trackingArea, INT16* border); + +#endif diff --git a/xorg/server/module/rdpReg.c b/xorg/server/module/rdpReg.c new file mode 100644 index 00000000..3a343f14 --- /dev/null +++ b/xorg/server/module/rdpReg.c @@ -0,0 +1,233 @@ +/* +Copyright 2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +to deal with regions changing in xorg versions + +*/ +#include +#include +#include + +/* this should be before all X11 .h files */ +#include + +/* all driver need this */ +#include +#include + +/* +miRegionCopy -> RegionCopy +miTranslateRegion -> RegionTranslate +miRegionNotEmpty -> RegionNotEmpty +miIntersect -> RegionIntersect +miRectIn -> RegionContainsRect +miRegionInit -> RegionInit +miRegionUninit -> RegionUninit +miRectsToRegion -> RegionFromRects +miRegionDestroy -> RegionDestroy +miRegionCreate -> RegionCreate +miUnion -> RegionUnion +miRegionExtents -> RegionExtents +miRegionReset -> RegionReset +miRegionBreak -> RegionBreak +*/ + +#if XORG_VERSION_CURRENT < (((1) * 10000000) + ((9) * 100000) + ((0) * 1000) + 0) +/* 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8 */ +#define XRDP_REG 1 +#else +/* 1.9, 1.10, 1.11, 1.12 */ +#define XRDP_REG 2 +#endif + +/*****************************************************************************/ +Bool +rdpRegionCopy(RegionPtr dst, RegionPtr src) +{ +#if XRDP_REG == 1 + return miRegionCopy(dst, src); +#else + return RegionCopy(dst, src); +#endif +} + +/*****************************************************************************/ +void +rdpRegionTranslate(RegionPtr pReg, int x, int y) +{ +#if XRDP_REG == 1 + miTranslateRegion(pReg, x, y); +#else + RegionTranslate(pReg, x, y); +#endif +} + +/*****************************************************************************/ +Bool +rdpRegionNotEmpty(RegionPtr pReg) +{ +#if XRDP_REG == 1 + return miRegionNotEmpty(pReg); +#else + return RegionNotEmpty(pReg); +#endif +} + +/*****************************************************************************/ +Bool +rdpRegionIntersect(RegionPtr newReg, RegionPtr reg1, RegionPtr reg2) +{ +#if XRDP_REG == 1 + return miIntersect(newReg, reg1, reg2); +#else + return RegionIntersect(newReg, reg1, reg2); +#endif +} + +/*****************************************************************************/ +int +rdpRegionContainsRect(RegionPtr region, BoxPtr prect) +{ +#if XRDP_REG == 1 + return miRectIn(region, prect); +#else + return RegionContainsRect(region, prect); +#endif +} + +/*****************************************************************************/ +void +rdpRegionInit(RegionPtr pReg, BoxPtr rect, int size) +{ +#if XRDP_REG == 1 + miRegionInit(pReg, rect, size); +#else + RegionInit(pReg, rect, size); +#endif +} + +/*****************************************************************************/ +void +rdpRegionUninit(RegionPtr pReg) +{ +#if XRDP_REG == 1 + miRegionUninit(pReg); +#else + RegionUninit(pReg); +#endif +} + +/*****************************************************************************/ +RegionPtr +rdpRegionFromRects(int nrects, xRectanglePtr prect, int ctype) +{ +#if XRDP_REG == 1 + return miRectsToRegion(nrects, prect, ctype); +#else + return RegionFromRects(nrects, prect, ctype); +#endif +} + +/*****************************************************************************/ +void +rdpRegionDestroy(RegionPtr pReg) +{ +#if XRDP_REG == 1 + miRegionDestroy(pReg); +#else + RegionDestroy(pReg); +#endif +} + +/*****************************************************************************/ +RegionPtr +rdpRegionCreate(BoxPtr rect, int size) +{ +#if XRDP_REG == 1 + return miRegionCreate(rect, size); +#else + return RegionCreate(rect, size); +#endif +} + +/*****************************************************************************/ +Bool +rdpRegionUnion(RegionPtr newReg, RegionPtr reg1, RegionPtr reg2) +{ +#if XRDP_REG == 1 + return miUnion(newReg, reg1, reg2); +#else + return RegionUnion(newReg, reg1, reg2); +#endif +} + +/*****************************************************************************/ +Bool +rdpRegionSubtract(RegionPtr newReg, RegionPtr reg1, RegionPtr reg2) +{ +#if XRDP_REG == 1 + return miSubtract(newReg, reg1, reg2); +#else + return RegionSubtract(newReg, reg1, reg2); +#endif +} + +/*****************************************************************************/ +Bool +rdpRegionInverse(RegionPtr newReg, RegionPtr reg1, BoxPtr invRect) +{ +#if XRDP_REG == 1 + return miInverse(newReg, reg1, invRect); +#else + return RegionInverse(newReg, reg1, invRect); +#endif +} + +/*****************************************************************************/ +BoxPtr +rdpRegionExtents(RegionPtr pReg) +{ +#if XRDP_REG == 1 + return miRegionExtents(pReg); +#else + return RegionExtents(pReg); +#endif +} + +/*****************************************************************************/ +void +rdpRegionReset(RegionPtr pReg, BoxPtr pBox) +{ +#if XRDP_REG == 1 + miRegionReset(pReg, pBox); +#else + RegionReset(pReg, pBox); +#endif +} + +/*****************************************************************************/ +Bool +rdpRegionBreak(RegionPtr pReg) +{ +#if XRDP_REG == 1 + return miRegionBreak(pReg); +#else + return RegionBreak(pReg); +#endif +} diff --git a/xorg/server/module/rdpReg.h b/xorg/server/module/rdpReg.h new file mode 100644 index 00000000..b788cd69 --- /dev/null +++ b/xorg/server/module/rdpReg.h @@ -0,0 +1,60 @@ +/* +Copyright 2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +to deal with regions changing in xorg versions + +*/ + +#ifndef __RDPREG_H +#define __RDPREG_H + +Bool +rdpRegionCopy(RegionPtr dst, RegionPtr src); +void +rdpRegionTranslate(RegionPtr pReg, int x, int y); +Bool +rdpRegionNotEmpty(RegionPtr pReg); +Bool +rdpRegionIntersect(RegionPtr newReg, RegionPtr reg1, RegionPtr reg2); +int +rdpRegionContainsRect(RegionPtr region, BoxPtr prect); +void +rdpRegionInit(RegionPtr pReg, BoxPtr rect, int size); +void +rdpRegionUninit(RegionPtr pReg); +RegionPtr +rdpRegionFromRects(int nrects, xRectanglePtr prect, int ctype); +void +rdpRegionDestroy(RegionPtr pReg); +RegionPtr +rdpRegionCreate(BoxPtr rect, int size); +Bool +rdpRegionUnion(RegionPtr newReg, RegionPtr reg1, RegionPtr reg2); +Bool +rdpRegionSubtract(RegionPtr newReg, RegionPtr reg1, RegionPtr reg2); +Bool +rdpRegionInverse(RegionPtr newReg, RegionPtr reg1, BoxPtr invRect); +BoxPtr +rdpRegionExtents(RegionPtr pReg); +void +rdpRegionReset(RegionPtr pReg, BoxPtr pBox); +Bool +rdpRegionBreak(RegionPtr pReg); + +#endif diff --git a/xorg/server/module/rdpSetSpans.c b/xorg/server/module/rdpSetSpans.c new file mode 100644 index 00000000..1bd9ed80 --- /dev/null +++ b/xorg/server/module/rdpSetSpans.c @@ -0,0 +1,52 @@ +/* +Copyright 2005-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#include "rdp.h" +#include "rdpDraw.h" + +#define LDEBUG 0 + +#define LOG_LEVEL 1 +#define LLOGLN(_level, _args) \ + do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0) + +/******************************************************************************/ +void +rdpSetSpansOrg(DrawablePtr pDrawable, GCPtr pGC, char *psrc, + DDXPointPtr ppt, int *pwidth, int nspans, int fSorted) +{ + rdpGCPtr priv; + GCFuncs *oldFuncs; + + GC_OP_PROLOGUE(pGC); + pGC->ops->SetSpans(pDrawable, pGC, psrc, ppt, pwidth, nspans, fSorted); + GC_OP_EPILOGUE(pGC); +} + +/******************************************************************************/ +void +rdpSetSpans(DrawablePtr pDrawable, GCPtr pGC, char *psrc, + DDXPointPtr ppt, int *pwidth, int nspans, int fSorted) +{ + LLOGLN(0, ("rdpSetSpans:")); + /* do original call */ + rdpSetSpansOrg(pDrawable, pGC, psrc, ppt, pwidth, nspans, fSorted); +} diff --git a/xorg/server/module/rdpSetSpans.h b/xorg/server/module/rdpSetSpans.h new file mode 100644 index 00000000..acaedd66 --- /dev/null +++ b/xorg/server/module/rdpSetSpans.h @@ -0,0 +1,29 @@ +/* +Copyright 2005-2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +*/ + +#ifndef __RDPSETSPANS_H +#define __RDPSETSPANS_H + +void +rdpSetSpans(DrawablePtr pDrawable, GCPtr pGC, char* psrc, + DDXPointPtr ppt, int* pwidth, int nspans, int fSorted); + +#endif diff --git a/xorg/server/readme.txt b/xorg/server/readme.txt new file mode 100644 index 00000000..1207efda --- /dev/null +++ b/xorg/server/readme.txt @@ -0,0 +1,46 @@ + +Notes for building xrdpdev_drv.so and libxorgxrdp.so + + + +to run it +create /etc/X11/xrdp +copy xorg.conf into it + +copy xrdpdev_drv.so to /usr/lib/xorg/modules/drivers +copy libxorgxrdp.so to /usr/lib/xorg/modules + +copy xrdpmouse_drv.so to /usr/lib/xorg/modules/input +copy xrdpkeyb_drv.so to /usr/lib/xorg/modules/input + +start xserver like this +Xorg -modulepath /usr/lib/xorg/modules -config xrdp/xorg.conf -logfile /tmp/Xjay.log -novtswitch -sharevts -noreset -nohwaccess -ac :10 +or this on older Xorg but need /dev/vc/ thing below +Xorg -modulepath /home/jay/xorg-modules -config xrdp/xorg.conf -logfile /tmp/Xjay.log -novtswitch -sharevts -noreset -ac vt7 :10 + +older Xorg don't have -nohwaccess so you need to run Xorg as root +or do something like this. + +sudo rm /dev/tty0 +sudo mknod -m 666 /dev/tty0 c 4 0 + +sudo mkdir /dev/vc/ +sudo mknod -m 666 /dev/vc/7 c 7 7 + +--modules + libfb.so + libint10.so + libvbe.so + libxorgxrdp.so +----drivers + xrdpdev_drv.so +----extensions + libdbe.so + libdri.so + libdri2.so + libextmod.so + libglx.so + librecord.so +----input + xrdpkeyb_drv.so + xrdpmouse_drv.so diff --git a/xorg/server/xrdpdev/Makefile b/xorg/server/xrdpdev/Makefile new file mode 100644 index 00000000..0219959e --- /dev/null +++ b/xorg/server/xrdpdev/Makefile @@ -0,0 +1,16 @@ + +OBJS = xrdpdev.o + +CFLAGS = -g -O2 -Wall -fPIC -I/usr/include/xorg -I/usr/include/pixman-1 -I../module + +LDFLAGS = + +LIBS = + +all: xrdpdev_drv.so + +xrdpdev_drv.so: $(OBJS) Makefile + $(CC) -shared -o xrdpdev_drv.so $(LDFLAGS) $(OBJS) $(LIBS) + +clean: + rm -f $(OBJS) xrdpdev_drv.so diff --git a/xorg/server/xrdpdev/xorg.conf b/xorg/server/xrdpdev/xorg.conf new file mode 100644 index 00000000..1c9d7cfc --- /dev/null +++ b/xorg/server/xrdpdev/xorg.conf @@ -0,0 +1,68 @@ + +Section "ServerLayout" + Identifier "X11 Server" + Screen "Screen (xrdpdev)" + InputDevice "xrdpMouse" "CorePointer" + InputDevice "xrdpKeyboard" "CoreKeyboard" +EndSection + +Section "ServerFlags" + Option "DontVTSwitch" "on" + Option "AutoAddDevices" "off" +EndSection + +Section "Files" + FontPath "/usr/X11R6/lib/X11/fonts/misc/:unscaled" + FontPath "/usr/X11R6/lib/X11/fonts/75dpi/:unscaled" + FontPath "/usr/X11R6/lib/X11/fonts/100dpi/:unscaled" + FontPath "/usr/X11R6/lib/X11/fonts/viewtouch" +EndSection + +Section "Module" + Load "dbe" + Load "ddc" + Load "extmod" + Load "glx" + Load "int10" + Load "record" + Load "vbe" + Load "xorgxrdp" + Load "fb" +EndSection + +Section "InputDevice" + Identifier "xrdpKeyboard" + Driver "xrdpkeyb" +EndSection + +Section "InputDevice" + Identifier "xrdpMouse" + Driver "xrdpmouse" +EndSection + +Section "Monitor" + Identifier "Monitor" + Option "DPMS" + HorizSync 30-80 + VertRefresh 60-75 + ModeLine "1920x1080" 138.500 1920 1968 2000 2080 1080 1083 1088 1111 +hsync -vsync + ModeLine "1280x720" 74.25 1280 1720 1760 1980 720 725 730 750 +HSync +VSync + Modeline "1368x768" 72.25 1368 1416 1448 1528 768 771 781 790 +hsync -vsync + Modeline "1600x900" 119.00 1600 1696 1864 2128 900 901 904 932 -hsync +vsync +EndSection + +Section "Device" + Identifier "Video Card (xrdpdev)" + Driver "xrdpdev" +EndSection + +Section "Screen" + Identifier "Screen (xrdpdev)" + Device "Video Card (xrdpdev)" + Monitor "Monitor" + DefaultDepth 24 + SubSection "Display" + Depth 24 + Modes "640x480" "800x600" "1024x768" "1280x720" "1280x1024" "1600x900" "1920x1080" + EndSubSection +EndSection diff --git a/xorg/server/xrdpdev/xrdpdev.c b/xorg/server/xrdpdev/xrdpdev.c new file mode 100644 index 00000000..cc863d4d --- /dev/null +++ b/xorg/server/xrdpdev/xrdpdev.c @@ -0,0 +1,705 @@ +/* +Copyright 2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +This is the main driver file + +*/ + +#include +#include +#include + +/* this should be before all X11 .h files */ +#include + +/* all driver need this */ +#include +#include + +#include +#include +#include +#include +#include + +#include "rdp.h" +#include "rdpPri.h" +#include "rdpDraw.h" +#include "rdpGC.h" +#include "rdpCursor.h" +#include "rdpRandR.h" +#include "rdpMisc.h" +#include "rdpComposite.h" +#include "rdpGlyphs.h" + +#define XRDP_DRIVER_NAME "XRDPDEV" +#define XRDP_NAME "XRDPDEV" +#define XRDP_VERSION 1000 + +#define PACKAGE_VERSION_MAJOR 1 +#define PACKAGE_VERSION_MINOR 0 +#define PACKAGE_VERSION_PATCHLEVEL 0 + +#define LLOG_LEVEL 1 +#define LLOGLN(_level, _args) \ + do \ + { \ + if (_level < LLOG_LEVEL) \ + { \ + ErrorF _args ; \ + ErrorF("\n"); \ + } \ + } \ + while (0) + +int g_bpp = 32; +int g_depth = 24; +int g_rgb_bits = 8; +int g_redOffset = 16; +int g_redBits = 8; +int g_greenOffset = 8; +int g_greenBits = 8; +int g_blueOffset = 0; +int g_blueBits = 8; + +static int g_setup_done = 0; +static OsTimerPtr g_timer = 0; + +/* Supported "chipsets" */ +static SymTabRec g_Chipsets[] = +{ + { 0, XRDP_DRIVER_NAME }, + { -1, 0 } +}; + +static XF86ModuleVersionInfo g_VersRec = +{ + XRDP_DRIVER_NAME, + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XORG_VERSION_CURRENT, + PACKAGE_VERSION_MAJOR, + PACKAGE_VERSION_MINOR, + PACKAGE_VERSION_PATCHLEVEL, + ABI_CLASS_VIDEODRV, + ABI_VIDEODRV_VERSION, + 0, + { 0, 0, 0, 0 } +}; + +/*****************************************************************************/ +static Bool +rdpAllocRec(ScrnInfoPtr pScrn) +{ + LLOGLN(10, ("rdpAllocRec:")); + if (pScrn->driverPrivate != 0) + { + return TRUE; + } + /* xnfcalloc exits if alloc failed */ + pScrn->driverPrivate = xnfcalloc(sizeof(rdpRec), 1); + return TRUE; +} + +/*****************************************************************************/ +static void +rdpFreeRec(ScrnInfoPtr pScrn) +{ + LLOGLN(10, ("rdpFreeRec:")); + if (pScrn->driverPrivate == 0) + { + return; + } + free(pScrn->driverPrivate); + pScrn->driverPrivate = 0; +} + +/*****************************************************************************/ +static Bool +rdpPreInit(ScrnInfoPtr pScrn, int flags) +{ + rgb zeros1; + Gamma zeros2; + int got_res_match; + char **modename; + DisplayModePtr mode; + rdpPtr dev; + + LLOGLN(0, ("rdpPreInit:")); + if (flags & PROBE_DETECT) + { + return FALSE; + } + if (pScrn->numEntities != 1) + { + return FALSE; + } + + rdpPrivateInit(); + + rdpAllocRec(pScrn); + dev = XRDPPTR(pScrn); + + dev->width = 1024; + dev->height = 768; + + pScrn->monitor = pScrn->confScreen->monitor; + pScrn->bitsPerPixel = g_bpp; + pScrn->virtualX = dev->width; + pScrn->displayWidth = dev->width; + pScrn->virtualY = dev->height; + pScrn->progClock = 1; + pScrn->rgbBits = g_rgb_bits; + pScrn->depth = g_depth; + pScrn->chipset = XRDP_DRIVER_NAME; + pScrn->currentMode = pScrn->modes; + pScrn->offset.blue = g_blueOffset; + pScrn->offset.green = g_greenOffset; + pScrn->offset.red = g_redOffset; + pScrn->mask.blue = ((1 << g_blueBits) - 1) << pScrn->offset.blue; + pScrn->mask.green = ((1 << g_greenBits) - 1) << pScrn->offset.green; + pScrn->mask.red = ((1 << g_redBits) - 1) << pScrn->offset.red; + + if (!xf86SetDepthBpp(pScrn, g_depth, g_bpp, g_bpp, + Support24bppFb | Support32bppFb | + SupportConvert32to24 | SupportConvert24to32)) + { + LLOGLN(0, ("rdpPreInit: xf86SetDepthBpp failed")); + rdpFreeRec(pScrn); + return FALSE; + } + xf86PrintDepthBpp(pScrn); + g_memset(&zeros1, 0, sizeof(zeros1)); + if (!xf86SetWeight(pScrn, zeros1, zeros1)) + { + LLOGLN(0, ("rdpPreInit: xf86SetWeight failed")); + rdpFreeRec(pScrn); + return FALSE; + } + g_memset(&zeros2, 0, sizeof(zeros2)); + if (!xf86SetGamma(pScrn, zeros2)) + { + LLOGLN(0, ("rdpPreInit: xf86SetGamma failed")); + rdpFreeRec(pScrn); + return FALSE; + } + if (!xf86SetDefaultVisual(pScrn, -1)) + { + LLOGLN(0, ("rdpPreInit: xf86SetDefaultVisual failed")); + rdpFreeRec(pScrn); + return FALSE; + } + xf86SetDpi(pScrn, 0, 0); + if (0 == pScrn->display->modes) + { + LLOGLN(0, ("rdpPreInit: modes error")); + rdpFreeRec(pScrn); + return FALSE; + } + + pScrn->virtualX = pScrn->display->virtualX; + pScrn->virtualY = pScrn->display->virtualY; + + got_res_match = 0; + for (modename = pScrn->display->modes; *modename != 0; modename++) + { + for (mode = pScrn->monitor->Modes; mode != 0; mode = mode->next) + { + LLOGLN(10, ("%s %s", mode->name, *modename)); + if (0 == strcmp(mode->name, *modename)) + { + break; + } + } + if (0 == mode) + { + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "\tmode \"%s\" not found\n", + *modename); + continue; + } + xf86DrvMsg(pScrn->scrnIndex, X_INFO, "\tmode \"%s\" ok\n", *modename); + LLOGLN(10, ("%d %d %d %d", mode->HDisplay, dev->width, + mode->VDisplay, dev->height)); + if ((mode->HDisplay == dev->width) && (mode->VDisplay == dev->height)) + { + pScrn->virtualX = mode->HDisplay; + pScrn->virtualY = mode->VDisplay; + got_res_match = 1; + } + if (got_res_match) + { + pScrn->modes = xf86DuplicateMode(mode); + pScrn->modes->next = pScrn->modes; + pScrn->modes->prev = pScrn->modes; + dev->num_modes = 1; + break; + } + } + pScrn->currentMode = pScrn->modes; + xf86PrintModes(pScrn); + LLOGLN(10, ("rdpPreInit: out fPtr->num_modes %d", dev->num_modes)); + if (!got_res_match) + { + LLOGLN(0, ("rdpPreInit: could not find screen resolution %dx%d", + dev->width, dev->height)); + return FALSE; + } + return TRUE; +} + +/******************************************************************************/ +static miPointerSpriteFuncRec g_rdpSpritePointerFuncs = +{ + /* these are in rdpCursor.c */ + rdpSpriteRealizeCursor, + rdpSpriteUnrealizeCursor, + rdpSpriteSetCursor, + rdpSpriteMoveCursor, + rdpSpriteDeviceCursorInitialize, + rdpSpriteDeviceCursorCleanup +}; + +/******************************************************************************/ +static Bool +rdpSaveScreen(ScreenPtr pScreen, int on) +{ + LLOGLN(0, ("rdpSaveScreen:")); + return TRUE; +} + +/******************************************************************************/ +static Bool +rdpResizeSession(rdpPtr dev, int width, int height) +{ + int mmwidth; + int mmheight; + RRScreenSizePtr pSize; + Bool ok; + + LLOGLN(0, ("rdpResizeSession: width %d height %d", width, height)); + mmwidth = PixelToMM(width); + mmheight = PixelToMM(height); + + pSize = RRRegisterSize(dev->pScreen, width, height, mmwidth, mmheight); + RRSetCurrentConfig(dev->pScreen, RR_Rotate_0, 0, pSize); + + ok = TRUE; + if ((dev->width != width) || (dev->height != height)) + { + LLOGLN(0, (" calling RRScreenSizeSet")); + ok = RRScreenSizeSet(dev->pScreen, width, height, mmwidth, mmheight); + LLOGLN(0, (" RRScreenSizeSet ok=[%d]", ok)); + } + return ok; +} + +/******************************************************************************/ +/* returns error */ +static CARD32 +rdpDeferredRandR(OsTimerPtr timer, CARD32 now, pointer arg) +{ + ScreenPtr pScreen; + rrScrPrivPtr pRRScrPriv; + ScrnInfoPtr pScrn; + rdpPtr dev; + char *envvar; + int width; + int height; + + pScreen = (ScreenPtr) arg; + pScrn = xf86Screens[pScreen->myNum]; + dev = XRDPPTR(pScrn); + LLOGLN(10, ("rdpDeferredRandR:")); + pRRScrPriv = rrGetScrPriv(pScreen); + if (pRRScrPriv == 0) + { + LLOGLN(0, ("rdpDeferredRandR: rrGetScrPriv failed")); + return 1; + } + + dev->rrSetConfig = pRRScrPriv->rrSetConfig; + dev->rrGetInfo = pRRScrPriv->rrGetInfo; + dev->rrScreenSetSize = pRRScrPriv->rrScreenSetSize; + dev->rrCrtcSet = pRRScrPriv->rrCrtcSet; + dev->rrCrtcSetGamma = pRRScrPriv->rrCrtcSetGamma; + dev->rrCrtcGetGamma = pRRScrPriv->rrCrtcGetGamma; + dev->rrOutputSetProperty = pRRScrPriv->rrOutputSetProperty; + dev->rrOutputValidateMode = pRRScrPriv->rrOutputValidateMode; + dev->rrModeDestroy = pRRScrPriv->rrModeDestroy; + dev->rrOutputGetProperty = pRRScrPriv->rrOutputGetProperty; + dev->rrGetPanning = pRRScrPriv->rrGetPanning; + dev->rrSetPanning = pRRScrPriv->rrSetPanning; + + LLOGLN(10, (" rrSetConfig = %p", dev->rrSetConfig)); + LLOGLN(10, (" rrGetInfo = %p", dev->rrGetInfo)); + LLOGLN(10, (" rrScreenSetSize = %p", dev->rrScreenSetSize)); + LLOGLN(10, (" rrCrtcSet = %p", dev->rrCrtcSet)); + LLOGLN(10, (" rrCrtcSetGamma = %p", dev->rrCrtcSetGamma)); + LLOGLN(10, (" rrCrtcGetGamma = %p", dev->rrCrtcGetGamma)); + LLOGLN(10, (" rrOutputSetProperty = %p", dev->rrOutputSetProperty)); + LLOGLN(10, (" rrOutputValidateMode = %p", dev->rrOutputValidateMode)); + LLOGLN(10, (" rrModeDestroy = %p", dev->rrModeDestroy)); + LLOGLN(10, (" rrOutputGetProperty = %p", dev->rrOutputGetProperty)); + LLOGLN(10, (" rrGetPanning = %p", dev->rrGetPanning)); + LLOGLN(10, (" rrSetPanning = %p", dev->rrSetPanning)); + + pRRScrPriv->rrSetConfig = rdpRRSetConfig; + pRRScrPriv->rrGetInfo = rdpRRGetInfo; + pRRScrPriv->rrScreenSetSize = rdpRRScreenSetSize; + pRRScrPriv->rrCrtcSet = rdpRRCrtcSet; + pRRScrPriv->rrCrtcSetGamma = rdpRRCrtcSetGamma; + pRRScrPriv->rrCrtcGetGamma = rdpRRCrtcGetGamma; + pRRScrPriv->rrOutputSetProperty = rdpRROutputSetProperty; + pRRScrPriv->rrOutputValidateMode = rdpRROutputValidateMode; + pRRScrPriv->rrModeDestroy = rdpRRModeDestroy; + pRRScrPriv->rrOutputGetProperty = rdpRROutputGetProperty; + pRRScrPriv->rrGetPanning = rdpRRGetPanning; + pRRScrPriv->rrSetPanning = rdpRRSetPanning; + + rdpResizeSession(dev, dev->width, dev->height); + + envvar = getenv("XRDP_START_WIDTH"); + if (envvar != 0) + { + width = atoi(envvar); + if ((width >= 16) && (width < 8192)) + { + envvar = getenv("XRDP_START_HEIGHT"); + if (envvar != 0) + { + height = atoi(envvar); + if ((height >= 16) && (height < 8192)) + { + rdpResizeSession(dev, width, height); + } + } + } + } + + return 0; +} + +/*****************************************************************************/ +static Bool +rdpScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv) +{ + ScrnInfoPtr pScrn; + rdpPtr dev; + VisualPtr vis; + Bool vis_found; + PictureScreenPtr ps; + + pScrn = xf86Screens[scrnIndex]; + dev = XRDPPTR(pScrn); + + dev->pScreen = pScreen; + + miClearVisualTypes(); + miSetVisualTypes(pScrn->depth, miGetDefaultVisualMask(pScrn->depth), + pScrn->rgbBits, TrueColor); + miSetPixmapDepths(); + LLOGLN(0, ("rdpScreenInit: virtualX %d virtualY %d rgbBits %d depth %d", + pScrn->virtualX, pScrn->virtualY, pScrn->rgbBits, pScrn->depth)); + + dev->depth = pScrn->depth; + dev->paddedWidthInBytes = PixmapBytePad(dev->width, dev->depth); + dev->bitsPerPixel = rdpBitsPerPixel(dev->depth); + dev->sizeInBytes = dev->paddedWidthInBytes * dev->height; + LLOGLN(0, ("rdpScreenInit: pfbMemory bytes %d", dev->sizeInBytes)); + dev->pfbMemory = (char *) g_malloc(dev->sizeInBytes, 1); + if (!fbScreenInit(pScreen, dev->pfbMemory, + pScrn->virtualX, pScrn->virtualY, + pScrn->xDpi, pScrn->yDpi, pScrn->displayWidth, + pScrn->bitsPerPixel)) + { + LLOGLN(0, ("rdpScreenInit: fbScreenInit failed")); + return FALSE; + } + miInitializeBackingStore(pScreen); + +#if 0 + /* XVideo */ + if (rdp_xv_init(pScreen, pScrn) != 0) + { + LLOGLN(0, ("rdpScreenInit: rdp_xv_init failed")); + } +#endif + + vis = pScreen->visuals + (pScreen->numVisuals - 1); + while (vis >= pScreen->visuals) + { + if ((vis->class | DynamicClass) == DirectColor) + { + vis->offsetBlue = pScrn->offset.blue; + vis->blueMask = pScrn->mask.blue; + vis->offsetGreen = pScrn->offset.green; + vis->greenMask = pScrn->mask.green; + vis->offsetRed = pScrn->offset.red; + vis->redMask = pScrn->mask.red; + } + vis--; + } + fbPictureInit(pScreen, 0, 0); + xf86SetBlackWhitePixels(pScreen); + xf86SetBackingStore(pScreen); + +#if 1 + /* hardware cursor */ + dev->pCursorFuncs = xf86GetPointerScreenFuncs(); + miPointerInitialize(pScreen, &g_rdpSpritePointerFuncs, + dev->pCursorFuncs, 0); +#else + /* software cursor */ + dev->pCursorFuncs = xf86GetPointerScreenFuncs(); + miDCInitialize(pScreen, dev->pCursorFuncs); +#endif + + fbCreateDefColormap(pScreen); + + /* must assign this one */ + pScreen->SaveScreen = rdpSaveScreen; + + vis_found = FALSE; + vis = pScreen->visuals + (pScreen->numVisuals - 1); + while (vis >= pScreen->visuals) + { + if (vis->vid == pScreen->rootVisual) + { + vis_found = TRUE; + } + vis--; + } + if (!vis_found) + { + LLOGLN(0, ("rdpScreenInit: no root visual")); + return FALSE; + } + + dev->privateKeyRecGC = rdpAllocateGCPrivate(pScreen, sizeof(rdpGCRec)); + dev->privateKeyRecPixmap = rdpAllocatePixmapPrivate(pScreen, sizeof(rdpPixmapRec)); + + dev->CopyWindow = pScreen->CopyWindow; + pScreen->CopyWindow = rdpCopyWindow; + + dev->CreateGC = pScreen->CreateGC; + pScreen->CreateGC = rdpCreateGC; + + dev->CreatePixmap = pScreen->CreatePixmap; + pScreen->CreatePixmap = rdpCreatePixmap; + + dev->DestroyPixmap = pScreen->DestroyPixmap; + pScreen->DestroyPixmap = rdpDestroyPixmap; + + dev->ModifyPixmapHeader = pScreen->ModifyPixmapHeader; + pScreen->ModifyPixmapHeader = rdpModifyPixmapHeader; + + ps = GetPictureScreenIfSet(pScreen); + if (ps != 0) + { + /* composite */ + dev->Composite = ps->Composite; + ps->Composite = rdpComposite; + /* glyphs */ + dev->Glyphs = ps->Glyphs; + ps->Glyphs = rdpGlyphs; + } + + g_timer = TimerSet(g_timer, 0, 10, rdpDeferredRandR, pScreen); + + LLOGLN(0, ("rdpScreenInit: out")); + return TRUE; +} + +/*****************************************************************************/ +static Bool +rdpSwitchMode(int a, DisplayModePtr b, int c) +{ + LLOGLN(0, ("rdpSwitchMode:")); + return TRUE; +} + +/*****************************************************************************/ +static void +rdpAdjustFrame(int a, int b, int c, int d) +{ + LLOGLN(10, ("rdpAdjustFrame:")); +} + +/*****************************************************************************/ +static Bool +rdpEnterVT(int a, int b) +{ + LLOGLN(0, ("rdpEnterVT:")); + return TRUE; +} + +/*****************************************************************************/ +static void +rdpLeaveVT(int a, int b) +{ + LLOGLN(0, ("rdpLeaveVT:")); +} + +/*****************************************************************************/ +static ModeStatus +rdpValidMode(int a, DisplayModePtr b, Bool c, int d) +{ + LLOGLN(0, ("rdpValidMode:")); + return 0; +} + +/*****************************************************************************/ +static Bool +rdpProbe(DriverPtr drv, int flags) +{ + int num_dev_sections; + int i; + int entity; + GDevPtr *dev_sections; + Bool found_screen; + ScrnInfoPtr pscrn; + + LLOGLN(0, ("rdpProbe:")); + if (flags & PROBE_DETECT) + { + return FALSE; + } + /* fbScreenInit, fbPictureInit, ... */ + if (!xf86LoadDrvSubModule(drv, "fb")) + { + LLOGLN(0, ("rdpProbe: xf86LoadDrvSubModule for fb failed")); + return FALSE; + } + + num_dev_sections = xf86MatchDevice(XRDP_DRIVER_NAME, &dev_sections); + if (num_dev_sections <= 0) + { + LLOGLN(0, ("rdpProbe: xf86MatchDevice failed")); + return FALSE; + } + + pscrn = 0; + found_screen = FALSE; + for (i = 0; i < num_dev_sections; i++) + { + entity = xf86ClaimFbSlot(drv, 0, dev_sections[i], 1); + pscrn = xf86ConfigFbEntity(pscrn, 0, entity, 0, 0, 0, 0); + if (pscrn) + { + LLOGLN(10, ("rdpProbe: found screen")); + found_screen = 1; + pscrn->driverVersion = XRDP_VERSION; + pscrn->driverName = XRDP_DRIVER_NAME; + pscrn->name = XRDP_NAME; + pscrn->Probe = rdpProbe; + pscrn->PreInit = rdpPreInit; + pscrn->ScreenInit = rdpScreenInit; + pscrn->SwitchMode = rdpSwitchMode; + pscrn->AdjustFrame = rdpAdjustFrame; + pscrn->EnterVT = rdpEnterVT; + pscrn->LeaveVT = rdpLeaveVT; + pscrn->ValidMode = rdpValidMode; + + xf86DrvMsg(pscrn->scrnIndex, X_INFO, "%s", "using default device\n"); + } + } + free(dev_sections); + return found_screen; +} + +/*****************************************************************************/ +static const OptionInfoRec * +rdpAvailableOptions(int chipid, int busid) +{ + LLOGLN(0, ("rdpAvailableOptions:")); + return 0; +} + +#ifndef HW_SKIP_CONSOLE +#define HW_SKIP_CONSOLE 4 +#endif + +/*****************************************************************************/ +static Bool +rdpDriverFunc(ScrnInfoPtr pScrn, xorgDriverFuncOp op, pointer ptr) +{ + xorgHWFlags *flags; + int rv; + + rv = FALSE; + LLOGLN(0, ("rdpDriverFunc: op %d", (int)op)); + if (op == GET_REQUIRED_HW_INTERFACES) + { + flags = (xorgHWFlags *) ptr; + *flags = HW_SKIP_CONSOLE; + rv = TRUE; + } + return rv; +} + +/*****************************************************************************/ +static void +rdpIdentify(int flags) +{ + LLOGLN(0, ("rdpIdentify:")); + xf86PrintChipsets(XRDP_NAME, "driver for xrdp", g_Chipsets); +} + +/*****************************************************************************/ +_X_EXPORT DriverRec g_DriverRec = +{ + XRDP_VERSION, + XRDP_DRIVER_NAME, + rdpIdentify, + rdpProbe, + rdpAvailableOptions, + 0, + 0, + rdpDriverFunc +}; + +/*****************************************************************************/ +static pointer +xrdpdevSetup(pointer module, pointer opts, int *errmaj, int *errmin) +{ + LLOGLN(0, ("xrdpdevSetup:")); + if (!g_setup_done) + { + g_setup_done = 1; + xf86AddDriver(&g_DriverRec, module, HaveDriverFuncs); + return (pointer)1; + } + else + { + if (errmaj != 0) + { + *errmaj = LDR_ONCEONLY; + } + return 0; + } +} + +/* ModuleData */ +_X_EXPORT XF86ModuleData xrdpdevModuleData = +{ + &g_VersRec, + xrdpdevSetup, + 0 +}; diff --git a/xorg/server/xrdpkeyb/Makefile b/xorg/server/xrdpkeyb/Makefile new file mode 100644 index 00000000..c8654851 --- /dev/null +++ b/xorg/server/xrdpkeyb/Makefile @@ -0,0 +1,16 @@ + +OBJS = rdpKeyboard.o + +CFLAGS = -g -O2 -Wall -fPIC -I/usr/include/xorg -I/usr/include/pixman-1 -I../module + +LDFLAGS = + +LIBS = + +all: xrdpkeyb_drv.so + +xrdpkeyb_drv.so: $(OBJS) Makefile + $(CC) -shared -o xrdpkeyb_drv.so $(LDFLAGS) $(OBJS) $(LIBS) + +clean: + rm -f $(OBJS) xrdpkeyb_drv.so diff --git a/xorg/server/xrdpkeyb/rdpKeyboard.c b/xorg/server/xrdpkeyb/rdpKeyboard.c new file mode 100644 index 00000000..4fda5e76 --- /dev/null +++ b/xorg/server/xrdpkeyb/rdpKeyboard.c @@ -0,0 +1,467 @@ +/* +Copyright 2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +xrdp keyboard module + +*/ + +#include +#include +#include + +/* this should be before all X11 .h files */ +#include + +/* all driver need this */ +#include +#include + +#include "xf86Xinput.h" + +#include +#include +#include +#include + +#include "X11/keysym.h" + +#include "rdp.h" + +/* if 1, a keystroke is done every minute, down, then up */ +#define XRDPKB_TEST 0 + +/******************************************************************************/ +#define LOG_LEVEL 1 +#define LLOGLN(_level, _args) \ + do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0) + +#define XRDP_DRIVER_NAME "XRDPKEYB" +#define XRDP_NAME "XRDPKEYB" +#define XRDP_VERSION 1000 + +#define PACKAGE_VERSION_MAJOR 1 +#define PACKAGE_VERSION_MINOR 0 +#define PACKAGE_VERSION_PATCHLEVEL 0 + +#define MIN_KEY_CODE 8 +#define MAX_KEY_CODE 255 +#define NO_OF_KEYS ((MAX_KEY_CODE - MIN_KEY_CODE) + 1) +#define GLYPHS_PER_KEY 2 +/* control */ +#define CONTROL_L_KEY_CODE 37 +#define CONTROL_R_KEY_CODE 109 +/* shift */ +#define SHIFT_L_KEY_CODE 50 +#define SHIFT_R_KEY_CODE 62 +/* win keys */ +#define SUPER_L_KEY_CODE 115 +#define SUPER_R_KEY_CODE 116 +/* alt */ +#define ALT_L_KEY_CODE 64 +#define ALT_R_KEY_CODE 113 +/* caps lock */ +#define CAPS_LOCK_KEY_CODE 66 +/* num lock */ +#define NUM_LOCK_KEY_CODE 77 + +#define N_PREDEFINED_KEYS \ + (sizeof(g_kbdMap) / (sizeof(KeySym) * GLYPHS_PER_KEY)) + +static DeviceIntPtr g_keyboard = 0; +static OsTimerPtr g_timer = 0; + +static KeySym g_kbdMap[] = +{ + NoSymbol, NoSymbol, /* 8 */ + XK_Escape, NoSymbol, /* 9 */ + XK_1, XK_exclam, /* 10 */ + XK_2, XK_at, + XK_3, XK_numbersign, + XK_4, XK_dollar, + XK_5, XK_percent, + XK_6, XK_asciicircum, + XK_7, XK_ampersand, + XK_8, XK_asterisk, + XK_9, XK_parenleft, + XK_0, XK_parenright, + XK_minus, XK_underscore, /* 20 */ + XK_equal, XK_plus, + XK_BackSpace, NoSymbol, + XK_Tab, XK_ISO_Left_Tab, + XK_Q, NoSymbol, + XK_W, NoSymbol, + XK_E, NoSymbol, + XK_R, NoSymbol, + XK_T, NoSymbol, + XK_Y, NoSymbol, + XK_U, NoSymbol, /* 30 */ + XK_I, NoSymbol, + XK_O, NoSymbol, + XK_P, NoSymbol, + XK_bracketleft, XK_braceleft, + XK_bracketright, XK_braceright, + XK_Return, NoSymbol, + XK_Control_L, NoSymbol, + XK_A, NoSymbol, + XK_S, NoSymbol, + XK_D, NoSymbol, /* 40 */ + XK_F, NoSymbol, + XK_G, NoSymbol, + XK_H, NoSymbol, + XK_J, NoSymbol, + XK_K, NoSymbol, + XK_L, NoSymbol, + XK_semicolon, XK_colon, + XK_apostrophe, XK_quotedbl, + XK_grave, XK_asciitilde, + XK_Shift_L, NoSymbol, /* 50 */ + XK_backslash, XK_bar, + XK_Z, NoSymbol, + XK_X, NoSymbol, + XK_C, NoSymbol, + XK_V, NoSymbol, + XK_B, NoSymbol, + XK_N, NoSymbol, + XK_M, NoSymbol, + XK_comma, XK_less, + XK_period, XK_greater, /* 60 */ + XK_slash, XK_question, + XK_Shift_R, NoSymbol, + XK_KP_Multiply, NoSymbol, + XK_Alt_L, NoSymbol, + XK_space, NoSymbol, + XK_Caps_Lock, NoSymbol, + XK_F1, NoSymbol, + XK_F2, NoSymbol, + XK_F3, NoSymbol, + XK_F4, NoSymbol, /* 70 */ + XK_F5, NoSymbol, + XK_F6, NoSymbol, + XK_F7, NoSymbol, + XK_F8, NoSymbol, + XK_F9, NoSymbol, + XK_F10, NoSymbol, + XK_Num_Lock, NoSymbol, + XK_Scroll_Lock, NoSymbol, + XK_KP_Home, XK_KP_7, + XK_KP_Up, XK_KP_8, /* 80 */ + XK_KP_Prior, XK_KP_9, + XK_KP_Subtract, NoSymbol, + XK_KP_Left, XK_KP_4, + XK_KP_Begin, XK_KP_5, + XK_KP_Right, XK_KP_6, + XK_KP_Add, NoSymbol, + XK_KP_End, XK_KP_1, + XK_KP_Down, XK_KP_2, + XK_KP_Next, XK_KP_3, + XK_KP_Insert, XK_KP_0, /* 90 */ + XK_KP_Delete, XK_KP_Decimal, + NoSymbol, NoSymbol, + NoSymbol, NoSymbol, + NoSymbol, NoSymbol, + XK_F11, NoSymbol, + XK_F12, NoSymbol, + XK_Home, NoSymbol, + XK_Up, NoSymbol, + XK_Prior, NoSymbol, + XK_Left, NoSymbol, /* 100 */ + XK_Print, NoSymbol, + XK_Right, NoSymbol, + XK_End, NoSymbol, + XK_Down, NoSymbol, + XK_Next, NoSymbol, + XK_Insert, NoSymbol, + XK_Delete, NoSymbol, + XK_KP_Enter, NoSymbol, + XK_Control_R, NoSymbol, + XK_Pause, NoSymbol, /* 110 */ + XK_Print, NoSymbol, + XK_KP_Divide, NoSymbol, + XK_Alt_R, NoSymbol, + NoSymbol, NoSymbol, + XK_Super_L, NoSymbol, + XK_Super_R, NoSymbol, + XK_Menu, NoSymbol, + NoSymbol, NoSymbol, + NoSymbol, NoSymbol, + NoSymbol, NoSymbol, /* 120 */ + NoSymbol, NoSymbol +}; + +/******************************************************************************/ +static void +rdpEnqueueKey(int type, int scancode) +{ + if (type == KeyPress) + { + /* need this cause rdp and X11 repeats are different */ + xf86PostKeyboardEvent(g_keyboard, scancode, FALSE); + xf86PostKeyboardEvent(g_keyboard, scancode, TRUE); + } + else + { + xf86PostKeyboardEvent(g_keyboard, scancode, FALSE); + } +} + +#if XRDPKB_TEST +/******************************************************************************/ +static CARD32 +rdpDeferredUpdateCallback(OsTimerPtr timer, CARD32 now, pointer arg) +{ + LLOGLN(0, ("rdpDeferredUpdateCallback:")); + + rdpEnqueueKey(KeyPress, 115); + rdpEnqueueKey(KeyRelease, 115); + + g_timer = TimerSet(g_timer, 0, 1000, rdpDeferredUpdateCallback, 0); + return 0; +} +#endif + +/******************************************************************************/ +void +rdpkeybDeviceInit(DeviceIntPtr pDevice, KeySymsPtr pKeySyms, CARD8 *pModMap) +{ + int i; + + LLOGLN(0, ("rdpkeybDeviceInit:")); + LLOGLN(10, (" MAP_LENGTH %d GLYPHS_PER_KEY %d N_PREDEFINED_KEYS %d", + MAP_LENGTH, GLYPHS_PER_KEY, (int) N_PREDEFINED_KEYS)); + + for (i = 0; i < MAP_LENGTH; i++) + { + pModMap[i] = NoSymbol; + } + + pModMap[SHIFT_L_KEY_CODE] = ShiftMask; + pModMap[SHIFT_R_KEY_CODE] = ShiftMask; + pModMap[CAPS_LOCK_KEY_CODE] = LockMask; + pModMap[CONTROL_L_KEY_CODE] = ControlMask; + pModMap[CONTROL_R_KEY_CODE] = ControlMask; + pModMap[ALT_L_KEY_CODE] = Mod1Mask; + pModMap[ALT_R_KEY_CODE] = Mod1Mask; + pModMap[NUM_LOCK_KEY_CODE] = Mod2Mask; + pModMap[SUPER_L_KEY_CODE] = Mod4Mask; + pModMap[SUPER_R_KEY_CODE] = Mod4Mask; + pKeySyms->minKeyCode = MIN_KEY_CODE; + pKeySyms->maxKeyCode = MAX_KEY_CODE; + pKeySyms->mapWidth = GLYPHS_PER_KEY; + i = sizeof(KeySym) * MAP_LENGTH * GLYPHS_PER_KEY; + pKeySyms->map = (KeySym *)malloc(i); + if (pKeySyms->map == 0) + { + LLOGLN(0, ("rdpkeybDeviceInit: malloc failed")); + exit(1); + } + else + { + memset(pKeySyms->map, 0, i); + } + + for (i = 0; i < MAP_LENGTH * GLYPHS_PER_KEY; i++) + { + pKeySyms->map[i] = NoSymbol; + } + + for (i = 0; i < N_PREDEFINED_KEYS * GLYPHS_PER_KEY; i++) + { + pKeySyms->map[i] = g_kbdMap[i]; + } +} + +/******************************************************************************/ +static void +rdpkeybDeviceOn(void) +{ + LLOGLN(0, ("rdpkeybDeviceOn:")); +} + +/******************************************************************************/ +static void +rdpkeybDeviceOff(void) +{ + LLOGLN(0, ("rdpkeybDeviceOff:")); +} + +/******************************************************************************/ +static void +rdpkeybBell(int volume, DeviceIntPtr pDev, pointer ctrl, int cls) +{ + LLOGLN(0, ("rdpkeybBell:")); +} + +/******************************************************************************/ +static void +rdpkeybChangeKeyboardControl(DeviceIntPtr pDev, KeybdCtrl *ctrl) +{ + LLOGLN(0, ("rdpkeybChangeKeyboardControl:")); +} + +/******************************************************************************/ +static int +rdpkeybControl(DeviceIntPtr device, int what) +{ + KeySymsRec keySyms; + CARD8 modMap[MAP_LENGTH]; + DevicePtr pDev; + XkbRMLVOSet set; + + LLOGLN(0, ("rdpkeybControl: what %d", what)); + pDev = (DevicePtr)device; + + switch (what) + { + case DEVICE_INIT: + rdpkeybDeviceInit(device, &keySyms, modMap); + memset(&set, 0, sizeof(set)); + set.rules = "base"; + set.model = "pc104"; + set.layout = "us"; + set.variant = ""; + set.options = ""; + InitKeyboardDeviceStruct(device, &set, rdpkeybBell, + rdpkeybChangeKeyboardControl); + g_keyboard = device; +#if XRDPKB_TEST + g_timer = TimerSet(g_timer, 0, 1000, rdpDeferredUpdateCallback, 0); +#endif + break; + case DEVICE_ON: + pDev->on = 1; + rdpkeybDeviceOn(); + break; + case DEVICE_OFF: + pDev->on = 0; + rdpkeybDeviceOff(); + break; + case DEVICE_CLOSE: + if (pDev->on) + { + rdpkeybDeviceOff(); + } + break; + } + return Success; +} + +#if XORG_VERSION_CURRENT < (((1) * 10000000) + ((9) * 100000) + ((0) * 1000) + 1) + +/* debian 6 + ubuntu 10.04 */ + +/******************************************************************************/ +static InputInfoPtr +rdpkeybPreInit(InputDriverPtr drv, IDevPtr dev, int flags) +{ + InputInfoPtr info; + + LLOGLN(0, ("rdpkeybPreInit: drv %p dev %p, flags 0x%x", + drv, dev, flags)); + info = xf86AllocateInput(drv, 0); + info->name = dev->identifier; + info->device_control = rdpkeybControl; + info->flags = XI86_CONFIGURED | XI86_ALWAYS_CORE | XI86_SEND_DRAG_EVENTS | + XI86_CORE_KEYBOARD | XI86_KEYBOARD_CAPABLE; + info->type_name = "Keyboard"; + info->fd = -1; + info->conf_idev = dev; + + return info; +} + +#else + +/* debian 7 + ubuntu 12.04 */ + +/******************************************************************************/ +static int +rdpkeybPreInit(InputDriverPtr drv, InputInfoPtr info, int flags) +{ + LLOGLN(0, ("rdpkeybPreInit: drv %p info %p, flags 0x%x", + drv, info, flags)); + info->device_control = rdpkeybControl; + info->type_name = "Keyboard"; + + return 0; +} + +#endif + +/******************************************************************************/ +static void +rdpkeybUnInit(InputDriverPtr drv, InputInfoPtr info, int flags) +{ + LLOGLN(0, ("rdpkeybUnInit: drv %p info %p, flags 0x%x", + drv, info, flags)); +} + +/******************************************************************************/ +static InputDriverRec rdpkeyb = +{ + PACKAGE_VERSION_MAJOR, /* version */ + XRDP_NAME, /* name */ + NULL, /* identify */ + rdpkeybPreInit, /* preinit */ + rdpkeybUnInit, /* uninit */ + NULL, /* module */ + 0 /* ref count */ +}; + +/******************************************************************************/ +static void +rdpkeybUnplug(pointer p) +{ + LLOGLN(0, ("rdpkeybUnplug:")); +} + +/******************************************************************************/ +static pointer +rdpkeybPlug(pointer module, pointer options, int *errmaj, int *errmin) +{ + LLOGLN(0, ("rdpkeybPlug:")); + xf86AddInputDriver(&rdpkeyb, module, 0); + return module; +} + +/******************************************************************************/ +static XF86ModuleVersionInfo rdpkeybVersionRec = +{ + XRDP_DRIVER_NAME, + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XORG_VERSION_CURRENT, + PACKAGE_VERSION_MAJOR, + PACKAGE_VERSION_MINOR, + PACKAGE_VERSION_PATCHLEVEL, + ABI_CLASS_XINPUT, + ABI_XINPUT_VERSION, + MOD_CLASS_XINPUT, + { 0, 0, 0, 0 } +}; + +/******************************************************************************/ +XF86ModuleData xrdpkeybModuleData = +{ + &rdpkeybVersionRec, + rdpkeybPlug, + rdpkeybUnplug +}; diff --git a/xorg/server/xrdpmouse/Makefile b/xorg/server/xrdpmouse/Makefile new file mode 100644 index 00000000..dfcabc88 --- /dev/null +++ b/xorg/server/xrdpmouse/Makefile @@ -0,0 +1,16 @@ + +OBJS = rdpMouse.o + +CFLAGS = -g -O2 -Wall -fPIC -I/usr/include/xorg -I/usr/include/pixman-1 -I../module + +LDFLAGS = + +LIBS = + +all: xrdpmouse_drv.so + +xrdpmouse_drv.so: $(OBJS) Makefile + $(CC) -shared -o xrdpmouse_drv.so $(LDFLAGS) $(OBJS) $(LIBS) + +clean: + rm -f $(OBJS) xrdpmouse_drv.so diff --git a/xorg/server/xrdpmouse/rdpMouse.c b/xorg/server/xrdpmouse/rdpMouse.c new file mode 100644 index 00000000..7142a4ee --- /dev/null +++ b/xorg/server/xrdpmouse/rdpMouse.c @@ -0,0 +1,246 @@ +/* +Copyright 2013 Jay Sorg + +Permission to use, copy, modify, distribute, and sell this software and its +documentation for any purpose is hereby granted without fee, provided that +the above copyright notice appear in all copies and that both that +copyright notice and this permission notice appear in supporting +documentation. + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +xrdp mouse module + +*/ + +#include +#include +#include + +/* this should be before all X11 .h files */ +#include + +/* all driver need this */ +#include +#include + +#include "xf86Xinput.h" + +#include +#include +#include +#include +#include +#include + +#include "rdp.h" + +/******************************************************************************/ +#define LOG_LEVEL 1 +#define LLOGLN(_level, _args) \ + do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0) + +#define XRDP_DRIVER_NAME "XRDPMOUSE" +#define XRDP_NAME "XRDPMOUSE" +#define XRDP_VERSION 1000 + +#define PACKAGE_VERSION_MAJOR 1 +#define PACKAGE_VERSION_MINOR 0 +#define PACKAGE_VERSION_PATCHLEVEL 0 + +/******************************************************************************/ +static void +rdpmouseDeviceInit(void) +{ + LLOGLN(0, ("rdpmouseDeviceInit:")); +} + +/******************************************************************************/ +static void +rdpmouseDeviceOn(DeviceIntPtr pDev) +{ + LLOGLN(0, ("rdpmouseDeviceOn:")); +} + +/******************************************************************************/ +static void +rdpmouseDeviceOff(void) +{ + LLOGLN(0, ("rdpmouseDeviceOff:")); +} + +/******************************************************************************/ +static void +rdpmouseCtrl(DeviceIntPtr pDevice, PtrCtrl *pCtrl) +{ + LLOGLN(0, ("rdpmouseCtrl:")); +} + +/******************************************************************************/ +static int +rdpmouseControl(DeviceIntPtr device, int what) +{ + BYTE map[6]; + DevicePtr pDev; + Atom btn_labels[6]; + Atom axes_labels[2]; + + LLOGLN(0, ("rdpmouseControl: what %d", what)); + pDev = (DevicePtr)device; + + switch (what) + { + case DEVICE_INIT: + rdpmouseDeviceInit(); + map[0] = 0; + map[1] = 1; + map[2] = 2; + map[3] = 3; + map[4] = 4; + map[5] = 5; + + btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT); + btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE); + btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT); + btn_labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP); + btn_labels[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN); + + axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X); + axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y); + + InitPointerDeviceStruct(pDev, map, 5, btn_labels, rdpmouseCtrl, + GetMotionHistorySize(), 2, axes_labels); + + break; + case DEVICE_ON: + pDev->on = 1; + rdpmouseDeviceOn(device); + break; + case DEVICE_OFF: + pDev->on = 0; + rdpmouseDeviceOff(); + break; + case DEVICE_CLOSE: + + if (pDev->on) + { + rdpmouseDeviceOff(); + } + + break; + } + + return Success; +} + +#if XORG_VERSION_CURRENT < (((1) * 10000000) + ((9) * 100000) + ((0) * 1000) + 1) + +/* debian 6 + ubuntu 10.04 */ + +/******************************************************************************/ +static InputInfoPtr +rdpmousePreInit(InputDriverPtr drv, IDevPtr dev, int flags) +{ + InputInfoPtr info; + + LLOGLN(0, ("rdpmousePreInit: drv %p dev %p, flags 0x%x", + drv, dev, flags)); + info = xf86AllocateInput(drv, 0); + info->name = dev->identifier; + info->device_control = rdpmouseControl; + info->flags = XI86_CONFIGURED | XI86_ALWAYS_CORE | XI86_SEND_DRAG_EVENTS | + XI86_CORE_POINTER | XI86_POINTER_CAPABLE; + info->type_name = "Mouse"; + info->fd = -1; + info->conf_idev = dev; + + return info; +} + +#else + +/* debian 7 + ubuntu 12.04 */ + +/******************************************************************************/ +static int +rdpmousePreInit(InputDriverPtr drv, InputInfoPtr info, int flags) +{ + LLOGLN(0, ("rdpmousePreInit: drv %p info %p, flags 0x%x", + drv, info, flags)); + info->device_control = rdpmouseControl; + info->type_name = "Mouse"; + return 0; +} + +#endif + +/******************************************************************************/ +static void +rdpmouseUnInit(InputDriverPtr drv, InputInfoPtr info, int flags) +{ + LLOGLN(0, ("rdpmouseUnInit: drv %p info %p, flags 0x%x", + drv, info, flags)); +} + +/******************************************************************************/ +static InputDriverRec rdpmouse = +{ + PACKAGE_VERSION_MAJOR, /* version */ + XRDP_NAME, /* name */ + NULL, /* identify */ + rdpmousePreInit, /* preinit */ + rdpmouseUnInit, /* uninit */ + NULL, /* module */ + 0 /* ref count */ +}; + +/******************************************************************************/ +static void +rdpmouseUnplug(pointer p) +{ + LLOGLN(0, ("rdpmouseUnplug:")); +} + +/******************************************************************************/ +static pointer +rdpmousePlug(pointer module, pointer options, int *errmaj, int *errmin) +{ + LLOGLN(0, ("rdpmousePlug:")); + xf86AddInputDriver(&rdpmouse, module, 0); + return module; +} + +/******************************************************************************/ +static XF86ModuleVersionInfo rdpmouseVersionRec = +{ + XRDP_DRIVER_NAME, + MODULEVENDORSTRING, + MODINFOSTRING1, + MODINFOSTRING2, + XORG_VERSION_CURRENT, + PACKAGE_VERSION_MAJOR, + PACKAGE_VERSION_MINOR, + PACKAGE_VERSION_PATCHLEVEL, + ABI_CLASS_XINPUT, + ABI_XINPUT_VERSION, + MOD_CLASS_XINPUT, + { 0, 0, 0, 0 } +}; + +/******************************************************************************/ +XF86ModuleData xrdpmouseModuleData = +{ + &rdpmouseVersionRec, + rdpmousePlug, + rdpmouseUnplug +}; diff --git a/xorg/tests/randr/trandr.c b/xorg/tests/randr/trandr.c index 77ce2c33..4f7be527 100644 --- a/xorg/tests/randr/trandr.c +++ b/xorg/tests/randr/trandr.c @@ -31,17 +31,22 @@ #include static int -process_randr(Display *disp, Window win, int event_base, XEvent *ev) +process_randr(Display *disp, Screen *screen, int screenNumber, Window win, + int event_base, XEvent *ev) { XRRScreenChangeNotifyEvent *rr_screen_change_notify; switch (ev->type - event_base) { case RRScreenChangeNotify: + XRRUpdateConfiguration(ev); rr_screen_change_notify = (XRRScreenChangeNotifyEvent *) ev; printf("RRScreenChangeNotify: width %d height %d\n", rr_screen_change_notify->width, rr_screen_change_notify->height); + printf("DisplayWidth %d DisplayHeight %d\n", + DisplayWidth(disp, screenNumber), + DisplayHeight(disp, screenNumber)); break; } return 0; @@ -119,7 +124,9 @@ main(int argc, char **argv) case ConfigureNotify: if (ev.xconfigure.window == root_window) { - printf("ConfigureNotify for root window width %d height %d\n", + XRRUpdateConfiguration(&ev); + printf("ConfigureNotify for root window " + "width %d height %d\n", ev.xconfigure.width, ev.xconfigure.height); } break; @@ -128,7 +135,8 @@ main(int argc, char **argv) (ev.type < rr_event_base + RRNumberEvents)) { printf("randr\n"); - process_randr(disp, win, rr_event_base, &ev); + process_randr(disp, screen, screenNumber, win, + rr_event_base, &ev); } break; } diff --git a/xup/xup.c b/xup/xup.c index 27063366..5320a3c9 100644 --- a/xup/xup.c +++ b/xup/xup.c @@ -534,6 +534,7 @@ lib_mod_process_orders(struct mod *mod, int type, struct stream *s) int width; int height; int fgcolor; + int bgcolor; int opcode; char *bmpdata; char cur_data[32 * (32 * 3)]; @@ -594,6 +595,10 @@ lib_mod_process_orders(struct mod *mod, int type, struct stream *s) in_uint32_le(s, fgcolor); rv = mod->server_set_fgcolor(mod, fgcolor); break; + case 13: /* server_set_bgcolor */ + in_uint32_le(s, bgcolor); + rv = mod->server_set_bgcolor(mod, bgcolor); + break; case 14: in_uint16_le(s, opcode); rv = mod->server_set_opcode(mod, opcode);