Restore the pre-r17946 UserGetAncestor behaviour and fix the code calling it.
Modified: trunk/reactos/subsys/win32k/ntuser/focus.c
Modified: trunk/reactos/subsys/win32k/ntuser/window.c

Modified: trunk/reactos/subsys/win32k/ntuser/focus.c
--- trunk/reactos/subsys/win32k/ntuser/focus.c	2005-09-20 10:31:57 UTC (rev 17946)
+++ trunk/reactos/subsys/win32k/ntuser/focus.c	2005-09-20 10:45:27 UTC (rev 17947)
@@ -520,7 +520,7 @@
       }
 
       TopWnd = UserGetAncestor(Window, GA_ROOT);
-      if (TopWnd->hSelf != UserGetActiveWindow())
+      if (TopWnd && TopWnd->hSelf != UserGetActiveWindow())
       {
 //         PWINDOW_OBJECT WndTops = UserGetWindowObject(hWndTop);
          UserRefObjectCo(TopWnd);

Modified: trunk/reactos/subsys/win32k/ntuser/window.c
--- trunk/reactos/subsys/win32k/ntuser/window.c	2005-09-20 10:31:57 UTC (rev 17946)
+++ trunk/reactos/subsys/win32k/ntuser/window.c	2005-09-20 10:45:27 UTC (rev 17947)
@@ -1374,9 +1374,9 @@
       else
       {
          //temp hack
-         PWINDOW_OBJECT Par = UserGetWindowObject(hWndParent);
-         if (Par)
-            OwnerWindowHandle = UserGetAncestor(Par, GA_ROOT)->hSelf;
+         PWINDOW_OBJECT Par = UserGetWindowObject(hWndParent), Root;
+         if (Par && (Root = UserGetAncestor(Par, GA_ROOT)))
+            OwnerWindowHandle = Root->hSelf;
       }
    }
    else if ((dwStyle & (WS_CHILD | WS_POPUP)) == WS_CHILD)
@@ -2543,6 +2543,11 @@
 {
    PWINDOW_OBJECT WndAncestor, Parent;
 
+   if (Wnd->hSelf == IntGetDesktopWindow())
+   {
+      return NULL;
+   }
+
    switch (Type)
    {
       case GA_PARENT: