From 1d1bc017207971b309e8a0b3924ea42afaf6ee14 Mon Sep 17 00:00:00 2001 From: Jon TURNEY Date: Thu, 1 Aug 2013 16:04:03 +0100 Subject: Undefine _XSERVER64 in multiwindow WM Undefine _XSERVER64 in multiwindow WM, so client code can build correctly on x86_64. Move winUpdateWindowPosition() to winmultwindowproc.c, as it needs to access the server Drawable structure correctly, which uses affected types. This supersedes "Bodge around issues with XSendEvent()" needed to get the WM_KILL message ClientMessage sent correctly (We still play a dangerous game with bringing the WindowPtr type into scope so we can use it in window shaping code to access the server's shape data. This would be better rewritten as client code using ShapeNotify and XShapeGetRectangles()) --- hw/xwin/winmultiwindowwm.c | 90 +++++------------------------------------ hw/xwin/winmultiwindowwndproc.c | 54 +++++++++++++++++++++++++ hw/xwin/winprefs.h | 3 -- 3 files changed, 65 insertions(+), 82 deletions(-) diff --git a/hw/xwin/winmultiwindowwm.c b/hw/xwin/winmultiwindowwm.c index 7b44a7384..ab096c8fa 100644 --- a/hw/xwin/winmultiwindowwm.c +++ b/hw/xwin/winmultiwindowwm.c @@ -38,6 +38,16 @@ #ifdef HAVE_XWIN_CONFIG_H #include #endif + +/* + * Including any server header might define the macro _XSERVER64 on 64 bit machines. + * That macro must _NOT_ be defined for Xlib client code, otherwise bad things happen. + * So let's undef that macro if necessary. + */ +#ifdef _XSERVER64 +#undef _XSERVER64 +#endif + #include #include #include @@ -61,8 +71,6 @@ #include "winwindow.h" #include "winprefs.h" #include "window.h" -#include "pixmapstr.h" -#include "windowstr.h" #include "winglobals.h" #include "winmultiwindowicons.h" @@ -84,6 +92,7 @@ extern void winUpdateRgnMultiWindow(WindowPtr pWin); extern void winUpdateIcon(HWND hWnd, Display * pDisplay, Window id, HICON hIconNew); extern void winSetAuthorization(void); extern void winGetDisplayName(char *szDisplay, unsigned int screen); +extern void winUpdateWindowPosition(HWND hWnd, HWND * zstyle); #ifndef CYGDEBUG #define CYGDEBUG NO @@ -204,9 +213,6 @@ static void static void winApplyHints(Display * pDisplay, Window iWindow, HWND hWnd, HWND * zstyle); -void - winUpdateWindowPosition(HWND hWnd, HWND * zstyle); - /* * Local globals */ @@ -536,27 +542,7 @@ IsWmProtocolAvailable(Display * pDisplay, Window iWindow, Atom atmProtocol) static int SendXMessage(Display * pDisplay, Window iWin, Atom atmType, long nData) { -#ifdef __x86_64__ - union { - int type; - struct { - int type; - unsigned long serial; - Bool send_event; - Display *display; - unsigned long window; - unsigned long message_type; - int format; - union { - char b[20]; - short s[10]; - long l[5]; - } data; - } xclient; - } e; -#else XEvent e; -#endif /* Prepare the X event structure */ memset(&e, 0, sizeof(e)); @@ -1986,57 +1972,3 @@ winApplyHints(Display * pDisplay, Window iWindow, HWND hWnd, HWND * zstyle) ("winApplyHints: iWindow 0x%08x hints 0x%08x style 0x%08x exstyle 0x%08x\n", iWindow, hint, style, exStyle); } - -void -winUpdateWindowPosition(HWND hWnd, HWND * zstyle) -{ - int iX, iY, iWidth, iHeight; - int iDx, iDy; - RECT rcNew; - WindowPtr pWin = GetProp(hWnd, WIN_WINDOW_PROP); - DrawablePtr pDraw = NULL; - - if (!pWin) - return; - pDraw = &pWin->drawable; - if (!pDraw) - return; - - /* Get the X and Y location of the X window */ - iX = pWin->drawable.x + GetSystemMetrics(SM_XVIRTUALSCREEN); - iY = pWin->drawable.y + GetSystemMetrics(SM_YVIRTUALSCREEN); - - /* Get the height and width of the X window */ - iWidth = pWin->drawable.width; - iHeight = pWin->drawable.height; - - /* Setup a rectangle with the X window position and size */ - SetRect(&rcNew, iX, iY, iX + iWidth, iY + iHeight); - - winDebug("winUpdateWindowPosition - drawable extent (%d, %d)-(%d, %d)\n", - rcNew.left, rcNew.top, rcNew.right, rcNew.bottom); - - AdjustWindowRectEx(&rcNew, GetWindowLongPtr(hWnd, GWL_STYLE), FALSE, - GetWindowLongPtr(hWnd, GWL_EXSTYLE)); - - /* Don't allow window decoration to disappear off to top-left as a result of this adjustment */ - if (rcNew.left < GetSystemMetrics(SM_XVIRTUALSCREEN)) { - iDx = GetSystemMetrics(SM_XVIRTUALSCREEN) - rcNew.left; - rcNew.left += iDx; - rcNew.right += iDx; - } - - if (rcNew.top < GetSystemMetrics(SM_YVIRTUALSCREEN)) { - iDy = GetSystemMetrics(SM_YVIRTUALSCREEN) - rcNew.top; - rcNew.top += iDy; - rcNew.bottom += iDy; - } - - winDebug("winUpdateWindowPosition - Window extent (%d, %d)-(%d, %d)\n", - rcNew.left, rcNew.top, rcNew.right, rcNew.bottom); - - /* Position the Windows window */ - SetWindowPos(hWnd, *zstyle, rcNew.left, rcNew.top, - rcNew.right - rcNew.left, rcNew.bottom - rcNew.top, 0); - -} diff --git a/hw/xwin/winmultiwindowwndproc.c b/hw/xwin/winmultiwindowwndproc.c index 502292d10..3a0076a7b 100644 --- a/hw/xwin/winmultiwindowwndproc.c +++ b/hw/xwin/winmultiwindowwndproc.c @@ -1197,3 +1197,57 @@ winChildWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) return DefWindowProc(hwnd, message, wParam, lParam); } + +void +winUpdateWindowPosition(HWND hWnd, HWND * zstyle) +{ + int iX, iY, iWidth, iHeight; + int iDx, iDy; + RECT rcNew; + WindowPtr pWin = GetProp(hWnd, WIN_WINDOW_PROP); + DrawablePtr pDraw = NULL; + + if (!pWin) + return; + pDraw = &pWin->drawable; + if (!pDraw) + return; + + /* Get the X and Y location of the X window */ + iX = pWin->drawable.x + GetSystemMetrics(SM_XVIRTUALSCREEN); + iY = pWin->drawable.y + GetSystemMetrics(SM_YVIRTUALSCREEN); + + /* Get the height and width of the X window */ + iWidth = pWin->drawable.width; + iHeight = pWin->drawable.height; + + /* Setup a rectangle with the X window position and size */ + SetRect(&rcNew, iX, iY, iX + iWidth, iY + iHeight); + + winDebug("winUpdateWindowPosition - drawable extent (%d, %d)-(%d, %d)\n", + rcNew.left, rcNew.top, rcNew.right, rcNew.bottom); + + AdjustWindowRectEx(&rcNew, GetWindowLongPtr(hWnd, GWL_STYLE), FALSE, + GetWindowLongPtr(hWnd, GWL_EXSTYLE)); + + /* Don't allow window decoration to disappear off to top-left as a result of this adjustment */ + if (rcNew.left < GetSystemMetrics(SM_XVIRTUALSCREEN)) { + iDx = GetSystemMetrics(SM_XVIRTUALSCREEN) - rcNew.left; + rcNew.left += iDx; + rcNew.right += iDx; + } + + if (rcNew.top < GetSystemMetrics(SM_YVIRTUALSCREEN)) { + iDy = GetSystemMetrics(SM_YVIRTUALSCREEN) - rcNew.top; + rcNew.top += iDy; + rcNew.bottom += iDy; + } + + winDebug("winUpdateWindowPosition - Window extent (%d, %d)-(%d, %d)\n", + rcNew.left, rcNew.top, rcNew.right, rcNew.bottom); + + /* Position the Windows window */ + SetWindowPos(hWnd, *zstyle, rcNew.left, rcNew.top, + rcNew.right - rcNew.left, rcNew.bottom - rcNew.top, 0); + +} diff --git a/hw/xwin/winprefs.h b/hw/xwin/winprefs.h index a4a6e7eec..352ae3a88 100644 --- a/hw/xwin/winprefs.h +++ b/hw/xwin/winprefs.h @@ -34,9 +34,6 @@ /* Need Bool */ #include -/* Need TRUE */ -#include "misc.h" - /* Need to know how long paths can be... */ #include /* Xwindows redefines PATH_MAX to at least 1024 */ -- cgit v1.2.3 From 8d9ffa6d6a2354993500110bb8500f7ef219cb28 Mon Sep 17 00:00:00 2001 From: Jon TURNEY Date: Fri, 2 Aug 2013 18:19:22 +0100 Subject: Fix ARGB cursor conversion on x86_64 Fix erroneous use of unsigned long * for lpBits in winXCursorToHCURSOR() which leads to ARGB cursors being horizontally streched by a factor of two on x86_64. --- hw/xwin/wmutil/cursor_convert.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/hw/xwin/wmutil/cursor_convert.c b/hw/xwin/wmutil/cursor_convert.c index 727d83813..157e3a4ea 100644 --- a/hw/xwin/wmutil/cursor_convert.c +++ b/hw/xwin/wmutil/cursor_convert.c @@ -84,7 +84,7 @@ winXCursorToHCURSOR(WMUTIL_CURSOR *pCursor) HDC hDC; BITMAPV4HEADER bi; BITMAPINFO *pbmi; - unsigned long *lpBits; + uint32_t *lpBits; int sm_cx = GetSystemMetrics(SM_CXCURSOR); int sm_cy = GetSystemMetrics(SM_CYCURSOR); @@ -144,15 +144,14 @@ winXCursorToHCURSOR(WMUTIL_CURSOR *pCursor) bi.bV4AlphaMask = 0xFF000000; lpBits = - (unsigned long *) calloc(sm_cx * + (uint32_t *) calloc(sm_cx * sm_cy, - sizeof(unsigned long)); + sizeof(uint32_t)); if (lpBits) { int y; for (y = 0; y < nCY; y++) { - unsigned long *src, *dst; - + void *src, *dst; src = &(pCursor->argb[y * pCursor->width]); dst = &(lpBits[y * sm_cx]); memcpy(dst, src, 4 * nCX); @@ -231,7 +230,7 @@ winXCursorToHCURSOR(WMUTIL_CURSOR *pCursor) pbmiColors[2].rgbReserved = 0; lpBits = - (unsigned long *) calloc(sm_cx * + (uint32_t *) calloc(sm_cx * sm_cy, sizeof(char)); pCur = (unsigned char *) lpBits; -- cgit v1.2.3