diff --git a/hw/xwin/winmultiwindowwm.c b/hw/xwin/winmultiwindowwm.c index 2d5ebc2f5..4745c7557 100644 --- a/hw/xwin/winmultiwindowwm.c +++ b/hw/xwin/winmultiwindowwm.c @@ -909,6 +909,7 @@ winMultiWindowWMProc(void *pArg) -- independently, the WM_TAKE_FOCUS protocol determines whether the WM should send a WM_TAKE_FOCUS ClientMessage. */ + if (pNode->msg.iWindow) { Bool neverFocus = FALSE; xcb_get_property_cookie_t cookie; @@ -922,7 +923,7 @@ winMultiWindowWMProc(void *pArg) } if (!neverFocus) - xcb_set_input_focus(pWMInfo->conn, XCB_INPUT_FOCUS_POINTER_ROOT, + xcb_set_input_focus(pWMInfo->conn, XCB_INPUT_FOCUS_PARENT, pNode->msg.iWindow, XCB_CURRENT_TIME); if (IsWmProtocolAvailable(pWMInfo, @@ -932,6 +933,13 @@ winMultiWindowWMProc(void *pArg) pNode->msg.iWindow, pWMInfo->atmWmProtos, pWMInfo->atmWmTakeFocus); + } + else + /* Set the input focus to none */ + { + xcb_set_input_focus(pWMInfo->conn, XCB_INPUT_FOCUS_NONE, + XCB_NONE, XCB_CURRENT_TIME); + } break; diff --git a/hw/xwin/winmultiwindowwndproc.c b/hw/xwin/winmultiwindowwndproc.c index edc1c0a03..1022a73c9 100644 --- a/hw/xwin/winmultiwindowwndproc.c +++ b/hw/xwin/winmultiwindowwndproc.c @@ -803,6 +803,16 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) /* Add the keyboard hook if possible */ if (g_fKeyboardHookLL) g_fKeyboardHookLL = winInstallKeyboardHookLL(); + + /* Tell our Window Manager thread to activate the window */ + if (fWMMsgInitialized) + { + wmMsg.msg = WM_WM_ACTIVATE; + /* don't focus override redirect windows (e.g. menus) */ + if (!pWin || !pWin->overrideRedirect) + winSendMessageToWM(s_pScreenPriv->pWMInfo, &wmMsg); + } + return 0; case WM_KILLFOCUS: @@ -812,9 +822,13 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) /* Remove our keyboard hook if it is installed */ winRemoveKeyboardHookLL(); - /* Revert the X focus as well, but only if the Windows focus is going to another window */ - if (!wParam && pWin) - DeleteWindowFromAnyEvents(pWin, FALSE); + /* Revert the X focus as well */ + if (fWMMsgInitialized) + { + wmMsg.msg = WM_WM_ACTIVATE; + wmMsg.iWindow = 0; + winSendMessageToWM(s_pScreenPriv->pWMInfo, &wmMsg); + } return 0; @@ -898,26 +912,8 @@ winTopLevelWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) /* Pass the message to the root window */ SendMessage(hwndScreen, message, wParam, lParam); - if (LOWORD(wParam) != WA_INACTIVE) { - /* Raise the window to the top in Z order */ - /* ago: Activate does not mean putting it to front! */ - /* - wmMsg.msg = WM_WM_RAISE; - if (fWMMsgInitialized) - winSendMessageToWM (s_pScreenPriv->pWMInfo, &wmMsg); - */ - - /* Tell our Window Manager thread to activate the window */ - wmMsg.msg = WM_WM_ACTIVATE; - if (fWMMsgInitialized) - if (!pWin || !pWin->overrideRedirect) /* for OOo menus */ - winSendMessageToWM(s_pScreenPriv->pWMInfo, &wmMsg); - } - /* Prevent the mouse wheel from stalling when another window is minimized */ - if (HIWORD(wParam) == 0 && LOWORD(wParam) == WA_ACTIVE && - (HWND) lParam != NULL && (HWND) lParam != GetParent(hwnd)) - SetFocus(hwnd); - return 0; + /* Allow DefWindowProc to SetFocus() as needed */ + break; case WM_ACTIVATEAPP: /*