Update the desktop window size and send WM_DISPLAYCHANGE on resolution
changes.

diff --git a/dlls/x11drv/desktop.c b/dlls/x11drv/desktop.c
index be39dfd..ac141d6 100644
--- a/dlls/x11drv/desktop.c
+++ b/dlls/x11drv/desktop.c
@@ -176,20 +176,12 @@
     /* do the work */
     XSetWMNormalHints( display, w, size_hints );
     XResizeWindow( display, w, width, height );
-    screen_width  = width;
-    screen_height = height;
-#if 0 /* FIXME */
-    SYSMETRICS_Set( SM_CXSCREEN, width );
-    SYSMETRICS_Set( SM_CYSCREEN, height );
-#else
-    FIXME("Need to update SYSMETRICS after resizing display (now %dx%d)\n", 
-          width, height);
-#endif
 
     /* clean up */
     XFree( size_hints );
     XFlush( display );
     wine_tsx11_unlock();
+    X11DRV_handle_desktop_resize( width, height );
     return 1;
 }
 
diff --git a/dlls/x11drv/winpos.c b/dlls/x11drv/winpos.c
index b6b5886..bd93302 100644
--- a/dlls/x11drv/winpos.c
+++ b/dlls/x11drv/winpos.c
@@ -1552,6 +1552,24 @@
 
 
 /***********************************************************************
+ *		X11DRV_handle_desktop_resize
+ */
+void X11DRV_handle_desktop_resize( unsigned int width, unsigned int height )
+{
+    RECT rect;
+    HWND hwnd = GetDesktopWindow();
+
+    screen_width  = width;
+    screen_height = height;
+    TRACE("desktop %p change to (%dx%d)\n", hwnd, width, height);
+    SetRect( &rect, 0, 0, width, height );
+    WIN_SetRectangles( hwnd, &rect, &rect );
+    SendMessageTimeoutW( HWND_BROADCAST, WM_DISPLAYCHANGE, screen_depth,
+                         MAKELPARAM( width, height ), SMTO_ABORTIFHUNG, 2000, NULL );
+}
+
+
+/***********************************************************************
  *		X11DRV_ConfigureNotify
  */
 void X11DRV_ConfigureNotify( HWND hwnd, XConfigureEvent *event )
diff --git a/dlls/x11drv/x11drv.h b/dlls/x11drv/x11drv.h
index f36599e..2975646 100644
--- a/dlls/x11drv/x11drv.h
+++ b/dlls/x11drv/x11drv.h
@@ -222,6 +222,7 @@
 extern int client_side_antialias_with_core;
 extern int client_side_antialias_with_render;
 extern int using_client_side_fonts;
+extern int using_wine_desktop;
 extern void X11DRV_XRender_Init(void);
 extern void X11DRV_XRender_Finalize(void);
 extern BOOL X11DRV_XRender_SelectFont(X11DRV_PDEVICE*, HFONT);
@@ -551,6 +552,7 @@
 extern int X11DRV_sync_client_window_position( Display *display, WND *win );
 extern void X11DRV_set_wm_hints( Display *display, WND *win );
 
+extern void X11DRV_handle_desktop_resize(unsigned int width, unsigned int height);
 extern void X11DRV_Settings_AddDepthModes(void);
 extern void X11DRV_Settings_AddOneMode(unsigned int width, unsigned int height, unsigned int bpp, unsigned int freq);
 extern int X11DRV_Settings_CreateDriver(LPDDHALINFO info);
diff --git a/dlls/x11drv/x11drv_main.c b/dlls/x11drv/x11drv_main.c
index 25c02e5..f364ba8 100644
--- a/dlls/x11drv/x11drv_main.c
+++ b/dlls/x11drv/x11drv_main.c
@@ -90,6 +90,7 @@
 int client_side_with_render = 1;
 int client_side_antialias_with_core = 1;
 int client_side_antialias_with_render = 1;
+int using_wine_desktop = 0;
 
 unsigned int X11DRV_server_startticks;
 
@@ -380,7 +381,10 @@
     X11DRV_Settings_Init();
 
     if (desktop_geometry)
+    {
         root_window = X11DRV_create_desktop( desktop_vi, desktop_geometry );
+        using_wine_desktop = 1;
+    }
 
     /* initialize GDI */
     if(!X11DRV_GDI_Initialize( display ))
diff --git a/dlls/x11drv/xrandr.c b/dlls/x11drv/xrandr.c
index 81f3e27..53d3513 100644
--- a/dlls/x11drv/xrandr.c
+++ b/dlls/x11drv/xrandr.c
@@ -56,7 +56,6 @@
     return 1;
 }
 
-static Bool in_desktop_mode;
 
 /* create the mode structures */
 static void make_modes(void)
@@ -154,8 +153,6 @@
                               dd_modes[mode].dwWidth, dd_modes[mode].dwHeight, rate);
                         stat = XRRSetScreenConfigAndRate (gdi_display, sc, root, 
                                                           size, rot, rate, CurrentTime);
-                        FIXME("Need to update SYSMETRICS after resizing display (now %ldx%ld)\n",
-                              dd_modes[mode].dwWidth, dd_modes[mode].dwHeight);
                     }
                 }
             }
@@ -165,17 +162,15 @@
                       dd_modes[mode].dwWidth, dd_modes[mode].dwHeight);
                 stat = XRRSetScreenConfig (gdi_display, sc, root, 
                                            size, rot, CurrentTime);
-                FIXME("Need to update SYSMETRICS after resizing display (now %ldx%ld)\n",
-                      dd_modes[mode].dwWidth, dd_modes[mode].dwHeight);
             }
         }
     }
-    if (stat != RRSetConfigSuccess)
-    {
-        ERR("Resolution change not successful -- perhaps display has changed?\n");
-    }
     XRRFreeScreenConfigInfo(sc);
     wine_tsx11_unlock();
+    if (stat == RRSetConfigSuccess)
+        X11DRV_handle_desktop_resize( dd_modes[mode].dwWidth, dd_modes[mode].dwHeight );
+    else
+        ERR("Resolution change not successful -- perhaps display has changed?\n");
 }
 
 void X11DRV_XRandR_Init(void)
@@ -183,11 +178,10 @@
     Bool ok;
     int nmodes = 0;
     int i;
-    in_desktop_mode = (root_window != DefaultRootWindow(gdi_display));
 
     if (xrandr_major) return; /* already initialized? */
     if (!usexrandr) return; /* disabled in config */
-    if (in_desktop_mode) return; /* not compatible with desktop mode */
+    if (using_wine_desktop) return; /* not compatible with desktop mode */
 
     /* see if Xrandr is available */
     wine_tsx11_lock();
diff --git a/dlls/x11drv/xvidmode.c b/dlls/x11drv/xvidmode.c
index 19dfa9b..13b48f7 100644
--- a/dlls/x11drv/xvidmode.c
+++ b/dlls/x11drv/xvidmode.c
@@ -92,8 +92,6 @@
     return 1;
 }
 
-static Bool in_desktop_mode;
-
 int X11DRV_XF86VM_GetCurrentMode(void)
 {
   XF86VidModeModeLine line;
@@ -131,13 +129,6 @@
   TRACE("Resizing X display to %dx%d\n", 
         real_xf86vm_modes[mode]->hdisplay, real_xf86vm_modes[mode]->vdisplay);
   XF86VidModeSwitchToMode(gdi_display, DefaultScreen(gdi_display), real_xf86vm_modes[mode]);
-#if 0 /* FIXME */
-  SYSMETRICS_Set( SM_CXSCREEN, real_xf86vm_modes[mode]->hdisplay );
-  SYSMETRICS_Set( SM_CYSCREEN, real_xf86vm_modes[mode]->vdisplay );
-#else
-  FIXME("Need to update SYSMETRICS after resizing display (now %dx%d)\n",
-        real_xf86vm_modes[mode]->hdisplay, real_xf86vm_modes[mode]->vdisplay);
-#endif
 #if 0 /* it is said that SetViewPort causes problems with some X servers */
   XF86VidModeSetViewPort(gdi_display, DefaultScreen(gdi_display), 0, 0);
 #else
@@ -145,6 +136,8 @@
 #endif
   XSync(gdi_display, False);
   wine_tsx11_unlock();
+  X11DRV_handle_desktop_resize( real_xf86vm_modes[mode]->hdisplay,
+                                real_xf86vm_modes[mode]->vdisplay );
 }
 
 void X11DRV_XF86VM_Init(void)
@@ -154,8 +147,6 @@
   DWORD dwBpp = screen_depth;
   if (dwBpp == 24) dwBpp = 32;
 
-  in_desktop_mode = (root_window != DefaultRootWindow(gdi_display));
-
   if (xf86vm_major) return; /* already initialized? */
 
   if (!usexvidmode) return;
@@ -182,13 +173,13 @@
 #endif /* X_XF86VidModeSetGammaRamp */
 
       /* retrieve modes */
-      if (!in_desktop_mode) ok = XF86VidModeGetAllModeLines(gdi_display, DefaultScreen(gdi_display), &nmodes, &real_xf86vm_modes);
+      if (!using_wine_desktop) ok = XF86VidModeGetAllModeLines(gdi_display, DefaultScreen(gdi_display), &nmodes, &real_xf86vm_modes);
   }
   wine_tsx11_unlock();
   if (!ok) return;
 
   /* In desktop mode, do not switch resolution... But still use the Gamma ramp stuff */
-  if (in_desktop_mode) return;
+  if (using_wine_desktop) return;
   
   TRACE("XVidMode modes: count=%d\n", nmodes);