1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
/*
* Graphics configuration code
*
* Copyright 2003 Mark Westcott
* Copyright 2003-2004 Mike Hearn
* Copyright 2005 Raphael Junqueira
*
* 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 WIN32_LEAN_AND_MEAN
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <windows.h>
#include <wine/debug.h>
#include "resource.h"
#include "winecfg.h"
WINE_DEFAULT_DEBUG_CHANNEL(winecfg);
#define RES_MAXLEN 5 /* the maximum number of characters in a screen dimension. 5 digits should be plenty, what kind of crazy person runs their screen >10,000 pixels across? */
static struct SHADERMODE
{
UINT displayStrID;
const char* settingStr;
} const D3D_VS_Modes[] = {
{IDS_SHADER_MODE_HARDWARE, "hardware"},
{IDS_SHADER_MODE_NONE, "none"},
{0, 0}
};
int updating_ui;
static void update_gui_for_desktop_mode(HWND dialog) {
int desktopenabled = FALSE;
WINE_TRACE("\n");
updating_ui = TRUE;
if (current_app)
{
disable(IDC_ENABLE_DESKTOP);
disable(IDC_DESKTOP_WIDTH);
disable(IDC_DESKTOP_HEIGHT);
disable(IDC_DESKTOP_SIZE);
disable(IDC_DESKTOP_BY);
return;
}
enable(IDC_ENABLE_DESKTOP);
/* do we have desktop mode enabled? */
if (reg_key_exists(config_key, keypath("X11 Driver"), "Desktop"))
{
char* buf, *bufindex;
CheckDlgButton(dialog, IDC_ENABLE_DESKTOP, BST_CHECKED);
buf = get_reg_key(config_key, keypath("X11 Driver"), "Desktop", "640x480");
/* note: this test must match the one in x11drv */
if( buf[0] != 'n' && buf[0] != 'N' && buf[0] != 'F' && buf[0] != 'f'
&& buf[0] != '0') {
desktopenabled = TRUE;
enable(IDC_DESKTOP_WIDTH);
enable(IDC_DESKTOP_HEIGHT);
enable(IDC_DESKTOP_SIZE);
enable(IDC_DESKTOP_BY);
bufindex = strchr(buf, 'x');
if (bufindex) {
*bufindex = 0;
++bufindex;
SetWindowText(GetDlgItem(dialog, IDC_DESKTOP_WIDTH), buf);
SetWindowText(GetDlgItem(dialog, IDC_DESKTOP_HEIGHT), bufindex);
} else {
WINE_TRACE("Desktop registry entry is malformed\n");
SetWindowText(GetDlgItem(dialog, IDC_DESKTOP_WIDTH), "640");
SetWindowText(GetDlgItem(dialog, IDC_DESKTOP_HEIGHT), "480");
}
}
HeapFree(GetProcessHeap(), 0, buf);
}
if (!desktopenabled)
{
CheckDlgButton(dialog, IDC_ENABLE_DESKTOP, BST_UNCHECKED);
disable(IDC_DESKTOP_WIDTH);
disable(IDC_DESKTOP_HEIGHT);
disable(IDC_DESKTOP_SIZE);
disable(IDC_DESKTOP_BY);
SetWindowText(GetDlgItem(dialog, IDC_DESKTOP_WIDTH), "");
SetWindowText(GetDlgItem(dialog, IDC_DESKTOP_HEIGHT), "");
}
updating_ui = FALSE;
}
static void init_dialog(HWND dialog)
{
unsigned int it;
char* buf;
update_gui_for_desktop_mode(dialog);
updating_ui = TRUE;
SendDlgItemMessage(dialog, IDC_DESKTOP_WIDTH, EM_LIMITTEXT, RES_MAXLEN, 0);
SendDlgItemMessage(dialog, IDC_DESKTOP_HEIGHT, EM_LIMITTEXT, RES_MAXLEN, 0);
buf = get_reg_key(config_key, keypath("X11 Driver"), "DXGrab", "N");
if (IS_OPTION_TRUE(*buf))
CheckDlgButton(dialog, IDC_DX_MOUSE_GRAB, BST_CHECKED);
else
CheckDlgButton(dialog, IDC_DX_MOUSE_GRAB, BST_UNCHECKED);
HeapFree(GetProcessHeap(), 0, buf);
buf = get_reg_key(config_key, keypath("X11 Driver"), "Managed", "Y");
if (IS_OPTION_TRUE(*buf))
CheckDlgButton(dialog, IDC_ENABLE_MANAGED, BST_CHECKED);
else
CheckDlgButton(dialog, IDC_ENABLE_MANAGED, BST_UNCHECKED);
HeapFree(GetProcessHeap(), 0, buf);
SendDlgItemMessage(dialog, IDC_D3D_VSHADER_MODE, CB_RESETCONTENT, 0, 0);
for (it = 0; 0 != D3D_VS_Modes[it].displayStrID; ++it) {
SendDlgItemMessageW (dialog, IDC_D3D_VSHADER_MODE, CB_ADDSTRING, 0,
(LPARAM)load_string (D3D_VS_Modes[it].displayStrID));
}
buf = get_reg_key(config_key, keypath("Direct3D"), "VertexShaderMode", "hardware");
for (it = 0; NULL != D3D_VS_Modes[it].settingStr; ++it) {
if (strcmp(buf, D3D_VS_Modes[it].settingStr) == 0) {
SendDlgItemMessage(dialog, IDC_D3D_VSHADER_MODE, CB_SETCURSEL, it, 0);
break ;
}
}
if (NULL == D3D_VS_Modes[it].settingStr) {
WINE_ERR("Invalid Direct3D VertexShader Mode read from registry (%s)\n", buf);
}
HeapFree(GetProcessHeap(), 0, buf);
buf = get_reg_key(config_key, keypath("Direct3D"), "PixelShaderMode", "enabled");
if (!strcmp(buf, "enabled"))
CheckDlgButton(dialog, IDC_D3D_PSHADER_MODE, BST_CHECKED);
else
CheckDlgButton(dialog, IDC_D3D_PSHADER_MODE, BST_UNCHECKED);
HeapFree(GetProcessHeap(), 0, buf);
updating_ui = FALSE;
}
static void set_from_desktop_edits(HWND dialog) {
char *width, *height, *new;
if (updating_ui) return;
WINE_TRACE("\n");
width = get_text(dialog, IDC_DESKTOP_WIDTH);
height = get_text(dialog, IDC_DESKTOP_HEIGHT);
if (width == NULL || strcmp(width, "") == 0) {
HeapFree(GetProcessHeap(), 0, width);
width = strdupA("640");
}
if (height == NULL || strcmp(height, "") == 0) {
HeapFree(GetProcessHeap(), 0, height);
height = strdupA("480");
}
new = HeapAlloc(GetProcessHeap(), 0, strlen(width) + strlen(height) + 2 /* x + terminator */);
sprintf(new, "%sx%s", width, height);
set_reg_key(config_key, keypath("X11 Driver"), "Desktop", new);
HeapFree(GetProcessHeap(), 0, width);
HeapFree(GetProcessHeap(), 0, height);
HeapFree(GetProcessHeap(), 0, new);
}
static void on_enable_desktop_clicked(HWND dialog) {
WINE_TRACE("\n");
if (IsDlgButtonChecked(dialog, IDC_ENABLE_DESKTOP) == BST_CHECKED) {
set_from_desktop_edits(dialog);
} else {
set_reg_key(config_key, keypath("X11 Driver"), "Desktop", NULL);
}
update_gui_for_desktop_mode(dialog);
}
static void on_enable_managed_clicked(HWND dialog) {
WINE_TRACE("\n");
if (IsDlgButtonChecked(dialog, IDC_ENABLE_MANAGED) == BST_CHECKED) {
set_reg_key(config_key, keypath("X11 Driver"), "Managed", "Y");
} else {
set_reg_key(config_key, keypath("X11 Driver"), "Managed", "N");
}
}
static void on_dx_mouse_grab_clicked(HWND dialog) {
if (IsDlgButtonChecked(dialog, IDC_DX_MOUSE_GRAB) == BST_CHECKED)
set_reg_key(config_key, keypath("X11 Driver"), "DXGrab", "Y");
else
set_reg_key(config_key, keypath("X11 Driver"), "DXGrab", "N");
}
static void on_d3d_vshader_mode_changed(HWND dialog) {
int selected_mode = SendDlgItemMessage(dialog, IDC_D3D_VSHADER_MODE, CB_GETCURSEL, 0, 0);
set_reg_key(config_key, keypath("Direct3D"), "VertexShaderMode",
D3D_VS_Modes[selected_mode].settingStr);
}
static void on_d3d_pshader_mode_clicked(HWND dialog) {
if (IsDlgButtonChecked(dialog, IDC_D3D_PSHADER_MODE) == BST_CHECKED)
set_reg_key(config_key, keypath("Direct3D"), "PixelShaderMode", "enabled");
else
set_reg_key(config_key, keypath("Direct3D"), "PixelShaderMode", "disabled");
}
INT_PTR CALLBACK
GraphDlgProc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg) {
case WM_INITDIALOG:
break;
case WM_SHOWWINDOW:
set_window_title(hDlg);
break;
case WM_COMMAND:
switch(HIWORD(wParam)) {
case EN_CHANGE: {
if (updating_ui) break;
SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0);
if ( ((LOWORD(wParam) == IDC_DESKTOP_WIDTH) || (LOWORD(wParam) == IDC_DESKTOP_HEIGHT)) && !updating_ui )
set_from_desktop_edits(hDlg);
break;
}
case BN_CLICKED: {
if (updating_ui) break;
SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0);
switch(LOWORD(wParam)) {
case IDC_ENABLE_DESKTOP: on_enable_desktop_clicked(hDlg); break;
case IDC_ENABLE_MANAGED: on_enable_managed_clicked(hDlg); break;
case IDC_DX_MOUSE_GRAB: on_dx_mouse_grab_clicked(hDlg); break;
case IDC_D3D_PSHADER_MODE: on_d3d_pshader_mode_clicked(hDlg); break;
}
break;
}
case CBN_SELCHANGE: {
SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0);
switch (LOWORD(wParam)) {
case IDC_D3D_VSHADER_MODE: on_d3d_vshader_mode_changed(hDlg); break;
}
break;
}
default:
break;
}
break;
case WM_NOTIFY:
switch (((LPNMHDR)lParam)->code) {
case PSN_KILLACTIVE: {
SetWindowLongPtr(hDlg, DWLP_MSGRESULT, FALSE);
break;
}
case PSN_APPLY: {
apply();
SetWindowLongPtr(hDlg, DWLP_MSGRESULT, PSNRET_NOERROR);
break;
}
case PSN_SETACTIVE: {
init_dialog (hDlg);
break;
}
}
break;
default:
break;
}
return FALSE;
}