summaryrefslogtreecommitdiffstats
path: root/xorg/server/module
diff options
context:
space:
mode:
authorJay Sorg <jay.sorg@gmail.com>2013-07-20 15:11:54 -0700
committerJay Sorg <jay.sorg@gmail.com>2013-07-20 15:11:54 -0700
commit058e2ecd2824475bb3866c89bab24cefab1b7f06 (patch)
tree5d12e3235f2e19d021100d6bcaaad8d363e42c3c /xorg/server/module
parentbb19b8ed5770a5a45e78ec8e3919b859932a76a0 (diff)
downloadxrdp-proprietary-058e2ecd2824475bb3866c89bab24cefab1b7f06.tar.gz
xrdp-proprietary-058e2ecd2824475bb3866c89bab24cefab1b7f06.zip
xorg driver, added region files, misc, cleanup
Diffstat (limited to 'xorg/server/module')
-rw-r--r--xorg/server/module/Makefile2
-rw-r--r--xorg/server/module/rdpDraw.c22
-rw-r--r--xorg/server/module/rdpDraw.h2
-rw-r--r--xorg/server/module/rdpMisc.c415
-rw-r--r--xorg/server/module/rdpMisc.h78
-rw-r--r--xorg/server/module/rdpPri.c7
-rw-r--r--xorg/server/module/rdpRandR.c14
-rw-r--r--xorg/server/module/rdpReg.c233
-rw-r--r--xorg/server/module/rdpReg.h60
9 files changed, 799 insertions, 34 deletions
diff --git a/xorg/server/module/Makefile b/xorg/server/module/Makefile
index 7ee49277..3662b218 100644
--- a/xorg/server/module/Makefile
+++ b/xorg/server/module/Makefile
@@ -4,7 +4,7 @@ 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
+rdpCursor.o rdpMain.o rdpRandR.o rdpMisc.o rdpReg.o
CFLAGS = -g -O2 -Wall -fPIC -I/usr/include/xorg -I/usr/include/pixman-1
diff --git a/xorg/server/module/rdpDraw.c b/xorg/server/module/rdpDraw.c
index 4de9fa9f..7abcb406 100644
--- a/xorg/server/module/rdpDraw.c
+++ b/xorg/server/module/rdpDraw.c
@@ -146,25 +146,3 @@ rdpGetRootWindowPtr(ScreenPtr pScreen)
return pScreen->root;
#endif
}
-
-/******************************************************************************/
-int
-rdpBitsPerPixel(int depth)
-{
- if (depth == 1)
- {
- return 1;
- }
- else if (depth <= 8)
- {
- return 8;
- }
- else if (depth <= 16)
- {
- return 16;
- }
- else
- {
- return 32;
- }
-}
diff --git a/xorg/server/module/rdpDraw.h b/xorg/server/module/rdpDraw.h
index 632a7467..ba696541 100644
--- a/xorg/server/module/rdpDraw.h
+++ b/xorg/server/module/rdpDraw.h
@@ -66,7 +66,5 @@ Bool
rdpCloseScreen(int index, ScreenPtr pScreen);
WindowPtr
rdpGetRootWindowPtr(ScreenPtr pScreen);
-int
-rdpBitsPerPixel(int depth);
#endif
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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <sys/un.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <netinet/in.h>
+#include <netinet/tcp.h>
+
+/* this should be before all X11 .h files */
+#include <xorg-server.h>
+
+/* all driver need this */
+#include <xf86.h>
+#include <xf86_OSproc.h>
+
+/******************************************************************************/
+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/rdpPri.c b/xorg/server/module/rdpPri.c
index 3de181a8..43f3d883 100644
--- a/xorg/server/module/rdpPri.c
+++ b/xorg/server/module/rdpPri.c
@@ -38,6 +38,7 @@ to deal with privates changing in xorg versions
#include <mi.h>
#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 */
@@ -167,9 +168,9 @@ int
rdpPrivateInit(void)
{
#if XRDP_PRI == 3
- memset(&g_privateKeyRecGC, 0, sizeof(g_privateKeyRecGC));
- memset(&g_privateKeyRecWindow, 0, sizeof(g_privateKeyRecWindow));
- memset(&g_privateKeyRecPixmap, 0, sizeof(g_privateKeyRecPixmap));
+ 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/rdpRandR.c b/xorg/server/module/rdpRandR.c
index 82de2f2e..e5ce814b 100644
--- a/xorg/server/module/rdpRandR.c
+++ b/xorg/server/module/rdpRandR.c
@@ -39,6 +39,8 @@ RandR draw calls
#include "rdp.h"
#include "rdpDraw.h"
+#include "rdpReg.h"
+#include "rdpMisc.h"
/******************************************************************************/
#define LOG_LEVEL 1
@@ -120,8 +122,8 @@ rdpRRScreenSetSize(ScreenPtr pScreen, CARD16 width, CARD16 height,
pScreen->mmWidth = mmWidth;
pScreen->mmHeight = mmHeight;
screenPixmap = pScreen->GetScreenPixmap(pScreen);
- free(dev->pfbMemory);
- dev->pfbMemory = (char *) malloc(dev->sizeInBytes);
+ g_free(dev->pfbMemory);
+ dev->pfbMemory = (char *) g_malloc(dev->sizeInBytes, 1);
if (screenPixmap != 0)
{
pScreen->ModifyPixmapHeader(screenPixmap, width, height,
@@ -133,10 +135,10 @@ rdpRRScreenSetSize(ScreenPtr pScreen, CARD16 width, CARD16 height,
box.y1 = 0;
box.x2 = width;
box.y2 = height;
- REGION_INIT(pScreen, &root->winSize, &box, 1);
- REGION_INIT(pScreen, &root->borderSize, &box, 1);
- REGION_RESET(pScreen, &root->borderClip, &box);
- REGION_BREAK(pScreen, &root->clipList);
+ 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);
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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+/* this should be before all X11 .h files */
+#include <xorg-server.h>
+
+/* all driver need this */
+#include <xf86.h>
+#include <xf86_OSproc.h>
+
+/*
+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