summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChun-wei Fan <fanchunwei@src.gnome.org>2014-03-07 12:28:40 +0800
committerChun-wei Fan <fanchunwei@src.gnome.org>2014-03-08 18:38:00 +0800
commit293f35ef6f0805590e1d3d0d139b9c9dbde0fe3b (patch)
tree7151b84a1b4f6b60d524ebcc14611e5b04d21f32
parent6665f47d66a871b6e1a5f4200282f42da043a0e8 (diff)
downloadclutter-293f35ef6f0805590e1d3d0d139b9c9dbde0fe3b.tar.gz
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
-rw-r--r--clutter/win32/clutter-stage-win32.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/clutter/win32/clutter-stage-win32.c b/clutter/win32/clutter-stage-win32.c
index bcc39a7d3..cdc1fc69b 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