update sysmetrics after resolution changes

Alex Pasadyn ajp at mail.utexas.edu
Fri Oct 17 19:58:47 CDT 2003


Fixing my own FIXME...   This prevents some misplaced and incorrectly 
sized windows after changing resolutions.

ChangeLog:
- Update system metrics after resolution changes

-------------- next part --------------
Index: dlls/x11drv/desktop.c
===================================================================
RCS file: /home/wine/wine/dlls/x11drv/desktop.c,v
retrieving revision 1.16
diff -u -r1.16 desktop.c
--- dlls/x11drv/desktop.c	16 Oct 2003 00:21:42 -0000	1.16
+++ dlls/x11drv/desktop.c	18 Oct 2003 00:52:57 -0000
@@ -177,13 +177,6 @@
     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 );
Index: dlls/x11drv/xrandr.c
===================================================================
RCS file: /home/wine/wine/dlls/x11drv/xrandr.c,v
retrieving revision 1.1
diff -u -r1.1 xrandr.c
--- dlls/x11drv/xrandr.c	16 Oct 2003 00:21:42 -0000	1.1
+++ dlls/x11drv/xrandr.c	18 Oct 2003 00:52:57 -0000
@@ -156,8 +156,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);
                     }
                 }
             }
@@ -167,14 +165,17 @@
                       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)
+    if (stat == RRSetConfigSuccess)
+    {
+        screen_width  = dd_modes[mode].dwWidth;
+        screen_height = dd_modes[mode].dwHeight;
+    }
+    else
     {
-        ERR("Resolution change not successful -- perhaps display has chaned?");
+        ERR("Resolution change not successful -- perhaps display has changed?");
     }
     XRRFreeScreenConfigInfo(sc);
     wine_tsx11_unlock();
Index: dlls/x11drv/xvidmode.c
===================================================================
RCS file: /home/wine/wine/dlls/x11drv/xvidmode.c,v
retrieving revision 1.24
diff -u -r1.24 xvidmode.c
--- dlls/x11drv/xvidmode.c	16 Oct 2003 00:21:42 -0000	1.24
+++ dlls/x11drv/xvidmode.c	18 Oct 2003 00:52:58 -0000
@@ -128,13 +128,8 @@
   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
+  screen_width  = real_xf86vm_modes[mode]->hdisplay;
+  screen_height = real_xf86vm_modes[mode]->vdisplay;
 #if 0 /* it is said that SetViewPort causes problems with some X servers */
   XF86VidModeSetViewPort(gdi_display, DefaultScreen(gdi_display), 0, 0);
 #else
Index: windows/user.c
===================================================================
RCS file: /home/wine/wine/windows/user.c,v
retrieving revision 1.96
diff -u -r1.96 user.c
--- windows/user.c	5 Sep 2003 23:15:39 -0000	1.96
+++ windows/user.c	18 Oct 2003 00:52:58 -0000
@@ -391,14 +391,44 @@
 }
 
 /***********************************************************************
+ *		USER_EnumCallbackCDS (USER32.@)
+ *
+ * Callback function so we can update all existing windows
+ */
+static int new_bpp, new_width, new_height;
+static BOOL CALLBACK USER_EnumCallbackCDS(HWND hwnd, LPARAM ignored)
+{
+    WPARAM wParam = new_bpp;
+    LPARAM lParam = (new_height<<16) | new_width;
+    SendMessageA( hwnd, WM_DISPLAYCHANGE, wParam, lParam );
+    return TRUE;
+}
+
+/***********************************************************************
  *		ChangeDisplaySettingsExW (USER32.@)
  */
 LONG WINAPI ChangeDisplaySettingsExW( LPCWSTR devname, LPDEVMODEW devmode, HWND hwnd,
                                       DWORD flags, LPVOID lparam )
 {
     /* Pass the request on to the driver */
+    LONG res;
     if (!USER_Driver.pChangeDisplaySettingsExW) return DISP_CHANGE_FAILED;
-    return USER_Driver.pChangeDisplaySettingsExW( devname, devmode, hwnd, flags, lparam );
+    res = USER_Driver.pChangeDisplaySettingsExW( devname, devmode, hwnd, flags, lparam );
+    if (res == DISP_CHANGE_SUCCESSFUL)
+    {
+        /* update sysmetrics and applications */
+        HDC hdc = CreateDCA( "DISPLAY", NULL, NULL, NULL );
+        new_bpp = GetDeviceCaps( hdc, BITSPIXEL );
+        new_width = GetDeviceCaps( hdc, HORZRES );
+        new_height = GetDeviceCaps( hdc, VERTRES );
+        DeleteDC( hdc );
+        SYSMETRICS_Set( SM_CXSCREEN, new_width );
+        SYSMETRICS_Set( SM_CYSCREEN, new_height );
+        SYSMETRICS_Set( SM_WINE_BPP, new_bpp);
+        if (new_bpp == 24) new_bpp = 32;
+        EnumWindows(USER_EnumCallbackCDS, 0);
+    }
+    return res;
 }
 
 /***********************************************************************


More information about the wine-patches mailing list