[PATCH 4/5] explorer: Implement IShellWindows::FindWindowSW() for non-desktop windows.
Zebediah Figura
z.figura12 at gmail.com
Sun May 17 23:29:43 CDT 2020
Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
dlls/shell32/tests/shelldispatch.c | 8 +++---
programs/explorer/desktop.c | 45 ++++++++++++++++++++++--------
2 files changed, 38 insertions(+), 15 deletions(-)
diff --git a/dlls/shell32/tests/shelldispatch.c b/dlls/shell32/tests/shelldispatch.c
index 207733afe7e..54957875615 100644
--- a/dlls/shell32/tests/shelldispatch.c
+++ b/dlls/shell32/tests/shelldispatch.c
@@ -1064,7 +1064,7 @@ static void test_ShellWindows(void)
VariantInit(&v2);
hr = IShellWindows_FindWindowSW(shellwindows, &v, &v2, SWC_EXPLORER, &ret, 0, &disp);
- todo_wine ok(hr == S_FALSE, "Got hr %#x.\n", hr);
+ ok(hr == S_FALSE, "Got hr %#x.\n", hr);
ok(!ret, "Got window %#x.\n", ret);
ok(!disp, "Got IDispatch %p.\n", &disp);
@@ -1075,15 +1075,15 @@ static void test_ShellWindows(void)
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IShellWindows_FindWindowSW(shellwindows, &v, &v2, SWC_EXPLORER, &ret, 0, &disp);
- todo_wine ok(hr == S_OK, "Got hr %#x.\n", hr);
- todo_wine ok(ret == (LONG)(LONG_PTR)hwnd, "Expected %p, got %#x.\n", hwnd, ret);
+ ok(hr == S_OK, "Got hr %#x.\n", hr);
+ ok(ret == (LONG)(LONG_PTR)hwnd, "Expected %p, got %#x.\n", hwnd, ret);
ok(!disp, "Got IDispatch %p.\n", &disp);
hr = IShellWindows_Revoke(shellwindows, cookie);
ok(hr == S_OK, "got 0x%08x\n", hr);
hr = IShellWindows_FindWindowSW(shellwindows, &v, &v2, SWC_EXPLORER, &ret, 0, &disp);
- todo_wine ok(hr == S_FALSE, "Got hr %#x.\n", hr);
+ ok(hr == S_FALSE, "Got hr %#x.\n", hr);
ok(!ret, "Got window %#x.\n", ret);
ok(!disp, "Got IDispatch %p.\n", &disp);
diff --git a/programs/explorer/desktop.c b/programs/explorer/desktop.c
index 5d0ca9948ef..035a1e03288 100644
--- a/programs/explorer/desktop.c
+++ b/programs/explorer/desktop.c
@@ -1283,26 +1283,49 @@ static HRESULT WINAPI shellwindows_OnActivated(IShellWindows *iface, LONG cookie
return E_NOTIMPL;
}
-static HRESULT WINAPI shellwindows_FindWindowSW(IShellWindows *iface, VARIANT *loc,
- VARIANT *root, int class, LONG *hwnd, int options, IDispatch **disp)
+static HRESULT WINAPI shellwindows_FindWindowSW(IShellWindows *iface, VARIANT *location,
+ VARIANT *root, int class, LONG *hwnd, int options, IDispatch **disp)
{
- TRACE("%s %s 0x%x %p 0x%x %p\n", debugstr_variant(loc), debugstr_variant(root),
- class, hwnd, options, disp);
+ struct shellwindows *sw = impl_from_IShellWindows(iface);
+ unsigned int i;
+
+ TRACE("iface %p, location %p, root %p, class %#x, hwnd %p, options %#x, disp %p.\n",
+ iface, location, root, class, hwnd, options, disp);
- if (class != SWC_DESKTOP)
+ if (class == SWC_DESKTOP)
+ {
+ *hwnd = (LONG)(LONG_PTR)GetDesktopWindow();
+ if (options & SWFO_NEEDDISPATCH)
+ {
+ *disp = (IDispatch *)&desktopshellbrowserwindow.IWebBrowser2_iface;
+ IDispatch_AddRef(*disp);
+ }
+ return S_OK;
+ }
+
+ if (options)
+ FIXME("Ignoring options %#x.\n", options);
+
+ if (V_VT(location) != (VT_ARRAY | VT_UI1))
{
- WARN("only SWC_DESKTOP class supported.\n");
+ FIXME("Unexpected variant type %s.\n", debugstr_vt(V_VT(location)));
return E_NOTIMPL;
}
- *hwnd = HandleToLong(GetDesktopWindow());
- if (options & SWFO_NEEDDISPATCH)
+ EnterCriticalSection(&sw->cs);
+
+ for (i = 0; i < sw->count; ++i)
{
- *disp = (IDispatch*)&desktopshellbrowserwindow.IWebBrowser2_iface;
- IDispatch_AddRef(*disp);
+ if (sw->windows[i].class == class && ILIsEqual(V_ARRAY(location)->pvData, sw->windows[i].pidl))
+ {
+ *hwnd = sw->windows[i].hwnd;
+ LeaveCriticalSection(&sw->cs);
+ return S_OK;
+ }
}
- return S_OK;
+ LeaveCriticalSection(&sw->cs);
+ return S_FALSE;
}
static HRESULT WINAPI shellwindows_OnCreated(IShellWindows *iface, LONG cookie, IUnknown *punk)
--
2.26.2
More information about the wine-devel
mailing list