Mark Westcott <mark@houseoffish.org> Mike Hearn <mike@theoretic.com> - Rename hSession to configKey - Make the config struct a global, rename to "config" - Correct bug in OK/Cancel handling - Merge X11DRV dialog code from Mark - Add newline to the initial FIXME diff -ur --exclude-from=diff-exclusions ../head/programs/winecfg/main.c programs/winecfg/main.c --- ../head/programs/winecfg/main.c 2003-08-28 12:17:50.000000000 +0100 +++ programs/winecfg/main.c 2003-08-28 11:52:40.000000000 +0100 @@ -3,6 +3,7 @@ * * Copyright 2002 Jaco Greeff * Copyright 2003 Dimitrie O. Paun + * Copyright 2003 Mike Hearn * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -35,7 +36,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(winecfg); -WINECFG_DESC sCfg; +WINECFG_DESC config; void CALLBACK PropSheetCallback (HWND hWnd, UINT uMsg, LPARAM lParam) @@ -68,7 +69,7 @@ { SendDlgItemMessage (hDlg, IDC_WINVER, CB_ADDSTRING, 0, (LPARAM) pVer->szDescription); - if (!strcmp (pVer->szVersion, sCfg.szWinVer)) + if (!strcmp (pVer->szVersion, config.szWinVer)) SendDlgItemMessage (hDlg, IDC_WINVER, CB_SETCURSEL, (WPARAM) i, 0); } @@ -79,7 +80,7 @@ { SendDlgItemMessage (hDlg, IDC_DOSVER, CB_ADDSTRING, 0, (LPARAM) pVer->szDescription); - if (!strcmp (pVer->szVersion, sCfg.szDOSVer)) + if (!strcmp (pVer->szVersion, config.szDOSVer)) SendDlgItemMessage (hDlg, IDC_DOSVER, CB_SETCURSEL, (WPARAM) i, 0); } @@ -90,7 +91,7 @@ { SendDlgItemMessage (hDlg, IDC_WINELOOK, CB_ADDSTRING, 0, (LPARAM) pVer->szDescription); - if (!strcmp (pVer->szVersion, sCfg.szWinLook)) + if (!strcmp (pVer->szVersion, config.szWinLook)) SendDlgItemMessage (hDlg, IDC_WINELOOK, CB_SETCURSEL, (WPARAM) i, 0); } @@ -116,7 +117,7 @@ while (selection > 0) { desc++; selection--; } - strcpy(sCfg.szWinVer, desc->szVersion); + strcpy(config.szWinVer, desc->szVersion); } break; } @@ -159,39 +160,6 @@ return FALSE; } -void -initX11DrvDlg (HWND hDlg) -{ - char szBuf[20]; - - sprintf (szBuf, "%d", sCfg.sX11Drv.nSysColors); - SendDlgItemMessage (hDlg, IDC_SYSCOLORS, WM_SETTEXT, 0, (LPARAM) szBuf); - sprintf (szBuf, "%d", sCfg.sX11Drv.nDesktopSizeX); - SendDlgItemMessage (hDlg, IDC_DESKTOP_WIDTH, WM_SETTEXT, 0, - (LPARAM) szBuf); - sprintf (szBuf, "%d", sCfg.sX11Drv.nDesktopSizeY); - SendDlgItemMessage (hDlg, IDC_DESKTOP_HEIGHT, WM_SETTEXT, 0, - (LPARAM) szBuf); -} - -INT_PTR CALLBACK -X11DrvDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) -{ - switch (uMsg) - { - case WM_INITDIALOG: - initX11DrvDlg (hDlg); - break; - - case WM_COMMAND: - break; - - default: - break; - } - return FALSE; -} - #define NUM_PROPERTY_PAGES 4 INT_PTR doPropertySheet (HINSTANCE hInstance, HWND hOwner) @@ -286,21 +254,21 @@ /* Until winecfg is fully functional, warn users that it is incomplete and doesn't do anything */ WINE_FIXME("The winecfg tool is not yet complete, and does not actually alter your configuration.\n"); - WINE_FIXME("If you want to alter the way Wine works, look in the ~/.wine/config file for more information."); + WINE_FIXME("If you want to alter the way Wine works, look in the ~/.wine/config file for more information.\n"); /* * Load the configuration from registry */ - loadConfig (&sCfg); + loadConfig (&config); /* * The next 3 lines should be all that is needed * for the Wine Configuration property sheet */ InitCommonControls (); - if (doPropertySheet (hInstance, NULL) >= 0) { + if (doPropertySheet (hInstance, NULL) > 0) { WINE_TRACE("OK\n"); - saveConfig(&sCfg); + saveConfig(&config); } else WINE_TRACE("Cancel\n"); diff -ur --exclude-from=diff-exclusions ../head/programs/winecfg/Makefile.in programs/winecfg/Makefile.in --- ../head/programs/winecfg/Makefile.in 2003-08-28 12:17:50.000000000 +0100 +++ programs/winecfg/Makefile.in 2003-08-28 11:54:33.000000000 +0100 @@ -9,7 +9,8 @@ C_SRCS = \ main.c \ properties.c \ - winecfg.c + winecfg.c \ + x11drvdlg.c RC_SRCS = winecfg.rc diff -ur --exclude-from=diff-exclusions ../head/programs/winecfg/properties.h programs/winecfg/properties.h --- ../head/programs/winecfg/properties.h 2003-08-28 12:17:50.000000000 +0100 +++ programs/winecfg/properties.h 2003-08-27 11:58:27.000000000 +0100 @@ -64,6 +64,9 @@ int nDesktopSizeY; int nDGA; int nXVidMode; + int nXShm; + int nTextCP; + int nXVideoPort; int nTakeFocus; int nDXGrab; int nDoubleBuffered; Only in programs/winecfg: TODO diff -ur --exclude-from=diff-exclusions ../head/programs/winecfg/winecfg.c programs/winecfg/winecfg.c --- ../head/programs/winecfg/winecfg.c 2003-08-28 12:17:50.000000000 +0100 +++ programs/winecfg/winecfg.c 2003-08-28 12:20:03.000000000 +0100 @@ -3,6 +3,7 @@ * * Copyright 2002 Jaco Greeff * Copyright 2003 Dimitrie O. Paun + * Copyright 2003 Mike Hearn * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -30,6 +31,7 @@ #include "winecfg.h" +HKEY configKey = NULL; /***************************************************************************** */ @@ -188,13 +190,12 @@ int loadConfig (WINECFG_DESC* pCfg) { const DLL_DESC *pDllDefaults; - - HKEY hSession=NULL; + char buffer[MAX_PATH]; DWORD res; WINE_TRACE("\n"); - res = RegCreateKey(HKEY_LOCAL_MACHINE, WINEHQ_KEY_ROOT, &hSession); + res = RegCreateKey(HKEY_LOCAL_MACHINE, WINEHQ_KEY_ROOT, &configKey); if (res != ERROR_SUCCESS) { WINE_ERR("RegOpenKey failed on wine config key (%ld)\n", res); @@ -202,19 +203,19 @@ } /* Windows and DOS versions */ - getConfigValue(hSession, "Version", "Windows", pCfg->szWinVer, MAX_VERSION_LENGTH, "win95"); - getConfigValue(hSession, "Version", "DOS", pCfg->szDOSVer, MAX_VERSION_LENGTH, "6.22"); - getConfigValue(hSession, "Tweak.Layout", "WineLook", pCfg->szWinLook, MAX_VERSION_LENGTH, "win95"); + getConfigValue(configKey, "Version", "Windows", pCfg->szWinVer, MAX_VERSION_LENGTH, "win95"); + getConfigValue(configKey, "Version", "DOS", pCfg->szDOSVer, MAX_VERSION_LENGTH, "6.22"); + getConfigValue(configKey, "Tweak.Layout", "WineLook", pCfg->szWinLook, MAX_VERSION_LENGTH, "win95"); /* System Paths */ - getConfigValue(hSession, "Wine", "Windows", pCfg->szWinDir, MAX_PATH, "c:\\Windows"); - getConfigValue(hSession, "Wine", "System", pCfg->szWinSysDir, MAX_PATH, "c:\\Windows\\System"); - getConfigValue(hSession, "Wine", "Temp", pCfg->szWinTmpDir, MAX_PATH, "c:\\Windows\\Temp"); - getConfigValue(hSession, "Wine", "Profile", pCfg->szWinProfDir, MAX_PATH, "c:\\Windows\\Profiles\\Administrator"); - getConfigValue(hSession, "Wine", "Path", pCfg->szWinPath, MAX_PATH, "c:\\Windows;c:\\Windows\\System"); + getConfigValue(configKey, "Wine", "Windows", pCfg->szWinDir, MAX_PATH, "c:\\Windows"); + getConfigValue(configKey, "Wine", "System", pCfg->szWinSysDir, MAX_PATH, "c:\\Windows\\System"); + getConfigValue(configKey, "Wine", "Temp", pCfg->szWinTmpDir, MAX_PATH, "c:\\Windows\\Temp"); + getConfigValue(configKey, "Wine", "Profile", pCfg->szWinProfDir, MAX_PATH, "c:\\Windows\\Profiles\\Administrator"); + getConfigValue(configKey, "Wine", "Path", pCfg->szWinPath, MAX_PATH, "c:\\Windows;c:\\Windows\\System"); /* Graphics driver */ - getConfigValue(hSession, "Wine", "GraphicsDriver", pCfg->szGraphDriver, MAX_NAME_LENGTH, "x11drv"); + getConfigValue(configKey, "Wine", "GraphicsDriver", pCfg->szGraphDriver, MAX_NAME_LENGTH, "x11drv"); /* * DLL defaults for all applications is built using @@ -232,15 +233,28 @@ * level (if not set, this defaults to what * is already there) */ - /* FIXME: TODO */ + + /* FIXME: Finish these off. Do we actually need GUI for all of them? */ /* * X11Drv defaults */ - strcpy(pCfg->sX11Drv.szX11Display, ":0.0"); - pCfg->sX11Drv.nSysColors = 100; - pCfg->sX11Drv.nPrivateMap = 0; - pCfg->sX11Drv.nPerfect = 0; + getConfigValue(configKey, "x11drv", "Display", pCfg->sX11Drv.szX11Display, sizeof(pCfg->sX11Drv.szX11Display), ":0.0"); + + getConfigValue(configKey, "x11drv", "AllocSystemColors", buffer, sizeof(buffer), "100"); + pCfg->sX11Drv.nSysColors = atoi(buffer); + + getConfigValue(configKey, "x11drv", "PrivateColorMap", buffer, sizeof(buffer), "N"); + pCfg->sX11Drv.nPrivateMap = IS_OPTION_TRUE(buffer[0]); + + getConfigValue(configKey, "x11drv", "PerfectGraphics", buffer, sizeof(buffer), "N"); + pCfg->sX11Drv.nPerfect = IS_OPTION_TRUE(buffer[0]); + + getConfigValue(configKey, "x11drv", "Desktop", buffer, sizeof(buffer), "640x480"); + sscanf(buffer, "%dx%d", &pCfg->sX11Drv.nDesktopSizeX, &pCfg->sX11Drv.nDesktopSizeY); + + pCfg->sX11Drv.nTextCP = 0; + pCfg->sX11Drv.nXVideoPort = 43; pCfg->sX11Drv.nDepth = 16; pCfg->sX11Drv.nManaged = 1; pCfg->sX11Drv.nDesktopSizeX = 640; @@ -252,8 +266,7 @@ pCfg->sX11Drv.nDoubleBuffered = 0; pCfg->sX11Drv.nSynchronous = 1; - RegCloseKey( hSession ); - + RegCloseKey( configKey ); return 0; } diff -ur --exclude-from=diff-exclusions ../head/programs/winecfg/winecfg.h programs/winecfg/winecfg.h --- ../head/programs/winecfg/winecfg.h 2003-08-28 12:17:50.000000000 +0100 +++ programs/winecfg/winecfg.h 2003-08-28 11:43:14.000000000 +0100 @@ -25,6 +25,11 @@ #include "properties.h" +#define IS_OPTION_TRUE(ch) \ + ((ch) == 'y' || (ch) == 'Y' || (ch) == 't' || (ch) == 'T' || (ch) == '1') +#define IS_OPTION_FALSE(ch) \ + ((ch) == 'n' || (ch) == 'N' || (ch) == 'f' || (ch) == 'F' || (ch) == '0') + typedef struct structWineCfg { char szWinVer[MAX_VERSION_LENGTH]; @@ -45,13 +50,22 @@ X11DRV_DESC sX11Drv; } WINECFG_DESC; +extern WINECFG_DESC config; + WINECFG_DESC *allocConfig(void); int freeConfig(WINECFG_DESC *pCfg); int loadConfig(WINECFG_DESC *pCfg); int saveConfig(const WINECFG_DESC *pCfg); +int setConfigValue (HKEY hCurrent, char *subkey, char *valueName, const char *value); +int getConfigValue (HKEY hCurrent, char *subkey, char *valueName, char *retVal, int length, char *defaultResult); + +void initX11DrvDlg (HWND hDlg); +void saveX11DrvDlgSettings (HWND hDlg); +INT_PTR CALLBACK X11DrvDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); + #define WINEHQ_KEY_ROOT "Software\\Wine\\Wine\\Config" #endif --- /dev/null 2003-01-30 10:24:37.000000000 +0000 +++ programs/winecfg/x11drvdlg.c 2003-08-28 11:52:44.000000000 +0100 @@ -0,0 +1,109 @@ +/* + * X11DRV configuration code + * + * Copyright 2003 Mark Westcott + * Copyright 2003 Mike Hearn + * + * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include <winreg.h> +#include <wine/debug.h> +#include <stdlib.h> +#include <stdio.h> + +#include "resource.h" +#include "winecfg.h" + +WINE_DEFAULT_DEBUG_CHANNEL(winecfg); + +/* pokes the win32 api to setup the dialog from the config struct */ +void initX11DrvDlg (HWND hDlg) +{ + char szBuf[20]; + + /* system colors */ + sprintf (szBuf, "%d", config.sX11Drv.nSysColors); + SendDlgItemMessage (hDlg, IDC_SYSCOLORS, WM_SETTEXT, 0, (LPARAM) szBuf); + + /* private color map */ + if (config.sX11Drv.nPrivateMap) + SendDlgItemMessage( hDlg, IDC_PRIVATEMAP, BM_SETCHECK, BST_CHECKED, 0); + + /* perfect graphics */ + if (config.sX11Drv.nPerfect) + SendDlgItemMessage( hDlg, IDC_PERFECTGRAPH, BM_SETCHECK, BST_CHECKED, 0); + + /* desktop size */ + sprintf (szBuf, "%d", config.sX11Drv.nDesktopSizeX); + SendDlgItemMessage (hDlg, IDC_DESKTOP_WIDTH, WM_SETTEXT, 0, (LPARAM) szBuf); + sprintf (szBuf, "%d", config.sX11Drv.nDesktopSizeY); + SendDlgItemMessage (hDlg, IDC_DESKTOP_HEIGHT, WM_SETTEXT, 0, (LPARAM) szBuf); + + if (config.sX11Drv.nDGA) SendDlgItemMessage( hDlg, IDC_XDGA, BM_SETCHECK, BST_CHECKED, 0); + if (config.sX11Drv.nXShm) SendDlgItemMessage( hDlg, IDC_XSHM, BM_SETCHECK, BST_CHECKED, 0); +} + +void +saveX11DrvDlgSettings (HWND hDlg) +{ +} + +INT_PTR CALLBACK +X11DrvDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) +{ + switch (uMsg) { + case WM_INITDIALOG: + break; + + case WM_COMMAND: + switch(HIWORD(wParam)) { + case EN_CHANGE: { + SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); + break; + } + + default: + break; + } + break; + + + case WM_NOTIFY: + switch (((LPNMHDR)lParam)->code) { + case PSN_KILLACTIVE: { + /* validate user info. Lets just assume everything is okay for now */ + SetWindowLong(hDlg, DWL_MSGRESULT, FALSE); + break; + } + case PSN_APPLY: { + /* should probably check everything is really all rosy :) */ + saveX11DrvDlgSettings (hDlg); + SetWindowLong(hDlg, DWL_MSGRESULT, PSNRET_NOERROR); + break; + } + case PSN_SETACTIVE: { + initX11DrvDlg (hDlg); + break; + } + } + break; + + default: + break; + } + return FALSE; +}