From 3c9eab9f6e96d05a6e5ca0f82d6b52a07092c526 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Sun, 14 Dec 2014 20:42:45 +0100
Subject: winecfg: Add staging tab for CSMT.

---
 programs/winecfg/Makefile.in |  1 +
 programs/winecfg/main.c      | 12 +++++-
 programs/winecfg/resource.h  |  5 +++
 programs/winecfg/staging.c   | 89 ++++++++++++++++++++++++++++++++++++++++++++
 programs/winecfg/winecfg.h   |  1 +
 programs/winecfg/winecfg.rc  | 10 +++++
 6 files changed, 117 insertions(+), 1 deletion(-)
 create mode 100644 programs/winecfg/staging.c

diff --git a/programs/winecfg/Makefile.in b/programs/winecfg/Makefile.in
index 4e66e04..1cf7031 100644
--- a/programs/winecfg/Makefile.in
+++ b/programs/winecfg/Makefile.in
@@ -11,6 +11,7 @@ C_SRCS = \
 	driveui.c \
 	libraries.c \
 	main.c \
+	staging.c \
 	theme.c \
 	winecfg.c \
 	x11drvdlg.c
diff --git a/programs/winecfg/main.c b/programs/winecfg/main.c
index 6ac5f89..17909dc 100644
--- a/programs/winecfg/main.c
+++ b/programs/winecfg/main.c
@@ -60,7 +60,7 @@ PropSheetCallback (HWND hWnd, UINT uMsg, LPARAM lParam)
     return 0;
 }
 
-#define NUM_PROPERTY_PAGES 7
+#define NUM_PROPERTY_PAGES 8
 
 static INT_PTR
 doPropertySheet (HINSTANCE hInstance, HWND hOwner)
@@ -141,6 +141,16 @@ doPropertySheet (HINSTANCE hInstance, HWND hOwner)
     psp[pg].lParam = 0;
     pg++;
 
+    psp[pg].dwSize = sizeof (PROPSHEETPAGEW);
+    psp[pg].dwFlags = PSP_USETITLE;
+    psp[pg].hInstance = hInstance;
+    psp[pg].u.pszTemplate = MAKEINTRESOURCEW (IDD_STAGING);
+    psp[pg].u2.pszIcon = NULL;
+    psp[pg].pfnDlgProc = StagingDlgProc;
+    psp[pg].pszTitle =  load_string (IDS_TAB_STAGING);
+    psp[pg].lParam = 0;
+    pg++;
+
     /*
      * Fill out the (General) PROPSHEETPAGE data structure 
      * for the property sheet
diff --git a/programs/winecfg/resource.h b/programs/winecfg/resource.h
index fffc4da..7d11050 100644
--- a/programs/winecfg/resource.h
+++ b/programs/winecfg/resource.h
@@ -45,6 +45,7 @@
 #define IDS_SHELL_FOLDER                16
 #define IDS_LINKS_TO                    17
 #define IDS_WINECFG_TITLE_APP           18   /* App specific title */
+#define IDS_TAB_STAGING                 19
 #define IDI_WINECFG                     100
 #define IDI_LOGO                        102
 #define IDD_ABOUTCFG                    107
@@ -54,6 +55,7 @@
 #define IDD_DLLCFG                      111
 #define IDD_DRIVECFG                    112
 #define IDD_DESKTOP_INTEGRATION         115
+#define IDD_STAGING                     116
 #define IDC_WINVER                      1012
 #define IDC_DESKTOP_WIDTH               1023
 #define IDC_DESKTOP_HEIGHT              1024
@@ -202,6 +204,9 @@
 #define IDC_SYSPARAMS_MENU_HILIGHT      8430
 #define IDC_SYSPARAMS_MENUBAR           8431
 
+/* Staging tab */
+#define IDC_ENABLE_CSMT                 9001
+
 /* About tab */
 #define IDC_ABT_OWNER                8432
 #define IDC_ABT_ORG                  8433
diff --git a/programs/winecfg/staging.c b/programs/winecfg/staging.c
new file mode 100644
index 0000000..09c0d3f
--- /dev/null
+++ b/programs/winecfg/staging.c
@@ -0,0 +1,89 @@
+/*
+ * WineCfg Staging panel
+ *
+ * Copyright 2014 Michael Müller
+ * Copyright 2015 Sebastian Lackner
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ *
+ */
+
+#define COBJMACROS
+
+#include "config.h"
+
+#include <windows.h>
+#include <wine/unicode.h>
+#include <wine/debug.h>
+
+#include "resource.h"
+#include "winecfg.h"
+
+WINE_DEFAULT_DEBUG_CHANNEL(winecfg);
+
+/*
+ * Command stream multithreading
+ */
+static BOOL csmt_get(void)
+{
+    BOOL ret;
+    char *value = get_reg_key(config_key, keypath("DllRedirects"), "wined3d", NULL);
+    ret = (value && !strcmp(value, "wined3d-csmt.dll"));
+    HeapFree(GetProcessHeap(), 0, value);
+    return ret;
+}
+static void csmt_set(BOOL status)
+{
+    set_reg_key(config_key, keypath("DllRedirects"), "wined3d", status ? "wined3d-csmt.dll" : NULL);
+}
+
+
+static void load_staging_settings(HWND dialog)
+{
+    CheckDlgButton(dialog, IDC_ENABLE_CSMT, csmt_get() ? BST_CHECKED : BST_UNCHECKED);
+}
+
+INT_PTR CALLBACK StagingDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
+{
+    switch (uMsg)
+    {
+    case WM_INITDIALOG:
+        break;
+
+    case WM_NOTIFY:
+        if (((LPNMHDR)lParam)->code == PSN_SETACTIVE)
+            load_staging_settings(hDlg);
+        break;
+
+    case WM_SHOWWINDOW:
+        set_window_title(hDlg);
+        break;
+
+    case WM_DESTROY:
+        break;
+
+    case WM_COMMAND:
+        if (HIWORD(wParam) != BN_CLICKED) break;
+        switch (LOWORD(wParam))
+        {
+        case IDC_ENABLE_CSMT:
+            csmt_set(IsDlgButtonChecked(hDlg, IDC_ENABLE_CSMT) == BST_CHECKED);
+            SendMessageW(GetParent(hDlg), PSM_CHANGED, 0, 0);
+            return TRUE;
+        }
+        break;
+    }
+    return FALSE;
+}
diff --git a/programs/winecfg/winecfg.h b/programs/winecfg/winecfg.h
index 110856a..a949474 100644
--- a/programs/winecfg/winecfg.h
+++ b/programs/winecfg/winecfg.h
@@ -87,6 +87,7 @@ INT_PTR CALLBACK AppDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 INT_PTR CALLBACK LibrariesDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
 INT_PTR CALLBACK AudioDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
 INT_PTR CALLBACK ThemeDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
+INT_PTR CALLBACK StagingDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
 INT_PTR CALLBACK AboutDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
 
 /* Drive management  */
diff --git a/programs/winecfg/winecfg.rc b/programs/winecfg/winecfg.rc
index 9f763a7..ad3e842 100644
--- a/programs/winecfg/winecfg.rc
+++ b/programs/winecfg/winecfg.rc
@@ -39,6 +39,7 @@ BEGIN
     IDS_TAB_GRAPHICS        "Graphics"
     IDS_TAB_DESKTOP_INTEGRATION "Desktop Integration"
     IDS_TAB_AUDIO           "Audio"
+    IDS_TAB_STAGING         "Staging"
     IDS_TAB_ABOUT           "About"
     IDS_WINECFG_TITLE       "Wine configuration"
     IDS_WINECFG_TITLE_APP   "Wine configuration for %s"
@@ -297,6 +298,15 @@ BEGIN
     PUSHBUTTON      "B&rowse...",IDC_BROWSE_SFPATH,195,195,50,13,WS_DISABLED
 END
 
+IDD_STAGING DIALOG  0, 0, 260, 220
+STYLE WS_CHILD | WS_DISABLED
+FONT 8, "MS Shell Dlg"
+BEGIN
+    GROUPBOX    "Staging settings",IDC_STATIC,8,4,244,210
+    LTEXT       "The following settings are experimental and may break stuff!\nMake sure to reset them again in case of a problem.",IDC_STATIC,16,16,230,16
+    CONTROL     "Enable &CSMT for better graphic performance",IDC_ENABLE_CSMT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,40,230,8
+END
+
 LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
 
 /* @makedep: winecfg.ico */
-- 
2.2.1

