[Spice-devel] [PATCH 1/2] mingw32 build: check for CXImage, disable if not found (only on mingw32)

Alon Levy alevy at redhat.com
Wed Dec 8 07:18:11 PST 2010


v2:
 + simplify (Hans)
 + also report presence of cximage for mingw32 target
---
 client/windows/Makefile.am  |    1 +
 client/windows/platform.cpp |   15 +++++++++++++++
 configure.ac                |   37 ++++++++++++++++++++++++++++++++++++-
 3 files changed, 52 insertions(+), 1 deletions(-)

diff --git a/client/windows/Makefile.am b/client/windows/Makefile.am
index 0bd6e42..ae104ff 100644
--- a/client/windows/Makefile.am
+++ b/client/windows/Makefile.am
@@ -21,6 +21,7 @@ INCLUDES = \
 	$(CEGUI_CFLAGS)					\
 	$(WARN_CFLAGS)                                  \
 	$(SPICE_NONPKGCONFIG_CFLAGS)			\
+	$(CXIMAGE_CFLAGS)               \
 	$(NULL)
 
 
diff --git a/client/windows/platform.cpp b/client/windows/platform.cpp
index b6f1918..c41c39a 100644
--- a/client/windows/platform.cpp
+++ b/client/windows/platform.cpp
@@ -32,7 +32,14 @@
 #include "playback.h"
 #include "cursor.h"
 #include "named_pipe.h"
+
+#ifndef DISABLE_CXIMAGE
+#define USE_CXIMAGE
+#endif
+
+#ifdef USE_CXIMAGE
 #include "ximage.h"
+#endif
 #include <spice/vd_agent.h>
 
 int gdi_handlers = 0;
@@ -82,6 +89,7 @@ static ClipboardFormat clipboard_formats[] = {
 
 #define clipboard_formats_count (sizeof(clipboard_formats) / sizeof(clipboard_formats[0]))
 
+#ifdef USE_CXIMAGE
 typedef struct ImageType {
     uint32_t type;
     DWORD cximage_format;
@@ -91,6 +99,7 @@ static ImageType image_types[] = {
     {VD_AGENT_CLIPBOARD_IMAGE_PNG, CXIMAGE_FORMAT_PNG},
     {VD_AGENT_CLIPBOARD_IMAGE_BMP, CXIMAGE_FORMAT_BMP},
 };
+#endif
 
 static std::set<uint32_t> grab_types;
 
@@ -154,6 +163,7 @@ static int get_available_clipboard_types(uint32_t** types)
     return count;
 }
 
+#ifdef USE_CXIMAGE
 static DWORD get_cximage_format(uint32_t type)
 {
     for (size_t i = 0; i < sizeof(image_types) / sizeof(image_types[0]); i++) {
@@ -163,6 +173,7 @@ static DWORD get_cximage_format(uint32_t type)
     }
     return 0;
 }
+#endif
 
 static LRESULT CALLBACK PlatformWinProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 {
@@ -1005,6 +1016,7 @@ bool Platform::on_clipboard_notify(uint32_t type, const uint8_t* data, int32_t s
     case VD_AGENT_CLIPBOARD_UTF8_TEXT:
         clip_data = utf8_alloc((LPCSTR)data, size);
         break;
+#ifdef USE_CXIMAGE
     case VD_AGENT_CLIPBOARD_IMAGE_PNG:
     case VD_AGENT_CLIPBOARD_IMAGE_BMP: {
         DWORD cximage_format = get_cximage_format(type);
@@ -1013,6 +1025,7 @@ bool Platform::on_clipboard_notify(uint32_t type, const uint8_t* data, int32_t s
         clip_data = image.CopyToHandle();
         break;
     }
+#endif
     default:
         LOG_INFO("Unsupported clipboard type %u", type);
         return true;
@@ -1072,6 +1085,7 @@ bool Platform::on_clipboard_request(uint32_t type)
         GlobalUnlock(clip_data);
         break;
     }
+#ifdef USE_CXIMAGE
     case VD_AGENT_CLIPBOARD_IMAGE_PNG:
     case VD_AGENT_CLIPBOARD_IMAGE_BMP: {
         DWORD cximage_format = get_cximage_format(type);
@@ -1091,6 +1105,7 @@ bool Platform::on_clipboard_request(uint32_t type)
         ret = true;
         break;
     }
+#endif
     default:
         LOG_INFO("Unsupported clipboard type %u", type);
     }
diff --git a/configure.ac b/configure.ac
index e92d7d8..5b20e5b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -378,6 +378,33 @@ AC_CACHE_CHECK([for supported warning flags], spice_cv_warn_cflags, [
 WARN_CFLAGS="$spice_cv_warn_cflags"
 SPICE_CFLAGS="$SPICE_CFLAGS $WARN_CFLAGS"
 
+# use ximage.h for win32 build if it is found (no package for mingw32 atm)
+if test $os_win32 == "yes" ; then
+    AC_MSG_CHECKING([for cximage])
+    AC_TRY_CPP(
+[#include <ximage.h>
+int main()
+{
+ return CXIMAGE_FORMAT_RAW;
+)}
+],[
+ AC_MSG_RESULT([found])
+ have_cximage="yes"
+]
+,[AC_MSG_RESULT([missing])
+ CXIMAGE_CFLAGS='-DDISABLE_CXIMAGE'
+ have_cximage="no"
+ ]
+)
+fi
+AC_SUBST(CXIMAGE_CFLAGS)
+
+# check for windres for mingw32 builds
+if test $os_win32 == "yes" ; then
+    AC_CHECK_PROGS(WINDRES,i686-pc-mingw32-windres mingw-windres mingw32-windres,false)
+    AC_SUBST(WINDRES)
+fi
+
 # We only wish to enable attribute(warn_unused_result) if we can prevent
 # gcc from generating thousands of warnings about the misapplication of the
 # attribute to void functions and variables.
@@ -459,6 +486,14 @@ echo "
         GUI:                      ${use_gui}
 
         Smartcard:                ${have_smartcard}
+"
+
+if test $os_win32 == "yes" ; then
+echo \
+"        Copy & Paste Images:     ${have_cximage}
+"
+fi
 
-        Now type 'make' to build $PACKAGE
+echo \
+"        Now type 'make' to build $PACKAGE
 "
-- 
1.7.3.2



More information about the Spice-devel mailing list