Alexandre Julliard : user: Launch explorer to manage the desktop window.

Alexandre Julliard julliard at wine.codeweavers.com
Tue Mar 7 06:12:56 CST 2006


Module: wine
Branch: refs/heads/master
Commit: 1a4f6e579b6aab685fae2e649fd5accee7ec0b4f
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=1a4f6e579b6aab685fae2e649fd5accee7ec0b4f

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Tue Mar  7 11:42:35 2006 +0100

user: Launch explorer to manage the desktop window.

---

 dlls/user/win.c                |   46 +++++++++++++++++++++++++++++++++++++---
 dlls/x11drv/winpos.c           |    2 --
 include/wine/server_protocol.h |    3 ++-
 server/protocol.def            |    1 +
 server/trace.c                 |    1 +
 server/window.c                |    2 +-
 6 files changed, 48 insertions(+), 7 deletions(-)

diff --git a/dlls/user/win.c b/dlls/user/win.c
index 1fc2d7c..44c2461 100644
--- a/dlls/user/win.c
+++ b/dlls/user/win.c
@@ -103,6 +103,16 @@ static WND *create_window_handle( HWND p
         return NULL;
     }
 
+    if (!parent)  /* if parent is 0 we don't have a desktop window yet */
+    {
+        struct user_thread_info *thread_info = get_user_thread_info();
+
+        assert( !thread_info->desktop );
+        thread_info->desktop = full_parent ? full_parent : handle;
+        if (full_parent && !USER_Driver->pCreateDesktopWindow( thread_info->desktop ))
+            ERR( "failed to create desktop window\n" );
+    }
+
     USER_Lock();
 
     index = USER_HANDLE_TO_INDEX(handle);
@@ -946,7 +956,8 @@ static HWND WIN_CreateWindowEx( CREATEST
             WARN("No parent for child window\n" );
             return 0;  /* WS_CHILD needs a parent, but WS_POPUP doesn't */
         }
-        parent = GetDesktopWindow();
+        if (classAtom != LOWORD(DESKTOP_CLASS_ATOM))  /* are we creating the desktop itself? */
+            parent = GetDesktopWindow();
     }
 
     WIN_FixCoordinates(cs, &sw); /* fix default coordinates */
@@ -1553,16 +1564,45 @@ HWND WINAPI GetDesktopWindow(void)
 {
     struct user_thread_info *thread_info = get_user_thread_info();
 
+    if (thread_info->desktop) return thread_info->desktop;
+
+    SERVER_START_REQ( get_desktop_window )
+    {
+        req->force = 0;
+        if (!wine_server_call( req )) thread_info->desktop = reply->handle;
+    }
+    SERVER_END_REQ;
+
     if (!thread_info->desktop)
     {
+        STARTUPINFOW si;
+        PROCESS_INFORMATION pi;
+        WCHAR command_line[] = {'e','x','p','l','o','r','e','r','.','e','x','e',' ','/','d','e','s','k','t','o','p',0};
+
+        memset( &si, 0, sizeof(si) );
+        si.cb = sizeof(si);
+        if (CreateProcessW( NULL, command_line, NULL, NULL, FALSE, DETACHED_PROCESS,
+                            NULL, NULL, &si, &pi ))
+        {
+            TRACE( "started explorer pid %04lx tid %04lx\n", pi.dwProcessId, pi.dwThreadId );
+            WaitForInputIdle( pi.hProcess, 10000 );
+            CloseHandle( pi.hThread );
+            CloseHandle( pi.hProcess );
+
+        }
+        else WARN( "failed to start explorer, err %ld\n", GetLastError() );
+
         SERVER_START_REQ( get_desktop_window )
         {
+            req->force = 1;
             if (!wine_server_call( req )) thread_info->desktop = reply->handle;
         }
         SERVER_END_REQ;
-        if (!thread_info->desktop || !USER_Driver->pCreateDesktopWindow( thread_info->desktop ))
-            ERR( "failed to create desktop window\n" );
     }
+
+    if (!thread_info->desktop || !USER_Driver->pCreateDesktopWindow( thread_info->desktop ))
+        ERR( "failed to create desktop window\n" );
+
     return thread_info->desktop;
 }
 
diff --git a/dlls/x11drv/winpos.c b/dlls/x11drv/winpos.c
index e912531..96b1004 100644
--- a/dlls/x11drv/winpos.c
+++ b/dlls/x11drv/winpos.c
@@ -942,8 +942,6 @@ BOOL X11DRV_ShowWindow( HWND hwnd, INT c
     RECT newPos = {0, 0, 0, 0};
     UINT swp = 0;
 
-    if (hwnd == GetDesktopWindow()) return FALSE;
-
     TRACE("hwnd=%p, cmd=%d, wasVisible %d\n", hwnd, cmd, wasVisible);
 
     switch(cmd)
diff --git a/include/wine/server_protocol.h b/include/wine/server_protocol.h
index 0e9ae22..95587cd 100644
--- a/include/wine/server_protocol.h
+++ b/include/wine/server_protocol.h
@@ -2543,6 +2543,7 @@ struct destroy_window_reply
 struct get_desktop_window_request
 {
     struct request_header __header;
+    int            force;
 };
 struct get_desktop_window_reply
 {
@@ -4360,6 +4361,6 @@ union generic_reply
     struct query_symlink_reply query_symlink_reply;
 };
 
-#define SERVER_PROTOCOL_VERSION 230
+#define SERVER_PROTOCOL_VERSION 231
 
 #endif /* __WINE_WINE_SERVER_PROTOCOL_H */
diff --git a/server/protocol.def b/server/protocol.def
index 9163a36..5db269a 100644
--- a/server/protocol.def
+++ b/server/protocol.def
@@ -1804,6 +1804,7 @@ enum message_type
 
 /* Retrieve the desktop window for the current thread */
 @REQ(get_desktop_window)
+    int            force;       /* force creation if it doesn't exist */
 @REPLY
     user_handle_t  handle;      /* handle to the desktop window */
 @END
diff --git a/server/trace.c b/server/trace.c
index 0d5fac9..9b4f7bd 100644
--- a/server/trace.c
+++ b/server/trace.c
@@ -2280,6 +2280,7 @@ static void dump_destroy_window_request(
 
 static void dump_get_desktop_window_request( const struct get_desktop_window_request *req )
 {
+    fprintf( stderr, " force=%d", req->force );
 }
 
 static void dump_get_desktop_window_reply( const struct get_desktop_window_reply *req )
diff --git a/server/window.c b/server/window.c
index 8b7af20..6b876af 100644
--- a/server/window.c
+++ b/server/window.c
@@ -1459,7 +1459,7 @@ DECL_HANDLER(destroy_window)
 /* retrieve the desktop window for the current thread */
 DECL_HANDLER(get_desktop_window)
 {
-    struct window *win = get_desktop_window( current, 1 );
+    struct window *win = get_desktop_window( current, req->force );
 
     if (win) reply->handle = win->handle;
 }




More information about the wine-cvs mailing list