Commit eb30a1c7 authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

Make sure that both deactivated and activated MDI children receive

WM_MDIACTIVATE message in all cases.
parent d530e548
...@@ -490,17 +490,11 @@ static void MDI_SwitchActiveChild( HWND clientHwnd, HWND childHwnd, ...@@ -490,17 +490,11 @@ static void MDI_SwitchActiveChild( HWND clientHwnd, HWND childHwnd,
TRACE("from %p, to %p\n",childHwnd,hwndTo); TRACE("from %p, to %p\n",childHwnd,hwndTo);
if ( !hwndTo ) return; /* no window to switch to */ if ( !hwndTo )
MDI_ChildActivate( clientHwnd, 0 );
if ( hwndTo != hwndPrev ) else if ( hwndTo != hwndPrev )
{
SetWindowPos( hwndTo, HWND_TOP, 0, 0, 0, 0, SetWindowPos( hwndTo, HWND_TOP, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE ); SWP_NOMOVE | SWP_NOSIZE );
if( bNextWindow && hwndPrev )
SetWindowPos( hwndPrev, HWND_BOTTOM, 0, 0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE );
}
} }
...@@ -517,19 +511,7 @@ static LRESULT MDIDestroyChild( HWND parent, MDICLIENTINFO *ci, ...@@ -517,19 +511,7 @@ static LRESULT MDIDestroyChild( HWND parent, MDICLIENTINFO *ci,
if( child == ci->hwndActiveChild ) if( child == ci->hwndActiveChild )
{ {
MDI_SwitchActiveChild(parent, child, TRUE); MDI_SwitchActiveChild(parent, child, TRUE);
ShowWindow(child, SW_HIDE);
if( child == ci->hwndActiveChild )
{
ShowWindow( child, SW_HIDE);
if( child == ci->hwndActiveChild && IsZoomed(ci->hwndActiveChild) )
{
HWND frame = GetParent(parent);
MDI_RestoreFrameMenu( frame, child );
MDI_UpdateFrameText( frame, parent, TRUE, NULL);
}
MDI_ChildActivate(parent, 0);
}
} }
for (i = 0; i < ci->nActiveChildren; i++) for (i = 0; i < ci->nActiveChildren; i++)
...@@ -567,7 +549,7 @@ static LRESULT MDIDestroyChild( HWND parent, MDICLIENTINFO *ci, ...@@ -567,7 +549,7 @@ static LRESULT MDIDestroyChild( HWND parent, MDICLIENTINFO *ci,
static LONG MDI_ChildActivate( HWND client, HWND child ) static LONG MDI_ChildActivate( HWND client, HWND child )
{ {
MDICLIENTINFO *clientInfo; MDICLIENTINFO *clientInfo;
HWND prevActiveWnd; HWND prevActiveWnd, frame;
BOOL isActiveFrameWnd; BOOL isActiveFrameWnd;
if (child && (!IsWindowEnabled( child ))) return 0; if (child && (!IsWindowEnabled( child ))) return 0;
...@@ -576,42 +558,41 @@ static LONG MDI_ChildActivate( HWND client, HWND child ) ...@@ -576,42 +558,41 @@ static LONG MDI_ChildActivate( HWND client, HWND child )
TRACE("%p\n", child); TRACE("%p\n", child);
isActiveFrameWnd = (GetActiveWindow() == GetParent(client)); frame = GetParent(client);
isActiveFrameWnd = (GetActiveWindow() == frame);
prevActiveWnd = clientInfo->hwndActiveChild; prevActiveWnd = clientInfo->hwndActiveChild;
if (prevActiveWnd == child) return 0;
/* deactivate prev. active child */ /* deactivate prev. active child */
if(prevActiveWnd) if(prevActiveWnd)
{ {
SetWindowLongW( prevActiveWnd, GWL_STYLE,
GetWindowLongW( prevActiveWnd, GWL_STYLE ) | WS_SYSMENU );
SendMessageW( prevActiveWnd, WM_NCACTIVATE, FALSE, 0L ); SendMessageW( prevActiveWnd, WM_NCACTIVATE, FALSE, 0L );
SendMessageW( prevActiveWnd, WM_MDIACTIVATE, (WPARAM)prevActiveWnd, (LPARAM)child); SendMessageW( prevActiveWnd, WM_MDIACTIVATE, (WPARAM)prevActiveWnd, (LPARAM)child);
} }
clientInfo->hwndActiveChild = child;
/* set appearance */ /* set appearance */
if (IsZoomed(clientInfo->hwndActiveChild) && clientInfo->hwndActiveChild != child) if (IsZoomed(prevActiveWnd) && prevActiveWnd != child)
{ {
INT cmd = SW_SHOWNORMAL;
if( child ) if( child )
{ {
INT cmd = SW_SHOWNORMAL;
HMENU hSysMenu = GetSystemMenu(child, FALSE); HMENU hSysMenu = GetSystemMenu(child, FALSE);
UINT state = 0; UINT state = 0;
if (hSysMenu) if (hSysMenu)
state = GetMenuState(hSysMenu, SC_MAXIMIZE, MF_BYCOMMAND); state = GetMenuState(hSysMenu, SC_MAXIMIZE, MF_BYCOMMAND);
if (state != 0xFFFFFFFF && !(state & (MF_DISABLED | MF_GRAYED))) if (state != 0xFFFFFFFF && !(state & (MF_DISABLED | MF_GRAYED)))
{
SendMessageW(clientInfo->hwndActiveChild, WM_SYSCOMMAND, SC_RESTORE, 0);
cmd = SW_SHOWMAXIMIZED; cmd = SW_SHOWMAXIMIZED;
}
clientInfo->hwndActiveChild = child; ShowWindow( child, cmd );
} }
else
ShowWindow( clientInfo->hwndActiveChild, cmd ); MDI_RestoreFrameMenu(frame, child);
} }
clientInfo->hwndActiveChild = child; MDI_UpdateFrameText(frame, client, TRUE, NULL);
/* check if we have any children left */ /* check if we have any children left */
if( !child ) if( !child )
...@@ -623,18 +604,10 @@ static LONG MDI_ChildActivate( HWND client, HWND child ) ...@@ -623,18 +604,10 @@ static LONG MDI_ChildActivate( HWND client, HWND child )
MDI_RefreshMenu(clientInfo); MDI_RefreshMenu(clientInfo);
/* bring active child to the top */
SetWindowPos( child, 0,0,0,0,0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE);
if( isActiveFrameWnd ) if( isActiveFrameWnd )
{ SendMessageW( child, WM_NCACTIVATE, TRUE, 0L);
SendMessageA( child, WM_NCACTIVATE, TRUE, 0L);
if( GetFocus() == client ) SendMessageW( child, WM_MDIACTIVATE, (WPARAM)prevActiveWnd, (LPARAM)child );
SendMessageA( client, WM_SETFOCUS, (WPARAM)client, 0L );
else
SetFocus( client );
}
SendMessageA( child, WM_MDIACTIVATE, (WPARAM)prevActiveWnd, (LPARAM)child );
return TRUE; return TRUE;
} }
...@@ -937,11 +910,11 @@ static BOOL MDI_RestoreFrameMenu( HWND frame, HWND hChild ) ...@@ -937,11 +910,11 @@ static BOOL MDI_RestoreFrameMenu( HWND frame, HWND hChild )
} }
/* close */ /* close */
DeleteMenu(menu,GetMenuItemCount(menu) - 1,MF_BYPOSITION); DeleteMenu(menu, SC_CLOSE, MF_BYCOMMAND);
/* restore */ /* restore */
DeleteMenu(menu,GetMenuItemCount(menu) - 1,MF_BYPOSITION); DeleteMenu(menu, SC_RESTORE, MF_BYCOMMAND);
/* minimize */ /* minimize */
DeleteMenu(menu,GetMenuItemCount(menu) - 1,MF_BYPOSITION); DeleteMenu(menu, SC_MINIMIZE, MF_BYCOMMAND);
DrawMenuBar(frame); DrawMenuBar(frame);
...@@ -1089,11 +1062,7 @@ static LRESULT MDIClientWndProc_common( HWND hwnd, UINT message, ...@@ -1089,11 +1062,7 @@ static LRESULT MDIClientWndProc_common( HWND hwnd, UINT message,
case WM_MDIACTIVATE: case WM_MDIACTIVATE:
{ {
HWND hwndActive; if( ci->hwndActiveChild != (HWND)wParam )
hwndActive = ci->hwndActiveChild;
if( hwndActive != (HWND)wParam )
SetWindowPos((HWND)wParam, 0,0,0,0,0, SWP_NOSIZE | SWP_NOMOVE); SetWindowPos((HWND)wParam, 0,0,0,0,0, SWP_NOSIZE | SWP_NOMOVE);
return 0; return 0;
} }
...@@ -1195,6 +1164,9 @@ static LRESULT MDIClientWndProc_common( HWND hwnd, UINT message, ...@@ -1195,6 +1164,9 @@ static LRESULT MDIClientWndProc_common( HWND hwnd, UINT message,
else else
ci->child = HeapReAlloc(GetProcessHeap(), 0, ci->child, sizeof(HWND) * ci->nActiveChildren); ci->child = HeapReAlloc(GetProcessHeap(), 0, ci->child, sizeof(HWND) * ci->nActiveChildren);
TRACE("Adding MDI child %p, # of children %d\n",
(HWND)lParam, ci->nActiveChildren);
ci->child[ci->nActiveChildren - 1] = (HWND)lParam; ci->child[ci->nActiveChildren - 1] = (HWND)lParam;
} }
break; break;
...@@ -1468,11 +1440,6 @@ LRESULT WINAPI DefMDIChildProcW( HWND hwnd, UINT message, ...@@ -1468,11 +1440,6 @@ LRESULT WINAPI DefMDIChildProcW( HWND hwnd, UINT message,
SendMessageW( client, WM_MDIDESTROY, (WPARAM)hwnd, 0 ); SendMessageW( client, WM_MDIDESTROY, (WPARAM)hwnd, 0 );
return 0; return 0;
case WM_SETFOCUS:
if (ci->hwndActiveChild != hwnd && IsWindowVisible(hwnd))
MDI_ChildActivate( client, hwnd );
break;
case WM_CHILDACTIVATE: case WM_CHILDACTIVATE:
MDI_ChildActivate( client, hwnd ); MDI_ChildActivate( client, hwnd );
return 0; return 0;
...@@ -1486,14 +1453,10 @@ LRESULT WINAPI DefMDIChildProcW( HWND hwnd, UINT message, ...@@ -1486,14 +1453,10 @@ LRESULT WINAPI DefMDIChildProcW( HWND hwnd, UINT message,
break; break;
case SC_RESTORE: case SC_RESTORE:
case SC_MINIMIZE: case SC_MINIMIZE:
SetWindowLongW( hwnd, GWL_STYLE,
GetWindowLongW( hwnd, GWL_STYLE ) | WS_SYSMENU );
break; break;
case SC_MAXIMIZE: case SC_MAXIMIZE:
if (ci->hwndActiveChild == hwnd && IsZoomed(ci->hwndActiveChild)) if (ci->hwndActiveChild == hwnd && IsZoomed(ci->hwndActiveChild))
return SendMessageW( GetParent(client), message, wParam, lParam); return SendMessageW( GetParent(client), message, wParam, lParam);
SetWindowLongW( hwnd, GWL_STYLE,
GetWindowLongW( hwnd, GWL_STYLE ) & ~WS_SYSMENU );
break; break;
case SC_NEXTWINDOW: case SC_NEXTWINDOW:
SendMessageW( client, WM_MDINEXT, 0, 0); SendMessageW( client, WM_MDINEXT, 0, 0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment