diff --git a/dlls/ieframe/oleobject.c b/dlls/ieframe/oleobject.c index 462cf7497ec..d02562dbe8e 100644 --- a/dlls/ieframe/oleobject.c +++ b/dlls/ieframe/oleobject.c @@ -49,6 +49,22 @@ static LRESULT resize_window(WebBrowser *This, LONG width, LONG height) return 0; } +static void notify_on_focus(WebBrowser *This, BOOL got_focus) +{ + IOleControlSite *control_site; + HRESULT hres; + + if(!This->client) + return; + + hres = IOleClientSite_QueryInterface(This->client, &IID_IOleControlSite, (void**)&control_site); + if(FAILED(hres)) + return; + + IOleControlSite_OnFocus(control_site, got_focus); + IOleControlSite_Release(control_site); +} + static LRESULT WINAPI shell_embedding_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { WebBrowser *This; @@ -67,6 +83,12 @@ static LRESULT WINAPI shell_embedding_proc(HWND hwnd, UINT msg, WPARAM wParam, L return resize_window(This, LOWORD(lParam), HIWORD(lParam)); case WM_DOCHOSTTASK: return process_dochost_tasks(&This->doc_host); + case WM_SETFOCUS: + notify_on_focus(This, TRUE); + break; + case WM_KILLFOCUS: + notify_on_focus(This, FALSE); + break; } return DefWindowProcW(hwnd, msg, wParam, lParam); @@ -203,6 +225,7 @@ static HRESULT activate_ui(WebBrowser *This, IOleClientSite *active_site) IOleInPlaceFrame_SetMenu(This->doc_host.frame, NULL, NULL, This->shell_embedding_hwnd); SetFocus(This->shell_embedding_hwnd); + notify_on_focus(This, TRUE); return S_OK; } @@ -534,10 +557,11 @@ static HRESULT WINAPI OleObject_Close(IOleObject *iface, DWORD dwSaveOption) if(This->uiwindow) IOleInPlaceUIWindow_SetActiveObject(This->uiwindow, NULL, NULL); - if(This->inplace) { + if(This->inplace) IOleInPlaceSiteEx_OnUIDeactivate(This->inplace, FALSE); + notify_on_focus(This, FALSE); + if(This->inplace) IOleInPlaceSiteEx_OnInPlaceDeactivate(This->inplace); - } return IOleObject_SetClientSite(iface, NULL); } diff --git a/dlls/ieframe/tests/webbrowser.c b/dlls/ieframe/tests/webbrowser.c index 9ceed46f4ce..aa90755ae68 100644 --- a/dlls/ieframe/tests/webbrowser.c +++ b/dlls/ieframe/tests/webbrowser.c @@ -143,7 +143,8 @@ DEFINE_EXPECT(OnUIDeactivate); DEFINE_EXPECT(OnInPlaceDeactivate); DEFINE_EXPECT(RequestUIActivate); DEFINE_EXPECT(ControlSite_TranslateAccelerator); -DEFINE_EXPECT(OnFocus); +DEFINE_EXPECT(OnFocus_TRUE); +DEFINE_EXPECT(OnFocus_FALSE); DEFINE_EXPECT(GetExternal); static const WCHAR wszItem[] = {'i','t','e','m',0}; @@ -1135,7 +1136,10 @@ static HRESULT WINAPI IOleControlSite_fnTranslateAccelerator(IOleControlSite* Th static HRESULT WINAPI IOleControlSite_fnOnFocus(IOleControlSite* This, BOOL fGotFocus) { - CHECK_EXPECT2(OnFocus); + if(fGotFocus) + CHECK_EXPECT2(OnFocus_TRUE); + else + CHECK_EXPECT2(OnFocus_FALSE); return E_NOTIMPL; } @@ -1813,7 +1817,7 @@ static void test_DoVerb(IWebBrowser2 *unk) SET_EXPECT(Frame_SetActiveObject); SET_EXPECT(UIWindow_SetActiveObject); SET_EXPECT(SetMenu); - SET_EXPECT(OnFocus); + SET_EXPECT(OnFocus_TRUE); hres = IOleObject_DoVerb(oleobj, OLEIVERB_SHOW, NULL, &ClientSite, 0, (HWND)0xdeadbeef, &rect); @@ -1830,7 +1834,7 @@ static void test_DoVerb(IWebBrowser2 *unk) CHECK_CALLED(Frame_SetActiveObject); CHECK_CALLED(UIWindow_SetActiveObject); CHECK_CALLED(SetMenu); - todo_wine CHECK_CALLED(OnFocus); + CHECK_CALLED(OnFocus_TRUE); hres = IOleObject_DoVerb(oleobj, OLEIVERB_SHOW, NULL, &ClientSite, 0, (HWND)0xdeadbeef, &rect); @@ -3213,7 +3217,7 @@ static void test_UIActivate(IWebBrowser2 *unk, BOOL activate) SET_EXPECT(RequestUIActivate); SET_EXPECT(ShowUI); SET_EXPECT(HideUI); - SET_EXPECT(OnFocus); + SET_EXPECT(OnFocus_FALSE); } hres = IOleDocumentView_UIActivate(docview, activate); @@ -3227,7 +3231,7 @@ static void test_UIActivate(IWebBrowser2 *unk, BOOL activate) CHECK_CALLED(RequestUIActivate); CHECK_CALLED(ShowUI); CHECK_CALLED(HideUI); - CHECK_CALLED(OnFocus); + CHECK_CALLED(OnFocus_FALSE); } } @@ -3490,7 +3494,7 @@ static void test_Close(IWebBrowser2 *wb, BOOL do_download) SET_EXPECT(Frame_SetActiveObject); SET_EXPECT(UIWindow_SetActiveObject); SET_EXPECT(OnUIDeactivate); - SET_EXPECT(OnFocus); + SET_EXPECT(OnFocus_FALSE); SET_EXPECT(OnInPlaceDeactivate); SET_EXPECT(Invoke_STATUSTEXTCHANGE); if(!do_download) { @@ -3513,7 +3517,7 @@ static void test_Close(IWebBrowser2 *wb, BOOL do_download) CHECK_CALLED(Frame_SetActiveObject); CHECK_CALLED(UIWindow_SetActiveObject); CHECK_CALLED(OnUIDeactivate); - todo_wine CHECK_CALLED(OnFocus); + CHECK_CALLED(OnFocus_FALSE); CHECK_CALLED(OnInPlaceDeactivate); CLEAR_CALLED(Invoke_STATUSTEXTCHANGE); /* Called by IE9 */ if(!do_download) {