Skip to content

Commit

Permalink
hw/xwin: Ensure full styling is applied when the window is mapped
Browse files Browse the repository at this point in the history
Move styling update code from WM_WM_HINTS_EVENT to a function UpdateStyle(),
which is also invoked from WM_WM_MAP3, so everything which needs to be done
to style the window happens when it is mapped

(Otherwise, the appearance of the window is sensitive to the timing of the
notification of the windows appearance hint properties being set relative to
window creation. e.g. see [1])

[1] http://sourceware.org/ml/cygwin-xfree/2012-06/msg00004.html

Signed-off-by: Jon TURNEY <[email protected]>
Reviewed-by: Colin Harrison <[email protected]>
  • Loading branch information
jon-turney committed Jan 16, 2013
1 parent ef61f8c commit c94d1cb
Showing 1 changed file with 28 additions and 20 deletions.
48 changes: 28 additions & 20 deletions hw/xwin/winmultiwindowwm.c
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,32 @@ UpdateIcon(WMInfoPtr pWMInfo, Window iWindow)
winUpdateIcon(hWnd, pWMInfo->pDisplay, iWindow, hIconNew);
}

/*
* Updates the style of a HWND according to its X style properties
*/

static void
UpdateStyle(WMInfoPtr pWMInfo, Window iWindow)
{
HWND hWnd;
HWND zstyle = HWND_NOTOPMOST;
UINT flags;

hWnd = getHwnd(pWMInfo, iWindow);
if (!hWnd)
return;

/* Determine the Window style, which determines borders and clipping region... */
winApplyHints(pWMInfo->pDisplay, iWindow, hWnd, &zstyle);
winUpdateWindowPosition(hWnd, &zstyle);

/* Apply the updated window style, without changing it's show or activation state */
flags = SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE;
if (zstyle == HWND_NOTOPMOST)
flags |= SWP_NOZORDER | SWP_NOOWNERZORDER;
SetWindowPos(hWnd, NULL, 0, 0, 0, 0, flags);
}

#if 0
/*
* Fix up any differences between the X11 and Win32 window stacks
Expand Down Expand Up @@ -737,13 +763,8 @@ winMultiWindowWMProc(void *pArg)
(unsigned char *) &(pNode->msg.hwndWindow), 1);
UpdateName(pWMInfo, pNode->msg.iWindow);
UpdateIcon(pWMInfo, pNode->msg.iWindow);
{
HWND zstyle = HWND_NOTOPMOST;
UpdateStyle(pWMInfo, pNode->msg.iWindow);

winApplyHints(pWMInfo->pDisplay, pNode->msg.iWindow,
pNode->msg.hwndWindow, &zstyle);
winUpdateWindowPosition(pNode->msg.hwndWindow, &zstyle);
}

/* Reshape */
{
Expand Down Expand Up @@ -815,27 +836,14 @@ winMultiWindowWMProc(void *pArg)

case WM_WM_HINTS_EVENT:
{
HWND zstyle = HWND_NOTOPMOST;
UINT flags;
XWindowAttributes attr;

/* Don't do anything if this is an override-redirect window */
XGetWindowAttributes (pWMInfo->pDisplay, pNode->msg.iWindow, &attr);
if (attr.override_redirect)
break;

pNode->msg.hwndWindow = getHwnd(pWMInfo, pNode->msg.iWindow);

/* Determine the Window style, which determines borders and clipping region... */
winApplyHints(pWMInfo->pDisplay, pNode->msg.iWindow,
pNode->msg.hwndWindow, &zstyle);
winUpdateWindowPosition(pNode->msg.hwndWindow, &zstyle);

/* Apply the updated window style, without changing it's show or activation state */
flags = SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE;
if (zstyle == HWND_NOTOPMOST)
flags |= SWP_NOZORDER | SWP_NOOWNERZORDER;
SetWindowPos(pNode->msg.hwndWindow, NULL, 0, 0, 0, 0, flags);
UpdateStyle(pWMInfo, pNode->msg.iWindow);
}
break;

Expand Down

0 comments on commit c94d1cb

Please sign in to comment.