Make running tests on a visible desktop a mandatory requirement

Dmitry Timoshkov dmitry at baikal.ru
Thu Mar 10 10:06:39 CST 2005


"Paul Vriens" <Paul.Vriens at xs4all.nl> wrote:

> Apart from the fact whether winrash should be 'fixed' or not, this patch
> doesn't seem to do what it is supposed to do. Put in other words the
> running_on_visible_desktop is not correct (enough).

Apparently that's because desktop window is completely covered by the Progman
window and SysListView32. I'm very sorry for the breakage.

Here is a patch that hopefully should finally work for all systems. It's based
on the article pointed out by Robert Shearman.

Changelog:
    Dmitry Timoshkov <dmitry at codeweavers.com>
    Implement a test for the desktop visibility based on the MSDN article
    pointed out by Robert Shearman.

-- 
Dmitry.
-------------- next part --------------
--- cvs/hq/wine/programs/winetest/main.c	Wed Mar 09 00:16:54 2005
+++ wine/programs/winetest/main.c	Thu Mar 10 15:56:58 2005
@@ -30,6 +30,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <assert.h>
 #include <errno.h>
 #ifdef HAVE_UNISTD_H
 #  include <unistd.h>
@@ -68,23 +69,21 @@ static int running_under_wine ()
 
 static int running_on_visible_desktop ()
 {
-    BOOL visible;
-    HWND desktop;
-    HDC hdc;
-    HRGN hrgn;
-    RECT rc;
-
-    desktop = GetDesktopWindow();
-    hdc = GetDC(desktop);
-    hrgn = CreateRectRgn(0, 0, 0, 0);
-    GetRandomRgn(hdc, hrgn, SYSRGN);
+    FARPROC pGetProcessWindowStation = GetProcAddress(GetModuleHandle("user32.dll"), "GetProcessWindowStation");
 
-    visible = GetRgnBox(hrgn, &rc) != NULLREGION;
-
-    DeleteObject(hrgn);
-    ReleaseDC(desktop, hdc);
-
-    return visible;
+    if (pGetProcessWindowStation)
+    {
+        DWORD len;
+        HWINSTA wstation;
+        USEROBJECTFLAGS uoflags;
+        FARPROC pGetUserObjectInformationA = GetProcAddress(GetModuleHandle("user32.dll"), "GetUserObjectInformationA");
+
+        wstation = (HWINSTA)pGetProcessWindowStation();
+        assert(pGetUserObjectInformationA(wstation, UOI_FLAGS, &uoflags, sizeof(uoflags), &len));
+        return (uoflags.dwFlags & WSF_VISIBLE) != 0;
+    }
+    else
+        return IsWindowVisible(GetDesktopWindow());
 }
 
 void print_version ()


More information about the wine-patches mailing list