[clutter] Fix The Win32 Backend for Newer Visual Studio Versions



commit ae58ad8c465f377fc769b246fb261e1cbb8d48cd
Author: Chun-wei Fan <fanchunwei src gnome org>
Date:   Fri Mar 7 12:28:40 2014 +0800

    Fix The Win32 Backend for Newer Visual Studio Versions
    
    The GetSystemMetrics() function returns wrong values for SM_CXSIZEFRAME,
    SM_CYSIZEFRAME, SM_CXFIXEDFRAME and SM_CYFIXEDFRAME when built with Visual
    Studio 2012 and 2013 (unless the XP compatibility setting for the
    PlatformToolset entry is turned on), causing the window of Clutter programs
    to automatically shrink to a point where they become unusable.
    
    This patch uses AdjustWindowRectEx() for builds using Visual Studio 2012
    and later, which deduces the required height and width of the Window
    properly.  Unfortunately we can't use this for the VS 2008/2010 builds as
    they cause the Window to continually expand as the program is run.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=725873

 clutter/win32/clutter-stage-win32.c |   25 ++++++++++++++++++++-----
 1 files changed, 20 insertions(+), 5 deletions(-)
---
diff --git a/clutter/win32/clutter-stage-win32.c b/clutter/win32/clutter-stage-win32.c
index 733f01f..b7eae25 100644
--- a/clutter/win32/clutter-stage-win32.c
+++ b/clutter/win32/clutter-stage-win32.c
@@ -138,11 +138,26 @@ get_full_window_size (ClutterStageWin32 *stage_win32,
     = clutter_stage_get_user_resizable (stage_win32->wrapper);
   /* The window size passed to CreateWindow includes the window
      decorations */
-  *width_out = width_in + GetSystemMetrics (resizable ? SM_CXSIZEFRAME
-                                           : SM_CXFIXEDFRAME) * 2;
-  *height_out = height_in + GetSystemMetrics (resizable ? SM_CYSIZEFRAME
-                                             : SM_CYFIXEDFRAME) * 2
-    + GetSystemMetrics (SM_CYCAPTION);
+  gint frame_width, frame_height;
+
+#if !defined (_MSC_VER) || (_MSC_VER < 1700)
+  frame_width = GetSystemMetrics (resizable ? SM_CXSIZEFRAME : SM_CXFIXEDFRAME);
+  frame_height = GetSystemMetrics (resizable ? SM_CYSIZEFRAME : SM_CYFIXEDFRAME);
+#else
+  /* MSVC 2012 and later returns wrong values from GetSystemMetrics()
+   * 
http://connect.microsoft.com/VisualStudio/feedback/details/753224/regression-getsystemmetrics-delivers-different-values
+   *
+   * For AdjustWindowRectEx(), it doesn't matter much whether the Window is resizble.
+   */
+
+  RECT cxrect = {0, 0, 0, 0};
+  AdjustWindowRectEx (&cxrect, WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_THICKFRAME | WS_DLGFRAME, 
FALSE, 0);
+
+  frame_width = abs (cxrect.bottom);
+  frame_height = abs (cxrect.left);
+#endif
+  *width_out = width_in + frame_width * 2;
+  *height_out = height_in + frame_height * 2 + GetSystemMetrics (SM_CYCAPTION);
 }
 
 void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]