diff options
author | Jon TURNEY <jon.turney@dronecode.org.uk> | 2012-07-05 18:00:06 +0100 |
---|---|---|
committer | Jon TURNEY <jon.turney@dronecode.org.uk> | 2012-07-16 13:55:49 +0100 |
commit | c98471fad7d85fc9d9959b1c48edd90415f7bf15 (patch) | |
tree | 4eac8730788f110a68dee0bc129772e61d1a3a2e | |
parent | df7636dddb4981e14ee7d128c43bb08bdf6a8727 (diff) |
hw/xwin: Consolidate duplicated code as getHwnd() function
Consolidate code to find the native HWND of an X window, stored in the _WINDOWSWM_NATIVE_HWND
property, duplicated in UpdateName() and PreserveWin32Stack() as getHwnd()
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Reviewed-by: Colin Harrison <colin.harrison@virgin.net>
-rw-r--r-- | hw/xwin/winmultiwindowwm.c | 63 |
1 files changed, 33 insertions, 30 deletions
diff --git a/hw/xwin/winmultiwindowwm.c b/hw/xwin/winmultiwindowwm.c index 66ced75c4..76b46837c 100644 --- a/hw/xwin/winmultiwindowwm.c +++ b/hw/xwin/winmultiwindowwm.c @@ -477,23 +477,23 @@ SendXMessage(Display * pDisplay, Window iWin, Atom atmType, long nData) } /* - * Updates the name of a HWND according to its X WM_NAME property + * See if we can get the stored HWND for this window... */ - -static void -UpdateName(WMInfoPtr pWMInfo, Window iWindow) +static HWND +getHwnd(WMInfoPtr pWMInfo, Window iWindow) { - wchar_t *pszName; Atom atmType; int fmtRet; unsigned long items, remain; - HWND *retHwnd, hWnd; - XWindowAttributes attr; - - hWnd = 0; - - /* See if we can get the cached HWND for this window... */ - if (XGetWindowProperty(pWMInfo->pDisplay, iWindow, pWMInfo->atmPrivMap, 0, 1, False, XA_INTEGER, //pWMInfo->atmPrivMap, + HWND *retHwnd, hWnd = NULL; + + if (XGetWindowProperty(pWMInfo->pDisplay, + iWindow, + pWMInfo->atmPrivMap, + 0, + 1, + False, + XA_INTEGER, &atmType, &fmtRet, &items, @@ -506,8 +506,26 @@ UpdateName(WMInfoPtr pWMInfo, Window iWindow) /* Some sanity checks */ if (!hWnd) - return; + return NULL; if (!IsWindow(hWnd)) + return NULL; + + return hWnd; +} + +/* + * Updates the name of a HWND according to its X WM_NAME property + */ + +static void +UpdateName(WMInfoPtr pWMInfo, Window iWindow) +{ + wchar_t *pszName; + HWND hWnd; + XWindowAttributes attr; + + hWnd = getHwnd(pWMInfo, iWindow); + if (!hWnd) return; /* Set the Windows window name */ @@ -532,27 +550,12 @@ UpdateName(WMInfoPtr pWMInfo, Window iWindow) static void PreserveWin32Stack(WMInfoPtr pWMInfo, Window iWindow, UINT direction) { - Atom atmType; - int fmtRet; - unsigned long items, remain; - HWND hWnd, *retHwnd; + HWND hWnd; DWORD myWinProcID, winProcID; Window xWindow; WINDOWPLACEMENT wndPlace; - hWnd = NULL; - /* See if we can get the cached HWND for this window... */ - if (XGetWindowProperty(pWMInfo->pDisplay, iWindow, pWMInfo->atmPrivMap, 0, 1, False, XA_INTEGER, //pWMInfo->atmPrivMap, - &atmType, - &fmtRet, - &items, - &remain, (unsigned char **) &retHwnd) == Success) { - if (retHwnd) { - hWnd = *retHwnd; - XFree(retHwnd); - } - } - + hWnd = getHwnd(pWMInfo, iWindow); if (!hWnd) return; |