Merge pull request #1104 from metalefty/remove-x11rdp

Remove x11rdp
master
metalefty 7 years ago committed by GitHub
commit b522fb4a2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -21,8 +21,7 @@ EXTRA_DIST = \
postinstall-pak \
tcutils \
tests \
vrplayer \
xorg
vrplayer
if XRDP_NEUTRINORDP
NEUTRINORDPDIR = neutrinordp

@ -137,7 +137,6 @@ xrdp
├── tests ······· tests for the code
├── vnc ········· VNC client module for xrdp
├── vrplayer ···· QT player redirecting video/audio to clients over xrdpvr channel
├── xorg ········ X11rdp, an Xorg backend for xrdp
├── xrdp ········ main server code
├── xrdpapi ····· virtual channel API
├── xrdpvr ······ API for playing media over RDP

1
xorg/.gitignore vendored

@ -1 +0,0 @@
!Makefile

@ -1,3 +0,0 @@
build_dir
cookies
downloads

@ -1,11 +0,0 @@
--- a/src/mesa/x86-64/xform4.S
+++ b/src/mesa/x86-64/xform4.S
@@ -118,7 +118,7 @@
.byte 0x00, 0x00, 0x00, 0x00
.byte 0x00, 0x00, 0x00, 0x00
.byte 0x00, 0x00, 0x00, 0x00
-.float 0f+1.0
+.float 1.0
.text
.align 16

@ -1,299 +0,0 @@
#!/bin/sh
# buildx.sh: a script for building X11R7.6 X server for use with xrdp
#
# Copyright 2011-2013 Jay Sorg Jay.Sorg@gmail.com
#
# Authors
# Jay Sorg Jay.Sorg@gmail.com
# Laxmikant Rashinkar LK.Rashinkar@gmail.com
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# debian packages needed
# flex bison libxml2-dev intltool xsltproc xutils-dev python-libxml2 g++ xutils
download_all_files()
{
# download files in parallel using keepalive - a little bit faster
# than calling wget for a single file more than 100 times
urls=
for f in `cut -f1 -d: x11_file_list.txt`; do
if ! test -s "downloads/$f"; then
urls="$urls ${download_url}/$f"
fi
done
if test -n "$urls"; then
echo $urls | \
xargs -P2 -n $(expr $num_modules / 2 + 1) \
wget \
--directory-prefix=downloads \
--no-verbose \
--timestamping \
--continue
fi
status=$?
return $status
}
remove_modules()
{
local mod_file mod_dir mod_args
if [ -d cookies ]; then
rm cookies/*
fi
if [ ! -d build_dir ]; then
echo ""
echo "build_dir does not exist; nothing to delete"
echo ""
exit 0
fi
while IFS=: read mod_file mod_dir mod_args
do
(cd build_dir; [ -d $mod_dir ] && rm -rf $mod_dir)
done < $data_file
}
extract_it()
{
local mod_file mod_name mod_args comp
mod_file=$1
mod_name=$2
mod_args=$3
if [ -e cookies/$mod_name.extracted ]; then
return 0
fi
cd build_dir
# if pkg has not yet been extracted, do so now
if [ ! -d $mod_name ]; then
case "$mod_file" in
*.tar.bz2) comp=j ;;
*.tar.gz) comp=z ;;
*.tar.xz) comp=J ;;
*.tar) comp= ;;
*) echo "unknown compressed module $mod_name" ; exit 1 ;;
esac
if ! tar x${comp}f ../downloads/$mod_file > /dev/null
then
echo "error extracting module $mod_name"
exit 1
fi
fi
# patch and configure module - we only need to do this once
cd $mod_name
# check for patches
if [ -e ../../$mod_name.patch ]; then
patch -N -p1 < ../../$mod_name.patch
fi
# now configure
echo "executing ./configure --prefix=$PREFIX_DIR $mod_args"
if ! ./configure --prefix=$PREFIX_DIR $mod_args
then
echo "configuration failed for module $mod_name"
exit 1
fi
cd ../..
touch cookies/$mod_name.extracted
}
make_it()
{
local mod_file mod_name mod_args
mod_file=$1
mod_name=$2
mod_args=$3
count=`expr $count + 1`
# if a cookie with $mod_name exists...
if [ -e cookies/$mod_name.installed ]; then
# ...package has already been installed
return 0
fi
echo ""
echo "*** processing module $mod_name ($count of $num_modules) ***"
echo ""
if ! extract_it $mod_file $mod_name "$mod_args"
then
echo ""
echo "extract failed for module $mod_name"
echo ""
exit 1
fi
# make module
if [ ! -e cookies/$mod_name.made ]; then
if ! make -j $NPROC -C build_dir/$mod_name
then
echo ""
echo "make failed for module $mod_name"
echo ""
exit 1
fi
touch cookies/$mod_name.made
fi
# install module
if ! make -C build_dir/$mod_name install
then
echo ""
echo "make install failed for module $mod_name"
echo ""
exit 1
fi
touch cookies/$mod_name.installed
return 0
}
# this is where we store list of modules to be processed
data_file=x11_file_list.txt
# this is the default download location for most modules
# changed now to server1.xrdp.org
# was www.x.org/releases/X11R7.6/src/everything
download_url=http://server1.xrdp.org/xrdp/X11R7.6
num_modules=`wc -l < $data_file`
count=0
##########################
# program flow starts here
##########################
if [ $# -lt 1 ]; then
echo ""
echo "usage: buildx.sh <installation dir>"
echo "usage: buildx.sh clean"
echo "usage: buildx.sh default"
echo "usage: buildx.sh <installation dir> drop - set env and run bash in rdp dir"
echo ""
exit 1
fi
# remove all modules
if [ "$1" = "clean" ]; then
echo "removing source modules"
remove_modules
exit 0
fi
if [ "$1" = "default" ]; then
export PREFIX_DIR=$PWD/staging
else
export PREFIX_DIR=$1
fi
# prefix dir must exist...
if [ ! -d $PREFIX_DIR ]; then
echo "$PREFIX_DIR does not exist, creating it"
if ! mkdir -p $PREFIX_DIR; then
echo "$PREFIX_DIR cannot be created - cannot continue"
exit 1
fi
fi
# ...and be writable
if [ ! -w $PREFIX_DIR ]; then
echo "$PREFIX_DIR is not writable - cannot continue"
exit 1
fi
echo "installation directory: $PREFIX_DIR"
export PKG_CONFIG_PATH=$PREFIX_DIR/lib/pkgconfig:$PREFIX_DIR/share/pkgconfig
export PATH=$PREFIX_DIR/bin:$PATH
export LDFLAGS=-Wl,-rpath=$PREFIX_DIR/lib
export CFLAGS="-I$PREFIX_DIR/include -fPIC -O2"
# create a downloads dir
if [ ! -d downloads ]; then
if ! mkdir downloads
then
echo "error creating downloads directory"
exit 1
fi
fi
# this is where we do the actual build
if [ ! -d build_dir ]; then
if ! mkdir build_dir
then
echo "error creating build_dir directory"
exit 1
fi
fi
# this is where we store cookie files
if [ ! -d cookies ]; then
if ! mkdir cookies
then
echo "error creating cookies directory"
exit 1
fi
fi
if ! NPROC=`nproc`; then
NPROC=1
fi
if ! download_all_files; then
echo ""
echo "download failed - aborting build"
echo "rerun this script to resume download/build"
echo ""
exit 1
fi
while IFS=: read mod_file mod_dir mod_args
do
mod_args=`eval echo $mod_args`
make_it $mod_file $mod_dir "$mod_args"
done < $data_file
echo "build for X OK"
X11RDPBASE=$PREFIX_DIR
export X11RDPBASE
if ! make -C rdp
then
echo "error building rdp"
exit 1
fi
# this will copy the build X server with the other X server binaries
cd rdp
cp X11rdp $X11RDPBASE/bin/X11rdp
strip $X11RDPBASE/bin/X11rdp
if [ "$2" = "drop" ]; then
echo ""
echo "dropping you in dir, type exit to get out"
bash
exit 1
fi
echo "All done"

@ -1,102 +0,0 @@
#!/bin/sh
#
# all directories can be read only except
# Read Write
# share/X11/xkb/compiled/
if test $# -lt 1
then
echo ""
echo "usage: clean_build_dir.sh <installation dir>"
echo ""
exit 1
fi
BASEDIR=$1
if ! test -d $BASEDIR
then
echo "error directory $BASEDIR does not exist"
exit 1
fi
if ! test -w $BASEDIR
then
echo "error directory $BASEDIR is not writable"
exit 1
fi
echo cleaning $BASEDIR
if ! test -x $BASEDIR/bin/X11rdp
then
echo "error $BASEDIR/bin/X11rdp does not exist"
fi
bin_check_file()
{
if [ "$1" = "X11rdp" ]
then
return 0
fi
if [ "$1" = "xkbcomp" ]
then
return 0
fi
rm -f $1
return 0
}
HOLDPATH=$PWD
cd $BASEDIR
# remove unused directories
rm -fr man/
rm -fr include/
rm -fr lib/python2.7/
rm -fr lib/pkgconfig/
rm -fr share/pkgconfig/
rm -fr share/gtk-doc
rm -fr share/doc
rm -fr share/man
rm -fr share/aclocal
rm -fr share/intltool
rm -fr share/util-macros
# remove development files
rm -f lib/*.a
rm -f lib/*.la
rm -f lib/xorg/modules/*.a
rm -f lib/xorg/modules/*.la
# remove symbols
#strip lib/*.so
#strip lib/xorg/modules/*.so
# remove hardware specific files
rm -f lib/dri/i915_dri.so
rm -f lib/dri/i965_dri.so
rm -f lib/dri/mach64_dri.so
rm -f lib/dri/mga_dri.so
rm -f lib/dri/r128_dri.so
rm -f lib/dri/r200_dri.so
rm -f lib/dri/r300_dri.so
rm -f lib/dri/r600_dri.so
rm -f lib/dri/radeon_dri.so
rm -f lib/dri/savage_dri.so
#strip lib/dri/swrast_dri.so
rm -f lib/dri/tdfx_dri.so
rm -f lib/dri/unichrome_dri.so
# remove extra bin tools
cd bin
for i in *
do
if ! test -d "$i"
then
bin_check_file $i
fi
done
cd ..
cd $HOLDPATH

@ -1,13 +0,0 @@
diff --git a/src/Xge.c b/src/Xge.c
index 7a583e5..2ea5d27 100644
--- a/src/Xge.c
+++ b/src/Xge.c
@@ -294,7 +294,7 @@ _xgeEventToWire(Display* dpy, XEvent* re, xEvent* event)
/*
* Extensions need to register callbacks for their events.
*/
-Bool
+_X_HIDDEN Bool
xgeExtRegister(Display* dpy, int offset, XExtensionHooks* callbacks)
{
XGEExtNode* newExt;

@ -1,24 +0,0 @@
diff -ur a/src/common_interface.c b/src/common_interface.c
--- a/src/common_interface.c
+++ b/src/common_interface.c
@@ -51,6 +51,20 @@
# define HTOLE_32(x) (x)
#endif /* linux */
+#elif defined(__GNUC__) || defined(__clang__)
+
+#if __BYTE_ORDER == __BIG_ENDIAN
+# define LETOH_16(x) __builtin_bswap16(x)
+# define HTOLE_16(x) __builtin_bswap16(x)
+# define LETOH_32(x) __builtin_bswap32(x)
+# define HTOLE_32(x) __builtin_bswap32(x)
+#else
+# define LETOH_16(x) (x)
+# define HTOLE_16(x) (x)
+# define LETOH_32(x) (x)
+# define HTOLE_32(x) (x)
+#endif /* gcc or clang */
+
#elif defined(__sun)
#include <sys/byteorder.h>

@ -1,11 +0,0 @@
--- a/pixman/pixman-mmx.c
+++ b/pixman/pixman-mmx.c
@@ -89,7 +89,7 @@ _mm_mulhi_pu16 (__m64 __A, __m64 __B)
return __A;
}
-# ifdef __OPTIMIZE__
+# if defined(__OPTIMIZE__) && !defined(__clang__)
extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
_mm_shuffle_pi16 (__m64 __A, int8_t const __N)
{

@ -1 +0,0 @@
X11rdp

@ -1,112 +0,0 @@
# X11RDPBASE is the top-level X11rdp install directory
ifeq ($(X11RDPBASE),)
$(error X11RDPBASE needs to be set)
endif
BINBASE = $(X11RDPBASE)/bin
INCBASE = $(X11RDPBASE)/include
LIBBASE = $(X11RDPBASE)/lib
INSTALL = /usr/bin/install -c
XSRCBASE = ../build_dir/xorg-server-1.9.3
OBJS = rdpmain.o rdpdraw.o rdpinput.o rdpmisc.o rdpup.o rdprandr.o \
rdpCopyArea.o rdpPolyFillRect.o rdpPutImage.o rdpPolyRectangle.o \
rdpPolylines.o rdpPolySegment.o rdpFillSpans.o rdpSetSpans.o \
rdpCopyPlane.o rdpPolyPoint.o rdpPolyArc.o rdpFillPolygon.o \
rdpPolyFillArc.o rdpPolyText8.o rdpPolyText16.o \
rdpImageText8.o rdpImageText16.o rdpImageGlyphBlt.o rdpPolyGlyphBlt.o \
rdpPushPixels.o rdpxv.o rdpglyph.o rdpComposite.o \
rdpkeyboard.o rdpkeyboardevdev.o rdpkeyboardbase.o \
miinitext.o \
fbcmap_mi.o
# in Xorg 7.1, fbcmap.c was used but now it looks like fbcmap_mi.c should
# be used
#fbcmap_mi.o
#fbcmap.o
LIBS = \
$(XSRCBASE)/dix/.libs/libmain.a \
librdp.a \
$(XSRCBASE)/dbe/.libs/libdbe.a \
$(XSRCBASE)/dix/.libs/libdix.a \
$(XSRCBASE)/fb/.libs/libfb.a \
$(XSRCBASE)/mi/.libs/libmi.a \
$(XSRCBASE)/randr/.libs/librandr.a \
$(XSRCBASE)/render/.libs/librender.a \
$(XSRCBASE)/os/.libs/libos.a \
$(XSRCBASE)/record/.libs/librecord.a \
$(XSRCBASE)/xkb/.libs/libxkb.a \
$(XSRCBASE)/Xext/.libs/libXext.a \
$(XSRCBASE)/Xi/.libs/libXi.a \
$(XSRCBASE)/glx/.libs/libglx.a \
$(XSRCBASE)/xfixes/.libs/libxfixes.a \
$(XSRCBASE)/damageext/.libs/libdamageext.a \
$(XSRCBASE)/miext/damage/.libs/libdamage.a
LLIBS = -Wl,-rpath=$(LIBBASE) -lfreetype -lz -lm -lXfont -lXau \
-lXdmcp -lpixman-1 -lrt -ldl -lcrypto -lGL -lXdamage
CFLAGS = -g -O2 -Wall -fno-strength-reduce \
-I$(INCBASE) \
-I$(INCBASE)/X11 \
-I$(INCBASE)/X11/fonts \
-I$(INCBASE)/X11/extensions \
-I$(INCBASE)/xorg \
-I$(INCBASE)/pixman-1 \
-I../../../common \
-D_POSIX_C_SOURCE=199309L -D_SVID_SOURCE -D_REENTRANT \
-DGLX_USE_MESA -DXRECORD -D_GNU_SOURCE -DXAPPGROUP \
-DTOGCUP -DSINGLEDEPTH -DXFree86Server \
-DDBE -DEVI -DXVMC -DFONTCACHE -DGCCUSESGAS -DSTATIC_COLOR \
-DAVOID_GLYPHBLT -DFUNCPROTO=15 -DNARROWPROTO -DDDXOSFATALERROR \
-DPART_NET -DDDXTIME -D_HAVE_XALLOC_DECLS \
-DDAMAGE \
-DXFIXES \
-DSMART_SCHEDULE -DSERVER_LOCK -DGLXEXT -DSHAPE -DRENDER -DRANDR \
-DBIGREQS -D_POSIX_SOURCE -D_BSD_SOURCE -DSCREENSAVER \
-DXCMISC -DXTEST -DXTRAP -DXV -DXSYNC -DMITMISC -DPANORAMIX \
-DDPMSExtension -DXvExtension -DXvMCExtension -DXResExtension \
-DMITSHM -DPIXPRIV -DNDEBUG -DDDXOSINIT -DXKB -DXINPUT
#-DDAMAGE
# -pedantic
# -DXCSECURITY -DXF86BIGFONT
# these are defined in xorg-server.h
# -D_XOPEN_SOURCE=500L
# -DX_BYTE_ORDER=X_LITTLE_ENDIAN
# -DSMART_SCHEDULE -DSERVER_LOCK -DGLXEXT -DSHAPE -DRENDER -DRANDR
# -DBIGREQS -D_POSIX_SOURCE -D_BSD_SOURCE -DSCREENSAVER -DXF86BIGFONT
# -DXCMISC -DXTEST -DXTRAP -DXV -DXSYNC -DMITMISC -DPANORAMIX
# -DDPMSExtension -DXvExtension -DXvMCExtension -DXResExtension
# -DMITSHM -DPIXPRIV -DNDEBUG -DDDXOSINIT
# these are not needed I think
# -Dlinux -D__i386__
LDFLAGS = -L$(LIBBASE) -Wl,-rpath,$(LIBBASE)
all: X11rdp
X11rdp: $(OBJS)
$(AR) rvu librdp.a $(OBJS)
ranlib librdp.a
$(CC) $(LDFLAGS) -o X11rdp $(LIBS) $(LLIBS)
clean:
rm -f $(OBJS) librdp.a
miinitext.o: ../build_dir/xorg-server-1.9.3/mi/miinitext.c Makefile
$(CC) $(CFLAGS) -I../build_dir/xorg-server-1.9.3/Xext -c ../build_dir/xorg-server-1.9.3/mi/miinitext.c
fbcmap.o: ../build_dir/xorg-server-1.9.3/fb/fbcmap.c
$(CC) $(CFLAGS) -c ../build_dir/xorg-server-1.9.3/fb/fbcmap.c
fbcmap_mi.o: ../build_dir/xorg-server-1.9.3/fb/fbcmap_mi.c
$(CC) $(CFLAGS) -c ../build_dir/xorg-server-1.9.3/fb/fbcmap_mi.c
install: all
$(INSTALL) X11rdp $(BINBASE)/X11rdp

@ -1,35 +0,0 @@
/*
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.
*/
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);

@ -1,784 +0,0 @@
/*
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.
*/
#if defined(__arm__) && !defined(__arm32__)
#define __arm32__
#endif
#include "xorg-server.h"
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/param.h>
#include <sys/stat.h>
#include <netinet/tcp.h>
#include <netinet/in.h>
#include <netdb.h>
#include "X.h"
#define NEED_EVENTS
#include "Xproto.h"
#include "Xos.h"
#include "scrnintstr.h"
#include "servermd.h"
#define PSZ 8
//#include "cfb.h"
#include "mibstore.h"
#include "colormapst.h"
#include "gcstruct.h"
#include "input.h"
#include "mipointer.h"
#include "dixstruct.h"
#include "propertyst.h"
#include "Xatom.h"
#include "dix.h"
#include "X11/keysym.h"
#include "dixfontstr.h"
#include "fontstruct.h"
#include "cursorstr.h"
#include "picturestr.h"
#include "XKBstr.h"
#include "inputstr.h"
#include "randrstr.h"
#include "mi.h"
#include "fb.h"
#include "micmap.h"
#include "events.h"
#include "exevents.h"
#include "xserver-properties.h"
#include "xkbsrv.h"
/* in xrdp/common */
#include "xrdp_client_info.h"
#include "xrdp_constants.h"
//#include "colormapst.h"
#define X11RDPVER "0.9.6"
#define PixelDPI 100
#define PixelToMM(_size) (((_size) * 254 + (PixelDPI) * 5) / ((PixelDPI) * 10))
#define TAG_COMPOSITE 0
#define TAG_COPYAREA 1
#define TAG_POLYFILLRECT 2
#define TAG_PUTIMAGE 3
#define TAG_POLYRECTANGLE 4
#define TAG_COPYPLANE 5
#define TAG_POLYARC 6
#define TAG_FILLPOLYGON 7
#define TAG_POLYFILLARC 8
#define TAG_IMAGETEXT8 9
#define TAG_POLYTEXT8 10
#define TAG_POLYTEXT16 11
#define TAG_IMAGETEXT16 12
#define TAG_IMAGEGLYPHBLT 13
#define TAG_POLYGLYPHBLT 14
#define TAG_PUSHPIXELS 15
struct image_data
{
int width;
int height;
int bpp;
int Bpp;
int lineBytes;
char* pixels;
char* shmem_pixels;
int shmem_id;
int shmem_offset;
int shmem_lineBytes;
};
/* Per-screen (framebuffer) structure. There is only one of these, since we
don't allow the X server to have multiple screens. */
struct _rdpScreenInfoRec
{
int width;
int paddedWidthInBytes;
int height;
int depth;
int bitsPerPixel;
int sizeInBytes; /* size of current used frame buffer */
int sizeInBytesAlloc; /* size of current alloc frame buffer,
always >= sizeInBytes */
char* pfbMemory;
Pixel blackPixel;
Pixel whitePixel;
/* wrapped screen functions */
/* Random screen procedures */
CloseScreenProcPtr CloseScreen;
/* GC procedures */
CreateGCProcPtr CreateGC;
/* Pixmap procedures */
CreatePixmapProcPtr CreatePixmap;
DestroyPixmapProcPtr DestroyPixmap;
/* Window Procedures */
CreateWindowProcPtr CreateWindow;
DestroyWindowProcPtr DestroyWindow;
PositionWindowProcPtr PositionWindow;
RealizeWindowProcPtr RealizeWindow;
UnrealizeWindowProcPtr UnrealizeWindow;
ChangeWindowAttributesProcPtr ChangeWindowAttributes;
WindowExposuresProcPtr WindowExposures;
CreateColormapProcPtr CreateColormap;
DestroyColormapProcPtr DestroyColormap;
CopyWindowProcPtr CopyWindow;
ClearToBackgroundProcPtr ClearToBackground;
ScreenWakeupHandlerProcPtr WakeupHandler;
CreatePictureProcPtr CreatePicture;
DestroyPictureProcPtr DestroyPicture;
CompositeProcPtr Composite;
GlyphsProcPtr Glyphs;
/* Backing store procedures */
RestoreAreasProcPtr RestoreAreas;
int rdp_width;
int rdp_height;
int rdp_bpp;
int rdp_Bpp;
int rdp_Bpp_mask;
struct xrdp_client_info client_info;
};
typedef struct _rdpScreenInfoRec rdpScreenInfoRec;
typedef rdpScreenInfoRec* rdpScreenInfoPtr;
struct _rdpGCRec
{
GCFuncs* funcs;
GCOps* ops;
};
typedef struct _rdpGCRec rdpGCRec;
typedef rdpGCRec* rdpGCPtr;
#define GETGCPRIV(_pGC) \
(rdpGCPtr)dixGetPrivateAddr(&(_pGC->devPrivates), &g_rdpGCIndex)
struct _rdpWindowRec
{
int status;
};
typedef struct _rdpWindowRec rdpWindowRec;
typedef rdpWindowRec* rdpWindowPtr;
#define GETWINPRIV(_pWindow) \
(rdpWindowPtr)dixGetPrivateAddr(&(_pWindow->devPrivates), &g_rdpWindowIndex)
#define XR_IS_ROOT(_pWindow) ((_pWindow)->drawable.pScreen->root == (_pWindow))
/* for tooltips */
#define XR_STYLE_TOOLTIP (0x80000000)
#define XR_EXT_STYLE_TOOLTIP (0x00000080 | 0x00000008)
/* for normal desktop windows */
/* WS_TILEDWINDOW (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME |
WS_MINIMIZEBOX | WS_MAXIMIZEBOX) */
#define XR_STYLE_NORMAL (0x00C00000 | 0x00080000 | 0x00040000 | 0x00010000 | 0x00020000)
#define XR_EXT_STYLE_NORMAL (0x00040000)
/* for dialogs */
#define XR_STYLE_DIALOG (0x80000000)
#define XR_EXT_STYLE_DIALOG (0x00040000)
#define RDI_FILL 1
#define RDI_IMGLL 2 /* lossless */
#define RDI_IMGLY 3 /* lossy */
#define RDI_LINE 4
#define RDI_SCRBLT 5
#define RDI_TEXT 6
struct urdp_draw_item_fill
{
int opcode;
int fg_color;
int bg_color;
int pad0;
};
struct urdp_draw_item_img
{
int opcode;
int pad0;
};
struct urdp_draw_item_line
{
int opcode;
int fg_color;
int bg_color;
int width;
xSegment* segs;
int nseg;
int flags;
};
struct urdp_draw_item_scrblt
{
int srcx;
int srcy;
int dstx;
int dsty;
int cx;
int cy;
};
struct urdp_draw_item_text
{
int opcode;
int fg_color;
struct rdp_text* rtext; /* in rdpglyph.h */
};
union urdp_draw_item
{
struct urdp_draw_item_fill fill;
struct urdp_draw_item_img img;
struct urdp_draw_item_line line;
struct urdp_draw_item_scrblt scrblt;
struct urdp_draw_item_text text;
};
struct rdp_draw_item
{
int type; /* RDI_FILL, RDI_IMGLL, ... */
int flags;
struct rdp_draw_item* prev;
struct rdp_draw_item* next;
RegionPtr reg;
union urdp_draw_item u;
};
#define XRDP_USE_COUNT_THRESHOLD 1
struct _rdpPixmapRec
{
int status;
int rdpindex;
int con_number;
int is_dirty;
int is_scratch;
int is_alpha_dirty_not;
/* number of times used in a remote operation
if this gets above XRDP_USE_COUNT_THRESHOLD
then we force remote the pixmap */
int use_count;
int kind_width;
struct rdp_draw_item* draw_item_head;
struct rdp_draw_item* draw_item_tail;
};
typedef struct _rdpPixmapRec rdpPixmapRec;
typedef rdpPixmapRec* rdpPixmapPtr;
#define GETPIXPRIV(_pPixmap) \
(rdpPixmapPtr)dixGetPrivateAddr(&(_pPixmap->devPrivates), &g_rdpPixmapIndex)
#define XRDP_IS_OS(_priv) (_priv->status != 0)
/* rdpmisc.c */
void
rdpLog(char *format, ...);
int
rdpBitsPerPixel(int depth);
void
rdpClientStateChange(CallbackListPtr* cbl, pointer myData, pointer clt);
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);
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);
const char *
g_socket_dir(void);
void
hexdump(unsigned char *p, unsigned int len);
void
RegionAroundSegs(RegionPtr reg, xSegment* segs, int nseg);
int
get_crc(char* data, int data_bytes);
int
get_mstime(void);
/* rdpdraw.c */
Bool
rdpCloseScreen(int i, ScreenPtr pScreen);
int
draw_item_add(rdpPixmapRec* priv, struct rdp_draw_item* di);
int
draw_item_remove(rdpPixmapRec* priv, struct rdp_draw_item* di);
int
draw_item_remove_all(rdpPixmapRec* priv);
int
draw_item_pack(PixmapPtr pix, rdpPixmapRec* priv);
int
draw_item_add_img_region(rdpPixmapRec* priv, RegionPtr reg, int opcode,
int type, int code);
int
draw_item_add_fill_region(rdpPixmapRec* priv, RegionPtr reg, int color,
int opcode);
int
draw_item_add_line_region(rdpPixmapRec* priv, RegionPtr reg, int color,
int opcode, int width, xSegment* segs, int nsegs,
int is_segment);
int
draw_item_add_srcblt_region(rdpPixmapRec* priv, RegionPtr reg,
int srcx, int srcy, int dstx, int dsty,
int cx, int cy);
int
draw_item_add_text_region(rdpPixmapRec* priv, RegionPtr reg, int color,
int opcode, struct rdp_text* rtext);
PixmapPtr
rdpCreatePixmap(ScreenPtr pScreen, int width, int height, int depth,
unsigned usage_hint);
Bool
rdpDestroyPixmap(PixmapPtr pPixmap);
int
xrdp_is_os(PixmapPtr pix, rdpPixmapPtr priv);
Bool
rdpCreateWindow(WindowPtr pWindow);
Bool
rdpDestroyWindow(WindowPtr pWindow);
Bool
rdpPositionWindow(WindowPtr pWindow, int x, int y);
Bool
rdpRealizeWindow(WindowPtr pWindow);
Bool
rdpUnrealizeWindow(WindowPtr pWindow);
Bool
rdpChangeWindowAttributes(WindowPtr pWindow, unsigned long mask);
void
rdpWindowExposures(WindowPtr pWindow, RegionPtr pRegion, RegionPtr pBSRegion);
Bool
rdpCreateGC(GCPtr pGC);
void
rdpCopyWindow(WindowPtr pWin, DDXPointRec ptOldOrg, RegionPtr pOldRegion);
void
rdpClearToBackground(WindowPtr pWin, int x, int y, int w, int h,
Bool generateExposures);
RegionPtr
rdpRestoreAreas(WindowPtr pWin, RegionPtr prgnExposed);
void
rdpInstallColormap(ColormapPtr pmap);
void
rdpUninstallColormap(ColormapPtr pmap);
int
rdpListInstalledColormaps(ScreenPtr pScreen, Colormap* pmaps);
void
rdpStoreColors(ColormapPtr pmap, int ndef, xColorItem* pdefs);
Bool
rdpSaveScreen(ScreenPtr pScreen, int on);
Bool
rdpRealizeCursor(ScreenPtr pScreen, CursorPtr pCursor);
Bool
rdpUnrealizeCursor(ScreenPtr pScreen, CursorPtr pCursor);
void
rdpCursorLimits(ScreenPtr pScreen, CursorPtr pCursor,
BoxPtr pHotBox, BoxPtr pTopLeftBox);
void
rdpConstrainCursor(ScreenPtr pScreen, BoxPtr pBox);
Bool
rdpSetCursorPosition(ScreenPtr pScreen, int x, int y, Bool generateEvent);
Bool
rdpDisplayCursor(ScreenPtr pScreen, CursorPtr pCursor);
void
rdpRecolorCursor(ScreenPtr pScreen, CursorPtr pCursor,
Bool displayed);
/* rdpglyph.c */
/* look in rdpglyph.h */
/* rdpComposite.c */
int
rdpCreatePicture(PicturePtr pPicture);
void
rdpDestroyPicture(PicturePtr pPicture);
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);
/* rdpinput.c */
int
rdpKeybdProc(DeviceIntPtr pDevice, int onoff);
int
rdpMouseProc(DeviceIntPtr pDevice, int onoff);
Bool
rdpCursorOffScreen(ScreenPtr* ppScreen, int* x, int* y);
void
rdpCrossScreen(ScreenPtr pScreen, Bool entering);
void
rdpPointerWarpCursor(DeviceIntPtr pDev, ScreenPtr pScr, int x, int y);
void
rdpPointerEnqueueEvent(DeviceIntPtr pDev, InternalEvent* event);
void
rdpPointerNewEventScreen(DeviceIntPtr pDev, ScreenPtr pScr, Bool fromDIX);
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);
void
PtrAddEvent(int buttonMask, int x, int y);
void
KbdAddEvent(int down, int param1, int param2, int param3, int param4);
void
KbdSync(int param1);
int
rdpLoadLayout(struct xrdp_client_info *client_info);
/* rdpup.c */
int
rdpup_add_os_bitmap(PixmapPtr pixmap, rdpPixmapPtr priv);
int
rdpup_remove_os_bitmap(int rdpindex);
int
rdpup_update_os_use(int rdpindex);
void
rdpup_get_screen_image_rect(struct image_data* id);
void
rdpup_get_pixmap_image_rect(PixmapPtr pPixmap, struct image_data* id);
int
rdpup_init(void);
int
rdpup_check(void);
int
rdpup_begin_update(void);
int
rdpup_end_update(void);
int
rdpup_fill_rect(short x, short y, int cx, int cy);
int
rdpup_screen_blt(short x, short y, int cx, int cy, short srcx, short srcy);
int
rdpup_set_clip(short x, short y, int cx, int cy);
int
rdpup_reset_clip(void);
int
rdpup_set_fgcolor(int fgcolor);
int
rdpup_set_bgcolor(int bgcolor);
int
rdpup_set_opcode(int opcode);
int
rdpup_paint_rect(short x, short y, int cx, int cy,
char* bmpdata, int width, int height,
short srcx, short srcy);
int
rdpup_set_pen(int style, int width);
int
rdpup_draw_line(short x1, short y1, short x2, short y2);
void
rdpup_send_area(struct image_data* id, int x, int y, int w, int h);
int
rdpup_set_cursor(short x, short y, char* cur_data, char* cur_mask);
int
rdpup_set_cursor_ex(short x, short y, char *cur_data, char *cur_mask, int bpp);
int
rdpup_create_os_surface(int rdpindex, int width, int height);
int
rdpup_create_os_surface_bpp(int rdpindex, int width, int height, int bpp);
int
rdpup_switch_os_surface(int rdpindex);
int
rdpup_delete_os_surface(int rdpindex);
void
rdpup_paint_rect_os(int x, int y, int cx, int cy,
int rdpindex, int srcx, int srcy);
void
rdpup_set_hints(int hints, int mask);
void
rdpup_create_window(WindowPtr pWindow, rdpWindowRec* priv);
void
rdpup_delete_window(WindowPtr pWindow, rdpWindowRec* priv);
int
rdpup_check_dirty(PixmapPtr pDirtyPixmap, rdpPixmapRec* pDirtyPriv);
int
rdpup_check_alpha_dirty(PixmapPtr pDirtyPixmap, rdpPixmapRec* pDirtyPriv);
int
rdpup_check_dirty_screen(rdpPixmapRec* pDirtyPriv);
int
rdpup_add_char(int font, int character, short x, short y, int cx, int cy,
char* bmpdata, int bmpdata_bytes);
int
rdpup_add_char_alpha(int font, int character, short x, short y, int cx, int cy,
char* bmpdata, int bmpdata_bytes);
int
rdpup_draw_text(int font, int flags, int mixmode,
short clip_left, short clip_top,
short clip_right, short clip_bottom,
short box_left, short box_top,
short box_right, short box_bottom, short x, short y,
char* data, int data_bytes);
int
rdpup_composite(short srcidx, int srcformat, short srcwidth, CARD8 srcrepeat,
PictTransform* srctransform, CARD8 mskflags,
short mskidx, int mskformat, short mskwidth, CARD8 mskrepeat,
CARD8 op, short srcx, short srcy, short mskx, short msky,
short dstx, short dsty, short width, short height,
int dstformat);
void
rdpScheduleDeferredUpdate(void);
int
rdpXvInit(ScreenPtr pScreen);
#if defined(X_BYTE_ORDER)
# if X_BYTE_ORDER == X_LITTLE_ENDIAN
# define L_ENDIAN
# else
# define B_ENDIAN
# endif
#else
# error Unknown endianness in rdp.h
#endif
/* check if we need to align data */
/* check if we need to align data */
#if defined(__sparc__) || defined(__alpha__) || defined(__hppa__) || \
defined(__AIX__) || defined(__PPC__) || defined(__mips__) || \
defined(__ia64__) || defined(__ppc__) || defined(__arm__)
#define NEED_ALIGN
#endif
/* parser state */
struct stream
{
char* p;
char* end;
char* data;
int size;
/* offsets of various headers */
char* iso_hdr;
char* mcs_hdr;
char* sec_hdr;
char* rdp_hdr;
char* channel_hdr;
char* next_packet;
};
/******************************************************************************/
#define s_push_layer(s, h, n) \
{ \
(s)->h = (s)->p; \
(s)->p += (n); \
}
/******************************************************************************/
#define s_pop_layer(s, h) \
{ \
(s)->p = (s)->h; \
}
/******************************************************************************/
#if defined(B_ENDIAN) || defined(NEED_ALIGN)
#define out_uint16_le(s, v) \
{ \
*((s)->p) = (unsigned char)((v) >> 0); \
(s)->p++; \
*((s)->p) = (unsigned char)((v) >> 8); \
(s)->p++; \
}
#else
#define out_uint16_le(s, v) \
{ \
*((unsigned short*)((s)->p)) = (unsigned short)(v); \
(s)->p += 2; \
}
#endif
/******************************************************************************/
#define out_uint8(s, v) \
{ \
*((s)->p) = (unsigned char)((v) >> 0); \
(s)->p++; \
}
/******************************************************************************/
#define init_stream(s, v) \
{ \
if ((v) > (s)->size) \
{ \
g_free((s)->data); \
(s)->data = (char*)g_malloc((v), 0); \
(s)->size = (v); \
} \
(s)->p = (s)->data; \
(s)->end = (s)->data; \
(s)->next_packet = 0; \
}
/******************************************************************************/
#define out_uint8p(s, v, n) \
{ \
g_memcpy((s)->p, (v), (n)); \
(s)->p += (n); \
}
/******************************************************************************/
#define out_uint8a(s, v, n) \
{ \
out_uint8p((s), (v), (n)); \
}
/******************************************************************************/
#define out_uint8s(s, n) do \
{ \
memset((s)->p, 0, (n)); \
(s)->p += (n); \
} while (0)
/******************************************************************************/
#if defined(B_ENDIAN) || defined(NEED_ALIGN)
#define out_uint32_le(s, v) \
{ \
*((s)->p) = (unsigned char)((v) >> 0); \
(s)->p++; \
*((s)->p) = (unsigned char)((v) >> 8); \
(s)->p++; \
*((s)->p) = (unsigned char)((v) >> 16); \
(s)->p++; \
*((s)->p) = (unsigned char)((v) >> 24); \
(s)->p++; \
}
#else
#define out_uint32_le(s, v) \
{ \
*((unsigned int*)((s)->p)) = (v); \
(s)->p += 4; \
}
#endif
/******************************************************************************/
#if defined(B_ENDIAN) || defined(NEED_ALIGN)
#define in_uint32_le(s, v) \
{ \
(v) = (unsigned int) \
( \
(*((unsigned char*)((s)->p + 0)) << 0) | \
(*((unsigned char*)((s)->p + 1)) << 8) | \
(*((unsigned char*)((s)->p + 2)) << 16) | \
(*((unsigned char*)((s)->p + 3)) << 24) \
); \
(s)->p += 4; \
}
#else
#define in_uint32_le(s, v) \
{ \
(v) = *((unsigned int*)((s)->p)); \
(s)->p += 4; \
}
#endif
/******************************************************************************/
#if defined(B_ENDIAN) || defined(NEED_ALIGN)
#define in_uint16_le(s, v) \
{ \
(v) = (unsigned short) \
( \
(*((unsigned char*)((s)->p + 0)) << 0) | \
(*((unsigned char*)((s)->p + 1)) << 8) \
); \
(s)->p += 2; \
}
#else
#define in_uint16_le(s, v) \
{ \
(v) = *((unsigned short*)((s)->p)); \
(s)->p += 2; \
}
#endif
/******************************************************************************/
#define s_mark_end(s) \
{ \
(s)->end = (s)->p; \
}
/******************************************************************************/
#define make_stream(s) \
{ \
(s) = (struct stream*)g_malloc(sizeof(struct stream), 1); \
}
/******************************************************************************/
#define free_stream(s) do \
{ \
if ((s) != 0) \
{ \
g_free((s)->data); \
} \
g_free((s)); \
} while (0)

@ -1,846 +0,0 @@
/*
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.
*/
#include "rdp.h"
#include "rdpdraw.h"
#define LDEBUG 0
#define LOG_LEVEL 1
#define LLOG(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; } } while (0)
#define LLOGLN(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0)
extern rdpScreenInfoRec g_rdpScreen; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpGCIndex; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpWindowIndex; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpPixmapIndex; /* from rdpmain.c */
extern int g_Bpp; /* from rdpmain.c */
extern ScreenPtr g_pScreen; /* from rdpmain.c */
extern Bool g_wrapPixmap; /* from rdpmain.c */
extern int g_can_do_pix_to_pix; /* from rdpmain.c */
extern int g_do_dirty_os; /* in rdpmain.c */
extern int g_do_dirty_ons; /* in rdpmain.c */
extern rdpPixmapRec g_screenPriv; /* in rdpmain.c */
extern int g_do_glyph_cache; /* in rdpmain.c */
extern int g_doing_font; /* in rdpmain.c */
extern int g_do_composite; /* in rdpmain.c */
extern GCOps g_rdpGCOps; /* from rdpdraw.c */
extern int g_con_number; /* in rdpup.c */
extern int g_crc_seed; /* in rdpmisc.c */
extern int g_crc_table[]; /* in rdpmisc.c */
/******************************************************************************/
int
rdpCreatePicture(PicturePtr pPicture)
{
PictureScreenPtr ps;
int rv;
LLOGLN(10, ("rdpCreatePicture:"));
ps = GetPictureScreen(g_pScreen);
ps->CreatePicture = g_rdpScreen.CreatePicture;
rv = ps->CreatePicture(pPicture);
ps->CreatePicture = rdpCreatePicture;
return rv;
}
/******************************************************************************/
void
rdpDestroyPicture(PicturePtr pPicture)
{
PictureScreenPtr ps;
LLOGLN(10, ("rdpDestroyPicture:"));
ps = GetPictureScreen(g_pScreen);
ps->DestroyPicture = g_rdpScreen.DestroyPicture;
ps->DestroyPicture(pPicture);
ps->DestroyPicture = rdpDestroyPicture;
}
/******************************************************************************/
static int
print_format(PictFormatShort format)
{
switch (format)
{
case PIXMAN_a2r10g10b10:
LLOGLN(0, (" PIXMAN_x2r10g10b10"));
break;
case PIXMAN_x2r10g10b10:
LLOGLN(0, (" PIXMAN_x2r10g10b10"));
break;
case PIXMAN_a2b10g10r10:
LLOGLN(0, (" PIXMAN_a2b10g10r10"));
break;
case PIXMAN_x2b10g10r10:
LLOGLN(0, (" PIXMAN_x2b10g10r10"));
break;
case PIXMAN_a8r8g8b8:
LLOGLN(0, (" PIXMAN_a8r8g8b8"));
break;
case PIXMAN_x8r8g8b8:
LLOGLN(0, (" PIXMAN_x8r8g8b8"));
break;
case PIXMAN_a8b8g8r8:
LLOGLN(0, (" PIXMAN_a8b8g8r8"));
break;
case PIXMAN_x8b8g8r8:
LLOGLN(0, (" PIXMAN_x8b8g8r8"));
break;
case PIXMAN_b8g8r8a8:
LLOGLN(0, (" PIXMAN_b8g8r8a8"));
break;
case PIXMAN_b8g8r8x8:
LLOGLN(0, (" PIXMAN_b8g8r8x8"));
break;
/* 24bpp formats */
case PIXMAN_r8g8b8:
LLOGLN(0, (" PIXMAN_r8g8b8"));
break;
case PIXMAN_b8g8r8:
LLOGLN(0, (" PIXMAN_b8g8r8"));
break;
/* 16bpp formats */
case PIXMAN_r5g6b5:
LLOGLN(0, (" PIXMAN_r5g6b5"));
break;
case PIXMAN_b5g6r5:
LLOGLN(0, (" PIXMAN_b5g6r5"));
break;
case PIXMAN_a1r5g5b5:
LLOGLN(0, (" PIXMAN_a1r5g5b5"));
break;
case PIXMAN_x1r5g5b5:
LLOGLN(0, (" PIXMAN_x1r5g5b5"));
break;
case PIXMAN_a1b5g5r5:
LLOGLN(0, (" PIXMAN_a1b5g5r5"));
break;
case PIXMAN_x1b5g5r5:
LLOGLN(0, (" PIXMAN_x1b5g5r5"));
break;
case PIXMAN_a4r4g4b4:
LLOGLN(0, (" PIXMAN_a4r4g4b4"));
break;
case PIXMAN_x4r4g4b4:
LLOGLN(0, (" PIXMAN_x4r4g4b4"));
break;
case PIXMAN_a4b4g4r4:
LLOGLN(0, (" PIXMAN_a4b4g4r4"));
break;
case PIXMAN_x4b4g4r4:
LLOGLN(0, (" PIXMAN_x4b4g4r4"));
break;
/* 8bpp formats */
case PIXMAN_a8:
LLOGLN(0, (" PIXMAN_a8"));
break;
case PIXMAN_r3g3b2:
LLOGLN(0, (" PIXMAN_r3g3b2"));
break;
case PIXMAN_b2g3r3:
LLOGLN(0, (" PIXMAN_b2g3r3"));
break;
case PIXMAN_a2r2g2b2:
LLOGLN(0, (" PIXMAN_a2r2g2b2"));
break;
case PIXMAN_a2b2g2r2:
LLOGLN(0, (" PIXMAN_a2b2g2r2"));
break;
case PIXMAN_c8:
LLOGLN(0, (" PIXMAN_c8"));
break;
case PIXMAN_g8:
LLOGLN(0, (" PIXMAN_g8"));
break;
case PIXMAN_x4a4:
LLOGLN(0, (" PIXMAN_x4a4"));
break;
/* 4bpp formats */
case PIXMAN_a4:
LLOGLN(0, (" PIXMAN_a4"));
break;
case PIXMAN_r1g2b1:
LLOGLN(0, (" PIXMAN_r1g2b1"));
break;
case PIXMAN_b1g2r1:
LLOGLN(0, (" PIXMAN_b1g2r1"));
break;
case PIXMAN_a1r1g1b1:
LLOGLN(0, (" PIXMAN_a1r1g1b1"));
break;
case PIXMAN_a1b1g1r1:
LLOGLN(0, (" PIXMAN_a1b1g1r1"));
break;
case PIXMAN_c4:
LLOGLN(0, (" PIXMAN_c4"));
break;
case PIXMAN_g4:
LLOGLN(0, (" PIXMAN_g4"));
break;
/* 1bpp formats */
case PIXMAN_a1:
LLOGLN(0, (" PIXMAN_a1"));
break;
case PIXMAN_g1:
LLOGLN(0, (" PIXMAN_g1"));
break;
}
return 0;
}
/******************************************************************************/
static int
composite_print(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst,
INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask, INT16 xDst,
INT16 yDst, CARD16 width, CARD16 height)
{
PixmapPtr pSrcPixmap;
PixmapPtr pDstPixmap;
rdpPixmapRec* pSrcPriv;
rdpPixmapRec* pDstPriv;
LLOGLN(0, ("composite_print: op %d xSrc %d ySrc %d xDst %d yDst %d "
"width %d height %d",
op, xSrc, ySrc, xDst, yDst, width, height));
if (pSrc != 0)
{
LLOGLN(0, (" src depth %d width %d height %d repeat %d repeatType %d "
"dither %d filter %d alphaMap %p componentAlpha %d", pSrc->pDrawable->depth,
pSrc->pDrawable->width, pSrc->pDrawable->height,
pSrc->repeat, pSrc->repeatType, pSrc->dither, pSrc->filter,
pSrc->alphaMap, pSrc->componentAlpha));
LLOGLN(0, (" transform %p", pSrc->transform));
LLOGLN(0, (" detail format red %d red mask %d green %d green mask %d "
"blue %d blue mask %d",
pSrc->pFormat->direct.red, pSrc->pFormat->direct.redMask,
pSrc->pFormat->direct.green, pSrc->pFormat->direct.greenMask,
pSrc->pFormat->direct.blue, pSrc->pFormat->direct.blueMask));
print_format(pSrc->format);
if (pSrc->pDrawable->type == DRAWABLE_PIXMAP)
{
pSrcPixmap = (PixmapPtr)(pSrc->pDrawable);
pSrcPriv = GETPIXPRIV(pSrcPixmap);
LLOGLN(0, (" DRAWABLE_PIXMAP pSrcPriv %p status %d", pSrcPriv, pSrcPriv->status));
}
else if (pSrc->pDrawable->type == DRAWABLE_WINDOW)
{
LLOGLN(0, (" DRAWABLE_WINDOW"));
}
else
{
LLOGLN(0, (" OTHER"));
}
}
if (pMask != 0)
{
LLOGLN(0, (" msk depth %d width %d height %d repeat %d repeatType %d",
pMask->pDrawable->depth,
pMask->pDrawable->width,
pMask->pDrawable->height, pMask->repeat, pMask->repeatType));
print_format(pMask->format);
}
if (pDst != 0)
{
LLOGLN(0, (" dst depth %d width %d height %d repeat %d repeatType %d "
"dither %d filter %d alphaMap %p", pDst->pDrawable->depth,
pDst->pDrawable->width, pDst->pDrawable->height,
pDst->repeat, pDst->repeatType, pDst->dither, pDst->filter,
pDst->alphaMap));
LLOGLN(0, (" transform %p", pDst->transform));
print_format(pDst->format);
if (pDst->pDrawable->type == DRAWABLE_PIXMAP)
{
pDstPixmap = (PixmapPtr)(pDst->pDrawable);
pDstPriv = GETPIXPRIV(pDstPixmap);
LLOGLN(0, (" DRAWABLE_PIXMAP pDstPriv %p status %d", pDstPriv, pDstPriv->status));
}
else if (pDst->pDrawable->type == DRAWABLE_WINDOW)
{
LLOGLN(0, (" DRAWABLE_WINDOW"));
}
else
{
LLOGLN(0, (" OTHER"));
}
}
return 0;
}
/******************************************************************************/
static int
src_alpha_needed(CARD8 op)
{
int rv;
rv = 0;
switch (op)
{
case 3: /* Over */
case 6: /* InReverse */
case 8: /* OutReverse */
case 9: /* Atop */
case 10: /* AtopReverse */
case 11: /* Xor */
case 13: /* Saturate */
case 17: /* DisjointOver */
case 18: /* DisjointOverReverse */
case 19: /* DisjointIn */
case 20: /* DisjointInReverse */
case 21: /* DisjointOut */
case 22: /* DisjointOutReverse */
case 23: /* DisjointAtop */
case 24: /* DisjointAtopReverse */
case 25: /* DisjointXor */
case 29: /* ConjointOver */
case 30: /* ConjointOverReverse */
case 31: /* ConjointIn */
case 32: /* ConjointInReverse */
case 33: /* ConjointOut */
case 34: /* ConjointOutReverse */
case 35: /* ConjointAtop */
case 36: /* ConjointAtopReverse */
case 37: /* ConjointXor */
rv = 1;
break;
}
return rv;
}
/******************************************************************************/
static int
dst_alpha_needed(CARD8 op)
{
int rv;
rv = 0;
switch (op)
{
case 4: /* OverReverse */
case 5: /* In */
case 7: /* Out */
case 9: /* Atop */
case 10: /* AtopReverse */
case 11: /* Xor */
case 13: /* Saturate */
case 17: /* DisjointOver */
case 18: /* DisjointOverReverse */
case 19: /* DisjointIn */
case 20: /* DisjointInReverse */
case 21: /* DisjointOut */
case 22: /* DisjointOutReverse */
case 23: /* DisjointAtop */
case 24: /* DisjointAtopReverse */
case 25: /* DisjointXor */
case 29: /* ConjointOver */
case 30: /* ConjointOverReverse */
case 31: /* ConjointIn */
case 32: /* ConjointInReverse */
case 33: /* ConjointOut */
case 34: /* ConjointOutReverse */
case 35: /* ConjointAtop */
case 36: /* ConjointAtopReverse */
case 37: /* ConjointXor */
rv = 1;
break;
}
return rv;
}
struct msk_info
{
int flags;
int idx;
int format;
int width;
int repeat;
};
static char g_com_fail_strings[][128] =
{
"OK",
"src not remotable",
"dst not remotable",
"msk not remotable"
};
/******************************************************************************/
/* returns boolean */
static int
check_drawables(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst,
INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask, INT16 xDst,
INT16 yDst, CARD16 width, CARD16 height, struct msk_info* msk)
{
int rv;
int fail_reason;
PixmapPtr pSrcPixmap;
PixmapPtr pDstPixmap;
PixmapPtr pMskPixmap;
rdpPixmapRec* pSrcPriv;
rdpPixmapRec* pDstPriv;
rdpPixmapRec* pMskPriv;
fail_reason = 0;
pSrcPixmap = 0;
pDstPixmap = 0;
pMskPixmap = 0;
pSrcPriv = 0;
pDstPriv = 0;
pMskPriv = 0;
rv = 0;
if (pSrc != 0)
{
if (pSrc->pDrawable != 0)
{
if (pSrc->pDrawable->type == DRAWABLE_PIXMAP)
{
pSrcPixmap = (PixmapPtr)(pSrc->pDrawable);
pSrcPriv = GETPIXPRIV(pSrcPixmap);
if (xrdp_is_os(pSrcPixmap, pSrcPriv))
{
if (pDst != 0)
{
if (pDst->pDrawable != 0)
{
if (pDst->pDrawable->type == DRAWABLE_PIXMAP)
{
pDstPixmap = (PixmapPtr)(pDst->pDrawable);
pDstPriv = GETPIXPRIV(pDstPixmap);
if (xrdp_is_os(pDstPixmap, pDstPriv))
{
rv = 1;
}
else
{
fail_reason = 2;
}
}
}
}
}
else
{
fail_reason = 1;
}
}
}
}
if (rv)
{
if (pMask != 0)
{
#if 1
rv = 0;
if (pMask->pDrawable != 0)
{
if (pMask->pDrawable->type == DRAWABLE_PIXMAP)
{
pMskPixmap = (PixmapPtr)(pMask->pDrawable);
pMskPriv = GETPIXPRIV(pMskPixmap);
if (xrdp_is_os(pMskPixmap, pMskPriv))
{
rv = 1;
msk->flags = 1;
msk->idx = pMskPriv->rdpindex;
msk->format = pMask->format;
msk->width = pMask->pDrawable->width;
msk->repeat = pMask->repeatType;
}
else
{
fail_reason = 3;
}
}
}
#endif
}
}
if (rv == 0)
{
LLOGLN(10, ("check_drawables: can not remote [%s]", g_com_fail_strings[fail_reason]));
#if 0
composite_print(op, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask,
xDst, yDst, width, height);
#endif
}
else
{
LLOGLN(10, ("check_drawables: can remote [%s]", g_com_fail_strings[fail_reason]));
#if 0
composite_print(op, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask,
xDst, yDst, width, height);
#endif
}
return rv;
}
/******************************************************************************/
static int
rdpRemoteComposite(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst,
INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask, INT16 xDst,
INT16 yDst, CARD16 width, CARD16 height)
{
int ok_to_remote;
PixmapPtr pSrcPixmap;
PixmapPtr pMskPixmap;
PixmapPtr pDstPixmap;
rdpPixmapRec* pSrcPriv;
rdpPixmapRec* pMskPriv;
rdpPixmapRec* pDstPriv;
BoxRec box;
RegionRec reg1;
RegionRec reg2;
DrawablePtr p;
int j;
int num_clips;
struct msk_info msk;
LLOGLN(10, ("rdpRemoteComposite:"));
memset(&msk, 0, sizeof(msk));
ok_to_remote = check_drawables(op, pSrc, pMask, pDst, xSrc, ySrc,
xMask, yMask, xDst, yDst, width, height,
&msk);
if (!ok_to_remote)
{
return 1;
}
ValidatePicture(pSrc);
pSrcPixmap = (PixmapPtr)(pSrc->pDrawable);
pSrcPriv = GETPIXPRIV(pSrcPixmap);
rdpup_check_dirty(pSrcPixmap, pSrcPriv);
if (PIXMAN_FORMAT_A(pSrc->format) > 0)
{
if (src_alpha_needed(op))
{
rdpup_check_alpha_dirty(pSrcPixmap, pSrcPriv);
}
}
ValidatePicture(pDst);
pDstPixmap = (PixmapPtr)(pDst->pDrawable);
pDstPriv = GETPIXPRIV(pDstPixmap);
rdpup_check_dirty(pDstPixmap, pDstPriv);
if (PIXMAN_FORMAT_A(pDst->format) > 0)
{
if (dst_alpha_needed(op))
{
rdpup_check_alpha_dirty(pDstPixmap, pDstPriv);
}
}
if (pMask != 0)
{
ValidatePicture(pMask);
pMskPixmap = (PixmapPtr)(pMask->pDrawable);
pMskPriv = GETPIXPRIV(pMskPixmap);
rdpup_check_dirty(pMskPixmap, pMskPriv);
if (PIXMAN_FORMAT_A(msk.format) > 0)
{
rdpup_check_alpha_dirty(pMskPixmap, pMskPriv);
}
}
p = pDst->pDrawable;
rdpup_switch_os_surface(pDstPriv->rdpindex);
if (pDst->pCompositeClip != 0)
{
box.x1 = xDst;
box.y1 = yDst;
box.x2 = box.x1 + width;
box.y2 = box.y1 + height;
RegionInit(&reg1, &box, 0);
RegionInit(&reg2, NullBox, 0);
RegionCopy(&reg2, pDst->pCompositeClip);
RegionIntersect(&reg1, &reg1, &reg2);
RegionTranslate(&reg1, p->x, p->y);
num_clips = REGION_NUM_RECTS(&reg1);
if (num_clips > 0)
{
LLOGLN(10, ("num_clips %d", num_clips));
rdpup_begin_update();
for (j = num_clips - 1; j >= 0; j--)
{
box = REGION_RECTS(&reg1)[j];
rdpup_set_clip(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1);
LLOGLN(10, ("pSrc->format 0x%x 0x%x 0x%x %d %d %d %d %d %d %d %d",
pSrc->format, msk.format, pDst->format, xSrc, ySrc,
xMask, yMask, xDst, yDst, width, height));
rdpup_composite(pSrcPriv->rdpindex, pSrc->format,
pSrc->pDrawable->width, pSrc->repeatType,
pSrc->transform, msk.flags, msk.idx, msk.format,
msk.width, msk.repeat, op, xSrc, ySrc,
xMask, yMask, xDst, yDst, width, height, pDst->format);
}
rdpup_reset_clip();
rdpup_end_update();
}
RegionUninit(&reg1);
RegionUninit(&reg2);
}
else
{
rdpup_begin_update();
rdpup_composite(pSrcPriv->rdpindex, pSrc->format,
pSrc->pDrawable->width, pSrc->repeatType,
pSrc->transform, msk.flags, msk.idx, msk.format,
msk.width, msk.repeat, op, xSrc, ySrc,
xMask, yMask, xDst, yDst, width, height, pDst->format);
rdpup_end_update();
}
rdpup_switch_os_surface(-1);
return 0;
}
/******************************************************************************/
static void
rdpCompositeOrg(CARD8 op, PicturePtr pSrc, PicturePtr pMask, PicturePtr pDst,
INT16 xSrc, INT16 ySrc, INT16 xMask, INT16 yMask, INT16 xDst,
INT16 yDst, CARD16 width, CARD16 height)
{
PictureScreenPtr ps;
ps = GetPictureScreen(g_pScreen);
ps->Composite = g_rdpScreen.Composite;
ps->Composite(op, pSrc, pMask, pDst, xSrc, ySrc,
xMask, yMask, xDst, yDst, width, height);
ps->Composite = rdpComposite;
}
/******************************************************************************/
/* it looks like all the antialias draws go through here
op is one of the following
#define PictOpMinimum 0
#define PictOpClear 0
#define PictOpSrc 1
#define PictOpDst 2
#define PictOpOver 3
#define PictOpOverReverse 4
#define PictOpIn 5
#define PictOpInReverse 6
#define PictOpOut 7
#define PictOpOutReverse 8
#define PictOpAtop 9
#define PictOpAtopReverse 10
#define PictOpXor 11
#define PictOpAdd 12
#define PictOpSaturate 13
#define PictOpMaximum 13
see for porter duff
http://www.svgopen.org/2005/papers/abstractsvgopen/
*/
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)
{
BoxRec box;
RegionRec reg1;
RegionRec reg2;
DrawablePtr p;
int dirty_type;
int j;
int num_clips;
int post_process;
int reset_surface;
int got_id;
WindowPtr pDstWnd;
PixmapPtr pDstPixmap;
rdpPixmapRec* pDstPriv;
rdpPixmapRec* pDirtyPriv;
struct image_data id;
LLOGLN(10, ("rdpComposite:"));
if (g_doing_font == 2)
{
rdpCompositeOrg(op, pSrc, pMask, pDst, xSrc, ySrc,
xMask, yMask, xDst, yDst, width, height);
return;
}
#if 0
if (g_do_glyph_cache && g_do_alpha_glyphs)
{
if (pSrc->pDrawable->width == 1 &&
pSrc->pDrawable->height == 1)
{
if (pMask != 0)
{
/* TODO: here we can try to send it as a glyph */
}
}
}
#endif
/* try to remote the composite call */
if (g_do_composite &&
rdpRemoteComposite(op, pSrc, pMask, pDst, xSrc, ySrc, xMask, yMask,
xDst, yDst, width, height) == 0)
{
rdpCompositeOrg(op, pSrc, pMask, pDst, xSrc, ySrc,
xMask, yMask, xDst, yDst, width, height);
return;
}
rdpCompositeOrg(op, pSrc, pMask, pDst, xSrc, ySrc,
xMask, yMask, xDst, yDst, width, height);
LLOGLN(10, ("rdpComposite: op %d %p %p %p w %d h %d", op, pSrc, pMask, pDst, width, height));
p = pDst->pDrawable;
pDstPriv = 0;
dirty_type = 0;
pDirtyPriv = 0;
post_process = 0;
reset_surface = 0;
got_id = 0;
if (p->type == DRAWABLE_PIXMAP)
{
pDstPixmap = (PixmapPtr)p;
pDstPriv = GETPIXPRIV(pDstPixmap);
if (XRDP_IS_OS(pDstPriv))
{
post_process = 1;
if (g_do_dirty_os)
{
LLOGLN(10, ("rdpComposite: getting dirty"));
pDstPriv->is_dirty = 1;
dirty_type = g_doing_font ? RDI_IMGLL : RDI_IMGLY;
pDirtyPriv = pDstPriv;
}
else
{
rdpup_switch_os_surface(pDstPriv->rdpindex);
reset_surface = 1;
rdpup_get_pixmap_image_rect(pDstPixmap, &id);
got_id = 1;
LLOGLN(10, ("rdpComposite: offscreen"));
}
}
}
else
{
if (p->type == DRAWABLE_WINDOW)
{
pDstWnd = (WindowPtr)p;
if (pDstWnd->viewable)
{
post_process = 1;
if (g_do_dirty_ons)
{
LLOGLN(10, ("rdpComposite: getting dirty"));
g_screenPriv.is_dirty = 1;
pDirtyPriv = &g_screenPriv;
dirty_type = g_doing_font ? RDI_IMGLL : RDI_IMGLY;
}
else
{
rdpup_get_screen_image_rect(&id);
got_id = 1;
}
}
}
}
if (!post_process)
{
return;
}
if (pDst->pCompositeClip != 0)
{
box.x1 = p->x + xDst;
box.y1 = p->y + yDst;
box.x2 = box.x1 + width;
box.y2 = box.y1 + height;
RegionInit(&reg1, &box, 0);
RegionInit(&reg2, NullBox, 0);
RegionCopy(&reg2, pDst->pCompositeClip);
RegionIntersect(&reg1, &reg1, &reg2);
if (dirty_type != 0)
{
draw_item_add_img_region(pDirtyPriv, &reg1, GXcopy, dirty_type, TAG_COMPOSITE);
}
else if (got_id)
{
num_clips = REGION_NUM_RECTS(&reg1);
if (num_clips > 0)
{
rdpup_begin_update();
for (j = num_clips - 1; j >= 0; j--)
{
box = REGION_RECTS(&reg1)[j];
rdpup_send_area(&id, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1);
}
rdpup_end_update();
}
}
RegionUninit(&reg1);
RegionUninit(&reg2);
}
else
{
box.x1 = p->x + xDst;
box.y1 = p->y + yDst;
box.x2 = box.x1 + width;
box.y2 = box.y1 + height;
if (dirty_type != 0)
{
RegionInit(&reg1, &box, 0);
draw_item_add_img_region(pDirtyPriv, &reg1, GXcopy, dirty_type, TAG_COMPOSITE);
RegionUninit(&reg1);
}
else if (got_id)
{
rdpup_begin_update();
rdpup_send_area(&id, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1);
rdpup_end_update();
}
}
if (reset_surface)
{
rdpup_switch_os_surface(-1);
}
}

@ -1,630 +0,0 @@
/*
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 LLOG(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; } } while (0)
#define LLOGLN(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0)
extern rdpScreenInfoRec g_rdpScreen; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpGCIndex; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpWindowIndex; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpPixmapIndex; /* from rdpmain.c */
extern int g_Bpp; /* from rdpmain.c */
extern ScreenPtr g_pScreen; /* from rdpmain.c */
extern Bool g_wrapPixmap; /* from rdpmain.c */
extern int g_can_do_pix_to_pix; /* from rdpmain.c */
extern int g_do_dirty_os; /* in rdpmain.c */
extern int g_do_dirty_ons; /* in rdpmain.c */
extern rdpPixmapRec g_screenPriv; /* in rdpmain.c */
extern GCOps g_rdpGCOps; /* from rdpdraw.c */
extern int g_con_number; /* in rdpup.c */
/******************************************************************************/
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;
}
/******************************************************************************/
static RegionPtr
rdpCopyAreaWndToWnd(WindowPtr pSrcWnd, WindowPtr pDstWnd, GCPtr pGC,
int srcx, int srcy, int w, int h,
int dstx, int dsty)
{
int cd;
int lsrcx;
int lsrcy;
int ldstx;
int ldsty;
int num_clips;
int dx;
int dy;
int j;
BoxRec box;
RegionPtr rv;
RegionRec clip_reg;
LLOGLN(10, ("rdpCopyAreaWndToWnd:"));
RegionInit(&clip_reg, NullBox, 0);
cd = rdp_get_clip(&clip_reg, &(pDstWnd->drawable), pGC);
lsrcx = pSrcWnd->drawable.x + srcx;
lsrcy = pSrcWnd->drawable.y + srcy;
ldstx = pDstWnd->drawable.x + dstx;
ldsty = pDstWnd->drawable.y + dsty;
if (cd == 1)
{
rdpup_begin_update();
rdpup_screen_blt(ldstx, ldsty, w, h, lsrcx, lsrcy);
rdpup_end_update();
}
else if (cd == 2)
{
num_clips = REGION_NUM_RECTS(&clip_reg);
if (num_clips > 0)
{
rdpup_begin_update();
dx = ldstx - lsrcx;
dy = ldsty - lsrcy;
if ((dy < 0) || ((dy == 0) && (dx < 0)))
{
for (j = 0; j < num_clips; j++)
{
box = REGION_RECTS(&clip_reg)[j];
LLOGLN(10, (" index %d x1 %d y1 %d x2 %d y2 %d", j,
box.x1, box.y1, box.x2, box.y2));
rdpup_set_clip(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1);
rdpup_screen_blt(ldstx, ldsty, w, h, lsrcx, lsrcy);
}
}
else
{
for (j = num_clips - 1; j >= 0; j--)
{
box = REGION_RECTS(&clip_reg)[j];
LLOGLN(10, (" index %d x1 %d y1 %d x2 %d y2 %d", j,
box.x1, box.y1, box.x2, box.y2));
rdpup_set_clip(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1);
rdpup_screen_blt(ldstx, ldsty, w, h, lsrcx, lsrcy);
}
}
rdpup_reset_clip();
rdpup_end_update();
}
}
RegionUninit(&clip_reg);
rv = rdpCopyAreaOrg(&(pSrcWnd->drawable), &(pDstWnd->drawable),
pGC, srcx, srcy, w, h, dstx, dsty);
return rv;
}
/******************************************************************************/
static RegionPtr
rdpCopyAreaWndToPixmap(WindowPtr pSrcWnd,
PixmapPtr pDstPixmap, rdpPixmapRec *pDstPriv,
GCPtr pGC, int srcx, int srcy, int w, int h,
int dstx, int dsty)
{
int cd;
int lsrcx;
int lsrcy;
int ldstx;
int ldsty;
int num_clips;
int j;
BoxRec box;
RegionPtr rv;
RegionRec clip_reg;
LLOGLN(10, ("rdpCopyAreaWndToPixmap:"));
RegionInit(&clip_reg, NullBox, 0);
cd = rdp_get_clip(&clip_reg, &(pDstPixmap->drawable), pGC);
lsrcx = pSrcWnd->drawable.x + srcx;
lsrcy = pSrcWnd->drawable.y + srcy;
ldstx = pDstPixmap->drawable.x + dstx;
ldsty = pDstPixmap->drawable.y + dsty;
if (cd == 1)
{
rdpup_switch_os_surface(pDstPriv->rdpindex);
rdpup_begin_update();
rdpup_screen_blt(ldstx, ldsty, w, h, lsrcx, lsrcy);
rdpup_end_update();
rdpup_switch_os_surface(-1);
}
else if (cd == 2)
{
num_clips = REGION_NUM_RECTS(&clip_reg);
if (num_clips > 0)
{
rdpup_switch_os_surface(pDstPriv->rdpindex);
rdpup_begin_update();
for (j = 0; j < num_clips; j++)
{
box = REGION_RECTS(&clip_reg)[j];
rdpup_set_clip(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1);
rdpup_screen_blt(ldstx, ldsty, w, h, lsrcx, lsrcy);
}
rdpup_reset_clip();
rdpup_end_update();
rdpup_switch_os_surface(-1);
}
}
RegionUninit(&clip_reg);
rv = rdpCopyAreaOrg(&(pSrcWnd->drawable), &(pDstPixmap->drawable),
pGC, srcx, srcy, w, h, dstx, dsty);
return rv;
}
/******************************************************************************/
/* draw from an off screen pixmap to a visible window */
static RegionPtr
rdpCopyAreaPixmapToWnd(PixmapPtr pSrcPixmap, rdpPixmapRec *pSrcPriv,
WindowPtr pDstWnd, GCPtr pGC,
int srcx, int srcy, int w, int h,
int dstx, int dsty)
{
int lsrcx;
int lsrcy;
int ldstx;
int ldsty;
int cd;
int j;
int num_clips;
RegionPtr rv;
RegionRec clip_reg;
BoxRec box;
LLOGLN(10, ("rdpCopyAreaPixmapToWnd:"));
RegionInit(&clip_reg, NullBox, 0);
cd = rdp_get_clip(&clip_reg, &(pDstWnd->drawable), pGC);
ldstx = pDstWnd->drawable.x + dstx;
ldsty = pDstWnd->drawable.y + dsty;
lsrcx = pSrcPixmap->drawable.x + srcx;
lsrcy = pSrcPixmap->drawable.y + srcy;
if (cd == 1)
{
rdpup_begin_update();
rdpup_paint_rect_os(ldstx, ldsty, w, h, pSrcPriv->rdpindex, lsrcx, lsrcy);
rdpup_end_update();
}
else if (cd == 2)
{
num_clips = REGION_NUM_RECTS(&clip_reg);
if (num_clips > 0)
{
rdpup_begin_update();
LLOGLN(10, ("rdpCopyAreaPixmapToWnd: num_clips %d", num_clips));
for (j = 0; j < num_clips; j++)
{
box = REGION_RECTS(&clip_reg)[j];
LLOGLN(10, ("rdpCopyAreaPixmapToWnd: %d %d %d %d", box.x1, box.y1, box.x2, box.y2));
rdpup_set_clip(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1);
LLOGLN(10, ("rdpCopyAreaPixmapToWnd: %d %d", w, h));
rdpup_paint_rect_os(ldstx, ldsty, w, h, pSrcPriv->rdpindex, lsrcx, lsrcy);
}
rdpup_reset_clip();
rdpup_end_update();
}
}
RegionUninit(&clip_reg);
rv = rdpCopyAreaOrg(&(pSrcPixmap->drawable), &(pDstWnd->drawable),
pGC, srcx, srcy, w, h, dstx, dsty);
return rv;
}
/******************************************************************************/
/* draw from an off screen pixmap to an off screen pixmap */
static RegionPtr
rdpCopyAreaPixmapToPixmap(PixmapPtr pSrcPixmap, rdpPixmapRec *pSrcPriv,
PixmapPtr pDstPixmap, rdpPixmapRec *pDstPriv,
GCPtr pGC, int srcx, int srcy, int w, int h,
int dstx, int dsty)
{
int lsrcx;
int lsrcy;
int ldstx;
int ldsty;
int cd;
int j;
int num_clips;
int dx;
int dy;
RegionPtr rv;
RegionRec clip_reg;
BoxRec box;
LLOGLN(10, ("rdpCopyAreaPixmapToPixmap:"));
RegionInit(&clip_reg, NullBox, 0);
cd = rdp_get_clip(&clip_reg, &(pDstPixmap->drawable), pGC);
LLOGLN(10, ("rdpCopyAreaPixmapToPixmap: cd %d", cd));
ldstx = pDstPixmap->drawable.x + dstx;
ldsty = pDstPixmap->drawable.y + dsty;
lsrcx = pSrcPixmap->drawable.x + srcx;
lsrcy = pSrcPixmap->drawable.y + srcy;
if (cd == 1)
{
rdpup_switch_os_surface(pDstPriv->rdpindex);
rdpup_begin_update();
rdpup_paint_rect_os(ldstx, ldsty, w, h, pSrcPriv->rdpindex, lsrcx, lsrcy);
LLOGLN(10, ("%d %d %d %d %d %d", ldstx, ldsty, w, h, lsrcx, lsrcy));
rdpup_end_update();
rdpup_switch_os_surface(-1);
}
else if (cd == 2)
{
num_clips = REGION_NUM_RECTS(&clip_reg);
if (num_clips > 0)
{
rdpup_switch_os_surface(pDstPriv->rdpindex);
rdpup_begin_update();
dx = ldstx - lsrcx;
dy = ldsty - lsrcy;
LLOGLN(10, ("rdpCopyAreaPixmapToPixmap: num_clips %d", num_clips));
if ((dy < 0) || ((dy == 0) && (dx < 0)))
{
for (j = 0; j < num_clips; j++)
{
box = REGION_RECTS(&clip_reg)[j];
rdpup_set_clip(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1);
rdpup_paint_rect_os(ldstx, ldsty, w, h, pSrcPriv->rdpindex, lsrcx, lsrcy);
LLOGLN(10, ("%d %d %d %d %d %d", ldstx, ldsty, w, h, lsrcx, lsrcy));
}
}
else
{
for (j = num_clips - 1; j >= 0; j--)
{
box = REGION_RECTS(&clip_reg)[j];
rdpup_set_clip(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1);
rdpup_paint_rect_os(ldstx, ldsty, w, h, pSrcPriv->rdpindex, lsrcx, lsrcy);
LLOGLN(10, ("%d %d %d %d %d %d", ldstx, ldsty, w, h, lsrcx, lsrcy));
}
}
rdpup_reset_clip();
rdpup_end_update();
rdpup_switch_os_surface(-1);
}
}
RegionUninit(&clip_reg);
rv = rdpCopyAreaOrg(&(pSrcPixmap->drawable), &(pDstPixmap->drawable),
pGC, srcx, srcy, w, h, dstx, dsty);
return rv;
}
/******************************************************************************/
RegionPtr
rdpCopyArea(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
int srcx, int srcy, int w, int h, int dstx, int dsty)
{
RegionPtr rv;
RegionRec clip_reg;
RegionRec box_reg;
RegionRec reg1;
int num_clips;
int cd;
int j;
int can_do_screen_blt;
int got_id;
int dirty_type;
int post_process;
int reset_surface;
struct image_data id;
BoxRec box;
BoxPtr pbox;
PixmapPtr pSrcPixmap;
PixmapPtr pDstPixmap;
rdpPixmapRec *pSrcPriv;
rdpPixmapRec *pDstPriv;
rdpPixmapRec *pDirtyPriv;
WindowPtr pDstWnd;
WindowPtr pSrcWnd;
LLOGLN(10, ("rdpCopyArea: x %d y %d w %d h %d", dstx, dsty, w, h));
if (pSrc->type == DRAWABLE_WINDOW)
{
pSrcWnd = (WindowPtr)pSrc;
if (pSrcWnd->viewable)
{
rdpup_check_dirty_screen(&g_screenPriv);
if (pDst->type == DRAWABLE_WINDOW)
{
pDstWnd = (WindowPtr)pDst;
if (pDstWnd->viewable)
{
can_do_screen_blt = pGC->alu == GXcopy;
if (can_do_screen_blt)
{
return rdpCopyAreaWndToWnd(pSrcWnd, pDstWnd, pGC,
srcx, srcy, w, h, dstx, dsty);
}
}
}
else if (pDst->type == DRAWABLE_PIXMAP)
{
pDstPixmap = (PixmapPtr)pDst;
pDstPriv = GETPIXPRIV(pDstPixmap);
if (xrdp_is_os(pDstPixmap, pDstPriv))
{
can_do_screen_blt = pGC->alu == GXcopy;
if (can_do_screen_blt)
{
rdpup_check_dirty(pDstPixmap, pDstPriv);
return rdpCopyAreaWndToPixmap(pSrcWnd, pDstPixmap, pDstPriv, pGC,
srcx, srcy, w, h, dstx, dsty);
}
}
else
{
LLOGLN(10, ("rdpCopyArea: 1"));
}
}
}
}
if (pSrc->type == DRAWABLE_PIXMAP)
{
pSrcPixmap = (PixmapPtr)pSrc;
pSrcPriv = GETPIXPRIV(pSrcPixmap);
LLOGLN(10, ("rdpCopyArea: 3 %d %d", pSrcPixmap->usage_hint, pSrcPriv->is_scratch));
if (xrdp_is_os(pSrcPixmap, pSrcPriv))
{
if (pDst->type == DRAWABLE_WINDOW)
{
pDstWnd = (WindowPtr)pDst;
if (pDstWnd->viewable)
{
rdpup_check_dirty_screen(&g_screenPriv);
rdpup_check_dirty(pSrcPixmap, pSrcPriv);
return rdpCopyAreaPixmapToWnd(pSrcPixmap, pSrcPriv, pDstWnd, pGC,
srcx, srcy, w, h, dstx, dsty);
}
}
else if (pDst->type == DRAWABLE_PIXMAP)
{
pDstPixmap = (PixmapPtr)pDst;
pDstPriv = GETPIXPRIV(pDstPixmap);
if (xrdp_is_os(pDstPixmap, pDstPriv))
{
if (g_can_do_pix_to_pix)
{
rdpup_check_dirty(pSrcPixmap, pSrcPriv);
rdpup_check_dirty(pDstPixmap, pDstPriv);
return rdpCopyAreaPixmapToPixmap(pSrcPixmap, pSrcPriv,
pDstPixmap, pDstPriv,
pGC, srcx, srcy, w, h,
dstx, dsty);
}
}
else
{
LLOGLN(10, ("rdpCopyArea: 4"));
}
}
}
else
{
LLOGLN(10, ("rdpCopyArea: 2 %d %d", pSrcPixmap->usage_hint, pSrcPriv->is_scratch));
}
}
LLOGLN(10, ("rdpCopyArea: fallback"));
/* do original call */
rv = rdpCopyAreaOrg(pSrc, pDst, pGC, srcx, srcy, w, h, dstx, dsty);
dirty_type = 0;
pDirtyPriv = 0;
post_process = 0;
reset_surface = 0;
got_id = 0;
if (pDst->type == DRAWABLE_PIXMAP)
{
pDstPixmap = (PixmapPtr)pDst;
pDstPriv = GETPIXPRIV(pDstPixmap);
if (xrdp_is_os(pDstPixmap, pDstPriv))
{
post_process = 1;
if (g_do_dirty_os)
{
LLOGLN(10, ("rdpCopyArea: getting dirty"));
pDstPriv->is_dirty = 1;
pDirtyPriv = pDstPriv;
dirty_type = RDI_IMGLY;
}
else
{
rdpup_switch_os_surface(pDstPriv->rdpindex);
reset_surface = 1;
rdpup_get_pixmap_image_rect(pDstPixmap, &id);
got_id = 1;
}
}
else
{
LLOGLN(10, ("rdpCopyArea: 3"));
}
}
else
{
if (pDst->type == DRAWABLE_WINDOW)
{
pDstWnd = (WindowPtr)pDst;
if (pDstWnd->viewable)
{
post_process = 1;
if (g_do_dirty_ons)
{
LLOGLN(10, ("rdpCopyArea: getting dirty"));
g_screenPriv.is_dirty = 1;
pDirtyPriv = &g_screenPriv;
dirty_type = RDI_IMGLY;
}
else
{
rdpup_get_screen_image_rect(&id);
got_id = 1;
}
}
}
}
if (!post_process)
{
return rv;
}
LLOGLN(10, ("rdpCopyArea: post_process"));
RegionInit(&clip_reg, NullBox, 0);
cd = rdp_get_clip(&clip_reg, pDst, pGC);
if (cd == 1)
{
if (dirty_type != 0)
{
box.x1 = pDst->x + dstx;
box.y1 = pDst->y + dsty;
box.x2 = box.x1 + w;
box.y2 = box.y1 + h;
RegionInit(&reg1, &box, 0);
draw_item_add_img_region(pDirtyPriv, &reg1, GXcopy, dirty_type, TAG_COPYAREA);
RegionUninit(&reg1);
}
else if (got_id)
{
rdpup_begin_update();
rdpup_send_area(&id, pDst->x + dstx, pDst->y + dsty, w, h);
rdpup_end_update();
}
}
else if (cd == 2)
{
num_clips = REGION_NUM_RECTS(&clip_reg);
if (num_clips > 0)
{
if (dirty_type != 0)
{
box.x1 = pDst->x + dstx;
box.y1 = pDst->y + dsty;
box.x2 = box.x1 + w;
box.y2 = box.y1 + h;
RegionInit(&box_reg, &box, 0);
RegionIntersect(&clip_reg, &clip_reg, &box_reg);
draw_item_add_img_region(pDirtyPriv, &clip_reg, GXcopy, dirty_type, TAG_COPYAREA);
RegionUninit(&box_reg);
}
else if (got_id)
{
rdpup_begin_update();
box.x1 = pDst->x + dstx;
box.y1 = pDst->y + dsty;
box.x2 = box.x1 + w;
box.y2 = box.y1 + h;
RegionInit(&box_reg, &box, 0);
RegionIntersect(&clip_reg, &clip_reg, &box_reg);
num_clips = REGION_NUM_RECTS(&clip_reg);
if (num_clips < 10)
{
for (j = num_clips - 1; j >= 0; j--)
{
box = REGION_RECTS(&clip_reg)[j];
rdpup_send_area(&id, box.x1, box.y1, box.x2 - box.x1,
box.y2 - box.y1);
}
}
else
{
pbox = RegionExtents(&clip_reg);
rdpup_send_area(&id, pbox->x1, pbox->y1, pbox->x2 - pbox->x1,
pbox->y2 - pbox->y1);
}
RegionUninit(&box_reg);
rdpup_end_update();
}
}
}
RegionUninit(&clip_reg);
if (reset_surface)
{
rdpup_switch_os_surface(-1);
}
return rv;
}

@ -1,29 +0,0 @@
/*
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

@ -1,241 +0,0 @@
/*
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 LLOG(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; } } while (0)
#define LLOGLN(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0)
extern rdpScreenInfoRec g_rdpScreen; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpGCIndex; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpWindowIndex; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpPixmapIndex; /* from rdpmain.c */
extern int g_Bpp; /* from rdpmain.c */
extern ScreenPtr g_pScreen; /* from rdpmain.c */
extern Bool g_wrapPixmap; /* from rdpmain.c */
extern int g_do_dirty_os; /* in rdpmain.c */
extern int g_do_dirty_ons; /* in rdpmain.c */
extern rdpPixmapRec g_screenPriv; /* in rdpmain.c */
extern GCOps g_rdpGCOps; /* from rdpdraw.c */
extern int g_con_number; /* in rdpup.c */
/******************************************************************************/
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;
RegionRec clip_reg;
RegionRec box_reg;
RegionRec reg1;
RegionRec reg2;
int cd;
int num_clips;
int j;
int got_id;
int dirty_type;
int post_process;
int reset_surface;
BoxRec box;
BoxPtr pbox;
struct image_data id;
WindowPtr pDstWnd;
PixmapPtr pDstPixmap;
rdpPixmapRec *pDstPriv;
rdpPixmapRec *pDirtyPriv;
LLOGLN(10, ("rdpCopyPlane:"));
/* do original call */
rv = rdpCopyPlaneOrg(pSrc, pDst, pGC, srcx, srcy, w, h,
dstx, dsty, bitPlane);
dirty_type = 0;
pDirtyPriv = 0;
post_process = 0;
reset_surface = 0;
got_id = 0;
if (pDst->type == DRAWABLE_PIXMAP)
{
pDstPixmap = (PixmapPtr)pDst;
pDstPriv = GETPIXPRIV(pDstPixmap);
if (xrdp_is_os(pDstPixmap, pDstPriv))
{
post_process = 1;
if (g_do_dirty_os)
{
LLOGLN(10, ("rdpCopyPlane: getting dirty"));
pDstPriv->is_dirty = 1;
pDirtyPriv = pDstPriv;
dirty_type = RDI_IMGLL;
}
else
{
rdpup_switch_os_surface(pDstPriv->rdpindex);
reset_surface = 1;
rdpup_get_pixmap_image_rect(pDstPixmap, &id);
got_id = 1;
}
}
}
else
{
if (pDst->type == DRAWABLE_WINDOW)
{
pDstWnd = (WindowPtr)pDst;
if (pDstWnd->viewable)
{
post_process = 1;
if (g_do_dirty_ons)
{
LLOGLN(10, ("rdpCopyPlane: getting dirty"));
g_screenPriv.is_dirty = 1;
pDirtyPriv = &g_screenPriv;
dirty_type = RDI_IMGLL;
}
else
{
rdpup_get_screen_image_rect(&id);
got_id = 1;
}
}
}
}
if (!post_process)
{
return rv;
}
RegionInit(&clip_reg, NullBox, 0);
cd = rdp_get_clip(&clip_reg, pDst, pGC);
if (cd == 1)
{
if (dirty_type != 0)
{
box.x1 = pDst->x + dstx;
box.y1 = pDst->y + dsty;
box.x2 = box.x1 + w;
box.y2 = box.y1 + h;
RegionInit(&reg1, &box, 0);
draw_item_add_img_region(pDirtyPriv, &reg1, GXcopy, dirty_type, TAG_COPYPLANE);
RegionUninit(&reg1);
}
else if (got_id)
{
rdpup_begin_update();
rdpup_send_area(&id, pDst->x + dstx, pDst->y + dsty, w, h);
rdpup_end_update();
}
}
else if (cd == 2)
{
num_clips = REGION_NUM_RECTS(&clip_reg);
if (num_clips > 0)
{
if (dirty_type != 0)
{
box.x1 = pDst->x + dstx;
box.y1 = pDst->y + dsty;
box.x2 = box.x1 + w;
box.y2 = box.y1 + h;
RegionInit(&reg1, &box, 0);
RegionInit(&reg2, NullBox, 0);
RegionCopy(&reg2, &clip_reg);
RegionIntersect(&reg1, &reg1, &reg2);
draw_item_add_img_region(pDirtyPriv, &reg1, GXcopy, dirty_type, TAG_COPYPLANE);
RegionUninit(&reg1);
RegionUninit(&reg2);
}
else if (got_id)
{
rdpup_begin_update();
box.x1 = pDst->x + dstx;
box.y1 = pDst->y + dsty;
box.x2 = box.x1 + w;
box.y2 = box.y1 + h;
RegionInit(&box_reg, &box, 0);
RegionIntersect(&clip_reg, &clip_reg, &box_reg);
num_clips = REGION_NUM_RECTS(&clip_reg);
if (num_clips < 10)
{
for (j = num_clips - 1; j >= 0; j--)
{
box = REGION_RECTS(&clip_reg)[j];
rdpup_send_area(&id, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1);
}
}
else
{
pbox = RegionExtents(&clip_reg);
rdpup_send_area(&id, pbox->x1, pbox->y1, pbox->x2 - pbox->x1,
pbox->y2 - pbox->y1);
}
RegionUninit(&box_reg);
rdpup_end_update();
}
}
}
RegionUninit(&clip_reg);
if (reset_surface)
{
rdpup_switch_os_surface(-1);
}
return rv;
}

@ -1,30 +0,0 @@
/*
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

@ -1,251 +0,0 @@
/*
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 LLOG(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; } } while (0)
#define LLOGLN(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0)
extern rdpScreenInfoRec g_rdpScreen; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpGCIndex; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpWindowIndex; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpPixmapIndex; /* from rdpmain.c */
extern int g_Bpp; /* from rdpmain.c */
extern ScreenPtr g_pScreen; /* from rdpmain.c */
extern Bool g_wrapPixmap; /* from rdpmain.c */
extern int g_do_dirty_os; /* in rdpmain.c */
extern int g_do_dirty_ons; /* in rdpmain.c */
extern rdpPixmapRec g_screenPriv; /* in rdpmain.c */
extern GCOps g_rdpGCOps; /* from rdpdraw.c */
extern int g_con_number; /* in rdpup.c */
/******************************************************************************/
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)
{
RegionRec clip_reg;
RegionRec box_reg;
RegionRec reg1;
int num_clips;
int cd;
int maxx;
int maxy;
int minx;
int miny;
int i;
int j;
int got_id;
int dirty_type;
int post_process;
int reset_surface;
BoxRec box;
struct image_data id;
WindowPtr pDstWnd;
PixmapPtr pDstPixmap;
rdpPixmapRec *pDstPriv;
rdpPixmapRec *pDirtyPriv;
LLOGLN(10, ("rdpFillPolygon:"));
box.x1 = 0;
box.y1 = 0;
box.x2 = 0;
box.y2 = 0;
if (count > 0)
{
maxx = pPts[0].x;
maxy = pPts[0].y;
minx = maxx;
miny = maxy;
for (i = 1; i < count; i++)
{
if (pPts[i].x > maxx)
{
maxx = pPts[i].x;
}
if (pPts[i].x < minx)
{
minx = pPts[i].x;
}
if (pPts[i].y > maxy)
{
maxy = pPts[i].y;
}
if (pPts[i].y < miny)
{
miny = pPts[i].y;
}
}
box.x1 = pDrawable->x + minx;
box.y1 = pDrawable->y + miny;
box.x2 = pDrawable->x + maxx + 1;
box.y2 = pDrawable->y + maxy + 1;
}
/* do original call */
rdpFillPolygonOrg(pDrawable, pGC, shape, mode, count, pPts);
dirty_type = 0;
pDirtyPriv = 0;
post_process = 0;
reset_surface = 0;
got_id = 0;
if (pDrawable->type == DRAWABLE_PIXMAP)
{
pDstPixmap = (PixmapPtr)pDrawable;
pDstPriv = GETPIXPRIV(pDstPixmap);
if (xrdp_is_os(pDstPixmap, pDstPriv))
{
post_process = 1;
if (g_do_dirty_os)
{
LLOGLN(10, ("rdpFillPolygon: getting dirty"));
pDstPriv->is_dirty = 1;
pDirtyPriv = pDstPriv;
dirty_type = RDI_IMGLL;
}
else
{
rdpup_switch_os_surface(pDstPriv->rdpindex);
reset_surface = 1;
rdpup_get_pixmap_image_rect(pDstPixmap, &id);
got_id = 1;
}
}
}
else
{
if (pDrawable->type == DRAWABLE_WINDOW)
{
pDstWnd = (WindowPtr)pDrawable;
if (pDstWnd->viewable)
{
post_process = 1;
if (g_do_dirty_ons)
{
LLOGLN(10, ("rdpFillPolygon: getting dirty"));
g_screenPriv.is_dirty = 1;
pDirtyPriv = &g_screenPriv;
dirty_type = RDI_IMGLL;
}
else
{
rdpup_get_screen_image_rect(&id);
got_id = 1;
}
}
}
}
if (!post_process)
{
return;
}
RegionInit(&clip_reg, NullBox, 0);
cd = rdp_get_clip(&clip_reg, pDrawable, pGC);
if (cd == 1)
{
if (dirty_type != 0)
{
RegionInit(&reg1, &box, 0);
draw_item_add_img_region(pDirtyPriv, &reg1, GXcopy, dirty_type, TAG_FILLPOLYGON);
RegionUninit(&reg1);
}
else if (got_id)
{
rdpup_begin_update();
rdpup_send_area(&id, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1);
rdpup_end_update();
}
}
else if (cd == 2)
{
RegionInit(&box_reg, &box, 0);
RegionIntersect(&clip_reg, &clip_reg, &box_reg);
num_clips = REGION_NUM_RECTS(&clip_reg);
if (num_clips > 0)
{
if (dirty_type != 0)
{
draw_item_add_img_region(pDirtyPriv, &clip_reg, GXcopy, dirty_type, TAG_FILLPOLYGON);
}
else if (got_id)
{
rdpup_begin_update();
for (j = num_clips - 1; j >= 0; j--)
{
box = REGION_RECTS(&clip_reg)[j];
rdpup_send_area(&id, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1);
}
rdpup_end_update();
}
}
RegionUninit(&box_reg);
}
RegionUninit(&clip_reg);
if (reset_surface)
{
rdpup_switch_os_surface(-1);
}
}

@ -1,30 +0,0 @@
/*
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

@ -1,121 +0,0 @@
/*
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 LLOG(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; } } while (0)
#define LLOGLN(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0)
extern rdpScreenInfoRec g_rdpScreen; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpGCIndex; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpWindowIndex; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpPixmapIndex; /* from rdpmain.c */
extern int g_Bpp; /* from rdpmain.c */
extern ScreenPtr g_pScreen; /* from rdpmain.c */
extern Bool g_wrapPixmap; /* from rdpmain.c */
extern GCOps g_rdpGCOps; /* from rdpdraw.c */
extern int g_con_number; /* in rdpup.c */
/******************************************************************************/
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)
{
RegionRec clip_reg;
int cd;
int got_id;
struct image_data id;
WindowPtr pDstWnd;
PixmapPtr pDstPixmap;
rdpPixmapRec *pDstPriv;
LLOGLN(0, ("rdpFillSpans: todo"));
/* do original call */
rdpFillSpansOrg(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted);
got_id = 0;
if (pDrawable->type == DRAWABLE_PIXMAP)
{
pDstPixmap = (PixmapPtr)pDrawable;
pDstPriv = GETPIXPRIV(pDstPixmap);
if (xrdp_is_os(pDstPixmap, pDstPriv))
{
rdpup_switch_os_surface(pDstPriv->rdpindex);
rdpup_get_pixmap_image_rect(pDstPixmap, &id);
got_id = 1;
}
}
else
{
if (pDrawable->type == DRAWABLE_WINDOW)
{
pDstWnd = (WindowPtr)pDrawable;
if (pDstWnd->viewable)
{
rdpup_get_screen_image_rect(&id);
got_id = 1;
}
}
}
if (!got_id)
{
return;
}
RegionInit(&clip_reg, NullBox, 0);
cd = rdp_get_clip(&clip_reg, pDrawable, pGC);
if (cd == 1)
{
}
else if (cd == 2)
{
}
RegionUninit(&clip_reg);
rdpup_switch_os_surface(-1);
}

@ -1,29 +0,0 @@
/*
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

@ -1,219 +0,0 @@
/*
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 LLOG(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; } } while (0)
#define LLOGLN(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0)
extern rdpScreenInfoRec g_rdpScreen; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpGCIndex; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpWindowIndex; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpPixmapIndex; /* from rdpmain.c */
extern int g_Bpp; /* from rdpmain.c */
extern ScreenPtr g_pScreen; /* from rdpmain.c */
extern Bool g_wrapPixmap; /* from rdpmain.c */
extern int g_do_dirty_os; /* in rdpmain.c */
extern int g_do_dirty_ons; /* in rdpmain.c */
extern rdpPixmapRec g_screenPriv; /* in rdpmain.c */
extern GCOps g_rdpGCOps; /* from rdpdraw.c */
extern int g_con_number; /* in rdpup.c */
/******************************************************************************/
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)
{
RegionRec reg;
RegionRec reg1;
int num_clips;
int cd;
int j;
int got_id;
int dirty_type;
int post_process;
int reset_surface;
BoxRec box;
struct image_data id;
WindowPtr pDstWnd;
PixmapPtr pDstPixmap;
rdpPixmapRec *pDstPriv;
rdpPixmapRec *pDirtyPriv;
LLOGLN(10, ("rdpImageGlyphBlt:"));
if (nglyph != 0)
{
GetTextBoundingBox(pDrawable, pGC->font, x, y, nglyph, &box);
}
/* do original call */
rdpImageGlyphBltOrg(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
dirty_type = 0;
pDirtyPriv = 0;
post_process = 0;
reset_surface = 0;
got_id = 0;
if (pDrawable->type == DRAWABLE_PIXMAP)
{
pDstPixmap = (PixmapPtr)pDrawable;
pDstPriv = GETPIXPRIV(pDstPixmap);
if (xrdp_is_os(pDstPixmap, pDstPriv))
{
post_process = 1;
if (g_do_dirty_os)
{
LLOGLN(10, ("rdpImageGlyphBlt: getting dirty"));
pDstPriv->is_dirty = 1;
pDirtyPriv = pDstPriv;
dirty_type = RDI_IMGLL;
}
else
{
rdpup_switch_os_surface(pDstPriv->rdpindex);
reset_surface = 1;
rdpup_get_pixmap_image_rect(pDstPixmap, &id);
got_id = 1;
}
}
}
else
{
if (pDrawable->type == DRAWABLE_WINDOW)
{
pDstWnd = (WindowPtr)pDrawable;
if (pDstWnd->viewable)
{
post_process = 1;
if (g_do_dirty_ons)
{
LLOGLN(10, ("rdpImageGlyphBlt: getting dirty"));
g_screenPriv.is_dirty = 1;
pDirtyPriv = &g_screenPriv;
dirty_type = RDI_IMGLL;
}
else
{
rdpup_get_screen_image_rect(&id);
got_id = 1;
}
}
}
}
if (!post_process)
{
return;
}
RegionInit(&reg, NullBox, 0);
if (nglyph == 0)
{
cd = 0;
}
else
{
cd = rdp_get_clip(&reg, pDrawable, pGC);
}
if (cd == 1)
{
if (dirty_type != 0)
{
RegionInit(&reg1, &box, 0);
draw_item_add_img_region(pDirtyPriv, &reg1, GXcopy, dirty_type, TAG_IMAGEGLYPHBLT);
RegionUninit(&reg1);
}
else if (got_id)
{
rdpup_begin_update();
rdpup_send_area(&id, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1);
rdpup_end_update();
}
}
else if (cd == 2)
{
RegionInit(&reg1, &box, 0);
RegionIntersect(&reg, &reg, &reg1);
num_clips = REGION_NUM_RECTS(&reg);
if (num_clips > 0)
{
if (dirty_type != 0)
{
draw_item_add_img_region(pDirtyPriv, &reg, GXcopy, dirty_type, TAG_IMAGEGLYPHBLT);
}
else if (got_id)
{
rdpup_begin_update();
for (j = num_clips - 1; j >= 0; j--)
{
box = REGION_RECTS(&reg)[j];
rdpup_send_area(&id, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1);
}
rdpup_end_update();
}
}
RegionUninit(&reg1);
}
RegionUninit(&reg);
if (reset_surface)
{
rdpup_switch_os_surface(-1);
}
return;
}

@ -1,30 +0,0 @@
/*
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

@ -1,218 +0,0 @@
/*
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 LLOG(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; } } while (0)
#define LLOGLN(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0)
extern rdpScreenInfoRec g_rdpScreen; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpGCIndex; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpWindowIndex; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpPixmapIndex; /* from rdpmain.c */
extern int g_Bpp; /* from rdpmain.c */
extern ScreenPtr g_pScreen; /* from rdpmain.c */
extern Bool g_wrapPixmap; /* from rdpmain.c */
extern int g_do_dirty_os; /* in rdpmain.c */
extern int g_do_dirty_ons; /* in rdpmain.c */
extern rdpPixmapRec g_screenPriv; /* in rdpmain.c */
extern GCOps g_rdpGCOps; /* from rdpdraw.c */
extern int g_con_number; /* in rdpup.c */
/******************************************************************************/
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)
{
RegionRec reg;
RegionRec reg1;
int num_clips;
int cd;
int j;
int got_id;
int dirty_type;
int post_process;
int reset_surface;
BoxRec box;
struct image_data id;
WindowPtr pDstWnd;
PixmapPtr pDstPixmap;
rdpPixmapRec *pDstPriv;
rdpPixmapRec *pDirtyPriv;
LLOGLN(10, ("rdpImageText16:"));
if (count != 0)
{
GetTextBoundingBox(pDrawable, pGC->font, x, y, count, &box);
}
/* do original call */
rdpImageText16Org(pDrawable, pGC, x, y, count, chars);
dirty_type = 0;
pDirtyPriv = 0;
post_process = 0;
reset_surface = 0;
got_id = 0;
if (pDrawable->type == DRAWABLE_PIXMAP)
{
pDstPixmap = (PixmapPtr)pDrawable;
pDstPriv = GETPIXPRIV(pDstPixmap);
if (xrdp_is_os(pDstPixmap, pDstPriv))
{
post_process = 1;
if (g_do_dirty_os)
{
LLOGLN(10, ("rdpImageText16: getting dirty"));
pDstPriv->is_dirty = 1;
pDirtyPriv = pDstPriv;
dirty_type = RDI_IMGLY;
}
else
{
rdpup_switch_os_surface(pDstPriv->rdpindex);
reset_surface = 1;
rdpup_get_pixmap_image_rect(pDstPixmap, &id);
got_id = 1;
}
}
}
else
{
if (pDrawable->type == DRAWABLE_WINDOW)
{
pDstWnd = (WindowPtr)pDrawable;
if (pDstWnd->viewable)
{
post_process = 1;
if (g_do_dirty_ons)
{
LLOGLN(10, ("rdpImageText16: getting dirty"));
g_screenPriv.is_dirty = 1;
pDirtyPriv = &g_screenPriv;
dirty_type = RDI_IMGLL;
}
else
{
rdpup_get_screen_image_rect(&id);
got_id = 1;
}
}
}
}
if (!post_process)
{
return;
}
RegionInit(&reg, NullBox, 0);
if (count == 0)
{
cd = 0;
}
else
{
cd = rdp_get_clip(&reg, pDrawable, pGC);
}
if (cd == 1)
{
if (dirty_type != 0)
{
RegionInit(&reg1, &box, 0);
draw_item_add_img_region(pDirtyPriv, &reg1, GXcopy, dirty_type, TAG_IMAGETEXT16);
RegionUninit(&reg1);
}
else if (got_id)
{
rdpup_begin_update();
rdpup_send_area(&id, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1);
rdpup_end_update();
}
}
else if (cd == 2)
{
RegionInit(&reg1, &box, 0);
RegionIntersect(&reg, &reg, &reg1);
num_clips = REGION_NUM_RECTS(&reg);
if (num_clips > 0)
{
if (dirty_type != 0)
{
draw_item_add_img_region(pDirtyPriv, &reg, GXcopy, dirty_type, TAG_IMAGETEXT16);
}
else if (got_id)
{
rdpup_begin_update();
for (j = num_clips - 1; j >= 0; j--)
{
box = REGION_RECTS(&reg)[j];
rdpup_send_area(&id, box.x1, box.y1, box.x2 - box.x1,
box.y2 - box.y1);
}
rdpup_end_update();
}
}
RegionUninit(&reg1);
}
RegionUninit(&reg);
if (reset_surface)
{
rdpup_switch_os_surface(-1);
}
return;
}

@ -1,29 +0,0 @@
/*
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

@ -1,218 +0,0 @@
/*
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 LLOG(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; } } while (0)
#define LLOGLN(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0)
extern rdpScreenInfoRec g_rdpScreen; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpGCIndex; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpWindowIndex; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpPixmapIndex; /* from rdpmain.c */
extern int g_Bpp; /* from rdpmain.c */
extern ScreenPtr g_pScreen; /* from rdpmain.c */
extern Bool g_wrapPixmap; /* from rdpmain.c */
extern int g_do_dirty_os; /* in rdpmain.c */
extern int g_do_dirty_ons; /* in rdpmain.c */
extern rdpPixmapRec g_screenPriv; /* in rdpmain.c */
extern GCOps g_rdpGCOps; /* from rdpdraw.c */
extern int g_con_number; /* in rdpup.c */
/******************************************************************************/
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)
{
RegionRec reg;
RegionRec reg1;
int num_clips;
int cd;
int j;
int got_id;
int dirty_type;
int post_process;
int reset_surface;
BoxRec box;
struct image_data id;
WindowPtr pDstWnd;
PixmapPtr pDstPixmap;
rdpPixmapRec *pDstPriv;
rdpPixmapRec *pDirtyPriv;
LLOGLN(10, ("rdpImageText8:"));
if (count != 0)
{
GetTextBoundingBox(pDrawable, pGC->font, x, y, count, &box);
}
/* do original call */
rdpImageText8Org(pDrawable, pGC, x, y, count, chars);
dirty_type = 0;
pDirtyPriv = 0;
post_process = 0;
reset_surface = 0;
got_id = 0;
if (pDrawable->type == DRAWABLE_PIXMAP)
{
pDstPixmap = (PixmapPtr)pDrawable;
pDstPriv = GETPIXPRIV(pDstPixmap);
if (xrdp_is_os(pDstPixmap, pDstPriv))
{
post_process = 1;
if (g_do_dirty_os)
{
LLOGLN(10, ("rdpImageText8: getting dirty"));
pDstPriv->is_dirty = 1;
pDirtyPriv = pDstPriv;
dirty_type = RDI_IMGLL;
}
else
{
rdpup_switch_os_surface(pDstPriv->rdpindex);
reset_surface = 1;
rdpup_get_pixmap_image_rect(pDstPixmap, &id);
got_id = 1;
}
}
}
else
{
if (pDrawable->type == DRAWABLE_WINDOW)
{
pDstWnd = (WindowPtr)pDrawable;
if (pDstWnd->viewable)
{
post_process = 1;
if (g_do_dirty_ons)
{
LLOGLN(10, ("rdpImageText8: getting dirty"));
g_screenPriv.is_dirty = 1;
pDirtyPriv = &g_screenPriv;
dirty_type = RDI_IMGLL;
}
else
{
rdpup_get_screen_image_rect(&id);
got_id = 1;
}
}
}
}
if (!post_process)
{
return;
}
RegionInit(&reg, NullBox, 0);
if (count == 0)
{
cd = 0;
}
else
{
cd = rdp_get_clip(&reg, pDrawable, pGC);
}
if (cd == 1)
{
if (dirty_type != 0)
{
RegionInit(&reg1, &box, 0);
draw_item_add_img_region(pDirtyPriv, &reg1, GXcopy, dirty_type, TAG_IMAGETEXT8);
RegionUninit(&reg1);
}
else if (got_id)
{
rdpup_begin_update();
rdpup_send_area(&id, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1);
rdpup_end_update();
}
}
else if (cd == 2)
{
RegionInit(&reg1, &box, 0);
RegionIntersect(&reg, &reg, &reg1);
num_clips = REGION_NUM_RECTS(&reg);
if (num_clips > 0)
{
if (dirty_type != 0)
{
draw_item_add_img_region(pDirtyPriv, &reg, GXcopy, dirty_type, TAG_IMAGETEXT8);
}
else if (got_id)
{
rdpup_begin_update();
for (j = num_clips - 1; j >= 0; j--)
{
box = REGION_RECTS(&reg)[j];
rdpup_send_area(&id, box.x1, box.y1, box.x2 - box.x1,
box.y2 - box.y1);
}
rdpup_end_update();
}
}
RegionUninit(&reg1);
}
RegionUninit(&reg);
if (reset_surface)
{
rdpup_switch_os_surface(-1);
}
return;
}

@ -1,29 +0,0 @@
/*
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

@ -1,248 +0,0 @@
/*
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 LLOG(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; } } while (0)
#define LLOGLN(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0)
extern rdpScreenInfoRec g_rdpScreen; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpGCIndex; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpWindowIndex; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpPixmapIndex; /* from rdpmain.c */
extern int g_Bpp; /* from rdpmain.c */
extern ScreenPtr g_pScreen; /* from rdpmain.c */
extern Bool g_wrapPixmap; /* from rdpmain.c */
extern int g_do_dirty_os; /* in rdpmain.c */
extern int g_do_dirty_ons; /* in rdpmain.c */
extern rdpPixmapRec g_screenPriv; /* in rdpmain.c */
extern GCOps g_rdpGCOps; /* from rdpdraw.c */
extern int g_con_number; /* in rdpup.c */
/******************************************************************************/
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)
{
RegionRec clip_reg;
RegionPtr tmpRegion;
int cd;
int lw;
int extra;
int i;
int num_clips;
int got_id;
int dirty_type;
int post_process;
int reset_surface;
xRectangle *rects;
BoxRec box;
struct image_data id;
WindowPtr pDstWnd;
PixmapPtr pDstPixmap;
rdpPixmapRec *pDstPriv;
rdpPixmapRec *pDirtyPriv;
LLOGLN(10, ("rdpPolyArc:"));
rects = 0;
if (narcs > 0)
{
rects = (xRectangle *)g_malloc(narcs * sizeof(xRectangle), 0);
lw = pGC->lineWidth;
if (lw == 0)
{
lw = 1;
}
extra = lw / 2;
for (i = 0; i < narcs; i++)
{
rects[i].x = (parcs[i].x - extra) + pDrawable->x;
rects[i].y = (parcs[i].y - extra) + pDrawable->y;
rects[i].width = parcs[i].width + lw;
rects[i].height = parcs[i].height + lw;
}
}
/* do original call */
rdpPolyArcOrg(pDrawable, pGC, narcs, parcs);
dirty_type = 0;
pDirtyPriv = 0;
post_process = 0;
reset_surface = 0;
got_id = 0;
if (pDrawable->type == DRAWABLE_PIXMAP)
{
pDstPixmap = (PixmapPtr)pDrawable;
pDstPriv = GETPIXPRIV(pDstPixmap);
if (xrdp_is_os(pDstPixmap, pDstPriv))
{
post_process = 1;
if (g_do_dirty_os)
{
LLOGLN(10, ("rdpPolyArc: getting dirty"));
pDstPriv->is_dirty = 1;
pDirtyPriv = pDstPriv;
dirty_type = RDI_IMGLL;
}
else
{
rdpup_switch_os_surface(pDstPriv->rdpindex);
reset_surface = 1;
rdpup_get_pixmap_image_rect(pDstPixmap, &id);
got_id = 1;
}
}
}
else
{
if (pDrawable->type == DRAWABLE_WINDOW)
{
pDstWnd = (WindowPtr)pDrawable;
if (pDstWnd->viewable)
{
post_process = 1;
if (g_do_dirty_ons)
{
LLOGLN(10, ("rdpPolyArc: getting dirty"));
g_screenPriv.is_dirty = 1;
pDirtyPriv = &g_screenPriv;
dirty_type = RDI_IMGLL;
}
else
{
rdpup_get_screen_image_rect(&id);
got_id = 1;
}
}
}
}
if (!post_process)
{
g_free(rects);
return;
}
RegionInit(&clip_reg, NullBox, 0);
cd = rdp_get_clip(&clip_reg, pDrawable, pGC);
if (cd == 1)
{
if (rects != 0)
{
tmpRegion = RegionFromRects(narcs, rects, CT_NONE);
num_clips = REGION_NUM_RECTS(tmpRegion);
if (num_clips > 0)
{
if (dirty_type != 0)
{
draw_item_add_img_region(pDirtyPriv, tmpRegion, GXcopy, dirty_type, TAG_POLYARC);
}
else if (got_id)
{
rdpup_begin_update();
for (i = num_clips - 1; i >= 0; i--)
{
box = REGION_RECTS(tmpRegion)[i];
rdpup_send_area(&id, box.x1, box.y1, box.x2 - box.x1,
box.y2 - box.y1);
}
rdpup_end_update();
}
}
RegionDestroy(tmpRegion);
}
}
else if (cd == 2)
{
if (rects != 0)
{
tmpRegion = RegionFromRects(narcs, rects, CT_NONE);
RegionIntersect(tmpRegion, tmpRegion, &clip_reg);
num_clips = REGION_NUM_RECTS(tmpRegion);
if (num_clips > 0)
{
if (dirty_type != 0)
{
draw_item_add_img_region(pDirtyPriv, tmpRegion, GXcopy, dirty_type, TAG_POLYARC);
}
else if (got_id)
{
rdpup_begin_update();
for (i = num_clips - 1; i >= 0; i--)
{
box = REGION_RECTS(tmpRegion)[i];
rdpup_send_area(&id, box.x1, box.y1, box.x2 - box.x1,
box.y2 - box.y1);
}
rdpup_end_update();
}
}
RegionDestroy(tmpRegion);
}
}
RegionUninit(&clip_reg);
g_free(rects);
if (reset_surface)
{
rdpup_switch_os_surface(-1);
}
}

@ -1,28 +0,0 @@
/*
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

@ -1,248 +0,0 @@
/*
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 LLOG(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; } } while (0)
#define LLOGLN(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0)
extern rdpScreenInfoRec g_rdpScreen; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpGCIndex; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpWindowIndex; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpPixmapIndex; /* from rdpmain.c */
extern int g_Bpp; /* from rdpmain.c */
extern ScreenPtr g_pScreen; /* from rdpmain.c */
extern Bool g_wrapPixmap; /* from rdpmain.c */
extern int g_do_dirty_os; /* in rdpmain.c */
extern int g_do_dirty_ons; /* in rdpmain.c */
extern rdpPixmapRec g_screenPriv; /* in rdpmain.c */
extern GCOps g_rdpGCOps; /* from rdpdraw.c */
extern int g_con_number; /* in rdpup.c */
/******************************************************************************/
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)
{
RegionRec clip_reg;
RegionPtr tmpRegion;
int cd;
int lw;
int extra;
int i;
int num_clips;
int got_id;
int dirty_type;
int post_process;
int reset_surface;
xRectangle *rects;
BoxRec box;
struct image_data id;
WindowPtr pDstWnd;
PixmapPtr pDstPixmap;
rdpPixmapRec *pDstPriv;
rdpPixmapRec *pDirtyPriv;
LLOGLN(10, ("rdpPolyFillArc:"));
rects = 0;
if (narcs > 0)
{
rects = (xRectangle *)g_malloc(narcs * sizeof(xRectangle), 0);
lw = pGC->lineWidth;
if (lw == 0)
{
lw = 1;
}
extra = lw / 2;
for (i = 0; i < narcs; i++)
{
rects[i].x = (parcs[i].x - extra) + pDrawable->x;
rects[i].y = (parcs[i].y - extra) + pDrawable->y;
rects[i].width = parcs[i].width + lw;
rects[i].height = parcs[i].height + lw;
}
}
/* do original call */
rdpPolyFillArcOrg(pDrawable, pGC, narcs, parcs);
dirty_type = 0;
pDirtyPriv = 0;
post_process = 0;
reset_surface = 0;
got_id = 0;
if (pDrawable->type == DRAWABLE_PIXMAP)
{
pDstPixmap = (PixmapPtr)pDrawable;
pDstPriv = GETPIXPRIV(pDstPixmap);
if (xrdp_is_os(pDstPixmap, pDstPriv))
{
post_process = 1;
if (g_do_dirty_os)
{
LLOGLN(10, ("rdpPolyFillArc: getting dirty"));
pDstPriv->is_dirty = 1;
pDirtyPriv = pDstPriv;
dirty_type = RDI_IMGLY;
}
else
{
rdpup_switch_os_surface(pDstPriv->rdpindex);
reset_surface = 1;
rdpup_get_pixmap_image_rect(pDstPixmap, &id);
got_id = 1;
}
}
}
else
{
if (pDrawable->type == DRAWABLE_WINDOW)
{
pDstWnd = (WindowPtr)pDrawable;
if (pDstWnd->viewable)
{
post_process = 1;
if (g_do_dirty_ons)
{
LLOGLN(10, ("rdpPolyFillArc: getting dirty"));
g_screenPriv.is_dirty = 1;
pDirtyPriv = &g_screenPriv;
dirty_type = RDI_IMGLL;
}
else
{
rdpup_get_screen_image_rect(&id);
got_id = 1;
}
}
}
}
if (!post_process)
{
g_free(rects);
return;
}
RegionInit(&clip_reg, NullBox, 0);
cd = rdp_get_clip(&clip_reg, pDrawable, pGC);
if (cd == 1)
{
if (rects != 0)
{
tmpRegion = RegionFromRects(narcs, rects, CT_NONE);
num_clips = REGION_NUM_RECTS(tmpRegion);
if (num_clips > 0)
{
if (dirty_type != 0)
{
draw_item_add_img_region(pDirtyPriv, tmpRegion, GXcopy, dirty_type, TAG_POLYFILLARC);
}
else if (got_id)
{
rdpup_begin_update();
for (i = num_clips - 1; i >= 0; i--)
{
box = REGION_RECTS(tmpRegion)[i];
rdpup_send_area(&id, box.x1, box.y1, box.x2 - box.x1,
box.y2 - box.y1);
}
rdpup_end_update();
}
}
RegionDestroy(tmpRegion);
}
}
else if (cd == 2)
{
if (rects != 0)
{
tmpRegion = RegionFromRects(narcs, rects, CT_NONE);
RegionIntersect(tmpRegion, tmpRegion, &clip_reg);
num_clips = REGION_NUM_RECTS(tmpRegion);
if (num_clips > 0)
{
if (dirty_type != 0)
{
draw_item_add_img_region(pDirtyPriv, tmpRegion, GXcopy, dirty_type, TAG_POLYFILLARC);
}
else if (got_id)
{
rdpup_begin_update();
for (i = num_clips - 1; i >= 0; i--)
{
box = REGION_RECTS(tmpRegion)[i];
rdpup_send_area(&id, box.x1, box.y1, box.x2 - box.x1,
box.y2 - box.y1);
}
rdpup_end_update();
}
}
RegionDestroy(tmpRegion);
}
}
RegionUninit(&clip_reg);
g_free(rects);
if (reset_surface)
{
rdpup_switch_os_surface(-1);
}
}

@ -1,28 +0,0 @@
/*
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

@ -1,319 +0,0 @@
/*
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 LLOG(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; } } while (0)
#define LLOGLN(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0)
extern rdpScreenInfoRec g_rdpScreen; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpGCIndex; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpWindowIndex; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpPixmapIndex; /* from rdpmain.c */
extern int g_Bpp; /* from rdpmain.c */
extern ScreenPtr g_pScreen; /* from rdpmain.c */
extern Bool g_wrapPixmap; /* from rdpmain.c */
extern int g_do_dirty_os; /* in rdpmain.c */
extern int g_do_dirty_ons; /* in rdpmain.c */
extern rdpPixmapRec g_screenPriv; /* in rdpmain.c */
extern GCOps g_rdpGCOps; /* from rdpdraw.c */
extern int g_con_number; /* in rdpup.c */
/******************************************************************************/
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)
{
int j;
int cd;
int num_clips;
RegionRec clip_reg;
RegionPtr fill_reg;
BoxRec box;
int got_id;
int dirty_type;
int post_process;
int reset_surface;
struct image_data id;
WindowPtr pDstWnd;
PixmapPtr pDstPixmap;
rdpPixmapRec *pDstPriv;
rdpPixmapRec *pDirtyPriv;
LLOGLN(10, ("rdpPolyFillRect:"));
/* make a copy of rects */
fill_reg = RegionFromRects(nrectFill, prectInit, CT_NONE);
/* do original call */
rdpPolyFillRectOrg(pDrawable, pGC, nrectFill, prectInit);
dirty_type = 0;
pDirtyPriv = 0;
post_process = 0;
reset_surface = 0;
if (pDrawable->type == DRAWABLE_PIXMAP)
{
pDstPixmap = (PixmapPtr)pDrawable;
pDstPriv = GETPIXPRIV(pDstPixmap);
if (pDstPixmap->devPrivate.ptr == g_rdpScreen.pfbMemory)
{
/* treat like root window */
post_process = 1;
if (g_do_dirty_ons)
{
LLOGLN(10, ("rdpPolyFillRect: getting dirty"));
g_screenPriv.is_dirty = 1;
pDirtyPriv = &g_screenPriv;
dirty_type = (FillTiled == pGC->fillStyle) ?
RDI_IMGLY : RDI_IMGLL;
}
else
{
rdpup_get_screen_image_rect(&id);
got_id = 1;
}
}
else if (xrdp_is_os(pDstPixmap, pDstPriv))
{
post_process = 1;
if (g_do_dirty_os)
{
LLOGLN(10, ("rdpPolyFillRect: getting dirty"));
pDstPriv->is_dirty = 1;
pDirtyPriv = pDstPriv;
dirty_type = (FillTiled == pGC->fillStyle) ?
RDI_IMGLY : RDI_IMGLL;
}
else
{
rdpup_switch_os_surface(pDstPriv->rdpindex);
reset_surface = 1;
rdpup_get_pixmap_image_rect(pDstPixmap, &id);
got_id = 1;
}
}
}
else
{
if (pDrawable->type == DRAWABLE_WINDOW)
{
pDstWnd = (WindowPtr)pDrawable;
if (pDstWnd->viewable)
{
post_process = 1;
if (g_do_dirty_ons)
{
LLOGLN(10, ("rdpPolyFillRect: getting dirty"));
g_screenPriv.is_dirty = 1;
pDirtyPriv = &g_screenPriv;
dirty_type = (FillTiled == pGC->fillStyle) ?
RDI_IMGLY : RDI_IMGLL;
}
else
{
rdpup_get_screen_image_rect(&id);
got_id = 1;
}
}
}
}
if (!post_process)
{
RegionDestroy(fill_reg);
LLOGLN(10, ("rdpPolyFillRect: out, post_process not set"));
return;
}
RegionTranslate(fill_reg, pDrawable->x, pDrawable->y);
RegionInit(&clip_reg, NullBox, 0);
cd = rdp_get_clip(&clip_reg, pDrawable, pGC);
LLOGLN(10, ("rdpPolyFillRect: cd %d", cd));
if (cd == 1) /* no clip */
{
if (dirty_type != 0)
{
if (pGC->fillStyle == 0 && /* solid fill */
(pGC->alu == GXclear ||
pGC->alu == GXset ||
pGC->alu == GXinvert ||
pGC->alu == GXnoop ||
pGC->alu == GXand ||
pGC->alu == GXcopy /*||
pGC->alu == GXxor*/)) /* todo, why doesn't xor work? */
{
draw_item_add_fill_region(pDirtyPriv, fill_reg, pGC->fgPixel,
pGC->alu);
}
else
{
draw_item_add_img_region(pDirtyPriv, fill_reg, GXcopy,
dirty_type, TAG_POLYFILLRECT);
}
}
else if (got_id)
{
rdpup_begin_update();
if (pGC->fillStyle == 0 && /* solid fill */
(pGC->alu == GXclear ||
pGC->alu == GXset ||
pGC->alu == GXinvert ||
pGC->alu == GXnoop ||
pGC->alu == GXand ||
pGC->alu == GXcopy /*||
pGC->alu == GXxor*/)) /* todo, why doesn't xor work? */
{
rdpup_set_fgcolor(pGC->fgPixel);
rdpup_set_opcode(pGC->alu);
for (j = REGION_NUM_RECTS(fill_reg) - 1; j >= 0; j--)
{
box = REGION_RECTS(fill_reg)[j];
rdpup_fill_rect(box.x1, box.y1,
box.x2 - box.x1, box.y2 - box.y1);
}
rdpup_set_opcode(GXcopy);
}
else /* non solid fill */
{
for (j = REGION_NUM_RECTS(fill_reg) - 1; j >= 0; j--)
{
box = REGION_RECTS(fill_reg)[j];
rdpup_send_area(&id, box.x1, box.y1, box.x2 - box.x1,
box.y2 - box.y1);
}
}
rdpup_end_update();
}
}
else if (cd == 2) /* clip */
{
RegionIntersect(&clip_reg, &clip_reg, fill_reg);
num_clips = REGION_NUM_RECTS(&clip_reg);
if (num_clips > 0)
{
if (dirty_type != 0)
{
if (pGC->fillStyle == 0 && /* solid fill */
(pGC->alu == GXclear ||
pGC->alu == GXset ||
pGC->alu == GXinvert ||
pGC->alu == GXnoop ||
pGC->alu == GXand ||
pGC->alu == GXcopy /*||
pGC->alu == GXxor*/)) /* todo, why doesn't xor work? */
{
LLOGLN(10, ("rdpPolyFillRect: 3"));
draw_item_add_fill_region(pDirtyPriv, &clip_reg,
pGC->fgPixel,
pGC->alu);
}
else
{
LLOGLN(10, ("rdpPolyFillRect: 4"));
draw_item_add_img_region(pDirtyPriv, &clip_reg, GXcopy,
dirty_type, TAG_POLYFILLRECT);
}
}
else if (got_id)
{
rdpup_begin_update();
LLOGLN(10, ("2 %x", pGC->fgPixel));
if (pGC->fillStyle == 0 && /* solid fill */
(pGC->alu == GXclear ||
pGC->alu == GXset ||
pGC->alu == GXinvert ||
pGC->alu == GXnoop ||
pGC->alu == GXand ||
pGC->alu == GXcopy /*||
pGC->alu == GXxor*/)) /* todo, why doesn't xor work? */
{
rdpup_set_fgcolor(pGC->fgPixel);
rdpup_set_opcode(pGC->alu);
for (j = num_clips - 1; j >= 0; j--)
{
box = REGION_RECTS(&clip_reg)[j];
rdpup_fill_rect(box.x1, box.y1,
box.x2 - box.x1, box.y2 - box.y1);
}
rdpup_set_opcode(GXcopy);
}
else /* non solid fill */
{
for (j = num_clips - 1; j >= 0; j--)
{
box = REGION_RECTS(&clip_reg)[j];
rdpup_send_area(&id, box.x1, box.y1,
box.x2 - box.x1, box.y2 - box.y1);
}
}
rdpup_end_update();
}
}
}
RegionUninit(&clip_reg);
RegionDestroy(fill_reg);
if (reset_surface)
{
rdpup_switch_os_surface(-1);
}
}

@ -1,29 +0,0 @@
/*
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

@ -1,220 +0,0 @@
/*
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 LLOG(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; } } while (0)
#define LLOGLN(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0)
extern rdpScreenInfoRec g_rdpScreen; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpGCIndex; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpWindowIndex; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpPixmapIndex; /* from rdpmain.c */
extern int g_Bpp; /* from rdpmain.c */
extern ScreenPtr g_pScreen; /* from rdpmain.c */
extern Bool g_wrapPixmap; /* from rdpmain.c */
extern int g_do_dirty_os; /* in rdpmain.c */
extern int g_do_dirty_ons; /* in rdpmain.c */
extern rdpPixmapRec g_screenPriv; /* in rdpmain.c */
extern GCOps g_rdpGCOps; /* from rdpdraw.c */
extern int g_con_number; /* in rdpup.c */
/******************************************************************************/
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)
{
RegionRec reg;
RegionRec reg1;
int num_clips;
int cd;
int j;
int got_id;
int dirty_type;
int post_process;
int reset_surface;
BoxRec box;
struct image_data id;
WindowPtr pDstWnd;
PixmapPtr pDstPixmap;
rdpPixmapRec *pDstPriv;
rdpPixmapRec *pDirtyPriv;
LLOGLN(10, ("rdpPolyGlyphBlt:"));
if (nglyph != 0)
{
GetTextBoundingBox(pDrawable, pGC->font, x, y, nglyph, &box);
}
/* do original call */
rdpPolyGlyphBltOrg(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
dirty_type = 0;
pDirtyPriv = 0;
post_process = 0;
reset_surface = 0;
got_id = 0;
if (pDrawable->type == DRAWABLE_PIXMAP)
{
pDstPixmap = (PixmapPtr)pDrawable;
pDstPriv = GETPIXPRIV(pDstPixmap);
if (xrdp_is_os(pDstPixmap, pDstPriv))
{
post_process = 1;
if (g_do_dirty_os)
{
LLOGLN(10, ("rdpPolyGlyphBlt: getting dirty"));
pDstPriv->is_dirty = 1;
pDirtyPriv = pDstPriv;
dirty_type = RDI_IMGLY;
}
else
{
rdpup_switch_os_surface(pDstPriv->rdpindex);
reset_surface = 1;
rdpup_get_pixmap_image_rect(pDstPixmap, &id);
got_id = 1;
}
}
}
else
{
if (pDrawable->type == DRAWABLE_WINDOW)
{
pDstWnd = (WindowPtr)pDrawable;
if (pDstWnd->viewable)
{
post_process = 1;
if (g_do_dirty_ons)
{
LLOGLN(10, ("rdpPolyGlyphBlt: getting dirty"));
g_screenPriv.is_dirty = 1;
pDirtyPriv = &g_screenPriv;
dirty_type = RDI_IMGLL;
}
else
{
rdpup_get_screen_image_rect(&id);
got_id = 1;
}
}
}
}
if (!post_process)
{
return;
}
RegionInit(&reg, NullBox, 0);
if (nglyph == 0)
{
cd = 0;
}
else
{
cd = rdp_get_clip(&reg, pDrawable, pGC);
}
if (cd == 1)
{
if (dirty_type != 0)
{
RegionInit(&reg1, &box, 0);
draw_item_add_img_region(pDirtyPriv, &reg1, GXcopy, dirty_type, TAG_POLYGLYPHBLT);
RegionUninit(&reg1);
}
else if (got_id)
{
rdpup_begin_update();
rdpup_send_area(&id, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1);
rdpup_end_update();
}
}
else if (cd == 2)
{
RegionInit(&reg1, &box, 0);
RegionIntersect(&reg, &reg, &reg1);
num_clips = REGION_NUM_RECTS(&reg);
if (num_clips > 0)
{
if (dirty_type != 0)
{
draw_item_add_img_region(pDirtyPriv, &reg, GXcopy, dirty_type, TAG_POLYGLYPHBLT);
}
else if (got_id)
{
rdpup_begin_update();
for (j = num_clips - 1; j >= 0; j--)
{
box = REGION_RECTS(&reg)[j];
rdpup_send_area(&id, box.x1, box.y1, box.x2 - box.x1,
box.y2 - box.y1);
}
rdpup_end_update();
}
}
RegionUninit(&reg1);
}
RegionUninit(&reg);
if (reset_surface)
{
rdpup_switch_os_surface(-1);
}
return;
}

@ -1,30 +0,0 @@
/*
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

@ -1,307 +0,0 @@
/*
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 LLOG(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; } } while (0)
#define LLOGLN(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0)
extern rdpScreenInfoRec g_rdpScreen; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpGCIndex; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpWindowIndex; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpPixmapIndex; /* from rdpmain.c */
extern int g_Bpp; /* from rdpmain.c */
extern ScreenPtr g_pScreen; /* from rdpmain.c */
extern Bool g_wrapPixmap; /* from rdpmain.c */
extern int g_do_dirty_os; /* in rdpmain.c */
extern int g_do_dirty_ons; /* in rdpmain.c */
extern rdpPixmapRec g_screenPriv; /* in rdpmain.c */
extern GCOps g_rdpGCOps; /* from rdpdraw.c */
extern int g_con_number; /* in rdpup.c */
/******************************************************************************/
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)
{
RegionRec clip_reg;
RegionRec reg1;
RegionRec reg2;
int num_clips;
int cd;
int x;
int y;
int i;
int j;
int got_id;
int dirty_type;
int post_process;
int reset_surface;
BoxRec box;
BoxRec total_box;
DDXPointPtr pts;
DDXPointRec stack_pts[32];
struct image_data id;
WindowPtr pDstWnd;
PixmapPtr pDstPixmap;
rdpPixmapRec *pDstPriv;
rdpPixmapRec *pDirtyPriv;
LLOGLN(10, ("rdpPolyPoint:"));
LLOGLN(10, ("rdpPolyPoint: npt %d", npt));
if (npt > 32)
{
pts = (DDXPointPtr)g_malloc(sizeof(DDXPointRec) * npt, 0);
}
else
{
pts = stack_pts;
}
for (i = 0; i < npt; i++)
{
pts[i].x = pDrawable->x + in_pts[i].x;
pts[i].y = pDrawable->y + in_pts[i].y;
if (i == 0)
{
total_box.x1 = pts[0].x;
total_box.y1 = pts[0].y;
total_box.x2 = pts[0].x;
total_box.y2 = pts[0].y;
}
else
{
if (pts[i].x < total_box.x1)
{
total_box.x1 = pts[i].x;
}
if (pts[i].y < total_box.y1)
{
total_box.y1 = pts[i].y;
}
if (pts[i].x > total_box.x2)
{
total_box.x2 = pts[i].x;
}
if (pts[i].y > total_box.y2)
{
total_box.y2 = pts[i].y;
}
}
/* todo, use this total_box */
}
/* do original call */
rdpPolyPointOrg(pDrawable, pGC, mode, npt, in_pts);
dirty_type = 0;
pDirtyPriv = 0;
post_process = 0;
reset_surface = 0;
got_id = 0;
if (pDrawable->type == DRAWABLE_PIXMAP)
{
pDstPixmap = (PixmapPtr)pDrawable;
pDstPriv = GETPIXPRIV(pDstPixmap);
if (xrdp_is_os(pDstPixmap, pDstPriv))
{
post_process = 1;
if (g_do_dirty_os)
{
LLOGLN(10, ("rdpPolyPoint: getting dirty"));
pDstPriv->is_dirty = 1;
pDirtyPriv = pDstPriv;
dirty_type = RDI_IMGLL;
}
else
{
rdpup_switch_os_surface(pDstPriv->rdpindex);
reset_surface = 1;
rdpup_get_pixmap_image_rect(pDstPixmap, &id);
got_id = 1;
}
}
}
else
{
if (pDrawable->type == DRAWABLE_WINDOW)
{
pDstWnd = (WindowPtr)pDrawable;
if (pDstWnd->viewable)
{
post_process = 1;
if (g_do_dirty_ons)
{
LLOGLN(10, ("rdpPolyPoint: getting dirty"));
g_screenPriv.is_dirty = 1;
pDirtyPriv = &g_screenPriv;
dirty_type = RDI_IMGLL;
}
else
{
rdpup_get_screen_image_rect(&id);
got_id = 1;
}
}
}
}
if (!post_process)
{
return;
}
RegionInit(&clip_reg, NullBox, 0);
cd = rdp_get_clip(&clip_reg, pDrawable, pGC);
if (cd == 1)
{
if (npt > 0)
{
if (dirty_type != 0)
{
RegionInit(&reg1, NullBox, 0);
for (i = 0; i < npt; i++)
{
box.x1 = pts[i].x;
box.y1 = pts[i].y;
box.x2 = box.x1 + 1;
box.y2 = box.y1 + 1;
RegionInit(&reg2, &box, 0);
RegionUnion(&reg1, &reg1, &reg2);
RegionUninit(&reg2);
}
draw_item_add_fill_region(pDirtyPriv, &reg1, pGC->fgPixel,
pGC->alu);
RegionUninit(&reg1);
}
else if (got_id)
{
rdpup_begin_update();
rdpup_set_fgcolor(pGC->fgPixel);
for (i = 0; i < npt; i++)
{
x = pts[i].x;
y = pts[i].y;
rdpup_fill_rect(x, y, 1, 1);
}
rdpup_end_update();
}
}
}
else if (cd == 2)
{
num_clips = REGION_NUM_RECTS(&clip_reg);
if (npt > 0 && num_clips > 0)
{
if (dirty_type != 0)
{
RegionInit(&reg1, NullBox, 0);
for (i = 0; i < npt; i++)
{
box.x1 = pts[i].x;
box.y1 = pts[i].y;
box.x2 = box.x1 + 1;
box.y2 = box.y1 + 1;
RegionInit(&reg2, &box, 0);
RegionUnion(&reg1, &reg1, &reg2);
RegionUninit(&reg2);
}
RegionIntersect(&reg1, &reg1, &clip_reg);
draw_item_add_fill_region(pDirtyPriv, &reg1, pGC->fgPixel,
pGC->alu);
RegionUninit(&reg1);
}
else if (got_id)
{
rdpup_begin_update();
rdpup_set_fgcolor(pGC->fgPixel);
for (j = num_clips - 1; j >= 0; j--)
{
box = REGION_RECTS(&clip_reg)[j];
rdpup_set_clip(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1);
for (i = 0; i < npt; i++)
{
x = pts[i].x;
y = pts[i].y;
rdpup_fill_rect(x, y, 1, 1);
}
}
rdpup_reset_clip();
rdpup_end_update();
}
}
}
RegionUninit(&clip_reg);
if (pts != stack_pts)
{
g_free(pts);
}
if (reset_surface)
{
rdpup_switch_os_surface(-1);
}
}

@ -1,29 +0,0 @@
/*
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

@ -1,323 +0,0 @@
/*
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 LLOG(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; } } while (0)
#define LLOGLN(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0)
extern rdpScreenInfoRec g_rdpScreen; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpGCIndex; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpWindowIndex; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpPixmapIndex; /* from rdpmain.c */
extern int g_Bpp; /* from rdpmain.c */
extern ScreenPtr g_pScreen; /* from rdpmain.c */
extern Bool g_wrapPixmap; /* from rdpmain.c */
extern int g_do_dirty_os; /* in rdpmain.c */
extern int g_do_dirty_ons; /* in rdpmain.c */
extern rdpPixmapRec g_screenPriv; /* in rdpmain.c */
extern GCOps g_rdpGCOps; /* from rdpdraw.c */
extern int g_con_number; /* in rdpup.c */
/******************************************************************************/
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)
{
RegionRec clip_reg;
RegionPtr fill_reg;
int num_clips;
int cd;
int lw;
int i;
int j;
int up;
int down;
int got_id;
int dirty_type;
int post_process;
int reset_surface;
xRectangle *regRects;
xRectangle *r;
xRectangle *rect1;
BoxRec box;
struct image_data id;
WindowPtr pDstWnd;
PixmapPtr pDstPixmap;
rdpPixmapRec *pDstPriv;
rdpPixmapRec *pDirtyPriv;
LLOGLN(10, ("rdpPolyRectangle:"));
/* make a copy of rects */
rect1 = (xRectangle *)g_malloc(sizeof(xRectangle) * nrects, 0);
for (i = 0; i < nrects; i++)
{
rect1[i] = rects[i];
}
/* do original call */
rdpPolyRectangleOrg(pDrawable, pGC, nrects, rects);
dirty_type = 0;
pDirtyPriv = 0;
post_process = 0;
reset_surface = 0;
got_id = 0;
if (pDrawable->type == DRAWABLE_PIXMAP)
{
pDstPixmap = (PixmapPtr)pDrawable;
pDstPriv = GETPIXPRIV(pDstPixmap);
if (xrdp_is_os(pDstPixmap, pDstPriv))
{
post_process = 1;
if (g_do_dirty_os)
{
LLOGLN(10, ("rdpPolyRectangle: getting dirty"));
pDstPriv->is_dirty = 1;
pDirtyPriv = pDstPriv;
dirty_type = RDI_IMGLL;
}
else
{
rdpup_switch_os_surface(pDstPriv->rdpindex);
reset_surface = 1;
rdpup_get_pixmap_image_rect(pDstPixmap, &id);
got_id = 1;
}
}
}
else
{
if (pDrawable->type == DRAWABLE_WINDOW)
{
pDstWnd = (WindowPtr)pDrawable;
if (pDstWnd->viewable)
{
post_process = 1;
if (g_do_dirty_ons)
{
LLOGLN(10, ("rdpPolyRectangle: getting dirty"));
g_screenPriv.is_dirty = 1;
pDirtyPriv = &g_screenPriv;
dirty_type = RDI_IMGLL;
}
else
{
rdpup_get_screen_image_rect(&id);
got_id = 1;
}
}
}
}
if (!post_process)
{
g_free(rect1);
return;
}
RegionInit(&clip_reg, NullBox, 0);
cd = rdp_get_clip(&clip_reg, pDrawable, pGC);
regRects = 0;
if ((cd != 0) && (nrects > 0))
{
regRects = (xRectangle *)g_malloc(nrects * 4 * sizeof(xRectangle), 0);
lw = pGC->lineWidth;
if (lw < 1)
{
lw = 1;
}
up = lw / 2;
down = 1 + (lw - 1) / 2;
for (i = 0; i < nrects; i++)
{
r = regRects + i * 4;
r->x = (rect1[i].x + pDrawable->x) - up;
r->y = (rect1[i].y + pDrawable->y) - up;
r->width = rect1[i].width + up + down;
r->height = lw;
r++;
r->x = (rect1[i].x + pDrawable->x) - up;
r->y = (rect1[i].y + pDrawable->y) + down;
r->width = lw;
r->height = MAX(rect1[i].height - (up + down), 0);
r++;
r->x = ((rect1[i].x + rect1[i].width) + pDrawable->x) - up;
r->y = (rect1[i].y + pDrawable->y) + down;
r->width = lw;
r->height = MAX(rect1[i].height - (up + down), 0);
r++;
r->x = (rect1[i].x + pDrawable->x) - up;
r->y = ((rect1[i].y + rect1[i].height) + pDrawable->y) - up;
r->width = rect1[i].width + up + down;
r->height = lw;
}
}
if (cd == 1)
{
if (regRects != 0)
{
if (dirty_type != 0)
{
fill_reg = RegionFromRects(nrects * 4, regRects, CT_NONE);
if (pGC->lineStyle == LineSolid)
{
draw_item_add_fill_region(pDirtyPriv, fill_reg, pGC->fgPixel,
pGC->alu);
}
else
{
draw_item_add_img_region(pDirtyPriv, fill_reg, GXcopy, dirty_type, TAG_POLYRECTANGLE);
}
RegionDestroy(fill_reg);
}
else if (got_id)
{
rdpup_begin_update();
if (pGC->lineStyle == LineSolid)
{
rdpup_set_fgcolor(pGC->fgPixel);
rdpup_set_opcode(pGC->alu);
for (i = 0; i < nrects * 4; i++)
{
r = regRects + i;
rdpup_fill_rect(r->x, r->y, r->width, r->height);
}
rdpup_set_opcode(GXcopy);
}
else
{
for (i = 0; i < nrects * 4; i++)
{
r = regRects + i;
rdpup_send_area(&id, r->x, r->y, r->width, r->height);
}
}
rdpup_end_update();
}
}
}
else if (cd == 2)
{
if (regRects != 0)
{
fill_reg = RegionFromRects(nrects * 4, regRects, CT_NONE);
RegionIntersect(&clip_reg, &clip_reg, fill_reg);
num_clips = REGION_NUM_RECTS(&clip_reg);
if (num_clips > 0)
{
if (dirty_type != 0)
{
if (pGC->lineStyle == LineSolid)
{
draw_item_add_fill_region(pDirtyPriv, &clip_reg, pGC->fgPixel,
pGC->alu);
}
else
{
draw_item_add_img_region(pDirtyPriv, &clip_reg, GXcopy, dirty_type, TAG_POLYRECTANGLE);
}
}
else if (got_id)
{
rdpup_begin_update();
if (pGC->lineStyle == LineSolid)
{
rdpup_set_fgcolor(pGC->fgPixel);
rdpup_set_opcode(pGC->alu);
for (j = num_clips - 1; j >= 0; j--)
{
box = REGION_RECTS(&clip_reg)[j];
rdpup_fill_rect(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1);
}
rdpup_set_opcode(GXcopy);
}
else
{
for (j = num_clips - 1; j >= 0; j--)
{
box = REGION_RECTS(&clip_reg)[j];
rdpup_send_area(&id, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1);
}
}
rdpup_end_update();
}
}
RegionDestroy(fill_reg);
}
}
RegionUninit(&clip_reg);
g_free(regRects);
g_free(rect1);
if (reset_surface)
{
rdpup_switch_os_surface(-1);
}
}

@ -1,29 +0,0 @@
/*
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

@ -1,240 +0,0 @@
/*
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 LLOG(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; } } while (0)
#define LLOGLN(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0)
extern rdpScreenInfoRec g_rdpScreen; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpGCIndex; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpWindowIndex; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpPixmapIndex; /* from rdpmain.c */
extern int g_Bpp; /* from rdpmain.c */
extern ScreenPtr g_pScreen; /* from rdpmain.c */
extern Bool g_wrapPixmap; /* from rdpmain.c */
extern int g_do_dirty_os; /* in rdpmain.c */
extern int g_do_dirty_ons; /* in rdpmain.c */
extern rdpPixmapRec g_screenPriv; /* in rdpmain.c */
extern GCOps g_rdpGCOps; /* from rdpdraw.c */
extern int g_con_number; /* in rdpup.c */
/******************************************************************************/
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)
{
RegionRec clip_reg;
int cd;
int i;
int j;
int got_id;
int dirty_type;
int post_process;
int reset_surface;
xSegment *segs;
BoxRec box;
struct image_data id;
WindowPtr pDstWnd;
PixmapPtr pDstPixmap;
rdpPixmapRec *pDstPriv;
rdpPixmapRec *pDirtyPriv;
LLOGLN(10, ("rdpPolySegment:"));
LLOGLN(10, (" nseg %d", nseg));
segs = 0;
if (nseg) /* get the rects */
{
segs = (xSegment *)g_malloc(nseg * sizeof(xSegment), 0);
for (i = 0; i < nseg; i++)
{
segs[i].x1 = pSegs[i].x1 + pDrawable->x;
segs[i].y1 = pSegs[i].y1 + pDrawable->y;
segs[i].x2 = pSegs[i].x2 + pDrawable->x;
segs[i].y2 = pSegs[i].y2 + pDrawable->y;
}
}
/* do original call */
rdpPolySegmentOrg(pDrawable, pGC, nseg, pSegs);
dirty_type = 0;
pDirtyPriv = 0;
post_process = 0;
reset_surface = 0;
got_id = 0;
if (pDrawable->type == DRAWABLE_PIXMAP)
{
pDstPixmap = (PixmapPtr)pDrawable;
pDstPriv = GETPIXPRIV(pDstPixmap);
if (xrdp_is_os(pDstPixmap, pDstPriv))
{
post_process = 1;
if (g_do_dirty_os)
{
LLOGLN(10, ("rdpPolySegment: getting dirty"));
pDstPriv->is_dirty = 1;
pDirtyPriv = pDstPriv;
dirty_type = RDI_IMGLL;
}
else
{
rdpup_switch_os_surface(pDstPriv->rdpindex);
reset_surface = 1;
rdpup_get_pixmap_image_rect(pDstPixmap, &id);
got_id = 1;
}
}
}
else
{
if (pDrawable->type == DRAWABLE_WINDOW)
{
pDstWnd = (WindowPtr)pDrawable;
if (pDstWnd->viewable)
{
post_process = 1;
if (g_do_dirty_ons)
{
LLOGLN(10, ("rdpPolySegment: getting dirty"));
g_screenPriv.is_dirty = 1;
pDirtyPriv = &g_screenPriv;
dirty_type = RDI_IMGLL;
}
else
{
rdpup_get_screen_image_rect(&id);
got_id = 1;
}
}
}
}
if (!post_process)
{
g_free(segs);
return;
}
RegionInit(&clip_reg, NullBox, 0);
cd = rdp_get_clip(&clip_reg, pDrawable, pGC);
LLOGLN(10, ("rdpPolySegment: cd %d", cd));
if (cd == 1) /* no clip */
{
if (segs != 0)
{
if (dirty_type != 0)
{
RegionUninit(&clip_reg);
RegionInit(&clip_reg, NullBox, 0);
RegionAroundSegs(&clip_reg, segs, nseg);
draw_item_add_line_region(pDirtyPriv, &clip_reg, pGC->fgPixel,
pGC->alu, pGC->lineWidth, segs, nseg, 1);
}
else if (got_id)
{
rdpup_begin_update();
rdpup_set_fgcolor(pGC->fgPixel);
rdpup_set_opcode(pGC->alu);
rdpup_set_pen(0, pGC->lineWidth);
for (i = 0; i < nseg; i++)
{
rdpup_draw_line(segs[i].x1, segs[i].y1, segs[i].x2, segs[i].y2);
}
rdpup_set_opcode(GXcopy);
rdpup_end_update();
}
}
}
else if (cd == 2) /* clip */
{
if (segs != 0)
{
if (dirty_type != 0)
{
draw_item_add_line_region(pDirtyPriv, &clip_reg, pGC->fgPixel,
pGC->alu, pGC->lineWidth, segs, nseg, 1);
}
else if (got_id)
{
rdpup_begin_update();
rdpup_set_fgcolor(pGC->fgPixel);
rdpup_set_opcode(pGC->alu);
rdpup_set_pen(0, pGC->lineWidth);
for (j = REGION_NUM_RECTS(&clip_reg) - 1; j >= 0; j--)
{
box = REGION_RECTS(&clip_reg)[j];
rdpup_set_clip(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1);
for (i = 0; i < nseg; i++)
{
rdpup_draw_line(segs[i].x1, segs[i].y1, segs[i].x2, segs[i].y2);
LLOGLN(10, (" %d %d %d %d", segs[i].x1, segs[i].y1,
segs[i].x2, segs[i].y2));
}
}
rdpup_reset_clip();
rdpup_set_opcode(GXcopy);
rdpup_end_update();
}
}
}
g_free(segs);
RegionUninit(&clip_reg);
if (reset_surface)
{
rdpup_switch_os_surface(-1);
}
}

@ -1,28 +0,0 @@
/*
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

@ -1,220 +0,0 @@
/*
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 LLOG(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; } } while (0)
#define LLOGLN(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0)
extern rdpScreenInfoRec g_rdpScreen; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpGCIndex; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpWindowIndex; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpPixmapIndex; /* from rdpmain.c */
extern int g_Bpp; /* from rdpmain.c */
extern ScreenPtr g_pScreen; /* from rdpmain.c */
extern Bool g_wrapPixmap; /* from rdpmain.c */
extern int g_do_dirty_os; /* in rdpmain.c */
extern int g_do_dirty_ons; /* in rdpmain.c */
extern rdpPixmapRec g_screenPriv; /* in rdpmain.c */
extern GCOps g_rdpGCOps; /* from rdpdraw.c */
extern int g_con_number; /* in rdpup.c */
/******************************************************************************/
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)
{
RegionRec reg;
RegionRec reg1;
int num_clips;
int cd;
int j;
int rv;
int got_id;
int dirty_type;
int post_process;
int reset_surface;
BoxRec box;
struct image_data id;
WindowPtr pDstWnd;
PixmapPtr pDstPixmap;
rdpPixmapRec *pDstPriv;
rdpPixmapRec *pDirtyPriv;
LLOGLN(10, ("rdpPolyText16:"));
if (count != 0)
{
GetTextBoundingBox(pDrawable, pGC->font, x, y, count, &box);
}
/* do original call */
rv = rdpPolyText16Org(pDrawable, pGC, x, y, count, chars);
dirty_type = 0;
pDirtyPriv = 0;
post_process = 0;
reset_surface = 0;
got_id = 0;
if (pDrawable->type == DRAWABLE_PIXMAP)
{
pDstPixmap = (PixmapPtr)pDrawable;
pDstPriv = GETPIXPRIV(pDstPixmap);
if (xrdp_is_os(pDstPixmap, pDstPriv))
{
post_process = 1;
if (g_do_dirty_os)
{
LLOGLN(10, ("rdpPolyText16: getting dirty"));
pDstPriv->is_dirty = 1;
pDirtyPriv = pDstPriv;
dirty_type = RDI_IMGLY;
}
else
{
rdpup_switch_os_surface(pDstPriv->rdpindex);
reset_surface = 1;
rdpup_get_pixmap_image_rect(pDstPixmap, &id);
got_id = 1;
}
}
}
else
{
if (pDrawable->type == DRAWABLE_WINDOW)
{
pDstWnd = (WindowPtr)pDrawable;
if (pDstWnd->viewable)
{
post_process = 1;
if (g_do_dirty_ons)
{
LLOGLN(10, ("rdpPolyText16: getting dirty"));
g_screenPriv.is_dirty = 1;
pDirtyPriv = &g_screenPriv;
dirty_type = RDI_IMGLL;
}
else
{
rdpup_get_screen_image_rect(&id);
got_id = 1;
}
}
}
}
if (!post_process)
{
return rv;
}
RegionInit(&reg, NullBox, 0);
if (count == 0)
{
cd = 0;
}
else
{
cd = rdp_get_clip(&reg, pDrawable, pGC);
}
if (cd == 1)
{
if (dirty_type != 0)
{
RegionInit(&reg1, &box, 0);
draw_item_add_img_region(pDirtyPriv, &reg1, GXcopy, dirty_type, TAG_POLYTEXT16);
RegionUninit(&reg1);
}
else if (got_id)
{
rdpup_begin_update();
rdpup_send_area(&id, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1);
rdpup_end_update();
}
}
else if (cd == 2)
{
RegionInit(&reg1, &box, 0);
RegionIntersect(&reg, &reg, &reg1);
num_clips = REGION_NUM_RECTS(&reg);
if (num_clips > 0)
{
if (dirty_type != 0)
{
draw_item_add_img_region(pDirtyPriv, &reg, GXcopy, dirty_type, TAG_POLYTEXT16);
}
else if (got_id)
{
rdpup_begin_update();
for (j = num_clips - 1; j >= 0; j--)
{
box = REGION_RECTS(&reg)[j];
rdpup_send_area(&id, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1);
}
rdpup_end_update();
}
}
RegionUninit(&reg1);
}
RegionUninit(&reg);
if (reset_surface)
{
rdpup_switch_os_surface(-1);
}
return rv;
}

@ -1,29 +0,0 @@
/*
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

@ -1,220 +0,0 @@
/*
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 LLOG(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; } } while (0)
#define LLOGLN(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0)
extern rdpScreenInfoRec g_rdpScreen; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpGCIndex; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpWindowIndex; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpPixmapIndex; /* from rdpmain.c */
extern int g_Bpp; /* from rdpmain.c */
extern ScreenPtr g_pScreen; /* from rdpmain.c */
extern Bool g_wrapPixmap; /* from rdpmain.c */
extern int g_do_dirty_os; /* in rdpmain.c */
extern int g_do_dirty_ons; /* in rdpmain.c */
extern rdpPixmapRec g_screenPriv; /* in rdpmain.c */
extern GCOps g_rdpGCOps; /* from rdpdraw.c */
extern int g_con_number; /* in rdpup.c */
/******************************************************************************/
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)
{
RegionRec reg;
RegionRec reg1;
int num_clips;
int cd;
int j;
int rv;
int got_id;
int dirty_type;
int post_process;
int reset_surface;
BoxRec box;
struct image_data id;
WindowPtr pDstWnd;
PixmapPtr pDstPixmap;
rdpPixmapRec *pDstPriv;
rdpPixmapRec *pDirtyPriv;
LLOGLN(10, ("rdpPolyText8:"));
if (count != 0)
{
GetTextBoundingBox(pDrawable, pGC->font, x, y, count, &box);
}
/* do original call */
rv = rdpPolyText8Org(pDrawable, pGC, x, y, count, chars);
dirty_type = 0;
pDirtyPriv = 0;
post_process = 0;
reset_surface = 0;
got_id = 0;
if (pDrawable->type == DRAWABLE_PIXMAP)
{
pDstPixmap = (PixmapPtr)pDrawable;
pDstPriv = GETPIXPRIV(pDstPixmap);
if (xrdp_is_os(pDstPixmap, pDstPriv))
{
post_process = 1;
if (g_do_dirty_os)
{
LLOGLN(10, ("rdpPolyText8: getting dirty"));
pDstPriv->is_dirty = 1;
pDirtyPriv = pDstPriv;
dirty_type = RDI_IMGLY;
}
else
{
rdpup_switch_os_surface(pDstPriv->rdpindex);
reset_surface = 1;
rdpup_get_pixmap_image_rect(pDstPixmap, &id);
got_id = 1;
}
}
}
else
{
if (pDrawable->type == DRAWABLE_WINDOW)
{
pDstWnd = (WindowPtr)pDrawable;
if (pDstWnd->viewable)
{
post_process = 1;
if (g_do_dirty_ons)
{
LLOGLN(10, ("rdpPolyText8: getting dirty"));
g_screenPriv.is_dirty = 1;
pDirtyPriv = &g_screenPriv;
dirty_type = RDI_IMGLL;
}
else
{
rdpup_get_screen_image_rect(&id);
got_id = 1;
}
}
}
}
if (!post_process)
{
return rv;
}
RegionInit(&reg, NullBox, 0);
if (count == 0)
{
cd = 0;
}
else
{
cd = rdp_get_clip(&reg, pDrawable, pGC);
}
if (cd == 1)
{
if (dirty_type != 0)
{
RegionInit(&reg1, &box, 0);
draw_item_add_img_region(pDirtyPriv, &reg1, GXcopy, dirty_type, TAG_POLYTEXT8);
RegionUninit(&reg1);
}
else if (got_id)
{
rdpup_begin_update();
rdpup_send_area(&id, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1);
rdpup_end_update();
}
}
else if (cd == 2)
{
RegionInit(&reg1, &box, 0);
RegionIntersect(&reg, &reg, &reg1);
num_clips = REGION_NUM_RECTS(&reg);
if (num_clips > 0)
{
if (dirty_type != 0)
{
draw_item_add_img_region(pDirtyPriv, &reg, GXcopy, dirty_type, TAG_POLYTEXT8);
}
else if (got_id)
{
rdpup_begin_update();
for (j = num_clips - 1; j >= 0; j--)
{
box = REGION_RECTS(&reg)[j];
rdpup_send_area(&id, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1);
}
rdpup_end_update();
}
}
RegionUninit(&reg1);
}
RegionUninit(&reg);
if (reset_surface)
{
rdpup_switch_os_surface(-1);
}
return rv;
}

@ -1,29 +0,0 @@
/*
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

@ -1,290 +0,0 @@
/*
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 LLOG(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; } } while (0)
#define LLOGLN(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0)
extern rdpScreenInfoRec g_rdpScreen; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpGCIndex; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpWindowIndex; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpPixmapIndex; /* from rdpmain.c */
extern int g_Bpp; /* from rdpmain.c */
extern ScreenPtr g_pScreen; /* from rdpmain.c */
extern Bool g_wrapPixmap; /* from rdpmain.c */
extern int g_do_dirty_os; /* in rdpmain.c */
extern int g_do_dirty_ons; /* in rdpmain.c */
extern rdpPixmapRec g_screenPriv; /* in rdpmain.c */
extern GCOps g_rdpGCOps; /* from rdpdraw.c */
extern int g_con_number; /* in rdpup.c */
/******************************************************************************/
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)
{
RegionRec clip_reg;
int num_clips;
int cd;
int i;
int j;
int got_id;
int dirty_type;
int post_process;
int reset_surface;
BoxRec box;
xSegment *segs;
int nseg;
struct image_data id;
WindowPtr pDstWnd;
PixmapPtr pDstPixmap;
rdpPixmapRec *pDstPriv;
rdpPixmapRec *pDirtyPriv;
LLOGLN(10, ("rdpPolylines:"));
LLOGLN(10, (" npt %d mode %d x %d y %d", npt, mode,
pDrawable->x, pDrawable->y));
#if 0
LLOGLN(0, (" points"));
for (i = 0; i < npt; i++)
{
LLOGLN(0, (" %d %d", pptInit[i].x, pptInit[i].y));
}
#endif
/* convert lines to line segments */
nseg = npt - 1;
segs = 0;
if (npt > 1)
{
segs = (xSegment *)g_malloc(sizeof(xSegment) * nseg, 0);
segs[0].x1 = pptInit[0].x + pDrawable->x;
segs[0].y1 = pptInit[0].y + pDrawable->y;
if (mode == CoordModeOrigin)
{
segs[0].x2 = pptInit[1].x + pDrawable->x;
segs[0].y2 = pptInit[1].y + pDrawable->y;
for (i = 2; i < npt; i++)
{
segs[i - 1].x1 = segs[i - 2].x2;
segs[i - 1].y1 = segs[i - 2].y2;
segs[i - 1].x2 = pptInit[i].x + pDrawable->x;
segs[i - 1].y2 = pptInit[i].y + pDrawable->y;
}
}
else
{
segs[0].x2 = segs[0].x1 + pptInit[1].x;
segs[0].y2 = segs[0].y1 + pptInit[1].y;
for (i = 2; i < npt; i++)
{
segs[i - 1].x1 = segs[i - 2].x2;
segs[i - 1].y1 = segs[i - 2].y2;
segs[i - 1].x2 = segs[i - 1].x1 + pptInit[i].x;
segs[i - 1].y2 = segs[i - 1].y1 + pptInit[i].y;
}
}
}
else
{
LLOGLN(0, ("rdpPolylines: weird npt [%d]", npt));
}
#if 0
LLOGLN(0, (" segments"));
for (i = 0; i < nseg; i++)
{
LLOGLN(0, (" %d %d %d %d", segs[i].x1, segs[i].y1,
segs[i].x2, segs[i].y2));
}
#endif
/* do original call */
rdpPolylinesOrg(pDrawable, pGC, mode, npt, pptInit);
dirty_type = 0;
pDirtyPriv = 0;
post_process = 0;
reset_surface = 0;
got_id = 0;
if (pDrawable->type == DRAWABLE_PIXMAP)
{
pDstPixmap = (PixmapPtr)pDrawable;
pDstPriv = GETPIXPRIV(pDstPixmap);
if (xrdp_is_os(pDstPixmap, pDstPriv))
{
post_process = 1;
if (g_do_dirty_os)
{
LLOGLN(10, ("rdpPolylines: getting dirty"));
pDstPriv->is_dirty = 1;
pDirtyPriv = pDstPriv;
dirty_type = RDI_IMGLL;
}
else
{
rdpup_switch_os_surface(pDstPriv->rdpindex);
reset_surface = 1;
rdpup_get_pixmap_image_rect(pDstPixmap, &id);
got_id = 1;
}
}
}
else
{
if (pDrawable->type == DRAWABLE_WINDOW)
{
pDstWnd = (WindowPtr)pDrawable;
if (pDstWnd->viewable)
{
post_process = 1;
if (g_do_dirty_ons)
{
LLOGLN(10, ("rdpPolylines: getting dirty"));
g_screenPriv.is_dirty = 1;
pDirtyPriv = &g_screenPriv;
dirty_type = RDI_IMGLL;
}
else
{
rdpup_get_screen_image_rect(&id);
got_id = 1;
}
}
}
}
if (!post_process)
{
g_free(segs);
return;
}
RegionInit(&clip_reg, NullBox, 0);
cd = rdp_get_clip(&clip_reg, pDrawable, pGC);
if (cd == 1)
{
if (segs != 0)
{
if (dirty_type != 0)
{
RegionUninit(&clip_reg);
RegionInit(&clip_reg, NullBox, 0);
RegionAroundSegs(&clip_reg, segs, nseg);
draw_item_add_line_region(pDirtyPriv, &clip_reg, pGC->fgPixel,
pGC->alu, pGC->lineWidth, segs, nseg, 0);
}
else if (got_id)
{
rdpup_begin_update();
rdpup_set_fgcolor(pGC->fgPixel);
rdpup_set_opcode(pGC->alu);
rdpup_set_pen(0, pGC->lineWidth);
for (i = 0; i < nseg; i++)
{
rdpup_draw_line(segs[i].x1, segs[i].y1, segs[i].x2, segs[i].y2);
}
rdpup_set_opcode(GXcopy);
rdpup_end_update();
}
}
}
else if (cd == 2)
{
num_clips = REGION_NUM_RECTS(&clip_reg);
if (nseg != 0 && num_clips > 0)
{
if (dirty_type != 0)
{
draw_item_add_line_region(pDirtyPriv, &clip_reg, pGC->fgPixel,
pGC->alu, pGC->lineWidth, segs, nseg, 0);
}
else if (got_id)
{
rdpup_begin_update();
rdpup_set_fgcolor(pGC->fgPixel);
rdpup_set_opcode(pGC->alu);
rdpup_set_pen(0, pGC->lineWidth);
for (j = num_clips - 1; j >= 0; j--)
{
box = REGION_RECTS(&clip_reg)[j];
rdpup_set_clip(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1);
for (i = 0; i < nseg; i++)
{
rdpup_draw_line(segs[i].x1, segs[i].y1, segs[i].x2, segs[i].y2);
}
}
rdpup_reset_clip();
rdpup_set_opcode(GXcopy);
rdpup_end_update();
}
}
}
g_free(segs);
RegionUninit(&clip_reg);
if (reset_surface)
{
rdpup_switch_os_surface(-1);
}
}

@ -1,29 +0,0 @@
/*
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

@ -1,214 +0,0 @@
/*
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 LLOG(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; } } while (0)
#define LLOGLN(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0)
extern rdpScreenInfoRec g_rdpScreen; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpGCIndex; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpWindowIndex; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpPixmapIndex; /* from rdpmain.c */
extern int g_Bpp; /* from rdpmain.c */
extern ScreenPtr g_pScreen; /* from rdpmain.c */
extern Bool g_wrapPixmap; /* from rdpmain.c */
extern int g_do_dirty_os; /* in rdpmain.c */
extern int g_do_dirty_ons; /* in rdpmain.c */
extern rdpPixmapRec g_screenPriv; /* in rdpmain.c */
extern GCOps g_rdpGCOps; /* from rdpdraw.c */
extern int g_con_number; /* in rdpup.c */
/******************************************************************************/
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)
{
RegionRec clip_reg;
RegionRec box_reg;
RegionRec reg1;
int num_clips;
int cd;
int j;
int got_id;
int dirty_type;
int post_process;
int reset_surface;
BoxRec box;
struct image_data id;
WindowPtr pDstWnd;
PixmapPtr pDstPixmap;
rdpPixmapRec *pDstPriv;
rdpPixmapRec *pDirtyPriv;
LLOGLN(10, ("rdpPushPixels:"));
/* do original call */
rdpPushPixelsOrg(pGC, pBitMap, pDst, w, h, x, y);
dirty_type = 0;
pDirtyPriv = 0;
post_process = 0;
reset_surface = 0;
got_id = 0;
if (pDst->type == DRAWABLE_PIXMAP)
{
pDstPixmap = (PixmapPtr)pDst;
pDstPriv = GETPIXPRIV(pDstPixmap);
if (xrdp_is_os(pDstPixmap, pDstPriv))
{
post_process = 1;
if (g_do_dirty_os)
{
LLOGLN(10, ("rdpPushPixels: getting dirty"));
pDstPriv->is_dirty = 1;
pDirtyPriv = pDstPriv;
dirty_type = RDI_IMGLY;
}
else
{
rdpup_switch_os_surface(pDstPriv->rdpindex);
reset_surface = 1;
rdpup_get_pixmap_image_rect(pDstPixmap, &id);
got_id = 1;
}
}
}
else
{
if (pDst->type == DRAWABLE_WINDOW)
{
pDstWnd = (WindowPtr)pDst;
if (pDstWnd->viewable)
{
post_process = 1;
if (g_do_dirty_ons)
{
LLOGLN(10, ("rdpPushPixels: getting dirty"));
g_screenPriv.is_dirty = 1;
pDirtyPriv = &g_screenPriv;
dirty_type = RDI_IMGLL;
}
else
{
rdpup_get_screen_image_rect(&id);
got_id = 1;
}
}
}
}
if (!post_process)
{
return;
}
memset(&box, 0, sizeof(box));
RegionInit(&clip_reg, NullBox, 0);
cd = rdp_get_clip(&clip_reg, pDst, pGC);
if (cd == 1)
{
if (dirty_type != 0)
{
box.x1 = pDst->x + x;
box.y1 = pDst->y + y;
box.x2 = box.x1 + w;
box.y2 = box.y1 + h;
RegionInit(&reg1, &box, 0);
draw_item_add_img_region(pDirtyPriv, &reg1, GXcopy, dirty_type, TAG_PUSHPIXELS);
RegionUninit(&reg1);
}
else if (got_id)
{
rdpup_begin_update();
rdpup_send_area(0, pDst->x + x, pDst->y + y, w, h);
rdpup_end_update();
}
}
else if (cd == 2)
{
box.x1 = pDst->x + x;
box.y1 = pDst->y + y;
box.x2 = box.x1 + w;
box.y2 = box.y1 + h;
RegionInit(&box_reg, &box, 0);
RegionIntersect(&clip_reg, &clip_reg, &box_reg);
num_clips = REGION_NUM_RECTS(&clip_reg);
if (num_clips > 0)
{
if (dirty_type != 0)
{
RegionInit(&reg1, &box, 0);
draw_item_add_img_region(pDirtyPriv, &clip_reg, GXcopy, dirty_type, TAG_PUSHPIXELS);
RegionUninit(&reg1);
}
else if (got_id)
{
rdpup_begin_update();
for (j = num_clips - 1; j >= 0; j--)
{
box = REGION_RECTS(&clip_reg)[j];
rdpup_send_area(0, box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1);
}
rdpup_end_update();
}
}
RegionUninit(&box_reg);
}
RegionUninit(&clip_reg);
if (reset_surface)
{
rdpup_switch_os_surface(-1);
}
}

@ -1,29 +0,0 @@
/*
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

@ -1,214 +0,0 @@
/*
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 LLOG(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; } } while (0)
#define LLOGLN(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0)
extern rdpScreenInfoRec g_rdpScreen; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpGCIndex; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpWindowIndex; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpPixmapIndex; /* from rdpmain.c */
extern int g_Bpp; /* from rdpmain.c */
extern ScreenPtr g_pScreen; /* from rdpmain.c */
extern Bool g_wrapPixmap; /* from rdpmain.c */
extern int g_do_dirty_os; /* in rdpmain.c */
extern int g_do_dirty_ons; /* in rdpmain.c */
extern rdpPixmapRec g_screenPriv; /* in rdpmain.c */
extern GCOps g_rdpGCOps; /* from rdpdraw.c */
extern int g_con_number; /* in rdpup.c */
/******************************************************************************/
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)
{
RegionRec clip_reg;
int cd;
int j;
int reset_surface;
int post_process;
int got_id;
int dirty_type;
BoxRec box;
struct image_data id;
WindowPtr pDstWnd;
PixmapPtr pDstPixmap;
rdpPixmapRec *pDstPriv;
rdpPixmapRec *pDirtyPriv;
RegionRec reg1;
RegionRec reg2;
LLOGLN(10, ("rdpPutImage:"));
LLOGLN(10, ("rdpPutImage: drawable id 0x%x", (int)(pDst->id)));
LLOGLN(10, ("rdpPutImage: x %d y %d w %d h %d is_window %d", x, y, w, h,
pDst->type == DRAWABLE_WINDOW));
/* do original call */
rdpPutImageOrg(pDst, pGC, depth, x, y, w, h, leftPad, format, pBits);
dirty_type = 0;
pDirtyPriv = 0;
post_process = 0;
reset_surface = 0;
got_id = 0;
if (pDst->type == DRAWABLE_PIXMAP)
{
pDstPixmap = (PixmapPtr)pDst;
pDstPriv = GETPIXPRIV(pDstPixmap);
if (xrdp_is_os(pDstPixmap, pDstPriv))
{
post_process = 1;
if (g_do_dirty_os)
{
LLOGLN(10, ("rdpPutImage: getting dirty"));
pDstPriv->is_dirty = 1;
pDirtyPriv = pDstPriv;
dirty_type = RDI_IMGLY;
}
else
{
rdpup_switch_os_surface(pDstPriv->rdpindex);
reset_surface = 1;
rdpup_get_pixmap_image_rect(pDstPixmap, &id);
got_id = 1;
}
}
}
else
{
if (pDst->type == DRAWABLE_WINDOW)
{
pDstWnd = (WindowPtr)pDst;
if (pDstWnd->viewable)
{
post_process = 1;
if (g_do_dirty_ons)
{
LLOGLN(10, ("rdpPutImage: getting dirty"));
g_screenPriv.is_dirty = 1;
pDirtyPriv = &g_screenPriv;
dirty_type = RDI_IMGLY;
}
else
{
rdpup_get_screen_image_rect(&id);
got_id = 1;
}
}
}
}
if (!post_process)
{
return;
}
RegionInit(&clip_reg, NullBox, 0);
cd = rdp_get_clip(&clip_reg, pDst, pGC);
if (cd == 1)
{
if (dirty_type != 0)
{
box.x1 = pDst->x + x;
box.y1 = pDst->y + y;
box.x2 = box.x1 + w;
box.y2 = box.y1 + h;
RegionInit(&reg1, &box, 0);
draw_item_add_img_region(pDirtyPriv, &reg1, GXcopy, dirty_type, TAG_PUTIMAGE);
RegionUninit(&reg1);
}
else if (got_id)
{
rdpup_begin_update();
rdpup_send_area(&id, pDst->x + x, pDst->y + y, w, h);
rdpup_end_update();
}
}
else if (cd == 2)
{
if (dirty_type != 0)
{
box.x1 = pDst->x + x;
box.y1 = pDst->y + y;
box.x2 = box.x1 + w;
box.y2 = box.y1 + h;
RegionInit(&reg1, &box, 0);
RegionInit(&reg2, NullBox, 0);
RegionCopy(&reg2, &clip_reg);
RegionIntersect(&reg1, &reg1, &reg2);
draw_item_add_img_region(pDirtyPriv, &reg1, GXcopy, dirty_type, TAG_PUTIMAGE);
RegionUninit(&reg1);
RegionUninit(&reg2);
}
else if (got_id)
{
rdpup_begin_update();
for (j = REGION_NUM_RECTS(&clip_reg) - 1; j >= 0; j--)
{
box = REGION_RECTS(&clip_reg)[j];
rdpup_set_clip(box.x1, box.y1, (box.x2 - box.x1), (box.y2 - box.y1));
rdpup_send_area(&id, pDst->x + x, pDst->y + y, w, h);
}
rdpup_reset_clip();
rdpup_end_update();
}
}
RegionUninit(&clip_reg);
if (reset_surface)
{
rdpup_switch_os_surface(-1);
}
}

@ -1,29 +0,0 @@
/*
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

@ -1,172 +0,0 @@
/*
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 LLOG(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; } } while (0)
#define LLOGLN(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0)
extern rdpScreenInfoRec g_rdpScreen; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpGCIndex; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpWindowIndex; /* from rdpmain.c */
extern DevPrivateKeyRec g_rdpPixmapIndex; /* from rdpmain.c */
extern int g_Bpp; /* from rdpmain.c */
extern ScreenPtr g_pScreen; /* from rdpmain.c */
extern Bool g_wrapPixmap; /* from rdpmain.c */
extern int g_do_dirty_os; /* in rdpmain.c */
extern int g_do_dirty_ons; /* in rdpmain.c */
extern rdpPixmapRec g_screenPriv; /* in rdpmain.c */
extern GCOps g_rdpGCOps; /* from rdpdraw.c */
extern int g_con_number; /* in rdpup.c */
/******************************************************************************/
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)
{
RegionRec clip_reg;
int cd;
int got_id;
int dirty_type;
int post_process;
int reset_surface;
struct image_data id;
WindowPtr pDstWnd;
PixmapPtr pDstPixmap;
rdpPixmapRec *pDstPriv;
rdpPixmapRec *pDirtyPriv;
LLOGLN(0, ("rdpSetSpans: todo"));
/* do original call */
rdpSetSpansOrg(pDrawable, pGC, psrc, ppt, pwidth, nspans, fSorted);
dirty_type = 0;
pDirtyPriv = 0;
post_process = 0;
reset_surface = 0;
got_id = 0;
if (pDrawable->type == DRAWABLE_PIXMAP)
{
pDstPixmap = (PixmapPtr)pDrawable;
pDstPriv = GETPIXPRIV(pDstPixmap);
if (xrdp_is_os(pDstPixmap, pDstPriv))
{
post_process = 1;
if (g_do_dirty_os)
{
LLOGLN(10, ("rdpSetSpans: getting dirty"));
pDstPriv->is_dirty = 1;
pDirtyPriv = pDstPriv;
dirty_type = RDI_IMGLY;
}
else
{
rdpup_switch_os_surface(pDstPriv->rdpindex);
reset_surface = 1;
rdpup_get_pixmap_image_rect(pDstPixmap, &id);
got_id = 1;
}
}
}
else
{
if (pDrawable->type == DRAWABLE_WINDOW)
{
pDstWnd = (WindowPtr)pDrawable;
if (pDstWnd->viewable)
{
post_process = 1;
if (g_do_dirty_ons)
{
LLOGLN(10, ("rdpSetSpans: getting dirty"));
g_screenPriv.is_dirty = 1;
pDirtyPriv = &g_screenPriv;
dirty_type = RDI_IMGLL;
}
else
{
rdpup_get_screen_image_rect(&id);
got_id = 1;
}
}
}
}
if (!post_process)
{
return;
}
RegionInit(&clip_reg, NullBox, 0);
cd = rdp_get_clip(&clip_reg, pDrawable, pGC);
if (cd == 1)
{
if (dirty_type != 0)
{
}
else if (got_id)
{
}
}
else if (cd == 2)
{
if (dirty_type != 0)
{
}
else if (got_id)
{
}
}
RegionUninit(&clip_reg);
if (reset_surface)
{
rdpup_switch_os_surface(-1);
}
}

@ -1,29 +0,0 @@
/*
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

File diff suppressed because it is too large Load Diff

@ -1,48 +0,0 @@
/*
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 __RDPDRAW_H
#define __RDPDRAW_H
/******************************************************************************/
#define GC_OP_PROLOGUE(_pGC) \
{ \
priv = (rdpGCPtr)dixGetPrivateAddr(&(pGC->devPrivates), &g_rdpGCIndex); \
oldFuncs = _pGC->funcs; \
(_pGC)->funcs = priv->funcs; \
(_pGC)->ops = priv->ops; \
}
/******************************************************************************/
#define GC_OP_EPILOGUE(_pGC) \
{ \
priv->ops = (_pGC)->ops; \
(_pGC)->funcs = oldFuncs; \
(_pGC)->ops = &g_rdpGCOps; \
}
int
rdp_get_clip(RegionPtr pRegion, DrawablePtr pDrawable, GCPtr pGC);
void
GetTextBoundingBox(DrawablePtr pDrawable, FontPtr font, int x, int y,
int n, BoxPtr pbox);
#endif

@ -1,862 +0,0 @@
/*
Copyright 2012 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.
*/
/*
http://msdn.microsoft.com/en-us/library/cc241863(v=prot.20).aspx
4.6.1 "d" Character
This topic has not yet been rated - Rate this topic
The following shows glyph image data (1 bpp format) for character
"d" extracted from a Cache Glyph (Revision 2) (section 2.2.2.2.1.2.6)
Secondary Drawing Order.
Glyph width = 5 pixels
Glyph height = 9 pixels
Glyph origin = (0, -9), marked with an "X" on the image grid
Bitmap = { 0x08, 0x08, 0x08, 0x78, 0x88, 0x88, 0x88, 0x88, 0x78 }
http://msdn.microsoft.com/en-us/library/cc241864(v=prot.20).aspx
4.6.2 "p" Character
This topic has not yet been rated - Rate this topic
The following shows glyph image data (1 bpp format) for character
"p" extracted from a Cache Glyph (Revision 2) (section 2.2.2.2.1.2.6)
Secondary Drawing Order.
Glyph width = 5 pixels
Glyph height = 8 pixels
Glyph origin = (0, -6), marked with an "X" on the image grid
Bitmap = { 0xF0, 0x88, 0x88, 0x88, 0x88, 0xF0, 0x80, 0x80 }
*/
#include "rdp.h"
#include "rdpdraw.h"
#include "rdpglyph.h"
extern DevPrivateKeyRec g_rdpPixmapIndex; /* from rdpmain.c */
extern int g_do_dirty_os; /* in rdpmain.c */
extern int g_do_alpha_glyphs; /* in rdpmain.c */
extern int g_do_glyph_cache; /* in rdpmain.c */
extern int g_doing_font; /* in rdpmain.c */
extern ScreenPtr g_pScreen; /* in rdpmain.c */
extern rdpScreenInfoRec g_rdpScreen; /* in rdpmain.c */
#define LOG_LEVEL 1
#define LLOG(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; } } while (0)
#define LLOGLN(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0)
struct font_cache
{
int offset;
int baseline;
int width;
int height;
int crc;
int stamp;
};
static struct font_cache g_font_cache[12][256];
static int g_stamp = 0;
/*****************************************************************************/
static void
set_mono_pixel(char* data, int x, int y, int width, int pixel)
{
int start;
int shift;
width = (width + 7) / 8;
start = (y * width) + x / 8;
shift = x % 8;
if (pixel != 0)
{
data[start] = data[start] | (0x80 >> shift);
}
else
{
data[start] = data[start] & ~(0x80 >> shift);
}
}
/*****************************************************************************/
static int
lget_pixel(char* data, int x, int y, int depth, int stride_bytes)
{
int start;
int shift;
if (depth == 1)
{
start = (y * stride_bytes) + x / 8;
shift = x % 8;
return (data[start] & (0x01 << shift)) ? 0xff : 0;
}
else if (depth == 8)
{
return data[y * stride_bytes + x];
}
return 0;
}
/******************************************************************************/
static int
glyph_get_data(ScreenPtr pScreen, GlyphPtr glyph, struct rdp_font_char* rfd)
{
int i;
int j;
int src_xoff;
int src_yoff;
int src_stride_bytes;
int dst_stride_bytes;
int hh;
int ww;
int src_depth;
unsigned char pixel;
PicturePtr pPicture;
pixman_image_t *src;
uint32_t* pi32;
char* pi8;
pPicture = GlyphPicture(glyph)[pScreen->myNum];
if (pPicture == 0)
{
return 0;
}
src = image_from_pict(pPicture, FALSE, &src_xoff, &src_yoff);
if (src == 0)
{
return 0;
}
src_stride_bytes = pixman_image_get_stride(src);
if (g_do_alpha_glyphs)
{
dst_stride_bytes = (glyph->info.width + 3) & ~3;
rfd->bpp = 8;
}
else
{
dst_stride_bytes = (((glyph->info.width + 7) / 8) + 3) & ~3;
rfd->bpp = 1;
}
src_depth = pixman_image_get_depth(src);
ww = pixman_image_get_width(src);
hh = pixman_image_get_height(src);
if ((ww != glyph->info.width) || (hh != glyph->info.height) ||
((src_depth != 1) && (src_depth != 8)))
{
LLOGLN(0, ("glyph_get_data: bad glyph"));
free_pixman_pict(pPicture, src);
return 0;
}
rfd->data_bytes = glyph->info.height * dst_stride_bytes;
rfd->data = (char*)g_malloc(rfd->data_bytes, 1);
rfd->offset = -glyph->info.x;
rfd->baseline = -glyph->info.y;
rfd->width = glyph->info.width;
rfd->height = glyph->info.height;
pi32 = pixman_image_get_data(src);
pi8 = (char*)pi32;
for (j = 0; j < rfd->height; j++)
{
for (i = 0; i < rfd->width; i++)
{
pixel = lget_pixel(pi8, i, j, src_depth, src_stride_bytes);
if (g_do_alpha_glyphs)
{
rfd->data[j * dst_stride_bytes + i] = pixel;
}
else
{
if (pixel > 0x7f)
{
set_mono_pixel(rfd->data, i, j, rfd->width, 1);
}
else
{
set_mono_pixel(rfd->data, i, j, rfd->width, 0);
}
}
}
}
free_pixman_pict(pPicture, src);
return 0;
}
/******************************************************************************/
struct rdp_text*
create_rdp_text(ScreenPtr pScreen, int nlists, GlyphListPtr lists,
GlyphPtr* glyphs)
{
struct rdp_text* rv;
struct rdp_text* rtext;
struct rdp_text* last_rtext;
BoxRec box;
RegionRec reg1;
int n;
int lxoff;
int lyoff;
int count;
int lx;
int ly;
int font_index;
int max_height;
int min_height;
int force_new;
GlyphPtr glyph;
struct rdp_font_char* rfd;
LLOGLN(10, ("create_rdp_text: nlists %d", nlists));
max_height = 0;
min_height = 0x7fffffff;
lx = lists->xOff;
ly = lists->yOff;
lxoff = 0;
lyoff = 0;
force_new = 0;
rtext = (struct rdp_text*)g_malloc(sizeof(struct rdp_text), 1);
rtext->reg = RegionCreate(NullBox, 0);
rtext->flags = 3;
rtext->mixmode = 0;
rtext->x = lx;
rtext->y = ly;
rv = rtext;
last_rtext = rtext;
count = 0;
while (nlists--)
{
LLOGLN(10, ("lists->xOff %d lists->yOff %d", lists->xOff, lists->yOff));
if (count != 0)
{
lx += lists->xOff;
ly += lists->yOff;
force_new = 1;
}
count++;
n = lists->len;
lists++;
while (n--)
{
glyph = *glyphs++;
/* process glyph here */
if ((glyph->info.width > 0) && (glyph->info.height > 0))
{
if (force_new)
{
LLOGLN(10, ("create_rdp_text: too many chars"));
force_new = 0;
rtext = (struct rdp_text*)g_malloc(sizeof(struct rdp_text), 1);
rtext->reg = RegionCreate(NullBox, 0);
rtext->flags = 3;
rtext->mixmode = 0;
rtext->x = lx;
rtext->y = ly;
last_rtext->next = rtext;
last_rtext = rtext;
lxoff = 0;
lyoff = 0;
}
LLOGLN(10, ("x %d y %d width %d height %d xOff %d yOff %d "
"num_chars %d lxoff %d lyoff %d lx %d ly %d",
glyph->info.x, glyph->info.y,
glyph->info.width, glyph->info.height,
glyph->info.xOff, glyph->info.yOff, rtext->num_chars,
lxoff, lyoff, lx, ly));
rfd = (struct rdp_font_char*)g_malloc(sizeof(struct rdp_font_char), 1);
rtext->chars[rtext->num_chars] = rfd;
box.x1 = lx - glyph->info.x;
box.y1 = ly - glyph->info.y;
box.x2 = box.x1 + glyph->info.width;
box.y2 = box.y1 + glyph->info.height;
if (glyph->info.height > max_height)
{
max_height = glyph->info.height;
}
if (glyph->info.height < min_height)
{
min_height = glyph->info.height;
}
RegionInit(&reg1, &box, 0);
RegionUnion(rtext->reg, &reg1, rtext->reg);
RegionUninit(&reg1);
glyph_get_data(pScreen, glyph, rfd);
rfd->incby = lxoff;
lxoff = glyph->info.xOff;
lyoff = glyph->info.yOff;
rtext->num_chars++;
if (rtext->num_chars > 63)
{
force_new = 1;
}
}
else
{
lxoff += glyph->info.xOff;
lyoff += glyph->info.yOff;
}
lx += glyph->info.xOff;
ly += glyph->info.yOff;
}
}
if (max_height > 10)
{
font_index = 8;
}
else if (max_height < 7)
{
font_index = 6;
}
else
{
font_index = 7;
}
LLOGLN(10, ("create_rdp_text: min_height %d max_height %d font_index %d",
min_height, max_height, font_index));
rtext = rv;
while (rtext != 0)
{
rtext->font = font_index;
rtext = rtext->next;
}
return rv;
}
/******************************************************************************/
int
delete_rdp_text(struct rdp_text* rtext)
{
int index;
if (rtext == 0)
{
return 0;
}
for (index = 0; index < rtext->num_chars; index++)
{
if (rtext->chars[index] != 0)
{
g_free(rtext->chars[index]->data);
g_free(rtext->chars[index]);
}
}
RegionDestroy(rtext->reg);
delete_rdp_text(rtext->next);
g_free(rtext);
return 0;
}
/******************************************************************************/
static int
get_color(PicturePtr pPicture)
{
int src_xoff;
int src_yoff;
int rv;
uint32_t* pi32;
pixman_image_t *src;
src = image_from_pict(pPicture, FALSE, &src_xoff, &src_yoff);
if (src == 0)
{
return 0;
}
pi32 = pixman_image_get_data(src);
if (pi32 == 0)
{
return 0;
}
rv = *pi32;
LLOGLN(10, ("get_color: 0x%8.8x width %d height %d ", rv,
pixman_image_get_width(src),
pixman_image_get_height(src)));
free_pixman_pict(pPicture, src);
return rv;
}
/******************************************************************************/
static int
find_or_add_char(int font, struct rdp_font_char* rfd)
{
int crc;
int index;
int char_index;
int oldest;
crc = get_crc(rfd->data, rfd->data_bytes);
LLOGLN(10, ("find_or_add_char: crc 0x%8.8x", crc));
char_index = 0;
oldest = 0x7fffffff;
for (index = 0; index < 250; index++)
{
if ((g_font_cache[font][index].crc == crc) &&
(g_font_cache[font][index].width == rfd->width) &&
(g_font_cache[font][index].height == rfd->height) &&
(g_font_cache[font][index].offset == rfd->offset) &&
(g_font_cache[font][index].baseline == rfd->baseline))
{
g_stamp++;
g_font_cache[font][index].stamp = g_stamp;
LLOGLN(10, ("find_or_add_char: found char at %d %d", font, index));
return index;
}
if (g_font_cache[font][index].stamp < oldest)
{
oldest = g_font_cache[font][index].stamp;
char_index = index;
}
}
g_stamp++;
g_font_cache[font][char_index].stamp = g_stamp;
g_font_cache[font][char_index].crc = crc;
g_font_cache[font][char_index].width = rfd->width;
g_font_cache[font][char_index].height = rfd->height;
g_font_cache[font][char_index].offset = rfd->offset;
g_font_cache[font][char_index].baseline = rfd->baseline;
LLOGLN(10, ("find_or_add_char: adding char at %d %d", font, char_index));
if (rfd->bpp == 8)
{
rdpup_add_char_alpha(font, char_index, rfd->offset, rfd->baseline,
rfd->width, rfd->height,
rfd->data, rfd->data_bytes);
}
else
{
rdpup_add_char(font, char_index, rfd->offset, rfd->baseline,
rfd->width, rfd->height,
rfd->data, rfd->data_bytes);
}
return char_index;
}
/******************************************************************************/
int
rdp_text_chars_to_data(struct rdp_text* rtext)
{
int index;
int data_bytes;
int char_index;
struct rdp_font_char* rfd;
LLOGLN(10, ("rdp_text_chars_to_data: rtext->num_chars %d", rtext->num_chars));
data_bytes = 0;
for (index = 0; index < rtext->num_chars; index++)
{
rfd = rtext->chars[index];
if (rfd == 0)
{
LLOGLN(0, ("rdp_text_chars_to_data: error rfd is nil"));
continue;
}
char_index = find_or_add_char(rtext->font, rfd);
rtext->data[data_bytes] = char_index;
data_bytes++;
if (rfd->incby > 127)
{
rtext->data[data_bytes] = 0x80;
data_bytes++;
rtext->data[data_bytes] = (rfd->incby >> 0) & 0xff;
data_bytes++;
rtext->data[data_bytes] = (rfd->incby >> 8) & 0xff;
data_bytes++;
}
else
{
rtext->data[data_bytes] = rfd->incby;
data_bytes++;
}
}
rtext->data_bytes = data_bytes;
return 0;
}
/******************************************************************************/
/*
typedef struct _GlyphList {
INT16 xOff;
INT16 yOff;
CARD8 len;
PictFormatPtr format;
} GlyphListRec, *GlyphListPtr;
*/
/* see glyphstr.h but the following is not in there
typedef struct _XGlyphInfo {
unsigned short width;
unsigned short height;
short x;
short y;
short xOff;
short yOff;
} XGlyphInfo;
*/
static void
rdpGlyphu(CARD8 op, PicturePtr pSrc, PicturePtr pDst,
PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc,
int nlists, GlyphListPtr lists, GlyphPtr* glyphs,
BoxPtr extents)
{
BoxRec box;
RegionRec reg1;
RegionRec reg2;
DrawablePtr p;
int dirty_type;
int j;
int num_clips;
int post_process;
int reset_surface;
int got_id;
int fg_color;
WindowPtr pDstWnd;
PixmapPtr pDstPixmap;
rdpPixmapRec* pDstPriv;
rdpPixmapRec* pDirtyPriv;
struct image_data id;
struct rdp_text* rtext;
struct rdp_text* trtext;
LLOGLN(10, ("rdpGlyphu: xSrc %d ySrc %d", xSrc, ySrc));
p = pDst->pDrawable;
dirty_type = 0;
pDirtyPriv = 0;
post_process = 0;
reset_surface = 0;
got_id = 0;
if (p->type == DRAWABLE_PIXMAP)
{
pDstPixmap = (PixmapPtr)p;
pDstPriv = GETPIXPRIV(pDstPixmap);
if (XRDP_IS_OS(pDstPriv))
{
rdpup_check_dirty(pDstPixmap, pDstPriv);
post_process = 1;
if (g_do_dirty_os)
{
LLOGLN(10, ("rdpGlyphu: getting dirty"));
pDstPriv->is_dirty = 1;
dirty_type = RDI_IMGLL;
pDirtyPriv = pDstPriv;
}
else
{
rdpup_switch_os_surface(pDstPriv->rdpindex);
reset_surface = 1;
rdpup_get_pixmap_image_rect(pDstPixmap, &id);
got_id = 1;
LLOGLN(10, ("rdpGlyphu: offscreen"));
}
}
}
else
{
if (p->type == DRAWABLE_WINDOW)
{
pDstWnd = (WindowPtr)p;
if (pDstWnd->viewable)
{
post_process = 1;
rdpup_get_screen_image_rect(&id);
got_id = 1;
LLOGLN(10, ("rdpGlyphu: screen"));
}
}
}
if (!post_process)
{
return;
}
rtext = create_rdp_text(pDst->pDrawable->pScreen, nlists, lists, glyphs);
if (rtext == 0)
{
LLOGLN(0, ("rdpGlyphu: create_rdp_text failed"));
return;
}
fg_color = get_color(pSrc);
LLOGLN(10, ("rdpGlyphu: pDst->clientClipType %d pCompositeClip %p",
pDst->clientClipType, pDst->pCompositeClip));
if (pDst->pCompositeClip != 0)
{
box.x1 = p->x + extents->x1;
box.y1 = p->y + extents->y1;
box.x2 = p->x + extents->x2;
box.y2 = p->y + extents->y2;
RegionInit(&reg1, &box, 0);
RegionInit(&reg2, NullBox, 0);
RegionCopy(&reg2, pDst->pCompositeClip);
RegionIntersect(&reg1, &reg1, &reg2);
if (dirty_type != 0)
{
LLOGLN(10, ("1"));
draw_item_add_text_region(pDirtyPriv, &reg1, fg_color, GXcopy, rtext);
rtext = 0;
}
else if (got_id)
{
num_clips = REGION_NUM_RECTS(&reg1);
if (num_clips > 0)
{
LLOGLN(10, (" num_clips %d", num_clips));
rdpup_begin_update();
rdpup_set_fgcolor(fg_color);
trtext = rtext;
while (trtext != 0)
{
rdp_text_chars_to_data(trtext);
for (j = num_clips - 1; j >= 0; j--)
{
box = REGION_RECTS(&reg1)[j];
LLOGLN(10, ("2"));
rdpup_set_clip(box.x1, box.y1, box.x2 - box.x1, box.y2 - box.y1);
LLOGLN(10, ("rdpGlyphu: rdpup_draw_text"));
box = RegionExtents(trtext->reg)[0];
rdpup_draw_text(trtext->font, trtext->flags, trtext->mixmode,
box.x1 + p->x, box.y1 + p->y,
box.x2 + p->x, box.y2 + p->y,
//box.x1 + p->x, box.y1 + p->y,
//box.x2 + p->x, box.y2 + p->y,
0, 0, 0, 0,
trtext->x + p->x, trtext->y + p->y,
trtext->data, trtext->data_bytes);
}
trtext = trtext->next;
}
rdpup_reset_clip();
rdpup_end_update();
}
}
RegionUninit(&reg1);
RegionUninit(&reg2);
}
else
{
box.x1 = p->x + extents->x1;
box.y1 = p->y + extents->y1;
box.x2 = p->x + extents->x2;
box.y2 = p->y + extents->y2;
if (dirty_type != 0)
{
RegionInit(&reg1, &box, 0);
LLOGLN(10, ("3"));
draw_item_add_text_region(pDirtyPriv, &reg1, fg_color, GXcopy, rtext);
rtext = 0;
RegionUninit(&reg1);
}
else if (got_id)
{
rdpup_begin_update();
LLOGLN(10, ("4"));
rdpup_set_fgcolor(fg_color);
trtext = rtext;
while (trtext != 0)
{
LLOGLN(10, ("rdpGlyphu: rdpup_draw_text"));
rdp_text_chars_to_data(trtext);
box = RegionExtents(trtext->reg)[0];
rdpup_draw_text(trtext->font, trtext->flags, trtext->mixmode,
box.x1 + p->x, box.y1 + p->y,
box.x2 + p->x, box.y2 + p->y,
//box.x1 + p->x, box.y1 + p->y,
//box.x2 + p->x, box.y2 + p->y,
0, 0, 0, 0,
trtext->x + p->x, trtext->y + p->y,
trtext->data, trtext->data_bytes);
trtext = trtext->next;
}
rdpup_end_update();
}
}
if (reset_surface)
{
rdpup_switch_os_surface(-1);
}
delete_rdp_text(rtext);
}
/******************************************************************************/
static void
GlyphExtents(int nlist, GlyphListPtr list, GlyphPtr* glyphs, BoxPtr extents)
{
int x1;
int x2;
int y1;
int y2;
int n;
int x;
int y;
GlyphPtr glyph;
x = 0;
y = 0;
extents->x1 = MAXSHORT;
extents->x2 = MINSHORT;
extents->y1 = MAXSHORT;
extents->y2 = MINSHORT;
while (nlist--)
{
x += list->xOff;
y += list->yOff;
n = list->len;
list++;
while (n--)
{
glyph = *glyphs++;
x1 = x - glyph->info.x;
if (x1 < MINSHORT)
{
x1 = MINSHORT;
}
y1 = y - glyph->info.y;
if (y1 < MINSHORT)
{
y1 = MINSHORT;
}
x2 = x1 + glyph->info.width;
if (x2 > MAXSHORT)
{
x2 = MAXSHORT;
}
y2 = y1 + glyph->info.height;
if (y2 > MAXSHORT)
{
y2 = MAXSHORT;
}
if (x1 < extents->x1)
{
extents->x1 = x1;
}
if (x2 > extents->x2)
{
extents->x2 = x2;
}
if (y1 < extents->y1)
{
extents->y1 = y1;
}
if (y2 > extents->y2)
{
extents->y2 = y2;
}
x += glyph->info.xOff;
y += glyph->info.yOff;
}
}
}
/******************************************************************************/
static void
rdpGlypht(CARD8 op, PicturePtr pSrc, PicturePtr pDst,
PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc,
int nlists, GlyphListPtr lists, GlyphPtr* glyphs)
{
BoxRec extents;
GlyphExtents(nlists, lists, glyphs, &extents);
if ((extents.x2 <= extents.x1) || (extents.y2 <= extents.y1))
{
return;
}
rdpGlyphu(op, pSrc, pDst, maskFormat, xSrc, ySrc, nlists, lists,
glyphs, &extents);
}
/******************************************************************************/
/* make sure no glyph is too big */
/* returns boolean */
static int
rdpGlyphCheck(int nlist, GlyphListPtr list, GlyphPtr* glyphs)
{
int n;
GlyphPtr glyph;
while (nlist--)
{
n = list->len;
list++;
while (n--)
{
glyph = *glyphs++;
if ((glyph->info.width * glyph->info.height) > 8192)
{
LLOGLN(10, ("rdpGlyphCheck: too big"));
return 0;
}
}
}
return 1;
}
/******************************************************************************/
void
rdpGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst,
PictFormatPtr maskFormat,
INT16 xSrc, INT16 ySrc, int nlists, GlyphListPtr lists,
GlyphPtr* glyphs)
{
PictureScreenPtr ps;
LLOGLN(10, ("rdpGlyphs: op %d xSrc %d ySrc %d maskFormat %p",
op, xSrc, ySrc, maskFormat));
LLOGLN(10, ("rdpGlyphs: g_do_glyph_cache %d", g_do_glyph_cache));
if (g_do_glyph_cache && rdpGlyphCheck(nlists, lists, glyphs))
{
g_doing_font = 2;
rdpGlypht(op, pSrc, pDst, maskFormat, xSrc, ySrc, nlists, lists, glyphs);
ps = GetPictureScreen(g_pScreen);
ps->Glyphs = g_rdpScreen.Glyphs;
ps->Glyphs(op, pSrc, pDst, maskFormat, xSrc, ySrc,
nlists, lists, glyphs);
ps->Glyphs = rdpGlyphs;
}
else
{
g_doing_font = 1;
rdpup_set_hints(1, 1);
ps = GetPictureScreen(g_pScreen);
ps->Glyphs = g_rdpScreen.Glyphs;
ps->Glyphs(op, pSrc, pDst, maskFormat, xSrc, ySrc,
nlists, lists, glyphs);
ps->Glyphs = rdpGlyphs;
rdpup_set_hints(0, 1);
}
g_doing_font = 0;
LLOGLN(10, ("rdpGlyphs: out"));
}
/******************************************************************************/
int
rdpGlyphInit(void)
{
memset(&g_font_cache, 0, sizeof(g_font_cache));
return 0;
}

@ -1,64 +0,0 @@
/*
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.
*/
#ifndef __RDPGLYPH_H
#define __RDPGLYPH_H
struct rdp_font_char
{
int offset; /* x */
int baseline; /* y */
int width; /* cx */
int height; /* cy */
int incby;
int bpp;
char* data;
int data_bytes;
};
struct rdp_text
{
RegionPtr reg;
int font;
int x;
int y;
int flags;
int mixmode;
char data[256];
int data_bytes;
struct rdp_font_char* chars[256];
int num_chars;
struct rdp_text* next;
};
int
delete_rdp_text(struct rdp_text* rtext);
int
rdp_text_chars_to_data(struct rdp_text* rtext);
void
rdpGlyphs(CARD8 op, PicturePtr pSrc, PicturePtr pDst,
PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc,
int nlists, GlyphListPtr lists, GlyphPtr* glyphs);
int
rdpGlyphInit(void);
#endif

@ -1,987 +0,0 @@
/*
Copyright 2005-2014 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.
keyboard and mouse stuff
*/
/* control notes */
/* rdesktop sends control before scan code 69 but it doesn't set the
flags right so control down is used to determine between pause and
num lock */
/* this should be fixed in rdesktop */
/* g_pause_spe flag for special control sent by ms client before scan code
69 is sent to tell that it's pause, not num lock. both pause and num
lock use scan code 69 */
/* tab notes */
/* mstsc send tab up without a tab down to mark the mstsc has gained focus
this should make sure control alt and shift are all up
rdesktop does not do this */
/* this should be fixed in rdesktop */
#include "rdp.h"
#include <sys/types.h>
#include <sys/wait.h>
#include "rdpkeyboard.h"
#include "rdpkeyboardbase.h"
#include "rdpkeyboardevdev.h"
#define LOG_LEVEL 1
#define LLOG(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; } } while (0)
#define LLOGLN(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0)
extern ScreenPtr g_pScreen; /* in rdpmain.c */
extern DeviceIntPtr g_pointer; /* in rdpmain.c */
extern DeviceIntPtr g_keyboard; /* in rdpmain.c */
extern rdpScreenInfoRec g_rdpScreen; /* from rdpmain.c */
extern int g_shift_down; /* in rdpmain.c */
extern int g_alt_down; /* in rdpmain.c */
extern int g_ctrl_down; /* in rdpmain.c */
static int g_old_button_mask = 0;
static int g_old_x = 0;
static int g_old_y = 0;
/* this is toggled every time num lock key is released, not like the
above *_down vars */
static int g_scroll_lock_down = 0;
static OsTimerPtr g_kbtimer = 0;
static OsTimerPtr g_timer = 0;
static int g_x = 0;
static int g_y = 0;
static int g_timer_scheduled = 0;
static int g_delay_motion = 1; /* turn on or off */
static int g_use_evdev = 0;
/* Copied from Xvnc/lib/font/util/utilbitmap.c */
static unsigned char g_reverse_byte[0x100] =
{
0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff
};
#if 0
/******************************************************************************/
static void
rdpSendBell(void)
{
LLOGLN(10, ("rdpSendBell:"));
}
#endif
/******************************************************************************/
void
KbdDeviceOn(void)
{
LLOGLN(10, ("KbdDeviceOn:"));
}
/******************************************************************************/
void
KbdDeviceOff(void)
{
LLOGLN(10, ("KbdDeviceOff:"));
}
/******************************************************************************/
void
rdpBell(int volume, DeviceIntPtr pDev, pointer ctrl, int cls)
{
LLOGLN(0, ("rdpBell:"));
}
/******************************************************************************/
static CARD32
rdpInDeferredUpdateCallback(OsTimerPtr timer, CARD32 now, pointer arg)
{
LLOGLN(10, ("rdpInDeferredUpdateCallback:"));
/* our keyboard device */
XkbSetRepeatKeys(g_keyboard, -1, AutoRepeatModeOff);
/* the main one for the server */
XkbSetRepeatKeys(inputInfo.keyboard, -1, AutoRepeatModeOff);
return 0;
}
/******************************************************************************/
void
rdpChangeKeyboardControl(DeviceIntPtr pDev, KeybdCtrl *ctrl)
{
XkbControlsPtr ctrls;
LLOGLN(0, ("rdpChangeKeyboardControl:"));
ctrls = 0;
if (pDev != 0)
{
if (pDev->key != 0)
{
if (pDev->key->xkbInfo != 0)
{
if (pDev->key->xkbInfo->desc != 0)
{
if (pDev->key->xkbInfo->desc->ctrls != 0)
{
ctrls = pDev->key->xkbInfo->desc->ctrls;
}
}
}
}
}
if (ctrls != 0)
{
if (ctrls->enabled_ctrls & XkbRepeatKeysMask)
{
LLOGLN(10, ("rdpChangeKeyboardControl: autoRepeat on"));
/* schedule to turn off the autorepeat after 100 ms so any app
* polling it will be happy it's on */
g_kbtimer = TimerSet(g_kbtimer, 0, 100,
rdpInDeferredUpdateCallback, 0);
}
else
{
LLOGLN(10, ("rdpChangeKeyboardControl: autoRepeat off"));
}
}
}
/******************************************************************************/
/*
0x00000401 Arabic (101)
0x00000402 Bulgarian
0x00000404 Chinese (Traditional) - US Keyboard
0x00000405 Czech
0x00000406 Danish
0x00000407 German
0x00000408 Greek
0x00000409 US
0x0000040A Spanish
0x0000040B Finnish
0x0000040C French
0x0000040D Hebrew
0x0000040E Hungarian
0x0000040F Icelandic
0x00000410 Italian
0x00000411 Japanese
0x00000412 Korean
0x00000413 Dutch
0x00000414 Norwegian
0x00000415 Polish (Programmers)
0x00000416 Portuguese (Brazilian ABNT)
0x00000418 Romanian
0x00000419 Russian
0x0000041A Croatian
0x0000041B Slovak
0x0000041C Albanian
0x0000041D Swedish
0x0000041E Thai Kedmanee
0x0000041F Turkish Q
0x00000420 Urdu
0x00000422 Ukrainian
0x00000423 Belarusian
0x00000424 Slovenian
0x00000425 Estonian
0x00000426 Latvian
0x00000427 Lithuanian IBM
0x00000429 Farsi
0x0000042A Vietnamese
0x0000042B Armenian Eastern
0x0000042C Azeri Latin
0x0000042F FYRO Macedonian
0x00000437 Georgian
0x00000438 Faroese
0x00000439 Devanagari - INSCRIPT
0x0000043A Maltese 47-key
0x0000043B Norwegian with Sami
0x0000043F Kazakh
0x00000440 Kyrgyz Cyrillic
0x00000444 Tatar
0x00000445 Bengali
0x00000446 Punjabi
0x00000447 Gujarati
0x00000449 Tamil
0x0000044A Telugu
0x0000044B Kannada
0x0000044C Malayalam
0x0000044E Marathi
0x00000450 Mongolian Cyrillic
0x00000452 United Kingdom Extended
0x0000045A Syriac
0x00000461 Nepali
0x00000463 Pashto
0x00000465 Divehi Phonetic
0x0000046E Luxembourgish
0x00000481 Maori
0x00000804 Chinese (Simplified) - US Keyboard
0x00000807 Swiss German
0x00000809 United Kingdom
0x0000080A Latin American
0x0000080C Belgian French
0x00000813 Belgian (Period)
0x00000816 Portuguese
0x0000081A Serbian (Latin)
0x0000082C Azeri Cyrillic
0x0000083B Swedish with Sami
0x00000843 Uzbek Cyrillic
0x0000085D Inuktitut Latin
0x00000C0C Canadian French (legacy)
0x00000C1A Serbian (Cyrillic)
0x00001009 Canadian French
0x0000100C Swiss French
0x0000141A Bosnian
0x00001809 Irish
0x0000201A Bosnian Cyrillic
*/
/******************************************************************************/
int
rdpLoadLayout(struct xrdp_client_info *client_info)
{
XkbRMLVOSet set;
XkbSrvInfoPtr xkbi;
XkbDescPtr xkb;
KeySymsPtr keySyms;
DeviceIntPtr pDev;
KeyCode first_key;
CARD8 num_keys;
int keylayout = client_info->keylayout;
LLOGLN(0, ("rdpLoadLayout: keylayout 0x%8.8x variant %s display %s",
keylayout, client_info->variant, display));
memset(&set, 0, sizeof(set));
if (g_use_evdev)
{
set.rules = "evdev";
}
else
{
set.rules = "base";
}
set.model = "pc105";
set.layout = "us";
set.variant = "";
set.options = "";
if (strlen(client_info->model) > 0)
{
set.model = client_info->model;
}
if (strlen(client_info->variant) > 0)
{
set.variant = client_info->variant;
}
if (strlen(client_info->layout) > 0)
{
set.layout = client_info->layout;
}
if (strlen(client_info->options) > 0)
{
set.options = client_info->options;
}
retry:
/* free some stuff so we can call InitKeyboardDeviceStruct again */
xkbi = g_keyboard->key->xkbInfo;
xkb = xkbi->desc;
XkbFreeKeyboard(xkb, 0, TRUE);
free(xkbi);
g_keyboard->key->xkbInfo = NULL;
free(g_keyboard->kbdfeed);
g_keyboard->kbdfeed = NULL;
free(g_keyboard->key);
g_keyboard->key = NULL;
/* init keyboard and reload the map */
if (!InitKeyboardDeviceStruct(g_keyboard, &set, rdpBell,
rdpChangeKeyboardControl))
{
LLOGLN(0, ("rdpLoadLayout: InitKeyboardDeviceStruct failed"));
return 1;
}
/* notify the X11 clients eg. X_ChangeKeyboardMapping */
keySyms = XkbGetCoreMap(g_keyboard);
if (keySyms)
{
first_key = keySyms->minKeyCode;
num_keys = (keySyms->maxKeyCode - keySyms->minKeyCode) + 1;
XkbApplyMappingChange(g_keyboard, keySyms, first_key, num_keys,
NULL, serverClient);
for (pDev = inputInfo.devices; pDev; pDev = pDev->next)
{
if ((pDev->coreEvents || pDev == inputInfo.keyboard) && pDev->key)
{
XkbApplyMappingChange(pDev, keySyms, first_key, num_keys,
NULL, serverClient);
}
}
}
else
{
/* sometimes, variant doesn't support all layouts */
set.variant = "";
goto retry;
}
return 0;
}
/******************************************************************************/
int
rdpKeybdProc(DeviceIntPtr pDevice, int onoff)
{
DevicePtr pDev;
XkbRMLVOSet set;
int ok;
LLOGLN(10, ("rdpKeybdProc:"));
pDev = (DevicePtr)pDevice;
switch (onoff)
{
case DEVICE_INIT:
LLOGLN(10, ("rdpKeybdProc: DEVICE_INIT"));
memset(&set, 0, sizeof(set));
if (g_use_evdev)
{
set.rules = "evdev";
}
else
{
set.rules = "base";
}
set.model = "pc105";
set.layout = "us";
set.variant = "";
set.options = "";
ok = InitKeyboardDeviceStruct(pDevice, &set, rdpBell,
rdpChangeKeyboardControl);
LLOGLN(10, ("rdpKeybdProc: InitKeyboardDeviceStruct %d", ok));
break;
case DEVICE_ON:
LLOGLN(10, ("rdpKeybdProc: DEVICE_ON"));
pDev->on = 1;
KbdDeviceOn();
break;
case DEVICE_OFF:
LLOGLN(10, ("rdpKeybdProc: DEVICE_OFF"));
pDev->on = 0;
KbdDeviceOff();
break;
case DEVICE_CLOSE:
LLOGLN(10, ("rdpKeybdProc: DEVICE_CLOSE"));
if (pDev->on)
{
pDev->on = 0;
KbdDeviceOff();
}
break;
}
return Success;
}
/******************************************************************************/
void
PtrDeviceControl(DeviceIntPtr dev, PtrCtrl *ctrl)
{
LLOGLN(10, ("PtrDeviceControl:"));
}
/******************************************************************************/
void
PtrDeviceInit(void)
{
LLOGLN(10, ("PtrDeviceInit:"));
}
/******************************************************************************/
void
PtrDeviceOn(DeviceIntPtr pDev)
{
LLOGLN(10, ("PtrDeviceOn:"));
}
/******************************************************************************/
void
PtrDeviceOff(void)
{
LLOGLN(10, ("PtrDeviceOff:"));
}
/******************************************************************************/
static void
rdpMouseCtrl(DeviceIntPtr pDevice, PtrCtrl *pCtrl)
{
LLOGLN(0, ("rdpMouseCtrl:"));
}
/******************************************************************************/
int
rdpMouseProc(DeviceIntPtr pDevice, int onoff)
{
BYTE map[8];
DevicePtr pDev;
Atom btn_labels[8];
Atom axes_labels[2];
LLOGLN(10, ("rdpMouseProc:"));
pDev = (DevicePtr)pDevice;
switch (onoff)
{
case DEVICE_INIT:
PtrDeviceInit();
map[0] = 0;
map[1] = 1;
map[2] = 2;
map[3] = 3;
map[4] = 4;
map[5] = 5;
map[6] = 6;
map[7] = 7;
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);
btn_labels[5] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_LEFT);
btn_labels[6] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_RIGHT);
axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_X);
axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_REL_Y);
InitPointerDeviceStruct(pDev, map, 7, btn_labels, rdpMouseCtrl,
GetMotionHistorySize(), 2, axes_labels);
break;
case DEVICE_ON:
pDev->on = 1;
PtrDeviceOn(pDevice);
break;
case DEVICE_OFF:
pDev->on = 0;
PtrDeviceOff();
break;
case DEVICE_CLOSE:
if (pDev->on)
{
PtrDeviceOff();
}
break;
}
return Success;
}
/******************************************************************************/
Bool
rdpCursorOffScreen(ScreenPtr *ppScreen, int *x, int *y)
{
LLOGLN(10, ("rdpCursorOffScreen:"));
return 0;
}
/******************************************************************************/
void
rdpCrossScreen(ScreenPtr pScreen, Bool entering)
{
LLOGLN(10, ("rdpCrossScreen:"));
}
/******************************************************************************/
void
rdpPointerWarpCursor(DeviceIntPtr pDev, ScreenPtr pScr, int x, int y)
{
LLOGLN(0, ("rdpPointerWarpCursor:"));
miPointerWarpCursor(pDev, pScr, x, y);
}
/******************************************************************************/
void
rdpPointerEnqueueEvent(DeviceIntPtr pDev, InternalEvent *event)
{
LLOGLN(0, ("rdpPointerEnqueueEvent:"));
}
/******************************************************************************/
void
rdpPointerNewEventScreen(DeviceIntPtr pDev, ScreenPtr pScr, Bool fromDIX)
{
LLOGLN(0, ("rdpPointerNewEventScreen:"));
}
/******************************************************************************/
Bool
rdpSpriteRealizeCursor(DeviceIntPtr pDev, ScreenPtr pScr, CursorPtr pCurs)
{
LLOGLN(10, ("rdpSpriteRealizeCursor:"));
return 1;
}
/******************************************************************************/
Bool
rdpSpriteUnrealizeCursor(DeviceIntPtr pDev, ScreenPtr pScr, CursorPtr pCurs)
{
LLOGLN(10, ("rdpSpriteUnrealizeCursor:"));
return 1;
}
/******************************************************************************/
int
get_pixel_safe(char *data, int x, int y, int width, int height, int bpp)
{
int start;
int shift;
int c;
unsigned int *src32;
if (x < 0)
{
return 0;
}
if (y < 0)
{
return 0;
}
if (x >= width)
{
return 0;
}
if (y >= height)
{
return 0;
}
if (bpp == 1)
{
width = (width + 7) / 8;
start = (y * width) + x / 8;
shift = x % 8;
c = (unsigned char)(data[start]);
#if (X_BYTE_ORDER == X_LITTLE_ENDIAN)
return (g_reverse_byte[c] & (0x80 >> shift)) != 0;
#else
return (c & (0x80 >> shift)) != 0;
#endif
}
else if (bpp == 32)
{
src32 = (unsigned int*)data;
return src32[y * width + x];
}
return 0;
}
/******************************************************************************/
void
set_pixel_safe(char *data, int x, int y, int width, int height, int bpp,
int pixel)
{
int start;
int shift;
unsigned int *dst32;
if (x < 0)
{
return;
}
if (y < 0)
{
return;
}
if (x >= width)
{
return;
}
if (y >= height)
{
return;
}
if (bpp == 1)
{
width = (width + 7) / 8;
start = (y * width) + x / 8;
shift = x % 8;
if (pixel & 1)
{
data[start] = data[start] | (0x80 >> shift);
}
else
{
data[start] = data[start] & ~(0x80 >> shift);
}
}
else if (bpp == 24)
{
*(data + (3 * (y * width + x)) + 0) = pixel >> 0;
*(data + (3 * (y * width + x)) + 1) = pixel >> 8;
*(data + (3 * (y * width + x)) + 2) = pixel >> 16;
}
else if (bpp == 32)
{
dst32 = (unsigned int*)data;
dst32[y * width + x] = pixel;
}
}
/******************************************************************************/
void
rdpSpriteSetCursor(DeviceIntPtr pDev, ScreenPtr pScr, CursorPtr pCurs,
int x, int y)
{
char cur_data[32 * (32 * 4)];
char cur_mask[32 * (32 / 8)];
char *mask;
char *data;
int i;
int j;
int w;
int h;
int p;
int xhot;
int yhot;
int paddedRowBytes;
int fgcolor;
int bgcolor;
int bpp;
if (pCurs == 0)
{
return;
}
if (pCurs->bits == 0)
{
return;
}
w = pCurs->bits->width;
h = pCurs->bits->height;
if ((pCurs->bits->argb != 0) &&
(g_rdpScreen.client_info.pointer_flags & 1))
{
bpp = 32;
paddedRowBytes = PixmapBytePad(w, 32);
xhot = pCurs->bits->xhot;
yhot = pCurs->bits->yhot;
data = (char *)(pCurs->bits->argb);
memset(cur_data, 0, sizeof(cur_data));
memset(cur_mask, 0, sizeof(cur_mask));
for (j = 0; j < 32; j++)
{
for (i = 0; i < 32; i++)
{
p = get_pixel_safe(data, i, j, paddedRowBytes / 4, h, 32);
set_pixel_safe(cur_data, i, 31 - j, 32, 32, 32, p);
}
}
}
else
{
bpp = 0;
paddedRowBytes = PixmapBytePad(w, 1);
xhot = pCurs->bits->xhot;
yhot = pCurs->bits->yhot;
data = (char *)(pCurs->bits->source);
mask = (char *)(pCurs->bits->mask);
fgcolor = (((pCurs->foreRed >> 8) & 0xff) << 16) |
(((pCurs->foreGreen >> 8) & 0xff) << 8) |
((pCurs->foreBlue >> 8) & 0xff);
bgcolor = (((pCurs->backRed >> 8) & 0xff) << 16) |
(((pCurs->backGreen >> 8) & 0xff) << 8) |
((pCurs->backBlue >> 8) & 0xff);
memset(cur_data, 0, sizeof(cur_data));
memset(cur_mask, 0, sizeof(cur_mask));
for (j = 0; j < 32; j++)
{
for (i = 0; i < 32; i++)
{
p = get_pixel_safe(mask, i, j, paddedRowBytes * 8, h, 1);
set_pixel_safe(cur_mask, i, 31 - j, 32, 32, 1, !p);
if (p != 0)
{
p = get_pixel_safe(data, i, j, paddedRowBytes * 8, h, 1);
p = p ? fgcolor : bgcolor;
set_pixel_safe(cur_data, i, 31 - j, 32, 32, 24, p);
}
}
}
}
rdpup_begin_update();
rdpup_set_cursor_ex(xhot, yhot, cur_data, cur_mask, bpp);
rdpup_end_update();
}
/******************************************************************************/
void
rdpSpriteMoveCursor(DeviceIntPtr pDev, ScreenPtr pScr, int x, int y)
{
LLOGLN(10, ("rdpSpriteMoveCursor:"));
}
/******************************************************************************/
Bool
rdpSpriteDeviceCursorInitialize(DeviceIntPtr pDev, ScreenPtr pScr)
{
LLOGLN(0, ("rdpSpriteDeviceCursorInitialize:"));
return 1;
}
/******************************************************************************/
void
rdpSpriteDeviceCursorCleanup(DeviceIntPtr pDev, ScreenPtr pScr)
{
LLOGLN(0, ("rdpSpriteDeviceCursorCleanup:"));
}
/******************************************************************************/
static void
rdpEnqueueMotion(int x, int y)
{
int i;
int n;
int valuators[2];
EventListPtr rdp_events;
xEvent *pev;
LLOGLN(10, ("rdpEnqueueMotion: x %d y %d", x, y));
# if 0
if (x < 128)
{
rdpup_begin_update();
rdpup_send_area(0, 0, 0, 1024, 768);
rdpup_end_update();
}
#endif
miPointerSetPosition(g_pointer, &x, &y);
valuators[0] = x;
valuators[1] = y;
GetEventList(&rdp_events);
n = GetPointerEvents(rdp_events, g_pointer, MotionNotify, 0,
POINTER_ABSOLUTE | POINTER_SCREEN,
0, 2, valuators);
for (i = 0; i < n; i++)
{
pev = (rdp_events + i)->event;
mieqEnqueue(g_pointer, (InternalEvent *)pev);
}
}
/******************************************************************************/
static void
rdpEnqueueButton(int type, int buttons)
{
int i;
int n;
EventListPtr rdp_events;
xEvent *pev;
LLOGLN(10, ("rdpEnqueueButton:"));
i = GetEventList(&rdp_events);
n = GetPointerEvents(rdp_events, g_pointer, type, buttons, 0, 0, 0, 0);
for (i = 0; i < n; i++)
{
pev = (rdp_events + i)->event;
mieqEnqueue(g_pointer, (InternalEvent *)pev);
}
}
/******************************************************************************/
static CARD32
rdpDeferredInputCallback(OsTimerPtr timer, CARD32 now, pointer arg)
{
LLOGLN(10, ("rdpDeferredInputCallback:"));
g_timer_scheduled = 0;
if ((g_old_x != g_x) || (g_old_y != g_y))
{
rdpEnqueueMotion(g_x, g_y);
g_old_x = g_x;
g_old_y = g_x;
}
return 0;
}
/******************************************************************************/
void
PtrAddEvent(int buttonMask, int x, int y)
{
int i;
int type;
int buttons;
int send_now;
LLOGLN(10, ("PtrAddEvent: x %d y %d", x, y));
if (g_pointer == 0)
{
return;
}
send_now = (buttonMask ^ g_old_button_mask) || (g_delay_motion == 0);
LLOGLN(10, ("PtrAddEvent: send_now %d g_timer_scheduled %d",
send_now, g_timer_scheduled));
if (send_now)
{
if (g_timer_scheduled)
{
g_timer_scheduled = 0;
TimerCancel(g_timer);
}
if ((g_old_x != x) || (g_old_y != y))
{
rdpEnqueueMotion(x, y);
g_old_x = x;
g_old_y = y;
}
for (i = 0; i < 5; i++)
{
if ((buttonMask ^ g_old_button_mask) & (1 << i))
{
if (buttonMask & (1 << i))
{
type = ButtonPress;
buttons = i + 1;
rdpEnqueueButton(type, buttons);
}
else
{
type = ButtonRelease;
buttons = i + 1;
rdpEnqueueButton(type, buttons);
}
}
}
g_old_button_mask = buttonMask;
}
else
{
g_x = x;
g_y = y;
if (!g_timer_scheduled)
{
g_timer_scheduled = 1;
g_timer = TimerSet(g_timer, 0, 60, rdpDeferredInputCallback, 0);
}
}
}
/******************************************************************************/
void
KbdAddEvent(int down, int param1, int param2, int param3, int param4)
{
if (g_use_evdev)
{
KbdAddEvent_evdev(down, param1, param2, param3, param4);
}
else
{
KbdAddEvent_base(down, param1, param2, param3, param4);
}
}
/******************************************************************************/
/* notes -
scroll lock doesn't seem to be a modifier in X
*/
void
KbdSync(int param1)
{
int xkb_state;
if (g_keyboard == 0)
{
return;
}
xkb_state = XkbStateFieldFromRec(&(g_keyboard->key->xkbInfo->state));
if ((!(xkb_state & 0x02)) != (!(param1 & 4))) /* caps lock */
{
LLOGLN(0, ("KbdSync: toggling caps lock"));
KbdAddEvent(1, 58, 0, 58, 0);
KbdAddEvent(0, 58, 49152, 58, 49152);
}
if ((!(xkb_state & 0x10)) != (!(param1 & 2))) /* num lock */
{
LLOGLN(0, ("KbdSync: toggling num lock"));
KbdAddEvent(1, 69, 0, 69, 0);
KbdAddEvent(0, 69, 49152, 69, 49152);
}
if ((!(g_scroll_lock_down)) != (!(param1 & 1))) /* scroll lock */
{
LLOGLN(0, ("KbdSync: toggling scroll lock"));
KbdAddEvent(1, 70, 0, 70, 0);
KbdAddEvent(0, 70, 49152, 70, 49152);
}
}

@ -1,95 +0,0 @@
/*
Copyright 2005-2014 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.
keyboard
*/
#include "rdp.h"
#include "rdpkeyboard.h"
#include "rdpkeyboardevdev.h"
#define LOG_LEVEL 1
#define LLOGLN(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0)
extern DeviceIntPtr g_keyboard; /* in rdpmain.c */
extern int g_shift_down; /* in rdpmain.c */
extern int g_alt_down; /* in rdpmain.c */
extern int g_ctrl_down; /* in rdpmain.c */
extern int g_pause_spe; /* in rdpmain.c */
extern int g_tab_down; /* in rdpmain.c */
/******************************************************************************/
void
rdpEnqueueKey(int type, int scancode)
{
int i;
int n;
EventListPtr rdp_events;
xEvent *pev;
i = GetEventList(&rdp_events);
n = GetKeyboardEvents(rdp_events, g_keyboard, type, scancode);
for (i = 0; i < n; i++)
{
pev = (rdp_events + i)->event;
mieqEnqueue(g_keyboard, (InternalEvent *)pev);
}
}
/******************************************************************************/
void
check_keysa(void)
{
if (g_ctrl_down != 0)
{
rdpEnqueueKey(KeyRelease, g_ctrl_down);
g_ctrl_down = 0;
}
if (g_alt_down != 0)
{
rdpEnqueueKey(KeyRelease, g_alt_down);
g_alt_down = 0;
}
if (g_shift_down != 0)
{
rdpEnqueueKey(KeyRelease, g_shift_down);
g_shift_down = 0;
}
}
/******************************************************************************/
void
sendDownUpKeyEvent(int type, int x_scancode)
{
/* if type is keydown, send keyup + keydown */
if (type == KeyPress)
{
rdpEnqueueKey(KeyRelease, x_scancode);
rdpEnqueueKey(KeyPress, x_scancode);
}
else
{
rdpEnqueueKey(KeyRelease, x_scancode);
}
}

@ -1,68 +0,0 @@
/*
Copyright 2013-2014 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.
keyboard map for base rules
*/
#ifndef _RDPKEYBOARD_H
#define _RDPKEYBOARD_H
#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
#define RDPSCAN_Tab 15
#define RDPSCAN_Return 28 /* ext is used to know KP or not */
#define RDPSCAN_Control 29 /* ext is used to know L or R */
#define RDPSCAN_Shift_L 42
#define RDPSCAN_Slash 53
#define RDPSCAN_Shift_R 54
#define RDPSCAN_KP_Multiply 55
#define RDPSCAN_Alt 56 /* ext is used to know L or R */
#define RDPSCAN_Caps_Lock 58
#define RDPSCAN_Pause 69
#define RDPSCAN_Scroll_Lock 70
#define RDPSCAN_KP_7 71 /* KP7 or home */
#define RDPSCAN_KP_8 72 /* KP8 or up */
#define RDPSCAN_KP_9 73 /* KP9 or page up */
#define RDPSCAN_KP_4 75 /* KP4 or left */
#define RDPSCAN_KP_6 77 /* KP6 or right */
#define RDPSCAN_KP_1 79 /* KP1 or home */
#define RDPSCAN_KP_2 80 /* KP2 or up */
#define RDPSCAN_KP_3 81 /* KP3 or page down */
#define RDPSCAN_KP_0 82 /* KP0 or insert */
#define RDPSCAN_KP_Decimal 83 /* KP. or delete */
#define RDPSCAN_89 89
#define RDPSCAN_90 90
#define RDPSCAN_LWin 91
#define RDPSCAN_RWin 92
#define RDPSCAN_Menu 93
#define RDPSCAN_115 115
#define RDPSCAN_126 126
void
rdpEnqueueKey(int type, int scancode);
void
check_keysa(void);
void
sendDownUpKeyEvent(int type, int x_scancode);
#endif

@ -1,301 +0,0 @@
/*
Copyright 2005-2014 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.
keyboard map for base rules
*/
#include "rdp.h"
#include "rdpkeyboard.h"
#include "rdpkeyboardbase.h"
extern DeviceIntPtr g_keyboard; /* in rdpmain.c */
extern int g_shift_down; /* in rdpmain.c */
extern int g_alt_down; /* in rdpmain.c */
extern int g_ctrl_down; /* in rdpmain.c */
extern int g_pause_spe; /* in rdpmain.c */
extern int g_tab_down; /* in rdpmain.c */
#define LOG_LEVEL 1
#define LLOGLN(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0)
#define XSCAN_Tab 23
#define XSCAN_Return 36 /* above right shift */
#define XSCAN_Control_L 37
#define XSCAN_Shift_L 50
#define XSCAN_slash 61
#define XSCAN_Shift_R 62
#define XSCAN_KP_Multiply 63
#define XSCAN_Alt_L 64
#define XSCAN_Caps_Lock 66 /* caps lock */
#define XSCAN_Num_Lock 77 /* num lock */
#define XSCAN_KP_7 79
#define XSCAN_KP_8 80
#define XSCAN_KP_9 81
#define XSCAN_KP_4 83
#define XSCAN_KP_6 85
#define XSCAN_KP_1 87
#define XSCAN_KP_2 88
#define XSCAN_KP_3 89
#define XSCAN_KP_0 90
#define XSCAN_KP_Decimal 91
/* "/ ?" on br keyboard */
#define XSCAN_97 97 /* ------------------------------? */
#define XSCAN_Enter 108 /* 104 */ /* on keypad */
#define XSCAN_Control_R 109 /* 105 */
#define XSCAN_KP_Divide 112 /* 106 */
#define XSCAN_Print 111 /* 107 */
#define XSCAN_Alt_R 113 /* 108 */
#define XSCAN_Home 97 /* 110 */
#define XSCAN_Up 98 /* 111 */
#define XSCAN_Prior 99 /* 112 */
#define XSCAN_Left 100 /* 113 */
#define XSCAN_Right 102 /* 114 */
#define XSCAN_End 103 /* 115 */
#define XSCAN_Down 104 /* 116 */
#define XSCAN_Next 105 /* 117 */
#define XSCAN_Insert 106 /* 118 */
#define XSCAN_Delete 107 /* 119 */
#define XSCAN_Pause 110 /* 127 */
/* . on br keypad */
#define XSCAN_129 129 /* ------------------------------? */
#define XSCAN_LWin 115 /* 133 */
#define XSCAN_RWin 116 /* 134 */
#define XSCAN_Menu 117 /* 135 */
#define XSCAN_LMeta 156
#define XSCAN_RMeta 156
#define XSCAN_211 211 /* "/ ?" on br keyboard, "\ _" on jp keyboard */
/******************************************************************************/
void
KbdAddEvent_base(int down, int param1, int param2, int param3, int param4)
{
int rdp_scancode;
int x_scancode;
int is_ext;
int is_spe;
int type;
LLOGLN(10, ("KbdAddEvent_base: down=0x%x param1=0x%x param2=0x%x "
"param3=0x%x param4=0x%x", down, param1, param2, param3, param4));
if (g_keyboard == 0)
{
return;
}
type = down ? KeyPress : KeyRelease;
rdp_scancode = param3;
is_ext = param4 & 256; /* 0x100 */
is_spe = param4 & 512; /* 0x200 */
x_scancode = 0;
switch (rdp_scancode)
{
case RDPSCAN_Caps_Lock: /* caps lock */
case RDPSCAN_Shift_L: /* left shift */
case RDPSCAN_Shift_R: /* right shift */
case RDPSCAN_Scroll_Lock: /* scroll lock */
x_scancode = rdp_scancode + MIN_KEY_CODE;
if (x_scancode > 0)
{
/* left or right shift */
if ((rdp_scancode == RDPSCAN_Shift_L) ||
(rdp_scancode == RDPSCAN_Shift_R))
{
g_shift_down = down ? x_scancode : 0;
}
rdpEnqueueKey(type, x_scancode);
}
break;
case RDPSCAN_Alt: /* left - right alt button */
if (is_ext)
{
x_scancode = XSCAN_Alt_R; /* right alt button */
}
else
{
x_scancode = XSCAN_Alt_L; /* left alt button */
}
g_alt_down = down ? x_scancode : 0;
rdpEnqueueKey(type, x_scancode);
break;
case RDPSCAN_Tab: /* tab */
if (!down && !g_tab_down)
{
check_keysa(); /* leave x_scancode 0 here, we don't want the tab key up */
}
else
{
sendDownUpKeyEvent(type, XSCAN_Tab);
}
g_tab_down = down;
break;
case RDPSCAN_Control: /* left or right ctrl */
/* this is to handle special case with pause key sending control first */
if (is_spe)
{
if (down)
{
g_pause_spe = 1;
/* leave x_scancode 0 here, we don't want the control key down */
}
}
else
{
x_scancode = is_ext ? XSCAN_Control_R : XSCAN_Control_L;
g_ctrl_down = down ? x_scancode : 0;
rdpEnqueueKey(type, x_scancode);
}
break;
case RDPSCAN_Pause: /* Pause or Num Lock */
if (g_pause_spe)
{
x_scancode = XSCAN_Pause;
if (!down)
{
g_pause_spe = 0;
}
}
else
{
x_scancode = g_ctrl_down ? XSCAN_Pause : XSCAN_Num_Lock;
}
rdpEnqueueKey(type, x_scancode);
break;
case RDPSCAN_Return: /* Enter or Return */
x_scancode = is_ext ? XSCAN_Enter : XSCAN_Return;
sendDownUpKeyEvent(type, x_scancode);
break;
case RDPSCAN_Slash: /* / */
x_scancode = is_ext ? XSCAN_KP_Divide : XSCAN_slash;
sendDownUpKeyEvent(type, x_scancode);
break;
case RDPSCAN_KP_Multiply: /* * on KP or Print Screen */
x_scancode = is_ext ? XSCAN_Print : XSCAN_KP_Multiply;
sendDownUpKeyEvent(type, x_scancode);
break;
case RDPSCAN_KP_7: /* 7 or Home */
x_scancode = is_ext ? XSCAN_Home : XSCAN_KP_7;
sendDownUpKeyEvent(type, x_scancode);
break;
case RDPSCAN_KP_8: /* 8 or Up */
x_scancode = is_ext ? XSCAN_Up : XSCAN_KP_8;
sendDownUpKeyEvent(type, x_scancode);
break;
case RDPSCAN_KP_9: /* 9 or PgUp */
x_scancode = is_ext ? XSCAN_Prior : XSCAN_KP_9;
sendDownUpKeyEvent(type, x_scancode);
break;
case RDPSCAN_KP_4: /* 4 or Left */
x_scancode = is_ext ? XSCAN_Left : XSCAN_KP_4;
sendDownUpKeyEvent(type, x_scancode);
break;
case RDPSCAN_KP_6: /* 6 or Right */
x_scancode = is_ext ? XSCAN_Right : XSCAN_KP_6;
sendDownUpKeyEvent(type, x_scancode);
break;
case RDPSCAN_KP_1: /* 1 or End */
x_scancode = is_ext ? XSCAN_End : XSCAN_KP_1;
sendDownUpKeyEvent(type, x_scancode);
break;
case RDPSCAN_KP_2: /* 2 or Down */
x_scancode = is_ext ? XSCAN_Down : XSCAN_KP_2;
sendDownUpKeyEvent(type, x_scancode);
break;
case RDPSCAN_KP_3: /* 3 or PgDn */
x_scancode = is_ext ? XSCAN_Next : XSCAN_KP_3;
sendDownUpKeyEvent(type, x_scancode);
break;
case RDPSCAN_KP_0: /* 0 or Insert */
x_scancode = is_ext ? XSCAN_Insert : XSCAN_KP_0;
sendDownUpKeyEvent(type, x_scancode);
break;
case RDPSCAN_KP_Decimal: /* . or Delete */
x_scancode = is_ext ? XSCAN_Delete : XSCAN_KP_Decimal;
sendDownUpKeyEvent(type, x_scancode);
break;
case RDPSCAN_LWin: /* left win key */
rdpEnqueueKey(type, XSCAN_LWin);
break;
case RDPSCAN_RWin: /* right win key */
rdpEnqueueKey(type, XSCAN_RWin);
break;
case RDPSCAN_Menu: /* menu key */
rdpEnqueueKey(type, XSCAN_Menu);
break;
case RDPSCAN_89: /* left meta */
rdpEnqueueKey(type, XSCAN_LMeta);
break;
case RDPSCAN_90: /* right meta */
rdpEnqueueKey(type, XSCAN_RMeta);
break;
case RDPSCAN_115:
rdpEnqueueKey(type, XSCAN_211); /* "/ ?" on br keyboard, "\ _" on jp keyboard */
break;
case RDPSCAN_126:
rdpEnqueueKey(type, XSCAN_129); /* . on br keypad */
break;
default:
x_scancode = rdp_scancode + MIN_KEY_CODE;
if (x_scancode > 0)
{
LLOGLN(10, ("KbdAddEvent_base: rdp_scancode %d x_scancode %d",
rdp_scancode, x_scancode));
sendDownUpKeyEvent(type, x_scancode);
}
break;
}
}

@ -1,30 +0,0 @@
/*
Copyright 2013-2014 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.
keyboard map for base rules
*/
#ifndef _RDPKEYBOARDBASE_H
#define _RDPKEYBOARDBASE_H
void
KbdAddEvent_base(int down, int param1, int param2, int param3, int param4);
#endif

@ -1,300 +0,0 @@
/*
Copyright 2005-2014 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.
keyboard map for evdev rules
*/
#include "rdp.h"
#include "rdpkeyboard.h"
#include "rdpkeyboardevdev.h"
extern DeviceIntPtr g_keyboard; /* in rdpmain.c */
extern int g_shift_down; /* in rdpmain.c */
extern int g_alt_down; /* in rdpmain.c */
extern int g_ctrl_down; /* in rdpmain.c */
extern int g_pause_spe; /* in rdpmain.c */
extern int g_tab_down; /* in rdpmain.c */
#define LOG_LEVEL 1
#define LLOGLN(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0)
#define XSCAN_Tab 23
#define XSCAN_Return 36 /* above right shift */
#define XSCAN_Control_L 37
#define XSCAN_Shift_L 50
#define XSCAN_slash 61
#define XSCAN_Shift_R 62
#define XSCAN_KP_Multiply 63
#define XSCAN_Alt_L 64
#define XSCAN_Caps_Lock 66 /* caps lock */
#define XSCAN_Num_Lock 77 /* num lock */
#define XSCAN_KP_7 79
#define XSCAN_KP_8 80
#define XSCAN_KP_9 81
#define XSCAN_KP_4 83
#define XSCAN_KP_6 85
#define XSCAN_KP_1 87
#define XSCAN_KP_2 88
#define XSCAN_KP_3 89
#define XSCAN_KP_0 90
#define XSCAN_KP_Decimal 91
/* "/ ?" on br keyboard */
#define XSCAN_97 97
#define XSCAN_Enter 104 /* on keypad */
#define XSCAN_Control_R 105
#define XSCAN_KP_Divide 106
#define XSCAN_Print 107
#define XSCAN_Alt_R 108
#define XSCAN_Home 110
#define XSCAN_Up 111
#define XSCAN_Prior 112
#define XSCAN_Left 113
#define XSCAN_Right 114
#define XSCAN_End 115
#define XSCAN_Down 116
#define XSCAN_Next 117
#define XSCAN_Insert 118
#define XSCAN_Delete 119
#define XSCAN_Pause 127
/* . on br keypad */
#define XSCAN_129 129
#define XSCAN_LWin 133
#define XSCAN_RWin 134
#define XSCAN_Menu 135
#define XSCAN_LMeta 156
#define XSCAN_RMeta 156
/******************************************************************************/
void
KbdAddEvent_evdev(int down, int param1, int param2, int param3, int param4)
{
int rdp_scancode;
int x_scancode;
int is_ext;
int is_spe;
int type;
LLOGLN(10, ("KbdAddEvent_evdev: down=0x%x param1=0x%x param2=0x%x "
"param3=0x%x param4=0x%x", down, param1, param2, param3, param4));
if (g_keyboard == 0)
{
return;
}
type = down ? KeyPress : KeyRelease;
rdp_scancode = param3;
is_ext = param4 & 256; /* 0x100 */
is_spe = param4 & 512; /* 0x200 */
x_scancode = 0;
switch (rdp_scancode)
{
case RDPSCAN_Caps_Lock: /* caps lock */
case RDPSCAN_Shift_L: /* left shift */
case RDPSCAN_Shift_R: /* right shift */
case RDPSCAN_Scroll_Lock: /* scroll lock */
x_scancode = rdp_scancode + MIN_KEY_CODE;
if (x_scancode > 0)
{
/* left or right shift */
if ((rdp_scancode == RDPSCAN_Shift_L) ||
(rdp_scancode == RDPSCAN_Shift_R))
{
g_shift_down = down ? x_scancode : 0;
}
rdpEnqueueKey(type, x_scancode);
}
break;
case RDPSCAN_Alt: /* left - right alt button */
if (is_ext)
{
x_scancode = XSCAN_Alt_R; /* right alt button */
}
else
{
x_scancode = XSCAN_Alt_L; /* left alt button */
}
g_alt_down = down ? x_scancode : 0;
rdpEnqueueKey(type, x_scancode);
break;
case RDPSCAN_Tab: /* tab */
if (!down && !g_tab_down)
{
check_keysa(); /* leave x_scancode 0 here, we don't want the tab key up */
}
else
{
sendDownUpKeyEvent(type, XSCAN_Tab);
}
g_tab_down = down;
break;
case RDPSCAN_Control: /* left or right ctrl */
/* this is to handle special case with pause key sending control first */
if (is_spe)
{
if (down)
{
g_pause_spe = 1;
/* leave x_scancode 0 here, we don't want the control key down */
}
}
else
{
x_scancode = is_ext ? XSCAN_Control_R : XSCAN_Control_L;
g_ctrl_down = down ? x_scancode : 0;
rdpEnqueueKey(type, x_scancode);
}
break;
case RDPSCAN_Pause: /* Pause or Num Lock */
if (g_pause_spe)
{
x_scancode = XSCAN_Pause;
if (!down)
{
g_pause_spe = 0;
}
}
else
{
x_scancode = g_ctrl_down ? XSCAN_Pause : XSCAN_Num_Lock;
}
rdpEnqueueKey(type, x_scancode);
break;
case RDPSCAN_Return: /* Enter or Return */
x_scancode = is_ext ? XSCAN_Enter : XSCAN_Return;
sendDownUpKeyEvent(type, x_scancode);
break;
case RDPSCAN_Slash: /* / */
x_scancode = is_ext ? XSCAN_KP_Divide : XSCAN_slash;
sendDownUpKeyEvent(type, x_scancode);
break;
case RDPSCAN_KP_Multiply: /* * on KP or Print Screen */
x_scancode = is_ext ? XSCAN_Print : XSCAN_KP_Multiply;
sendDownUpKeyEvent(type, x_scancode);
break;
case RDPSCAN_KP_7: /* 7 or Home */
x_scancode = is_ext ? XSCAN_Home : XSCAN_KP_7;
sendDownUpKeyEvent(type, x_scancode);
break;
case RDPSCAN_KP_8: /* 8 or Up */
x_scancode = is_ext ? XSCAN_Up : XSCAN_KP_8;
sendDownUpKeyEvent(type, x_scancode);
break;
case RDPSCAN_KP_9: /* 9 or PgUp */
x_scancode = is_ext ? XSCAN_Prior : XSCAN_KP_9;
sendDownUpKeyEvent(type, x_scancode);
break;
case RDPSCAN_KP_4: /* 4 or Left */
x_scancode = is_ext ? XSCAN_Left : XSCAN_KP_4;
sendDownUpKeyEvent(type, x_scancode);
break;
case RDPSCAN_KP_6: /* 6 or Right */
x_scancode = is_ext ? XSCAN_Right : XSCAN_KP_6;
sendDownUpKeyEvent(type, x_scancode);
break;
case RDPSCAN_KP_1: /* 1 or End */
x_scancode = is_ext ? XSCAN_End : XSCAN_KP_1;
sendDownUpKeyEvent(type, x_scancode);
break;
case RDPSCAN_KP_2: /* 2 or Down */
x_scancode = is_ext ? XSCAN_Down : XSCAN_KP_2;
sendDownUpKeyEvent(type, x_scancode);
break;
case RDPSCAN_KP_3: /* 3 or PgDn */
x_scancode = is_ext ? XSCAN_Next : XSCAN_KP_3;
sendDownUpKeyEvent(type, x_scancode);
break;
case RDPSCAN_KP_0: /* 0 or Insert */
x_scancode = is_ext ? XSCAN_Insert : XSCAN_KP_0;
sendDownUpKeyEvent(type, x_scancode);
break;
case RDPSCAN_KP_Decimal: /* . or Delete */
x_scancode = is_ext ? XSCAN_Delete : XSCAN_KP_Decimal;
sendDownUpKeyEvent(type, x_scancode);
break;
case RDPSCAN_LWin: /* left win key */
rdpEnqueueKey(type, XSCAN_LWin);
break;
case RDPSCAN_RWin: /* right win key */
rdpEnqueueKey(type, XSCAN_RWin);
break;
case RDPSCAN_Menu: /* menu key */
rdpEnqueueKey(type, XSCAN_Menu);
break;
case RDPSCAN_89: /* left meta */
rdpEnqueueKey(type, XSCAN_LMeta);
break;
case RDPSCAN_90: /* right meta */
rdpEnqueueKey(type, XSCAN_RMeta);
break;
case RDPSCAN_115:
rdpEnqueueKey(type, XSCAN_97); /* "/ ?" on br keyboard */
break;
case RDPSCAN_126:
rdpEnqueueKey(type, XSCAN_129); /* . on br keypad */
break;
default:
x_scancode = rdp_scancode + MIN_KEY_CODE;
if (x_scancode > 0)
{
LLOGLN(10, ("KbdAddEvent_evdev: rdp_scancode %d x_scancode %d",
rdp_scancode, x_scancode));
sendDownUpKeyEvent(type, x_scancode);
}
break;
}
}

@ -1,30 +0,0 @@
/*
Copyright 2013-2014 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.
keyboard map for base rules
*/
#ifndef _RDPKEYBOARDEVDEV_H
#define _RDPKEYBOARDEVDEV_H
void
KbdAddEvent_evdev(int down, int param1, int param2, int param3, int param4);
#endif

@ -1,857 +0,0 @@
/*
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.
This is the main file called from main.c
Sets up the functions
*/
#include "rdp.h"
#include "rdprandr.h"
#include "rdpglyph.h"
#if 1
#define DEBUG_OUT(arg)
#else
#define DEBUG_OUT(arg) ErrorF arg
#endif
#ifndef XRDP_DISABLE_LINUX_ABSTRACT
#ifdef __linux__
#define XRDP_DISABLE_LINUX_ABSTRACT 1
#else
#define XRDP_DISABLE_LINUX_ABSTRACT 0
#endif
#endif
#if XRDP_DISABLE_LINUX_ABSTRACT
/* because including <X11/Xtrans/Xtransint.h> is problematic
* we dup a small struct
* we need to set flags to zero to turn off abstract sockets */
struct _MyXtransport
{
char *TransName;
int flags;
};
/* in xtrans-1.2.6/Xtranssock.c */
extern struct _MyXtransport _XSERVTransSocketLocalFuncs;
#endif
rdpScreenInfoRec g_rdpScreen; /* the one screen */
ScreenPtr g_pScreen = 0;
DevPrivateKeyRec g_rdpGCIndex;
DevPrivateKeyRec g_rdpWindowIndex;
DevPrivateKeyRec g_rdpPixmapIndex;
/* main mouse and keyboard devices */
DeviceIntPtr g_pointer = 0;
DeviceIntPtr g_keyboard = 0;
/* true if client is enhanced rdp client(freerdp) */
int g_can_do_pix_to_pix = 0;
int g_do_dirty_os = 1; /* delay remoting off screen bitmaps */
int g_do_dirty_ons = 1; /* delay remoting screen */
int g_do_glyph_cache = 0; /* rdpup.c may set this */
int g_do_alpha_glyphs = 1;
int g_do_composite = 0; /* rdpup.c may set this */
Bool g_wrapWindow = 1;
Bool g_wrapPixmap = 1;
int g_codec_mode = 0; /* 0 = standard rdp, 1 = rfx */
rdpPixmapRec g_screenPriv;
/* if true, running in RemoteApp / RAIL mode */
int g_use_rail = 0;
int g_con_number = 0; /* increments for each connection */
WindowPtr g_invalidate_window = 0;
int g_doing_font = 0;
/* if true, use a unix domain socket instead of a tcp socket */
int g_use_uds = 0;
char g_uds_data[256] = ""; /* data */
char g_uds_cont[256] = ""; /* control */
int g_shift_down = 0;
int g_alt_down = 0;
int g_ctrl_down = 0;
int g_pause_spe = 0;
int g_tab_down = 0;
/* set all these at once, use function set_bpp */
int g_bpp = 16;
int g_Bpp = 2;
int g_Bpp_mask = 0xffff;
static int g_firstTime = 1;
static int g_redBits = 5;
static int g_greenBits = 6;
static int g_blueBits = 5;
static int g_initOutputCalled = 0;
/* Common pixmap formats */
static PixmapFormatRec g_formats[MAXFORMATS] =
{
{ 1, 1, BITMAP_SCANLINE_PAD },
{ 4, 8, BITMAP_SCANLINE_PAD },
{ 8, 8, BITMAP_SCANLINE_PAD },
{ 15, 16, BITMAP_SCANLINE_PAD },
{ 16, 16, BITMAP_SCANLINE_PAD },
{ 24, 32, BITMAP_SCANLINE_PAD },
{ 32, 32, BITMAP_SCANLINE_PAD },
};
static int g_numFormats = 7;
static miPointerSpriteFuncRec g_rdpSpritePointerFuncs =
{
/* these are in rdpinput.c */
rdpSpriteRealizeCursor,
rdpSpriteUnrealizeCursor,
rdpSpriteSetCursor,
rdpSpriteMoveCursor,
rdpSpriteDeviceCursorInitialize,
rdpSpriteDeviceCursorCleanup
};
static miPointerScreenFuncRec g_rdpPointerCursorFuncs =
{
/* these are in rdpinput.c */
rdpCursorOffScreen,
rdpCrossScreen,
rdpPointerWarpCursor,
rdpPointerEnqueueEvent,
rdpPointerNewEventScreen
};
int glGetBufferSubData(void);
/******************************************************************************/
/* returns error, zero is good */
static int
set_bpp(int bpp)
{
int rv;
rv = 0;
g_bpp = bpp;
if (g_bpp == 8)
{
g_Bpp = 1;
g_Bpp_mask = 0xff;
g_redBits = 3;
g_greenBits = 3;
g_blueBits = 2;
}
else if (g_bpp == 15)
{
g_Bpp = 2;
g_Bpp_mask = 0x7fff;
g_redBits = 5;
g_greenBits = 5;
g_blueBits = 5;
}
else if (g_bpp == 16)
{
g_Bpp = 2;
g_Bpp_mask = 0xffff;
g_redBits = 5;
g_greenBits = 6;
g_blueBits = 5;
}
else if (g_bpp == 24)
{
g_Bpp = 4;
g_Bpp_mask = 0xffffff;
g_redBits = 8;
g_greenBits = 8;
g_blueBits = 8;
}
else if (g_bpp == 32)
{
g_Bpp = 4;
g_Bpp_mask = 0xffffff;
g_redBits = 8;
g_greenBits = 8;
g_blueBits = 8;
}
else if (g_bpp == 33)
{
/* will never happen */
glGetBufferSubData();
}
else
{
rv = 1;
}
return rv;
}
/******************************************************************************/
static void
rdpWakeupHandler(int i, pointer blockData, unsigned long err,
pointer pReadmask)
{
g_pScreen->WakeupHandler = g_rdpScreen.WakeupHandler;
g_pScreen->WakeupHandler(i, blockData, err, pReadmask);
g_pScreen->WakeupHandler = rdpWakeupHandler;
}
/******************************************************************************/
static void
rdpBlockHandler1(pointer blockData, OSTimePtr pTimeout, pointer pReadmask)
{
}
/******************************************************************************/
static void
rdpWakeupHandler1(pointer blockData, int result, pointer pReadmask)
{
rdpup_check();
}
#if 0
/******************************************************************************/
static Bool
rdpDeviceCursorInitialize(DeviceIntPtr pDev, ScreenPtr pScreen)
{
ErrorF("rdpDeviceCursorInitializeProcPtr:\n");
return 1;
}
/******************************************************************************/
static void
rdpDeviceCursorCleanup(DeviceIntPtr pDev, ScreenPtr pScreen)
{
ErrorF("rdpDeviceCursorCleanupProcPtr:\n");
}
#endif
#if 0
/******************************************************************************/
Bool
rdpCreateColormap(ColormapPtr pCmap)
{
ErrorF("rdpCreateColormap:\n");
return 1;
}
/******************************************************************************/
static void
rdpDestroyColormap(ColormapPtr pColormap)
{
ErrorF("rdpDestroyColormap:\n");
}
#endif
/******************************************************************************/
void
rdpSetUDSRights(void)
{
char unixSocketName[128];
sprintf(unixSocketName, "/tmp/.X11-unix/X%s", display);
chmod(unixSocketName, 0700);
}
/******************************************************************************/
/* returns boolean, true if everything is ok */
static Bool
rdpScreenInit(int index, ScreenPtr pScreen, int argc, char **argv)
{
int dpix;
int dpiy;
int ret;
Bool vis_found;
VisualPtr vis;
PictureScreenPtr ps;
rrScrPrivPtr pRRScrPriv;
g_pScreen = pScreen;
memset(&g_screenPriv, 0, sizeof(g_screenPriv));
/*dpix = 75;
dpiy = 75; */
dpix = PixelDPI;
dpiy = PixelDPI;
if (monitorResolution != 0)
{
dpix = monitorResolution;
dpiy = monitorResolution;
}
g_rdpScreen.paddedWidthInBytes = PixmapBytePad(g_rdpScreen.width,
g_rdpScreen.depth);
g_rdpScreen.bitsPerPixel = rdpBitsPerPixel(g_rdpScreen.depth);
ErrorF("\n");
ErrorF("X11rdp, an X server for xrdp\n");
ErrorF("Version %s\n", X11RDPVER);
ErrorF("Copyright (C) 2005-2015 Jay Sorg\n");
ErrorF("See http://www.xrdp.org for information on xrdp.\n");
#if defined(XORG_VERSION_CURRENT) && defined (XVENDORNAME)
ErrorF("Underlying X server release %d, %s\n",
XORG_VERSION_CURRENT, XVENDORNAME);
#endif
#if defined(XORG_RELEASE)
ErrorF("Xorg %s\n", XORG_RELEASE);
#endif
ErrorF("Screen width %d height %d depth %d bpp %d\n", g_rdpScreen.width,
g_rdpScreen.height, g_rdpScreen.depth, g_rdpScreen.bitsPerPixel);
ErrorF("dpix %d dpiy %d\n", dpix, dpiy);
if (g_rdpScreen.pfbMemory == 0)
{
g_rdpScreen.sizeInBytes =
(g_rdpScreen.paddedWidthInBytes * g_rdpScreen.height);
ErrorF("buffer size %d\n", g_rdpScreen.sizeInBytes);
g_rdpScreen.pfbMemory = (char *)g_malloc(g_rdpScreen.sizeInBytes, 1);
g_rdpScreen.sizeInBytesAlloc = g_rdpScreen.sizeInBytes;
}
if (g_rdpScreen.pfbMemory == 0)
{
rdpLog("rdpScreenInit g_malloc failed\n");
return 0;
}
miClearVisualTypes();
if (defaultColorVisualClass == -1)
{
defaultColorVisualClass = TrueColor;
}
if (!miSetVisualTypes(g_rdpScreen.depth,
miGetDefaultVisualMask(g_rdpScreen.depth),
8, defaultColorVisualClass))
{
rdpLog("rdpScreenInit miSetVisualTypes failed\n");
return 0;
}
miSetPixmapDepths();
switch (g_rdpScreen.bitsPerPixel)
{
case 8:
ret = fbScreenInit(pScreen, g_rdpScreen.pfbMemory,
g_rdpScreen.width, g_rdpScreen.height,
dpix, dpiy, g_rdpScreen.paddedWidthInBytes, 8);
break;
case 16:
ret = fbScreenInit(pScreen, g_rdpScreen.pfbMemory,
g_rdpScreen.width, g_rdpScreen.height,
dpix, dpiy, g_rdpScreen.paddedWidthInBytes / 2, 16);
break;
case 32:
ret = fbScreenInit(pScreen, g_rdpScreen.pfbMemory,
g_rdpScreen.width, g_rdpScreen.height,
dpix, dpiy, g_rdpScreen.paddedWidthInBytes / 4, 32);
break;
default:
ErrorF("rdpScreenInit: error\n");
return 0;
}
if (!ret)
{
ErrorF("rdpScreenInit: error\n");
return 0;
}
miInitializeBackingStore(pScreen);
/* this is for rgb, not bgr, just doing rgb for now */
vis = g_pScreen->visuals + (g_pScreen->numVisuals - 1);
while (vis >= pScreen->visuals)
{
if ((vis->class | DynamicClass) == DirectColor)
{
vis->offsetBlue = 0;
vis->blueMask = (1 << g_blueBits) - 1;
vis->offsetGreen = g_blueBits;
vis->greenMask = ((1 << g_greenBits) - 1) << vis->offsetGreen;
vis->offsetRed = g_blueBits + g_greenBits;
vis->redMask = ((1 << g_redBits) - 1) << vis->offsetRed;
}
vis--;
}
if (g_rdpScreen.bitsPerPixel > 4)
{
fbPictureInit(pScreen, 0, 0);
}
if (!dixRegisterPrivateKey(&g_rdpGCIndex, PRIVATE_GC, sizeof(rdpGCRec)))
{
FatalError("rdpScreenInit: dixRegisterPrivateKey PRIVATE_GC failed\n");
}
if (!dixRegisterPrivateKey(&g_rdpWindowIndex, PRIVATE_WINDOW, sizeof(rdpWindowRec)))
{
FatalError("rdpScreenInit: dixRegisterPrivateKey PRIVATE_WINDOW failed\n");
}
if (!dixRegisterPrivateKey(&g_rdpPixmapIndex, PRIVATE_PIXMAP, sizeof(rdpPixmapRec)))
{
FatalError("rdpScreenInit: dixRegisterPrivateKey PRIVATE_PIXMAP failed\n");
}
/* Random screen procedures */
g_rdpScreen.CloseScreen = pScreen->CloseScreen;
/* GC procedures */
g_rdpScreen.CreateGC = pScreen->CreateGC;
/* Pixmap procedures */
g_rdpScreen.CreatePixmap = pScreen->CreatePixmap;
g_rdpScreen.DestroyPixmap = pScreen->DestroyPixmap;
/* Window Procedures */
g_rdpScreen.CreateWindow = pScreen->CreateWindow;
g_rdpScreen.DestroyWindow = pScreen->DestroyWindow;
g_rdpScreen.ChangeWindowAttributes = pScreen->ChangeWindowAttributes;
g_rdpScreen.RealizeWindow = pScreen->RealizeWindow;
g_rdpScreen.UnrealizeWindow = pScreen->UnrealizeWindow;
g_rdpScreen.PositionWindow = pScreen->PositionWindow;
g_rdpScreen.WindowExposures = pScreen->WindowExposures;
g_rdpScreen.CopyWindow = pScreen->CopyWindow;
g_rdpScreen.ClearToBackground = pScreen->ClearToBackground;
/* Backing store procedures */
g_rdpScreen.RestoreAreas = pScreen->RestoreAreas;
g_rdpScreen.WakeupHandler = pScreen->WakeupHandler;
g_rdpScreen.CreateColormap = pScreen->CreateColormap;
g_rdpScreen.DestroyColormap = pScreen->DestroyColormap;
ps = GetPictureScreenIfSet(pScreen);
if (ps)
{
g_rdpScreen.CreatePicture = ps->CreatePicture;
g_rdpScreen.DestroyPicture = ps->DestroyPicture;
g_rdpScreen.Composite = ps->Composite;
g_rdpScreen.Glyphs = ps->Glyphs;
}
pScreen->blackPixel = g_rdpScreen.blackPixel;
pScreen->whitePixel = g_rdpScreen.whitePixel;
/* Random screen procedures */
pScreen->CloseScreen = rdpCloseScreen;
pScreen->WakeupHandler = rdpWakeupHandler;
if (ps)
{
ps->CreatePicture = rdpCreatePicture;
ps->DestroyPicture = rdpDestroyPicture;
ps->Composite = rdpComposite;
ps->Glyphs = rdpGlyphs;
}
pScreen->SaveScreen = rdpSaveScreen;
/* GC procedures */
pScreen->CreateGC = rdpCreateGC;
if (g_wrapPixmap)
{
/* Pixmap procedures */
pScreen->CreatePixmap = rdpCreatePixmap;
pScreen->DestroyPixmap = rdpDestroyPixmap;
}
if (g_wrapWindow)
{
/* Window Procedures */
pScreen->CreateWindow = rdpCreateWindow;
pScreen->DestroyWindow = rdpDestroyWindow;
pScreen->ChangeWindowAttributes = rdpChangeWindowAttributes;
pScreen->RealizeWindow = rdpRealizeWindow;
pScreen->UnrealizeWindow = rdpUnrealizeWindow;
pScreen->PositionWindow = rdpPositionWindow;
pScreen->WindowExposures = rdpWindowExposures;
}
pScreen->CopyWindow = rdpCopyWindow;
pScreen->ClearToBackground = rdpClearToBackground;
/* Backing store procedures */
pScreen->RestoreAreas = rdpRestoreAreas;
#if 0
pScreen->CreateColormap = rdpCreateColormap;
pScreen->DestroyColormap = rdpDestroyColormap;
#endif
miPointerInitialize(pScreen, &g_rdpSpritePointerFuncs,
&g_rdpPointerCursorFuncs, 1);
#if 0
pScreen->DeviceCursorInitialize = rdpDeviceCursorInitialize;
pScreen->DeviceCursorCleanup = rdpDeviceCursorCleanup;
#endif
vis_found = 0;
vis = g_pScreen->visuals + (g_pScreen->numVisuals - 1);
while (vis >= pScreen->visuals)
{
if (vis->vid == pScreen->rootVisual)
{
vis_found = 1;
}
vis--;
}
if (!vis_found)
{
rdpLog("rdpScreenInit: couldn't find root visual\n");
exit(1);
}
ret = 1;
if (ret)
{
ret = fbCreateDefColormap(pScreen);
if (!ret)
{
ErrorF("rdpScreenInit: fbCreateDefColormap failed\n");
}
}
if (ret)
{
ret = rdpup_init();
if (!ret)
{
ErrorF("rdpScreenInit: rdpup_init failed\n");
}
}
if (ret)
{
RegisterBlockAndWakeupHandlers(rdpBlockHandler1, rdpWakeupHandler1, NULL);
}
if (!RRScreenInit(pScreen))
{
ErrorF("rdpmain.c: RRScreenInit: screen init failed\n");
}
else
{
pRRScrPriv = rrGetScrPriv(pScreen);
ErrorF("pRRScrPriv %p\n", pRRScrPriv);
pRRScrPriv->rrSetConfig = rdpRRSetConfig;
pRRScrPriv->rrGetInfo = rdpRRGetInfo;
pRRScrPriv->rrScreenSetSize = rdpRRScreenSetSize;
pRRScrPriv->rrCrtcSet = rdpRRCrtcSet;
pRRScrPriv->rrCrtcGetGamma = rdpRRCrtcGetGamma;
pRRScrPriv->rrCrtcSetGamma = rdpRRCrtcSetGamma;
pRRScrPriv->rrOutputSetProperty = rdpRROutputSetProperty;
pRRScrPriv->rrOutputValidateMode = rdpRROutputValidateMode;
pRRScrPriv->rrModeDestroy = rdpRRModeDestroy;
pRRScrPriv->rrOutputGetProperty = rdpRROutputGetProperty;
pRRScrPriv->rrGetPanning = rdpRRGetPanning;
pRRScrPriv->rrSetPanning = rdpRRSetPanning;
}
rdpGlyphInit();
//rdpXvInit(pScreen);
rdpSetUDSRights();
ErrorF("rdpScreenInit: ret %d\n", ret);
return ret;
}
/******************************************************************************/
/* this is the first function called, it can be called many times
returns the number or parameters processed
if it doesn't apply to the rdp part, return 0 */
int
ddxProcessArgument(int argc, char **argv, int i)
{
if (g_firstTime)
{
memset(&g_rdpScreen, 0, sizeof(g_rdpScreen));
g_rdpScreen.width = 1024;
g_rdpScreen.height = 768;
g_rdpScreen.depth = 24;
set_bpp(24);
g_rdpScreen.blackPixel = 1;
g_firstTime = 0;
RRExtensionInit();
}
if (strcmp(argv[i], "-geometry") == 0)
{
if (i + 1 >= argc)
{
UseMsg();
}
if (sscanf(argv[i + 1], "%dx%d", &g_rdpScreen.width,
&g_rdpScreen.height) != 2)
{
ErrorF("Invalid geometry %s\n", argv[i + 1]);
UseMsg();
}
return 2;
}
if (strcmp(argv[i], "-depth") == 0)
{
if (i + 1 >= argc)
{
UseMsg();
}
g_rdpScreen.depth = atoi(argv[i + 1]);
if (set_bpp(g_rdpScreen.depth) != 0)
{
UseMsg();
}
return 2;
}
if (strcmp(argv[i], "-uds") == 0)
{
g_use_uds = 1;
return 1;
}
return 0;
}
/******************************************************************************/
void
OsVendorInit(void)
{
#if XRDP_DISABLE_LINUX_ABSTRACT
/* turn off the Linux abstract unix domain sockets TRANS_ABSTRACT */
/* TRANS_NOLISTEN = 1 << 3 */
_XSERVTransSocketLocalFuncs.flags = 0;
#endif
}
/******************************************************************************/
/* ddxInitGlobals - called by |InitGlobals| from os/util.c */
void
ddxInitGlobals(void)
{
}
/******************************************************************************/
int
XkbDDXSwitchScreen(DeviceIntPtr dev, KeyCode key, XkbAction *act)
{
ErrorF("XkbDDXSwitchScreen:\n");
return 1;
}
/******************************************************************************/
int
XkbDDXPrivate(DeviceIntPtr dev, KeyCode key, XkbAction *act)
{
ErrorF("XkbDDXPrivate:\n");
return 0;
}
/******************************************************************************/
int
XkbDDXTerminateServer(DeviceIntPtr dev, KeyCode key, XkbAction *act)
{
ErrorF("XkbDDXTerminateServer:\n");
GiveUp(1);
return 0;
}
/******************************************************************************/
/* InitOutput is called every time the server resets. It should call
AddScreen for each screen (but we only ever have one), and in turn this
will call rdpScreenInit. */
void
InitOutput(ScreenInfo *screenInfo, int argc, char **argv)
{
int i;
ErrorF("InitOutput:\n");
g_initOutputCalled = 1;
/* initialize pixmap formats */
screenInfo->imageByteOrder = IMAGE_BYTE_ORDER;
screenInfo->bitmapScanlineUnit = BITMAP_SCANLINE_UNIT;
screenInfo->bitmapScanlinePad = BITMAP_SCANLINE_PAD;
screenInfo->bitmapBitOrder = BITMAP_BIT_ORDER;
screenInfo->numPixmapFormats = g_numFormats;
for (i = 0; i < g_numFormats; i++)
{
screenInfo->formats[i] = g_formats[i];
}
if (!AddCallback(&ClientStateCallback, rdpClientStateChange, NULL))
{
rdpLog("InitOutput: AddCallback failed\n");
return;
}
/* initialize screen */
if (AddScreen(rdpScreenInit, argc, argv) == -1)
{
FatalError("Couldn't add screen\n");
}
ErrorF("InitOutput: out\n");
}
/******************************************************************************/
void
InitInput(int argc, char **argv)
{
int rc;
ErrorF("InitInput:\n");
rc = AllocDevicePair(serverClient, "X11rdp", &g_pointer, &g_keyboard,
rdpMouseProc, rdpKeybdProc, 0);
if (rc != Success)
{
FatalError("Failed to init X11rdp default devices.\n");
}
mieqInit();
}
/******************************************************************************/
void
ddxGiveUp(void)
{
char unixSocketName[128];
ErrorF("ddxGiveUp:\n");
g_free(g_rdpScreen.pfbMemory);
if (g_initOutputCalled)
{
sprintf(unixSocketName, "/tmp/.X11-unix/X%s", display);
unlink(unixSocketName);
sprintf(unixSocketName, "%s/xrdp_disconnect_display_%s",
g_socket_dir(), display);
unlink(unixSocketName);
if (g_uds_data[0] != 0)
{
unlink(g_uds_data);
}
}
}
/******************************************************************************/
Bool
LegalModifier(unsigned int key, DeviceIntPtr pDev)
{
return 1; /* true */
}
/******************************************************************************/
void
ProcessInputEvents(void)
{
mieqProcessInputEvents();
}
/******************************************************************************/
/* needed for some reason? todo
needs to be rfb */
void
rfbRootPropertyChange(PropertyPtr pProp)
{
}
/******************************************************************************/
void
AbortDDX(void)
{
ddxGiveUp();
}
/******************************************************************************/
void
OsVendorFatalError(void)
{
}
/******************************************************************************/
/* print the command list parameters and exit the program */
void
ddxUseMsg(void)
{
ErrorF("\n");
ErrorF("X11rdp specific options\n");
ErrorF("-geometry WxH set framebuffer width & height\n");
ErrorF("-depth D set framebuffer depth\n");
ErrorF("-uds create and listen on xrdp_display_x\n");
ErrorF("\n");
exit(1);
}
/******************************************************************************/
void
OsVendorPreInit(void)
{
}
/******************************************************************************/
void
CloseInput(void)
{
ErrorF("CloseInput\n");
}
/******************************************************************************/
void
DDXRingBell(int volume, int pitch, int duration)
{
ErrorF("DDXRingBell\n");
}
/******************************************************************************/
void
DeleteInputDeviceRequest(DeviceIntPtr dev)
{
ErrorF("DeleteInputDeviceRequest\n");
}

@ -1,696 +0,0 @@
/*
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 "rdp.h"
#include <sys/un.h>
Bool noFontCacheExtension = 1;
static int g_crc_seed = 0xffffffff;
static int g_crc_table[256] =
{
0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f,
0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988,
0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2,
0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172,
0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c,
0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59,
0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423,
0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x01db7106,
0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f, 0x9fbfe4a5, 0xe8b8d433,
0x7807c9a2, 0x0f00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x086d3d2d,
0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e,
0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65,
0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7,
0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0,
0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa,
0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81,
0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x03b6e20c, 0x74b1d29a,
0xead54739, 0x9dd277af, 0x04db2615, 0x73dc1683, 0xe3630b12, 0x94643b84,
0x0d6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1,
0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc,
0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e,
0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b,
0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55,
0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28,
0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d,
0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x026d930a, 0x9c0906a9, 0xeb0e363f,
0x72076785, 0x05005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38,
0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777,
0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69,
0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2,
0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc,
0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693,
0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94,
0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d
};
#define CRC_START(in_crc) (in_crc) = g_crc_seed
#define CRC_PASS(in_pixel, in_crc) \
(in_crc) = g_crc_table[((in_crc) ^ (in_pixel)) & 0xff] ^ ((in_crc) >> 8)
#define CRC_END(in_crc) (in_crc) = ((in_crc) ^ g_crc_seed)
/******************************************************************************/
/* print a time-stamped message to the log file (stderr). */
void
rdpLog(char *format, ...)
{
va_list args;
char buf[256];
time_t clock;
va_start(args, format);
time(&clock);
strftime(buf, 255, "%d/%m/%y %T ", localtime(&clock));
fprintf(stderr, "%s", buf);
vfprintf(stderr, format, args);
fflush(stderr);
va_end(args);
}
/******************************************************************************/
int
rdpBitsPerPixel(int depth)
{
if (depth == 1)
{
return 1;
}
else if (depth <= 8)
{
return 8;
}
else if (depth <= 16)
{
return 16;
}
else
{
return 32;
}
}
/******************************************************************************/
void
rdpClientStateChange(CallbackListPtr *cbl, pointer myData, pointer clt)
{
dispatchException &= ~DE_RESET; /* hack - force server not to reset */
}
/******************************************************************************/
int
DPMSSupported(void)
{
return 0;
}
/******************************************************************************/
int
DPSMGet(int *level)
{
return -1;
}
/******************************************************************************/
void
DPMSSet(int level)
{
}
/******************************************************************************/
void
AddOtherInputDevices(void)
{
}
/******************************************************************************/
void
OpenInputDevice(DeviceIntPtr dev, ClientPtr client, int *status)
{
}
/******************************************************************************/
int
SetDeviceValuators(register ClientPtr client, DeviceIntPtr dev,
int *valuators, int first_valuator, int num_valuators)
{
return BadMatch;
}
/******************************************************************************/
int
SetDeviceMode(register ClientPtr client, DeviceIntPtr dev, int mode)
{
return BadMatch;
}
/******************************************************************************/
int
ChangeKeyboardDevice(DeviceIntPtr old_dev, DeviceIntPtr new_dev)
{
return BadMatch;
}
/******************************************************************************/
int
ChangeDeviceControl(register ClientPtr client, DeviceIntPtr dev,
void *control)
{
return BadMatch;
}
/******************************************************************************/
int
ChangePointerDevice(DeviceIntPtr old_dev, DeviceIntPtr new_dev,
unsigned char x, unsigned char y)
{
return BadMatch;
}
/******************************************************************************/
void
CloseInputDevice(DeviceIntPtr d, ClientPtr client)
{
}
/* 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;
//#ifdef _XSERVER64
#if 1
/* I thought xalloc would work here but I guess not, why, todo */
rv = (char *)malloc(size);
#else
rv = (char *)Xalloc(size);
#endif
if (zero)
{
if (rv != 0)
{
memset(rv, 0, size);
}
}
return rv;
}
/*****************************************************************************/
void
g_free(void *ptr)
{
if (ptr != 0)
{
//#ifdef _XSERVER64
#if 1
/* I thought xfree would work here but I guess not, why, todo */
free(ptr);
#else
Xfree(ptr);
#endif
}
}
/*****************************************************************************/
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);
}
/*****************************************************************************/
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);
}
/*****************************************************************************/
/* returns directory where UNIX sockets are located */
const char *
g_socket_dir(void)
{
const char *socket_dir;
socket_dir = getenv("XRDP_SOCKET_PATH");
if (socket_dir == NULL || socket_dir[0] == '\0')
{
socket_dir = "/tmp/.xrdp";
}
return socket_dir;
}
/* produce a hex dump */
void
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;
}
}
/*
stub for XpClient* functions.
*/
/*****************************************************************************/
Bool
XpClientIsBitmapClient(ClientPtr client)
{
return 1;
}
/*****************************************************************************/
Bool
XpClientIsPrintClient(ClientPtr client, FontPathElementPtr fpe)
{
return 0;
}
/*****************************************************************************/
int
PrinterOptions(int argc, char **argv, int i)
{
return i;
}
/*****************************************************************************/
void
PrinterInitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
{
}
/*****************************************************************************/
void
PrinterUseMsg(void)
{
}
/*****************************************************************************/
void
PrinterInitGlobals(void)
{
}
/*****************************************************************************/
void
FontCacheExtensionInit(INITARGS)
{
}
/******************************************************************************/
void
RegionAroundSegs(RegionPtr reg, xSegment *segs, int nseg)
{
int index;
BoxRec box;
RegionRec treg;
index = 0;
while (index < nseg)
{
if (segs[index].x1 < segs[index].x2)
{
box.x1 = segs[index].x1;
box.x2 = segs[index].x2;
}
else
{
box.x1 = segs[index].x2;
box.x2 = segs[index].x1;
}
box.x2++;
if (segs[index].y1 < segs[index].y2)
{
box.y1 = segs[index].y1;
box.y2 = segs[index].y2;
}
else
{
box.y1 = segs[index].y2;
box.y2 = segs[index].y1;
}
box.y2++;
RegionInit(&treg, &box, 0);
RegionUnion(reg, reg, &treg);
RegionUninit(&treg);
index++;
}
}
/******************************************************************************/
int
get_crc(char* data, int data_bytes)
{
int crc;
int index;
CRC_START(crc);
for (index = 0; index < data_bytes; index++)
{
CRC_PASS(data[index], crc);
}
CRC_END(crc);
return crc;
}
/*****************************************************************************/
int
get_mstime(void)
{
struct timeval tp;
gettimeofday(&tp, 0);
return (tp.tv_sec * 1000) + (tp.tv_usec / 1000);
}

@ -1,456 +0,0 @@
/*
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 extension implementation
*/
#include "rdp.h"
#include "rdprandr.h"
#if 1
#define DEBUG_OUT(arg)
#else
#define DEBUG_OUT(arg) ErrorF arg
#endif
extern rdpScreenInfoRec g_rdpScreen; /* from rdpmain.c */
extern DeviceIntPtr g_pointer; /* in rdpmain.c */
extern DeviceIntPtr g_keyboard; /* in rdpmain.c */
extern ScreenPtr g_pScreen; /* in rdpmain.c */
extern WindowPtr g_invalidate_window; /* in rdpmain.c */
static XID g_wid = 0;
static int g_panning = 0;
#define LOG_LEVEL 1
#define LLOG(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; } } while (0)
#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;
ErrorF("rdpRRRegisterSize: width %d height %d\n", 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)
{
ErrorF("rdpRRSetConfig:\n");
return TRUE;
}
/******************************************************************************/
Bool
rdpRRGetInfo(ScreenPtr pScreen, Rotation *pRotations)
{
ErrorF("rdpRRGetInfo:\n");
*pRotations = RR_Rotate_0;
return TRUE;
}
/******************************************************************************/
/* for lack of a better way, a window is created that covers the area and
when its deleted, it's invalidated */
static int
rdpInvalidateArea(ScreenPtr pScreen, int x, int y, int cx, int cy)
{
WindowPtr pWin;
int result;
int attri;
XID attributes[4];
Mask mask;
DEBUG_OUT(("rdpInvalidateArea:\n"));
mask = 0;
attri = 0;
attributes[attri++] = pScreen->blackPixel;
mask |= CWBackPixel;
attributes[attri++] = xTrue;
mask |= CWOverrideRedirect;
if (g_wid == 0)
{
g_wid = FakeClientID(0);
}
pWin = CreateWindow(g_wid, pScreen->root,
x, y, cx, cy, 0, InputOutput, mask,
attributes, 0, serverClient,
wVisual(pScreen->root), &result);
if (result == 0)
{
g_invalidate_window = pWin;
MapWindow(pWin, serverClient);
DeleteWindow(pWin, None);
g_invalidate_window = pWin;
}
return 0;
}
/******************************************************************************/
Bool
rdpRRScreenSetSize(ScreenPtr pScreen, CARD16 width, CARD16 height,
CARD32 mmWidth, CARD32 mmHeight)
{
PixmapPtr screenPixmap;
BoxRec box;
ErrorF("rdpRRScreenSetSize: width %d height %d mmWidth %d mmHeight %d\n",
width, height, (int)mmWidth, (int)mmHeight);
if ((width < 1) || (height < 1))
{
ErrorF(" error width %d height %d\n", width, height);
return FALSE;
}
g_rdpScreen.width = width;
g_rdpScreen.height = height;
g_rdpScreen.paddedWidthInBytes =
PixmapBytePad(g_rdpScreen.width, g_rdpScreen.depth);
g_rdpScreen.sizeInBytes =
g_rdpScreen.paddedWidthInBytes * g_rdpScreen.height;
pScreen->width = width;
pScreen->height = height;
pScreen->mmWidth = mmWidth;
pScreen->mmHeight = mmHeight;
screenPixmap = pScreen->GetScreenPixmap(pScreen);
if (screenPixmap != 0)
{
ErrorF(" resizing screenPixmap [%p] to %dx%d, currently at %dx%d\n",
(void *)screenPixmap, width, height,
screenPixmap->drawable.width, screenPixmap->drawable.height);
if (g_rdpScreen.sizeInBytes > g_rdpScreen.sizeInBytesAlloc)
{
g_free(g_rdpScreen.pfbMemory);
g_rdpScreen.pfbMemory = (char*)g_malloc(g_rdpScreen.sizeInBytes, 1);
g_rdpScreen.sizeInBytesAlloc = g_rdpScreen.sizeInBytes;
ErrorF("new buffer size %d\n", g_rdpScreen.sizeInBytes);
}
pScreen->ModifyPixmapHeader(screenPixmap, width, height,
g_rdpScreen.depth, g_rdpScreen.bitsPerPixel,
g_rdpScreen.paddedWidthInBytes,
g_rdpScreen.pfbMemory);
ErrorF(" pixmap resized to %dx%d\n",
screenPixmap->drawable.width, screenPixmap->drawable.height);
}
DEBUG_OUT((" root window %p\n", (void *)pScreen->root));
box.x1 = 0;
box.y1 = 0;
box.x2 = width;
box.y2 = height;
RegionInit(&pScreen->root->winSize, &box, 1);
RegionInit(&pScreen->root->borderSize, &box, 1);
RegionReset(&pScreen->root->borderClip, &box);
RegionBreak(&pScreen->root->clipList);
pScreen->root->drawable.width = width;
pScreen->root->drawable.height = height;
ResizeChildrenWinSize(pScreen->root, 0, 0, 0, 0);
RRGetInfo(pScreen, 1);
RRScreenSizeNotify(pScreen);
rdpInvalidateArea(g_pScreen, 0, 0, g_rdpScreen.width, g_rdpScreen.height);
ErrorF(" screen resized to %dx%d\n",
pScreen->width, pScreen->height);
return TRUE;
}
/******************************************************************************/
Bool
rdpRRCrtcSet(ScreenPtr pScreen, RRCrtcPtr crtc, RRModePtr mode,
int x, int y, Rotation rotation, int numOutputs,
RROutputPtr *outputs)
{
ErrorF("rdpRRCrtcSet:\n");
return TRUE;
}
/******************************************************************************/
Bool
rdpRRCrtcSetGamma(ScreenPtr pScreen, RRCrtcPtr crtc)
{
ErrorF("rdpRRCrtcSetGamma:\n");
return TRUE;
}
/******************************************************************************/
Bool
rdpRRCrtcGetGamma(ScreenPtr pScreen, RRCrtcPtr crtc)
{
ErrorF("rdpRRCrtcGetGamma:\n");
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)
{
ErrorF("rdpRROutputSetProperty:\n");
return TRUE;
}
/******************************************************************************/
Bool
rdpRROutputValidateMode(ScreenPtr pScreen, RROutputPtr output,
RRModePtr mode)
{
ErrorF("rdpRROutputValidateMode:\n");
return TRUE;
}
/******************************************************************************/
void
rdpRRModeDestroy(ScreenPtr pScreen, RRModePtr mode)
{
ErrorF("rdpRRModeDestroy:\n");
}
/******************************************************************************/
Bool
rdpRROutputGetProperty(ScreenPtr pScreen, RROutputPtr output, Atom property)
{
ErrorF("rdpRROutputGetProperty:\n");
return TRUE;
}
/******************************************************************************/
Bool
rdpRRGetPanning(ScreenPtr pScrn, RRCrtcPtr crtc, BoxPtr totalArea,
BoxPtr trackingArea, INT16 *border)
{
ErrorF("rdpRRGetPanning:\n");
if (!g_panning)
{
return FALSE;
}
if (totalArea != 0)
{
totalArea->x1 = 0;
totalArea->y1 = 0;
totalArea->x2 = g_rdpScreen.width;
totalArea->y2 = g_rdpScreen.height;
}
if (trackingArea != 0)
{
trackingArea->x1 = 0;
trackingArea->y1 = 0;
trackingArea->x2 = g_rdpScreen.width;
trackingArea->y2 = g_rdpScreen.height;
}
if (border != 0)
{
border[0] = 0;
border[1] = 0;
border[2] = 0;
border[3] = 0;
}
return TRUE;
}
/******************************************************************************/
Bool
rdpRRSetPanning(ScreenPtr pScrn, RRCrtcPtr crtc, BoxPtr totalArea,
BoxPtr trackingArea, INT16 *border)
{
ErrorF("rdpRRSetPanning:\n");
return TRUE;
}
/******************************************************************************/
static RROutputPtr
rdpRRAddOutput(const char *aname, int x, int y, int width, int height)
{
RRModePtr mode;
RRCrtcPtr crtc;
RROutputPtr output;
xRRModeInfo modeInfo;
char name[64];
const int vfreq = 50;
sprintf (name, "%dx%d", width, height);
memset (&modeInfo, 0, sizeof(modeInfo));
modeInfo.width = width;
modeInfo.height = height;
modeInfo.hTotal = width;
modeInfo.vTotal = height;
modeInfo.dotClock = vfreq * width * height;
modeInfo.nameLength = strlen(name);
mode = RRModeGet(&modeInfo, name);
if (mode == 0)
{
LLOGLN(0, ("rdpRRAddOutput: RRModeGet failed"));
return 0;
}
crtc = RRCrtcCreate(g_pScreen, NULL);
if (crtc == 0)
{
LLOGLN(0, ("rdpRRAddOutput: RRCrtcCreate failed"));
RRModeDestroy(mode);
return 0;
}
output = RROutputCreate(g_pScreen, aname, strlen(aname), NULL);
if (output == 0)
{
LLOGLN(0, ("rdpRRAddOutput: RROutputCreate failed"));
RRCrtcDestroy(crtc);
RRModeDestroy(mode);
return 0;
}
if (!RROutputSetClones(output, NULL, 0))
{
LLOGLN(0, ("rdpRRAddOutput: RROutputSetClones failed"));
}
if (!RROutputSetModes(output, &mode, 1, 0))
{
LLOGLN(0, ("rdpRRAddOutput: RROutputSetModes failed"));
}
if (!RROutputSetCrtcs(output, &crtc, 1))
{
LLOGLN(0, ("rdpRRAddOutput: RROutputSetCrtcs failed"));
}
if (!RROutputSetConnection(output, RR_Connected))
{
LLOGLN(0, ("rdpRRAddOutput: RROutputSetConnection failed"));
}
RRCrtcNotify(crtc, mode, x, y, RR_Rotate_0, NULL, 1, &output);
return output;
}
/******************************************************************************/
static void
RRSetPrimaryOutput(rrScrPrivPtr pScrPriv, RROutputPtr output)
{
if (pScrPriv->primaryOutput == output)
{
return;
}
/* clear the old primary */
if (pScrPriv->primaryOutput)
{
RROutputChanged(pScrPriv->primaryOutput, 0);
pScrPriv->primaryOutput = NULL;
}
/* set the new primary */
if (output)
{
pScrPriv->primaryOutput = output;
RROutputChanged(output, 0);
}
pScrPriv->layoutChanged = TRUE;
}
/******************************************************************************/
int
rdpRRSetRdpOutputs(void)
{
rrScrPrivPtr pRRScrPriv;
int index;
int width;
int height;
char text[256];
RROutputPtr output;
pRRScrPriv = rrGetScrPriv(g_pScreen);
LLOGLN(0, ("rdpRRSetRdpOutputs: numCrtcs %d", pRRScrPriv->numCrtcs));
while (pRRScrPriv->numCrtcs > 0)
{
RRCrtcDestroy(pRRScrPriv->crtcs[0]);
}
LLOGLN(0, ("rdpRRSetRdpOutputs: numOutputs %d", pRRScrPriv->numOutputs));
while (pRRScrPriv->numOutputs > 0)
{
RROutputDestroy(pRRScrPriv->outputs[0]);
}
if (g_rdpScreen.client_info.monitorCount == 0)
{
rdpRRAddOutput("rdp0", 0, 0, g_rdpScreen.width, g_rdpScreen.height);
}
else
{
for (index = 0; index < g_rdpScreen.client_info.monitorCount; index++)
{
snprintf(text, 255, "rdp%d", index);
width = g_rdpScreen.client_info.minfo[index].right - g_rdpScreen.client_info.minfo[index].left + 1;
height = g_rdpScreen.client_info.minfo[index].bottom - g_rdpScreen.client_info.minfo[index].top + 1;
output = rdpRRAddOutput(text,
g_rdpScreen.client_info.minfo[index].left,
g_rdpScreen.client_info.minfo[index].top,
width, height);
if ((output != 0) && (g_rdpScreen.client_info.minfo[index].is_primary))
{
RRSetPrimaryOutput(pRRScrPriv, output);
}
}
}
#if 0
for (index = 0; index < pRRScrPriv->numOutputs; index++)
{
RROutputSetCrtcs(pRRScrPriv->outputs[index], pRRScrPriv->crtcs,
pRRScrPriv->numCrtcs);
}
#endif
return 0;
}

@ -1,63 +0,0 @@
/*
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);
int
rdpRRSetRdpOutputs(void);
#endif

File diff suppressed because it is too large Load Diff

@ -1,448 +0,0 @@
/*
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.
XVideo extension
*/
#include "rdp.h"
#include <X11/extensions/Xv.h>
#include <X11/extensions/Xvproto.h>
#include "xvdix.h"
#include <fourcc.h>
extern rdpScreenInfoRec g_rdpScreen; /* from rdpmain.c */
static DevPrivateKey g_XvScreenKey;
static char g_xv_adaptor_name[] = "xrdp XVideo adaptor";
static char g_xv_encoding_name[] = "XV_IMAGE";
#define GET_XV_SCREEN(pScreen) \
((XvScreenPtr)dixLookupPrivate(&(pScreen)->devPrivates, g_XvScreenKey))
#define LOG_LEVEL 1
#define LLOG(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; } } while (0)
#define LLOGLN(_level, _args) \
do { if (_level < LOG_LEVEL) { ErrorF _args ; ErrorF("\n"); } } while (0)
#define T_NUM_ENCODINGS 1
static XvEncodingRec g_encodings[T_NUM_ENCODINGS];
#define T_NUM_FORMATS 1
static XvFormatRec g_formats[T_NUM_FORMATS];
#define T_NUM_PORTS 1
static XvPortRec g_ports[T_NUM_PORTS];
#define FOURCC_RV15 0x35315652
#define FOURCC_RV16 0x36315652
#define FOURCC_RV24 0x34325652
#define FOURCC_RV32 0x32335652
#define T_NUM_IMAGES 8
static XvImageRec g_images[T_NUM_IMAGES] =
{
{
FOURCC_RV15,XvRGB,LSBFirst,
{'R','V','1','5',0,0,0,0,0,0,0,0,0,0,0,0},
16, XvPacked, 1, 15, 0x001f, 0x03e0, 0x7c00, 0, 0, 0, 0, 0, 0, 0, 0, 0,
{'R','V','B',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
XvTopToBottom
},
{
FOURCC_RV16,XvRGB,LSBFirst,
{'R','V','1','6',0,0,0,0,0,0,0,0,0,0,0,0},
16, XvPacked, 1, 16, 0x001f, 0x07e0, 0xf800, 0, 0, 0, 0, 0, 0, 0, 0, 0,
{'R','V','B',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
XvTopToBottom
},
{
FOURCC_RV24,XvRGB,LSBFirst,
{'R','V','2','4',0,0,0,0,0,0,0,0,0,0,0,0},
32, XvPacked, 1, 24, 0x000000ff, 0x0000ff00, 0x00ff0000, 0, 0, 0, 0, 0, 0, 0, 0, 0,
{'R','V','B',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
XvTopToBottom
},
{
FOURCC_RV32, XvRGB, LSBFirst,
{'R','V','3','2',0,0,0,0,0,0,0,0,0,0,0,0},
32, XvPacked, 1, 32, 0x000000ff, 0x0000ff00, 0x00ff0000, 0, 0, 0, 0, 0, 0, 0, 0, 0,
{'R','V','B',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
XvTopToBottom
},
XVIMAGE_YV12,
XVIMAGE_YUY2,
XVIMAGE_UYVY,
XVIMAGE_I420
};
/*****************************************************************************/
static int
rdpXvAllocatePort(unsigned long port, XvPortPtr pPort, XvPortPtr* ppPort)
{
LLOGLN(0, ("rdpXvAllocatePort:"));
*ppPort = pPort;
return Success;
}
/*****************************************************************************/
static int
rdpXvFreePort(XvPortPtr pPort)
{
LLOGLN(0, ("rdpXvFreePort:"));
return Success;
}
/*****************************************************************************/
static int
rdpXvPutVideo(ClientPtr client, DrawablePtr pDraw, XvPortPtr pPort, GCPtr pGC,
INT16 vid_x, INT16 vid_y, CARD16 vid_w, CARD16 vid_h,
INT16 drw_x, INT16 drw_y, CARD16 drw_w, CARD16 drw_h)
{
LLOGLN(0, ("rdpXvPutVideo:"));
return Success;
}
/*****************************************************************************/
static int
rdpXvPutStill(ClientPtr client, DrawablePtr pDraw, XvPortPtr pPort, GCPtr pGC,
INT16 vid_x, INT16 vid_y, CARD16 vid_w, CARD16 vid_h,
INT16 drw_x, INT16 drw_y, CARD16 drw_w, CARD16 drw_h)
{
LLOGLN(0, ("rdpXvPutStill:"));
return Success;
}
/*****************************************************************************/
static int
rdpXvGetVideo(ClientPtr client, DrawablePtr pDraw, XvPortPtr pPort, GCPtr pGC,
INT16 vid_x, INT16 vid_y, CARD16 vid_w, CARD16 vid_h,
INT16 drw_x, INT16 drw_y, CARD16 drw_w, CARD16 drw_h)
{
LLOGLN(0, ("rdpXvGetVideo:"));
return Success;
}
/*****************************************************************************/
static int
rdpXvGetStill(ClientPtr client, DrawablePtr pDraw, XvPortPtr pPort, GCPtr pGC,
INT16 vid_x, INT16 vid_y, CARD16 vid_w, CARD16 vid_h,
INT16 drw_x, INT16 drw_y, CARD16 drw_w, CARD16 drw_h)
{
LLOGLN(0, ("rdpXvGetStill:"));
return Success;
}
/*****************************************************************************/
static int
rdpXvStopVideo(ClientPtr client, XvPortPtr pPort, DrawablePtr pDraw)
{
LLOGLN(0, ("rdpXvStopVideo:"));
return Success;
}
/*****************************************************************************/
static int
rdpXvSetPortAttribute(ClientPtr client, XvPortPtr pPort, Atom attribute,
INT32 value)
{
LLOGLN(0, ("rdpXvSetPortAttribute:"));
return Success;
}
/*****************************************************************************/
static int
rdpXvGetPortAttribute(ClientPtr client, XvPortPtr pPort, Atom attribute,
INT32* p_value)
{
LLOGLN(0, ("rdpXvGetPortAttribute:"));
return Success;
}
/*****************************************************************************/
static int
rdpXvQueryBestSize(ClientPtr client, XvPortPtr pPort, CARD8 motion,
CARD16 vid_w, CARD16 vid_h, CARD16 drw_w, CARD16 drw_h,
unsigned int *p_w, unsigned int *p_h)
{
LLOGLN(0, ("rdpXvQueryBestSize:"));
return Success;
}
/*****************************************************************************/
static int
rdpXvPutImage(ClientPtr client, DrawablePtr pDraw, XvPortPtr pPort, GCPtr pGC,
INT16 src_x, INT16 src_y, CARD16 src_w, CARD16 src_h,
INT16 drw_x, INT16 drw_y, CARD16 drw_w, CARD16 drw_h,
XvImagePtr format, unsigned char* data, Bool sync,
CARD16 width, CARD16 height)
{
LLOGLN(0, ("rdpXvPutImage:"));
return Success;
}
/*****************************************************************************/
static int
rdpXvPrintFormat(int id)
{
switch (id)
{
case FOURCC_YV12:
/* big buck bunny 480p h264 */
/* vob files too */
LLOGLN(0, ("FOURCC_YV12"));
break;
case FOURCC_I420:
LLOGLN(0, ("FOURCC_I420"));
break;
case FOURCC_RV15:
LLOGLN(0, ("FOURCC_RV15"));
break;
case FOURCC_RV16:
LLOGLN(0, ("FOURCC_RV16"));
break;
case FOURCC_YUY2:
LLOGLN(0, ("FOURCC_YUY2"));
break;
case FOURCC_UYVY:
LLOGLN(0, ("FOURCC_UYVY"));
break;
case FOURCC_RV24:
LLOGLN(0, ("FOURCC_RV24"));
break;
default:
LLOGLN(0, ("other"));
break;
}
return 0;
}
/*****************************************************************************/
static int
rdpXvQueryImageAttributes(ClientPtr client, XvPortPtr pPort, XvImagePtr format,
CARD16* width, CARD16* height, int* pitches,
int* offsets)
{
int size;
int tmp;
LLOGLN(0, ("rdpXvQueryImageAttributes:"));
size = 0;
/* this is same code as all drivers currently have */
if (*width > 2046)
{
*width = 2046;
}
if (*height > 2046)
{
*height = 2046;
}
/* make w multiple of 4 so that resizing works properly */
*width = (*width + 3) & ~3;
if (offsets)
{
offsets[0] = 0;
}
LLOGLN(0, ("format %x", format->id));
rdpXvPrintFormat(format->id);
switch (format->id)
{
case FOURCC_YV12:
case FOURCC_I420:
/* make h be even */
*height = (*height + 1) & ~1;
/* make w be multiple of 4 (ie. pad it) */
size = (*width + 3) & ~3;
/* width of a Y row => width of image */
if (pitches != 0)
{
pitches[0] = size;
}
/* offset of U plane => w*h */
size *= *height;
if (offsets != 0)
{
offsets[1] = size;
}
/* width of U, V row => width/2 */
tmp = ((*width >> 1) +3) & ~3;
if (pitches != 0)
{
pitches[1] = pitches[2] = tmp;
}
/* offset of V => Y plane + U plane (w*h + w/2*h/2) */
tmp *= (*height >> 1);
size += tmp;
size += tmp;
if (offsets != 0)
{
offsets[2] = size;
}
size += tmp;
break;
case FOURCC_RV15:
case FOURCC_RV16:
case FOURCC_YUY2:
case FOURCC_UYVY:
size = (*width) * 2;
if (pitches)
{
pitches[0] = size;
}
size *= *height;
break;
case FOURCC_RV24:
size = (*width) * 3;
if (pitches)
{
pitches[0] = size;
}
size *= *height;
break;
default:
LLOGLN(0, ("rdpXvQueryImageAttributes: error"));
break;
}
return size;
}
/*****************************************************************************/
static Bool
rdpXvCloseScreen(int i, ScreenPtr pScreen)
{
XvScreenPtr pxvs = GET_XV_SCREEN(pScreen);
LLOGLN(0, ("rdpXvCloseScreen:"));
free(pxvs->pAdaptors);
return 0;
}
/*****************************************************************************/
static int
rdpXvQueryAdaptors(ScreenPtr pScreen, XvAdaptorPtr* p_pAdaptors,
int* p_nAdaptors)
{
XvScreenPtr pxvs = GET_XV_SCREEN(pScreen);
LLOGLN(0, ("rdpXvQueryAdaptors:"));
*p_nAdaptors = pxvs->nAdaptors;
*p_pAdaptors = pxvs->pAdaptors;
return Success;
}
#ifdef MITSHM
#endif
/*****************************************************************************/
static int
rdpXvInitAdaptors(ScreenPtr pScreen)
{
XvScreenPtr pxvs = GET_XV_SCREEN(pScreen);
XvAdaptorPtr pAdaptor;
pAdaptor = malloc(sizeof(XvAdaptorRec));
memset(pAdaptor, 0, sizeof(XvAdaptorRec));
pAdaptor->type = XvInputMask | XvOutputMask | XvImageMask |
XvVideoMask | XvStillMask;
pAdaptor->pScreen = pScreen;
pAdaptor->name = g_xv_adaptor_name;
pAdaptor->nEncodings = T_NUM_ENCODINGS;
pAdaptor->pEncodings = g_encodings;
pAdaptor->nFormats = T_NUM_FORMATS;
pAdaptor->pFormats = g_formats;
pAdaptor->nImages = T_NUM_IMAGES;
pAdaptor->pImages = g_images;
pAdaptor->nPorts = T_NUM_PORTS;
pAdaptor->pPorts = g_ports;
pAdaptor->ddAllocatePort = rdpXvAllocatePort;
pAdaptor->ddFreePort = rdpXvFreePort;
pAdaptor->ddPutVideo = rdpXvPutVideo;
pAdaptor->ddPutStill = rdpXvPutStill;
pAdaptor->ddGetVideo = rdpXvGetVideo;
pAdaptor->ddGetStill = rdpXvGetStill;
pAdaptor->ddStopVideo = rdpXvStopVideo;
pAdaptor->ddSetPortAttribute = rdpXvSetPortAttribute;
pAdaptor->ddGetPortAttribute = rdpXvGetPortAttribute;
pAdaptor->ddQueryBestSize = rdpXvQueryBestSize;
pAdaptor->ddPutImage = rdpXvPutImage;
pAdaptor->ddQueryImageAttributes = rdpXvQueryImageAttributes;
pxvs->pAdaptors = pAdaptor;
memset(g_encodings, 0, sizeof(g_encodings));
g_encodings[0].id = FakeClientID(0);
g_encodings[0].pScreen = pScreen;
g_encodings[0].name = g_xv_encoding_name;
g_encodings[0].width = 2046;
g_encodings[0].height = 2046;
g_encodings[0].rate.numerator = 1;
g_encodings[0].rate.denominator = 1;
memset(g_formats, 0, sizeof(g_formats));
g_formats[0].depth = g_rdpScreen.depth;
g_formats[0].visual = pScreen->rootVisual;
memset(g_ports, 0, sizeof(g_ports));
g_ports[0].id = FakeClientID(0);
g_ports[0].pAdaptor = pAdaptor;
g_ports[0].pNotify = 0;
g_ports[0].pDraw = 0;
g_ports[0].grab.id = 0;
g_ports[0].grab.client = 0;
g_ports[0].time = currentTime;
g_ports[0].devPriv.ptr = 0;
pAdaptor->base_id = g_ports[0].id;
AddResource(g_ports[0].id, XvRTPort, g_ports);
pxvs->nAdaptors = 1;
pxvs->pAdaptors = pAdaptor;
return 0;
}
/*****************************************************************************/
/* returns error */
int
rdpXvInit(ScreenPtr pScreen)
{
XvScreenPtr pxvs;
LLOGLN(0, ("rdpXvInit:"));
XvScreenInit(pScreen);
g_XvScreenKey = XvGetScreenKey();
pxvs = GET_XV_SCREEN(pScreen);
pxvs->nAdaptors = 0;
pxvs->ddCloseScreen = rdpXvCloseScreen;
pxvs->ddQueryAdaptors = rdpXvQueryAdaptors;
rdpXvInitAdaptors(pScreen);
return 0;
}

@ -1,101 +0,0 @@
util-macros-1.11.0.tar.bz2 : util-macros-1.11.0 :
xf86driproto-2.1.0.tar.bz2 : xf86driproto-2.1.0 :
dri2proto-2.3.tar.bz2 : dri2proto-2.3 :
glproto-1.4.12.tar.bz2 : glproto-1.4.12 :
libpciaccess-0.12.0.tar.bz2 : libpciaccess-0.12.0 :
libpthread-stubs-0.3.tar.bz2 : libpthread-stubs-0.3 :
libdrm-2.4.26.tar.bz2 : libdrm-2.4.26 :
damageproto-1.2.1.tar.bz2 : damageproto-1.2.1 :
xproto-7.0.20.tar.bz2 : xproto-7.0.20 :
makedepend-1.0.3.tar.bz2 : makedepend-1.0.3 :
libxml2-sources-2.7.8.tar.gz : libxml2-2.7.8 :
libpng-1.2.46.tar.gz : libpng-1.2.46 :
pixman-0.30.0.tar.bz2 : pixman-0.30.0 : --disable-gtk
freetype-2.4.6.tar.bz2 : freetype-2.4.6 :
fontconfig-2.8.0.tar.gz : fontconfig-2.8.0 : --disable-docs
cairo-1.8.8.tar.gz : cairo-1.8.8 :
expat-2.0.1.tar.gz : expat-2.0.1 :
xextproto-7.1.2.tar.bz2 : xextproto-7.1.2 :
xcb-proto-1.6.tar.bz2 : xcb-proto-1.6 :
libXau-1.0.6.tar.bz2 : libXau-1.0.6 :
libXdmcp-1.1.0.tar.bz2 : libXdmcp-1.1.0 :
libxcb-1.7.tar.bz2 : libxcb-1.7 :
xtrans-1.2.6.tar.bz2 : xtrans-1.2.6 :
kbproto-1.0.5.tar.bz2 : kbproto-1.0.5 :
inputproto-2.0.1.tar.bz2 : inputproto-2.0.1 :
libX11-1.4.0.tar.bz2 : libX11-1.4.0 :
libXext-1.2.0.tar.bz2 : libXext-1.2.0 :
libICE-1.0.7.tar.bz2 : libICE-1.0.7 :
libSM-1.2.0.tar.bz2 : libSM-1.2.0 :
libXt-1.0.9.tar.bz2 : libXt-1.0.9 :
fixesproto-4.1.2.tar.bz2 : fixesproto-4.1.2 :
libXfixes-4.0.5.tar.bz2 : libXfixes-4.0.5 :
libXdamage-1.1.3.tar.bz2 : libXdamage-1.1.3 :
MesaLib-7.10.3.tar.bz2 : Mesa-7.10.3 : --with-expat=$PREFIX_DIR --disable-gallium
randrproto-1.3.2.tar.bz2 : randrproto-1.3.2 :
renderproto-0.11.1.tar.bz2 : renderproto-0.11.1 :
xcmiscproto-1.2.1.tar.bz2 : xcmiscproto-1.2.1 :
xf86vidmodeproto-2.3.tar.bz2 : xf86vidmodeproto-2.3 :
xf86bigfontproto-1.2.0.tar.bz2 : xf86bigfontproto-1.2.0 :
scrnsaverproto-1.2.1.tar.bz2 : scrnsaverproto-1.2.1 :
bigreqsproto-1.1.1.tar.bz2 : bigreqsproto-1.1.1 :
resourceproto-1.1.1.tar.bz2 : resourceproto-1.1.1 :
fontsproto-2.1.1.tar.bz2 : fontsproto-2.1.1 :
xf86dgaproto-2.1.tar.bz2 : xf86dgaproto-2.1 :
videoproto-2.3.1.tar.bz2 : videoproto-2.3.1 :
compositeproto-0.4.2.tar.bz2 : compositeproto-0.4.2 :
recordproto-1.14.1.tar.bz2 : recordproto-1.14.1 :
xineramaproto-1.2.tar.bz2 : xineramaproto-1.2 :
libxslt-1.1.26.tar.gz : libxslt-1.1.26 :
libxkbfile-1.0.7.tar.bz2 : libxkbfile-1.0.7 :
libfontenc-1.1.0.tar.bz2 : libfontenc-1.1.0 :
libXfont-1.4.3.tar.bz2 : libXfont-1.4.3 :
libXmu-1.1.0.tar.bz2 : libXmu-1.1.0 :
libXxf86vm-1.1.1.tar.bz2 : libXxf86vm-1.1.1 :
libXpm-3.5.9.tar.bz2 : libXpm-3.5.9 :
libXaw-1.0.8.tar.bz2 : libXaw-1.0.8 :
mkfontdir-1.0.6.tar.bz2 : mkfontdir-1.0.6 :
mkfontscale-1.0.8.tar.bz2 : mkfontscale-1.0.8 :
xkbcomp-1.2.0.tar.bz2 : xkbcomp-1.2.0 :
xdriinfo-1.0.4.tar.bz2 : xdriinfo-1.0.4 :
applewmproto-1.4.1.tar.bz2 : applewmproto-1.4.1 :
xorg-server-1.9.3.tar.bz2 : xorg-server-1.9.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11 --with-sha1=libcrypto --disable-dmx --without-dtrace
bdftopcf-1.0.3.tar.bz2 : bdftopcf-1.0.3 :
intltool-0.41.1.tar.gz : intltool-0.41.1 :
xkeyboard-config-2.0.tar.bz2 : xkeyboard-config-2.0 :
font-util-1.2.0.tar.bz2 : font-util-1.2.0 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
font-adobe-75dpi-1.0.3.tar.bz2 : font-adobe-75dpi-1.0.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
font-adobe-100dpi-1.0.3.tar.bz2 : font-adobe-100dpi-1.0.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
font-adobe-utopia-75dpi-1.0.4.tar.bz2 : font-adobe-utopia-75dpi-1.0.4 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
font-adobe-utopia-100dpi-1.0.4.tar.bz2 : font-adobe-utopia-100dpi-1.0.4 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
font-adobe-utopia-type1-1.0.4.tar.bz2 : font-adobe-utopia-type1-1.0.4 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
font-alias-1.0.3.tar.bz2 : font-alias-1.0.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
font-arabic-misc-1.0.3.tar.bz2 : font-arabic-misc-1.0.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
font-bh-75dpi-1.0.3.tar.bz2 : font-bh-75dpi-1.0.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
font-bh-100dpi-1.0.3.tar.bz2 : font-bh-100dpi-1.0.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
font-bh-lucidatypewriter-75dpi-1.0.3.tar.bz2 : font-bh-lucidatypewriter-75dpi-1.0.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
font-bh-lucidatypewriter-100dpi-1.0.3.tar.bz2 : font-bh-lucidatypewriter-100dpi-1.0.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
font-bh-ttf-1.0.3.tar.bz2 : font-bh-ttf-1.0.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
font-bh-type1-1.0.3.tar.bz2 : font-bh-type1-1.0.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
font-bitstream-75dpi-1.0.3.tar.bz2 : font-bitstream-75dpi-1.0.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
font-bitstream-100dpi-1.0.3.tar.bz2 : font-bitstream-100dpi-1.0.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
font-bitstream-type1-1.0.3.tar.bz2 : font-bitstream-type1-1.0.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
font-cronyx-cyrillic-1.0.3.tar.bz2 : font-cronyx-cyrillic-1.0.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
font-cursor-misc-1.0.3.tar.bz2 : font-cursor-misc-1.0.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
font-daewoo-misc-1.0.3.tar.bz2 : font-daewoo-misc-1.0.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
font-dec-misc-1.0.3.tar.bz2 : font-dec-misc-1.0.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
font-ibm-type1-1.0.3.tar.bz2 : font-ibm-type1-1.0.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
font-isas-misc-1.0.3.tar.bz2 : font-isas-misc-1.0.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
font-jis-misc-1.0.3.tar.bz2 : font-jis-misc-1.0.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
font-micro-misc-1.0.3.tar.bz2 : font-micro-misc-1.0.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
font-misc-cyrillic-1.0.3.tar.bz2 : font-misc-cyrillic-1.0.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
font-misc-ethiopic-1.0.3.tar.bz2 : font-misc-ethiopic-1.0.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
font-misc-meltho-1.0.3.tar.bz2 : font-misc-meltho-1.0.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
font-misc-misc-1.1.2.tar.bz2 : font-misc-misc-1.1.2 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
font-mutt-misc-1.0.3.tar.bz2 : font-mutt-misc-1.0.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
font-schumacher-misc-1.1.2.tar.bz2 : font-schumacher-misc-1.1.2 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
font-screen-cyrillic-1.0.4.tar.bz2 : font-screen-cyrillic-1.0.4 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
font-sony-misc-1.0.3.tar.bz2 : font-sony-misc-1.0.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
font-sun-misc-1.0.3.tar.bz2 : font-sun-misc-1.0.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
font-winitzki-cyrillic-1.0.3.tar.bz2 : font-winitzki-cyrillic-1.0.3 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11
font-xfree86-type1-1.0.4.tar.bz2 : font-xfree86-type1-1.0.4 : --with-fontrootdir=$PREFIX_DIR/share/fonts/X11

@ -1,88 +0,0 @@
diff -rupP xkeyboard-config-2.0.orig/rules/HDR xkeyboard-config-2.0/rules/HDR
--- xkeyboard-config-2.0.orig/rules/HDR 2016-06-28 19:31:02.814647638 +0900
+++ xkeyboard-config-2.0/rules/HDR 2016-06-28 19:33:58.251517616 +0900
@@ -15,6 +15,7 @@
! model layout[3] variant[3] = symbols
! model layout[4] variant[4] = symbols
! model = symbols
+! model layout = symbols
! layout variant = compat
! layout[1] variant[1] = compat
! layout[2] variant[2] = compat
diff -rupP xkeyboard-config-2.0.orig/rules/Makefile.am xkeyboard-config-2.0/rules/Makefile.am
--- xkeyboard-config-2.0.orig/rules/Makefile.am 2016-06-28 19:31:02.814647638 +0900
+++ xkeyboard-config-2.0/rules/Makefile.am 2016-06-28 20:58:22.276629031 +0900
@@ -41,6 +41,7 @@ HDR compat/base.ml2v2_s.part extras/bas
HDR compat/base.ml3v3_s.part extras/base.ml3v3_s.part \
HDR compat/base.ml4v4_s.part extras/base.ml4v4_s.part \
HDR base.m_s.part \
+HDR base.ml_s1.part \
HDR compat/base.lv_c.part \
HDR compat/base.l1v1_c.part \
HDR compat/base.l2v2_c.part \
@@ -114,6 +115,7 @@ HDR extras/base.ml2v2_s.part \
HDR extras/base.ml3v3_s.part \
HDR extras/base.ml4v4_s.part \
HDR base.m_s.part \
+HDR base.ml_s1.part \
HDR \
HDR \
HDR \
@@ -183,6 +185,7 @@ base.ml2_s.part \
base.ml3_s.part \
base.ml4_s.part \
base.m_s.part \
+base.ml_s1.part \
base.ml_c.part \
base.ml1_c.part \
base.m_t.part \
diff -rupP xkeyboard-config-2.0.orig/rules/Makefile.in xkeyboard-config-2.0/rules/Makefile.in
--- xkeyboard-config-2.0.orig/rules/Makefile.in 2016-06-28 19:31:02.850647811 +0900
+++ xkeyboard-config-2.0/rules/Makefile.in 2016-06-28 21:00:57.569398853 +0900
@@ -239,6 +239,7 @@ SUBDIRS = bin compat extras
@USE_COMPAT_RULES_FALSE@HDR extras/base.ml3v3_s.part \
@USE_COMPAT_RULES_FALSE@HDR extras/base.ml4v4_s.part \
@USE_COMPAT_RULES_FALSE@HDR base.m_s.part \
+@USE_COMPAT_RULES_FALSE@HDR base.ml_s1.part \
@USE_COMPAT_RULES_FALSE@HDR \
@USE_COMPAT_RULES_FALSE@HDR \
@USE_COMPAT_RULES_FALSE@HDR \
@@ -275,6 +276,7 @@ SUBDIRS = bin compat extras
@USE_COMPAT_RULES_TRUE@HDR compat/base.ml3v3_s.part extras/base.ml3v3_s.part \
@USE_COMPAT_RULES_TRUE@HDR compat/base.ml4v4_s.part extras/base.ml4v4_s.part \
@USE_COMPAT_RULES_TRUE@HDR base.m_s.part \
+@USE_COMPAT_RULES_TRUE@HDR base.ml_s1.part \
@USE_COMPAT_RULES_TRUE@HDR compat/base.lv_c.part \
@USE_COMPAT_RULES_TRUE@HDR compat/base.l1v1_c.part \
@USE_COMPAT_RULES_TRUE@HDR compat/base.l2v2_c.part \
@@ -378,6 +380,7 @@ base.ml2_s.part \
base.ml3_s.part \
base.ml4_s.part \
base.m_s.part \
+base.ml_s1.part \
base.ml_c.part \
base.ml1_c.part \
base.m_t.part \
diff -rupP xkeyboard-config-2.0.orig/rules/base.ml_s1.part xkeyboard-config-2.0/rules/base.ml_s1.part
--- xkeyboard-config-2.0.orig/rules/base.ml_s1.part 1970-01-01 09:00:00.000000000 +0900
+++ xkeyboard-config-2.0/rules/base.ml_s1.part 2016-06-28 19:59:05.238990192 +0900
@@ -0,0 +1 @@
+ $inetkbds jp = +jp(henkan)
diff -rupP xkeyboard-config-2.0.orig/symbols/jp xkeyboard-config-2.0/symbols/jp
--- xkeyboard-config-2.0.orig/symbols/jp 2016-06-28 19:31:03.046648788 +0900
+++ xkeyboard-config-2.0/symbols/jp 2016-06-28 19:32:57.367215702 +0900
@@ -105,6 +105,14 @@ xkb_symbols "common" {
};
};
+partial alphanumeric_keys
+xkb_symbols "henkan" {
+ key <XFER> {
+ type[Group1]= "PC_ALT_LEVEL2",
+ symbols[Group1]= [ Henkan, Mode_switch ]
+ };
+};
+
// OADG109A map
partial alphanumeric_keys
xkb_symbols "OADG109A" {

@ -1,10 +0,0 @@
--- a/configure
+++ b/configure
@@ -21551,6 +21551,7 @@
if test "x$with_sha1" = xlibcrypto; then
if test "x$HAVE_LIBCRYPTO" = xyes; then
SHA1_LIBS=-lcrypto
+ SHA1_CFLAGS="$OPENSSL_CFLAGS"
else
SHA1_LIBS="$OPENSSL_LIBS"
SHA1_CFLAGS="$OPENSSL_CFLAGS"

@ -1,30 +0,0 @@
#!/bin/bash
# receives version, release number and source directory as arguments
VERSION=$1
RELEASE=$2
SRCDIR=$3
PKGDEST=$4
PACKDIR=x11rdp-files
DESTDIR=$PACKDIR/opt
NAME=x11rdp
ARCH=$( dpkg --print-architecture )
sed -i -e "s/DUMMYVERINFO/$VERSION-$RELEASE/" $PACKDIR/DEBIAN/control
sed -i -e "s/DUMMYARCHINFO/$ARCH/" $PACKDIR/DEBIAN/control
# need a different delimiter, since it has a path
sed -i -e "s,DUMMYDIRINFO,$SRCDIR," $PACKDIR/DEBIAN/postinst
mkdir -p $DESTDIR
cp -Rf $SRCDIR $DESTDIR
dpkg-deb --build $PACKDIR $PKGDEST/${NAME}_$VERSION-${RELEASE}_${ARCH}.deb
# revert to initial state
rm -rf $DESTDIR
sed -i -e "s/$VERSION-$RELEASE/DUMMYVERINFO/" $PACKDIR/DEBIAN/control
sed -i -e "s/$ARCH/DUMMYARCHINFO/" $PACKDIR/DEBIAN/control
# need a different delimiter, since it has a path
sed -i -e "s,$SRCDIR,DUMMYDIRINFO," $PACKDIR/DEBIAN/postinst

@ -1,7 +0,0 @@
Package: x11rdp
Version: DUMMYVERINFO
Section: unknown
Priority: optional
Architecture: DUMMYARCHINFO
Maintainer: Angulo Solido <packaging@angulosolido.pt>
Description: X11rdp backend for the xrdp remote access server

@ -1,18 +0,0 @@
#!/bin/bash
X11DIR=DUMMYDIRINFO
# make the /usr/bin/X11rdp symbolic link if it doesn't exist...
if [ ! -e /usr/bin/X11rdp ]
then
if [ -e $X11DIR/bin/X11rdp ]
then
ln -s $X11DIR/bin/X11rdp /usr/bin/X11rdp
else
clear
echo "There was a problem... the $X11DIR/bin/X11rdp binary could not be found. Did the compilation complete?"
echo "Stopped. Please investigate what went wrong."
exit
fi
fi

@ -1,2 +0,0 @@
xorg server readme

@ -1,16 +0,0 @@
#!/bin/sh
xhost +
# delete chache directory for testing
rm -r .nx
if ! [ -d .nx ]
then
mkdir .nx
fi
export LD_LIBRARY_PATH=$PWD
./nxproxy -S nx/nx,session=session,id=jay,root=.nx,connect=127.0.0.1:10,delta=1,stream=1,data=1

@ -1,14 +0,0 @@
#!/bin/sh
export LD_LIBRARY_PATH=$PWD
#./nxagent -R -bs -dpi 96 -geometry 1024x768 -noshpix -display nx/nx,link=adsl,delta=1,stream=1,data=1,a8taint=0,cache=4M:9 :9
# with cache
#./nxagent -D -bs -ac -dpi 96 -geometry 1024x768 -noshpix -display nx/nx,link=adsl,delta=1,stream=1,data=1,cache=4M:9 :9
# without cache
#./nxagent -D -bs -ac -dpi 96 -geometry 1024x768 -noshpix -display nx/nx,link=adsl,delta=1,stream=1,data=1,cache=0M:9 :9
# cache not set, defaulting, client script clears directory
./nxagent -D -bs -ac -dpi 96 -geometry 1024x768 -noshpix -display nx/nx,link=adsl,delta=1,stream=1,data=1:9 :9

@ -1,11 +0,0 @@
CFLAGS = -O2 -Wall
all: test-randr
test-randr: trandr.c
gcc $(CFLAGS) trandr.c -o test-randr -lX11 -lXrandr
.PHONY clean:
rm -f *.o test-randr

@ -1,146 +0,0 @@
/**
* xrdp: A Remote Desktop Protocol server.
*
* Copyright (C) Jay Sorg 2013
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <time.h>
#include <stdint.h>
#include <string.h>
#include <sys/types.h>
#include <sys/time.h>
#include <signal.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/extensions/Xrandr.h>
static int
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;
}
int
main(int argc, char **argv)
{
XEvent ev;
Display *disp;
Window win;
Window root_window;
Screen *screen;
int screenNumber;
int eventMask;
int white;
int black;
int rr_event_base;
int rr_error_base;
int ver_maj;
int ver_min;
int cont;
disp = XOpenDisplay(0);
if (disp == 0)
{
printf("error opening display\n");
return 1;
}
screenNumber = DefaultScreen(disp);
white = WhitePixel(disp, screenNumber);
black = BlackPixel(disp, screenNumber);
screen = ScreenOfDisplay(disp, screenNumber);
root_window = RootWindowOfScreen(screen);
eventMask = StructureNotifyMask;
XSelectInput(disp, root_window, eventMask);
win = XCreateSimpleWindow(disp, root_window, 50, 50, 250, 250,
0, black, white);
XMapWindow(disp, win);
eventMask = StructureNotifyMask | VisibilityChangeMask;
XSelectInput(disp, win, eventMask);
eventMask = KeyPressMask | KeyReleaseMask | ButtonPressMask |
ButtonReleaseMask | VisibilityChangeMask |
FocusChangeMask | StructureNotifyMask |
PointerMotionMask | ExposureMask | PropertyChangeMask;
XSelectInput(disp, win, eventMask);
if (!XRRQueryExtension(disp, &rr_event_base, &rr_error_base))
{
printf("error randr\n");
return 1;
}
XRRQueryVersion(disp, &ver_maj, &ver_min);
printf("randr version %d %d\n", ver_maj, ver_min);
XRRSelectInput(disp, win, RRScreenChangeNotifyMask);
cont = 1;
while (cont)
{
XNextEvent(disp, &ev);
switch (ev.type)
{
case ButtonPress:
cont = 0;
break;
case ClientMessage:
printf("ClientMessage\n");
break;
case ConfigureNotify:
if (ev.xconfigure.window == root_window)
{
XRRUpdateConfiguration(&ev);
printf("ConfigureNotify for root window "
"width %d height %d\n",
ev.xconfigure.width, ev.xconfigure.height);
}
break;
default:
if ((ev.type >= rr_event_base) &&
(ev.type < rr_event_base + RRNumberEvents))
{
printf("randr\n");
process_randr(disp, screen, screenNumber, win,
rr_event_base, &ev);
}
break;
}
}
return 0;
}

@ -1,11 +0,0 @@
CFLAGS = -Werror -Wall
all: xdemo
xdemo: xdemo.c bmp_parser.c
gcc $(CFLAGS) xdemo.c bmp_parser.c -o xdemo -lX11
.PHONY clean:
rm -f *.o xdemo

@ -1,3 +0,0 @@
this is a program to test xwindows

@ -1,238 +0,0 @@
/**
* xrdp: A Remote Desktop Protocol server.
*
* Copyright (C) Laxmikant Rashinkar 2004-2012
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdint.h>
#include "common.h"
// multi byte values are stored in little endian
struct bmp_magic
{
char magic[2];
};
struct bmp_hdr
{
uint32_t size; // file size in bytes
uint16_t reserved1;
uint16_t reserved2;
uint32_t offset; // offset to image data, in bytes
};
struct dib_hdr
{
uint32_t hdr_size;
int32_t width;
int32_t height;
uint16_t nplanes;
uint16_t bpp;
uint32_t compress_type;
uint32_t image_size;
int32_t hres;
int32_t vres;
uint32_t ncolors;
uint32_t nimpcolors;
};
// forward declarations
int parse_bmp(char *filename, struct pic_info *pic_info);
int parse_bmp_24(struct bmp_hdr *bmp_hdr, struct dib_hdr *dib_hdr, int fd, struct pic_info *pic_info);
int parse_bmp(char *filename, struct pic_info *pic_info)
{
int got_magic;
int fd;
int rval;
struct bmp_magic magic;
struct bmp_hdr bmp_hdr;
struct dib_hdr dib_hdr;
if ((fd = open(filename, O_RDONLY)) < 0)
{
printf("error opening %s\n", filename);
return -1;
}
// read BMP magic...
if ((rval = read(fd, magic.magic, 2)) != 2)
{
fprintf(stderr, "error reading BMP signature from file %s\n", filename);
return -1;
}
got_magic = 0;
// ...and confirm that this is indeed a BMP file
if ((magic.magic[0] == 'B') && (magic.magic[1] == 'M'))
{
// BM Windows 3.1x, 95, NT, ... etc
got_magic = 1;
}
else if ((magic.magic[0] == 'B') && (magic.magic[1] == 'A'))
{
// BA OS/2 struct Bitmap Array
got_magic = 1;
}
else if ((magic.magic[0] == 'C') && (magic.magic[1] == 'I'))
{
// CI OS/2 struct Color Icon
got_magic = 1;
}
else if ((magic.magic[0] == 'C') && (magic.magic[1] == 'P'))
{
// CP OS/2 const Color Pointer
got_magic = 1;
}
else if ((magic.magic[0] == 'I') && (magic.magic[1] == 'C'))
{
// IC OS/2 struct Icon
got_magic = 1;
}
else if ((magic.magic[0] == 'P') && (magic.magic[1] == 'T'))
{
// PT OS/2 Pointer
got_magic = 1;
}
if (!got_magic)
{
fprintf(stderr, "%s is not a valid BMP file\n", filename);
return -1;
}
// read BMP header
if ((rval = read(fd, &bmp_hdr, sizeof(bmp_hdr))) < sizeof(bmp_hdr))
{
fprintf(stderr, "error BMP header from file %s\n", filename);
return -1;
}
// read DIB header
if ((rval = read(fd, &dib_hdr, sizeof(dib_hdr))) < sizeof(dib_hdr))
{
fprintf(stderr, "error reading DIB header from file %s\n", filename);
return -1;
}
#if 0
printf("header size: %d\n", dib_hdr.hdr_size);
printf("width: %d\n", dib_hdr.width);
printf("height: %d\n", dib_hdr.height);
printf("num planes: %d\n", dib_hdr.nplanes);
printf("bpp: %d\n", dib_hdr.bpp);
printf("comp type: %d\n", dib_hdr.compress_type);
printf("image size: %d\n", dib_hdr.image_size);
printf("hres: %d\n", dib_hdr.hres);
printf("vres: %d\n", dib_hdr.vres);
printf("ncolors: %d\n", dib_hdr.ncolors);
printf("nimpcolors: %d\n", dib_hdr.nimpcolors);
#endif
if (dib_hdr.compress_type)
{
printf("TODO: compressed images not yet supported\n");
return -1;
}
pic_info->width = dib_hdr.width;
pic_info->height = dib_hdr.height;
if (dib_hdr.bpp == 24)
{
rval = parse_bmp_24(&bmp_hdr, &dib_hdr, fd, pic_info);
}
close(fd);
return rval;
}
/**
* extract 24bit BMP data from image file
*
* @return 0 on success
* @return -1 on failure
*/
int parse_bmp_24(
struct bmp_hdr *bmp_hdr,
struct dib_hdr *dib_hdr,
int fd,
struct pic_info *pic_info
)
{
char *file_data;
char *ptr_file_data;
char *mem_data;
char *ptr_mem_data;
char *cptr;
int w = dib_hdr->width; // picture width
int h = dib_hdr->height; // picture height
int bpl; // bytes per line
int bytes;
int i;
int j;
// bytes per image line = width x bytes_per_pixel + padding
i = (w * 3) % 4;
j = (i == 0) ? 0 : 4 - i;
bpl = w * 3 + j;
// 24 bit depth, no alpha channel
file_data = (char *) malloc(h * bpl);
// point to first line in image data, which is stored in reverse order
ptr_file_data = (file_data + dib_hdr->image_size) - bpl;
// 24 bit depth, with alpha channel
mem_data = (char *) malloc(w * h * 4);
ptr_mem_data = mem_data;
pic_info->pixel_data = ptr_mem_data;
// seek to beginning of pixel data
lseek(fd, bmp_hdr->offset, SEEK_SET);
// read all pixel data
bytes = read(fd, file_data, dib_hdr->image_size);
// convert 24bit to 24 bit with alpha and store in reverse
for (i = 0; i < h; i ++)
{
cptr = ptr_file_data;
for (j = 0; j < w; j++)
{
*ptr_mem_data++ = *cptr++; // blue value
*ptr_mem_data++ = *cptr++; // green value
*ptr_mem_data++ = *cptr++; // red value
*ptr_mem_data++ = 0; // alpha channel
}
ptr_file_data -= bpl;
}
free(file_data);
return 0;
}

@ -1,37 +0,0 @@
/**
* xrdp: A Remote Desktop Protocol server.
*
* Copyright (C) Laxmikant Rashinkar 2012
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __XDEMO_H
#define __XDEMO_H
#define DEBUG
#ifdef DEBUG
#define dprint(x...) printf(x)
#else
#define dprint(x...)
#endif
struct pic_info
{
int width;
int height;
char *pixel_data;
};
#endif

@ -1,897 +0,0 @@
/**
* xrdp: A Remote Desktop Protocol server.
*
* Copyright (C) Laxmikant Rashinkar 2012
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <time.h>
#include <stdint.h>
#include <string.h>
#include <sys/types.h>
#include <sys/time.h>
#include <signal.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include "common.h"
// LK_TODO
// http://tronche.com/gui/x/xlib/GC/convenience-functions/fill-tile-and-stipple.html
// fill stipple
// drawfonts: XDrawString, XDrawImageString XDrawText XLoadFont XTextExtents
// http://www.ac3.edu.au/SGI_Developer/books/XLib_PG/sgi_html/apa.html
// http://www.ac3.edu.au/SGI_Developer/books/XLib_PG/sgi_html/index.html
// use jpg lib to convert bmp to jpg and vice versa
#define MAX_COLORS 5
#define SCROLL_JUMP 1 // scroll in increments of g_winHeight
#define SCROLL_SMOOTH1 2 // scroll using XPutImage + XCopyArea
#define SCROLL_SMOOTH2 3 // scroll using XPutImage only
#define SCROLL_SMOOTH3 4 // scroll using XPutImage only
#define SCROLL_SMOOTH4 5 // scroll using XPutImage only
int parse_bmp(char *filename, struct pic_info *);
int drawBMP(char *filename, int scroll_type);
int signal_tcp_proxy(char *proxy_app);
// globals
Display *g_disp;
Window g_win;
XColor g_colors[MAX_COLORS];
GC g_gc;
int g_winWidth;
int g_winHeight;
int g_delay_dur;
void start_timer(struct timeval *tv)
{
gettimeofday(tv, NULL);
}
uint32_t time_elapsed_ms(struct timeval tv)
{
struct timeval tv_now;
uint32_t dur;
gettimeofday(&tv_now, NULL);
dur = ((tv_now.tv_sec - tv.tv_sec) * 1000) + ((tv_now.tv_usec - tv.tv_usec) / 1000);
return dur;
}
uint32_t time_elapsed_us(struct timeval tv)
{
struct timeval tv_now;
uint32_t dur;
gettimeofday(&tv_now, NULL);
dur = ((tv_now.tv_sec - tv.tv_sec) * 1000000) + (tv_now.tv_usec - tv.tv_usec);
return dur;
}
int drawLines(int count)
{
int x1;
int y1;
int x2;
int y2;
int i;
int index;
if (count <= 0)
{
return 0; // nothing to do
}
srandom(time(NULL));
XClearArea(g_disp, g_win, 0, 0, g_winWidth, g_winHeight, 0);
for (i = 0, index = 0; i < count; i++)
{
x1 = random() % g_winWidth;
y1 = random() % g_winHeight;
x2 = random() % g_winWidth;
y2 = random() % g_winHeight;
XSetForeground(g_disp, g_gc, g_colors[index++].pixel);
if (index == MAX_COLORS)
{
index = 0;
}
// from-to
XDrawLine(g_disp, g_win, g_gc, x1, y1, x2, y2);
XFlush(g_disp);
usleep(g_delay_dur);
}
return 0;
}
// LK_TODO support user defined w and h
int drawRectangles(int count)
{
int x1;
int y1;
int w;
int h;
int i;
int index;
if (count <= 0)
{
return 0; // nothing to do
}
srandom(time(NULL));
XClearArea(g_disp, g_win, 0, 0, g_winWidth, g_winHeight, 0);
for (i = 0, index = 0; i < count; i++)
{
x1 = random() % g_winWidth;
y1 = random() % g_winHeight;
w = 160;
h = 140;
XSetForeground(g_disp, g_gc, g_colors[index++].pixel);
if (index == MAX_COLORS)
{
index = 0;
}
//XDrawRectangle(g_disp, g_win, g_gc, x1, y1, w, h);
XFillRectangle(g_disp, g_win, g_gc, x1, y1, w, h);
XFlush(g_disp);
usleep(g_delay_dur);
}
return 0;
}
int drawFont(int count, char *msg)
{
int x1;
int y1;
int i;
int index;
#ifdef CHANGE_FONT_SIZE
int w;
int h;
int actual_count;
char **font_list;
#endif
if (count <= 0)
{
return 0; // nothing to do
}
srandom(time(NULL));
XClearArea(g_disp, g_win, 0, 0, g_winWidth, g_winHeight, 0);
#ifdef CHANGE_FONT_SIZE
font_list = XListFonts(g_disp, "*courier****00***0**", 2000, &actual_count);
if (!font_list)
{
printf("actual_count=%d\n", actual_count);
for (i = 0; i < actual_count; i++)
{
printf("%s\n", font_list[i]);
}
XFreeFontNames(font_list);
}
else
{
printf("XListFonts() returned NULL\n");
}
#endif
srandom(time(NULL));
for (i = 0, index = 0; i < count; i++)
{
x1 = random() % g_winWidth;
y1 = random() % g_winHeight;
XSetForeground(g_disp, g_gc, g_colors[index++].pixel);
if (index == MAX_COLORS)
{
index = 0;
}
XDrawString(g_disp, g_win, g_gc, x1, y1, msg, strlen(msg));
XFlush(g_disp);
usleep(g_delay_dur);
}
return 0; // nothing to do
}
static void
drawoffscreen(void)
{
int depth;
Pixmap pixmap1;
Pixmap pixmap2;
printf("draw off screen, should see green rect\n");
depth = DefaultDepth(g_disp, DefaultScreen(g_disp));
/* blue */
pixmap1 = XCreatePixmap(g_disp, g_win, 64, 64, depth);
XSetForeground(g_disp, g_gc, 0x000000ff);
XFillRectangle(g_disp, pixmap1, g_gc, 0, 0, 64, 64);
/* green */
pixmap2 = XCreatePixmap(g_disp, g_win, 64, 64, depth);
XSetForeground(g_disp, g_gc, 0x0000ff00);
XFillRectangle(g_disp, pixmap2, g_gc, 0, 0, 64, 64);
/* copy green to blue */
XCopyArea(g_disp, pixmap2, pixmap1, g_gc, 0, 0, 64, 64, 0, 0);
/* put on screen */
XCopyArea(g_disp, pixmap1, g_win, g_gc, 0, 0, 64, 64, 128, 128);
XFreePixmap(g_disp, pixmap1);
XFreePixmap(g_disp, pixmap2);
}
/**
* display a usage message
*/
static void
usage(void)
{
printf("usage: xdemo [-l] [-r] [-s] [-f <string>] [-i <image file>] [-g <WxH>] [-c <count>] [-o <scroll type>] [-d <delay>] -z\n");
printf(" -l draw lines\n");
printf(" -r draw fill rectangles\n");
printf(" -s draw stipple rectangles\n");
printf(" -f <string> draw string using fonts\n");
printf(" -i <image file> draw image\n");
printf(" -g <WxH> geometry, default is 640x480\n");
printf(" -c <count> iteration count, default is 5000\n");
printf(" -d <delay> loop delay in micro seconds, default 1000\n");
printf(" -o <jump|smooth1|smooth2| define scrolling method\n");
printf(" smooth3|smooth4>\n");
printf(" -z <proxy_app> zero proxy counters for specified application\n");
printf(" -j offscreen to offscreen test\n\n");
}
int
main(int argc, char **argv)
{
XEvent evt;
Colormap colormap;
struct timeval tv;
int screenNumber;
long eventMask;
unsigned long white;
unsigned long black;
Status rc;
int iters;
int opt;
int draw_lines;
int draw_rects;
int draw_stipples;
int draw_fonts;
int draw_image;
int draw_offscreen;
int zero_counters;
int scroll_type;
char image_file[256];
char proxy_app[256];
char msg[4096];
// set some defaults
g_winWidth = 640;
g_winHeight = 480;
iters = 5000;
draw_lines = 1;
draw_rects = 1;
draw_stipples = 1;
draw_fonts = 1;
draw_image = 1;
draw_offscreen = 1;
g_delay_dur = 1000;
scroll_type = SCROLL_SMOOTH1;
zero_counters = 0;
strcpy(image_file, "yosemite.bmp");
strcpy(msg, "To be or not to be!");
// process cmd line args
opterr = 0;
while ((opt = getopt(argc, argv, "lrsjg:c:f:i:d:o:z:")) != -1)
{
switch (opt)
{
case 'j':
draw_lines = 0;
draw_rects = 0;
draw_stipples = 0;
draw_fonts = 0;
draw_image = 0;
draw_offscreen = 1;
break;
case 'g':
if (sscanf(optarg, "%dx%d", &g_winWidth, &g_winHeight) != 2)
{
fprintf(stderr, "\nerror: invalid geometry specified\n\n");
usage();
return -1;
}
break;
case 'c':
if (sscanf(optarg, "%d", &iters) != 1)
{
fprintf(stderr, "\nerror: invalid count specified\n\n");
usage();
return -1;
}
break;
case 'l':
draw_lines = 1;
draw_rects = 0;
draw_stipples = 0;
draw_fonts = 0;
draw_image = 0;
draw_offscreen = 0;
break;
case 'r':
draw_rects = 1;
draw_lines = 0;
draw_stipples = 0;
draw_fonts = 0;
draw_image = 0;
draw_offscreen = 0;
break;
case 's':
draw_stipples = 1;
draw_lines = 0;
draw_rects = 0;
draw_fonts = 0;
draw_image = 0;
draw_offscreen = 0;
break;
case 'f':
if (strlen(optarg) <= 0)
{
fprintf(stderr, "\nerror: -f option requires an argument\n\n");
usage();
return -1;
}
draw_fonts = 1;
strncpy(msg, optarg, 4096);
draw_lines = 0;
draw_rects = 0;
draw_stipples = 0;
draw_image = 0;
draw_offscreen = 0;
break;
case 'i':
if (strlen(optarg) <= 0)
{
fprintf(stderr, "\nerror: -i option requires an argument\n\n");
usage();
return -1;
}
draw_image = 1;
strncpy(image_file, optarg, 255);
draw_lines = 0;
draw_rects = 0;
draw_stipples = 0;
draw_fonts = 0;
draw_offscreen = 0;
break;
case 'h':
usage();
return 0;
break;
case 'v':
printf("xdemo Ver 1.0\n");
return 0;
break;
case 'd':
if (sscanf(optarg, "%d", &g_delay_dur) != 1)
{
fprintf(stderr, "\nerror: -d option requires an argument\n\n");
usage();
return -1;
}
break;
case 'z':
if (strlen(optarg) <= 0)
{
fprintf(stderr, "\nerror: invalid proxy application specified\n\n");
usage();
return -1;
}
strcpy(proxy_app, optarg);
printf("##### LK_TODO: proxy_app=%s\n", proxy_app);
zero_counters = 1;
break;
case 'o':
if (strcmp(optarg, "jump") == 0)
{
scroll_type = SCROLL_JUMP;
}
else if (strcmp(optarg, "smooth1") == 0)
{
scroll_type = SCROLL_SMOOTH1;
}
else if (strcmp(optarg, "smooth2") == 0)
{
scroll_type = SCROLL_SMOOTH2;
}
else if (strcmp(optarg, "smooth3") == 0)
{
scroll_type = SCROLL_SMOOTH3;
}
else if (strcmp(optarg, "smooth4") == 0)
{
scroll_type = SCROLL_SMOOTH4;
}
else
{
fprintf(stderr, "\ninvalid scroll type specified\n\n");
usage();
return -1;
}
break;
default:
usage();
return -1;
}
}
// must have at least one operation
if ((!draw_lines) && (!draw_rects) && (!draw_stipples) &&
(!draw_fonts) && (!draw_image) && (!draw_offscreen))
{
usage();
return -1;
}
g_disp = XOpenDisplay(NULL);
if (!g_disp)
{
dprint("error opening X display\n");
exit(-1);
}
screenNumber = DefaultScreen(g_disp);
white = WhitePixel(g_disp, screenNumber);
black = BlackPixel(g_disp, screenNumber);
g_win = XCreateSimpleWindow(g_disp,
DefaultRootWindow(g_disp),
50, 50, // origin
g_winWidth, g_winHeight, // size
0, black, // border
white ); // backgd
XMapWindow(g_disp, g_win);
//eventMask = StructureNotifyMask | MapNotify | VisibilityChangeMask;
eventMask = StructureNotifyMask | VisibilityChangeMask;
XSelectInput(g_disp, g_win, eventMask);
g_gc = XCreateGC(g_disp, g_win,
0, // mask of values
NULL ); // array of values
#if 0
do
{
dprint("about to call XNextEvent(...)\n");
XNextEvent(g_disp, &evt);// calls XFlush
dprint("returned from XNextEvent(...)\n");
}
//while(evt.type != MapNotify);
while (evt.type != VisibilityNotify)
{
;
}
#endif
// get access to the screen's color map
colormap = DefaultColormap(g_disp, screenNumber);
// alloc red color
rc = XAllocNamedColor(g_disp, colormap, "red", &g_colors[0], &g_colors[0]);
if (rc == 0)
{
printf("XAllocNamedColor - failed to allocated 'red' color.\n");
exit(1);
}
rc = XAllocNamedColor(g_disp, colormap, "green", &g_colors[1], &g_colors[1]);
if (rc == 0)
{
printf("XAllocNamedColor - failed to allocated 'green' color.\n");
exit(1);
}
rc = XAllocNamedColor(g_disp, colormap, "blue", &g_colors[2], &g_colors[2]);
if (rc == 0)
{
printf("XAllocNamedColor - failed to allocated 'blue' color.\n");
exit(1);
}
rc = XAllocNamedColor(g_disp, colormap, "yellow", &g_colors[3], &g_colors[3]);
if (rc == 0)
{
printf("XAllocNamedColor - failed to allocated 'yellow' color.\n");
exit(1);
}
rc = XAllocNamedColor(g_disp, colormap, "orange", &g_colors[4], &g_colors[4]);
if (rc == 0)
{
printf("XAllocNamedColor - failed to allocated 'orange' color.\n");
exit(1);
}
if (zero_counters)
{
signal_tcp_proxy(proxy_app);
}
if (draw_lines)
{
start_timer(&tv);
drawLines(iters);
printf("drew %d lines in %d ms\n", iters, time_elapsed_ms(tv));
}
if (draw_rects)
{
start_timer(&tv);
drawRectangles(iters);
printf("drew %d rects in %d ms\n", iters, time_elapsed_ms(tv));
}
if (draw_stipples)
{
start_timer(&tv);
// LK_TODO
}
if (draw_fonts)
{
start_timer(&tv);
drawFont(iters, msg);
printf("drew %d strings in %d ms\n", iters, time_elapsed_ms(tv));
}
if (draw_image)
{
start_timer(&tv);
drawBMP(image_file, scroll_type);
printf("drew BMP in %d ms\n", time_elapsed_ms(tv));
}
if (draw_offscreen)
{
}
if (zero_counters)
{
signal_tcp_proxy(proxy_app);
}
eventMask = ButtonPressMask | ButtonReleaseMask | KeyPressMask;
XSelectInput(g_disp, g_win, eventMask);
do
{
XNextEvent(g_disp, &evt); // calls XFlush()
if (evt.type == KeyPress)
{
if (draw_offscreen)
{
drawoffscreen();
}
}
}
while (evt.type != ButtonRelease);
XDestroyWindow(g_disp, g_win);
XCloseDisplay(g_disp);
return 0;
}
int drawBMP(char *filename, int scroll_type)
{
struct pic_info pic_info;
XImage *image;
Visual *visual;
Pixmap pixmap;
int depth;
int i;
int j;
if (parse_bmp(filename, &pic_info) < 0)
{
exit(-1);
}
XClearArea(g_disp, g_win, 0, 0, g_winWidth, g_winHeight, 0);
depth = DefaultDepth(g_disp, DefaultScreen(g_disp));
visual = DefaultVisual(g_disp, DefaultScreen(g_disp));
// create empty pixmap
pixmap = XCreatePixmap(g_disp, g_win, pic_info.width, pic_info.height, depth);
// create an image from pixel data
image = XCreateImage(g_disp, visual, depth, ZPixmap, 0, pic_info.pixel_data,
pic_info.width, pic_info.height, 32, 0);
if (pic_info.height <= g_winHeight)
{
// image is too small to scroll
XFlush(g_disp);
XPutImage(g_disp, g_win, g_gc, image, 0, 0, 0, 0, pic_info.width, pic_info.height);
XFlush(g_disp);
return 0;
}
// copy image to pixelmap
XPutImage(g_disp, pixmap, g_gc, image, 0, 0, 0, 0, pic_info.width, pic_info.height);
if (scroll_type == SCROLL_JUMP)
{
if (pic_info.height <= g_winHeight)
{
// image too small - no scrolling required
XFlush(g_disp);
XCopyArea(g_disp, // connection to X server
pixmap, // source drawable
g_win, // dest drawable
g_gc, // graphics context
0, 0, // source x,y
pic_info.width, // width
pic_info.height, // height
0, 0); // dest x,y
XFlush(g_disp);
return 0;
}
j = pic_info.height / g_winHeight;
if (pic_info.height % g_winHeight != 0)
{
// need to include the last part of the image
j++;
}
XFlush(g_disp);
for (i = 0; i < j; i++)
{
XCopyArea(g_disp, // connection to X server
pixmap, // source drawable
g_win, // dest drawable
g_gc, // graphics context
0, i * g_winHeight, // source x,y
pic_info.width, // width
pic_info.height, // height
0, 0); // dest x,y
XFlush(g_disp);
sleep(3);
}
}
/*
** smooth scroll the image
*/
// number of lines to be scrolled
j = pic_info.height - g_winHeight;
if (scroll_type == SCROLL_SMOOTH1)
{
printf("running SCROLL_SMOOTH1\n");
XFlush(g_disp);
XPutImage(g_disp, g_win, g_gc, image, 0, 0, 0, 0, pic_info.width, pic_info.height);
XFlush(g_disp);
usleep(10000);
for (i = 0; i < j; i++)
{
XCopyArea(g_disp, g_win, g_win, g_gc, 0, 1, g_winWidth, g_winHeight - 1, 0, 0);
XPutImage(g_disp, g_win, g_gc, image, 0, g_winHeight + i, 0, g_winHeight - 1 , pic_info.width, 1);
XFlush(g_disp);
usleep(10000);
}
return 0;
}
if (scroll_type == SCROLL_SMOOTH2)
{
printf("running SCROLL_SMOOTH2\n");
XFlush(g_disp);
for (i = 0; i < j; i++)
{
XPutImage(g_disp, g_win, g_gc, image, 0, i, 0, 0, pic_info.width, pic_info.height - i);
XFlush(g_disp);
usleep(10000);
}
}
if (scroll_type == SCROLL_SMOOTH3)
{
printf("running SCROLL_SMOOTH3\n");
XFlush(g_disp);
XCopyArea(g_disp, pixmap, g_win, g_gc, 0, 0, pic_info.width, pic_info.height, 0, 0);
XFlush(g_disp);
usleep(10000);
for (i = 0; i < j; i++)
{
XCopyArea(g_disp, g_win, g_win, g_gc, 0, 1, g_winWidth, g_winHeight - 1, 0, 0);
XCopyArea(g_disp, pixmap, g_win, g_gc, 0, g_winHeight + i, pic_info.width, 1, 0, g_winHeight - 1);
XFlush(g_disp);
usleep(10000);
}
return 0;
}
if (scroll_type == SCROLL_SMOOTH4)
{
printf("running SCROLL_SMOOTH4\n");
XFlush(g_disp);
for (i = 0; i < j; i++)
{
XCopyArea(g_disp, pixmap, g_win, g_gc, 0, i, pic_info.width, pic_info.height - i, 0, 0);
XFlush(g_disp);
usleep(10000);
}
}
return 0;
}
int process_bmp_event(void)
{
XEvent ev;
long event_mask;
event_mask = ExposureMask | ButtonPressMask | ButtonReleaseMask | StructureNotifyMask;
XSelectInput(g_disp, g_win, event_mask);
XNextEvent(g_disp, &ev);
switch (ev.type)
{
case Expose:
printf("got expose event\n");
break;
default:
printf("did not get expose event\n");
break;
}
return 0;
}
/**
* send a SIGUSR1 to process tcp_proxy, causing it to clear counters
*
* @return 0 on success, -1 on failure
*/
int signal_tcp_proxy(char *proc_name)
{
FILE *fp;
char *cptr;
char buf[2048];
int pids[10];
int status = 0;
int num_procs;
int i;
sprintf(buf, "pidof %s", proc_name);
if ((fp = popen(buf, "r")) == NULL )
{
printf("xdemo: popen() failed\n");
return -1;
}
cptr = fgets(buf, 2047, fp);
if (cptr == NULL)
{
pclose(fp);
return -1;
}
num_procs = sscanf(buf, "%d %d %d %d %d %d %d %d %d %d",
&pids[0], &pids[1], &pids[2], &pids[3], &pids[4],
&pids[5], &pids[6], &pids[7], &pids[8], &pids[9]);
if (num_procs > 0)
{
for (i = 0; i < num_procs; i++)
{
kill(pids[i], SIGUSR1);
printf("sent SIGUSR1 to process %d\n", pids[i]);
}
}
pclose(fp);
return status;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 MiB

Loading…
Cancel
Save