On Thu, 6 Oct 2011, DRC wrote:

IMHO, this is not unsolvable. If MinGW still refuses to add support for
this, we should be able to include the missing definitions in the
TigerVNC code base.

It's not just missing definitions.  The patch you guys tried to commit
upstream didn't work, because it did not include support for
IActiveDesktop in the actual link libraries.  AFAIK, including such
support would require back-engineering the Windows libs, which is why
MinGW rejected the idea.

It seems that you have misunderstood how build time linking of Windows binaries works. You don't actually need the full library; only a stub. This stub can be generated with "dlltool", typically from a .def file. In the case of the ActiveDesktop constants though, you also need to have a small .c file containing 2 rows of DEFINE_GUID.

MinGW hasn't yet accepted the patch because one single constant (IID_IActiveDesktop ) cannot be found in the registry or the MS documentation on MSDN. Instead, a binary was used to retrieve the value. They haven't used that approach before. (The constant can now also be found on http://social.msdn.microsoft.com.)


Here's an offer: If we fix so that WinVNC can be built with a standard
MinGW distribution, can we then remove support for Visual Studio?

Assuming you could fix WinVNC in its current incarnation, my main
concern would still be that you would be painting me into a corner,
whereby I couldn't use any other advanced functionality if I needed it
in the future. Plus, I think it's probably a moot point, because I'm doubtful that anyone can make WinVNC work with MinGW, even in its current incarnation.

Could you please stop saying that things are close to impossible without even trying?

Attached is a patch that adds the missing definitions to the internal libos, if necessary. With this patch, building WinVNC with MinGW seems to work fine.

If you would need any "advanced functionality" in the future, you can just add the missing constants and/or stubs, just as I did. This is typically very straight forward. We have been using MinGW for almost 10 years, and with the exception of this ActiveDesktop COM stuff, we haven't had much problems.

Rgds, ---
Peter Åstrand           ThinLinc Chief Developer
Cendio AB               http://www.cendio.com
Wallenbergs gata 4
583 30 Linköping        Phone: +46-13-21 46 00
Index: common/os/os.h
===================================================================
--- common/os/os.h      (revision 23140)
+++ common/os/os.h      (arbetskopia)
@@ -23,6 +23,8 @@
 #include <config.h>
 #endif
 
+#include <os/w32tiger.h>
+
 /*
  * Get VNC home directory ($HOME/.vnc or %APPDATA%/vnc/).
  * If HOME environment variable is set then it is used.
Index: common/os/w32tiger.c
===================================================================
--- common/os/w32tiger.c        (revision 0)
+++ common/os/w32tiger.c        (revision 0)
@@ -0,0 +1,34 @@
+/* Copyright (C) 2011 TightVNC Team.  All Rights Reserved.
+ *
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
+ * USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef WIN32 
+
+#define INITGUID
+#include <basetyps.h>
+#include <shlguid.h>
+
+#ifndef HAVE_ACTIVE_DESKTOP
+DEFINE_GUID(CLSID_ActiveDesktop,0x75048700L,0xEF1F,0x11D0,0x98,0x88,0x00,0x60,0x97,0xDE,0xAC,0xF9);
+DEFINE_GUID(IID_IActiveDesktop,0xF490EB00L,0x1240,0x11D1,0x98,0x88,0x00,0x60,0x97,0xDE,0xAC,0xF9);
+#endif
+
+#endif /* WIN32 */
Index: common/os/w32tiger.h
===================================================================
--- common/os/w32tiger.h        (revision 0)
+++ common/os/w32tiger.h        (revision 0)
@@ -0,0 +1,180 @@
+/* Copyright (C) 2011 TightVNC Team.  All Rights Reserved.
+ *
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ * 
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
+ * USA.
+ */
+
+#ifndef OS_W32TIGER_H
+#define OS_W32TIGER_H
+
+#ifdef WIN32 
+
+#include <windows.h>
+#include <wininet.h>
+#include <shlobj.h>
+#include <shlguid.h>
+#include <wininet.h>
+
+
+/* MSLLHOOKSTRUCT structure*/
+#ifndef HAVE_LLMHF_INJECTED
+#define LLMHF_INJECTED          0x00000001
+#endif
+
+
+/* IActiveDesktop */
+#ifndef HAVE_ACTIVE_DESKTOP
+extern const GUID CLSID_ActiveDesktop;
+extern const GUID IID_IActiveDesktop;
+
+/* IActiveDesktop::AddUrl */
+#define ADDURL_SILENT          0x0001
+
+/* IActiveDesktop::AddDesktopItemWithUI */
+#define DTI_ADDUI_DEFAULT      0x00000000
+#define DTI_ADDUI_DISPSUBWIZARD        0x00000001
+#define DTI_ADDUI_POSITIONITEM 0x00000002
+
+/* IActiveDesktop::ModifyDesktopItem */
+#define COMP_ELEM_TYPE         0x00000001
+#define COMP_ELEM_CHECKED      0x00000002
+#define COMP_ELEM_DIRTY                0x00000004
+#define COMP_ELEM_NOSCROLL     0x00000008
+#define COMP_ELEM_POS_LEFT     0x00000010
+#define COMP_ELEM_POS_TOP      0x00000020
+#define COMP_ELEM_SIZE_WIDTH   0x00000040
+#define COMP_ELEM_SIZE_HEIGHT  0x00000080
+#define COMP_ELEM_POS_ZINDEX   0x00000100
+#define COMP_ELEM_SOURCE       0x00000200
+#define COMP_ELEM_FRIENDLYNAME 0x00000400
+#define COMP_ELEM_SUBSCRIBEDURL        0x00000800
+#define COMP_ELEM_ORIGINAL_CSI 0x00001000
+#define COMP_ELEM_RESTORED_CSI 0x00002000
+#define COMP_ELEM_CURITEMSTATE 0x00004000
+#define COMP_ELEM_ALL          0x00007FFF /* OR-ed all COMP_ELEM_ */
+
+/* IActiveDesktop::GetWallpaper */
+#define AD_GETWP_BMP           0x00000000
+#define AD_GETWP_IMAGE         0x00000001
+#define AD_GETWP_LAST_APPLIED  0x00000002
+
+/* IActiveDesktop::ApplyChanges */
+#define AD_APPLY_SAVE          0x00000001
+#define AD_APPLY_HTMLGEN       0x00000002
+#define AD_APPLY_REFRESH       0x00000004
+#define AD_APPLY_ALL           0x00000007 /* OR-ed three AD_APPLY_ above */
+#define AD_APPLY_FORCE         0x00000008
+#define AD_APPLY_BUFFERED_REFRESH 0x00000010
+#define AD_APPLY_DYNAMICREFRESH        0x00000020
+
+/* Structures for IActiveDesktop */
+typedef struct {
+       DWORD dwSize;
+       int iLeft;
+       int iTop;
+       DWORD dwWidth;
+       DWORD dwHeight;
+       DWORD dwItemState;
+} COMPSTATEINFO, *LPCOMPSTATEINFO;
+typedef const COMPSTATEINFO *LPCCOMPSTATEINFO;
+
+typedef struct {
+       DWORD dwSize;
+       int iLeft;
+       int iTop;
+       DWORD dwWidth;
+       DWORD dwHeight;
+       int izIndex;
+       BOOL fCanResize;
+       BOOL fCanResizeX;
+       BOOL fCanResizeY;
+       int iPreferredLeftPercent;
+       int iPreferredTopPercent;
+} COMPPOS, *LPCOMPPOS;
+typedef const COMPPOS *LPCCOMPPOS;
+
+typedef struct {
+       DWORD dwSize;
+       DWORD dwID;
+       int iComponentType;
+       BOOL fChecked;
+       BOOL fDirty;
+       BOOL fNoScroll;
+       COMPPOS cpPos;
+       WCHAR wszFriendlyName[MAX_PATH];
+       WCHAR wszSource[INTERNET_MAX_URL_LENGTH];
+       WCHAR wszSubscribedURL[INTERNET_MAX_URL_LENGTH];
+       DWORD dwCurItemState;
+       COMPSTATEINFO csiOriginal;
+       COMPSTATEINFO csiRestored;
+} COMPONENT, *LPCOMPONENT;
+typedef const COMPONENT *LPCCOMPONENT;
+
+typedef struct {
+       DWORD dwSize;
+       BOOL fEnableComponents;
+       BOOL fActiveDesktop;
+} COMPONENTSOPT, *LPCOMPONENTSOPT;
+typedef const COMPONENTSOPT *LPCCOMPONENTSOPT;
+
+typedef struct {
+    DWORD dwSize;
+    DWORD dwStyle;
+} WALLPAPEROPT, *LPWALLPAPEROPT;
+typedef const WALLPAPEROPT *LPCWALLPAPEROPT;
+
+/* WALLPAPEROPT styles */
+#define WPSTYLE_CENTER         0x0
+#define WPSTYLE_TILE           0x1
+#define WPSTYLE_STRETCH                0x2
+#define WPSTYLE_MAX            0x3
+
+/* Those two are defined in Windows 7 and newer, we don't need them now */
+#if 0
+#define WPSTYLE_KEEPASPECT     0x3
+#define WPSTYLE_CROPTOFIT      0x4
+#endif
+
+#define INTERFACE IActiveDesktop
+DECLARE_INTERFACE_(IActiveDesktop, IUnknown)
+{
+       STDMETHOD(QueryInterface)(THIS_ REFIID,PVOID*) PURE;
+       STDMETHOD_(ULONG,AddRef)(THIS) PURE;
+       STDMETHOD_(ULONG,Release)(THIS) PURE;
+       STDMETHOD(AddDesktopItem)(THIS_ LPCOMPONENT,DWORD) PURE;
+       STDMETHOD(AddDesktopItemWithUI)(THIS_ HWND,LPCOMPONENT,DWORD) PURE;
+       STDMETHOD(AddUrl)(THIS_ HWND,LPCWSTR,LPCOMPONENT,DWORD) PURE;
+       STDMETHOD(ApplyChanges)(THIS_ DWORD) PURE;
+       STDMETHOD(GenerateDesktopItemHtml)(THIS_ LPCWSTR,LPCOMPONENT,DWORD) 
PURE;
+       STDMETHOD(GetDesktopItem)(THIS_ int,LPCOMPONENT,DWORD) PURE;
+       STDMETHOD(GetDesktopItemByID)(THIS_ DWORD,LPCOMPONENT,DWORD) PURE;
+       STDMETHOD(GetDesktopItemBySource)(THIS_ LPCWSTR,LPCOMPONENT,DWORD) PURE;
+       STDMETHOD(GetDesktopItemCount)(THIS_ LPINT,DWORD) PURE;
+       STDMETHOD(GetDesktopItemOptions)(THIS_ LPCOMPONENTSOPT,DWORD) PURE;
+       STDMETHOD(GetPattern)(THIS_ LPWSTR,UINT,DWORD) PURE;
+       STDMETHOD(GetWallpaper)(THIS_ LPWSTR,UINT,DWORD) PURE;
+       STDMETHOD(GetWallpaperOptions)(THIS_ LPWALLPAPEROPT,DWORD) PURE;
+       STDMETHOD(ModifyDesktopItem)(THIS_ LPCCOMPONENT,DWORD) PURE;
+       STDMETHOD(RemoveDesktopItem)(THIS_ LPCCOMPONENT,DWORD) PURE;
+       STDMETHOD(SetDesktopItemOptions)(THIS_ LPCCOMPONENTSOPT,DWORD) PURE;
+       STDMETHOD(SetPattern)(THIS_ LPCWSTR,DWORD) PURE;
+       STDMETHOD(SetWallpaper)(THIS_ LPCWSTR,DWORD) PURE;
+       STDMETHOD(SetWallpaperOptions)(THIS_ LPCWALLPAPEROPT,DWORD) PURE;
+};
+#endif /* HAVE_ACTIVE_DESKTOP */
+#undef INTERFACE
+
+#endif /* WIN32 */
+#endif /* OS_W32TIGER_H */
Index: common/os/CMakeLists.txt
===================================================================
--- common/os/CMakeLists.txt    (revision 23140)
+++ common/os/CMakeLists.txt    (arbetskopia)
@@ -3,6 +3,7 @@
 add_library(os STATIC
   print.c
   net.c
+  w32tiger.c
   os.cxx
   tls.cxx)
 
Index: win/wm_hooks/wm_hooks.cxx
===================================================================
--- win/wm_hooks/wm_hooks.cxx   (revision 23140)
+++ win/wm_hooks/wm_hooks.cxx   (arbetskopia)
@@ -23,6 +23,7 @@
 #include <tchar.h>
 
 #include <wm_hooks/wm_hooks.h>
+#include <os/os.h>
 
 UINT WM_HK_PingThread = RegisterWindowMessage(_T("RFB.WM_Hooks.PingThread"));
 
Index: win/rfb_win32/CleanDesktop.cxx
===================================================================
--- win/rfb_win32/CleanDesktop.cxx      (revision 23140)
+++ win/rfb_win32/CleanDesktop.cxx      (arbetskopia)
@@ -27,6 +27,7 @@
 #include <rfb_win32/OSVersion.h>
 #include <rfb/LogWriter.h>
 #include <rdr/Exception.h>
+#include <os/os.h>
 #include <set>
 
 #ifdef SPI_GETUIEFFECTS
Index: CMakeLists.txt
===================================================================
--- CMakeLists.txt      (revision 23140)
+++ CMakeLists.txt      (arbetskopia)
@@ -67,11 +67,7 @@
 add_definitions(-D__BUILD__="${BUILD}")
 
 if(NOT DEFINED BUILD_WINVNC)
-  if(MSVC)
-    set(BUILD_WINVNC 1)
-  else()
-    set(BUILD_WINVNC 0)
-  endif()
+  set(BUILD_WINVNC 1)
 endif()
 
 if(MSVC)
@@ -164,6 +160,12 @@
     "<CMAKE_RC_COMPILER> <FLAGS> <DEFINES> -o <OBJECT> --output-format=coff 
<SOURCE>")
 endif()
 
+# Check if we need to activate MinGW W32 fallsbacks
+if(MINGW)
+    check_c_source_compiles("#include <windows.h>\nint main(int c, char** v) { 
return LLMHF_INJECTED; }" HAVE_LLMHF_INJECTED)
+    check_c_source_compiles("#include <shlguid.h>\nint main(int c, char** v) { 
return CLSID_ActiveDesktop; }" HAVE_ACTIVE_DESKTOP)
+endif()
+
 # X11 stuff. It's in a if() so that we can say REQUIRED
 if(UNIX AND NOT APPLE)
   find_package(X11 REQUIRED)
------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure contains a
definitive record of customers, application performance, security
threats, fraudulent activity and more. Splunk takes this data and makes
sense of it. Business sense. IT sense. Common sense.
http://p.sf.net/sfu/splunk-d2dcopy1
_______________________________________________
Tigervnc-devel mailing list
Tigervnc-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tigervnc-devel

Reply via email to