Alexandre Julliard : explorer: Create the driver desktop window after the window handle is created.

Alexandre Julliard julliard at winehq.org
Wed Oct 16 14:25:50 CDT 2013


Module: wine
Branch: master
Commit: 13149b67d3972c5babc8b5c368ffba85a5c5c2c2
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=13149b67d3972c5babc8b5c368ffba85a5c5c2c2

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Wed Oct 16 12:13:50 2013 +0200

explorer: Create the driver desktop window after the window handle is created.

---

 dlls/winex11.drv/desktop.c  |    1 +
 dlls/winex11.drv/window.c   |   19 ++++++++-----------
 dlls/winex11.drv/x11drv.h   |    3 ++-
 programs/explorer/desktop.c |   32 +++++++++++++++++---------------
 4 files changed, 28 insertions(+), 27 deletions(-)

diff --git a/dlls/winex11.drv/desktop.c b/dlls/winex11.drv/desktop.c
index 39b9965..7a1bb92 100644
--- a/dlls/winex11.drv/desktop.c
+++ b/dlls/winex11.drv/desktop.c
@@ -171,6 +171,7 @@ BOOL CDECL X11DRV_create_desktop( UINT width, UINT height )
             PropModeReplace, (unsigned char*)&x11drv_atom(_NET_WM_STATE_FULLSCREEN),
             1);
     }
+    if (!create_desktop_win_data( win )) return FALSE;
     XFlush( display );
     X11DRV_init_desktop( win, width, height );
     return TRUE;
diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c
index 17859f8..a76e80d 100644
--- a/dlls/winex11.drv/window.c
+++ b/dlls/winex11.drv/window.c
@@ -1651,16 +1651,19 @@ static struct x11drv_win_data *alloc_win_data( Display *display, HWND hwnd )
 
 
 /* initialize the desktop window id in the desktop manager process */
-static BOOL create_desktop_win_data( Display *display, HWND hwnd )
+BOOL create_desktop_win_data( Window win )
 {
+    struct x11drv_thread_data *thread_data = x11drv_thread_data();
+    Display *display = thread_data->display;
     struct x11drv_win_data *data;
 
-    if (!(data = alloc_win_data( display, hwnd ))) return FALSE;
-    data->whole_window = root_window;
+    if (!(data = alloc_win_data( display, GetDesktopWindow() ))) return FALSE;
+    data->whole_window = win;
     data->managed = TRUE;
-    SetPropA( data->hwnd, whole_window_prop, (HANDLE)root_window );
-    set_initial_wm_hints( display, root_window );
+    SetPropA( data->hwnd, whole_window_prop, (HANDLE)win );
+    set_initial_wm_hints( display, win );
     release_win_data( data );
+    if (thread_data->clip_window) XReparentWindow( display, thread_data->clip_window, win, 0, 0 );
     return TRUE;
 }
 
@@ -1719,12 +1722,6 @@ BOOL CDECL X11DRV_CreateWindow( HWND hwnd )
         struct x11drv_thread_data *data = x11drv_init_thread_data();
         XSetWindowAttributes attr;
 
-        if (root_window != DefaultRootWindow( gdi_display ))
-        {
-            /* the desktop win data can't be created lazily */
-            if (!create_desktop_win_data( data->display, hwnd )) return FALSE;
-        }
-
         /* create the cursor clipping window */
         attr.override_redirect = TRUE;
         attr.event_mask = StructureNotifyMask | FocusChangeMask;
diff --git a/dlls/winex11.drv/x11drv.h b/dlls/winex11.drv/x11drv.h
index 3b235ca..98386ce 100644
--- a/dlls/winex11.drv/x11drv.h
+++ b/dlls/winex11.drv/x11drv.h
@@ -639,7 +639,8 @@ struct x11drv_mode_info
 
 extern void X11DRV_init_desktop( Window win, unsigned int width, unsigned int height ) DECLSPEC_HIDDEN;
 extern void X11DRV_resize_desktop(unsigned int width, unsigned int height) DECLSPEC_HIDDEN;
-BOOL is_desktop_fullscreen(void) DECLSPEC_HIDDEN;
+extern BOOL is_desktop_fullscreen(void) DECLSPEC_HIDDEN;
+extern BOOL create_desktop_win_data( Window win ) DECLSPEC_HIDDEN;
 extern void X11DRV_Settings_AddDepthModes(void) DECLSPEC_HIDDEN;
 extern void X11DRV_Settings_AddOneMode(unsigned int width, unsigned int height, unsigned int bpp, unsigned int freq) DECLSPEC_HIDDEN;
 unsigned int X11DRV_Settings_GetModeCount(void) DECLSPEC_HIDDEN;
diff --git a/programs/explorer/desktop.c b/programs/explorer/desktop.c
index 49bbbe9..694f3f6 100644
--- a/programs/explorer/desktop.c
+++ b/programs/explorer/desktop.c
@@ -552,23 +552,15 @@ static LRESULT WINAPI desktop_wnd_proc( HWND hwnd, UINT message, WPARAM wp, LPAR
 static BOOL create_desktop( const WCHAR *name, unsigned int width, unsigned int height )
 {
     static const WCHAR rootW[] = {'r','o','o','t',0};
-    HDESK desktop;
     BOOL ret = FALSE;
     BOOL (CDECL *create_desktop_func)(unsigned int, unsigned int);
 
-    desktop = CreateDesktopW( name, NULL, NULL, 0, DESKTOP_ALL_ACCESS, NULL );
-    if (!desktop)
-    {
-        WINE_ERR( "failed to create desktop %s error %d\n", wine_dbgstr_w(name), GetLastError() );
-        ExitProcess( 1 );
-    }
     /* magic: desktop "root" means use the root window */
     if (graphics_driver && strcmpiW( name, rootW ))
     {
         create_desktop_func = (void *)GetProcAddress( graphics_driver, "wine_create_desktop" );
         if (create_desktop_func) ret = create_desktop_func( width, height );
     }
-    SetThreadDesktop( desktop );
     return ret;
 }
 
@@ -703,8 +695,8 @@ static void set_desktop_window_title( HWND hwnd, const WCHAR *name )
 /* main desktop management function */
 void manage_desktop( WCHAR *arg )
 {
-    static const WCHAR displayW[] = {'D','I','S','P','L','A','Y',0};
     static const WCHAR messageW[] = {'M','e','s','s','a','g','e',0};
+    HDESK desktop = 0;
     MSG msg;
     HDC hdc;
     HWND hwnd, msg_hwnd;
@@ -737,10 +729,15 @@ void manage_desktop( WCHAR *arg )
         if (!get_default_desktop_size( name, &width, &height )) width = height = 0;
     }
 
-    hdc = CreateDCW( displayW, NULL, NULL, NULL );
-    graphics_driver = __wine_get_driver_module( hdc );
-
-    if (name && width && height) using_root = !create_desktop( name, width, height );
+    if (name && width && height)
+    {
+        if (!(desktop = CreateDesktopW( name, NULL, NULL, 0, DESKTOP_ALL_ACCESS, NULL )))
+        {
+            WINE_ERR( "failed to create desktop %s error %d\n", wine_dbgstr_w(name), GetLastError() );
+            ExitProcess( 1 );
+        }
+        SetThreadDesktop( desktop );
+    }
 
     /* create the desktop window */
     hwnd = CreateWindowExW( 0, DESKTOP_CLASS_ATOM, NULL,
@@ -750,13 +747,18 @@ void manage_desktop( WCHAR *arg )
     msg_hwnd = CreateWindowExW( 0, messageW, NULL, WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
                                 0, 0, 100, 100, 0, 0, 0, NULL );
 
-    DeleteDC( hdc );
-
     if (hwnd == GetDesktopWindow())
     {
         HMODULE shell32;
         void (WINAPI *pShellDDEInit)( BOOL );
 
+        if (desktop)
+        {
+            hdc = GetDC( hwnd );
+            graphics_driver = __wine_get_driver_module( hdc );
+            using_root = !create_desktop( name, width, height );
+            ReleaseDC( hwnd, hdc );
+        }
         SetWindowLongPtrW( hwnd, GWLP_WNDPROC, (LONG_PTR)desktop_wnd_proc );
         SendMessageW( hwnd, WM_SETICON, ICON_BIG, (LPARAM)LoadIconW( 0, MAKEINTRESOURCEW(OIC_WINLOGO)));
         if (name) set_desktop_window_title( hwnd, name );




More information about the wine-cvs mailing list