Zebediah Figura : explorer: Implement IShellWindows::FindWindowSW() for non-desktop windows.

Alexandre Julliard julliard at winehq.org
Mon May 18 15:00:14 CDT 2020


Module: wine
Branch: master
Commit: 7b56edf9a46c14eb5c6c617826509cc0a4736389
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=7b56edf9a46c14eb5c6c617826509cc0a4736389

Author: Zebediah Figura <z.figura12 at gmail.com>
Date:   Sun May 17 23:29:43 2020 -0500

explorer: Implement IShellWindows::FindWindowSW() for non-desktop windows.

Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 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 207733afe7..5495787561 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 264a8cb810..8a8e5bc071 100644
--- a/programs/explorer/desktop.c
+++ b/programs/explorer/desktop.c
@@ -1284,26 +1284,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)




More information about the wine-cvs mailing list