From 6f4a48f8a55bc54b6d3e9d80734be05750c024de Mon Sep 17 00:00:00 2001 From: Jon TURNEY Date: Thu, 1 Apr 2010 15:08:26 +0100 Subject: [PATCH 01/12] hw/xwin: Bring the X screen window to the front on a single left-click on the tray icon Bring the X screen window to the front on a single left click on the tray icon, like the comment says we do Signed-off-by: Jon TURNEY Reviewed-by: Colin Harrison --- hw/xwin/wintrayicon.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/xwin/wintrayicon.c b/hw/xwin/wintrayicon.c index dbc47257b..f168b884a 100644 --- a/hw/xwin/wintrayicon.c +++ b/hw/xwin/wintrayicon.c @@ -114,7 +114,7 @@ winHandleIconMessage(HWND hwnd, UINT message, switch (lParam) { case WM_LBUTTONUP: /* Restack and bring all windows to top */ - SetForegroundWindow(hwnd); + SetForegroundWindow (pScreenPriv->hwndScreen); #ifdef XWIN_MULTIWINDOWEXTWM if (pScreenInfo->fMWExtWM) From e30e1ea98720acc583f34c830a1c1b7e3e88f694 Mon Sep 17 00:00:00 2001 From: Jon TURNEY Date: Mon, 17 Dec 2012 22:38:25 +0000 Subject: [PATCH 02/12] hw/xwin: Fix some comments in winkeybd.c Signed-off-by: Jon TURNEY Reviewed-by: Colin Harrison --- hw/xwin/winkeybd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hw/xwin/winkeybd.c b/hw/xwin/winkeybd.c index a70cdcd16..27c114c99 100644 --- a/hw/xwin/winkeybd.c +++ b/hw/xwin/winkeybd.c @@ -56,7 +56,7 @@ static void static void winKeybdCtrl(DeviceIntPtr pDevice, KeybdCtrl * pCtrl); -/* +/* * Translate a Windows WM_[SYS]KEY(UP/DOWN) message * into an ASCII scan code. * @@ -134,7 +134,7 @@ winKeybdCtrl(DeviceIntPtr pDevice, KeybdCtrl * pCtrl) { } -/* +/* * See Porting Layer Definition - p. 18 * winKeybdProc is known as a DeviceProc. */ @@ -509,8 +509,8 @@ winCheckKeyPressed(WPARAM wParam, LPARAM lParam) return FALSE; } -/* Only on shift release message is sent even if both are pressed. - * Fix this here +/* Only one shift release message is sent even if both are pressed. + * Fix this here */ void winFixShiftKeys(int iScanCode) From f57100bb36eae3b4d75f3c315973405f705b8de6 Mon Sep 17 00:00:00 2001 From: Jon TURNEY Date: Tue, 23 Feb 2010 13:38:48 +0000 Subject: [PATCH 03/12] hw/xwin: Process one Windows message per wakeup, rather than all of them. De-queuing Windows messages and X events happens in the same thread of execution. Draining the windows message queue can lead to the X event queue overflowing if lots of those windows messages cause X events (e.g. if a keyboard macro program has just dumped thousands of keypresses into the Windows message queue). See the mailing list thread [1] for more details. Processing one Windows message per wakeup, rather than all of them gives the X server a chance to do stuff as well after each message. [1] http://cygwin.com/ml/cygwin-xfree/2010-01/msg00056.html Signed-off-by: Jon TURNEY Reviewed-by: Colin Harrison --- hw/xwin/winblock.c | 32 ++++++++++++++++---------------- hw/xwin/winwakeup.c | 4 ++-- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/hw/xwin/winblock.c b/hw/xwin/winblock.c index a4ae8669f..c3ef4becd 100644 --- a/hw/xwin/winblock.c +++ b/hw/xwin/winblock.c @@ -42,14 +42,26 @@ winBlockHandler(ScreenPtr pScreen, #if defined(XWIN_CLIPBOARD) || defined(XWIN_MULTIWINDOW) winScreenPriv(pScreen); #endif - MSG msg; #ifndef HAS_DEVWINDOWS struct timeval **tvp = pTimeout; if (*tvp != NULL) { + if (GetQueueStatus(QS_ALLINPUT | QS_ALLPOSTMESSAGE) != 0) { + /* If there are still messages to process on the Windows message + queue, make sure select() just polls rather than blocking. + */ + (*tvp)->tv_sec = 0; + (*tvp)->tv_usec = 0; + } + else { + /* Otherwise, lacking /dev/windows, we must wake up again in + a reasonable time to check the Windows message queue. without + noticeable delay. + */ (*tvp)->tv_sec = 0; (*tvp)->tv_usec = 100; + } } #endif @@ -68,25 +80,13 @@ winBlockHandler(ScreenPtr pScreen, if (iReturn != 0) { ErrorF("winBlockHandler - pthread_mutex_unlock () failed: %d\n", iReturn); - goto winBlockHandler_ProcessMessages; } - - winDebug("winBlockHandler - pthread_mutex_unlock () returned\n"); + else { + winDebug("winBlockHandler - pthread_mutex_unlock () returned\n"); + } } - - winBlockHandler_ProcessMessages: #endif - /* Process all messages on our queue */ - while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { - if ((g_hDlgDepthChange == 0 - || !IsDialogMessage(g_hDlgDepthChange, &msg)) - && (g_hDlgExit == 0 || !IsDialogMessage(g_hDlgExit, &msg)) - && (g_hDlgAbout == 0 || !IsDialogMessage(g_hDlgAbout, &msg))) { - DispatchMessage(&msg); - } - } - /* At least one X client has asked to suspend the screensaver, so reset Windows' display idle timer diff --git a/hw/xwin/winwakeup.c b/hw/xwin/winwakeup.c index 77c160533..795221a1a 100644 --- a/hw/xwin/winwakeup.c +++ b/hw/xwin/winwakeup.c @@ -43,8 +43,8 @@ winWakeupHandler(ScreenPtr pScreen, { MSG msg; - /* Process all messages on our queue */ - while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { + /* Process one message from our queue */ + if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { if ((g_hDlgDepthChange == 0 || !IsDialogMessage(g_hDlgDepthChange, &msg)) && (g_hDlgExit == 0 || !IsDialogMessage(g_hDlgExit, &msg)) From a2037d7080ae64ea55f7d76971716346aa3ec6d3 Mon Sep 17 00:00:00 2001 From: Jon TURNEY Date: Wed, 28 Nov 2012 22:25:35 +0000 Subject: [PATCH 04/12] hw/xwin: Fix MinGW build of winSetAppModelID.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add missing #include In file included from /jhbuild/checkout/xorg/xserver/hw/xwin/winSetAppUserModelID.c:31:0: /jhbuild/checkout/xorg/xserver/hw/xwin/winwindow.h:140:11: error: expected declaration specifiers or ‘...’ before ‘pthread_t’ /jhbuild/checkout/xorg/xserver/hw/xwin/winwindow.h:141:11: error: expected declaration specifiers or ‘...’ before ‘pthread_t’ /jhbuild/checkout/xorg/xserver/hw/xwin/winwindow.h:142:11: error: expected declaration specifiers or ‘...’ before ‘pthread_mutex_t’ Signed-off-by: Jon TURNEY Reviewed-by: Colin Harrison --- hw/xwin/winSetAppUserModelID.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/xwin/winSetAppUserModelID.c b/hw/xwin/winSetAppUserModelID.c index ce9da5e7d..41615e19c 100644 --- a/hw/xwin/winSetAppUserModelID.c +++ b/hw/xwin/winSetAppUserModelID.c @@ -28,6 +28,7 @@ #include #include #include +#include #include "winwindow.h" #include "os.h" #include "winmsg.h" From ab686ce029208abf970a4bcd1435bf8411a44de9 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Wed, 26 Oct 2011 17:03:25 -0500 Subject: [PATCH 05/12] include: Add RELOCATE_PROJECTROOT to xwin-config.h header RELOCATE_PROJECTROOT is AC_DEFINED in configure.ac, but currently has no effect as it doesn't appear in any AC_CONFIG_HEADER header. When packaged for Windows, we do not have a unix-style filesystem tree, where file needed by the X server can be found in fixed, absolute paths under the prefix (PROJECTROOT). Instead, the filesystem tree containing files needed by the X server and clients will be installed with the directory containing the X server executable as the root directory of that tree. (Typically, this will be in the Program Files directory, which does not have a fixed name, as it can be moved, localized, or added to to indicate x86 or x64 binaries) So, RELOCATE_PROJECTROOT is used to make a native Windows build of the X server look for various files (fonts, xkb data) in locations relative to the X server rather than at absolute paths, by translating those paths at run-time. Additionally the XKEYSYMDB, XERRORDB, XLOCALEDIR env vars checked by libX11 are set appropriately for clients started by the X server. Signed-off-by: Ryan Pavlik Reviewed-by: Jon TURNEY Reviewed-by: Colin Harrison --- include/xwin-config.h.in | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/xwin-config.h.in b/include/xwin-config.h.in index 8122f5543..c5119f268 100644 --- a/include/xwin-config.h.in +++ b/include/xwin-config.h.in @@ -31,3 +31,6 @@ /* Default log location */ #undef DEFAULT_LOGDIR + +/* Whether we should re-locate the root to where the executable lives */ +#undef RELOCATE_PROJECTROOT From 852d1fb042f4160fe023a015f1c9a34126bf911a Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Sat, 1 Dec 2012 16:58:40 +0000 Subject: [PATCH 06/12] hw/xwin: Add missing include xwin-config.h to winglobals.h winglobals.h checks if RELOCATE_PROJECTROOT is defined to see if a declaration of g_fLogFileChanged is needed, so must include xwin-config.h Signed-off-by: Ryan Pavlik Reviewed-by: Jon TURNEY Reviewed-by: Colin Harrison --- hw/xwin/winglobals.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/xwin/winglobals.h b/hw/xwin/winglobals.h index 2edf9571e..d2e2ba2b4 100644 --- a/hw/xwin/winglobals.h +++ b/hw/xwin/winglobals.h @@ -26,6 +26,10 @@ #ifndef WINGLOBALS_H #define WINGLOBALS_H +#ifdef HAVE_XWIN_CONFIG_H +#include +#endif + /* * References to external symbols */ From 066ecbd11d516ea68d7ebc7470232d01c5717546 Mon Sep 17 00:00:00 2001 From: Jon TURNEY Date: Thu, 10 Jan 2013 14:37:45 +0000 Subject: [PATCH 07/12] hw/xwin: Move reshape code from winUpdateWindowPosition() to the map event handler Move reshape code, which was only used when handling a map event, from winUpdateWindowPosition(), to put it explicitly in the map event handler. Remove 'reshape' parameter from winUpdatePosition(). (Note that there's no handling of the ShapeNotify event to notice when the window shape changes, instead we hook the screen SetShape procedure and reshape the native window then) Signed-off-by: Jon TURNEY Reviewed-by: Colin Harrison --- hw/xwin/winmultiwindowwm.c | 21 ++++++++++++++------- hw/xwin/winmultiwindowwndproc.c | 4 ++-- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/hw/xwin/winmultiwindowwm.c b/hw/xwin/winmultiwindowwm.c index 773fc9767..feefcf4df 100644 --- a/hw/xwin/winmultiwindowwm.c +++ b/hw/xwin/winmultiwindowwm.c @@ -186,7 +186,7 @@ static void winApplyHints(Display * pDisplay, Window iWindow, HWND hWnd, HWND * zstyle); void - winUpdateWindowPosition(HWND hWnd, Bool reshape, HWND * zstyle); + winUpdateWindowPosition(HWND hWnd, HWND * zstyle); /* * Local globals @@ -742,8 +742,19 @@ winMultiWindowWMProc(void *pArg) winApplyHints(pWMInfo->pDisplay, pNode->msg.iWindow, pNode->msg.hwndWindow, &zstyle); - winUpdateWindowPosition(pNode->msg.hwndWindow, TRUE, &zstyle); + winUpdateWindowPosition(pNode->msg.hwndWindow, &zstyle); } + + /* Reshape */ + { + WindowPtr pWin = + GetProp(pNode->msg.hwndWindow, WIN_WINDOW_PROP); + if (pWin) { + winReshapeMultiWindow(pWin); + winUpdateRgnMultiWindow(pWin); + } + } + break; case WM_WM_UNMAP: @@ -1749,7 +1760,7 @@ winApplyHints(Display * pDisplay, Window iWindow, HWND hWnd, HWND * zstyle) } void -winUpdateWindowPosition(HWND hWnd, Bool reshape, HWND * zstyle) +winUpdateWindowPosition(HWND hWnd, HWND * zstyle) { int iX, iY, iWidth, iHeight; int iDx, iDy; @@ -1800,8 +1811,4 @@ winUpdateWindowPosition(HWND hWnd, Bool reshape, HWND * zstyle) SetWindowPos(hWnd, *zstyle, rcNew.left, rcNew.top, rcNew.right - rcNew.left, rcNew.bottom - rcNew.top, 0); - if (reshape) { - winReshapeMultiWindow(pWin); - winUpdateRgnMultiWindow(pWin); - } } diff --git a/hw/xwin/winmultiwindowwndproc.c b/hw/xwin/winmultiwindowwndproc.c index c2292c661..f7c6f2be6 100644 --- a/hw/xwin/winmultiwindowwndproc.c +++ b/hw/xwin/winmultiwindowwndproc.c @@ -42,7 +42,7 @@ #include "winmsg.h" #include "inputstr.h" -extern void winUpdateWindowPosition(HWND hWnd, Bool reshape, HWND * zstyle); +extern void winUpdateWindowPosition(HWND hWnd, HWND * zstyle); /* * Local globals @@ -891,7 +891,7 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) WS_CLIPCHILDREN | WS_CLIPSIBLINGS) & ~WS_CAPTION & ~WS_SIZEBOX); - winUpdateWindowPosition(hwnd, FALSE, &zstyle); + winUpdateWindowPosition(hwnd, &zstyle); { WinXWMHints hints; From 3628559e594fcbdfcc14b1e8fa60aa841f184e19 Mon Sep 17 00:00:00 2001 From: Jon TURNEY Date: Sun, 5 Feb 2012 11:25:39 +0000 Subject: [PATCH 08/12] hw/xwin: Add a new WM_WM_HINTS_EVENT event to update window style Add a new WM_WM_HINTS_EVENT event to update window style if any of the properties which affect window style change Check PropertyNotify events for any of the window properties which we consider to decide on the window style, and update the window style by sending a WM_WM_HINTS_EVENT message to the WM. This allows the styling of the window to change during it's lifetime. Signed-off-by: Jon TURNEY Reviewed-by: Colin Harrison --- hw/xwin/winmultiwindowwm.c | 59 +++++++++++++++++++++++++++++++++----- hw/xwin/winwindow.h | 1 + 2 files changed, 53 insertions(+), 7 deletions(-) diff --git a/hw/xwin/winmultiwindowwm.c b/hw/xwin/winmultiwindowwm.c index feefcf4df..12002430b 100644 --- a/hw/xwin/winmultiwindowwm.c +++ b/hw/xwin/winmultiwindowwm.c @@ -813,6 +813,26 @@ winMultiWindowWMProc(void *pArg) UpdateIcon(pWMInfo, pNode->msg.iWindow); break; + case WM_WM_HINTS_EVENT: + { + HWND zstyle = HWND_NOTOPMOST; + UINT flags; + + 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); + } + break; + case WM_WM_CHANGE_STATE: /* Minimize the window in Windows */ winMinimizeWindow(pNode->msg.iWindow); @@ -862,6 +882,7 @@ winMultiWindowXMsgProc(void *pArg) Atom atmWmHints; Atom atmWmChange; Atom atmNetWmIcon; + Atom atmWindowState, atmMotifWmHints, atmWindowType, atmNormalHints; int iReturn; XIconSize *xis; @@ -988,6 +1009,10 @@ winMultiWindowXMsgProc(void *pArg) atmWmHints = XInternAtom(pProcArg->pDisplay, "WM_HINTS", False); atmWmChange = XInternAtom(pProcArg->pDisplay, "WM_CHANGE_STATE", False); atmNetWmIcon = XInternAtom(pProcArg->pDisplay, "_NET_WM_ICON", False); + atmWindowState = XInternAtom(pProcArg->pDisplay, "_NET_WM_STATE", False); + atmMotifWmHints = XInternAtom(pProcArg->pDisplay, "_MOTIF_WM_HINTS", False); + atmWindowType = XInternAtom(pProcArg->pDisplay, "_NET_WM_WINDOW_TYPE", False); + atmNormalHints = XInternAtom(pProcArg->pDisplay, "WM_NORMAL_HINTS", False); /* iiimxcf had a bug until 2009-04-27, assuming that the @@ -1125,14 +1150,34 @@ winMultiWindowXMsgProc(void *pArg) /* Other fields ignored */ winSendMessageToWM(pProcArg->pWMInfo, &msg); } - else if ((event.xproperty.atom == atmWmHints) || - (event.xproperty.atom == atmNetWmIcon)) { - memset(&msg, 0, sizeof(msg)); - msg.msg = WM_WM_ICON_EVENT; - msg.iWindow = event.xproperty.window; + else { + /* + Several properties are considered for WM hints, check if this property change affects any of them... + (this list needs to be kept in sync with winApplyHints()) + */ + if ((event.xproperty.atom == atmWmHints) || + (event.xproperty.atom == atmWindowState) || + (event.xproperty.atom == atmMotifWmHints) || + (event.xproperty.atom == atmWindowType) || + (event.xproperty.atom == atmNormalHints)) { + memset(&msg, 0, sizeof(msg)); + msg.msg = WM_WM_HINTS_EVENT; + msg.iWindow = event.xproperty.window; - /* Other fields ignored */ - winSendMessageToWM(pProcArg->pWMInfo, &msg); + /* Other fields ignored */ + winSendMessageToWM(pProcArg->pWMInfo, &msg); + } + + /* Not an else as WM_HINTS affects both style and icon */ + if ((event.xproperty.atom == atmWmHints) || + (event.xproperty.atom == atmNetWmIcon)) { + memset(&msg, 0, sizeof(msg)); + msg.msg = WM_WM_ICON_EVENT; + msg.iWindow = event.xproperty.window; + + /* Other fields ignored */ + winSendMessageToWM(pProcArg->pWMInfo, &msg); + } } } else if (event.type == ClientMessage diff --git a/hw/xwin/winwindow.h b/hw/xwin/winwindow.h index 37b975224..25826ecc7 100644 --- a/hw/xwin/winwindow.h +++ b/hw/xwin/winwindow.h @@ -110,6 +110,7 @@ typedef struct _winWMMessageRec { #define WM_WM_CHANGE_STATE (WM_USER + 11) #define WM_WM_MAP2 (WM_USER + 12) #define WM_WM_MAP3 (WM_USER + 13) +#define WM_WM_HINTS_EVENT (WM_USER + 14) #define WM_MANAGE (WM_USER + 100) #define WM_UNMANAGE (WM_USER + 102) From ef61f8cacc84080c9156675f9ce26a27e8a90ac1 Mon Sep 17 00:00:00 2001 From: Jon TURNEY Date: Sat, 31 Mar 2012 18:45:28 +0100 Subject: [PATCH 09/12] hw/xwin: Make sure that WM_WM_HINTS_EVENT does nothing for override-redirect windows Future work: It looks like this code could be rationalized quite a lot: It might make sense to pull the checking for override-redirect up out of UpdateIcon() and UpdateName() and consolidate WM_WM_MAP2 and WM_WM_MAP3 Signed-off-by: Jon TURNEY Reviewed-by: Colin Harrison --- hw/xwin/winmultiwindowwm.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/xwin/winmultiwindowwm.c b/hw/xwin/winmultiwindowwm.c index 12002430b..1dc31fd0a 100644 --- a/hw/xwin/winmultiwindowwm.c +++ b/hw/xwin/winmultiwindowwm.c @@ -817,6 +817,12 @@ winMultiWindowWMProc(void *pArg) { 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); From c94d1cb0a49106f44714f4511720a197cc549164 Mon Sep 17 00:00:00 2001 From: Jon TURNEY Date: Thu, 10 Jan 2013 14:35:56 +0000 Subject: [PATCH 10/12] hw/xwin: Ensure full styling is applied when the window is mapped 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 Reviewed-by: Colin Harrison --- hw/xwin/winmultiwindowwm.c | 48 ++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 20 deletions(-) diff --git a/hw/xwin/winmultiwindowwm.c b/hw/xwin/winmultiwindowwm.c index 1dc31fd0a..0c6b09abb 100644 --- a/hw/xwin/winmultiwindowwm.c +++ b/hw/xwin/winmultiwindowwm.c @@ -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 @@ -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 */ { @@ -815,8 +836,6 @@ 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 */ @@ -824,18 +843,7 @@ winMultiWindowWMProc(void *pArg) 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; From 56e94403f8f9182e05428d895a983371c7737d2a Mon Sep 17 00:00:00 2001 From: Jon TURNEY Date: Wed, 9 Jan 2013 20:15:01 +0000 Subject: [PATCH 11/12] hw/xwin: Use ITaskBarList interface to ensure show-on-taskbar state is updated correctly Use ITaskBarList interface to ensure that the taskbar notices if the window has changed it's style in a way which affects if the taskbar shows it or not. Signed-off-by: Jon TURNEY Reviewed-by: Colin Harrison --- hw/xwin/winmultiwindowwm.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/hw/xwin/winmultiwindowwm.c b/hw/xwin/winmultiwindowwm.c index 0c6b09abb..4f6dec78b 100644 --- a/hw/xwin/winmultiwindowwm.c +++ b/hw/xwin/winmultiwindowwm.c @@ -614,6 +614,19 @@ UpdateStyle(WMInfoPtr pWMInfo, Window iWindow) if (zstyle == HWND_NOTOPMOST) flags |= SWP_NOZORDER | SWP_NOOWNERZORDER; SetWindowPos(hWnd, NULL, 0, 0, 0, 0, flags); + + /* + Use the WS_EX_TOOLWINDOW style to remove window from Alt-Tab window switcher + + According to MSDN, this is supposed to remove the window from the taskbar as well, + if we SW_HIDE before changing the style followed by SW_SHOW afterwards. + + But that doesn't seem to work reliably, and causes the window to flicker, so use + the iTaskbarList interface to tell the taskbar to show or hide this window. + */ + winShowWindowOnTaskbar(hWnd, + (GetWindowLongPtr(hWnd, GWL_EXSTYLE) & + WS_EX_APPWINDOW) ? TRUE : FALSE); } #if 0 From d6dcde7a03bb38c17ffc4ec5f0ca1c161e54569f Mon Sep 17 00:00:00 2001 From: Jon TURNEY Date: Sat, 11 Feb 2012 12:22:17 +0000 Subject: [PATCH 12/12] hw/xwin: Stop assuming WS_EX_APPWINDOW style in WM_SHOWWINDOW Signed-off-by: Jon TURNEY Reviewed-by: Colin Harrison --- hw/xwin/winmultiwindowwndproc.c | 53 +++++++++++++++------------------ 1 file changed, 24 insertions(+), 29 deletions(-) diff --git a/hw/xwin/winmultiwindowwndproc.c b/hw/xwin/winmultiwindowwndproc.c index f7c6f2be6..0e46ea7fe 100644 --- a/hw/xwin/winmultiwindowwndproc.c +++ b/hw/xwin/winmultiwindowwndproc.c @@ -870,41 +870,36 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) /* */ if (!pWin->overrideRedirect) { + HWND zstyle = HWND_NOTOPMOST; + /* Flag that this window needs to be made active when clicked */ SetProp(hwnd, WIN_NEEDMANAGE_PROP, (HANDLE) 1); - if (!(GetWindowLongPtr(hwnd, GWL_EXSTYLE) & WS_EX_APPWINDOW)) { - HWND zstyle = HWND_NOTOPMOST; + /* Set the transient style flags */ + if (GetParent(hwnd)) + SetWindowLongPtr(hwnd, GWL_STYLE, + WS_POPUP | WS_OVERLAPPED | WS_SYSMENU | + WS_CLIPCHILDREN | WS_CLIPSIBLINGS); + /* Set the window standard style flags */ + else + SetWindowLongPtr(hwnd, GWL_STYLE, + (WS_POPUP | WS_OVERLAPPEDWINDOW | + WS_CLIPCHILDREN | WS_CLIPSIBLINGS) + & ~WS_CAPTION & ~WS_SIZEBOX); - /* Set the window extended style flags */ - SetWindowLongPtr(hwnd, GWL_EXSTYLE, WS_EX_APPWINDOW); + winUpdateWindowPosition(hwnd, &zstyle); - /* Set the transient style flags */ - if (GetParent(hwnd)) - SetWindowLongPtr(hwnd, GWL_STYLE, - WS_POPUP | WS_OVERLAPPED | WS_SYSMENU | - WS_CLIPCHILDREN | WS_CLIPSIBLINGS); - /* Set the window standard style flags */ - else - SetWindowLongPtr(hwnd, GWL_STYLE, - (WS_POPUP | WS_OVERLAPPEDWINDOW | - WS_CLIPCHILDREN | WS_CLIPSIBLINGS) - & ~WS_CAPTION & ~WS_SIZEBOX); + { + WinXWMHints hints; - winUpdateWindowPosition(hwnd, &zstyle); - - { - WinXWMHints hints; - - if (winMultiWindowGetWMHints(pWin, &hints)) { - /* - Give the window focus, unless it has an InputHint - which is FALSE (this is used by e.g. glean to - avoid every test window grabbing the focus) - */ - if (!((hints.flags & InputHint) && (!hints.input))) { - SetForegroundWindow(hwnd); - } + if (winMultiWindowGetWMHints(pWin, &hints)) { + /* + Give the window focus, unless it has an InputHint + which is FALSE (this is used by e.g. glean to + avoid every test window grabbing the focus) + */ + if (!((hints.flags & InputHint) && (!hints.input))) { + SetForegroundWindow(hwnd); } } }