2 * X11DRV configuration code
4 * Copyright 2003 Mark Westcott
5 * Copyright 2003 Mike Hearn
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30 #include <wine/debug.h>
35 WINE_DEFAULT_DEBUG_CHANNEL(winecfg);
37 #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? */
41 void updateGUIForDesktopMode(HWND hDlg) {
46 /* do we have desktop mode enabled? */
47 if (doesConfigValueExist("x11drv", "Desktop") == S_OK) {
48 CheckDlgButton(hDlg, IDC_ENABLE_DESKTOP, BST_CHECKED);
49 /* enable the controls */
50 EnableWindow(GetDlgItem(hDlg, IDC_DESKTOP_WIDTH), 1);
51 EnableWindow(GetDlgItem(hDlg, IDC_DESKTOP_HEIGHT), 1);
52 EnableWindow(GetDlgItem(hDlg, IDC_DESKTOP_SIZE), 1);
53 EnableWindow(GetDlgItem(hDlg, IDC_DESKTOP_BY), 1);
54 SetWindowText(GetDlgItem(hDlg, IDC_DESKTOP_WIDTH), "640");
55 SetWindowText(GetDlgItem(hDlg, IDC_DESKTOP_HEIGHT), "480");
58 CheckDlgButton(hDlg, IDC_ENABLE_DESKTOP, BST_UNCHECKED);
59 /* disable the controls */
60 EnableWindow(GetDlgItem(hDlg, IDC_DESKTOP_WIDTH), 0);
61 EnableWindow(GetDlgItem(hDlg, IDC_DESKTOP_HEIGHT), 0);
62 EnableWindow(GetDlgItem(hDlg, IDC_DESKTOP_SIZE), 0);
63 EnableWindow(GetDlgItem(hDlg, IDC_DESKTOP_BY), 0);
65 SetWindowText(GetDlgItem(hDlg, IDC_DESKTOP_WIDTH), "");
66 SetWindowText(GetDlgItem(hDlg, IDC_DESKTOP_HEIGHT), "");
72 /* pokes the win32 api to setup the dialog from the config struct */
73 void initX11DrvDlg (HWND hDlg)
81 updateGUIForDesktopMode(hDlg);
84 buf = getConfigValue("x11drv", "Desktop", "640x480");
88 SetWindowText(GetDlgItem(hDlg, IDC_DESKTOP_WIDTH), buf);
89 SetWindowText(GetDlgItem(hDlg, IDC_DESKTOP_HEIGHT), i);
92 SendDlgItemMessage(hDlg, IDC_DESKTOP_WIDTH, EM_LIMITTEXT, RES_MAXLEN, 0);
93 SendDlgItemMessage(hDlg, IDC_DESKTOP_HEIGHT, EM_LIMITTEXT, RES_MAXLEN, 0);
100 void setFromDesktopSizeEdits(HWND hDlg) {
101 char *width = malloc(RES_MAXLEN+1);
102 char *height = malloc(RES_MAXLEN+1);
103 char *newStr = malloc((RES_MAXLEN*2) + 2);
105 if (updatingUI) return;
109 GetWindowText(GetDlgItem(hDlg, IDC_DESKTOP_WIDTH), width, RES_MAXLEN+1);
110 GetWindowText(GetDlgItem(hDlg, IDC_DESKTOP_HEIGHT), height, RES_MAXLEN+1);
112 if (strcmp(width, "") == 0) strcpy(width, "640");
113 if (strcmp(height, "") == 0) strcpy(height, "480");
115 sprintf(newStr, "%sx%s", width, height);
116 addTransaction("x11drv", "Desktop", ACTION_SET, newStr);
123 void onEnableDesktopClicked(HWND hDlg) {
125 if (IsDlgButtonChecked(hDlg, IDC_ENABLE_DESKTOP) == BST_CHECKED) {
126 /* it was just unchecked, so read the values of the edit boxes, set the config value */
127 setFromDesktopSizeEdits(hDlg);
129 /* it was just checked, so remove the config values */
130 addTransaction("x11drv", "Desktop", ACTION_REMOVE, NULL);
132 updateGUIForDesktopMode(hDlg);
136 X11DrvDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
143 switch(HIWORD(wParam)) {
145 SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0);
146 if ( (LOWORD(wParam) == IDC_DESKTOP_WIDTH) || (LOWORD(wParam) == IDC_DESKTOP_HEIGHT) ) setFromDesktopSizeEdits(hDlg);
150 WINE_TRACE("%ld\n", LOWORD(wParam));
151 switch(LOWORD(wParam)) {
152 case IDC_ENABLE_DESKTOP: onEnableDesktopClicked(hDlg); break;
164 switch (((LPNMHDR)lParam)->code) {
165 case PSN_KILLACTIVE: {
166 SetWindowLong(hDlg, DWL_MSGRESULT, FALSE);
170 SetWindowLong(hDlg, DWL_MSGRESULT, PSNRET_NOERROR);
173 case PSN_SETACTIVE: {
174 initX11DrvDlg (hDlg);