diff -urN microwindows-0.91/Makefile microwindows-0.91.g100/Makefile
--- microwindows-0.91/Makefile	1970-01-01 01:00:00.000000000 +0100
+++ microwindows-0.91.g100/Makefile	2007-05-28 21:56:36.000000000 +0200
@@ -0,0 +1,48 @@
+#Host
+MICROWINHOSTDEST=$(shell pwd)/host
+
+#Target
+MICROWINTARGETDEST=$(shell pwd)/target
+
+clean:
+	rm -f -R $(MICROWINHOSTDEST) &&\
+	rm -f -R $(MICROWINTARGETDEST) &&\
+	cd src &&\
+	make clean
+Host:
+	rm -f -R $(MICROWINHOSTDEST)/bin/* &&\
+	rm -f $(MICROWINHOSTDEST)/lib/* &&\
+	rm -f -R $(MICROWINHOSTDEST)/include/* &&\
+	rm -f $(MICROWINHOSTDEST)/lib/* &&\
+	cp src/Configs/config_host src/config &&\
+	cd src &&\
+	make clean &&\
+	make &&\
+	cd .. && \
+	mkdir -p $(MICROWINHOSTDEST) &&\
+	mkdir -p $(MICROWINHOSTDEST)/lib &&\
+	mkdir -p $(MICROWINHOSTDEST)/include/ &&\
+	mkdir -p $(MICROWINHOSTDEST)/include/microwin &&\
+	mkdir -p $(MICROWINHOSTDEST)/bin && \
+	cp -R src/bin/* $(MICROWINHOSTDEST)/bin &&\
+	cp -R src/lib/* $(MICROWINHOSTDEST)/lib &&\
+	cp src/include/* $(MICROWINHOSTDEST)/include/microwin
+
+Target:
+	rm -f -R $(MICROWINTARGETDEST)/bin/* &&\
+	rm -f -R $(MICROWINTARGETDEST)/include/* &&\
+	rm -f $(MICROWINTARGETDEST)/lib/* &&\
+	cp src/Configs/config_target src/config &&\
+	cd src &&\
+	make clean &&\
+	make &&\
+	cd .. &&\
+	mkdir -p $(MICROWINTARGETDEST) &&\
+	mkdir -p $(MICROWINTARGETDEST)/lib &&\
+	mkdir -p $(MICROWINTARGETDEST)/include/ &&\
+	mkdir -p $(MICROWINTARGETDEST)/include/microwin &&\
+	mkdir -p $(MICROWINTARGETDEST)/bin &&\
+	cp -R src/bin/* $(MICROWINTARGETDEST)/bin &&\
+	cp -R src/lib/* $(MICROWINTARGETDEST)/lib &&\
+	cp src/include/* $(MICROWINTARGETDEST)/include/microwin
+
diff -urN microwindows-0.91/src/Arch.rules microwindows-0.91.g100/src/Arch.rules
--- microwindows-0.91/src/Arch.rules	2007-06-17 21:56:35.000000000 +0200
+++ microwindows-0.91.g100/src/Arch.rules	2006-10-12 18:23:41.000000000 +0200
@@ -55,7 +55,13 @@
 CXX_COMPILER = g++
 TOOLSPREFIX = $(MIPSTOOLSPREFIX)
 DEFINES += -DLINUX=1 -DUNIX=1
+# REM: BEGIN: lets configure softfloat option via config
+ifeq ($(DISSABLE-SOFT-FLOAT),Y)
+CFLAGS += $(GCC_WARNINGS) $(OPTFLAGS)
+else
 CFLAGS += -msoft-float $(GCC_WARNINGS) $(OPTFLAGS)
+endif
+# REM: END
 ifneq ($(DEBUG), Y)
 CFLAGS += -s
 endif
diff -urN microwindows-0.91/src/config microwindows-0.91.g100/src/config
--- microwindows-0.91/src/config	2007-06-17 21:56:35.000000000 +0200
+++ microwindows-0.91.g100/src/config	2007-06-17 21:44:10.000000000 +0200
@@ -39,7 +39,6 @@
 ####################################################################
 ARCH                     = LINUX-NATIVE
 BIGENDIAN                = N
-NATIVETOOLSPREFIX        = 
 ARMTOOLSPREFIX           = arm-linux-
 MIPSTOOLSPREFIX          = mipsel-linux-
 POWERPCTOOLSPREFIX       = powerpc-linux-
@@ -51,10 +50,10 @@
 # Compiling options
 #
 ####################################################################
-OPTIMIZE                 = Y
-DEBUG                    = N
-VERBOSE                  = N
-THREADSAFE               = Y
+OPTIMIZE                 = N
+DEBUG                    = Y
+VERBOSE                  = Y
+THREADSAFE               = N
 GPROF                    = N
 
 ####################################################################
@@ -62,9 +61,9 @@
 # Libraries to build: microwin, nano-X, nanowidget, object frameworks
 #
 ####################################################################
-MICROWIN                 = Y
+MICROWIN                 = N
 NANOX                    = Y
-SHAREDLIBS               = Y
+SHAREDLIBS               = N
 OBJFRAMEWORK             = N
 
 
@@ -73,7 +72,7 @@
 # Demos to build
 #
 ####################################################################
-MICROWINDEMO             = Y
+MICROWINDEMO             = N
 NANOXDEMO                = Y
 
 ####################################################################
@@ -84,6 +83,21 @@
 NANOWM                   = Y
 
 ####################################################################
+# TCP_IP support for Nano-X client/server protocol vonnection via
+# LAN or Internet
+####################################################################
+
+HAVE_TCP_IP_SUPPORT = N
+
+####################################################################
+# Transparent color support 
+# 
+####################################################################
+
+HAVE_TRANS_COLOR_SUPPORT = Y
+
+
+####################################################################
 #
 # The pixeltype of the native hardware or underlying graphics library.
 # This definition defines the PIXELVAL to be 32, 16 or 8 bits wide.
@@ -99,7 +113,7 @@
 # define MWPF_TRUECOLOR332  /* pixel is packed 8 bits 3/3/2 truecolor*/
 #
 ####################################################################
-SCREEN_PIXTYPE           = MWPF_TRUECOLOR0888
+SCREEN_PIXTYPE           = MWPF_TRUECOLOR8888
 
 ####################################################################
 #
@@ -128,21 +142,21 @@
 ####################################################################
 HAVE_BMP_SUPPORT         = Y
 HAVE_GIF_SUPPORT         = Y
-HAVE_PNM_SUPPORT         = Y
-HAVE_XPM_SUPPORT         = Y
+HAVE_PNM_SUPPORT         = N
+HAVE_XPM_SUPPORT         = N
 
 ####################################################################
 # JPEG support through libjpeg, see README.txt in contrib/jpeg
 ####################################################################
-HAVE_JPEG_SUPPORT        = Y
+HAVE_JPEG_SUPPORT        = N
 INCJPEG                  = .
-LIBJPEG                  = /usr/lib/libjpeg.so
+LIBJPEG                  = /usr/lib/libjpeg.a
 
 ####################################################################
 # PNG support via libpng and libz
 ####################################################################
 HAVE_PNG_SUPPORT         = N
-INCPNG                   = .
+INCPNG                   = /usr/include
 LIBPNG                   = /usr/lib/libpng.a
 LIBZ                     = /usr/lib/libz.a
 
@@ -150,14 +164,14 @@
 # TIFF support through libtiff
 ####################################################################
 HAVE_TIFF_SUPPORT        = N
-INCTIFF                  = .
+INCTIFF                  = /usr/include
 LIBTIFF                  = /usr/lib/libtiff.a
 
 ####################################################################
 # native .fnt loadable font support
 ####################################################################
-HAVE_FNT_SUPPORT         = Y
-HAVE_FNTGZ_SUPPORT       = Y
+HAVE_FNT_SUPPORT         = N
+HAVE_FNTGZ_SUPPORT       = N
 FNT_FONT_DIR             = "fonts/bdf"
 
 ####################################################################
@@ -165,13 +179,13 @@
 ####################################################################
 HAVE_T1LIB_SUPPORT       = N
 INCT1LIB                 = /usr/include
-LIBT1LIB                 = /usr/local/lib/libt1.a
+LIBT1LIB                 = /usr/lib/libt1.a
 
 ####################################################################
 # TrueType font support thru FreeType 1.x
 ####################################################################
-HAVE_FREETYPE_SUPPORT    = Y
-INCFTLIB                 = /usr/include/freetype1
+HAVE_FREETYPE_SUPPORT    = N
+INCFTLIB                 = /usr/include
 LIBFTLIB                 = /usr/lib/libttf.so
 FREETYPE_FONT_DIR        = "fonts/truetype"
 
@@ -189,7 +203,7 @@
 # .pcf.gz files, but it will add libz to the size of the server
 ####################################################################
 HAVE_PCF_SUPPORT         = Y
-HAVE_PCFGZ_SUPPORT       = Y
+HAVE_PCFGZ_SUPPORT       = N
 PCF_FONT_DIR             = "fonts/pcf"
 
 ####################################################################
@@ -257,7 +271,7 @@
 ifneq ($(ARCH), ELKS)
 
 # X Window screen, mouse and kbd drivers
-X11                      = N
+X11                      = Y
 
 ifeq ($(X11), Y)
 # startup screen width, height, (depth for palette mode only)
@@ -326,7 +340,6 @@
 PSIONMOUSE               = N
 YOPYMOUSE                = N
 HARRIERMOUSE             = N
-LIRCMOUSE                = N
 
 # keyboard or null kbd driver
 TTYKBD                   = N
@@ -338,11 +351,6 @@
 
 endif
 
-# Secondary keyboard drivers.
-# You may have a normal keyboard driver in addition to these
-# drivers, e.g. for both normal keyboard and IR input.
-LIRCKBD2                 = N
-
 ####################################################################
 # Screen driver specific configuration
 # SA1100_LCD_LTLEND 4bpp driver with arm SA1100 LCD controller
diff -urN microwindows-0.91/src/Configs/config_host microwindows-0.91.g100/src/Configs/config_host
--- microwindows-0.91/src/Configs/config_host	1970-01-01 01:00:00.000000000 +0100
+++ microwindows-0.91.g100/src/Configs/config_host	2007-06-17 20:43:20.000000000 +0200
@@ -0,0 +1,394 @@
+####################################################################
+# Microwindows and Nano-X configuration file
+#
+# This package can be configured to run on Linux (MIPS, ARM, POWERPC or x86)
+# UNIX, ELKS, DJGPP, or RTEMS.
+# On Linux, we've got drivers for Linux 2.x framebuffers, X11, or,
+# svgalib for VGA hardware.
+# In addition, a gpm or direct serial mouse driver can be configured.
+# On ELKS, the bios screen driver and serial mouse driver are always used.
+#
+# Either Microwindows and/or Nano-X can be built.
+# Microwindows and Nano-X have several demos.
+#
+# For MSDOS makes, see mcmwin.mak and mcnanox.mak
+####################################################################
+
+####################################################################
+#
+# build target platform
+#
+# Valid ARCH values are:
+#
+# LINUX-NATIVE
+# LINUX-TCC
+# LINUX-ARM
+# LINUX-MIPS
+# LINUX-POWERPC (BIGENDIAN=Y)
+# LINUX-SPARC (BIGENDIAN=Y)
+# LINUX-SH
+# FREEBSD-X86
+# SOLARIS (BIGENDIAN=Y)
+# TRIMEDIA
+# RTEMS
+# DJGPP
+# ELKS
+#
+# note: ELKS can't build client/server nano-X, nor widget lib
+#
+####################################################################
+ARCH                     = LINUX-NATIVE
+BIGENDIAN                = N
+ARMTOOLSPREFIX           = arm-linux-
+MIPSTOOLSPREFIX          = mipsel-linux-
+POWERPCTOOLSPREFIX       = powerpc-linux-
+SHTOOLSPREFIX            = sh-linux-gnu
+RTEMSTOOLSPREFIX         = i386-rtemself-
+
+####################################################################
+#
+# Compiling options
+#
+####################################################################
+OPTIMIZE                 = N
+DEBUG                    = Y
+VERBOSE                  = Y
+THREADSAFE               = N
+GPROF                    = N
+
+####################################################################
+#
+# Libraries to build: microwin, nano-X, nanowidget, object frameworks
+#
+####################################################################
+MICROWIN                 = N
+NANOX                    = Y
+SHAREDLIBS               = N
+OBJFRAMEWORK             = N
+
+
+####################################################################
+#
+# Demos to build
+#
+####################################################################
+MICROWINDEMO             = N
+NANOXDEMO                = Y
+
+####################################################################
+#
+# Applications to build
+#
+####################################################################
+NANOWM                   = Y
+
+####################################################################
+# TCP_IP support for Nano-X client/server protocol vonnection via
+# LAN or Internet
+####################################################################
+
+HAVE_TCP_IP_SUPPORT = N
+
+####################################################################
+# Transparent color support 
+# 
+####################################################################
+
+HAVE_TRANS_COLOR_SUPPORT = Y
+
+
+####################################################################
+#
+# The pixeltype of the native hardware or underlying graphics library.
+# This definition defines the PIXELVAL to be 32, 16 or 8 bits wide.
+# If using Linux framebuffer, set to MWPF_TRUECOLOR0888, and use fbset.
+# It also enables GdArea/GrArea for this particular pixel packing format.
+#
+# define MWPF_PALETTE       /* pixel is packed 8 bits 1, 4 or 8 pal index*/
+# define MWPF_TRUECOLOR8888 /* pixel is packed 32 bits 8/8/8/8 truecolor w/alpha*/
+# define MWPF_TRUECOLOR0888 /* pixel is packed 32 bits 8/8/8 truecolor*/
+# define MWPF_TRUECOLOR888  /* pixel is packed 24 bits 8/8/8 truecolor*/
+# define MWPF_TRUECOLOR565  /* pixel is packed 16 bits 5/6/5 truecolor*/
+# define MWPF_TRUECOLOR555  /* pixel is packed 16 bits 5/5/5 truecolor*/
+# define MWPF_TRUECOLOR332  /* pixel is packed 8 bits 3/3/2 truecolor*/
+#
+####################################################################
+SCREEN_PIXTYPE           = MWPF_TRUECOLOR8888
+
+####################################################################
+#
+# NanoX: Put Y to the following line to link the nano-X application
+# with the server.  This is required for ELKS, if no network is present,
+# or for speed or debugging.  This affects the nano-X server only.
+#
+####################################################################
+LINK_APP_INTO_SERVER     = N
+
+####################################################################
+# Shared memory support for Nano-X client/server protocol speedup
+####################################################################
+HAVE_SHAREDMEM_SUPPORT   = N
+
+####################################################################
+#
+# File I/O support
+# Supporting either below drags in libc stdio, which may not be wanted
+#
+####################################################################
+HAVE_FILEIO              = Y
+
+####################################################################
+# BMP, GIF reading support
+####################################################################
+HAVE_BMP_SUPPORT         = Y
+HAVE_GIF_SUPPORT         = Y
+HAVE_PNM_SUPPORT         = N
+HAVE_XPM_SUPPORT         = N
+
+####################################################################
+# JPEG support through libjpeg, see README.txt in contrib/jpeg
+####################################################################
+HAVE_JPEG_SUPPORT        = N
+INCJPEG                  = .
+LIBJPEG                  = /usr/lib/libjpeg.a
+
+####################################################################
+# PNG support via libpng and libz
+####################################################################
+HAVE_PNG_SUPPORT         = N
+INCPNG                   = /usr/include
+LIBPNG                   = /usr/lib/libpng.a
+LIBZ                     = /usr/lib/libz.a
+
+####################################################################
+# TIFF support through libtiff
+####################################################################
+HAVE_TIFF_SUPPORT        = N
+INCTIFF                  = /usr/include
+LIBTIFF                  = /usr/lib/libtiff.a
+
+####################################################################
+# native .fnt loadable font support
+####################################################################
+HAVE_FNT_SUPPORT         = N
+HAVE_FNTGZ_SUPPORT       = N
+FNT_FONT_DIR             = "fonts/bdf"
+
+####################################################################
+# T1 adobe type1 font support thru t1lib
+####################################################################
+HAVE_T1LIB_SUPPORT       = N
+INCT1LIB                 = /usr/include
+LIBT1LIB                 = /usr/lib/libt1.a
+
+####################################################################
+# TrueType font support thru FreeType 1.x
+####################################################################
+HAVE_FREETYPE_SUPPORT    = N
+INCFTLIB                 = /usr/include
+LIBFTLIB                 = /usr/lib/libttf.so
+FREETYPE_FONT_DIR        = "fonts/truetype"
+
+####################################################################
+# Support for many kinds of font thru FreeType 2.x
+# Must also set FREETYPE_FONT_DIR in the Freetype 1.x section
+####################################################################
+HAVE_FREETYPE_2_SUPPORT  = N
+INCFT2LIB                = /usr/include
+LIBFT2LIB                = /usr/lib/libfreetype.a
+
+####################################################################
+# PCF font support 
+# Selecting HAVE_PCFGZ_SUPPORT will allow you to directly read
+# .pcf.gz files, but it will add libz to the size of the server
+####################################################################
+HAVE_PCF_SUPPORT         = Y
+HAVE_PCFGZ_SUPPORT       = N
+PCF_FONT_DIR             = "fonts/pcf"
+
+####################################################################
+# Chinese Han Zi Ku loadable font support
+####################################################################
+HAVE_HZK_SUPPORT         = N
+HZK_FONT_DIR             = "fonts/chinese"
+
+####################################################################
+# Chinese BIG5 compiled in font support (big5font.c)
+####################################################################
+HAVE_BIG5_SUPPORT        = N
+
+####################################################################
+# Chinese GB2312 compiled in font support (gb2312font.c)
+####################################################################
+HAVE_GB2312_SUPPORT      = N
+
+####################################################################
+# Japanese JISX0213 compiled in font support (jisx0213-12x12.c)
+####################################################################
+HAVE_JISX0213_SUPPORT    = N
+
+####################################################################
+# Korean HANGUL font support (jo16x16.c)
+####################################################################
+HAVE_KSC5601_SUPPORT     = N
+
+####################################################################
+# Japanese EUC-JP support using loadable MGL font
+####################################################################
+HAVE_EUCJP_SUPPORT       = N
+EUCJP_FONT_DIR           = "fonts/japanese"
+
+####################################################################
+# Generate screen driver interface only with no fonts or clipping
+####################################################################
+NOFONTSORCLIPPING        = N
+
+####################################################################
+#
+# Window move algorithms for Microwindows
+# Change for tradeoff between cpu speed and looks
+# ERASEMOVE repaints only backgrounds while window dragging, quicker.
+# Otherwise an XOR redraw is used for window moves only after button up,
+# quickest (should set for ELKS)
+# UPDATEREGIONS paints in update clipping region only for better look and feel
+#
+####################################################################
+ERASEMOVE                = Y
+UPDATEREGIONS            = Y
+
+####################################################################
+#
+# Link with Gray Palette (valid only for 4bpp modes)
+#
+####################################################################
+GRAYPALETTE              = N
+
+####################################################################
+#
+# If the platform is running UNIX, Linux or RTEMS...
+#
+####################################################################
+ifneq ($(ARCH), ELKS)
+
+# X Window screen, mouse and kbd drivers
+X11                      = Y
+
+ifeq ($(X11), Y)
+# startup screen width, height, (depth for palette mode only)
+SCREEN_WIDTH             = 640
+SCREEN_HEIGHT            = 480
+SCREEN_DEPTH             = 4
+
+# You may want to turn this on for XFree86 4.x or if your backing store
+# isn't functioning properly
+USE_EXPOSURE		 = Y
+
+else
+
+# framebuffer screen driver (linear and/or vga 4 planes)
+# set VTSWITCH to include virtual terminal switch code
+# set FBREVERSE to reverse bit orders in 1,2,4 bpp
+# set FBVGA=N for all systems without VGA hardware (for MIPS must=N)
+FRAMEBUFFER              = Y
+FBVGA                    = Y
+VTSWITCH                 = Y
+FBREVERSE                = N
+
+# set HAVETEXTMODE=Y for systems that can switch between text & graphics.
+# On a graphics-only embedded system, such as Osprey and Embedded
+# Planet boards, set HAVETEXTMODE=N
+HAVETEXTMODE             = Y
+
+# svgalib screen driver
+VGALIB                   = N
+
+# direct VGA hardware access screen driver
+HWVGA                    = N
+
+####################################################################
+# Mouse drivers
+# GPMMOUSE	gpm mouse
+# SERMOUSE	serial Microsoft, PC, Logitech, PS/2 mice (/dev/psaux)
+# SUNMOUSE	Sun Workstation mouse (/dev/sunmouse)
+# NOMOUSE	no mouse driver
+#
+# Touchscreen drivers
+# IPAQMOUSE	Compaq iPAQ, Intel Assabet (/dev/h3600_tsraw)
+# ZAURUSMOUSE	Sharp Zaurus (/dev/sharp_ts)
+# TUXMOUSE	TuxScreen (/dev/ucb1x00-ts)
+# ADSMOUSE	Applied Data Systems GC+ (/dev/ts)
+# ADS7846MOUSE	        ADS7846 chip, PSI OMAP Innovator (/dev/innnovator_ts)
+# EPMOUSE	Embedded Planet (/dev/tpanel)
+# VHMOUSE	Vtech Helio (/dev/tpanel)
+# MTMOUSE	MicroTouch serial (/dev/ttyS1)
+# PSIONMOUSE	Psion 5 (/dev/touch_psion)
+# YOPYMOUSE	Yopy (/dev/yopy-ts)
+# HARRIERMOUSE	NEC Harrier (/dev/tpanel)
+####################################################################
+GPMMOUSE                 = Y
+SERMOUSE                 = N
+SUNMOUSE                 = N
+NOMOUSE                  = N
+IPAQMOUSE                = N
+ZAURUSMOUSE              = N
+TUXMOUSE                 = N
+ADSMOUSE                 = N
+ADS7846MOUSE             = N
+EPMOUSE                  = N
+VHMOUSE                  = N
+MTMOUSE                  = N
+PSIONMOUSE               = N
+YOPYMOUSE                = N
+HARRIERMOUSE             = N
+
+# keyboard or null kbd driver
+TTYKBD                   = N
+SCANKBD                  = Y
+PIPEKBD                  = N
+IPAQKBD                  = N
+LIRCKBD                  = N
+NOKBD                    = N
+
+endif
+
+####################################################################
+# Screen driver specific configuration
+# SA1100_LCD_LTLEND 4bpp driver with arm SA1100 LCD controller
+# INVERT4BPP 4bpp inverted pixel driver for VTech Helio
+####################################################################
+SA1100_LCD_LTLEND        = N
+INVERT4BPP               = N
+
+####################################################################
+#
+# If the platform is a RTEMS box ....
+#
+####################################################################
+ifeq ($(ARCH), RTEMS)
+
+# Location & BSP information of the RTEMS build
+RTEMS_BUILD              = /tools/build-i386-elf-rtems
+RTEMS_BSP                = pc386
+LINK_APP_INTO_SERVER     = Y
+
+endif
+
+endif
+
+####################################################################
+#
+# If the platform is an ELKS box ...
+#
+####################################################################
+ifeq ($(ARCH), ELKS)
+
+# Higher speed asm driver, c driver of hercules screen driver
+ASMVGADRIVER             = Y
+CVGADRIVER               = N
+HERCDRIVER               = N
+DBGDRIVER                = N
+
+# Mouse support
+SERMOUSE                 = Y
+
+endif
diff -urN microwindows-0.91/src/Configs/config_target microwindows-0.91.g100/src/Configs/config_target
--- microwindows-0.91/src/Configs/config_target	1970-01-01 01:00:00.000000000 +0100
+++ microwindows-0.91.g100/src/Configs/config_target	2007-06-16 17:04:30.000000000 +0200
@@ -0,0 +1,400 @@
+####################################################################
+# Microwindows and Nano-X configuration file
+#
+# This package can be configured to run on Linux (MIPS, ARM, POWERPC or x86)
+# UNIX, ELKS, DJGPP, or RTEMS.
+# On Linux, we've got drivers for Linux 2.x framebuffers, X11, or,
+# svgalib for VGA hardware.
+# In addition, a gpm or direct serial mouse driver can be configured.
+# On ELKS, the bios screen driver and serial mouse driver are always used.
+#
+# Either Microwindows and/or Nano-X can be built.
+# Microwindows and Nano-X have several demos.
+#
+# For MSDOS makes, see mcmwin.mak and mcnanox.mak
+####################################################################
+
+####################################################################
+#
+# build target platform
+#
+# Valid ARCH values are:
+#
+# LINUX-NATIVE
+# LINUX-TCC
+# LINUX-ARM
+# LINUX-MIPS
+# LINUX-POWERPC (BIGENDIAN=Y)
+# LINUX-SPARC (BIGENDIAN=Y)
+# LINUX-SH
+# FREEBSD-X86
+# SOLARIS (BIGENDIAN=Y)
+# TRIMEDIA
+# RTEMS
+# DJGPP
+# ELKS
+#
+# note: ELKS can't build client/server nano-X, nor widget lib
+#
+####################################################################
+ARCH                     = LINUX-MIPS
+BIGENDIAN                = N
+ARMTOOLSPREFIX           = arm-linux-
+MIPSTOOLSPREFIX          = mipsel-linux-
+POWERPCTOOLSPREFIX       = powerpc-linux-
+SHTOOLSPREFIX            = sh-linux-gnu
+RTEMSTOOLSPREFIX         = i386-rtemself-
+
+#REM: only valid for mips
+DISSABLE-SOFT-FLOAT      = Y
+
+####################################################################
+#
+# Compiling options
+#
+####################################################################
+OPTIMIZE                 = Y
+DEBUG                    = N
+VERBOSE                  = N
+THREADSAFE               = N
+GPROF                    = N
+
+####################################################################
+#
+# Libraries to build: microwin, nano-X, nanowidget, object frameworks
+#
+####################################################################
+MICROWIN                 = N
+NANOX                    = Y
+SHAREDLIBS               = N
+OBJFRAMEWORK             = N
+
+
+####################################################################
+#
+# Demos to build
+#
+####################################################################
+MICROWINDEMO             = N
+NANOXDEMO                = N
+
+####################################################################
+#
+# Applications to build
+#
+####################################################################
+NANOWM                   = Y
+
+####################################################################
+# REM: TCP_IP support for Nano-X client/server protocol vonnection via
+# REM: LAN or Internet
+####################################################################
+
+HAVE_TCP_IP_SUPPORT = N
+
+####################################################################
+# Transparent color support
+#
+####################################################################
+
+HAVE_TRANS_COLOR_SUPPORT = Y
+
+####################################################################
+#
+# The pixeltype of the native hardware or underlying graphics library.
+# This definition defines the PIXELVAL to be 32, 16 or 8 bits wide.
+# If using Linux framebuffer, set to MWPF_TRUECOLOR0888, and use fbset.
+# It also enables GdArea/GrArea for this particular pixel packing format.
+#
+# define MWPF_PALETTE       /* pixel is packed 8 bits 1, 4 or 8 pal index*/
+# define MWPF_TRUECOLOR8888 /* pixel is packed 32 bits 8/8/8/8 truecolor w/alpha*/
+# define MWPF_TRUECOLOR0888 /* pixel is packed 32 bits 8/8/8 truecolor*/
+# define MWPF_TRUECOLOR888  /* pixel is packed 24 bits 8/8/8 truecolor*/
+# define MWPF_TRUECOLOR565  /* pixel is packed 16 bits 5/6/5 truecolor*/
+# define MWPF_TRUECOLOR555  /* pixel is packed 16 bits 5/5/5 truecolor*/
+# define MWPF_TRUECOLOR332  /* pixel is packed 8 bits 3/3/2 truecolor*/
+#
+####################################################################
+SCREEN_PIXTYPE           = MWPF_TRUECOLOR565
+
+####################################################################
+#
+# NanoX: Put Y to the following line to link the nano-X application
+# with the server.  This is required for ELKS, if no network is present,
+# or for speed or debugging.  This affects the nano-X server only.
+#
+####################################################################
+LINK_APP_INTO_SERVER     = Y
+
+####################################################################
+# Shared memory support for Nano-X client/server protocol speedup
+####################################################################
+HAVE_SHAREDMEM_SUPPORT   = N
+
+####################################################################
+#
+# File I/O support
+# Supporting either below drags in libc stdio, which may not be wanted
+#
+####################################################################
+HAVE_FILEIO              = Y
+
+####################################################################
+# BMP, GIF reading support
+####################################################################
+HAVE_BMP_SUPPORT         = Y
+HAVE_GIF_SUPPORT         = Y
+HAVE_PNM_SUPPORT         = N
+HAVE_XPM_SUPPORT         = N
+
+####################################################################
+# JPEG support through libjpeg, see README.txt in contrib/jpeg
+####################################################################
+HAVE_JPEG_SUPPORT        = N
+INCJPEG                  = .
+LIBJPEG                  = /usr/lib/libjpeg.a
+
+####################################################################
+# PNG support via libpng and libz
+####################################################################
+HAVE_PNG_SUPPORT         = N
+INCPNG                   = /usr/include
+LIBPNG                   = /usr/lib/libpng.a
+LIBZ                     = /usr/lib/libz.a
+
+####################################################################
+# TIFF support through libtiff
+####################################################################
+HAVE_TIFF_SUPPORT        = N
+INCTIFF                  = /usr/include
+LIBTIFF                  = /usr/lib/libtiff.a
+
+####################################################################
+# native .fnt loadable font support
+####################################################################
+HAVE_FNT_SUPPORT         = N
+HAVE_FNTGZ_SUPPORT       = N
+FNT_FONT_DIR             = "fonts/bdf"
+
+####################################################################
+# T1 adobe type1 font support thru t1lib
+####################################################################
+HAVE_T1LIB_SUPPORT       = N
+INCT1LIB                 = /usr/include
+LIBT1LIB                 = /usr/lib/libt1.a
+
+####################################################################
+# TrueType font support thru FreeType 1.x
+####################################################################
+HAVE_FREETYPE_SUPPORT    = N
+INCFTLIB                 = /usr/include
+LIBFTLIB                 = /usr/lib/libttf.so
+FREETYPE_FONT_DIR        = "fonts/truetype"
+
+####################################################################
+# Support for many kinds of font thru FreeType 2.x
+# Must also set FREETYPE_FONT_DIR in the Freetype 1.x section
+####################################################################
+HAVE_FREETYPE_2_SUPPORT  = N
+INCFT2LIB                = /usr/include
+LIBFT2LIB                = /usr/lib/libfreetype.a
+
+####################################################################
+# PCF font support 
+# Selecting HAVE_PCFGZ_SUPPORT will allow you to directly read
+# .pcf.gz files, but it will add libz to the size of the server
+####################################################################
+HAVE_PCF_SUPPORT         = Y
+HAVE_PCFGZ_SUPPORT       = N
+PCF_FONT_DIR             = "fonts/pcf"
+
+####################################################################
+# Chinese Han Zi Ku loadable font support
+####################################################################
+HAVE_HZK_SUPPORT         = N
+HZK_FONT_DIR             = "fonts/chinese"
+
+####################################################################
+# Chinese BIG5 compiled in font support (big5font.c)
+####################################################################
+HAVE_BIG5_SUPPORT        = N
+
+####################################################################
+# Chinese GB2312 compiled in font support (gb2312font.c)
+####################################################################
+HAVE_GB2312_SUPPORT      = N
+
+####################################################################
+# Japanese JISX0213 compiled in font support (jisx0213-12x12.c)
+####################################################################
+HAVE_JISX0213_SUPPORT    = N
+
+####################################################################
+# Korean HANGUL font support (jo16x16.c)
+####################################################################
+HAVE_KSC5601_SUPPORT     = N
+
+####################################################################
+# Japanese EUC-JP support using loadable MGL font
+####################################################################
+HAVE_EUCJP_SUPPORT       = N
+EUCJP_FONT_DIR           = "fonts/japanese"
+
+####################################################################
+# Generate screen driver interface only with no fonts or clipping
+####################################################################
+NOFONTSORCLIPPING        = N
+
+####################################################################
+#
+# Window move algorithms for Microwindows
+# Change for tradeoff between cpu speed and looks
+# ERASEMOVE repaints only backgrounds while window dragging, quicker.
+# Otherwise an XOR redraw is used for window moves only after button up,
+# quickest (should set for ELKS)
+# UPDATEREGIONS paints in update clipping region only for better look and feel
+#
+####################################################################
+ERASEMOVE                = Y
+UPDATEREGIONS            = Y
+
+####################################################################
+#
+# Link with Gray Palette (valid only for 4bpp modes)
+#
+####################################################################
+GRAYPALETTE              = N
+
+####################################################################
+#
+# If the platform is running UNIX, Linux or RTEMS...
+#
+####################################################################
+ifneq ($(ARCH), ELKS)
+
+# X Window screen, mouse and kbd drivers
+X11                      = N
+
+ifeq ($(X11), Y)
+# startup screen width, height, (depth for palette mode only)
+SCREEN_WIDTH             = 640
+SCREEN_HEIGHT            = 480
+SCREEN_DEPTH             = 4
+
+# You may want to turn this on for XFree86 4.x or if your backing store
+# isn't functioning properly
+USE_EXPOSURE		 = Y
+
+else
+
+# framebuffer screen driver (linear and/or vga 4 planes)
+# set VTSWITCH to include virtual terminal switch code
+# set FBREVERSE to reverse bit orders in 1,2,4 bpp
+# set FBVGA=N for all systems without VGA hardware (for MIPS must=N)
+FRAMEBUFFER              = Y
+FBVGA                    = N
+VTSWITCH                 = Y
+FBREVERSE                = N
+
+# set HAVETEXTMODE=Y for systems that can switch between text & graphics.
+# On a graphics-only embedded system, such as Osprey and Embedded
+# Planet boards, set HAVETEXTMODE=N
+HAVETEXTMODE             = Y
+
+# svgalib screen driver
+VGALIB                   = N
+
+# direct VGA hardware access screen driver
+HWVGA                    = N
+
+####################################################################
+# Mouse drivers
+# GPMMOUSE	gpm mouse
+# SERMOUSE	serial Microsoft, PC, Logitech, PS/2 mice (/dev/psaux)
+# SUNMOUSE	Sun Workstation mouse (/dev/sunmouse)
+# NOMOUSE	no mouse driver
+#
+# Touchscreen drivers
+# IPAQMOUSE	Compaq iPAQ, Intel Assabet (/dev/h3600_tsraw)
+# ZAURUSMOUSE	Sharp Zaurus (/dev/sharp_ts)
+# TUXMOUSE	TuxScreen (/dev/ucb1x00-ts)
+# ADSMOUSE	Applied Data Systems GC+ (/dev/ts)
+# ADS7846MOUSE	        ADS7846 chip, PSI OMAP Innovator (/dev/innnovator_ts)
+# EPMOUSE	Embedded Planet (/dev/tpanel)
+# VHMOUSE	Vtech Helio (/dev/tpanel)
+# MTMOUSE	MicroTouch serial (/dev/ttyS1)
+# PSIONMOUSE	Psion 5 (/dev/touch_psion)
+# YOPYMOUSE	Yopy (/dev/yopy-ts)
+# HARRIERMOUSE	NEC Harrier (/dev/tpanel)
+####################################################################
+GPMMOUSE                 = N
+SERMOUSE                 = N
+SUNMOUSE                 = N
+NOMOUSE                  = N
+IPAQMOUSE                = N
+ZAURUSMOUSE              = N
+TUXMOUSE                 = N
+ADSMOUSE                 = N
+ADS7846MOUSE             = N
+EPMOUSE                  = Y
+VHMOUSE                  = N
+MTMOUSE                  = N
+PSIONMOUSE               = N
+YOPYMOUSE                = N
+HARRIERMOUSE             = N
+
+# keyboard or null kbd driver
+TTYKBD                   = N
+SCANKBD                  = Y
+PIPEKBD                  = N
+IPAQKBD                  = N
+LIRCKBD                  = N
+NOKBD                    = N
+
+#REM:BEGIN  simply comment this line(s) if default device is desired
+KEYBOARDDEV              = "/dev/vc/0"
+MOUSEDEV                 = "/dev/misc/tpanel"
+#REM:END
+endif
+
+####################################################################
+# Screen driver specific configuration
+# SA1100_LCD_LTLEND 4bpp driver with arm SA1100 LCD controller
+# INVERT4BPP 4bpp inverted pixel driver for VTech Helio
+####################################################################
+SA1100_LCD_LTLEND        = N
+INVERT4BPP               = N
+
+####################################################################
+#
+# If the platform is a RTEMS box ....
+#
+####################################################################
+ifeq ($(ARCH), RTEMS)
+
+# Location & BSP information of the RTEMS build
+RTEMS_BUILD              = /tools/build-i386-elf-rtems
+RTEMS_BSP                = pc386
+LINK_APP_INTO_SERVER     = Y
+
+endif
+
+endif
+
+####################################################################
+#
+# If the platform is an ELKS box ...
+#
+####################################################################
+ifeq ($(ARCH), ELKS)
+
+# Higher speed asm driver, c driver of hercules screen driver
+ASMVGADRIVER             = Y
+CVGADRIVER               = N
+HERCDRIVER               = N
+DBGDRIVER                = N
+
+# Mouse support
+SERMOUSE                 = Y
+
+endif
diff -urN microwindows-0.91/src/demo microwindows-0.91.g100/src/demo
--- microwindows-0.91/src/demo	1970-01-01 01:00:00.000000000 +0100
+++ microwindows-0.91.g100/src/demo	2006-10-12 18:23:50.000000000 +0200
@@ -0,0 +1,5 @@
+
+# win32 applications, press <BREAK> key to exit
+bin/mdemo
+#bin/mine	# minefield
+#bin/malpha	# alpha blending
diff -urN microwindows-0.91/src/demos/nanox/Makefile microwindows-0.91.g100/src/demos/nanox/Makefile
--- microwindows-0.91/src/demos/nanox/Makefile	2007-06-17 21:56:35.000000000 +0200
+++ microwindows-0.91.g100/src/demos/nanox/Makefile	2007-06-17 21:44:04.000000000 +0200
@@ -69,7 +69,7 @@
 	$(MW_DIR_BIN)/convpbm \
 	$(MW_DIR_BIN)/nsaver \
 	$(MW_DIR_BIN)/nxcal \
-	$(MW_DIR_BIN)/grabdemo
+	$(MW_DIR_BIN)/grabdemo 
 
 ifneq ($(ARCH),CYGWIN)
 TARGETS += \
@@ -81,8 +81,12 @@
 	$(MW_DIR_BIN)/nxview \
 	$(MW_DIR_BIN)/slider \
 	$(MW_DIR_BIN)/tsdemo \
-	$(MW_DIR_BIN)/tux
-
+	$(MW_DIR_BIN)/tux \
+	$(MW_DIR_BIN)/tux2 \
+	$(MW_DIR_BIN)/nxview2
+#REM: tux2 nxview2
+	       
+	
 # Require MW_FEATURE_TIMERS support:
 TARGETS += \
 	$(MW_DIR_BIN)/nxmag \
@@ -107,6 +111,7 @@
 		$(MW_DIR_SRC)/demos/nanox/world.map \
 		$(MW_DIR_SRC)/demos/nanox/launcher.cnf \
 		$(MW_DIR_SRC)/demos/nanox/tux.gif \
+		$(MW_DIR_SRC)/demos/nanox/tux2.gif \
 		$(MW_DIR_SRC)/demos/nanox/slidebmp.bmp \
 		$(MW_DIR_SRC)/demos/nanox/uponface.ppm \
 		$(MW_DIR_SRC)/demos/nanox/mwlogo.ppm \
@@ -115,6 +120,7 @@
 		$(MW_DIR_SRC)/demos/nanox/ftdemo.txt\
 		$(MW_DIR_BIN)
 
+#		REM: tux2.gif added
 #		$(MW_DIR_SRC)/demos/nanox/transtest.gif
 #		$(MW_DIR_SRC)/demos/nanox/alphatest.png
 
diff -urN microwindows-0.91/src/demos/nanox/ntetris.c microwindows-0.91.g100/src/demos/nanox/ntetris.c
--- microwindows-0.91/src/demos/nanox/ntetris.c	2007-06-17 21:56:35.000000000 +0200
+++ microwindows-0.91.g100/src/demos/nanox/ntetris.c	2006-10-12 18:23:42.000000000 +0200
@@ -242,7 +242,11 @@
 			if(forcedraw || (state->blocks[0][y][x] !=
 						state->blocks[1][y][x])) {
 				state->blocks[1][y][x] = state->blocks[0][y][x];
-				GrSetGCForeground(state->wellgc,
+//*REM*/
+/*REM*/                         if(!state->blocks[0][y][x])
+/*REM*/                           GrSetGCForeground(state->wellgc,NEXT_SHAPE_WINDOW_BACKGROUND_COLOUR);
+/*REM*/                         else
+ 				  GrSetGCForeground(state->wellgc,
 							state->blocks[0][y][x]);
 				GrFillRect(state->well_window, state->wellgc,
 					(BLOCK_SIZE * x),
diff -urN microwindows-0.91/src/demos/nanox/nxview2.c microwindows-0.91.g100/src/demos/nanox/nxview2.c
--- microwindows-0.91/src/demos/nanox/nxview2.c	1970-01-01 01:00:00.000000000 +0100
+++ microwindows-0.91.g100/src/demos/nanox/nxview2.c	2007-05-30 23:32:46.000000000 +0200
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2000, 2001 Greg Haerr <greg@censoft.com>
+ *
+ * nxview - Nano-X image viewer
+ *
+ * Autorecognizes and displays BMP, GIF, JPEG, PNG and XPM files
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#define MWINCLUDECOLORS
+#include "nano-X.h"
+
+int
+main(int argc,char **argv)
+{
+	GR_IMAGE_ID	image_id;
+	GR_WINDOW_ID	window_id;
+	GR_GC_ID	gc_id;
+	GR_SIZE		w = -1;
+	GR_SIZE		h = -1;
+	GR_EVENT	event;
+	GR_SCREEN_INFO	sinfo;
+	GR_IMAGE_INFO	info;
+	char		title[256];
+
+	if (argc < 2) {
+		printf("Usage: nxview <image file> [stretch]\n");
+		exit(1);
+	}
+
+	if (GrOpen() < 0) {
+		fprintf(stderr, "cannot open graphics\n");
+		exit(1);
+	}
+	
+	if (!(image_id = GrLoadImageFromFile(argv[1], 0))) {
+		fprintf(stderr, "Can't load image file: %s\n", argv[1]);
+		exit(1);
+	}
+
+	if(argc > 2) {
+		/* stretch to half screen size*/
+		GrGetScreenInfo(&sinfo);
+		w = sinfo.cols/2;
+		h = sinfo.rows/2;
+	} else {
+		GrGetImageInfo(image_id, &info);
+		w = info.width;
+		h = info.height;
+	}
+
+	sprintf(title, "nxview %s", argv[1]);
+	window_id = GrNewWindowEx(GR_WM_PROPS_APPWINDOW, title,
+				  GR_ROOT_WINDOW_ID, 0, 0, w, h, /*BLACK*/GR_ARGB(0,0,0,0));
+
+	GrSelectEvents(window_id,
+		GR_EVENT_MASK_CLOSE_REQ|GR_EVENT_MASK_EXPOSURE);
+
+	GrMapWindow(window_id);
+
+	gc_id = GrNewGC();
+
+	while (1) {
+		GrGetNextEvent(&event);
+		switch(event.type) {
+		case GR_EVENT_TYPE_CLOSE_REQ:
+			GrDestroyWindow(window_id);
+			GrDestroyGC(gc_id);
+			GrFreeImage(image_id);
+			GrClose();
+			exit(0);
+			/* no return*/
+		case GR_EVENT_TYPE_EXPOSURE:
+			GrDrawImageToFit(window_id, gc_id, 0,0, w,h, image_id);
+			break;
+		}
+	}
+
+	return 0;
+}
diff -urN microwindows-0.91/src/demos/nanox/tux2.c microwindows-0.91.g100/src/demos/nanox/tux2.c
--- microwindows-0.91/src/demos/nanox/tux2.c	1970-01-01 01:00:00.000000000 +0100
+++ microwindows-0.91.g100/src/demos/nanox/tux2.c	2007-03-04 20:06:22.000000000 +0100
@@ -0,0 +1,153 @@
+/*
+ * tux - demonstrate shaped window frames for Nano-X
+ */
+/* 
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (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.mozilla.org/MPL/
+ * 
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ * 
+ * The Original Code is Nano-X Tux.
+ * 
+ * The Initial Developer of the Original Code is Alex Holden.
+ * Portions created by Alex Holden are Copyright (C) 2002
+ * Alex Holden <alex@alexholden.net>. All Rights Reserved.
+ * 
+ * Contributor(s):
+ * 
+ * Alternatively, the contents of this file may be used under the terms
+ * of the GNU General Public license (the  "[GNU] License"), in which case the
+ * provisions of [GNU] License are applicable instead of those
+ * above.  If you wish to allow use of your version of this file only
+ * under the terms of the [GNU] License and not to allow others to use
+ * your version of this file under the MPL, indicate your decision by
+ * deleting  the provisions above and replace  them with the notice and
+ * other provisions required by the [GNU] License.  If you do not delete
+ * the provisions above, a recipient may use your version of this file
+ * under either the MPL or the [GNU] License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <nano-X.h>
+#include <nxcolors.h>
+
+static int button_down = 0, x = 0, y = 0;
+
+GR_WINDOW_ID init(char *tuxfile)
+{
+	GR_GC_ID gc;
+	GR_IMAGE_ID iid;
+	GR_WINDOW_ID wid;
+	GR_REGION_ID rid;
+	GR_WINDOW_ID pid;
+	GR_IMAGE_INFO iif;
+	GR_WM_PROPERTIES props;
+	GR_SCREEN_INFO sinfo;
+	int x, y;
+
+	if(GrOpen() < 0) {
+		fprintf(stderr, "Couldn't connect to Nano-X server\n");
+		return 0;
+	}
+	GrGetScreenInfo(&sinfo);
+
+	if(!(iid = GrLoadImageFromFile(tuxfile, 0))) {
+		fprintf(stderr, "Failed to load image file \"%s\"\n", tuxfile);
+		return 0;
+	}
+	GrGetImageInfo(iid, &iif);
+	pid = GrNewPixmap(iif.width, iif.height, NULL);
+	gc = GrNewGC();
+	GrDrawImageToFit(pid, gc, 0, 0, iif.width, iif.height, iid);
+	GrDestroyGC(gc);
+	GrFreeImage(iid);
+
+	x = sinfo.cols - iif.width;
+	y = sinfo.rows - iif.height;
+	wid = GrNewWindowEx(GR_WM_PROPS_APPWINDOW|GR_WM_PROPS_NOAUTOMOVE, NULL,
+			    GR_ROOT_WINDOW_ID, x, y, iif.width, iif.height, GR_ARGB(0,0,0,0));
+
+	GrSetBackgroundPixmap(wid, pid, GR_BACKGROUND_TOPLEFT);
+
+
+	props.flags = GR_WM_FLAGS_PROPS;
+	props.props = GR_WM_PROPS_NODECORATE;
+	GrSetWMProperties(wid, &props);
+
+	GrSelectEvents(wid, GR_EVENT_MASK_CLOSE_REQ |
+			GR_EVENT_MASK_MOUSE_POSITION |
+			GR_EVENT_MASK_BUTTON_UP |
+			GR_EVENT_MASK_BUTTON_DOWN);
+
+	GrMapWindow(wid);
+
+	return wid;
+}
+
+void button_event(GR_EVENT_BUTTON *ev)
+{
+	if(ev->type == GR_EVENT_TYPE_BUTTON_DOWN) {
+		if(ev->buttons & GR_BUTTON_R) {
+			GrClose();
+			exit(0);
+		}
+		button_down = 1;
+		x = ev->x;
+		y = ev->y;
+		GrRaiseWindow(ev->wid);
+	} else button_down = 0;
+}
+
+void position_event(GR_EVENT_MOUSE *ev)
+{
+	static int newx = 0, newy = 0, oldx = 0, oldy = 0;
+
+	if(!button_down) return;
+
+	newx = ev->rootx - x;
+	newy = ev->rooty - y;
+
+	if(newx != oldx || newy != oldy) {
+		GrMoveWindow(ev->wid, newx, newy);
+		oldx = newx;
+		oldy = newy;
+	}
+}
+
+int main(int argc, char *argv[])
+{
+	char *tuxfile;
+	GR_EVENT event;
+	GR_WINDOW_ID wid;
+
+	if(argc >= 2) tuxfile = argv[1];
+	else {printf("usage: %s <tuxfile>\n",argv[0]);return 1;}
+
+	if(!(wid = init(tuxfile))) return 1;
+
+	while(1) {
+		GrGetNextEvent(&event);
+		switch(event.type) {
+			case GR_EVENT_TYPE_CLOSE_REQ:
+				return 0;
+				break;
+			case GR_EVENT_TYPE_MOUSE_POSITION:
+				position_event(&event.mouse);
+				break;
+			case GR_EVENT_TYPE_BUTTON_UP:
+			case GR_EVENT_TYPE_BUTTON_DOWN:
+				button_event(&event.button);
+				break;
+			default:
+				break;
+		}
+	}
+
+	return 0;
+}
Binärdateien microwindows-0.91/src/demos/nanox/tux2.gif and microwindows-0.91.g100/src/demos/nanox/tux2.gif sind verschieden.
diff -urN microwindows-0.91/src/drivers/fblin16.c microwindows-0.91.g100/src/drivers/fblin16.c
--- microwindows-0.91/src/drivers/fblin16.c	2007-06-17 21:56:36.000000000 +0200
+++ microwindows-0.91.g100/src/drivers/fblin16.c	2007-06-07 23:49:13.000000000 +0200
@@ -19,6 +19,13 @@
 #include "device.h"
 #include "fb.h"
 
+/*REM*/extern unsigned char* gr_alpha;  /* current alpha channel*/
+/*REM*/extern MWCOORD    gr_alpha_x;         /* current x position of alpha channel*/
+/*REM*/extern MWCOORD    gr_alpha_y;         /* current y position of alpha channel*/
+/*REM*/extern MWCOORD    gr_alpha_width;     /* current width of alpha channel*/
+/*REM*/extern MWCOORD    gr_alpha_height;    /* current height of alpha channel*/
+/*REM*/extern MWCLIPMAP *clipmap ;
+
 #define USE_16BIT_ACCESS 0	/* =1 to force 16 bit display access*/
 
 #if USE_16BIT_ACCESS
@@ -55,6 +62,24 @@
 	assert (y >= 0 && y < psd->yres);
 	assert (c < psd->ncolors);
 
+#if defined(TRANS_COLOR)
+	/*REM*/	int   clinelen=0;
+	/*REM*/	char *crc=NULL;
+	/*REM*/ if(clipmap  && clipmap->dirty)
+	/*REM*/   {
+	/*REM*/	   MWCOORD crcx=x-clipmap->clipregion->left;
+	/*REM*/	   MWCOORD crcy=y-clipmap->clipregion->top;
+	/*REM*/    clinelen=clipmap->clipregion->right-clipmap->clipregion->left;
+	/*REM*/    crc=clipmap->clipmap + crcx + (crcy * clinelen);
+	/*REM*/    if(!(*crc)) return;
+	/*REM*/   }
+
+	/*REM*/MWCOORD relx=x-gr_alpha_x;
+	/*REM*/MWCOORD rely=y-gr_alpha_y;
+	/*REM*/if(gr_alpha && (relx>=0)&&(relx<gr_alpha_width)&&(rely>=0)&&(rely<gr_alpha_height))
+	/*REM*/  {if(!gr_alpha[relx+(rely*gr_alpha_width)]) return;}
+#endif
+
 	DRAWON;
 	if(gr_mode == MWMODE_COPY)
 		addr[x + y * psd->linelen] = c;
@@ -89,8 +114,60 @@
 	assert (y >= 0 && y < psd->yres);
 	assert (c < psd->ncolors);
 
-	DRAWON;
 	addr += x1 + y * psd->linelen;
+
+/*REM*/#if defined(TRANS_COLOR)
+	/*REM*/	int   clinelen=0;
+	/*REM*/	char *crc=NULL;
+	/*REM*/ if(clipmap && clipmap->dirty)
+	/*REM*/   {
+	/*REM*/	    MWCOORD crcx=x1-clipmap->clipregion->left;
+	/*REM*/	    MWCOORD crcy=y-clipmap->clipregion->top;
+	/*REM*/     clinelen=clipmap->clipregion->right-clipmap->clipregion->left;
+	/*REM*/     crc=clipmap->clipmap + crcx + (crcy * clinelen);
+	/*REM*/   }
+	
+	/*REM*/ MWCOORD relx1=x1-gr_alpha_x;
+	/*REM*/ MWCOORD rely =y-gr_alpha_y;
+	/*REM*/ unsigned char* alpha=NULL;
+  	/*REM*/  if(gr_alpha && (relx1>=0) && (relx1<gr_alpha_width) && (rely>=0) && (rely<gr_alpha_height) &&
+	/*REM*/     ((x2-x1)<=gr_alpha_width))
+	/*REM*/       alpha=&gr_alpha[relx1+(rely*gr_alpha_width)];
+/*REM*/#endif
+
+	DRAWON;
+/*REM*/#if defined(TRANS_COLOR)
+	/*REM*/if (gr_mode == MWMODE_COPY) {
+	/*REM*/  if(crc||alpha) {
+ 	/*REM*/      while (x1++ <= x2){
+	/*REM*/	       if((crc&&(*crc))||(!crc)) 
+	/*REM*/		 {if((alpha&&(*alpha))||(!alpha)) *addr = c;}
+	/*REM*/	       if(crc)crc++;
+	/*REM*/	       if(alpha)alpha++;
+	/*REM*/	       addr++;
+	/*REM*/      }
+	/*REM*/	 } else {
+	/*REM*/	      /* FIXME: memsetw(dst, c, x2-x1+1)*/
+	/*REM*/	      while(x1++ <= x2)
+	/*REM*/	       *addr++ = c;
+	/*REM*/	 }
+	/*REM*/} else if (gr_mode <= MWMODE_SIMPLE_MAX) {
+	/*REM*/  if(crc||alpha) {
+	/*REM*/	     while (x1++ <= x2) {
+	/*REM*/	       if((crc&&(*crc))||(!crc)) 
+	/*REM*/		{if((alpha&&(*alpha))||(!alpha)) applyOp(gr_mode, c, addr, ADDR16);}
+	/*REM*/	       if(crc)crc++;
+	/*REM*/	       if(alpha)alpha++;
+	/*REM*/	       ++addr;
+	/*REM*/      }
+	/*REM*/	 } else {
+	/*REM*/	      /* FIXME: memsetw(dst, c, x2-x1+1)*/
+	/*REM*/	      while(x1++ <= x2)
+	/*REM*/		applyOp(gr_mode, c, addr, ADDR16);
+	/*REM*/	        ++addr;
+	/*REM*/	 }
+	/*REM*/}
+/*REM*/#else
 	if(gr_mode == MWMODE_COPY) {
 		/* FIXME: memsetw(dst, c, x2-x1+1)*/
 		while(x1++ <= x2)
@@ -101,6 +178,7 @@
 			++addr;
 		}
 	}
+/*REM*/#endif
 	DRAWOFF;
 }
 
@@ -118,8 +196,47 @@
 	assert (y2 >= y1);
 	assert (c < psd->ncolors);
 
+/*REM*/#if defined(TRANS_COLOR)
+	/*REM*/	int   clinelen=0;
+	/*REM*/	char *crc=NULL;
+	/*REM*/ if(clipmap  && clipmap->dirty)
+	/*REM*/   {
+	/*REM*/	    MWCOORD crcx=x-clipmap->clipregion->left;
+	/*REM*/	    MWCOORD crcy=y1-clipmap->clipregion->top;
+	/*REM*/    clinelen=clipmap->clipregion->right-clipmap->clipregion->left;
+	/*REM*/    crc=clipmap->clipmap + crcx + (crcy * clinelen);
+	/*REM*/   }
+
+	/*REM*/MWCOORD relx=x-gr_alpha_x;
+	/*REM*/MWCOORD rely1=y1-gr_alpha_y;
+	/*REM*/MWCOORD rely2=y2-gr_alpha_y;
+	/*REM*/unsigned char* alpha=NULL;
+	/*REM*/if(gr_alpha&& (relx>=0)&&(relx<gr_alpha_width)&&(rely1>=0)&&(rely1+rely2<=gr_alpha_height))
+	/*REM*/     alpha=&gr_alpha[relx+(rely1*gr_alpha_width)];
+/*REM*/#endif
+
 	DRAWON;
 	addr += x + y1 * linelen;
+
+/*REM*/#if defined(TRANS_COLOR)
+	/*REM*/if (gr_mode == MWMODE_COPY) {
+	/*REM*/	while (y1++ <= y2) {
+	/*REM*/	        if((crc&&(*crc))||(!crc)) 
+	/*REM*/		 {if((alpha&&(*alpha))||(!alpha)) *addr = c;}
+	/*REM*/	        if(crc)crc+=clinelen;
+	/*REM*/	        if(alpha)alpha+=gr_alpha_width;
+	/*REM*/		addr += linelen;
+	/*REM*/	}
+	/*REM*/} else if (gr_mode <= MWMODE_SIMPLE_MAX) {
+	/*REM*/	while (y1++ <= y2) {
+	/*REM*/         if((crc&&(*crc))||(!crc)) 
+	/*REM*/		 {if((alpha&&(*alpha))||(!alpha))applyOp(gr_mode, c, addr, ADDR16);}
+	/*REM*/         if(crc)crc+=clinelen;
+	/*REM*/	        if(alpha)alpha+=gr_alpha_width;
+	/*REM*/		addr += linelen;
+	/*REM*/ }
+	/*REM*/}
+/*REM*/#else
 	if(gr_mode == MWMODE_COPY) {
 		while(y1++ <= y2) {
 			*addr = c;
@@ -131,8 +248,10 @@
 			addr += linelen;
 		}
 	}
+/*REM*/#endif
+	  
 	DRAWOFF;
-}
+ }
 
 /* srccopy bitblt*/
 static void
@@ -144,6 +263,10 @@
 	int	i;
 	int	dlinelen = dstpsd->linelen;
 	int	slinelen = srcpsd->linelen;
+/*REM*/	int clinelen_minus_w;
+/*REM*/	int dlinelen_minus_w;
+/*REM*/	int slinelen_minus_w;
+/*REM*/	int alinelen_minus_w;
 #if ALPHABLEND
 	unsigned int alpha;
 #endif
@@ -162,6 +285,25 @@
 	assert (srcy+h <= srcpsd->yres);
 
 	DRAWON;
+
+/*REM*/#if defined(TRANS_COLOR)
+	/*REM*/	int   clinelen=0;
+	/*REM*/	char *crc=NULL;
+	/*REM*/ if(clipmap  && clipmap->dirty)
+	/*REM*/   {
+	/*REM*/	   MWCOORD crcx=dstx-clipmap->clipregion->left;
+	/*REM*/	   MWCOORD crcy=dsty-clipmap->clipregion->top;
+	/*REM*/    clinelen=clipmap->clipregion->right-clipmap->clipregion->left;
+	/*REM*/    crc=clipmap->clipmap + crcx + (crcy * clinelen);
+	/*REM*/   }
+
+	/*REM*/MWCOORD relx=dstx-gr_alpha_x;
+	/*REM*/MWCOORD rely=dsty-gr_alpha_y;
+	/*REM*/unsigned char* alphac=NULL;
+	/*REM*/if(gr_alpha&& (relx>=0)&&(relx+w<=gr_alpha_width)&&(rely>=0)&&(rely+h<=gr_alpha_height))
+	/*REM*/   alphac=&gr_alpha[relx+(rely*gr_alpha_width)];
+/*REM*/#endif
+
 	dst += dstx + dsty * dlinelen;
 	src += srcx + srcy * slinelen;
 
@@ -226,6 +368,29 @@
 			dst += dlinelen;
 			src += slinelen;
 		}
+/*REM*/#if defined(TRANS_COLOR)
+/*REM*/	} else if ((op & MWROP_EXTENSION) == MWROP_SRCTRANSCOPY)
+/*REM*/	  {
+/*REM*/	    dlinelen_minus_w = (dlinelen - w);
+/*REM*/	    slinelen_minus_w = (slinelen - w);
+/*REM*/	    clinelen_minus_w = (clinelen - w);
+/*REM*/	    alinelen_minus_w = (gr_alpha_width - w);
+/*REM*/	    while (--h >= 0) {
+/*REM*/	       for (i = 0; i < w; ++i) {
+/*REM*/	        if((crc&&(*crc))||(!crc)) 
+/*REM*/		 {if((alphac&&(*alphac))||(!alphac)) *dst = *src;}
+/*REM*/	         src++;
+/*REM*/	         dst++;
+/*REM*/	         if(crc)crc++;
+/*REM*/	         if(alphac)alphac++;
+/*REM*/        }
+/*REM*/	       dst += dlinelen_minus_w;
+/*REM*/	       src += slinelen_minus_w;
+/*REM*/	       if(crc) crc += clinelen_minus_w;
+/*REM*/	       if(alphac) alphac += alinelen_minus_w;
+/*REM*/     }
+/*REM*/#endif
+
 	} else {
 		while (--h >= 0) {
 			for (i=0; i<w; i++) {
diff -urN microwindows-0.91/src/drivers/fblin32alpha.c microwindows-0.91.g100/src/drivers/fblin32alpha.c
--- microwindows-0.91/src/drivers/fblin32alpha.c	2007-06-17 21:56:36.000000000 +0200
+++ microwindows-0.91.g100/src/drivers/fblin32alpha.c	2007-06-07 23:22:14.000000000 +0200
@@ -23,6 +23,13 @@
 typedef unsigned long MW_U32;
 typedef long MW_S32;
 
+/*REM*/extern unsigned char* gr_alpha;  /* current alpha channel*/
+/*REM*/extern MWCOORD    gr_alpha_x;         /* current x position of alpha channel*/
+/*REM*/extern MWCOORD    gr_alpha_y;         /* current y position of alpha channel*/
+/*REM*/extern MWCOORD    gr_alpha_width;     /* current width of alpha channel*/
+/*REM*/extern MWCOORD    gr_alpha_height;    /* current height of alpha channel*/
+/*REM*/extern MWCLIPMAP *clipmap ;
+
 /* It's a lot easier to treat the buffer as an array of bytes when
  * alpha blending, and an array of MW_U32 otherwise.  However,
  * without some care, that would not be portable due to endian
@@ -95,7 +102,23 @@
 	assert(addr != 0);
 	assert(x >= 0 && x < psd->xres);
 	assert(y >= 0 && y < psd->yres);
-
+#if defined(TRANS_COLOR)
+	/*REM*/	int   clinelen=0;
+	/*REM*/	char *crc=NULL;
+	/*REM*/ if(clipmap && clipmap->dirty)
+	/*REM*/   {
+	/*REM*/	   MWCOORD crcx=x-clipmap->clipregion->left;
+	/*REM*/	   MWCOORD crcy=y-clipmap->clipregion->top;
+	/*REM*/    clinelen=clipmap->clipregion->right - clipmap->clipregion->left;
+	/*REM*/    crc=clipmap->clipmap + crcx + (crcy * clinelen);
+	/*REM*/    if(!(*crc)) return;
+	/*REM*/   }
+
+	/*REM*/MWCOORD relx=x-gr_alpha_x;
+	/*REM*/MWCOORD rely=y-gr_alpha_y;
+	/*REM*/if(gr_alpha && (relx>=0)&&(relx<gr_alpha_width)&&(rely>=0)&&(rely<gr_alpha_height))
+	/*REM*/  {if(!gr_alpha[relx+(rely*gr_alpha_width)]) return;}
+#endif
 	addr += x + y * psd->linelen;
 
 	DRAWON;
@@ -185,16 +208,58 @@
 
 	addr += x1 + y * psd->linelen;
 
+/*REM*/#if defined(TRANS_COLOR)
+	/*REM*/	int   clinelen=0;
+	/*REM*/	char *crc=NULL;
+	/*REM*/ if(clipmap && clipmap->dirty)
+	/*REM*/   {
+	/*REM*/	    MWCOORD crcx=x1-clipmap->clipregion->left;
+	/*REM*/	    MWCOORD crcy=y-clipmap->clipregion->top;
+	/*REM*/    clinelen=clipmap->clipregion->right-clipmap->clipregion->left;
+	/*REM*/    crc=clipmap->clipmap + crcx + (crcy * clinelen);
+	/*REM*/   }
+	
+	/*REM*/ MWCOORD relx1=x1-gr_alpha_x;
+	/*REM*/ MWCOORD relx2=x2-gr_alpha_x;
+	/*REM*/ MWCOORD rely =y-gr_alpha_y;
+	/*REM*/ unsigned char* alpha=NULL;
+  	/*REM*/  if(gr_alpha && (relx1>=0) && (relx2<gr_alpha_width) && (rely>=0) && (rely<gr_alpha_height) &&
+	/*REM*/     ((x2-x1)<=gr_alpha_width))
+	/*REM*/       alpha=&gr_alpha[relx1+(rely*gr_alpha_width)];
+/*REM*/#endif
+
 	DRAWON;
+/*REM*/#if defined(TRANS_COLOR)
+	/*REM*/if (gr_mode == MWMODE_COPY) {
+ 	/*REM*/         while (x1++ <= x2){
+	/*REM*/	       if((crc&&(*crc))||(!crc)) 
+	/*REM*/		 {if((alpha&&(*alpha))||(!alpha)) *addr = c;}
+	/*REM*/	       if(crc)crc++;
+	/*REM*/	       if(alpha)alpha++;
+	/*REM*/	       addr++;
+	/*REM*/	 }
+	/*REM*/} else if (gr_mode <= MWMODE_SIMPLE_MAX) {
+	/*REM*/	while (x1++ <= x2) {
+	/*REM*/	        if((crc&&(*crc))||(!crc)) 
+	/*REM*/		 {if((alpha&&(*alpha))||(!alpha)) applyOp(gr_mode, c, addr, ADDR32);}
+	/*REM*/		if(crc)crc++;
+	/*REM*/	        if(alpha)alpha++;
+	/*REM*/		++addr;
+	/*REM*/	}
+
+/*REM*/#else
 	if (gr_mode == MWMODE_COPY) {
 		/* FIXME: memsetl(dst, c, x2-x1+1) */
 		while (x1++ <= x2)
 			*addr++ = c;
 	} else if (gr_mode <= MWMODE_SIMPLE_MAX) {
 		while (x1++ <= x2) {
-			applyOp(gr_mode, c, addr, ADDR32);
+		        applyOp(gr_mode, c, addr, ADDR32);
 			++addr;
 		}
+/*REM*/#endif
+
+	//*REM*/Dont know how to handle this for trans color
 	} else {
 		MW_S32 psr, psg, psb;
 		MW_S32 psa, psa_inv;
@@ -309,8 +374,46 @@
 	assert(y2 >= 0 && y2 < psd->yres);
 	assert(y2 >= y1);
 
+/*REM*/#if defined(TRANS_COLOR)
+	/*REM*/	int   clinelen=0;
+	/*REM*/	char *crc=NULL;
+	/*REM*/ if(clipmap && clipmap->dirty)
+	/*REM*/   {
+	/*REM*/	    MWCOORD crcx=x-clipmap->clipregion->left;
+	/*REM*/	    MWCOORD crcy=y1-clipmap->clipregion->top;
+	/*REM*/    clinelen=clipmap->clipregion->right-clipmap->clipregion->left;
+	/*REM*/    crc=clipmap->clipmap + crcx + (crcy * clinelen);
+	/*REM*/   }
+
+	/*REM*/MWCOORD relx=x-gr_alpha_x;
+	/*REM*/MWCOORD rely1=y1-gr_alpha_y;
+	/*REM*/MWCOORD rely2=y2-gr_alpha_y;
+	/*REM*/unsigned char* alpha=NULL;
+	/*REM*/if(gr_alpha&& (relx>=0)&&(relx<gr_alpha_width)&&(rely1>=0)&&(rely1+rely2<=gr_alpha_height))
+	/*REM*/     alpha=&gr_alpha[relx+(rely1*gr_alpha_width)];
+/*REM*/#endif
+
 	DRAWON;
 	addr += x + y1 * linelen;
+
+/*REM*/#if defined(TRANS_COLOR)
+	/*REM*/if (gr_mode == MWMODE_COPY) {
+	/*REM*/	while (y1++ <= y2) {
+	/*REM*/	        if((crc&&(*crc))||(!crc)) 
+	/*REM*/		 {if((alpha&&(*alpha))||(!alpha)) *addr = c;}
+	/*REM*/	        if(crc)crc+=clinelen;
+	/*REM*/	        if(alpha)alpha+=gr_alpha_width;
+	/*REM*/		addr += linelen;
+	/*REM*/	}
+	/*REM*/} else if (gr_mode <= MWMODE_SIMPLE_MAX) {
+	/*REM*/	while (y1++ <= y2) {
+	/*REM*/         if((crc&&(*crc))||(!crc)) 
+	/*REM*/		 {if((alpha&&(*alpha))||(!alpha))applyOp(gr_mode, c, addr, ADDR32);}
+	/*REM*/         if(crc)crc+=clinelen;
+	/*REM*/	        if(alpha)alpha+=gr_alpha_width;
+	/*REM*/		addr += linelen;
+	/*REM*/	}
+/*REM*/#else
 	if (gr_mode == MWMODE_COPY) {
 		while (y1++ <= y2) {
 			*addr = c;
@@ -321,7 +424,9 @@
 			applyOp(gr_mode, c, addr, ADDR32);
 			addr += linelen;
 		}
-	} else {
+/*REM*/#endif
+	//*REM*/Dont know how to handle this for trans color
+		  } else {
 		MW_S32 psr, psg, psb;
 		MW_S32 psa, psa_inv;
 		MW_U32 pd;
@@ -438,10 +543,15 @@
 	int slinelen = srcpsd->linelen;
 	int dlinelen_minus_w4;
 	int slinelen_minus_w4;
+/*REM*/	int clinelen_minus_w;
+/*REM*/	int dlinelen_minus_w;
+/*REM*/	int slinelen_minus_w;
+/*REM*/	int alinelen_minus_w;
 #if ALPHABLEND
 	unsigned int alpha;
 #endif
 
+
 	assert(dst != 0);
 	assert(dstx >= 0 && dstx < dstpsd->xres);
 	assert(dsty >= 0 && dsty < dstpsd->yres);
@@ -456,6 +566,25 @@
 	assert(srcy + h <= srcpsd->yres);
 
 	DRAWON;
+
+/*REM*/#if defined(TRANS_COLOR)
+	/*REM*/	int   clinelen=0;
+	/*REM*/	char *crc=NULL;
+	/*REM*/ if(clipmap && clipmap->dirty)
+	/*REM*/   {
+	/*REM*/	   MWCOORD crcx=dstx-clipmap->clipregion->left;
+	/*REM*/	   MWCOORD crcy=dsty-clipmap->clipregion->top;
+	/*REM*/    clinelen=clipmap->clipregion->right-clipmap->clipregion->left;
+	/*REM*/    crc=clipmap->clipmap + crcx + (crcy * clinelen);
+	/*REM*/   }
+
+	/*REM*/MWCOORD relx=dstx-gr_alpha_x;
+	/*REM*/MWCOORD rely=dsty-gr_alpha_y;
+	/*REM*/unsigned char* alphac=NULL;
+	/*REM*/if(gr_alpha&& (relx>=0)&&(relx+w<=gr_alpha_width)&&(rely>=0)&&(rely+h<=gr_alpha_height))
+	/*REM*/   alphac=&gr_alpha[relx+(rely*gr_alpha_width)];
+/*REM*/#endif
+
 	dst += dstx + dsty * dlinelen;
 	src += srcx + srcy * slinelen;
 
@@ -499,6 +628,7 @@
       stdblit:
 #endif
 
+
 	if (op == MWROP_COPY) {
 		/* copy from bottom up if dst in src rectangle */
 		/* memmove is used to handle x case */
@@ -514,6 +644,29 @@
 			dst += dlinelen;
 			src += slinelen;
 		}
+/*REM*/#if defined(TRANS_COLOR)
+/*REM*/	} else if ((op & MWROP_EXTENSION) == MWROP_SRCTRANSCOPY)
+/*REM*/	  {
+/*REM*/	    dlinelen_minus_w = (dlinelen - w);
+/*REM*/	    slinelen_minus_w = (slinelen - w);
+/*REM*/	    clinelen_minus_w = (clinelen - w);
+/*REM*/	    alinelen_minus_w = (gr_alpha_width - w);
+/*REM*/	    while (--h >= 0) {
+/*REM*/	       for (i = 0; i < w; ++i) {
+/*REM*/	        if((crc&&(*crc))||(!crc)) 
+/*REM*/		 {if((alphac&&(*alphac))||(!alphac)) *dst = *src;}
+/*REM*/	         src++;
+/*REM*/	         dst++;
+/*REM*/	         if(crc)crc++;
+/*REM*/	         if(alphac)alphac++;
+/*REM*/        }
+/*REM*/	       dst += dlinelen_minus_w;
+/*REM*/	       src += slinelen_minus_w;
+/*REM*/	       if(crc) crc += clinelen_minus_w;
+/*REM*/	       if(alphac) alphac += alinelen_minus_w;
+/*REM*/     }
+/*REM*/#endif
+
 	} else if (MWROP_TO_MODE(op) <= MWMODE_SIMPLE_MAX) {
 		for (i = 0; i < w; ++i) {
 			applyOp(MWROP_TO_MODE(op), *src, dst, ADDR32);
diff -urN microwindows-0.91/src/drivers/fblin8.c microwindows-0.91.g100/src/drivers/fblin8.c
--- microwindows-0.91/src/drivers/fblin8.c	2007-06-17 21:56:36.000000000 +0200
+++ microwindows-0.91.g100/src/drivers/fblin8.c	2007-06-09 13:33:31.000000000 +0200
@@ -19,6 +19,13 @@
 #include "device.h"
 #include "fb.h"
 
+/*REM*/extern unsigned char* gr_alpha;  /* current alpha channel*/
+/*REM*/extern MWCOORD    gr_alpha_x;         /* current x position of alpha channel*/
+/*REM*/extern MWCOORD    gr_alpha_y;         /* current y position of alpha channel*/
+/*REM*/extern MWCOORD    gr_alpha_width;     /* current width of alpha channel*/
+/*REM*/extern MWCOORD    gr_alpha_height;    /* current height of alpha channel*/
+/*REM*/extern MWCLIPMAP *clipmap ;
+
 #if ALPHABLEND
 /*
  * Alpha lookup tables for 256 color palette systems
@@ -55,6 +62,23 @@
 	assert (x >= 0 && x < psd->xres);
 	assert (y >= 0 && y < psd->yres);
 	assert (c < psd->ncolors);
+#if defined(TRANS_COLOR)
+	/*REM*/	int   clinelen=0;
+	/*REM*/	char *crc=NULL;
+	/*REM*/ if(clipmap && clipmap->dirty )
+	/*REM*/   {
+	/*REM*/	   MWCOORD crcx=x-clipmap->clipregion->left;
+	/*REM*/	   MWCOORD crcy=y-clipmap->clipregion->top;
+	/*REM*/    clinelen=clipmap->clipregion->right-clipmap->clipregion->left;
+	/*REM*/    crc=clipmap->clipmap + crcx + (crcy * clinelen);
+	/*REM*/    if(!(*crc)) return;
+	/*REM*/   }
+
+	/*REM*/MWCOORD relx=x-gr_alpha_x;
+	/*REM*/MWCOORD rely=y-gr_alpha_y;
+	/*REM*/if(gr_alpha && (relx>=0)&&(relx<gr_alpha_width)&&(rely>=0)&&(rely<gr_alpha_height))
+	/*REM*/  {if(!gr_alpha[relx+(rely*gr_alpha_width)]) return;}
+#endif
 
 	DRAWON;
 	if(gr_mode == MWMODE_COPY)
@@ -90,8 +114,58 @@
 	assert (y >= 0 && y < psd->yres);
 	assert (c < psd->ncolors);
 
-	DRAWON;
 	addr += x1 + y * psd->linelen;
+
+/*REM*/#if defined(TRANS_COLOR)
+	/*REM*/	int   clinelen=0;
+	/*REM*/	char *crc=NULL;
+	/*REM*/ if(clipmap && clipmap->dirty )
+	/*REM*/   {
+	/*REM*/	    MWCOORD crcx=x1-clipmap->clipregion->left;
+	/*REM*/	    MWCOORD crcy=y-clipmap->clipregion->top;
+	/*REM*/     clinelen=clipmap->clipregion->right-clipmap->clipregion->left;
+	/*REM*/     crc=clipmap->clipmap + crcx + (crcy * clinelen);
+	/*REM*/   }
+	
+	/*REM*/ MWCOORD relx1=x1-gr_alpha_x;
+	/*REM*/ MWCOORD rely =y-gr_alpha_y;
+	/*REM*/ unsigned char* alpha=NULL;
+  	/*REM*/  if(gr_alpha && (relx1>=0) && (relx1<gr_alpha_width) && (rely>=0) && (rely<gr_alpha_height) &&
+	/*REM*/     ((x2-x1)<=gr_alpha_width))
+	/*REM*/       alpha=&gr_alpha[relx1+(rely*gr_alpha_width)];
+/*REM*/#endif
+
+	DRAWON;
+/*REM*/#if defined(TRANS_COLOR)
+	/*REM*/if (gr_mode == MWMODE_COPY) {
+	/*REM*/  if(crc||alpha) {
+ 	/*REM*/      while (x1++ <= x2){
+	/*REM*/	       if((crc&&(*crc))||(!crc)) 
+	/*REM*/		 {if((alpha&&(*alpha))||(!alpha)) *addr = c;}
+	/*REM*/	       if(crc)crc++;
+	/*REM*/	       if(alpha)alpha++;
+	/*REM*/	       addr++;
+	/*REM*/	     }
+	/*REM*/	 } else {
+	/*REM*/	      memset(addr, c, x2 - x1 + 1);
+	/*REM*/	 }
+	/*REM*/} else if (gr_mode <= MWMODE_SIMPLE_MAX) {
+	/*REM*/    if(crc||alpha) {
+	/*REM*/	     while (x1++ <= x2) {
+	/*REM*/	       if((crc&&(*crc))||(!crc)) 
+	/*REM*/		 {if((alpha&&(*alpha))||(!alpha)) applyOp(gr_mode, c, addr, ADDR8);}
+	/*REM*/	       if(crc)crc++;
+	/*REM*/	       if(alpha)alpha++;
+	/*REM*/	       ++addr;
+	/*REM*/	     }
+	/*REM*/	   } else {
+	/*REM*/	     while(x1++ <= x2) {
+	/*REM*/	       applyOp(gr_mode, c, addr, ADDR8);
+	/*REM*/	       ++addr;
+	/*REM*/      }
+	/*REM*/    }
+	/*REM*/}
+/*REM*/#else
 	if(gr_mode == MWMODE_COPY)
 		memset(addr, c, x2 - x1 + 1);
 	else {
@@ -100,6 +174,7 @@
 			++addr;
 		}
 	}
+/*REM*/#endif
 	DRAWOFF;
 }
 
@@ -116,9 +191,48 @@
 	assert (y2 >= 0 && y2 < psd->yres);
 	assert (y2 >= y1);
 	assert (c < psd->ncolors);
+/*REM*/#if defined(TRANS_COLOR)
+	/*REM*/	int   clinelen=0;
+	/*REM*/	char *crc=NULL;
+	/*REM*/ if(clipmap && clipmap->dirty )
+	/*REM*/   {
+	/*REM*/	    MWCOORD crcx=x-clipmap->clipregion->left;
+	/*REM*/	    MWCOORD crcy=y1-clipmap->clipregion->top;
+	/*REM*/    clinelen=clipmap->clipregion->right-clipmap->clipregion->left;
+	/*REM*/    crc=clipmap->clipmap + crcx + (crcy * clinelen);
+	/*REM*/   }
+
+	/*REM*/MWCOORD relx=x-gr_alpha_x;
+	/*REM*/MWCOORD rely1=y1-gr_alpha_y;
+	/*REM*/MWCOORD rely2=y2-gr_alpha_y;
+	/*REM*/unsigned char* alpha=NULL;
+	/*REM*/if(gr_alpha&& (relx>=0)&&(relx<gr_alpha_width)&&(rely1>=0)&&(rely1+rely2<=gr_alpha_height))
+	/*REM*/     alpha=&gr_alpha[relx+(rely1*gr_alpha_width)];
+/*REM*/#endif
 
 	DRAWON;
 	addr += x + y1 * linelen;
+
+/*REM*/#if defined(TRANS_COLOR)
+	/*REM*/if (gr_mode == MWMODE_COPY) {
+	/*REM*/	while (y1++ <= y2) {
+	/*REM*/	        if((crc&&(*crc))||(!crc)) 
+	/*REM*/		 {if((alpha&&(*alpha))||(!alpha)) *addr = c;}
+	/*REM*/	        if(crc)crc+=clinelen;
+	/*REM*/	        if(alpha)alpha+=gr_alpha_width;
+	/*REM*/		addr += linelen;
+	/*REM*/	}
+	/*REM*/} else if (gr_mode <= MWMODE_SIMPLE_MAX) {
+	/*REM*/	while (y1++ <= y2) {
+	/*REM*/         if((crc&&(*crc))||(!crc)) 
+	/*REM*/		 {if((alpha&&(*alpha))||(!alpha))applyOp(gr_mode, c, addr, ADDR8);}
+	/*REM*/         if(crc)crc+=clinelen;
+	/*REM*/	        if(alpha)alpha+=gr_alpha_width;
+	/*REM*/		addr += linelen;
+	/*REM*/ }
+	/*REM*/}
+/*REM*/#else
+
 	if(gr_mode == MWMODE_COPY) {
 		while(y1++ <= y2) {
 			*addr = c;
@@ -130,6 +244,8 @@
 			addr += linelen;
 		}
 	}
+/*REM*/#endif
+
 	DRAWOFF;
 }
 
@@ -140,8 +256,13 @@
 {
 	ADDR8	dst;
 	ADDR8	src;
+	int     i;
 	int	dlinelen = dstpsd->linelen;
 	int	slinelen = srcpsd->linelen;
+/*REM*/	int clinelen_minus_w;
+/*REM*/	int dlinelen_minus_w;
+/*REM*/	int slinelen_minus_w;
+/*REM*/	int alinelen_minus_w;
 #if ALPHABLEND
 	unsigned int srcalpha, dstalpha;
 #endif
@@ -160,7 +281,26 @@
 	assert (srcy+h <= srcpsd->yres);
 
 	DRAWON;
-	dst = ((ADDR8)dstpsd->addr) + dstx + dsty * dlinelen;
+
+/*REM*/#if defined(TRANS_COLOR)
+	/*REM*/	int   clinelen=0;
+	/*REM*/	char *crc=NULL;
+	/*REM*/ if(clipmap && clipmap->dirty )
+	/*REM*/   {
+	/*REM*/	   MWCOORD crcx=dstx-clipmap->clipregion->left;
+	/*REM*/	   MWCOORD crcy=dsty-clipmap->clipregion->top;
+	/*REM*/    clinelen=clipmap->clipregion->right-clipmap->clipregion->left;
+	/*REM*/    crc=clipmap->clipmap + crcx + (crcy * clinelen);
+	/*REM*/   }
+
+	/*REM*/MWCOORD relx=dstx-gr_alpha_x;
+	/*REM*/MWCOORD rely=dsty-gr_alpha_y;
+	/*REM*/unsigned char* alphac=NULL;
+	/*REM*/if(gr_alpha&& (relx>=0)&&(relx+w<=gr_alpha_width)&&(rely>=0)&&(rely+h<=gr_alpha_height))
+	/*REM*/   alphac=&gr_alpha[relx+(rely*gr_alpha_width)];
+/*REM*/#endif
+
+ 	dst = ((ADDR8)dstpsd->addr) + dstx + dsty * dlinelen;
 	src = ((ADDR8)srcpsd->addr) + srcx + srcy * slinelen;
 
 #if ALPHABLEND
@@ -216,6 +356,29 @@
 			dst += dlinelen;
 			src += slinelen;
 		}
+/*REM*/#if defined(TRANS_COLOR)
+/*REM*/	} else if ((op & MWROP_EXTENSION) == MWROP_SRCTRANSCOPY)
+/*REM*/	  {
+/*REM*/	    dlinelen_minus_w = (dlinelen - w);
+/*REM*/	    slinelen_minus_w = (slinelen - w);
+/*REM*/	    clinelen_minus_w = (clinelen - w);
+/*REM*/	    alinelen_minus_w = (gr_alpha_width - w);
+/*REM*/	    while (--h >= 0) {
+/*REM*/	       for (i = 0; i < w; ++i) {
+/*REM*/	        if((crc&&(*crc))||(!crc)) 
+/*REM*/		 {if((alphac&&(*alphac))||(!alphac)) *dst = *src;}
+/*REM*/	         src++;
+/*REM*/	         dst++;
+/*REM*/	         if(crc)crc++;
+/*REM*/	         if(alphac)alphac++;
+/*REM*/        }
+/*REM*/	       dst += dlinelen_minus_w;
+/*REM*/	       src += slinelen_minus_w;
+/*REM*/	       if(crc) crc += clinelen_minus_w;
+/*REM*/	       if(alphac) alphac += alinelen_minus_w;
+/*REM*/     }
+/*REM*/#endif
+
 	} else {
 		while (--h >= 0) {
 			int i;
diff -urN microwindows-0.91/src/drivers/kbd_ttyscan.c microwindows-0.91.g100/src/drivers/kbd_ttyscan.c
--- microwindows-0.91/src/drivers/kbd_ttyscan.c	2007-06-17 21:56:36.000000000 +0200
+++ microwindows-0.91.g100/src/drivers/kbd_ttyscan.c	2006-10-12 18:23:44.000000000 +0200
@@ -18,7 +18,11 @@
 #include "device.h"
 #include "fb.h"
 
+/*REM*/#ifndef KEYBOARDDEV
 #define KEYBOARD	"/dev/tty"	/* console kbd to open*/
+/*REM*/#else
+#define KEYBOARD	KEYBOARDDEV
+/*REM*/#endif
 
 static int  TTY_Open(KBDDEVICE *pkd);
 static void TTY_Close(void);
diff -urN microwindows-0.91/src/drivers/Makefile.orig microwindows-0.91.g100/src/drivers/Makefile.orig
--- microwindows-0.91/src/drivers/Makefile.orig	1970-01-01 01:00:00.000000000 +0100
+++ microwindows-0.91.g100/src/drivers/Makefile.orig	2006-10-12 18:23:44.000000000 +0200
@@ -0,0 +1,26 @@
+##############################################################################
+# Microwindows template Makefile
+# Copyright (c) 2000 Martin Jolicoeur, Greg Haerr
+# Portions Copyright (c) 2002 by Koninklijke Philips Electronics N.V.
+##############################################################################
+
+ifndef MW_DIR_SRC
+MW_DIR_SRC := $(CURDIR)/..
+endif
+MW_DIR_RELATIVE := drivers/
+include $(MW_DIR_SRC)/Path.rules
+include $(CONFIG)
+
+############################# targets section ################################
+
+# If you want to create a library with the objects files, define the name here
+LIBNAME = libmwdrivers.a
+#LIBNAMESO = libmwdrivers.so
+
+OBJS := $(MW_DIR_OBJ)/drivers/obsolete.o
+
+######################### Makefile.rules section #############################
+
+include $(MW_DIR_SRC)/Makefile.rules
+
+######################## Tools targets section ###############################
diff -urN microwindows-0.91/src/drivers/mou_vrlinux.c microwindows-0.91.g100/src/drivers/mou_vrlinux.c
--- microwindows-0.91/src/drivers/mou_vrlinux.c	2007-06-17 21:56:36.000000000 +0200
+++ microwindows-0.91.g100/src/drivers/mou_vrlinux.c	2007-05-17 16:38:37.000000000 +0200
@@ -23,12 +23,20 @@
 
 #ifdef TOUCHSCREEN_HELIO
 #define TS_DEVICE "Helio"
+/*REM*/#ifndef MOUSEDEV
 #define TS_DEVICE_FILE "/dev/tpanel"
+/*REM*/#else 
+/*REM*/#define TS_DEVICE_FILE MOUSEDEV
+/*REM*/#endif
 #endif
 
 #ifdef TOUCHSCREEN_EPLANET
 #define TS_DEVICE "Embedded Planet"
+/*REM*/#ifndef MOUSEDEV
 #define TS_DEVICE_FILE "/dev/tpanel"
+/*REM*/#else 
+/*REM*/#define TS_DEVICE_FILE MOUSEDEV
+/*REM*/#endif
 #include <linux/tpanel.h>
 #endif
 
@@ -36,6 +44,8 @@
 #error "You didn't define a device for the VR-Linux touchscreen driver!"
 #endif
 
+/*REM*/ static int pd_fd = -1;
+
 static int PD_Open(MOUSEDEVICE *pmd)
 {	
 #ifdef TOUCHSCREEN_EPLANET
@@ -106,9 +116,9 @@
 #endif
 	int bytes_read;
 
-	bytes_read = read(pd_fd, &event, sizeof(event));
+	bytes_read = read(pd_fd, /*REM: bugfix*/ data, sizeof(/*REM: bugfix*/data));
 	
-	if(bytes_read != sizeof(event)) {
+	if(bytes_read != sizeof(/*REM: bugfix*/data)) {
 		if(bytes_read == -1) {
 			if(errno == EINTR || errno == EAGAIN) return 0;
 			EPRINTF("[%s] Error %d reading from touch panel\n", TS_DEVICE, errno);
@@ -116,7 +126,7 @@
 		}
 		
 		EPRINTF("[%s] Wrong number of bytes %d read from touch panel "
-			"(expected %d)\n", TS_DEVICE, bytes_read, sizeof(event));
+			"(expected %d)\n", TS_DEVICE, bytes_read, sizeof(/*REM: bugfix*/data));
 		return 0;
 	}
 	
@@ -153,6 +163,6 @@
 	PD_GetButtonInfo,
 	PD_GetDefaultAccel,
 	PD_Read,
-	NULL
+	NULL /*REM: bugfix*/,
 	MOUSE_TRANSFORM /* input filter flags */
 };
diff -urN microwindows-0.91/src/drivers/scr_x11.c microwindows-0.91.g100/src/drivers/scr_x11.c
--- microwindows-0.91/src/drivers/scr_x11.c	2007-06-17 21:56:36.000000000 +0200
+++ microwindows-0.91.g100/src/drivers/scr_x11.c	2006-10-12 18:23:44.000000000 +0200
@@ -921,6 +921,7 @@
 	/* draw savebits for readpixel or blit */
 	savebits.DrawPixel(&savebits, x, y, c);
 
+/*REM*/#ifndef TRANS_COLOR
 	if (gr_mode == MWMODE_COPY) {
 		set_color(c);
 		set_mode(gr_mode);
@@ -928,6 +929,10 @@
 	} else {
 		update_from_savebits(x, y, 1, 1);
 	}
+/*REM*/#else
+	update_from_savebits(x, y, 1, 1);
+/*REM*/#endif
+
 }
 
 static MWPIXELVAL
@@ -943,6 +948,7 @@
 	/* draw savebits for readpixel or blit */
 	savebits.DrawHorzLine(&savebits, x1, x2, y, c);
 
+/*REM*/#ifndef TRANS_COLOR
 	if (gr_mode == MWMODE_COPY) {
 		set_color(c);
 		set_mode(gr_mode);
@@ -952,6 +958,13 @@
 				     (x1 < x2 ? x2 - x1 + 1 : x1 - x2 + 1),
 				     1);
 	}
+/*REM*/#else
+	  update_from_savebits((x1 < x2 ? x1 : x2), y,
+			       (x1 < x2 ? x2 - x1 + 1 : x1 - x2 + 1),
+			       1);
+/*REM*/#endif
+
+
 }
 
 static void
@@ -959,6 +972,7 @@
 {
 	savebits.DrawVertLine(&savebits, x, y1, y2, c);
 
+/*REM*/#ifndef TRANS_COLOR
 	if (gr_mode == MWMODE_COPY) {
 		set_color(c);
 		set_mode(gr_mode);
@@ -968,6 +982,13 @@
 				     1,
 				     (y1 < y2 ? y2 - y1 + 1 : y1 - y2 + 1));
 	}
+
+/*REM*/#else
+	  update_from_savebits(x, (y1 < y2 ? y1 : y2),
+			       1,
+			       (y1 < y2 ? y2 - y1 + 1 : y1 - y2 + 1));
+/*REM*/#endif
+
 }
 
 static void
@@ -977,6 +998,7 @@
 	/* draw savebits for readpixel or blit */
 	savebits.FillRect(&savebits, x1, y1, x2, y2, c);
 
+/*REM*/#ifndef TRANS_COLOR
 	if (gr_mode == MWMODE_COPY) {
 		set_color(c);
 		set_mode(gr_mode);
@@ -985,6 +1007,9 @@
 	} else {
 		update_from_savebits(x1, y1, (x2-x1)+1, (y2-y1)+1);
 	}
+/*REM*/#else
+		update_from_savebits(x1, y1, (x2-x1)+1, (y2-y1)+1);
+/*REM*/#endif
 }
 
 static void
diff -urN microwindows-0.91/src/engine/devclip2.c microwindows-0.91.g100/src/engine/devclip2.c
--- microwindows-0.91/src/engine/devclip2.c	2007-06-17 21:56:36.000000000 +0200
+++ microwindows-0.91.g100/src/engine/devclip2.c	2007-06-16 17:57:08.000000000 +0200
@@ -8,6 +8,7 @@
  */
 #include <stdio.h>
 #include "device.h"
+/*REM*/#include <string.h>
 
 /* Clip cache rectangle information.
  * After calling GdClipPoint, this rectangle is guaranteed to contain the
@@ -20,7 +21,151 @@
 MWCOORD clipmaxy;		/* maximum y value of cache rectangle */
 
 static MWBOOL	clipresult;	/* whether clip rectangle is plottable */
-MWCLIPREGION *clipregion = NULL;
+MWCLIPREGION *clipregion = NULL; 
+/*REM*/MWCLIPMAP *clipmap     = NULL; /*current clipmap*/
+/*REM*/MWCLIPMAP *clipmapSave = NULL; /*current saved clipmap*/
+
+//*REM*/BEGIN
+/**
+ * Set a clip map for future drawing actions.
+ * Each pixel will be drawn by the screendriver only if the corresponding 
+ * byte in clipm is set to 0xff. clipm must always
+ * be as big as the current clipping region.
+ * 
+ *
+ * @param clipm pointer to the clipmap
+ * 
+ */
+void
+GdSetClipMap(MWCLIPMAP *clipm)
+{
+  if (clipmap==clipm)
+    return;
+
+  if(clipmap) GdDestroyClipMap(clipmap);
+  clipmap=clipm;
+}
+
+/**
+ * Save the current clipmap and hide
+ * it for future calls. Use GdRestoreClipMap
+ * to make it visible again. Already saved 
+ * clipmaps are deleted.
+ */
+void
+GdSaveClipMap()
+{
+  if(clipmapSave) GdDestroyClipMap(clipmapSave);
+  clipmapSave=clipmap;
+  clipmap=NULL;
+}
+
+/**
+ * Restore saved clipmap. Current 
+ * clipmap will be deleted if set.
+ * 
+ */
+void
+GdRestoreClipMap()
+{
+  if(clipmap) GdDestroyClipMap(clipmap);
+  clipmap=clipmapSave;
+  clipmapSave=NULL;
+}
+
+/**
+ * Destroys clipmap.
+ * 
+ *
+ * @param clipmap Clipmap to destroy
+ * 
+ */
+void GdDestroyClipMap(MWCLIPMAP *clipmap)
+{
+  if(clipmap)
+    {
+      if(clipmap->clipregion)
+	free(clipmap->clipregion);
+      if(clipmap->clipmap)
+	free(clipmap->clipmap);
+      free(clipmap);
+    }
+}
+
+/**
+ * Allocates clipmap and fills it with initval.
+ * 
+ *
+ * @param minx Left x position relative to rootwp.
+ * @param miny Top y position relative to rootwp.
+ * @param maxx Right x position relative to rootwp.
+ * @param maxy Bottom y position relative to rootwp.
+ * @param initval Initial value for clipmap. 
+ * @return pointer to new clipmap
+ * 
+ */
+MWCLIPMAP *GdAllocClipMap(MWCOORD minx,MWCOORD miny,MWCOORD maxx,MWCOORD maxy,unsigned char initval)
+{
+  //alloc MWCLIPMAP
+  MWCLIPMAP *clipmap=calloc(sizeof(MWCLIPMAP), 1);
+  if (clipmap == NULL) {
+    //GsError(GR_ERROR_MALLOC_FAILED, 0);
+    return NULL;
+  }
+  memset(clipmap,0x0,sizeof(MWCLIPMAP));
+
+  //alloc MWRECT
+  clipmap->clipregion=calloc(sizeof(MWRECT),1);
+  if (clipmap->clipregion == NULL) {
+    free(clipmap);
+    //GsError(GR_ERROR_MALLOC_FAILED, 0);
+    return NULL;
+  }
+
+  clipmap->clipregion->left  =minx;
+  clipmap->clipregion->top   =miny;
+  clipmap->clipregion->right =maxx;
+  clipmap->clipregion->bottom=maxy;
+
+  //alloc char
+  clipmap->clipmap=calloc((maxy-miny)*(maxx-minx),1);
+  if (clipmap->clipmap == NULL) {
+    free(clipmap->clipregion);
+    free(clipmap);
+    //GsError(GR_ERROR_MALLOC_FAILED, 0);
+    return NULL;
+  }
+  memset(clipmap->clipmap,initval,(maxy-miny)*(maxx-minx));
+  return clipmap;
+}
+
+/**
+ * Returns current clipmap.
+ * 
+ *
+ * @return Pointer to current clipmap.
+ * 
+ */
+MWCLIPMAP *GdGetClipMap()
+{
+  return clipmap;
+}
+
+/**
+ * Returns current clip region.
+ * 
+ *
+ * @return Pointer to current clip region.
+ * 
+ */
+MWCLIPREGION *GdGetClipRegion()
+{
+  return clipregion;
+}
+
+//*REM*/END
+
+
 
 /**
  * Set a clip region for future drawing actions.
@@ -35,13 +180,15 @@
 void
 GdSetClipRegion(PSD psd, MWCLIPREGION *reg)
 {
-  if(clipregion)
-  	GdDestroyRegion(clipregion);
-
-  if(!reg)
-	  reg = GdAllocRegion();
+  /*REM*/ if(clipregion!=reg)
+  /*REM*/   {
+               if(clipregion)
+  	         GdDestroyRegion(clipregion);
+               if(!reg)
+	          reg = GdAllocRegion();
 
-  clipregion = reg;
+               clipregion = reg;
+  /*REM*/ }
 
 
 #if 0
diff -urN microwindows-0.91/src/engine/devdraw.c microwindows-0.91.g100/src/engine/devdraw.c
--- microwindows-0.91/src/engine/devdraw.c	2007-06-17 21:56:36.000000000 +0200
+++ microwindows-0.91.g100/src/engine/devdraw.c	2007-06-16 17:10:27.000000000 +0200
@@ -22,6 +22,14 @@
 
 extern MWPIXELVAL gr_foreground;      /* current foreground color */
 extern MWPIXELVAL gr_background;      /* current background color */
+/*REM*/extern MWPIXELVAL gr_foreground_alpha;/* current foreground hardware independend alpha channel */
+/*REM*/extern MWPIXELVAL gr_background_alpha;/* current background hardware independend alpha channel */
+/*REM*/extern unsigned char* gr_alpha;       /* alpha channel*/
+/*REM*/extern unsigned char* gr_alpha_save;  /* save location for alpha channel*/
+/*REM*/extern MWCOORD    gr_alpha_x;         /* current x position of alpha channel*/
+/*REM*/extern MWCOORD    gr_alpha_y;         /* current y position of alpha channel*/
+/*REM*/extern MWCOORD    gr_alpha_width;     /* current width of alpha channel*/
+/*REM*/extern MWCOORD    gr_alpha_height;    /* current height of alpha channel*/
 extern MWBOOL 	  gr_usebg;    	      /* TRUE if background drawn in pixmaps */
 extern int 	  gr_mode; 	      /* drawing mode */
 extern MWPALENTRY gr_palette[256];    /* current palette*/
@@ -39,6 +47,48 @@
 /*static*/ void drawrow(PSD psd,MWCOORD x1,MWCOORD x2,MWCOORD y);
 static void drawcol(PSD psd,MWCOORD x,MWCOORD y1,MWCOORD y2);
 
+/*REM: BEGIN*/
+/**
+ * Set current alpha channel
+ *
+ * @param alpha alpha channel.
+ * @param x         x pos of alpha channel.
+ * @param y         y pos of alpha channel.
+ * @param width     width of alpha channel.
+ * @param height    height of alpha channel.
+ */
+void
+GdSetAlphaChannel(unsigned char* alpha, MWCOORD x, MWCOORD y, MWCOORD width, MWCOORD height)
+{
+	gr_alpha = alpha;
+	gr_alpha_x = x;
+	gr_alpha_y = y;
+	gr_alpha_width  = width;
+	gr_alpha_height = height;
+}
+
+/**
+ * Save and hide  current alpha channel
+ */
+void
+GdSaveAlphaChannel()
+{
+        gr_alpha_save=gr_alpha;
+        gr_alpha=NULL;
+}
+
+/**
+ * Restore current alpha channel
+ */
+void
+GdRestoreAlphaChannel()
+{
+        gr_alpha=gr_alpha_save;
+        gr_alpha_save=NULL;
+}
+
+/*REM: END*/
+
 /**
  * Set the drawing mode for future calls.
  *
@@ -96,6 +146,12 @@
 	MWPIXELVAL oldfg = gr_foreground;
 
 	gr_foreground = fg;
+
+/*REM*/ #if (MWPIXEL_FORMAT == MWPF_TRUECOLOR8888) || (MWPIXEL_FORMAT == MWPF_TRUECOLOR0888)
+/*REM*/ gr_foreground_alpha = MWA(fg);
+/*REM*/ #else
+/*REM*/ gr_foreground_alpha = 0xff;//May be we have a FIXME here
+/*REM*/ #endif
 	return oldfg;
 }
 
@@ -112,6 +168,12 @@
 	MWPIXELVAL oldbg = gr_background;
 
 	gr_background = bg;
+/*REM*/ #if (MWPIXEL_FORMAT == MWPF_TRUECOLOR8888) || (MWPIXEL_FORMAT == MWPF_TRUECOLOR0888)
+/*REM*/ gr_background_alpha = MWA(bg);
+/*REM*/ #else
+/*REM*/ gr_background_alpha = 0xff;//May be we have a FIXME here
+/*REM*/ #endif
+
 	return oldbg;
 }
 
@@ -128,6 +190,7 @@
 	MWPIXELVAL oldfg = gr_foreground;
 
 	gr_foreground = GdFindColor(psd, fg);
+/*REM*/ gr_foreground_alpha = MWA(fg);
 	return oldfg;
 }
 
@@ -145,6 +208,7 @@
 	MWPIXELVAL oldbg = gr_background;
 
 	gr_background = GdFindColor(psd, bg);
+/*REM*/ gr_background_alpha = MWA(bg);
 	return oldbg;
 }
 
@@ -178,6 +242,10 @@
 GdPoint(PSD psd, MWCOORD x, MWCOORD y)
 {
 	if (GdClipPoint(psd, x, y)) {
+//*REM*/        firstly lets set the alpha value
+/*REM*/#if defined(TRANS_COLOR)
+/*REM*/         GdAlphaPixel(x,y,gr_foreground_alpha);
+/*REM*/#endif
 		psd->DrawPixel(psd, x, y, gr_foreground);
 		GdFixCursor(psd);
 	}
@@ -300,13 +368,20 @@
 			}
 
 			if (gr_dashcount) {
-				if ((gr_dashmask & (1 << bit)) && GdClipPoint(psd, x1, y1))
+			        if ((gr_dashmask & (1 << bit)) && GdClipPoint(psd, x1, y1)){
+/*REM*/#if defined(TRANS_COLOR)
+/*REM*/                                 GdAlphaPixel(x1,y1,gr_foreground_alpha);
+/*REM*/#endif
 					psd->DrawPixel(psd, x1, y1, gr_foreground);
-
+				}
 				bit = (bit + 1) % gr_dashcount;
 			} else {	/* No dashes */
-				if (GdClipPoint(psd, x1, y1))
+			        if (GdClipPoint(psd, x1, y1)){
+/*REM*/#if defined(TRANS_COLOR)
+/*REM*/                                 GdAlphaPixel(x1,y1,gr_foreground_alpha);
+/*REM*/#endif
 					psd->DrawPixel(psd, x1, y1, gr_foreground);
+				}
 			}
 
 			if (bDrawLastPoint && x1 == x2)
@@ -327,13 +402,21 @@
 
 			/* If we are trying to draw to a dash mask */
 			if (gr_dashcount) {
-				if ((gr_dashmask & (1 << bit)) && GdClipPoint(psd, x1, y1))
+           			if ((gr_dashmask & (1 << bit)) && GdClipPoint(psd, x1, y1)){
+/*REM*/#if defined(TRANS_COLOR)
+/*REM*/                                 GdAlphaPixel(x1,y1,gr_foreground_alpha);
+/*REM*/#endif
 					psd->DrawPixel(psd, x1, y1, gr_foreground);
+				}
 
 				bit = (bit + 1) % gr_dashcount;
 			} else {	/* No dashes */
-				if (GdClipPoint(psd, x1, y1))
+			        if (GdClipPoint(psd, x1, y1)) {
+/*REM*/#if defined(TRANS_COLOR)
+/*REM*/                                 GdAlphaPixel(x1,y1,gr_foreground_alpha);
+/*REM*/#endif
 					psd->DrawPixel(psd, x1, y1, gr_foreground);
+				}
 			}
 
 			if (bDrawLastPoint && y1 == y2)
@@ -348,7 +431,12 @@
 drawpoint(PSD psd, MWCOORD x, MWCOORD y)
 {
 	if (GdClipPoint(psd, x, y))
+	  {
+/*REM*/#if defined(TRANS_COLOR)
+/*REM*/         GdAlphaPixel(x,y,gr_foreground_alpha);
+/*REM*/#endif
 		psd->DrawPixel(psd, x, y, gr_foreground);
+	  }
 }
 
 /* Draw a horizontal line from x1 to and including x2 in the
@@ -381,6 +469,9 @@
 		while (x1 <= x2) {
 			if (GdClipPoint(psd, x1, y)) {
 				temp = MWMIN(clipmaxx, x2);
+/*REM*/#if defined(TRANS_COLOR)
+/*REM*/                         GdAlphaHorzLine(x1,temp,y,gr_foreground_alpha);
+/*REM*/#endif
 				psd->DrawHorzLine(psd, x1, temp, y, gr_foreground);
 			} else
 				temp = MWMIN(clipmaxx, x2);
@@ -391,9 +482,12 @@
 
 		/* We want to draw a dashed line instead */
 		for (p = x1; p <= x2; p++) {
-			if ((gr_dashmask & (1 << bit)) && GdClipPoint(psd, p, y))
+		        if ((gr_dashmask & (1 << bit)) && GdClipPoint(psd, p, y)){
+/*REM*/#if defined(TRANS_COLOR)
+/*REM*/                         GdAlphaPixel(p,y,gr_foreground_alpha);
+/*REM*/#endif
 				psd->DrawPixel(psd, p, y, gr_foreground);
-
+			}
 			bit = (bit + 1) % gr_dashcount;
 		}
 	}
@@ -427,6 +521,9 @@
 		while (y1 <= y2) {
 			if (GdClipPoint(psd, x, y1)) {
 				temp = MWMIN(clipmaxy, y2);
+/*REM*/#if defined(TRANS_COLOR)
+/*REM*/                         GdAlphaVertLine(x,y1,temp,gr_foreground_alpha);
+/*REM*/#endif
 				psd->DrawVertLine(psd, x, y1, temp, gr_foreground);
 			} else
 				temp = MWMIN(clipmaxy, y2);
@@ -437,9 +534,12 @@
 
 		/* We want to draw a dashed line instead */
 		for (p = y1; p <= y2; p++) {
-			if ((gr_dashmask & (1<<bit)) && GdClipPoint(psd, x, p))
+		  if ((gr_dashmask & (1<<bit)) && GdClipPoint(psd, x, p)){
+/*REM*/#if defined(TRANS_COLOR)
+/*REM*/                         GdAlphaPixel(x,p,gr_foreground_alpha);
+/*REM*/#endif
 				psd->DrawPixel(psd, x, p, gr_foreground);
-
+		  }
 			bit = (bit + 1) % gr_dashcount;
 		}
 	}
@@ -504,7 +604,7 @@
 	/* Stipples and tiles have their own drawing routines */
 	if (gr_fillmode != MWFILL_SOLID) {
 		set_ts_origin(x1, y1);
-
+		//*REM*/FIXME: Stripples and tiles does not support trans color
 		ts_fillrect(psd, x1, y1, width, height);
 		GdFixCursor(psd);
 		return;
@@ -515,6 +615,9 @@
 	 */
 	switch (GdClipArea(psd, x1, y1, x2, y2)) {
 	case CLIP_VISIBLE:
+/*REM*/#if defined(TRANS_COLOR)
+/*REM*/         GdAlphaFillRect(x1, y1, x2, y2, gr_foreground_alpha);
+/*REM*/#endif
 		psd->FillRect(psd, x1, y1, x2, y2, gr_foreground);
 		GdFixCursor(psd);
 		return;
@@ -523,7 +626,6 @@
 		return;
 	}
 
-
 	/* Quickly save off the dash settings to avoid problems with drawrow */
 	GdSetDash(&dm, &dc);
 
@@ -585,8 +687,12 @@
 			bitvalue = *imagebits++;
 		}
 		/* draw without clipping*/
-		if (MWIMAGE_TESTBIT(bitvalue))
+		if (MWIMAGE_TESTBIT(bitvalue)) {
+/*REM*/#if defined(TRANS_COLOR)
+/*REM*/                 GdAlphaPixel(x,y,gr_foreground_alpha);
+/*REM*/#endif
 			psd->DrawPixel(psd, x, y, gr_foreground);
+		}
 		bitvalue = MWIMAGE_SHIFTBIT(bitvalue);
 		bitcount--;
 		if (x++ == maxx) {
@@ -639,10 +745,14 @@
 			bitcount = MWIMAGE_BITSPERIMAGE;
 			bitvalue = *imagebits++;
 		}
-		if (MWIMAGE_TESTBIT(bitvalue) && GdClipPoint(psd, x, y))
-			psd->DrawPixel(psd, x, y, gr_foreground);
-			bitvalue = MWIMAGE_SHIFTBIT(bitvalue);
-			bitcount--;
+		if (MWIMAGE_TESTBIT(bitvalue) && GdClipPoint(psd, x, y)){
+/*REM*/#if defined(TRANS_COLOR)
+/*REM*/                 GdAlphaPixel(x,y,gr_foreground_alpha);
+/*REM*/#endif
+		        psd->DrawPixel(psd, x, y, gr_foreground);
+		}
+		        bitvalue = MWIMAGE_SHIFTBIT(bitvalue);
+		        bitcount--;
 		if (x++ == maxx) {
 			x = minx;
 			y++;
@@ -910,9 +1020,12 @@
 				break;
 			}
 
-			if (clip == CLIP_VISIBLE || GdClipPoint(psd, x, y))
+			if (clip == CLIP_VISIBLE || GdClipPoint(psd, x, y)){
+/*REM*/#if defined(TRANS_COLOR)
+/*REM*/                         GdAlphaPixel(x,y,MWA(cr));
+/*REM*/#endif
 				psd->DrawPixel(psd, x, y, pixel);
-
+			}
 			if (x++ == maxx) {
 				/* printf("EOL\n  "); */
 				x = minx;
@@ -974,8 +1087,13 @@
 				}
 
 				if (clip == CLIP_VISIBLE
-				    || GdClipPoint(psd, x, y))
+				    || GdClipPoint(psd, x, y)){
+/*REM*/#if defined(TRANS_COLOR)
+/*REM*/                                 GdAlphaPixel(x,y,MWA(cr));
+/*REM*/#endif
+
 					psd->DrawPixel(psd, x, y, pixel);
+				}
 #if 0
 				/* fix: use clipmaxx to clip quicker */
 				else if (clip != CLIP_VISIBLE && !clipresult
@@ -1004,8 +1122,13 @@
 			default:
 			case 8:
 				bitcount = 0;
-				if (bitvalue == transcolor)
+				if (bitvalue == transcolor){
+/*REM*/#if defined(TRANS_COLOR)
+/*REM*/                                 GdAlphaPixel(x,y,0x00);
+/*REM*/#endif
+
 					goto next;
+				}
 
 				pixel = convtable[bitvalue];
 				break;
@@ -1013,6 +1136,9 @@
 				if (((bitvalue & 0xf0) >> 4) == transcolor) {
 					bitvalue <<= 4;
 					bitcount -= 4;
+/*REM*/#if defined(TRANS_COLOR)
+/*REM*/                                 GdAlphaPixel(x,y,0x00);
+/*REM*/#endif
 					goto next;
 				}
 
@@ -1024,6 +1150,9 @@
 				--bitcount;
 				if (((bitvalue & 0x80) ? 1 : 0) == transcolor) {
 					bitvalue <<= 1;
+/*REM*/#if defined(TRANS_COLOR)
+/*REM*/                                 GdAlphaPixel(x,y,0x00);
+/*REM*/#endif
 					goto next;
 				}
 
@@ -1032,8 +1161,13 @@
 				break;
 			}
 
-			if (clip == CLIP_VISIBLE || GdClipPoint(psd, x, y))
+			if (clip == CLIP_VISIBLE || GdClipPoint(psd, x, y)){
+/*REM*/#if defined(TRANS_COLOR)
+/*REM*/                         GdAlphaPixel(x,y,0xff);
+/*REM*/#endif
+
 				psd->DrawPixel(psd, x, y, pixel);
+			}
 #if 0
 			/* fix: use clipmaxx to clip quicker */
 			else if (clip != CLIP_VISIBLE && !clipresult
@@ -1541,8 +1675,10 @@
 		if (dstpsd != srcpsd)
 			GdCheckCursor(srcpsd, srcx, srcy, srcx+width-1,
 				srcy+height-1);
+
 		dstpsd->Blit(dstpsd, dstx, dsty, width, height,
 			srcpsd, srcx, srcy, rop);
+
 		GdFixCursor(dstpsd);
 		if (dstpsd != srcpsd)
 			GdFixCursor(srcpsd);
@@ -2340,3 +2476,133 @@
 		    outbuf += outpitch - width;
 	}
 }
+
+
+/*REM BEGIN: low level routines to draw into the hardware independent alpha channel*/
+void GdAlphaPixel(MWCOORD x, MWCOORD y,unsigned char alphaval)
+{
+  MWCOORD relx;
+  MWCOORD rely;
+
+  if(!gr_alpha) return;
+
+  relx=x-gr_alpha_x;
+  rely=y-gr_alpha_y;
+
+  if((relx>=0)&&(relx<gr_alpha_width)&&(rely>=0)&&(rely<gr_alpha_height))
+    gr_alpha[relx + (rely*gr_alpha_width)]=alphaval;
+}
+void GdAlphaFillRect(MWCOORD x1, MWCOORD y1, MWCOORD x2, MWCOORD y2, unsigned char alphaval)
+{
+  MWCOORD relx1,relx2;
+  MWCOORD rely1,rely2;
+
+  if(!gr_alpha) return;
+
+  relx1=x1-gr_alpha_x;
+  rely1=y1-gr_alpha_y;
+  relx2=x2-gr_alpha_x;
+  rely2=y2-gr_alpha_y;
+
+  //check if we can fill the whole area
+  if(((x2-x1+1)==gr_alpha_width) && ((y2-y1+1)==gr_alpha_height))
+    {
+      memset(gr_alpha,alphaval,gr_alpha_width*gr_alpha_height);
+      return;
+    }
+
+  if((relx1>=0)&&(relx2<gr_alpha_width)&&(rely1>=0)&&(rely2<gr_alpha_height))
+    {
+      int y;
+      for(y=rely1;y<=rely2;y++)
+	memset(&gr_alpha[(y*gr_alpha_width)+relx1],alphaval,(x2-x1)+1);
+    }
+}
+
+void GdAlphaHorzLine(MWCOORD x1, MWCOORD x2, MWCOORD y, unsigned char alphaval)
+{
+  MWCOORD relx1,relx2;
+  MWCOORD rely;
+
+  if(!gr_alpha) return;
+
+  relx1=x1-gr_alpha_x;
+  relx2=x2-gr_alpha_x;
+  rely =y-gr_alpha_y;
+  
+  if((relx1>=0)&&(relx2<gr_alpha_width)&&(rely>=0)&&(rely<gr_alpha_height))
+    memset(&gr_alpha[(rely*gr_alpha_width)+relx1],alphaval,(x2-x1)+1);
+
+}
+void GdAlphaVertLine(MWCOORD x, MWCOORD y1, MWCOORD y2, unsigned char alphaval)
+{
+  MWCOORD rely1,rely2;
+  MWCOORD relx;
+
+  if(!gr_alpha) return;
+
+  relx=x-gr_alpha_x;
+  rely1=y1-gr_alpha_y;
+  rely2=y2-gr_alpha_y;
+
+  if((relx>=0)&&(relx<gr_alpha_width)&&(rely1>=0)&&(rely2<gr_alpha_height))
+    {
+      int y;
+      for(y=rely1;y<=rely2;y++)
+	gr_alpha[(y*gr_alpha_width)+relx]=alphaval;
+    }
+}
+
+/*
+ * We copy a rectangle from srcalpha srcx,srcy srcwidth x scrheight to dstalpha, dstx, dsty 
+ * Be sure that src does fit into dst; dstheight and dstwith describes the dstalpha size
+ *
+ */
+void GdAlphaBlit(unsigned char *dstalpha, MWCOORD dstx, MWCOORD dsty, MWCOORD dstwidth, MWCOORD dstheight,
+		 unsigned char *srcalpha, MWCOORD srcx, MWCOORD srcy, MWCOORD srcwidth, MWCOORD srcheight)
+
+{
+  if(!dstalpha) return;
+  if(!srcalpha) return;
+  if(srcx>=srcwidth) return;
+  if(srcy>=srcheight) return;
+  if(srcwidth<=0) return;
+  if(srcheight<=0) return;
+
+  if(dstx>=dstwidth) return;
+  if(dsty>=dstheight) return;
+  if(dstwidth<=0) return;
+  if(dstheight<=0) return;
+
+  //FIXME:do a proper adjustment here; Currently we return here if src does not fit into dst
+  if(srcx<0) return;
+  if(srcy<0) return;
+  if(dstx<0) return;
+  if(dsty<0) return;
+  if((dstx+srcwidth)>dstwidth)return;
+  if((dsty+srcheight)>dstheight)return;
+
+  //printf("performoing GdAlphaBlit\n");
+
+  if(!srcx && !srcy && !dstx && !dsty && (dstheight==srcheight) && (dstwidth==srcwidth))
+    {
+      memcpy(dstalpha,srcalpha,srcwidth*srcheight);
+    }
+  else
+    {
+      unsigned char *dst=dstalpha+dstx;
+      unsigned char *src=srcalpha+srcx;
+      MWCOORD line=0;
+
+      while(line<srcheight)
+	{
+	  memcpy(dst,src,srcwidth);
+	  src+=srcwidth;
+	  dst+=dstwidth;
+	  line++;
+	}
+    }
+}
+
+
+/*REM END:*/
diff -urN microwindows-0.91/src/engine/devmouse.c microwindows-0.91.g100/src/engine/devmouse.c
--- microwindows-0.91/src/engine/devmouse.c	2007-06-17 21:56:36.000000000 +0200
+++ microwindows-0.91.g100/src/engine/devmouse.c	2006-10-12 18:23:44.000000000 +0200
@@ -404,6 +404,15 @@
 	cursorptr = cursorcolor;
 	maskptr = cursormask;
 
+
+/*REM*/#if defined(TRANS_COLOR)
+	//*REM*/Since cursor shouldnt be clipped out
+	//*REM*/by the clipmap,we simply hide it for some time 
+	//*REM*/We hide alpha channel, too.
+	/*REM*/GdSaveClipMap();
+        /*REM*/GdSaveAlphaChannel();
+/*REM*/#endif
+
 	/*
 	 * Loop through bits, resetting to firstbit at end of each row
 	 */
@@ -435,6 +444,10 @@
 	}
 
 	gr_mode = oldmode;
+/*REM*/#if defined(TRANS_COLOR)
+	/*REM*/GdRestoreClipMap();
+        /*REM*/GdRestoreAlphaChannel();
+/*REM*/#endif
 	return prevcursor;
 }
 
@@ -454,6 +467,15 @@
 
 	if(curvisible-- <= 0)
 		return prevcursor;
+
+/*REM*/#if defined(TRANS_COLOR)
+	//*REM*/Since cursor shouldnt be clipped out
+	//*REM*/by the clipmap,we simply hide it for some time.
+	//*REM*/We hide alpha channel, too.
+	/*REM*/GdSaveClipMap();
+        /*REM*/GdSaveAlphaChannel();
+/*REM*/#endif
+
 	oldmode = gr_mode;
 	gr_mode = MWMODE_COPY;
 
@@ -467,6 +489,10 @@
 		}
 	}
  	gr_mode = oldmode;
+/*REM*/#if defined(TRANS_COLOR)
+	/*REM*/GdRestoreClipMap();
+        /*REM*/GdRestoreAlphaChannel();
+/*REM*/#endif
 	return prevcursor;
 }
 
diff -urN microwindows-0.91/src/engine/devopen.c microwindows-0.91.g100/src/engine/devopen.c
--- microwindows-0.91/src/engine/devopen.c	2007-06-17 21:56:36.000000000 +0200
+++ microwindows-0.91.g100/src/engine/devopen.c	2006-10-12 18:23:44.000000000 +0200
@@ -34,6 +34,15 @@
 
        MWPIXELVAL gr_foreground;      /* current foreground color */
        MWPIXELVAL gr_background;      /* current background color */
+/*REM*/MWPIXELVAL gr_foreground_alpha;/* current foreground hardware independend alpha channel */
+/*REM*/MWPIXELVAL gr_background_alpha;/* current background hardware independend alpha channel */
+/*REM*/unsigned char* gr_alpha=NULL;  /* current alpha channel*/
+/*REM*/unsigned char* gr_alpha_save;  /* save location for alpha channel*/
+/*REM*/MWCOORD    gr_alpha_x;         /* current x position of alpha channel*/
+/*REM*/MWCOORD    gr_alpha_y;         /* current y position of alpha channel*/
+/*REM*/MWCOORD    gr_alpha_width;     /* current width of alpha channel*/
+/*REM*/MWCOORD    gr_alpha_height;    /* current height of alpha channel*/
+
        MWBOOL 	gr_usebg;    	    /* TRUE if background drawn in pixmaps */
        int 	gr_mode = MWMODE_COPY; 	    /* drawing mode */
 /*static*/ MWPALENTRY	gr_palette[256];    /* current palette*/
@@ -160,7 +169,7 @@
 #endif /* NOFONTSORCLIPPING*/
 
 	/* fill black (actually fill to first palette entry or truecolor 0*/
-	psd->FillRect(psd, 0, 0, psd->xvirtres-1, psd->yvirtres-1, 0);
+	psd->FillRect(psd, 0, 0, psd->xvirtres-1, psd->yvirtres-1, /*REM*//*0*/MWRGB(0,0,0));
 	return psd;
 }
 
diff -urN microwindows-0.91/src/include/device.h microwindows-0.91.g100/src/include/device.h
--- microwindows-0.91/src/include/device.h	2007-06-17 21:56:39.000000000 +0200
+++ microwindows-0.91.g100/src/include/device.h	2007-06-09 12:21:08.000000000 +0200
@@ -420,6 +420,15 @@
 	MWCOORD 	height;		/* height of rectangle */
 } MWCLIPRECT;
 
+/*REM BEGIN*/
+/* static clipmap with rectangle: drawing allowed if point within rectangle is marked as 0xff in clipmap*/
+typedef struct {
+  MWRECT *clipregion;
+  char *clipmap;
+  char dirty; /*1 if clipmap has at least one '0'; fb drivers will ignore clipmap if 0 is set*/
+} MWCLIPMAP;
+/*REM END*/
+
 typedef struct {
 	MWCOORD	width;
 	MWCOORD	height;
@@ -708,6 +717,17 @@
 int	GdCaptureScreen(char *path);
 void	GdGetScreenInfo(PSD psd,PMWSCREENINFO psi);
 void	GdPoint(PSD psd,MWCOORD x, MWCOORD y);
+/*REM: BEGIN*/
+void GdSetAlphaChannel(unsigned char* alpha, MWCOORD x, MWCOORD y, MWCOORD width, MWCOORD height);
+void GdSaveAlphaChannel();
+void GdRestoreAlphaChannel();
+void GdAlphaPixel(MWCOORD x, MWCOORD y,unsigned char alphaval);
+void GdAlphaFillRect(MWCOORD x1, MWCOORD y1, MWCOORD x2, MWCOORD y2, unsigned char alphaval);
+void GdAlphaHorzLine(MWCOORD x1, MWCOORD x2, MWCOORD y, unsigned char alphaval);
+void GdAlphaVertLine(MWCOORD x, MWCOORD y1, MWCOORD y2, unsigned char alphaval);
+void GdAlphaBlit(unsigned char *dstalpha, MWCOORD dstx, MWCOORD dsty, MWCOORD dstwidth, MWCOORD dstheight,
+		 unsigned char *srcalpha, MWCOORD srcx, MWCOORD srcy, MWCOORD srcwidth, MWCOORD srcheight);
+/*REM: END*/
 void	GdLine(PSD psd,MWCOORD x1,MWCOORD y1,MWCOORD x2,MWCOORD y2,
 		MWBOOL bDrawLastPoint);
 void	GdRect(PSD psd,MWCOORD x, MWCOORD y, MWCOORD width, MWCOORD height);
@@ -791,6 +811,16 @@
 
 /* devclip2.c*/
 void	GdSetClipRegion(PSD psd, MWCLIPREGION *reg);
+/*REM BEGIN*/
+void GdSetClipMap(MWCLIPMAP *clipm);
+void GdSaveClipMap();
+void GdRestoreClipMap();
+void GdDestroyClipMap(MWCLIPMAP *clipmap);
+MWCLIPMAP *GdAllocClipMap(MWCOORD minx,MWCOORD miny,MWCOORD maxx,MWCOORD maxy,unsigned char initval);
+MWCLIPMAP *GdGetClipMap();
+MWCLIPREGION *GdGetClipRegion();
+/*REM END*/
+
 
 /* devrgn.c - multi-rectangle region entry points*/
 MWBOOL GdPtInRegion(MWCLIPREGION *rgn, MWCOORD x, MWCOORD y);
diff -urN microwindows-0.91/src/include/mwtypes.h microwindows-0.91.g100/src/include/mwtypes.h
--- microwindows-0.91/src/include/mwtypes.h	2007-06-17 21:56:39.000000000 +0200
+++ microwindows-0.91.g100/src/include/mwtypes.h	2006-10-12 18:23:49.000000000 +0200
@@ -112,6 +112,10 @@
 #define MWRGB(r,g,b)	MWARGB(255,(r),(g),(b))		/* rgb full alpha*/
 #define MW0RGB(r,g,b)	MWARGB(0,(r),(g),(b))		/* rgb no alpha*/
 
+/*REM*/#define MWA(val) ((((MWCOLORVAL)val)&0xff000000)>>24)
+/*REM*/#define MWR(val) ((((MWCOLORVAL)val)&0x000000ff)>>0)
+/*REM*/#define MWG(val) ((((MWCOLORVAL)val)&0x0000ff00)>>8)
+/*REM*/#define MWB(val) ((((MWCOLORVAL)val)&0x00ff0000)>>16)
 
 /* convert an MWROP to drawing mode MWMODE value*/
 #define MWROP_TO_MODE(op)	((op) >> 24)
diff -urN microwindows-0.91/src/include/nano-X.h microwindows-0.91.g100/src/include/nano-X.h
--- microwindows-0.91/src/include/nano-X.h	2007-06-17 21:56:39.000000000 +0200
+++ microwindows-0.91.g100/src/include/nano-X.h	2007-06-03 18:20:41.000000000 +0200
@@ -104,6 +104,15 @@
 
 #define GR_MODE_DRAWMASK	0x00FF
 #define GR_MODE_EXCLUDECHILDREN	0x0100		/* exclude children on clip*/
+/*REM*/#define GR_MODE_DIRECTCHILD	0x0200	/* direct child only on clip (using GsSetClipWindowPart) */
+/*REM*/#define GR_MODE_DIRECTSIBLING	0x0400	/* direct sibling only on clip (using GsSetClipWindowPart)*/
+/*REM*/#define GR_MODE_THISWP	        0x0800	/* add wp to clipregion and clipmap on clip (using GsSetClipWindowPart)*/
+
+//*REM*/Flags for GsWpClearWpAndChilds
+/*REM*/#define GR_MODE_WPCLEAR_WP2CLR   0x0001  /* Tells GsWpClearWpAndChilds that wp is the window to be cleared*/
+/*REM*/#define GR_MODE_WPCLEAR_PARENT   0x0002  /* Tells GsWpClearWpAndChilds that we went up to next parent     */
+/*REM*/#define GR_MODE_WPCLEAR_SIBLING  0x0004  /* Tells GsWpClearWpAndChilds that we went to the next sibling   */
+/*REM*/#define GR_MODE_WPCLEAR_CHILD    0x0010  /* Tells GsWpClearWpAndChilds that we went to the next child     */
 
 /* Line modes */
 #define GR_LINE_SOLID           MWLINE_SOLID
@@ -726,6 +735,7 @@
 			GR_SIZE width, GR_SIZE height, GR_SIZE bordersize,
 			GR_COLOR background, GR_COLOR bordercolor);
 GR_WINDOW_ID    GrNewPixmap(GR_SIZE width, GR_SIZE height, void *pixels);
+/*REM*/GR_WINDOW_ID    GrResizePixmap(GR_WINDOW_ID wid,GR_SIZE width, GR_SIZE height, void * pixels);
 GR_WINDOW_ID	GrNewInputWindow(GR_WINDOW_ID parent, GR_COORD x, GR_COORD y,
 				GR_SIZE width, GR_SIZE height);
 void		GrDestroyWindow(GR_WINDOW_ID wid);
diff -urN microwindows-0.91/src/Makefile.rules microwindows-0.91.g100/src/Makefile.rules
--- microwindows-0.91/src/Makefile.rules	2007-06-17 21:56:35.000000000 +0200
+++ microwindows-0.91.g100/src/Makefile.rules	2006-10-12 18:23:41.000000000 +0200
@@ -62,6 +62,15 @@
 ifeq ($(ARCH),CYGWIN)
 INCLUDEDIRS += -I/usr/X11R6/include
 endif
+# REM: BEGIN: custom keyboard device if no X11
+else
+ifneq ($(KEYBOARDDEV),"")
+DEFINES += -DKEYBOARDDEV="\"$(KEYBOARDDEV)"\"
+endif
+ifneq ($(MOUSEDEV),"")
+DEFINES += -DMOUSEDEV="\"$(MOUSEDEV)"\"
+endif
+# REM: END
 endif
 
 ifeq ($(VGALIB), Y)
@@ -230,6 +239,19 @@
 #LDFLAGS += -lpthread
 endif
 
+# REM: BEGIN: TCPIP support
+ifeq ($(HAVE_TCP_IP_SUPPORT), Y)
+DEFINES += -DHAVE_TCP_IP_SUPPORT=1
+endif
+# REM: END
+
+# REM: BEGIN: transparent color support
+ifeq ($(HAVE_TRANS_COLOR_SUPPORT), Y)
+DEFINES += -DTRANS_COLOR=1
+endif
+# REM: END
+
+
 # Driver-specific stuff
 ifneq ($(ARCH), ELKS)
 ifneq ($(ARCH), DJGPP)
diff -urN microwindows-0.91/src/nanox/client.c microwindows-0.91.g100/src/nanox/client.c
--- microwindows-0.91/src/nanox/client.c	2007-06-17 21:56:40.000000000 +0200
+++ microwindows-0.91.g100/src/nanox/client.c	2006-10-12 18:23:49.000000000 +0200
@@ -29,6 +29,13 @@
 #include <signal.h>
 #include <errno.h>
 #include <time.h>
+/*REM: BEGIN*/
+#ifdef HAVE_TCP_IP_SUPPORT
+#include <netinet/in.h>
+#include <netdb.h>
+#endif
+/*REM: END*/
+
 #if HAVE_SHAREDMEM_SUPPORT
 #include <sys/types.h>
 #include <sys/ipc.h>
@@ -68,8 +75,16 @@
  * Default to unix socket for client/server.
  * @internal
  */
+
+/*REM: BEGIN*/
+#ifdef HAVE_TCP_IP_SUPPORT
+#define ADDR_FAM AF_INET
+#else
 #define ADDR_FAM AF_UNIX
 #endif
+//#define ADDR_FAM AF_UNIX
+/*REM: END*/
+#endif //ADDR_FAM
 
 #define GR_CLOSE_FIX	1	/* dirty hack attempts to fix GrClose hang bug*/
 
@@ -317,15 +332,32 @@
 	struct sockaddr_in name;
 	struct hostent *he;
 	/* allow specification of remote nano-X server address*/
-	char *sockaddr = getenv("NXDISPLAY");
-	if (!sockaddr)
-		sockaddr = "127.0.0.1";		/* loopback address*/
+/*REM: BEGIN*/
+	char sockaddr[20]={0};
+	if(getenv("NXDISPLAY"))
+		strcpy(sockaddr,getenv("NXDISPLAY"));
+	else 
+		strcpy(sockaddr,"127.0.0.1");		/* loopback address*/
+
+	//char *sockaddr = getenv("NXDISPLAY");
+	//if (!sockaddr)
+	//	sockaddr = "127.0.0.1";		/* loopback address*/
+/*REM: END*/
+
 #elif ADDR_FAM == AF_UNIX
 	struct sockaddr_un name;
 	/* allow override of named UNIX socket (default /tmp/.nano-X)*/
-	char *sockname = getenv("NXDISPLAY");
-	if (!sockname)
-		sockname = GR_NAMED_SOCKET;
+/*REM: BEGIN*/
+	char sockname[20]={0};
+	if (getenv("NXDISLAY")!=NULL)
+		strcpy(sockname,getenv("NXDISPLAY"));
+	else
+		strcpy(sockname,GR_NAMED_SOCKET);
+
+	//char *sockname = getenv("NXDISPLAY");
+	//if (!sockname)
+	//	sockname = GR_NAMED_SOCKET;
+/*REM: END*/
 #else
 #error "ADDR_FAM not defined to AF_NANO, AF_INET or AF_UNIX"
 #endif
@@ -2043,6 +2075,33 @@
 	UNLOCK(&nxGlobalLock);
 }
 
+/*REM BEGIN:*/ 
+/**
+ * Resizes the specified Pixmap to be the specified width and height.
+ *
+ * @param wid  the ID of the Pixmap to resize
+ * @param width  the width to resize the window to
+ * @param height  the height to resize the window to
+ *
+ * @ingroup nanox_window
+ */
+GR_WINDOW_ID 
+GrResizePixmap(GR_WINDOW_ID wid, GR_SIZE width, GR_SIZE height, void * pixels)
+{
+	nxResizePixmapReq *req;
+
+	LOCK(&nxGlobalLock);
+	req = AllocReq(ResizePixmap);
+	req->windowid = wid;
+	req->width = width;
+	req->height = height;
+	if(TypedReadBlock(&wid, sizeof(wid), GrNumResizePixmap) == -1)
+		wid = 0;
+	UNLOCK(&nxGlobalLock);
+	return wid;
+}
+/*REM END*/ 
+
 /**
  * Changes the parent window of the specified window to the specified parent
  * window and places it at the specified coordinates relative to the new
diff -urN microwindows-0.91/src/nanox/.cvsignore microwindows-0.91.g100/src/nanox/.cvsignore
--- microwindows-0.91/src/nanox/.cvsignore	2007-06-17 21:56:40.000000000 +0200
+++ microwindows-0.91.g100/src/nanox/.cvsignore	1970-01-01 01:00:00.000000000 +0100
@@ -1 +0,0 @@
-.depend
diff -urN microwindows-0.91/src/nanox/nxdraw.c microwindows-0.91.g100/src/nanox/nxdraw.c
--- microwindows-0.91/src/nanox/nxdraw.c	2007-06-17 21:56:40.000000000 +0200
+++ microwindows-0.91.g100/src/nanox/nxdraw.c	2007-06-09 11:22:49.000000000 +0200
@@ -18,7 +18,6 @@
 	GR_RECT		r;
 	/* *static GR_FONT_ID fontid = 0;***/
 
-
 	if (props & GR_WM_PROPS_APPFRAME) {
 		/* draw 2-line 3d border around window*/
 		nxDraw3dOutset(id, x, y, w, h);
diff -urN microwindows-0.91/src/nanox/nxproto.h microwindows-0.91.g100/src/nanox/nxproto.h
--- microwindows-0.91/src/nanox/nxproto.h	2007-06-17 21:56:40.000000000 +0200
+++ microwindows-0.91.g100/src/nanox/nxproto.h	2006-10-12 18:23:49.000000000 +0200
@@ -1366,4 +1366,17 @@
 	INT16 height;
 } nxCopyFontReq;
 
-#define GrTotalNumCalls         125
+/*REM BEGIN:*/
+#define GrNumResizePixmap          125
+typedef struct {
+	BYTE8	reqType;
+	BYTE8	hilength;
+	UINT16	length;
+	IDTYPE	windowid;
+	INT16	width;
+	INT16	height;
+/* FIXME: Add support for passing shared memory info */
+} nxResizePixmapReq;
+/*REM END*/
+
+/*REM*/ #define GrTotalNumCalls         126
diff -urN microwindows-0.91/src/nanox/serv.h microwindows-0.91.g100/src/nanox/serv.h
--- microwindows-0.91/src/nanox/serv.h	2007-06-17 21:56:40.000000000 +0200
+++ microwindows-0.91.g100/src/nanox/serv.h	2007-06-09 11:18:39.000000000 +0200
@@ -365,6 +365,11 @@
 	GR_WM_PROPS	props;		/* window properties*/
 	GR_CHAR		*title;		/* window title*/
 	MWCLIPREGION	*clipregion;	/* window clipping region */
+/*REM*/ unsigned char   *alpha;         /* alpha channel of window.*/
+                                        /* 0 means pixel is transparent and will*/ 
+                                        /* not be drawn. 255 pixel will be drawn.*/ 
+                                        /* An additional pixel based clipping region*/ 
+                                        /* will be generated with this information.*/ 
 };
 
 /*
@@ -382,6 +387,11 @@
 
 	GR_PIXMAP	*next;		/* next pixmap in list */
 	GR_CLIENT	*owner;		/* client that created it */
+/*REM*/ unsigned char   *alpha;         /* alpha channel of window.*/
+                                        /* 0 means pixel is transparent and will*/ 
+                                        /* not be drawn. 255 pixel will be drawn.*/ 
+                                        /* An additional pixel based clipping region*/ 
+                                        /* will be generated with this information.*/ 
 };
 
 /**
@@ -432,13 +442,32 @@
 			GR_COORD x, GR_COORD y, GR_SIZE width, GR_SIZE height);
 void		GsWpClearWindow(GR_WINDOW *wp, GR_COORD x, GR_COORD y,
 			GR_SIZE width, GR_SIZE height, GR_BOOL exposeflag);
-void		GsWpUnrealizeWindow(GR_WINDOW *wp, GR_BOOL temp_unmap);
+/*REM*/void     GsWpClearWindowUpAndDown(GR_WINDOW *wp, GR_COORD x, GR_COORD y, GR_SIZE width,
+					 GR_SIZE  height, GR_BOOL exposeflag);
+/*REM*/void     GsWpSmartClearWindow(GR_WINDOW *wp, MWRECT AreaToDraw, GR_BOOL exposeflag);
+/*REM*/void     GsWpClearWpAndChilds(GR_WINDOW *wp, MWRECT AreaToDraw, GR_BOOL exposeflag, int flags);
+void		GsWpUnrealizeWindow(GR_WINDOW *wp, GR_BOOL temp_unmap,/*REM*/char DoNotClear);
 void		GsWpRealizeWindow(GR_WINDOW *wp, GR_BOOL temp);
 void		GsWpDestroyWindow(GR_WINDOW *wp);
 void		GsSetPortraitMode(int mode);
 void		GsSetPortraitModeFromXY(GR_COORD rootx, GR_COORD rooty);
 void		GsSetClipWindow(GR_WINDOW *wp, MWCLIPREGION *userregion,
-			int flags);
+				int flags/*REM*/, MWRECT* RToClip);
+
+/*REM*/void	GsSetClipWindowPart(GR_WINDOW *wp, MWCLIPREGION *userregion,
+				int flags/*REM*/, MWRECT* RToClip);
+
+/*REM*/void     GsClipPixmap( char* vismap,
+			      GR_COORD	vismap_x,
+			      GR_COORD	vismap_y,
+			      GR_COORD	vismap_width,
+			      GR_COORD	vismap_height,
+			      char*        pixmap, 
+			      GR_COORD	pixmap_x,
+			      GR_COORD	pixmap_y,
+			      GR_COORD	pixmap_width,
+			      GR_COORD	pixmap_height);
+
 void		GsHandleMouseStatus(GR_COORD newx, GR_COORD newy,
 			int newbuttons);
 void		GsFreePositionEvent(GR_CLIENT *client, GR_WINDOW_ID wid,
@@ -478,7 +507,7 @@
 void		GsCheckMouseWindow(void);
 void		GsCheckFocusWindow(void);
 GR_DRAW_TYPE	GsPrepareDrawing(GR_DRAW_ID id, GR_GC_ID gcid,
-			GR_DRAWABLE **retdp);
+				 GR_DRAWABLE **retdp,/*REM*/MWRECT *AreaToDraw);
 GR_BOOL		GsCheckOverlap(GR_WINDOW *topwp, GR_WINDOW *botwp);
 GR_EVENT	*GsAllocEvent(GR_CLIENT *client);
 GR_WINDOW	*GsFindWindow(GR_WINDOW_ID id);
diff -urN microwindows-0.91/src/nanox/srvclip2.c microwindows-0.91.g100/src/nanox/srvclip2.c
--- microwindows-0.91/src/nanox/srvclip2.c	2007-06-17 21:56:40.000000000 +0200
+++ microwindows-0.91.g100/src/nanox/srvclip2.c	2007-06-17 20:41:26.000000000 +0200
@@ -10,6 +10,691 @@
 #include <stdlib.h>
 #include "serv.h"
 
+
+//*REM BEGIN*/
+/*  Quick and dirty stolen from devrgn.c
+ *  
+ *  1 if two RECTs overlap.
+ *  0 if two RECTs do not overlap.
+ */
+#define EXTENTCHECK(r1, r2) \
+	((r1)->right > (r2)->left && \
+	 (r1)->left < (r2)->right && \
+	 (r1)->bottom > (r2)->top && \
+	 (r1)->top < (r2)->bottom)
+
+
+/* This function takes a map of pixels which are visible.  
+ * The map is like a region, so its a rectangle with a
+ * position on the screen. The map 
+ * is a simple array of chars. A 0xff means the pixel is
+ * visible. All other values are invisible and wont be printed
+ * by the screendriver (as far as the SetClipmap function is used before). 
+ *  
+ * The pixmap is the analogon to vismap. Our job here is to substract 
+ * all visible parts of pixmap.
+ *  
+ * @param vismap        pointer to map with visible pixels
+ * @param vismap_x      absolute x-position of vismap
+ * @param vismap_y      absolute y-position of vismap
+ * @param vismap_height height of vismap
+ * @param vismap_width  width  of vismap
+ * @param pixmap        pointer to pixmap we have to substract
+ * @param pixmap_x      absolute left position of pixmap
+ * @param pixmap_y      absolute top  position of pixmap
+ * @param pixmap_width  width  of pixmap
+ * @param pixmap_height height of pixmap
+ *
+ */
+void GsClipPixmap( char* vismap,
+		   GR_COORD	vismap_x,
+		   GR_COORD	vismap_y,
+		   GR_COORD	vismap_width,
+		   GR_COORD	vismap_height,
+		   char*        pixmap, 
+		   GR_COORD	pixmap_x,
+		   GR_COORD	pixmap_y,
+		   GR_COORD	pixmap_width,
+		   GR_COORD	pixmap_height)
+{
+  //firstly we fill a MWRECT structure
+  MWRECT vismaprect={vismap_x,vismap_y,vismap_x+vismap_width,vismap_y+vismap_height};
+  MWRECT pixmaprect ={pixmap_x,pixmap_y,pixmap_x+pixmap_width,pixmap_y+pixmap_height};
+
+  //check if pixmap does overlap our pixmap
+  if(!(EXTENTCHECK(&vismaprect,&pixmaprect)))
+    return;
+
+  //cut away all parts which are not in vismap
+  if(pixmaprect.left<vismaprect.left)
+    pixmaprect.left=vismaprect.left;
+  if(pixmaprect.right>vismaprect.right)
+    pixmaprect.right=vismaprect.right;
+  if(pixmaprect.top<vismaprect.top)
+    pixmaprect.top=vismaprect.top;
+  if(pixmaprect.bottom>vismaprect.bottom)
+    pixmaprect.bottom=vismaprect.bottom;
+
+  //brief description of whats calculated here
+  //
+  //
+  //                                 pixmap
+  //                              |--------------------
+  //pixmaprelxbegin              >|<                  |
+  //                  ------------|--------------     |
+  //pixmaprelxend     |           |<----------->|     |
+  //                  |           |             |     |
+  //vismaprelxbegin   |<--------->|             |     |
+  //                  |           |             |     |
+  //                  |           |--------------------
+  //vismaprelxend     |<----------------------->|
+  //                  |                         |
+  //                  |                         |
+  //                  |                         |
+  //                  |vismap                   |
+  //                  ---------------------------
+  //
+  //
+  //
+  GR_COORD vismaprelxbegin=pixmaprect.left-vismaprect.left;
+  GR_COORD vismaprelybegin=pixmaprect.top-vismaprect.top;
+
+  //GR_COORD vismaprelxend=pixmaprect.right-vismaprect.left;
+  //GR_COORD vismaprelyend=pixmaprect.bottom-vismaprect.top;
+
+  GR_COORD pixmaprelxbegin=pixmaprect.left-/*minx*/pixmap_x;
+  GR_COORD pixmaprelybegin=pixmaprect.top-/*miny*/pixmap_y;
+
+  GR_COORD pixmaprelxend=pixmaprelxbegin+(pixmaprect.right-pixmaprect.left);
+  GR_COORD pixmaprelyend=pixmaprelybegin+(pixmaprect.bottom-pixmaprect.top);
+
+  char        *datasrc=pixmap;
+  char        *datadst=vismap; 
+
+  int xi,yi;
+  for(yi=0;yi<(pixmaprelyend-pixmaprelybegin);yi++)
+    {
+      GR_COORD pixmaprely=pixmaprelybegin+yi;
+      GR_COORD pixmaprelx=pixmaprelxbegin;
+
+      GR_COORD vismaprely=vismaprelybegin+yi;
+      GR_COORD vismaprelx=vismaprelxbegin;
+
+      datasrc=&pixmap[(pixmaprely*pixmap_width)+pixmaprelx];
+      datadst=&vismap[(vismaprely*vismap_width)+vismaprelx];
+      for(xi=0;xi<pixmaprelxend-pixmaprelxbegin;xi++)
+	{
+	  //*datadst=(*datadst)&(*datasrc);
+	  if((*datadst)&&(!(*datasrc)))
+	    *datadst=0xff;
+	  else
+	    *datadst=0x00;
+
+	  datadst++;
+	  datasrc++;
+	}
+    }
+  return;
+}
+//*REM END*/
+
+/*
+ * This function checks if wp is ovelaping the clipregion vis and substracts
+ * the overlaping part if wp has a nontransparent background. If wp is 
+ * transparent, GsClipPixmap is called which substracts all visible pixels of 
+ * wp from vismap. This recursive function calls itself again for all childs of
+ * wp if wp is transparent. Recursion is stopped with the first nontransparent child.
+ * @param wporig        Original window which should be clipped.             
+ * @param wp            Window to examine.           
+ * @param vis           Clip region.
+ * @param x             X position of area to clip. This position is relative to the root window.
+ * @param y             Y position of area to clip. This position is relative to the root window.
+ * @param with          Width of area to clip.
+ * @param height        Height of Area to clip.
+ * @param RToclip       Area where clipping is needed.  
+ * @param r             Temp region.    
+ * @param flags         flags.
+ *
+ */
+
+void GrSetClipWindowRec(GR_WINDOW *wporig,GR_WINDOW *wp,MWCLIPREGION *vis,MWCLIPMAP *vismap,GR_COORD x,GR_COORD y,GR_COORD width,GR_COORD height,MWRECT *RToClip, MWCLIPREGION *r, int flags)
+{
+  GR_SIZE  bs = wp->bordersize;
+  GR_COORD minx = wp->x - bs;
+  GR_COORD miny = wp->y - bs;
+  GR_COORD maxx = wp->x + wp->width + bs;
+  GR_COORD maxy = wp->y + wp->height + bs;
+  GR_WINDOW *sibwp=NULL;
+
+  if (!wp->realized || !wp->output)
+    return;
+  
+  GdSetRectRegion(r, minx, miny, maxx, maxy);
+
+  //if our window is not in the area we want to draw later, all childs will too, so we return
+  if(RToClip &&(!(EXTENTCHECK(RToClip, &r->extents))))
+    return;
+
+  //We have to distingish two situations:
+  //1.) The overlaping window has a non transparent background.
+  //    In this case we dont substract any pixels but we substract 
+  //    the whole region from vis to prevent the draw routines from
+  //    drawing here.
+  //2.) The overlaping window has a transparent background.
+  //    There are parts in vis we have to clip, and parts 
+  //    we must not clip, since ther may be transparent
+  //    pixels. All the transparent parts are described by 
+  //    the windows' alpha channel in wp->alpha. 
+  //    So we simply substract wp->alpha from vismap.
+  //
+  //If no alpha channel is found, we simply skip this.
+  //
+  //
+  if (((wp->background & 0xff000000)==0)||(wp->props & GR_WM_PROPS_APPMASK && wp->children && MWA(wp->children->background)==0))
+    {
+      if(wp->alpha && vismap)
+	{
+	  vismap->dirty=1;
+	  GsClipPixmap(vismap->clipmap,
+		       vismap->clipregion->left/*x*/,
+		       vismap->clipregion->top/*y*/,
+		       vismap->clipregion->right-vismap->clipregion->left/*width*/,
+		       vismap->clipregion->bottom-vismap->clipregion->top/*height*/,
+		       wp->alpha,minx,miny,maxx-minx,maxy-miny
+		       );
+	  if(wp->bgpixmap && wp->bgpixmap->alpha)
+	    {
+	      minx = wp->x;
+	      miny = wp->y;
+	      maxx = wp->x + wp->bgpixmap->width;
+	      maxy = wp->y + wp->bgpixmap->height;
+	      GsClipPixmap(vismap->clipmap,
+			   vismap->clipregion->left/*x*/,
+			   vismap->clipregion->top/*y*/,
+			   vismap->clipregion->right-vismap->clipregion->left/*width*/,
+			   vismap->clipregion->bottom-vismap->clipregion->top/*height*/,
+			   wp->bgpixmap->alpha,minx,miny,maxx-minx,maxy-miny
+			   );
+	    }
+	}
+    }
+  else
+    {
+
+      GdSubtractRegion(vis, vis, r);
+      /* FIXME: shaped windows with borders won't work */
+      if (wp->clipregion) {
+	/* FIXME: can user set invalid clipregion here? */
+	GdOffsetRegion(wp->clipregion,
+		       wp->x, wp->y);
+	GdSubtractRegion(vis, vis, wp->clipregion);
+	GdOffsetRegion(wp->clipregion,
+		       -wp->x, -wp->y);
+      }
+    }
+
+  //Now do the same for all childs. We can omit this if wp does not have a transparent bg
+  if (((wp->background & 0xff000000)==0)||(wp->props & GR_WM_PROPS_APPMASK && wp->children && MWA(wp->children->background)==0))
+    {
+      if(!(flags & GR_MODE_EXCLUDECHILDREN))
+	{
+	  for (sibwp=wp->children; sibwp; sibwp = sibwp->siblings) {
+	    if (!sibwp->realized || !sibwp->output)
+	      continue;
+	    GrSetClipWindowRec(wporig,sibwp,vis,vismap,x,y,width,height,RToClip,r,flags);
+	  }
+	}
+    }
+}
+
+/*
+ * Set the clip rectangles for a window taking into account other
+ * windows that may be obscuring it.  The windows that may be obscuring
+ * this one are the siblings of each direct ancestor which are higher
+ * in priority than those ancestors.  Also, each parent limits the visible
+ * area of the window.  The clipping is not done if it is already up to
+ * date of if the window is not outputtable.
+ *
+ * REM: This functions does not do the substraction any more, but is calling 
+ * GsSetClipWindowRec instead which will also check all childs recursively.
+ */
+
+#if defined(TRANS_COLOR)
+//*REM*/ RToClip indicates the area, wher clipping is important. We dont have to examin
+//*REM*/ the whole Area if we draw there in a small piece (described by RToClip). 
+void
+GsSetClipWindow(GR_WINDOW *wp, MWCLIPREGION *userregion, int flags, /*REM*/MWRECT* RToClip)
+{
+	GR_WINDOW	*orgwp;		/* original window pointer */
+	GR_WINDOW	*pwp;		/* parent window */
+	GR_WINDOW	*sibwp;		/* sibling windows */
+	GR_COORD	diff;		/* difference in coordinates */
+	GR_COORD	x, y, width, height;
+	MWCLIPREGION	*vis, *r;
+	MWCLIPMAP *          vismap=NULL;
+	/*REM*/struct timeval tv1, tv2;
+	/*REM*/struct timezone tz;
+
+	if (!wp->realized || !wp->output)
+		return;
+
+	clipwp = wp;
+
+	/*
+	 * Start with the rectangle for the complete window.
+	 * We will then cut pieces out of it as needed.
+	 */
+	x = wp->x;
+	y = wp->y;
+	width = wp->width;
+	height = wp->height;
+
+	/*
+	 * First walk upwards through all parent windows,
+	 * and restrict the visible part of this window to the part
+	 * that shows through all of those parent windows.
+	 */
+	pwp = wp;
+	while (pwp != rootwp) {
+		pwp = pwp->parent;
+
+		diff = pwp->x - x;
+		if (diff > 0) {
+			width -= diff;
+			x = pwp->x;
+		}
+
+		diff = (pwp->x + pwp->width) - (x + width);
+		if (diff < 0)
+			width += diff;
+
+		diff = pwp->y - y;
+		if (diff > 0) {
+			height -= diff;
+			y = pwp->y;
+		}
+
+		diff = (pwp->y + pwp->height) - (y + height);
+		if (diff < 0)
+			height += diff;
+	}
+
+	/*
+	 * If the window is completely clipped out of view, then
+	 * set the clipping region to indicate that.
+	 */
+	if (width <= 0 || height <= 0) {
+		GdSetClipRegion(clipwp->psd, NULL);
+		return;
+	}
+
+	/*
+	 * Allocate region to clipped size of window,
+	 * intersect with user window clip region.
+	 */
+	vis = GdAllocRectRegion(x, y, x+width, y+height);
+
+	if(!(flags & GR_MODE_EXCLUDECHILDREN))
+	  {
+	    if(RToClip)
+	      {
+		vismap=GdAllocClipMap(RToClip->left,
+				      RToClip->top,
+				      RToClip->right,
+				      RToClip->bottom,
+				      0xff);
+	      }
+	    else
+	      {
+		vismap=GdAllocClipMap(x,y,x+width, y+height,0xff); 
+	      }
+	  }
+
+	if (wp->clipregion) {
+		GdOffsetRegion(wp->clipregion, wp->x, wp->y);
+		GdIntersectRegion(vis, vis, wp->clipregion);
+		GdOffsetRegion(wp->clipregion, -wp->x, -wp->y);
+	}
+
+	/*
+	 * 
+	 * We are in the clipping function here. So 
+	 * someone wants to print some pixels and  
+	 * he only wants it in the region 
+	 * described by RToClip. So we can finish our work here 
+	 * if RToClip does not overlap vis. Although the clipmap 
+	 * is not correct, this does not matter since anyone 
+	 * will draw outside RToClip in near future.
+	 */
+	if(RToClip && (!(EXTENTCHECK(&vis->extents, RToClip))))
+	  goto end;
+
+
+	/* 
+	 * Allocate temp region
+	 */
+	r = GdAllocRegion();
+
+
+	/*
+	 * Now examine all windows that obscure this window, and
+	 * for each obscuration, break up the clip rectangles into
+	 * the smaller pieces that are still visible.  The windows
+	 * that can obscure us are the earlier siblings of all of
+	 * our parents.
+ 	 */
+	orgwp = wp;
+	pwp = wp;
+	while (pwp != NULL) {
+		wp = pwp;
+		pwp = wp->parent;
+
+		if(!pwp) {
+			/* We're clipping the root window*/
+			if (!(flags & GR_MODE_EXCLUDECHILDREN))
+				/* start with root's children*/
+				sibwp = rootwp->children;
+			else sibwp = NULL;	 /* no search*/
+			wp = NULL;		 /* search all root's children*/
+		} else {
+			sibwp = pwp->children;	 /* clip siblings*/
+		}
+
+		for (; sibwp != wp; sibwp = sibwp->siblings) {
+			if (!sibwp->realized || !sibwp->output)
+				continue;
+			GrSetClipWindowRec(orgwp,sibwp,vis,vismap,x,y,width,height,RToClip,r,flags);
+		}
+		/* if not clipping the root window, stop when you reach it*/
+		if (pwp == rootwp)
+			break;
+	}
+
+	wp = orgwp;
+	/*
+	 * If not the root window, clip all children.
+	 * (Root window's children are are clipped above)
+	 */
+	if(wp != rootwp && !(flags & GR_MODE_EXCLUDECHILDREN)) {
+		for (sibwp=wp->children; sibwp; sibwp = sibwp->siblings) {
+			if (!sibwp->realized || !sibwp->output)
+			  continue;
+			GrSetClipWindowRec(orgwp,sibwp,vis,vismap,x,y,width,height,RToClip,r,flags);
+		}
+	}
+
+	/*
+	 * Intersect with user region, if set.
+	 */
+	if (userregion) {
+		/* temporarily offset region by window coordinates*/
+		GdOffsetRegion(userregion, wp->x, wp->y);
+		GdIntersectRegion(vis, vis, userregion);
+		GdOffsetRegion(userregion, -wp->x, -wp->y);
+	}
+
+
+	/*
+	 * Set the clip region (later destroy handled by GdSetClipRegion)
+	 */
+	GdSetClipRegion(clipwp->psd, vis);
+
+	/*
+	 * Destroy temp region
+	 */
+	GdDestroyRegion(r);
+
+ end:
+	/*
+	 * Set the clip region (later destroy handled by GdSetClipRegion)
+	 */
+	GdSetClipMap(vismap);
+}
+
+/*
+ * This function is similar to GsSetClipWindow. It does not allocate a complete
+ * new region each time region but uses the current clipregion. Calling
+ * this function with NULL for wp, will cause an allocation of a new   
+ * clip region whith the same size than rootwp. This region is set as new clip region.
+ * All future calls with wp!-NULL will cause a modification of this region.
+ */
+void
+GsSetClipWindowPart(GR_WINDOW *wp, MWCLIPREGION *userregion, int flags, /*REM*/MWRECT* RToClip)
+{
+	GR_WINDOW	*orgwp;		/* original window pointer */
+	GR_WINDOW	*pwp;		/* parent window */
+	GR_WINDOW	*sibwp;		/* sibling windows */
+	GR_COORD	diff;		/* difference in coordinates */
+	GR_COORD	x, y, width, height;
+
+	static MWCLIPREGION *r=NULL;
+	MWCLIPREGION *vis=NULL;
+	MWCLIPMAP    *vismap=NULL;
+
+	if(!wp)
+	  {
+	    /*
+	     * Allocate region to clipped size of window,
+	     */
+	    vis = GdAllocRectRegion(0, 0, rootwp->width, rootwp->height);
+
+	    /*
+	     * Allocate vismap
+	     */
+	    vismap=GdAllocClipMap(0,0,rootwp->width, rootwp->height,0xff); 
+
+	    /* 
+	     * Allocate temp region
+	     */
+	    if(r) GdDestroyRegion(r);
+	    r = GdAllocRegion();
+
+	    /*
+	     * Set the clip region (later destroy handled by GdSetClipRegion)
+	     * GdSetClipRegion does not destroy the region if the clipregion set is the same we handle over
+	     */
+	    GdSetClipRegion(rootwp->psd, vis);
+
+	    /*
+	     * Set the clip region (later destroy handled by GdSetClipMap)
+	     * GdSetClipMap does not destroy the region if the clipmap set is the same we handle over
+	     */
+	    GdSetClipMap(vismap);
+	    
+
+	    return;
+	  }
+	else
+	  {
+	    if (!wp->realized || !wp->output)
+		return;
+
+
+	    /*
+	     * Get current region since we want to add something here
+	     */
+	    vis = GdGetClipRegion();
+
+	    /*
+	     * Get current vismap since we want to add something here
+	     */
+	    vismap=GdGetClipMap(); 
+
+	    /* someone did forget to do an initial call? */
+	    if(!vis || ! vismap)
+	      return;
+
+	    clipwp = wp;
+
+	    /*
+	     * Start with the rectangle for the complete window.
+	     * We will then cut pieces out of it as needed.
+	     */
+	    /*
+	      x = wp->x;
+	      y = wp->y;
+	      width = wp->width;
+	      height = wp->height;
+	    */
+
+	    x = RToClip->left;
+	    y = RToClip->top;
+	    width = RToClip->right-RToClip->left;
+	    height = RToClip->bottom-RToClip->top;
+
+
+	    /*
+	     * First walk upwards through all parent windows,
+	     * and restrict the visible part of this window to the part
+	     * that shows through all of those parent windows.
+	     */
+	    pwp = wp;
+	    while (pwp != rootwp) {
+	      pwp = pwp->parent;
+	      
+	      diff = pwp->x - x;
+	      if (diff > 0) {
+		width -= diff;
+		x = pwp->x;
+	      }
+	      
+	      diff = (pwp->x + pwp->width) - (x + width);
+	      if (diff < 0)
+		width += diff;
+	      
+	      diff = pwp->y - y;
+	      if (diff > 0) {
+		height -= diff;
+		y = pwp->y;
+	      }
+	      
+	      diff = (pwp->y + pwp->height) - (y + height);
+	      if (diff < 0)
+		height += diff;
+	    }
+
+	    /*
+	     * If the window is completely clipped out of view, then
+	     * set the clipping region to indicate that.
+	     */
+	    if (width <= 0 || height <= 0) {
+	      GdSetRectRegion(r, RToClip->left, RToClip->top, RToClip->right, RToClip->bottom);
+	      GdSubtractRegion(vis, vis, r);
+	      goto end;
+	    }
+
+	    /*
+	     * If the window is partially  clipped out of view, then
+	     * subtract the visible part from clip region.
+	     */
+	    if ((x != RToClip->left) ||	(y != RToClip->top)  ||	
+		(width  != (RToClip->right-RToClip->left)) ||
+		(height != (RToClip->bottom-RToClip->top))){
+
+	      MWCLIPREGION *rhelp = GdAllocRegion();
+	      GdSetRectRegion(rhelp, x, y, x+width, y+height);
+	      GdSetRectRegion(r, RToClip->left, RToClip->top, RToClip->right, RToClip->bottom);
+
+	      //r holds now the clipped out part
+	      GdSubtractRegion(r, r, rhelp);
+
+	      //substract it from vis
+	      GdSubtractRegion(vis, vis, r);
+
+	      GdDestroyRegion(rhelp);
+	    }
+
+	    if (wp->clipregion) {
+	      GdOffsetRegion(wp->clipregion, wp->x, wp->y);
+	      GdIntersectRegion(vis, vis, wp->clipregion);
+	      GdOffsetRegion(wp->clipregion, -wp->x, -wp->y);
+	    }
+
+	    /*
+	     * 
+	     * We are in the clipping function here. So 
+	     * someone wants to print some pixels and  
+	     * he only wants it in the region 
+	     * described by RToClip. So we can finish our work here 
+	     * if RToClip does not overlap vis. Although the clipmap 
+	     * is not correct, this does not matter since anyone 
+	     * will draw outside RToClip in near future.
+	     */
+	    if(RToClip && (!(EXTENTCHECK(&vis->extents, RToClip))))
+	      return;
+	    
+	    /*
+	     * Now examine all windows that obscure this window, and
+	     * for each obscuration, break up the clip rectangles into
+	     * the smaller pieces that are still visible.  The windows
+	     * that can obscure us are the earlier siblings of all of
+	     * our parents.
+	     */
+
+	    if(flags&GR_MODE_THISWP)
+	      {
+		GrSetClipWindowRec(wp,wp,vis,vismap,/*x*/0,/*y*/0,rootwp->width,rootwp->height,RToClip,r,flags);
+		goto end;
+	      }
+
+	    orgwp = wp;
+	    if(!(flags&GR_MODE_DIRECTCHILD))
+	      {
+		pwp = wp;
+		while (pwp!=rootwp) {
+		  wp = pwp;
+		  pwp = wp->parent;
+		  
+		  sibwp = pwp->children;	 /* clip siblings*/
+		  
+		  for (; sibwp != wp; sibwp = sibwp->siblings) {
+		    if (!sibwp->realized || !sibwp->output)
+		      continue;
+
+		    /* if GR_MODE_DIRECTSIBLING we clip the wp directly to the right only */
+		    if(((flags&GR_MODE_DIRECTSIBLING)&&(sibwp->siblings==orgwp)) || (!(flags&GR_MODE_DIRECTSIBLING)))
+		      GrSetClipWindowRec(orgwp,sibwp,vis,vismap,/*x*/0,/*y*/0,rootwp->width,rootwp->height,RToClip,r,flags);
+		  }
+		  
+		  /* if GR_MODE_DIRECTSIBLING is set we dont need to go up */
+		  if (flags&GR_MODE_DIRECTSIBLING)
+		    break;
+		}
+	      }
+
+	    wp = orgwp;
+	    /*
+	     * If not the root window, clip all children.
+	     * (Root window's children are are clipped above)
+	     */
+	    if((!(flags & GR_MODE_EXCLUDECHILDREN))|| (flags & GR_MODE_DIRECTCHILD)) {
+	      for (sibwp=wp->children; sibwp; sibwp = sibwp->siblings) {
+		if (!sibwp->realized || !sibwp->output)
+		  continue;
+		if(!(flags & GR_MODE_DIRECTCHILD) || ((flags & GR_MODE_DIRECTCHILD)&& !sibwp->siblings))
+		  GrSetClipWindowRec(orgwp,sibwp,vis,vismap,/*x*/0,/*y*/0,rootwp->width,rootwp->height,RToClip,r,flags);
+	      }
+	    }
+
+	  end:
+	    
+	    /*
+	     * Intersect with user region, if set.
+	     */
+	    if (userregion) {
+	      /* temporarily offset region by window coordinates*/
+	      GdOffsetRegion(userregion, wp->x, wp->y);
+	      GdIntersectRegion(vis, vis, userregion);
+	      GdOffsetRegion(userregion, -wp->x, -wp->y);
+	    }
+	  }
+	/* vismap is already set with the initial call */
+	/* clipreagion must be set again */
+	GdSetClipRegion(clipwp->psd, vis);
+}
+
+#else
+
 /*
  * Set the clip rectangles for a window taking into account other
  * windows that may be obscuring it.  The windows that may be obscuring
@@ -19,7 +704,7 @@
  * date of if the window is not outputtable.
  */
 void
-GsSetClipWindow(GR_WINDOW *wp, MWCLIPREGION *userregion, int flags)
+GsSetClipWindow(GR_WINDOW *wp, MWCLIPREGION *userregion, int flags, /*REM*/MWRECT* RToClip)
 {
 	GR_WINDOW	*orgwp;		/* original window pointer */
 	GR_WINDOW	*pwp;		/* parent window */
@@ -204,3 +889,7 @@
 	 */
 	GdDestroyRegion(r);
 }
+
+#endif
+
+
diff -urN microwindows-0.91/src/nanox/srvfunc.c microwindows-0.91.g100/src/nanox/srvfunc.c
--- microwindows-0.91/src/nanox/srvfunc.c	2007-06-17 21:56:40.000000000 +0200
+++ microwindows-0.91.g100/src/nanox/srvfunc.c	2007-06-09 21:37:03.000000000 +0200
@@ -283,6 +283,9 @@
 			if (psd->flags & PSF_ADDRMALLOC)
 				free(psd->addr);
 
+/*REM*/			if(pp->alpha)
+/*REM*/			  free(pp->alpha);
+
 			/* deallocate mem gc*/
 			psd->FreeMemGC(psd);
 
@@ -504,7 +507,7 @@
 #if 1
 	/* perform screen blit if topmost and mapped - no flicker!*/
 	if (wp->mapped && wp == wp->parent->children
-		&& wp->parent->id == GR_ROOT_WINDOW_ID
+	    && wp->parent->id == GR_ROOT_WINDOW_ID
 
 		/* temp don't blit in portrait mode, still buggy*/
 		/* *&& !(wp->psd->portrait & (MWPORTRAIT_LEFT|MWPORTRAIT_RIGHT))***/
@@ -590,11 +593,12 @@
 		return;
 	}
 #endif
+
 	/*
 	 * This method will redraw the window entirely,
 	 * resulting in considerable flicker.
 	 */
-	GsWpUnrealizeWindow(wp, GR_TRUE);
+	GsWpUnrealizeWindow(wp, GR_TRUE, /*REM Do clear*/GR_FALSE);
 	OffsetWindow(wp, offx, offy);
 	GsWpRealizeWindow(wp, GR_FALSE);
 	DeliverUpdateMoveEventAndChildren(wp);
@@ -637,6 +641,21 @@
 	if (!wp->realized || !wp->output) {
 		wp->width = width;
 		wp->height = height;
+/*REM BEGIN:*/
+#if defined(TRANS_COLOR)
+		/* Change space for alpha values */
+		if(wp->alpha) {
+		  free(wp->alpha);
+		  wp->alpha = calloc(width*height, 1);
+		  
+		  if (wp->alpha)
+		    memset(wp->alpha,(unsigned char) MWA(wp->background),width*height);
+		  else
+		    GsError(GR_ERROR_MALLOC_FAILED, wp->id);
+		}
+#endif
+/*REM END*/
+
 		SERVER_UNLOCK();
 		return;
 	}
@@ -645,9 +664,25 @@
 	 * This should be optimized to not require redrawing of the window
 	 * when possible.
 	 */
-	GsWpUnrealizeWindow(wp, GR_TRUE);
+	GsWpUnrealizeWindow(wp, GR_TRUE, /*REM DoClear*/GR_FALSE);
 	wp->width = width;
 	wp->height = height;
+
+/*REM BEGIN:*/
+#if defined(TRANS_COLOR)
+	  /* Change space for alpha values */
+	  if(wp->alpha) {
+	    free(wp->alpha);
+	    wp->alpha = calloc(width*height, 1);
+
+	    if (wp->alpha)
+	      memset(wp->alpha,(unsigned char) MWA(wp->background),width*height);
+	    else
+	      GsError(GR_ERROR_MALLOC_FAILED, wp->id);
+	  }
+#endif
+/*REM END*/
+
 	/* send size update before expose event*/
 	GsDeliverUpdateEvent(wp, GR_UPDATE_SIZE, wp->x, wp->y, width, height);
 	GsWpRealizeWindow(wp, GR_FALSE);
@@ -680,7 +715,6 @@
 		return;
 	}
 
-/*printf("grreparent: pid %d wid %d (oldpid %d) realized %d,%d\n", pwid, wid, wp->parent->id, pwp->realized, wp->realized);*/
 	x += pwp->x;
 	y += pwp->y;
 	offx = x - wp->x;
@@ -690,7 +724,7 @@
 	 * Unrealize window and all children.  No effect if
 	 * this window isn't already realized.
 	 */
-	GsWpUnrealizeWindow(wp, GR_TRUE);
+	GsWpUnrealizeWindow(wp, GR_TRUE,/*REM Do Clear*/GR_FALSE);
 
 	/* link window into new parent chain*/
 	for(mysibptr = &(wp->parent->children); *mysibptr != wp; 
@@ -1702,7 +1736,17 @@
 
 	pwp->children = wp;
 	listwp = wp;
-
+/*REM BEGIN:*/
+#if defined(TRANS_COLOR)
+	wp->alpha = calloc(width*height, 1);
+	if (wp->alpha)
+	  memset(wp->alpha,(unsigned char) MWA(background),width*height);
+	else
+	  GsError(GR_ERROR_MALLOC_FAILED, wp->id);
+#else
+	wp->alpha = NULL;
+#endif
+/*REM END*/
 	return wp;
 }
 
@@ -1848,12 +1892,105 @@
         listpp = pp;
 	
 	id = pp->id;
-	
+
+/*REM BEGIN:*/
+#if defined(TRANS_COLOR)
+	pp->alpha = calloc(width*height, 1);
+	if (!pp->alpha)
+	  GsError(GR_ERROR_MALLOC_FAILED, pp->id);
+	//else
+	//  memset(pp->alpha,0xff,width*height);
+#else
+	pp->alpha = NULL;
+#endif
+/*REM END*/
+
 	SERVER_UNLOCK();
 	
 	return id;
 }
 
+/*REM BEGIN:*/
+/*
+ * Allocate a pixmap, can be used with any drawing functions
+ * for offscreen drawing
+ */
+GR_WINDOW_ID
+GrResizePixmap(GR_WINDOW_ID wid,GR_SIZE width, GR_SIZE height, void * pixels)
+{
+	GR_PIXMAP	*pp;
+	PSD		psd;
+        int 		size, linelen, bpp, planes;
+	GR_WINDOW_ID    id;
+  
+	if (width <= 0 || height <= 0) {
+		/* no error for now, server will desynchronize w/app*/
+		/*GsError(GR_ERROR_BAD_WINDOW_SIZE, 0);*/
+		return 0;
+	}
+
+	SERVER_LOCK();
+
+
+	pp = GsFindPixmap(wid);
+	if (pp) {
+	  psd = pp->psd;
+
+
+	  /* Allocate space for pixel values */
+	  GdCalcMemGCAlloc(psd, width, height, 0, 0, &size, &linelen);
+	  if (!pixels) {
+	    pixels = calloc(size, 1);
+	  }
+
+	  /* do nothing if we got no space*/
+	  if (!pixels) {
+	    GsError(GR_ERROR_MALLOC_FAILED, 0);
+	    SERVER_UNLOCK();
+	    return 0;
+	  }
+  
+	  /* deallocate pixmap memory*/
+	  if ((psd->flags & PSF_ADDRMALLOC)&&(psd->addr))
+	    free(psd->addr);
+
+	  bpp = psd->bpp;
+
+
+#if defined(TRANS_COLOR)
+	  /* Change space for alpha values */
+	  if(pp->alpha) {
+	    free(pp->alpha);
+	    pp->alpha = calloc(width*height, 1);
+
+	    if (pp->alpha)
+	      memset(pp->alpha,0xff,width*height);
+	    else
+	      GsError(GR_ERROR_MALLOC_FAILED, pp->id);
+	  }
+#endif
+
+	  /* change values*/
+	  pp->width = width;
+	  pp->height = height;
+
+	  planes = psd->planes;
+	  psd->MapMemGC(psd, width, height, planes, bpp, linelen, size,
+			pixels/*,alpha for future use*/);
+
+          psd->flags |= PSF_ADDRMALLOC;
+	  id = pp->id;
+	
+	  SERVER_UNLOCK();
+	  
+	  return id;
+	}
+	else
+	  return 0;
+}
+/*REM END*/
+
+
 /*
  * Map the window to make it (and possibly its children) visible on the screen.
  */
@@ -1893,7 +2030,7 @@
 		return;
 	}
 
-	GsWpUnrealizeWindow(wp, GR_FALSE);
+	GsWpUnrealizeWindow(wp, GR_FALSE, /*REM Do Clear*/GR_FALSE);
 
 	wp->mapped = GR_FALSE;
 
@@ -1918,7 +2055,16 @@
 			width = wp->width;
 		if (height == 0)
 			height = wp->height;
+/*REM*/#if defined(TRANS_COLOR)
+/*REM*/	        GR_SIZE bs = wp->bordersize;
+/*REM*/		if(MWA(wp->background)==0)
+//*REM*/		  GsExposeArea(rootwp, wp->x - bs, wp->y - bs, wp->width + bs * 2, wp->height + bs * 2, NULL);
+		/*REM*/		  GsWpClearWindowUpAndDown(wp, x, y, width, height, exposeflag);
+/*REM*/		else
+/*REM*/		  GsWpClearWindow(wp, x, y, width, height, exposeflag);
+/*REM*/#else
 		GsWpClearWindow(wp, x, y, width, height, exposeflag);
+/*REM*/#endif
 	}
 
 	SERVER_UNLOCK();
@@ -2533,12 +2679,17 @@
 	GR_DRAWABLE	*dp;
 
 	SERVER_LOCK();
+	//*REM*/MWRECT RelAreaToDraw={x1>x2?x2:x1,/*left*/
+        //			     y1>y2?y2:y1,/*top*/
+        //				     x2>x1?x2+1:x1+1,/*right*/
+        //				     y2>y1?y2+1:y1+1 /*bottom*/
+        //	};
 
-	switch (GsPrepareDrawing(id, gc, &dp)) {
+	switch (GsPrepareDrawing(id, gc, &dp/*REM*/,/*&RelAreaToDraw*/NULL)) {
 		case GR_DRAW_TYPE_WINDOW:
 	        case GR_DRAW_TYPE_PIXMAP:
 			GdLine(dp->psd, dp->x + x1, dp->y + y1,
-				dp->x + x2, dp->y + y2, TRUE);
+			       dp->x + x2, dp->y + y2, TRUE);
 			break;
 	}
 
@@ -2559,7 +2710,9 @@
 
 	SERVER_LOCK();
 
-	switch (GsPrepareDrawing(id, gc, &dp)) {
+	//*REM*/MWRECT RelAreaToDraw={x,y,x+width,y+height};
+
+	switch (GsPrepareDrawing(id, gc, &dp,/*REM*//*&RelAreaToDraw*/NULL)) {
 		case GR_DRAW_TYPE_WINDOW:
       	        case GR_DRAW_TYPE_PIXMAP:
 			GdRect(dp->psd, dp->x + x, dp->y + y, width, height);
@@ -2581,7 +2734,9 @@
 
 	SERVER_LOCK();
 
-	switch (GsPrepareDrawing(id, gc, &dp)) {
+	//*REM*/MWRECT RelAreaToDraw={x,y,x+width,y+height};
+
+	switch (GsPrepareDrawing(id, gc, &dp, /*REM*//*&RelAreaToDraw*/NULL)) {
 		case GR_DRAW_TYPE_WINDOW:
 	        case GR_DRAW_TYPE_PIXMAP:
 			GdFillRect(dp->psd, dp->x + x, dp->y + y, width,height);
@@ -2603,7 +2758,9 @@
 
 	SERVER_LOCK();
 
-	switch (GsPrepareDrawing(id, gc, &dp)) {
+	//*REM*/MWRECT RelAreaToDraw={x,y,x+width,y+height};
+
+	switch (GsPrepareDrawing(id, gc, &dp,/*REM*//*&RelAreaToDraw*/NULL)) {
 		case GR_DRAW_TYPE_WINDOW:
 	        case GR_DRAW_TYPE_PIXMAP:
 			GdEllipse(dp->psd, dp->x + x, dp->y + y, rx, ry, FALSE);
@@ -2625,7 +2782,9 @@
 
 	SERVER_LOCK();
 
-	switch (GsPrepareDrawing(id, gc, &dp)) {
+	//*REM*/MWRECT RelAreaToDraw={x,y,x+width,y+height};
+
+	switch (GsPrepareDrawing(id, gc, &dp,/*REM*//*&RelAreaToDraw*/NULL)) {
 		case GR_DRAW_TYPE_WINDOW:
 	        case GR_DRAW_TYPE_PIXMAP:
 			GdEllipse(dp->psd, dp->x + x, dp->y + y, rx, ry, TRUE);
@@ -2648,7 +2807,7 @@
 
 	SERVER_LOCK();
 
-	switch (GsPrepareDrawing(id, gc, &dp)) {
+	switch (GsPrepareDrawing(id, gc, &dp,/*REM*/NULL)) {
 		case GR_DRAW_TYPE_WINDOW:
 	        case GR_DRAW_TYPE_PIXMAP:
 			GdArc(dp->psd, dp->x + x, dp->y + y, rx, ry, ax, ay,
@@ -2672,7 +2831,7 @@
 
 	SERVER_LOCK();
 
-	switch (GsPrepareDrawing(id, gc, &dp)) {
+	switch (GsPrepareDrawing(id, gc, &dp,/*REM*/NULL)) {
 		case GR_DRAW_TYPE_WINDOW:
 	        case GR_DRAW_TYPE_PIXMAP:
 			GdArcAngle(dp->psd, dp->x + x, dp->y + y, rx, ry,
@@ -2700,8 +2859,10 @@
 
 	SERVER_LOCK();
 
-	switch (GsPrepareDrawing(id, gc, &dp)) {
-		case GR_DRAW_TYPE_WINDOW:
+	//*REM*/MWRECT RelAreaToDraw={x,y,x+width,y+height};
+
+	switch (GsPrepareDrawing(id, gc, &dp,/*REM*//*&RelAreaToDraw*/NULL)) {
+	        case GR_DRAW_TYPE_WINDOW:
 	        case GR_DRAW_TYPE_PIXMAP:
 			GdBitmap(dp->psd, dp->x + x, dp->y + y, width, height,
 				imagebits);
@@ -2720,7 +2881,7 @@
 
 	SERVER_LOCK();
 
-	switch (GsPrepareDrawing(id, gc, &dp)) {
+	switch (GsPrepareDrawing(id, gc, &dp,/*REM*/NULL)) {
 		case GR_DRAW_TYPE_WINDOW:
 	        case GR_DRAW_TYPE_PIXMAP:
 			GdDrawImage(dp->psd, dp->x + x, dp->y + y, pimage);
@@ -2740,7 +2901,9 @@
 
 	SERVER_LOCK();
 
-	switch (GsPrepareDrawing(id, gc, &dp)) {
+	//*REM*/MWRECT RelAreaToDraw={x,y,x+width,y+height};
+
+	switch (GsPrepareDrawing(id, gc, &dp,/*REM*//*&RelAreaToDraw*/NULL)) {
 		case GR_DRAW_TYPE_WINDOW:
  	        case GR_DRAW_TYPE_PIXMAP:
 			GdDrawImageFromFile(dp->psd, dp->x + x, dp->y + y,
@@ -2794,7 +2957,9 @@
 
 	SERVER_LOCK();
 
-	switch (GsPrepareDrawing(id, gc, &dp)) {
+	//*REM*/MWRECT RelAreaToDraw={x,y,x+width,y+height};
+
+	switch (GsPrepareDrawing(id, gc, &dp,/*REM*//*&RelAreaToDraw*/NULL)) {
 	case GR_DRAW_TYPE_WINDOW:
 	case GR_DRAW_TYPE_PIXMAP:
 		GdDrawImageFromBuffer(dp->psd, dp->x + x, dp->y + y,
@@ -2847,7 +3012,9 @@
 
 	SERVER_LOCK();
 
-	switch (GsPrepareDrawing(id, gc, &dp)) {
+	//*REM*/MWRECT RelAreaToDraw={x,y,x+width,y+height};
+
+	switch (GsPrepareDrawing(id, gc, &dp,/*REM*//*&RelAreaToDraw*/NULL)) {
 		case GR_DRAW_TYPE_WINDOW:
  	        case GR_DRAW_TYPE_PIXMAP:
 			GdDrawImageToFit(dp->psd, dp->x + x, dp->y + y,
@@ -2915,7 +3082,9 @@
 
 	SERVER_LOCK();
 
-	switch (GsPrepareDrawing(id, gc, &dp)) {
+	//*REM*/MWRECT RelAreaToDraw={x,y,x+width,y+height};
+
+	switch (GsPrepareDrawing(id, gc, &dp,/*REM*//*&RelAreaToDraw*/NULL)) {
 		case GR_DRAW_TYPE_WINDOW:
 	        case GR_DRAW_TYPE_PIXMAP:
 			GdArea(dp->psd, dp->x + x, dp->y + y, width, height,
@@ -2939,16 +3108,22 @@
 
 	GR_DRAWABLE	*dp;
         GR_WINDOW	*swp;
+#if defined(TRANS_COLOR)
+/*REM*/ GR_WINDOW	*dwp=NULL;
+/*REM*/ GR_PIXMAP	*dpp=NULL;
+#endif
         GR_PIXMAP	*spp = NULL;
         GR_DRAW_TYPE	type;
         PSD 		srcpsd;
 
 	SERVER_LOCK();
+	//*REM*/This may not work since GsPrepareDraw wont
+	//*REM*/call GdSetClipwindow again if clipwp didnt change
+	//*REM*/MWRECT RelAreaToDraw={x,y,x+width,y+height};
    
         srcpsd = NULL;
-
         swp = GsFindWindow(srcid);
-        type = GsPrepareDrawing(id, gc, &dp);
+        type = GsPrepareDrawing(id, gc, &dp,/*REM*//*&RelAreaToDraw*/NULL);
 	if (type == GR_DRAW_TYPE_NONE) {
 		SERVER_UNLOCK();
 		return;
@@ -3022,9 +3197,62 @@
 		}
 	}
 
+#if defined(TRANS_COLOR)
+/*REM*/	if(swp && (op == MWROP_SRCTRANSCOPY))  GdSetAlphaChannel(swp->alpha,swp->x,swp->y,swp->width,swp->height);
+/*REM*/	if(spp && (op == MWROP_SRCTRANSCOPY))  GdSetAlphaChannel(spp->alpha,spp->x,spp->y,spp->width,spp->height);
+#endif
+
 	/* perform blit*/
 	GdCheckCursor(srcpsd, srcx, srcy, srcx+width, srcy+height); /* FIXME*/
 	GdBlit(dp->psd, dp->x+x, dp->y+y, width, height, srcpsd, srcx, srcy,op);
+#if defined(TRANS_COLOR)
+/*REM BEGIN:*/
+	//FIXME: GsFindWindow is called twice (already in PrepareDraw)
+	//FIXME: Only blit if dwp has a transparent bg
+        dwp = GsFindWindow(id);
+	if(!dwp) dpp=GsFindPixmap(id);
+	GR_SIZE dheight;
+	GR_SIZE dwidth;
+	unsigned char * salpha=NULL;
+	unsigned char * dalpha=NULL;
+	//dst is a window
+	if(dwp)
+	  {
+	    dalpha=dwp->alpha;
+	    dwidth=dwp->width;
+	    dheight=dwp->height;
+	    //src is a window
+	    if(swp)
+	      salpha=swp->alpha;
+
+	    //src is a pixmap
+	    else if (spp)
+	      salpha=spp->alpha;
+	  }
+	//dst is a pixmap
+	else if(dpp)
+	  {
+	    dalpha=dpp->alpha;
+	    dwidth=dpp->width;
+	    dheight=dpp->height;
+	    //src is a window
+	    if(swp)
+	      salpha=swp->alpha;
+
+	    //src is a pixmap
+	    else if (spp)
+	      salpha=spp->alpha;
+	  }
+	if(dalpha && salpha)
+	  {
+	    GdAlphaBlit(dalpha, x, y, dwidth, dheight, /*copy to x,y and handle over height/width*/
+			salpha, x, y, width, height); /*copy from x,y and copy rectangle height/width*/
+	  }
+
+/*REM END:*/
+#endif
+
+
 	GdFixCursor(srcpsd); /* FIXME*/
 
 	SERVER_UNLOCK();
@@ -3092,7 +3320,9 @@
 
 	SERVER_LOCK();
 
-	switch (GsPrepareDrawing(id, gc, &dp)) {
+	/*REM*/MWRECT RelAreaToDraw={x,y,x+1,y+1};
+
+	switch (GsPrepareDrawing(id, gc, &dp,/*REM*//*&RelAreaToDraw*/NULL)) {
 		case GR_DRAW_TYPE_WINDOW:
 	        case GR_DRAW_TYPE_PIXMAP:
 			GdPoint(dp->psd, dp->x + x, dp->y + y);
@@ -3116,7 +3346,7 @@
 
 	SERVER_LOCK();
    
-	switch (GsPrepareDrawing(id, gc, &dp)) {
+	switch (GsPrepareDrawing(id, gc, &dp,/*REM*/NULL)) {
 		case GR_DRAW_TYPE_WINDOW:
 	        case GR_DRAW_TYPE_PIXMAP:
 	                psd = dp->psd;
@@ -3149,7 +3379,7 @@
 
 	SERVER_LOCK();
    
-	switch (GsPrepareDrawing(id, gc, &dp)) {
+	switch (GsPrepareDrawing(id, gc, &dp,/*REM*/NULL)) {
 		case GR_DRAW_TYPE_WINDOW:
 	        case GR_DRAW_TYPE_PIXMAP:
 	                psd = dp->psd;
@@ -3202,7 +3432,7 @@
 
 	SERVER_LOCK();
    
-	switch (GsPrepareDrawing(id, gc, &dp)) {
+	switch (GsPrepareDrawing(id, gc, &dp,/*REM*/NULL)) {
 		case GR_DRAW_TYPE_WINDOW:
 	        case GR_DRAW_TYPE_PIXMAP:
 	                psd = dp->psd;
@@ -3256,7 +3486,7 @@
 	if((flags&(MWTF_TOP|MWTF_BASELINE|MWTF_BOTTOM)) == 0)
 		flags |= MWTF_BASELINE;
 
-	switch (GsPrepareDrawing(id, gc, &dp)) {
+	switch (GsPrepareDrawing(id, gc, &dp,/*REM*/NULL)) {
 		case GR_DRAW_TYPE_WINDOW:
 	        case GR_DRAW_TYPE_PIXMAP:
 			GdText(dp->psd, dp->x + x, dp->y + y, str, count,flags);
@@ -3361,7 +3591,24 @@
 
 	/* Set window properties*/
 	if (props->flags & GR_WM_FLAGS_PROPS)
-		wp->props = props->props;
+/*REM BEGIN*/
+#if defined(TRANS_COLOR)
+	  {
+	    wp->props = props->props;
+	    /*
+	     * If GR_WM_PROPS_APPWINDOW and GR_WM_PROPS_NOBACKGROUND is set, we assume a container window.
+	     * Further we assume (accordint to nanowms code) that the border will be redrawn soon.
+	     * So we clear the alpha map in order to provide GrSetClipWindowRec a valid alpha map for
+	     * container with transparent childs.
+	     */
+
+	    if(wp->alpha && (wp->props & (GR_WM_PROPS_APPWINDOW|GR_WM_PROPS_NOBACKGROUND)))
+	      memset(wp->alpha,0,(wp->width)*(wp->height));
+	  }
+#else
+	wp->props = props->props;
+#endif
+/*REM END*/
 
 	/* Set window title*/
 	if (props->flags & GR_WM_FLAGS_TITLE) {
@@ -3401,7 +3648,7 @@
 	if (props->flags & GR_WM_FLAGS_BORDERSIZE) {
 		if (wp->bordersize != props->bordersize) {
 			/* FIXME: check if this works if not already realized*/
-			GsWpUnrealizeWindow(wp, GR_TRUE);
+		  GsWpUnrealizeWindow(wp, GR_TRUE,/*REM Do Clear*/GR_FALSE);
 			wp->bordersize = props->bordersize;
 			GsWpRealizeWindow(wp, GR_TRUE);
 		}
@@ -3703,6 +3950,12 @@
 	wp->bgpixmap = pp;
 	wp->bgpixmapflags = flags;
 
+//*REM*/#if defined(TRANS_COLOR)
+   //	if((wp->width==pp->width)&&(wp->height==pp->height)&&wp->alpha&&pp->alpha)
+   //	  memcpy(wp->alpha,pp->alpha,wp->width * wp->height);
+//*REM*/#endif
+
+
 	SERVER_UNLOCK();
 }
 
@@ -3741,10 +3994,11 @@
 	PSD srcpsd;
 
 	SERVER_LOCK();
+	/*REM*/MWRECT RelAreaToDraw={dx1,dy1,dx2+1,dy2+1};
 
 	srcpsd = NULL;
 
-	type = GsPrepareDrawing(dstid, gc, &dp);
+	type = GsPrepareDrawing(dstid, gc, &dp,/*REM*//*&RelAreaToDraw*/NULL);
 	if (type == GR_DRAW_TYPE_NONE) {
 		SERVER_UNLOCK();
 		return;
diff -urN microwindows-0.91/src/nanox/srvmain.c microwindows-0.91.g100/src/nanox/srvmain.c
--- microwindows-0.91/src/nanox/srvmain.c	2007-06-17 21:56:40.000000000 +0200
+++ microwindows-0.91.g100/src/nanox/srvmain.c	2006-12-17 13:14:43.000000000 +0100
@@ -972,6 +972,12 @@
 	wp->title = NULL;
 	wp->clipregion = NULL;
 
+/*REM BEGIN:*/
+	//rootwindow does not need any alpha map
+        //since ther cannot be any other objects below
+       	wp->alpha = NULL;
+/*REM END*/
+	
         listpp = NULL;
 	listwp = wp;
 	rootwp = wp;
diff -urN microwindows-0.91/src/nanox/srvnet.c microwindows-0.91.g100/src/nanox/srvnet.c
--- microwindows-0.91/src/nanox/srvnet.c	2007-06-17 21:56:40.000000000 +0200
+++ microwindows-0.91.g100/src/nanox/srvnet.c	2006-10-12 18:23:49.000000000 +0200
@@ -1596,6 +1596,21 @@
 #endif /*HAVE_FREETYPE_2_SUPPORT*/
 }
 
+/*REM BEGIN:*/
+static void
+GrResizePixmapWrapper(void *r)
+{
+	nxResizePixmapReq *req = r;
+	GR_WINDOW_ID	wid;
+
+	wid = 	GrResizePixmap(req->windowid, req->width, req->height,0);
+
+	GsWriteType(current_fd,GrNumResizePixmap);
+	GsWrite(current_fd, &wid, sizeof(wid));
+
+}
+/*REM END*/
+
 
 void GrShmCmdsFlushWrapper(void *r);
 
@@ -1731,6 +1746,7 @@
 	/* 122 */ {GrSetTransformWrapper, "GrSetTransform" },
 	/* 123 */ {GrCreateFontFromBufferWrapper, "GrCreateFontFromBuffer"},
 	/* 124 */ {GrCopyFontWrapper, "GrCopyFont"},
+/*REM*/	/* 125 */ {GrResizePixmapWrapper, "GrResizePixmap"},
 };
 
 void
diff -urN microwindows-0.91/src/nanox/srvutil.c microwindows-0.91.g100/src/nanox/srvutil.c
--- microwindows-0.91/src/nanox/srvutil.c	2007-06-17 21:56:40.000000000 +0200
+++ microwindows-0.91.g100/src/nanox/srvutil.c	2007-06-16 17:14:45.000000000 +0200
@@ -79,7 +79,7 @@
  * as window will be mapped again momentarily (window move, resize, etc)
  */
 void
-GsWpUnrealizeWindow(GR_WINDOW *wp, GR_BOOL temp_unmap)
+GsWpUnrealizeWindow(GR_WINDOW *wp, GR_BOOL temp_unmap, /*REM*/char DoNotClear)
 {
 	GR_WINDOW	*pwp;		/* parent window */
 	GR_WINDOW	*sibwp;		/* sibling window */
@@ -101,8 +101,9 @@
 	/* set window invisible flag*/
 	wp->realized = GR_FALSE;
 
+	//*REM*/Unrealize all childs, but do not clear them since they are cleared later
 	for (childwp = wp->children; childwp; childwp = childwp->siblings)
-		GsWpUnrealizeWindow(childwp, temp_unmap);
+	  GsWpUnrealizeWindow(childwp, temp_unmap,/*REM*/GR_TRUE/*DoNotClear*/);
 
 	if (!temp_unmap && wp == mousewp) {
 		GsCheckMouseWindow();
@@ -134,6 +135,17 @@
 	 * Clear the area in the parent for this window, causing an
 	 * exposure event for it.  Take into account the border size.
 	 */
+
+/*REM*/#if defined(TRANS_COLOR)
+	/*We Do a redraw of all lower windows here:GR_MODE_WPCLEAR_UP*/
+	if(!DoNotClear)
+	  {
+	    bs = wp->bordersize;
+	    pwp = wp->parent;
+	    GsWpClearWindowUpAndDown(pwp, wp->x - pwp->x - bs, wp->y - pwp->y - bs,
+				     wp->width + bs * 2, wp->height + bs * 2, GR_TRUE/*exposure*/);
+	  }
+/*REM*/#else
 	bs = wp->bordersize;
 	pwp = wp->parent;
 	GsWpClearWindow(pwp, wp->x - pwp->x - bs, wp->y - pwp->y - bs,
@@ -149,6 +161,7 @@
 		GsExposeArea(sibwp, wp->x - bs, wp->y - bs,
 			wp->width + bs * 2, wp->height + bs * 2, NULL);
 	}
+/*REM*/#endif
 }
 
 /*
@@ -263,7 +276,7 @@
 	 * Unmap the window first.
 	 */
 	if (wp->realized)
-		GsWpUnrealizeWindow(wp, GR_FALSE);
+	  GsWpUnrealizeWindow(wp, GR_FALSE,/*REM Do clear*/GR_FALSE);
 
 	/* send destroy update event*/
 	GsDeliverUpdateEvent(wp, GR_UPDATE_DESTROY, wp->x, wp->y,
@@ -350,6 +363,10 @@
 		}
 	}
 
+
+/*REM*/	if(wp->alpha)
+/*REM*/   free(wp->alpha);
+
 	free(wp);
 }
 
@@ -411,6 +428,17 @@
 		destheight = y + height - pixmapy;
 	}
 
+/*REM*/#if defined(TRANS_COLOR)
+/*REM*/	if(destwidth > 0 && destheight > 0) {
+/*REM*/		if (wp->bgpixmapflags & GR_BACKGROUND_STRETCH) {
+/*REM FIXME:*/         GdStretchBlit(wp->psd, destx + wp->x, desty + wp->y,
+/*REM*/				destwidth, destheight, pm->psd, fromx, fromy,
+/*REM*/				pm->width, pm->height, MWROP_COPY);
+/*REM*/		} else GdBlit(wp->psd, destx + wp->x, desty + wp->y, destwidth,
+/*REM*/			destheight, pm->psd, fromx, fromy, MWROP_SRCTRANSCOPY);
+/*REM*/	}
+/*REM*/
+/*REM*/#else
 	if(destwidth > 0 && destheight > 0) {
 		if (wp->bgpixmapflags & GR_BACKGROUND_STRETCH) {
 			GdStretchBlit(wp->psd, destx + wp->x, desty + wp->y,
@@ -419,7 +447,7 @@
 		} else GdBlit(wp->psd, destx + wp->x, desty + wp->y, destwidth,
 			destheight, pm->psd, fromx, fromy, MWROP_COPY);
 	}
-
+/*REM*/#endif
 	if(wp->bgpixmapflags & (GR_BACKGROUND_TRANS|GR_BACKGROUND_STRETCH))
 		return;
 
@@ -525,14 +553,20 @@
 					fromy = 0;
 					cheight = y + height - tiley;
 				}
-				if(cwidth > width) cwidth = width;
+				//if(cwidth > width) cwidth = width;
+			        /*REM: BUGFIX*/if(cheight > height) cheight = height;
 				if(cheight > destheight) cheight = destheight;
 				cy = wp->y + tiley + fromy;
 			}
 
 			if((cwidth > 0) && (cheight > 0)) {
+/*REM*/#if defined(TRANS_COLOR)
+				GdBlit(wp->psd, cx, cy, cwidth, cheight,
+					pm->psd, fromx, fromy,MWROP_SRCTRANSCOPY );
+/*REM*/#else
 				GdBlit(wp->psd, cx, cy, cwidth, cheight,
 					pm->psd, fromx, fromy, MWROP_COPY);
+/*REM*/#endif
 			}
 		}
 	}
@@ -550,6 +584,10 @@
 {
 	if (!wp->realized || !wp->output)
 		return;
+
+	//*REM*/since we only clear a specific area, we can speed up clipping
+	/*REM*/MWRECT RToClip={x+wp->x,y+wp->y,x+wp->x+width,y+wp->y+height};
+
 	/*
 	 * Reduce the arguments so that they actually lie within the window.
 	 */
@@ -579,7 +617,7 @@
 	 * Invalidate the current graphics context since
 	 * we are changing the foreground color and mode.
 	 */
-	GsSetClipWindow(wp, NULL, 0);
+	GsSetClipWindow(wp, NULL, 0,/*REM*/&RToClip);
 	curgcp = NULL;
 
 	GdSetFillMode(GR_FILL_SOLID);
@@ -588,9 +626,23 @@
 		GdSetMode(GR_MODE_COPY);
 		GdSetForegroundColor(wp->psd, wp->background);
 		if (wp->bgpixmap) {
+//*REM*/screen driver will draw alpha values into the global alpha map.
+/*REM*/ #if defined(TRANS_COLOR)
+/*REM*/	                if ((MWA(wp->background)==0)||(wp->props & GR_WM_PROPS_APPMASK && wp->children && MWA(wp->children->background)==0))
+/*REM*/	                  GdSetAlphaChannel(wp->bgpixmap->alpha,wp->x,wp->y,wp->bgpixmap->width,wp->bgpixmap->height);
+/*REM*/                 else 
+/*REM*/	                  GdSetAlphaChannel(NULL,0,0,0,0); 
+/*REM*/ #endif
 			GsWpDrawBackgroundPixmap(wp, wp->bgpixmap, x, y,
 				width, height);
 		} else {
+//*REM*/screen driver will draw alpha values into the global alpha map.
+/*REM*/ #if defined(TRANS_COLOR)
+/*REM*/	                if ((MWA(wp->background)==0)||(wp->props & GR_WM_PROPS_APPMASK && wp->children && MWA(wp->children->background)==0))
+/*REM*/	                  GdSetAlphaChannel(wp->alpha,wp->x,wp->y,wp->width,wp->height);
+/*REM*/                 else 
+/*REM*/	                  GdSetAlphaChannel(NULL,0,0,0,0); 
+/*REM*/ #endif
 			GdFillRect(wp->psd, wp->x + x, wp->y + y, width,height);
 		}
 	}
@@ -598,8 +650,10 @@
 	/*
 	 * Now do the exposure if required.
 	 */
-	if (exposeflag)
+	if (exposeflag){
 		GsDeliverExposureEvent(wp, x, y, width, height);
+		//printf("GsDeliverExposureEvent(%d, %d, %d, %d, %d)\n",wp->id, x, y, width, height);
+	}
 }
 
 /*
@@ -648,6 +702,278 @@
 		GsExposeArea(wp, rootx, rooty, width, height, stopwp);
 }
 
+
+//*REM BEGIN*/
+#if defined(TRANS_COLOR)
+/*
+ * This function is a smaller version of GsWpClearWindow. I expects correct  
+ * values and is introduced for GsClearAreaUpAndDown which is responsible        
+ * for all the checking and clipping stuff.
+ */
+void
+GsWpSmartClearWindow(GR_WINDOW *wp, MWRECT AreaToDraw, GR_BOOL exposeflag)
+{
+	if (!wp->realized || !wp->output)
+		return;
+
+	GR_COORD x, y;
+
+	if(/*wp->parent*/0)
+	  {
+            x= AreaToDraw.left-wp->parent->x;
+	    y= AreaToDraw.top-wp->parent->y;
+	  }
+	else
+	  {
+            x= AreaToDraw.left-wp->x;
+	    y= AreaToDraw.top-wp->y;
+	  }
+	/*
+	 * All the clipping stuf have to be done somwhere before
+	 * At this point we expect apsolute correct values
+	 */
+
+	/*
+	 * Draw the background of the window.
+	 * Invalidate the current graphics context since
+	 * we are changing the foreground color and mode.
+	 */
+	curgcp = NULL;
+
+	GdSetFillMode(GR_FILL_SOLID);
+
+	if (!(wp->props & GR_WM_PROPS_NOBACKGROUND)) {
+		GdSetMode(GR_MODE_COPY);
+		GdSetForegroundColor(wp->psd, wp->background);
+		if (wp->bgpixmap) {
+		        //screen driver will draw alpha values into the global alpha map.
+                        if ((MWA(wp->background)==0)||(wp->props & GR_WM_PROPS_APPMASK && wp->children && MWA(wp->children->background)==0))
+                          GdSetAlphaChannel(wp->bgpixmap->alpha,wp->x,wp->y,wp->bgpixmap->width,wp->bgpixmap->height);
+			else 
+                          GdSetAlphaChannel(NULL,0,0,0,0); 
+			GsWpDrawBackgroundPixmap(wp, wp->bgpixmap, x, y,
+				   AreaToDraw.right-AreaToDraw.left /*width*/, AreaToDraw.bottom-AreaToDraw.top /*height*/);
+		} else {
+                        //screen driver will draw alpha values into the global alpha map.
+                        if ((MWA(wp->background)==0)||(wp->props & GR_WM_PROPS_APPMASK && wp->children && MWA(wp->children->background)==0))
+		          GdSetAlphaChannel(wp->alpha,wp->x,wp->y,wp->width,wp->height);
+		        else 
+		          GdSetAlphaChannel(NULL,0,0,0,0); 
+			GdFillRect(wp->psd, AreaToDraw.left/*wp->x + x*/, AreaToDraw.top /*wp->y + y*/,
+				   AreaToDraw.right-AreaToDraw.left /*width*/, AreaToDraw.bottom-AreaToDraw.top /*height*/);
+		}
+	}
+
+	/*
+	 * Now do the exposure if required.
+	 */
+	if (exposeflag){
+	        GsDeliverExposureEvent(wp,  AreaToDraw.right-wp->x/*x*/, AreaToDraw.top-wp->y/*y*/,
+				       AreaToDraw.left-AreaToDraw.right /*width*/, AreaToDraw.bottom-AreaToDraw.top /*height*/);
+		//printf("GsDeliverExposureEvent(%d, %d, %d, %d, %d)\n",wp->id, x, y, width, height);
+	}
+}
+
+
+
+/*  Quick and dirty stolen from devrgn.c
+ *  
+ *  1 if two RECTs overlap.
+ *  0 if two RECTs do not overlap.
+ */
+#define OVERLAP(r1, r2)           \
+	(r1.right  > r2.left  && \
+	 r1.left   < r2.right && \
+	 r1.bottom > r2.top    && \
+	 r1.top    < r2.bottom)
+
+/*
+ * This function clears the window itself in the specified area, all children
+ * and all overlaping lower windows. Following example tree 
+ * describes the way:
+ * 
+ *
+ *
+ *
+ *    R
+ *    ^
+ *    |
+ *    W <- w <- w <-
+ *    ^
+ *    |
+ *    W <- W <- w <- w
+ *         ^
+ *         |
+ *         W <- WP <- w <- w
+ *         ^    ^ 
+ *         |    | 
+ *         |    W <- W <- W <-W
+ *         |         |        |
+ *         |         |        W <- W <- W
+ *         |         |
+ *         |         W <- W <- W <- W
+ *         |      
+ *         |      
+ *         W <- W <- W
+ *                
+ *                
+ * WP: Start window    
+ * W : Window is redrawn
+ * w : Window is not redrawn
+ * R : Root window
+ *                
+ * This function handles redrawing windows with transparent background.
+ * so we stop with the first parent with a non transparent window.    
+ *     
+ *     
+ */               
+
+void
+GsWpClearWindowUpAndDown(GR_WINDOW *wp, GR_COORD x, GR_COORD y, GR_SIZE width,
+			 GR_SIZE  height, GR_BOOL exposeflag)
+{
+	if (!wp->realized || !wp->output)
+		return;
+
+	GR_WINDOW *pwp=NULL;
+	/*
+	 * Reduce the arguments so that they actually lie within the window.
+	 */
+	if (x < 0) {
+		width += x;
+		x = 0;
+	}
+	if (y < 0) {
+		height += y;
+		y = 0;
+	}
+	if (x + width > wp->width)
+		width = wp->width - x;
+	if (y + height > wp->height)
+		height = wp->height - y;
+
+	/*
+	 * Now see if the region is really in the window.  If not, then
+	 * do nothing.
+	 */
+	if ((x >= wp->width) || (y >= wp->height) || (width <= 0) ||
+		(height <= 0))
+			return;
+
+	//describe it in a rectangle
+	MWRECT AreaToDraw={x+wp->x,y+wp->y,x+wp->x+width,y+wp->y+height};
+
+	//init call
+	GsSetClipWindowPart(NULL, NULL, 0,&AreaToDraw);
+
+	//clear me, all childs, all siblings and parents+childs
+	pwp=wp;
+	while(pwp)
+	  {
+	    GR_WINDOW *wpt=NULL;
+	    if(pwp==wp)GsWpClearWpAndChilds(pwp, AreaToDraw, exposeflag, GR_MODE_WPCLEAR_WP2CLR);
+	    else GsWpClearWpAndChilds(pwp, AreaToDraw, exposeflag, GR_MODE_WPCLEAR_PARENT);
+
+	    for (wpt = pwp->siblings; wpt; wpt = wpt->siblings)
+	      {
+		GsWpClearWpAndChilds(wpt, AreaToDraw, exposeflag,GR_MODE_WPCLEAR_SIBLING);
+	      }	
+
+	    /* if pwp has a transparent bg, or pwp is a container window whose child has a transparent bg, we have to go on.*/
+	    if ((MWA(pwp->background)==0)||(pwp->props & GR_WM_PROPS_APPMASK && pwp->children && MWA(pwp->children->background)==0))
+	      pwp=pwp->parent;
+	    else
+	      break;
+	  }
+}
+
+void
+GsWpClearWpAndChilds(GR_WINDOW *wp, MWRECT AreaToDraw, GR_BOOL exposeflag, int flags)
+{
+	static char LastChildFound=0;
+	static GR_WINDOW *lastwp=NULL;
+
+	GR_WINDOW *sibwp=NULL;
+
+	if (!wp->realized || !wp->output)
+	  return;
+
+	//describe it in a rectangle
+	MWRECT AreaOfwp={wp->x,wp->y,wp->x+wp->width,wp->y+wp->height};
+
+
+	if(flags&GR_MODE_WPCLEAR_WP2CLR)
+	  {
+	    LastChildFound=0;
+	    lastwp=NULL;
+	  }
+
+	if(!OVERLAP(AreaOfwp,AreaToDraw))
+	   return;
+
+	//calc overlaping parts
+	//left side
+	if(AreaToDraw.left<AreaOfwp.left)
+	  AreaToDraw.left=AreaOfwp.left;
+	if(AreaToDraw.left>AreaOfwp.right) 
+	  return; //we are outside
+	//right side
+	if(AreaToDraw.right>AreaOfwp.right)
+	  AreaToDraw.right=AreaOfwp.right;
+	if(AreaToDraw.right<AreaOfwp.left) 
+	  return; //we are outside
+	//top
+	if(AreaToDraw.top<AreaOfwp.top)
+	  AreaToDraw.top=AreaOfwp.top;
+	if(AreaToDraw.top>AreaOfwp.bottom) 
+	  return; //we are outside
+	//bottom
+	if(AreaToDraw.bottom>AreaOfwp.bottom)
+	  AreaToDraw.bottom=AreaOfwp.bottom;
+	if(AreaToDraw.bottom<AreaOfwp.top) 
+	  return; //we are outside
+
+	/*
+	 * First do it for all the children. 
+	 * Except we just went up, in this case we already did it for all children. 
+	 */
+	
+	if(!(flags&GR_MODE_WPCLEAR_PARENT))
+	  {
+	    for (sibwp = wp->children; sibwp; sibwp = sibwp->siblings)
+	      {
+		//FIXME: check background and stop?
+		GsWpClearWpAndChilds(sibwp, AreaToDraw, exposeflag,GR_MODE_WPCLEAR_CHILD);
+	      }	
+	    
+	  }
+	/*
+	 * Check if we are the most top and right window in the tree 
+	 */
+	//set clip window
+	if((!wp->children && !LastChildFound)||(flags&GR_MODE_WPCLEAR_WP2CLR && !LastChildFound))
+	  {
+	    LastChildFound=1;
+	    /* 
+	     * We are the last child, so we call GsSetClipWindowPart the first time. 
+	     * In this case we have to clip aout all overlaping parents, too.
+	     *
+	     */
+	    GsSetClipWindowPart(wp, NULL, 0,&AreaToDraw);
+	  }
+
+	//clear window itself
+	GsWpSmartClearWindow(wp, AreaToDraw, exposeflag);
+
+	//prepare for next drawing
+	GsSetClipWindowPart(wp, NULL, GR_MODE_THISWP|GR_MODE_EXCLUDECHILDREN, &AreaToDraw);
+	lastwp=wp;
+}
+#endif
+//*REM END*/
+
+
+
 /*
  * Draw the border of a window if there is one.
  * Note: To allow the border to be drawn with the correct clipping,
@@ -687,7 +1013,8 @@
 
 	clipwp = NULL;
 	/* FIXME: window clipregion will fail here */
-	GsSetClipWindow(wp, NULL, 0);
+	/* REM: FIXME: may be we could use RToClip*/ 
+	GsSetClipWindow(wp, NULL, 0,/*REM*/NULL);
 	curgcp = NULL;
 	GdSetMode(GR_MODE_COPY);
 	GdSetForegroundColor(wp->psd, wp->bordercolor);
@@ -708,7 +1035,7 @@
 
 	/*
 	 * Restore the true window size.
-	 * Forget the currently clipped window since we messed it up.
+	 * Forget the currently clipped window since we messed it up
 	 */
 	wp->x += bs;
 	wp->y += bs;
@@ -926,7 +1253,7 @@
  * GR_DRAW_TYPE_NONE if an error is generated, or if drawing is useless.
  */
 GR_DRAW_TYPE
-GsPrepareDrawing(GR_DRAW_ID id, GR_GC_ID gcid, GR_DRAWABLE **retdp)
+GsPrepareDrawing(GR_DRAW_ID id, GR_GC_ID gcid, GR_DRAWABLE **retdp,/*REM*/MWRECT *RelAreaToDraw)
 {
 	GR_WINDOW	*wp;		/* found window */
         GR_PIXMAP       *pp;            /* found pixmap */
@@ -971,6 +1298,11 @@
 				GdIntersectRegion(reg, reg, regionp->rgn);
 		}
 		GdSetClipRegion(pp->psd, reg);
+		//*REM*/We reset the Clipmap since clipping the pixmap is not usefull here.
+		/*REM*/ #if defined(TRANS_COLOR)
+		/*REM*/ GdSetClipMap(NULL);
+		/*REM*/ #endif
+
 #else
 		{
 		MWCLIPRECT	cliprect;
@@ -1009,21 +1341,47 @@
 			 */
 			if (regionp && (gcp->xoff || gcp->yoff)) {
 				MWCLIPREGION *local = GdAllocRegion();
-
+				//*REM/FIXME: use RToClip here
 				GdCopyRegion(local, regionp->rgn);
 				GdOffsetRegion(local, gcp->xoff, gcp->yoff);
 
 				GsSetClipWindow(wp, local,  
-					gcp->mode & ~GR_MODE_DRAWMASK);
-
+						gcp->mode & ~GR_MODE_DRAWMASK/*REM*/,NULL);
 				GdDestroyRegion(local);
 			  } else {
+			        /*REM*/MWRECT AreaToDraw;
+				/*REM*/if(RelAreaToDraw) {
+				/*REM*/  AreaToDraw.left=RelAreaToDraw->left+wp->x;
+				/*REM*/  AreaToDraw.top =RelAreaToDraw->top+wp->y;
+				/*REM*/  AreaToDraw.right=RelAreaToDraw->right+wp->x;
+				/*REM*/  AreaToDraw.bottom=RelAreaToDraw->bottom+wp->y;
+				/*REM*/}
 				GsSetClipWindow(wp, regionp? regionp->rgn: NULL,
-					gcp->mode & ~GR_MODE_DRAWMASK);
+						gcp->mode & ~GR_MODE_DRAWMASK,
+						/*REM*/RelAreaToDraw?&AreaToDraw:NULL
+						);
 			  }
 		}
 	}
 
+//*REM*/We have to set the global alpha map here.
+//*REM*/Screen driver will draw alpha values into the global alpha map.
+/*REM*/ #if defined(TRANS_COLOR)
+/*REM*/ if(wp)
+/*REM*/ {
+/*REM*/	  if ((MWA(wp->background)==0)||(wp->props & GR_WM_PROPS_APPMASK && wp->children && MWA(wp->children->background)==0))
+/*REM*/	    GdSetAlphaChannel(wp->alpha,wp->x,wp->y,wp->width,wp->height);
+/*REM*/   else 
+/*REM*/	    GdSetAlphaChannel(NULL,0,0,0,0); 
+/*REM*/ }
+/*REM*/ if(pp)
+/*REM*/ {
+//*REM*/    if(MWA(pp->background))  GdSetAlphaChannel(NULL,0,0,0,0);
+//*REM*/    else GdSetAlphaChannel(pp->alpha,pp->x,pp->y,pp->width,pp->height);
+/*REM*/    GdSetAlphaChannel(pp->alpha,pp->x,pp->y,pp->width,pp->height);
+/*REM*/ }
+/*REM*/ #endif	
+
 	/*
 	 * If the graphics context has been changed, then tell the
 	 * device driver about it.
@@ -1106,9 +1464,23 @@
 
 	if (wp != clipwp) {
 		/* FIXME: no user region clipping here*/
-		GsSetClipWindow(wp, NULL, 0);
+	        /* REM: FIXME: may be we could use RToClip*/ 
+	  GsSetClipWindow(wp, NULL, 0/*REM*/,NULL);
 	}
 
+
+//*REM*/set current alpha map
+//*REM*/screen driver will draw alpha values into the global alpha map.
+/*REM*/ #if defined(TRANS_COLOR)
+/*REM*/ if(wp) 
+/*REM*/  {
+/*REM*/	  if ((MWA(wp->background)==0)||(wp->props & GR_WM_PROPS_APPMASK && wp->children && MWA(wp->children->background)==0))
+/*REM*/	    GdSetAlphaChannel(wp->alpha,wp->x,wp->y,wp->width,wp->height);
+/*REM*/   else 
+/*REM*/	    GdSetAlphaChannel(NULL,0,0,0,0); 
+/*REM*/  }
+/*REM*/ #endif	
+
 	return wp;
 }
 
