From 5a47c6420cfe298143310938f08cc36a503e8d3d Mon Sep 17 00:00:00 2001 From: Jon TURNEY Date: Mon, 8 Apr 2013 01:27:26 +0100 Subject: [PATCH 1/7] hw/xwin: Fix a 64-bit portability issue with casting HINSTANCE result of ShellExecute() to an integer Fix a 64-bit portability issue with casting HINSTANCE result of ShellExecute() to an integer: Since HINSTANCE is a pointer type, use INT_PTR rather than int. Signed-off-by: Jon TURNEY Reviewed-by: Colin Harrison --- hw/xwin/windialogs.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/hw/xwin/windialogs.c b/hw/xwin/windialogs.c index 86f332aad..3ceaf4ef6 100644 --- a/hw/xwin/windialogs.c +++ b/hw/xwin/windialogs.c @@ -621,7 +621,7 @@ winAboutDlgProc(HWND hwndDialog, UINT message, WPARAM wParam, LPARAM lParam) case ID_ABOUT_CHANGELOG: { - int iReturn; + INT_PTR iReturn; #ifdef __CYGWIN__ const char *pszCygPath = "/usr/X11R6/share/doc/" @@ -635,12 +635,12 @@ winAboutDlgProc(HWND hwndDialog, UINT message, WPARAM wParam, LPARAM lParam) "devel/server/changelog.html"; #endif - iReturn = (int) ShellExecute(NULL, + iReturn = (INT_PTR) ShellExecute(NULL, "open", pszWinPath, NULL, NULL, SW_MAXIMIZE); if (iReturn < 32) { ErrorF("winAboutDlgProc - WM_COMMAND - ID_ABOUT_CHANGELOG - " - "ShellExecute failed: %d\n", iReturn); + "ShellExecute failed: %d\n", (int)iReturn); } } return TRUE; @@ -648,14 +648,15 @@ winAboutDlgProc(HWND hwndDialog, UINT message, WPARAM wParam, LPARAM lParam) case ID_ABOUT_WEBSITE: { const char *pszPath = __VENDORDWEBSUPPORT__; - int iReturn; + INT_PTR iReturn; - iReturn = (int) ShellExecute(NULL, + iReturn = (INT_PTR) ShellExecute(NULL, "open", pszPath, NULL, NULL, SW_MAXIMIZE); if (iReturn < 32) { ErrorF("winAboutDlgProc - WM_COMMAND - ID_ABOUT_WEBSITE - " - "ShellExecute failed: %d\n", iReturn); + "ShellExecute failed: %d\n", (int)iReturn); + } } return TRUE; @@ -663,14 +664,14 @@ winAboutDlgProc(HWND hwndDialog, UINT message, WPARAM wParam, LPARAM lParam) case ID_ABOUT_UG: { const char *pszPath = "http://x.cygwin.com/docs/ug/"; - int iReturn; + INT_PTR iReturn; - iReturn = (int) ShellExecute(NULL, + iReturn = (INT_PTR) ShellExecute(NULL, "open", pszPath, NULL, NULL, SW_MAXIMIZE); if (iReturn < 32) { ErrorF("winAboutDlgProc - WM_COMMAND - ID_ABOUT_UG - " - "ShellExecute failed: %d\n", iReturn); + "ShellExecute failed: %d\n", (int)iReturn); } } return TRUE; @@ -678,14 +679,14 @@ winAboutDlgProc(HWND hwndDialog, UINT message, WPARAM wParam, LPARAM lParam) case ID_ABOUT_FAQ: { const char *pszPath = "http://x.cygwin.com/docs/faq/"; - int iReturn; + INT_PTR iReturn; - iReturn = (int) ShellExecute(NULL, + iReturn = (INT_PTR) ShellExecute(NULL, "open", pszPath, NULL, NULL, SW_MAXIMIZE); if (iReturn < 32) { ErrorF("winAboutDlgProc - WM_COMMAND - ID_ABOUT_FAQ - " - "ShellExecute failed: %d\n", iReturn); + "ShellExecute failed: %d\n", (int)iReturn); } } return TRUE; From b542976846eb5d4c82910272af32ec8298da4177 Mon Sep 17 00:00:00 2001 From: Jon TURNEY Date: Sat, 30 Mar 2013 19:40:31 +0000 Subject: [PATCH 2/7] hw/xwin: deprecated interface cygwin_conv_to_win32_path() doesn't exist in 64-bit cygwin The deprecated interface cygwin_conv_to_win32_path() doesn't exist in 64-bit cygwin, but both the ID_ABOUT_CHANGELOG control and the referenced file who's path we are converting haven't existed for a while, so just remove this unused, cygwin-specific code. Signed-off-by: Jon TURNEY Reviewed-by: Colin Harrison --- hw/xwin/windialogs.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/hw/xwin/windialogs.c b/hw/xwin/windialogs.c index 3ceaf4ef6..16f7ba0e2 100644 --- a/hw/xwin/windialogs.c +++ b/hw/xwin/windialogs.c @@ -33,9 +33,6 @@ #include #endif #include "win.h" -#ifdef __CYGWIN__ -#include -#endif #include #include "winprefs.h" @@ -623,17 +620,8 @@ winAboutDlgProc(HWND hwndDialog, UINT message, WPARAM wParam, LPARAM lParam) { INT_PTR iReturn; -#ifdef __CYGWIN__ - const char *pszCygPath = "/usr/X11R6/share/doc/" - "xorg-x11-xwin/changelog.html"; - char pszWinPath[MAX_PATH + 1]; - - /* Convert the POSIX path to a Win32 path */ - cygwin_conv_to_win32_path(pszCygPath, pszWinPath); -#else const char *pszWinPath = "http://x.cygwin.com/" "devel/server/changelog.html"; -#endif iReturn = (INT_PTR) ShellExecute(NULL, "open", From fc40f9a92cf5981bccc45bbc0b959cc06c5accc2 Mon Sep 17 00:00:00 2001 From: Jon TURNEY Date: Sat, 30 Mar 2013 19:41:06 +0000 Subject: [PATCH 3/7] hw/xwin: Fix uses of CreateDialogParam() for 64-bit builds Fix uses of CreateDialogParam() to be more strictly correct, for 64-bit builds dwInitParam parameter is LPARAM, not int Return type of DLGPROC is INT_PTR, not WINBOOL Also: Reporting the value of g_hDlgDepthChange is completely uninteresting, we are just interested in GetLastError() if it is NULL Signed-off-by: Jon TURNEY Reviewed-by: Colin Harrison --- hw/xwin/windialogs.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/hw/xwin/windialogs.c b/hw/xwin/windialogs.c index 16f7ba0e2..054ee95b5 100644 --- a/hw/xwin/windialogs.c +++ b/hw/xwin/windialogs.c @@ -47,13 +47,13 @@ extern Bool g_fClipboardStarted; * Local function prototypes */ -static wBOOL CALLBACK +static INT_PTR CALLBACK winExitDlgProc(HWND hDialog, UINT message, WPARAM wParam, LPARAM lParam); -static wBOOL CALLBACK +static INT_PTR CALLBACK winChangeDepthDlgProc(HWND hDialog, UINT message, WPARAM wParam, LPARAM lParam); -static wBOOL CALLBACK +static INT_PTR CALLBACK winAboutDlgProc(HWND hDialog, UINT message, WPARAM wParam, LPARAM lParam); static void @@ -285,7 +285,7 @@ winDisplayExitDialog(winPrivScreenPtr pScreenPriv) g_hDlgExit = CreateDialogParam(g_hInstance, "EXIT_DIALOG", pScreenPriv->hwndScreen, - winExitDlgProc, (int) pScreenPriv); + winExitDlgProc, (LPARAM) pScreenPriv); /* Show the dialog box */ ShowWindow(g_hDlgExit, SW_SHOW); @@ -304,7 +304,7 @@ winDisplayExitDialog(winPrivScreenPtr pScreenPriv) * Exit dialog window procedure */ -static wBOOL CALLBACK +static INT_PTR CALLBACK winExitDlgProc(HWND hDialog, UINT message, WPARAM wParam, LPARAM lParam) { static winPrivScreenPtr s_pScreenPriv = NULL; @@ -404,14 +404,13 @@ winDisplayDepthChangeDialog(winPrivScreenPtr pScreenPriv) "DEPTH_CHANGE_BOX", pScreenPriv->hwndScreen, winChangeDepthDlgProc, - (int) pScreenPriv); + (LPARAM) pScreenPriv); /* Show the dialog box */ ShowWindow(g_hDlgDepthChange, SW_SHOW); - ErrorF("winDisplayDepthChangeDialog - DialogBox returned: %d\n", - (int) g_hDlgDepthChange); - ErrorF("winDisplayDepthChangeDialog - GetLastError: %d\n", - (int) GetLastError()); + if (!g_hDlgDepthChange) + ErrorF("winDisplayDepthChangeDialog - GetLastError: %d\n", + (int) GetLastError()); /* Minimize the display window */ ShowWindow(pScreenPriv->hwndScreen, SW_MINIMIZE); @@ -422,7 +421,7 @@ winDisplayDepthChangeDialog(winPrivScreenPtr pScreenPriv) * disruptive screen depth changes. */ -static wBOOL CALLBACK +static INT_PTR CALLBACK winChangeDepthDlgProc(HWND hwndDialog, UINT message, WPARAM wParam, LPARAM lParam) { @@ -536,7 +535,7 @@ winDisplayAboutDialog(winPrivScreenPtr pScreenPriv) g_hDlgAbout = CreateDialogParam(g_hInstance, "ABOUT_BOX", pScreenPriv->hwndScreen, - winAboutDlgProc, (int) pScreenPriv); + winAboutDlgProc, (LPARAM) pScreenPriv); /* Show the dialog box */ ShowWindow(g_hDlgAbout, SW_SHOW); @@ -553,7 +552,7 @@ winDisplayAboutDialog(winPrivScreenPtr pScreenPriv) * Process messages for the about dialog. */ -static wBOOL CALLBACK +static INT_PTR CALLBACK winAboutDlgProc(HWND hwndDialog, UINT message, WPARAM wParam, LPARAM lParam) { static winPrivScreenPtr s_pScreenPriv = NULL; From be201ac257687355bf0916d7c525d598ed9b1282 Mon Sep 17 00:00:00 2001 From: Jon TURNEY Date: Sat, 30 Mar 2013 19:47:16 +0000 Subject: [PATCH 4/7] hw/xwin: Change winIconIsOverride() to take a HICON parameter Change winIconIsOverride() to take a HICON parameter, so some unneccessary casts, which weren't portable to 64-bit Cygwin, can be removed. Signed-off-by: Jon TURNEY Reviewed-by: Colin Harrison --- hw/xwin/winmultiwindowicons.c | 2 +- hw/xwin/winprefs.c | 5 +---- hw/xwin/winprefs.h | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/hw/xwin/winmultiwindowicons.c b/hw/xwin/winmultiwindowicons.c index 0322d9816..bcc5688df 100644 --- a/hw/xwin/winmultiwindowicons.c +++ b/hw/xwin/winmultiwindowicons.c @@ -624,7 +624,7 @@ winDestroyIcon(HICON hIcon) /* Delete the icon if its not one of the application defaults or an override */ if (hIcon && hIcon != g_hIconX && - hIcon != g_hSmallIconX && !winIconIsOverride((unsigned long) hIcon)) + hIcon != g_hSmallIconX && !winIconIsOverride(hIcon)) DestroyIcon(hIcon); } #endif diff --git a/hw/xwin/winprefs.c b/hw/xwin/winprefs.c index 6cbd7ad80..05d8c874d 100644 --- a/hw/xwin/winprefs.c +++ b/hw/xwin/winprefs.c @@ -617,13 +617,10 @@ winOverrideIcon(char *res_name, char *res_class, char *wmName) * ICONS{} overrides)? */ int -winIconIsOverride(unsigned hiconIn) +winIconIsOverride(HICON hicon) { - HICON hicon; int i; - hicon = (HICON) hiconIn; - if (!hicon) return 0; diff --git a/hw/xwin/winprefs.h b/hw/xwin/winprefs.h index 5de5719e1..a4a6e7eec 100644 --- a/hw/xwin/winprefs.h +++ b/hw/xwin/winprefs.h @@ -162,7 +162,7 @@ Bool HandleCustomWM_COMMAND(unsigned long hwndIn, int command); int - winIconIsOverride(unsigned hiconIn); + winIconIsOverride(HICON hicon); HICON winOverrideIcon(char *res_name, char *res_class, char *wmName); From e1a0945e8d4a3858838a14e64022524efd73c905 Mon Sep 17 00:00:00 2001 From: Jon TURNEY Date: Sun, 31 Mar 2013 18:35:35 +0100 Subject: [PATCH 5/7] hw/xwin: winMultiWindowGetTransientFor() returns an XID not a WindowPtr winMultiWindowGetTransientFor() accesses the WM_TRANSIENT_FOR property, which is an X window XID (which we compare with WINDOW_WID_PROP) and not a WindowPtr. Signed-off-by: Jon TURNEY Reviewed-by: Colin Harrison --- hw/xwin/winmultiwindowclass.c | 10 +++++----- hw/xwin/winmultiwindowclass.h | 2 +- hw/xwin/winmultiwindowwindow.c | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/hw/xwin/winmultiwindowclass.c b/hw/xwin/winmultiwindowclass.c index 1af104df9..ced8f4554 100644 --- a/hw/xwin/winmultiwindowclass.c +++ b/hw/xwin/winmultiwindowclass.c @@ -213,7 +213,7 @@ winMultiWindowGetWMNormalHints(WindowPtr pWin, WinXSizeHints * hints) } int -winMultiWindowGetTransientFor(WindowPtr pWin, WindowPtr *ppDaddy) +winMultiWindowGetTransientFor(WindowPtr pWin, Window *pDaddyId) { struct _Window *pwin; struct _Property *prop; @@ -230,13 +230,13 @@ winMultiWindowGetTransientFor(WindowPtr pWin, WindowPtr *ppDaddy) else prop = NULL; - if (ppDaddy) - *ppDaddy = NULL; + if (pDaddyId) + *pDaddyId = 0; while (prop) { if (prop->propertyName == XA_WM_TRANSIENT_FOR) { - if (ppDaddy) - memcpy(ppDaddy, prop->data, sizeof(WindowPtr)); + if (pDaddyId) + memcpy(pDaddyId, prop->data, sizeof(Window)); return 1; } else diff --git a/hw/xwin/winmultiwindowclass.h b/hw/xwin/winmultiwindowclass.h index 0e3465c78..3244f78e3 100644 --- a/hw/xwin/winmultiwindowclass.h +++ b/hw/xwin/winmultiwindowclass.h @@ -118,6 +118,6 @@ int winMultiWindowGetWMName(WindowPtr pWin, char **wmName); int - winMultiWindowGetTransientFor(WindowPtr pWin, WindowPtr *ppDaddy); + winMultiWindowGetTransientFor(WindowPtr pWin, Window *ppDaddy); #endif diff --git a/hw/xwin/winmultiwindowwindow.c b/hw/xwin/winmultiwindowwindow.c index 09481560c..dcbfaff72 100644 --- a/hw/xwin/winmultiwindowwindow.c +++ b/hw/xwin/winmultiwindowwindow.c @@ -486,7 +486,7 @@ winCreateWindowsWindow(WindowPtr pWin) winWindowPriv(pWin); winPrivScreenPtr pScreenPriv = pWinPriv->pScreenPriv; WinXSizeHints hints; - WindowPtr pDaddy; + Window daddyId; DWORD dwStyle, dwExStyle; RECT rc; @@ -516,10 +516,10 @@ winCreateWindowsWindow(WindowPtr pWin) winDebug("winCreateWindowsWindow - %dx%d @ %dx%d\n", iWidth, iHeight, iX, iY); - if (winMultiWindowGetTransientFor(pWin, &pDaddy)) { - if (pDaddy) { + if (winMultiWindowGetTransientFor(pWin, &daddyId)) { + if (daddyId) { hFore = GetForegroundWindow(); - if (hFore && (pDaddy != (WindowPtr) GetProp(hFore, WIN_WID_PROP))) + if (hFore && (daddyId != (Window) GetProp(hFore, WIN_WID_PROP))) hFore = NULL; } } From 689e7ad9b0fccd582cd63796cc90a999f141f589 Mon Sep 17 00:00:00 2001 From: Jon TURNEY Date: Sun, 31 Mar 2013 18:36:37 +0100 Subject: [PATCH 6/7] hw/xwin: Win32 Windows properties are of pointer type HANDLE, not an integer type Win32 Windows properties are of pointer type HANDLE, not an integer type, but we use the Windows property WINDOW_WID_PROP to store the X window XID. Add appropriate casts to show it doesn't matter that an XID is smaller than a pointer on 64-bit build. Signed-off-by: Jon TURNEY Reviewed-by: Colin Harrison --- hw/xwin/winmultiwindowwindow.c | 4 ++-- hw/xwin/winmultiwindowwndproc.c | 6 +++--- hw/xwin/winprefs.c | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/hw/xwin/winmultiwindowwindow.c b/hw/xwin/winmultiwindowwindow.c index dcbfaff72..44ad19302 100644 --- a/hw/xwin/winmultiwindowwindow.c +++ b/hw/xwin/winmultiwindowwindow.c @@ -519,7 +519,7 @@ winCreateWindowsWindow(WindowPtr pWin) if (winMultiWindowGetTransientFor(pWin, &daddyId)) { if (daddyId) { hFore = GetForegroundWindow(); - if (hFore && (daddyId != (Window) GetProp(hFore, WIN_WID_PROP))) + if (hFore && (daddyId != (Window) (INT_PTR) GetProp(hFore, WIN_WID_PROP))) hFore = NULL; } } @@ -593,7 +593,7 @@ winCreateWindowsWindow(WindowPtr pWin) /* Cause any .XWinrc menus to be added in main WNDPROC */ PostMessage(hWnd, WM_INIT_SYS_MENU, 0, 0); - SetProp(hWnd, WIN_WID_PROP, (HANDLE) winGetWindowID(pWin)); + SetProp(hWnd, WIN_WID_PROP, (HANDLE) (INT_PTR) winGetWindowID(pWin)); /* Flag that this Windows window handles its own activation */ SetProp(hWnd, WIN_NEEDMANAGE_PROP, (HANDLE) 0); diff --git a/hw/xwin/winmultiwindowwndproc.c b/hw/xwin/winmultiwindowwndproc.c index 0e46ea7fe..381818789 100644 --- a/hw/xwin/winmultiwindowwndproc.c +++ b/hw/xwin/winmultiwindowwndproc.c @@ -343,7 +343,7 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) /* */ wmMsg.msg = 0; wmMsg.hwndWindow = hwnd; - wmMsg.iWindow = (Window) GetProp(hwnd, WIN_WID_PROP); + wmMsg.iWindow = (Window) (INT_PTR) GetProp(hwnd, WIN_WID_PROP); wmMsg.iX = pDraw->x; wmMsg.iY = pDraw->y; @@ -391,8 +391,8 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) /* */ SetProp(hwnd, WIN_WID_PROP, - (HANDLE) winGetWindowID(((LPCREATESTRUCT) lParam)-> - lpCreateParams)); + (HANDLE) (INT_PTR) winGetWindowID(((LPCREATESTRUCT) lParam)-> + lpCreateParams)); /* * Make X windows' Z orders sync with Windows windows because diff --git a/hw/xwin/winprefs.c b/hw/xwin/winprefs.c index 05d8c874d..8936aae63 100644 --- a/hw/xwin/winprefs.c +++ b/hw/xwin/winprefs.c @@ -181,7 +181,7 @@ ReloadEnumWindowsProc(HWND hwnd, LPARAM lParam) wmMsg.msg = WM_WM_ICON_EVENT; wmMsg.hwndWindow = hwnd; - wmMsg.iWindow = (Window) GetProp(hwnd, WIN_WID_PROP); + wmMsg.iWindow = (Window) (INT_PTR) GetProp(hwnd, WIN_WID_PROP); winSendMessageToWM(s_pScreenPriv->pWMInfo, &wmMsg); } From 80054fcafb095aff76f6df00d348c7fd85e8ddbc Mon Sep 17 00:00:00 2001 From: Jon TURNEY Date: Sat, 30 Mar 2013 19:44:14 +0000 Subject: [PATCH 7/7] hw/xwin: Update manifest to target all architectures, not just x86 Update manifest to target all architectures, not just x86 Also: Write explicit dependencies for Xwin.rc. XWin.exe.manifest and X.ico are included the resource compiler output, so add a dependency on them to cause it to be recompiled if they change. Signed-off-by: Jon TURNEY Reviewed-by: Colin Harrison --- hw/xwin/Makefile.am | 2 ++ hw/xwin/XWin.exe.manifest | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/hw/xwin/Makefile.am b/hw/xwin/Makefile.am index 93ce57038..f13197592 100644 --- a/hw/xwin/Makefile.am +++ b/hw/xwin/Makefile.am @@ -160,6 +160,8 @@ XWin_LDFLAGS = -mwindows -static .rc.o: $(AM_V_GEN)$(WINDRES) --use-temp-file -i $< --input-format=rc -o $@ -O coff -I $(top_builddir)/include +XWin.o: XWin.rc XWin.exe.manifest X.ico + winprefsyacc.h: winprefsyacc.c winprefslex.c: winprefslex.l winprefsyacc.c winprefsyacc.h diff --git a/hw/xwin/XWin.exe.manifest b/hw/xwin/XWin.exe.manifest index a0d4d7dae..477334fb3 100755 --- a/hw/xwin/XWin.exe.manifest +++ b/hw/xwin/XWin.exe.manifest @@ -7,7 +7,7 @@ type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" - processorArchitecture="X86" + processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*" />