Index: focus.c =================================================================== --- focus.c (revision 48114) +++ focus.c (working copy) @@ -69,7 +69,26 @@ return previous; } +/******************************************************************* +* can_activate_window +* +* Check if we can activate the specified window. +*/ +BOOL can_activate_window( HWND hwnd ) +{ + LONG style = GetWindowLongW( hwnd, GWL_STYLE ); + + if (style & WS_MINIMIZE) return FALSE; + if (!(style & WS_VISIBLE)) return FALSE; + + if ((style & (WS_POPUP|WS_CHILD)) == WS_CHILD) return FALSE; + if (GetWindowLongW( hwnd, GWL_EXSTYLE ) & WS_EX_NOACTIVATE) return FALSE; + + return !(style & WS_DISABLED); + +} + /******************************************************************* * set_active_window */ @@ -86,6 +105,11 @@ return TRUE; } + if (!IsWindow(hwnd)) return FALSE; + + /* Windows doesn't seem to return an error here */ + if (!can_activate_window(hwnd)) return GetActiveWindow(); + /* call CBT hook chain */ cbt.fMouse = mouse; cbt.hWndActive = previous; @@ -105,6 +129,7 @@ previous = wine_server_ptr_handle( reply->previous ); } SERVER_END_REQ; + if (!ret) return FALSE; if (prev) *prev = previous; if (previous == hwnd) return TRUE; @@ -115,7 +140,6 @@ if (SendMessageW( hwnd, WM_QUERYNEWPALETTE, 0, 0 )) SendMessageTimeoutW( HWND_BROADCAST, WM_PALETTEISCHANGING, (WPARAM)hwnd, 0, SMTO_ABORTIFHUNG, 2000, NULL ); - if (!IsWindow(hwnd)) return FALSE; } old_thread = previous ? GetWindowThreadProcessId( previous, NULL ) : 0;