| Newsgroups |
gmane.comp.emulators.winex.cvs |
| Message-ID |
<[email protected]> |
Subject: winex/windows winpos.c,1.11,1.12Update of /var/lib/cvsd/cvsroot/winex/windows
In directory agravaine:/tmp/cvs-serv6906/windows
Modified Files:
winpos.c
Log Message:
- ensure the two parts of SetForegroundWindow() are run by the appropriate window threads
Index: winpos.c
===================================================================
RCS file: /var/lib/cvsd/cvsroot/winex/windows/winpos.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- winpos.c 28 Mar 2007 17:54:24 -0000 1.11
+++ winpos.c 30 Mar 2007 18:59:40 -0000 1.12
@@ -750,17 +750,52 @@
*/
BOOL WINAPI SetForegroundWindow( HWND hwnd )
{
- TRACE("(%08x)\n", hwnd);
- if (!hwnd) return WINPOS_SetActiveWindow( 0, FALSE, TRUE, TRUE );
+ HWND PrevWindow;
+ BOOL Ret = TRUE;
- /* child windows get WM_CHILDACTIVATE message */
- if ((GetWindowLongW( hwnd, GWL_STYLE ) & (WS_CHILD | WS_POPUP)) == WS_CHILD)
- return SendMessageA( hwnd, WM_CHILDACTIVATE, 0, 0 );
+ TRACE ("(0x%08x)\n", hwnd);
+ if (!hwnd)
+ return WINPOS_SetActiveWindow (0, FALSE, TRUE, TRUE);
- hwnd = WIN_GetFullHandle( hwnd );
- if( hwnd == GetForegroundWindow() ) return FALSE;
+ /* child windows get WM_CHILDACTIVATE message */
+ if ((GetWindowLongW (hwnd, GWL_STYLE) & (WS_CHILD | WS_POPUP)) == WS_CHILD)
+ return SendMessageA (hwnd, WM_CHILDACTIVATE, 0, 0);
- return WINPOS_SetActiveWindow( hwnd, FALSE, TRUE, TRUE );
+ hwnd = WIN_GetFullHandle (hwnd);
+ PrevWindow = GetForegroundWindow ();
+ if (hwnd == PrevWindow)
+ return FALSE;
+
+ /* If old window owned by different thread, send message; otherwise
+ clear directly */
+ if (PrevWindow)
+ {
+ DWORD PrevProcessId, PrevThreadId;
+
+ PrevThreadId = GetWindowThreadProcessId (PrevWindow, &PrevProcessId);
+ if ((PrevProcessId == GetCurrentProcessId ()) &&
+ (PrevThreadId == GetCurrentThreadId ()))
+ Ret = WINPOS_SetActiveWindow (0, FALSE, TRUE, TRUE);
+ else
+ SendNotifyMessageA (PrevWindow, WM_WINE_SETFOREGROUNDWINDOW, 0, 0);
+ }
+
+ /* If new window owned by different thread, send message; otherwise
+ set directly */
+ if (hwnd)
+ {
+ DWORD NewProcessId, NewThreadId;
+
+ NewThreadId = GetWindowThreadProcessId (hwnd, &NewProcessId);
+ if ((NewProcessId == GetCurrentProcessId ()) &&
+ (NewThreadId == GetCurrentThreadId ()))
+ Ret = WINPOS_SetActiveWindow (hwnd, FALSE, TRUE, TRUE);
+ else
+ SendNotifyMessageA (hwnd, WM_WINE_SETFOREGROUNDWINDOW,
+ (WPARAM)hwnd, 0);
+ }
+
+ return Ret;
}