From 3a8c43983755b1bc87f6a3b536f8004e87ca4c02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Moreau?= Date: Mon, 2 Jan 2012 22:33:35 -0500 Subject: [PATCH] xfreerdp-server: xdamage initialization --- server/X11/CMakeLists.txt | 7 ++++ server/X11/xf_peer.c | 67 +++++++++++++++++++++++++++++++++------ server/X11/xfreerdp.h | 15 +++++++++ 3 files changed, 79 insertions(+), 10 deletions(-) diff --git a/server/X11/CMakeLists.txt b/server/X11/CMakeLists.txt index c47c7552f..1f115f1e7 100644 --- a/server/X11/CMakeLists.txt +++ b/server/X11/CMakeLists.txt @@ -38,6 +38,13 @@ if(XDAMAGE_FOUND) target_link_libraries(xfreerdp-server ${XDAMAGE_LIBRARIES}) endif() +find_suggested_package(Xfixes) +if(XFIXES_FOUND) + add_definitions(-DWITH_XFIXES) + include_directories(${XFIXES_INCLUDE_DIRS}) + target_link_libraries(xfreerdp-server ${XFIXES_LIBRARIES}) +endif() + target_link_libraries(xfreerdp-server freerdp-core) target_link_libraries(xfreerdp-server freerdp-codec) target_link_libraries(xfreerdp-server freerdp-utils) diff --git a/server/X11/xf_peer.c b/server/X11/xf_peer.c index 99aea7b5f..3cf4cfd39 100644 --- a/server/X11/xf_peer.c +++ b/server/X11/xf_peer.c @@ -24,11 +24,6 @@ #include #include #include - -#ifdef WITH_XDAMAGE -#include -#endif - #include #include #include @@ -41,16 +36,67 @@ extern boolean xf_pcap_dump_realtime; #include "xf_peer.h" +#ifdef WITH_XDAMAGE + +void xf_xdamage_init(xfInfo* xfi) +{ + int damage_event; + int damage_error; + int major, minor; + XGCValues values; + + if (XDamageQueryExtension(xfi->display, &damage_event, &damage_error) == 0) + { + printf("XDamageQueryExtension failed\n"); + return; + } + + XDamageQueryVersion(xfi->display, &major, &minor); + + if (XDamageQueryVersion(xfi->display, &major, &minor) == 0) + { + printf("XDamageQueryVersion failed\n"); + return; + } + else if (major < 1) + { + printf("XDamageQueryVersion failed: major:%d minor:%d\n", major, minor); + return; + } + + xfi->xdamage_notify_event = damage_event + XDamageNotify; + xfi->xdamage = XDamageCreate(xfi->display, DefaultRootWindow(xfi->display), XDamageReportDeltaRectangles); + + if (xfi->xdamage == None) + { + printf("XDamageCreate failed\n"); + return; + } + +#ifdef WITH_XFIXES + xfi->xdamage_region = XFixesCreateRegion(xfi->display, NULL, 0); + + if (xfi->xdamage_region == None) + { + printf("XFixesCreateRegion failed\n"); + XDamageDestroy(xfi->display, xfi->xdamage); + xfi->xdamage = None; + return; + } +#endif + + values.subwindow_mode = IncludeInferiors; + xfi->xdamage_gc = XCreateGC(xfi->display, DefaultRootWindow(xfi->display), GCSubwindowMode, &values); +} + +#endif + xfInfo* xf_info_init() { int i; xfInfo* xfi; int pf_count; int vi_count; -#ifdef WITH_XDAMAGE - int damage_event; - int damage_error; -#endif XVisualInfo* vi; XVisualInfo* vis; XVisualInfo template; @@ -123,8 +169,9 @@ xfInfo* xf_info_init() xfi->clrconv->alpha = 1; XSelectInput(xfi->display, DefaultRootWindow(xfi->display), SubstructureNotifyMask); + #ifdef WITH_XDAMAGE - XDamageQueryExtension(xfi->display, &damage_event, &damage_error); + xf_xdamage_init(xfi); #endif return xfi; diff --git a/server/X11/xfreerdp.h b/server/X11/xfreerdp.h index 8ee95d281..67ce624eb 100644 --- a/server/X11/xfreerdp.h +++ b/server/X11/xfreerdp.h @@ -22,6 +22,14 @@ #include +#ifdef WITH_XFIXES +#include +#endif + +#ifdef WITH_XDAMAGE +#include +#endif + struct xf_info { int bpp; @@ -35,6 +43,13 @@ struct xf_info Display* display; int scanline_pad; HCLRCONV clrconv; + +#ifdef WITH_XDAMAGE + GC xdamage_gc; + Damage xdamage; + int xdamage_notify_event; + XserverRegion xdamage_region; +#endif }; typedef struct xf_info xfInfo;