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

Alon Levy alevy at redhat.com
Tue Dec 7 13:28:15 PST 2010


---
 client/windows/Makefile.am  |    1 +
 client/windows/platform.cpp |   16 ++++++++++++++++
 configure.ac                |   21 +++++++++++++++++++++
 3 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/client/windows/Makefile.am b/client/windows/Makefile.am
index f673afd..29c30a7 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 3eb2cf6..465bb2f 100644
--- a/client/windows/platform.cpp
+++ b/client/windows/platform.cpp
@@ -32,7 +32,15 @@
 #include "playback.h"
 #include "cursor.h"
 #include "named_pipe.h"
+
+#define USE_CXIMAGE
+#ifdef DISABLE_CXIMAGE
+#undef USE_CXIMAGE
+#endif
+
+#ifdef USE_CXIMAGE
 #include "ximage.h"
+#endif
 #include <spice/vd_agent.h>
 
 int gdi_handlers = 0;
@@ -82,6 +90,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 +100,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 +164,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 +174,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 +1017,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 +1026,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 +1086,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 +1106,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 918f7e7..b0a513a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -378,6 +378,27 @@ 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_TRY_CPP(
+[#include <ximage.h>
+int main()
+{
+ return CXIMAGE_FORMAT_RAW;
+)}
+],[echo cximage found]
+,[echo cximage missing
+ CXIMAGE_CFLAGS='-DDISABLE_CXIMAGE']
+)
+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.
-- 
1.7.3.2



More information about the Spice-devel mailing list