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 - Move X11DRV dialog init code to a separate file - Link with Xlib to get XParseGeometry - Add newline to the initial FIXME thanks -mike
diff -urb --exclude-from=diff-exclusions ../head/programs/winecfg/main.c programs/winecfg/main.c --- ../head/programs/winecfg/main.c 2003-08-27 12:18:43.000000000 +0100 +++ programs/winecfg/main.c 2003-08-27 12:16:21.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 @@ -32,10 +33,11 @@ #include "properties.h" #include "resource.h" #include "winecfg.h" +#include "x11drvdlg.h" WINE_DEFAULT_DEBUG_CHANNEL(winecfg); -WINECFG_DESC sCfg; +WINECFG_DESC config; void CALLBACK PropSheetCallback (HWND hWnd, UINT uMsg, LPARAM lParam) @@ -68,7 +70,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 +81,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 +92,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 +118,7 @@ while (selection > 0) { desc++; selection--; } - strcpy(sCfg.szWinVer, desc->szVersion); + strcpy(config.szWinVer, desc->szVersion); } break; } @@ -159,39 +161,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 +255,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 -urb --exclude-from=diff-exclusions ../head/programs/winecfg/Makefile.in programs/winecfg/Makefile.in --- ../head/programs/winecfg/Makefile.in 2003-04-27 01:33:07.000000000 +0100 +++ programs/winecfg/Makefile.in 2003-08-27 12:13:21.000000000 +0100 @@ -5,11 +5,13 @@ MODULE = winecfg.exe APPMODE = gui IMPORTS = comctl32 user32 advapi32 +EXTRALIBS = @X_LIBS@ @X_PRE_LIBS@ @XLIB@ @X_EXTRA_LIBS@ C_SRCS = \ main.c \ properties.c \ - winecfg.c + winecfg.c \ + x11drvdlg.c RC_SRCS = winecfg.rc diff -urb --exclude-from=diff-exclusions ../head/programs/winecfg/properties.h programs/winecfg/properties.h --- ../head/programs/winecfg/properties.h 2003-08-20 15:26:18.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 -urb --exclude-from=diff-exclusions ../head/programs/winecfg/winecfg.c programs/winecfg/winecfg.c --- ../head/programs/winecfg/winecfg.c 2003-08-27 12:18:43.000000000 +0100 +++ programs/winecfg/winecfg.c 2003-08-27 12:00: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 @@ -25,11 +26,13 @@ #include <windows.h> #include <winreg.h> #include <wine/debug.h> +#include <X11/Xlib.h> WINE_DEFAULT_DEBUG_CHANNEL(winecfg); #include "winecfg.h" +HKEY configKey = NULL; /***************************************************************************** */ @@ -188,13 +191,13 @@ int loadConfig (WINECFG_DESC* pCfg) { const DLL_DESC *pDllDefaults; - - HKEY hSession=NULL; + char buffer[MAX_PATH]; DWORD res; + int x, y; 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 +205,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 +235,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"); + XParseGeometry(buffer, &x, &y, &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 +268,7 @@ pCfg->sX11Drv.nDoubleBuffered = 0; pCfg->sX11Drv.nSynchronous = 1; - RegCloseKey( hSession ); - + RegCloseKey( configKey ); return 0; } diff -urb --exclude-from=diff-exclusions ../head/programs/winecfg/winecfg.h programs/winecfg/winecfg.h --- ../head/programs/winecfg/winecfg.h 2003-08-27 12:18:43.000000000 +0100 +++ programs/winecfg/winecfg.h 2003-08-27 12:10:49.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,12 +50,17 @@ 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); + #define WINEHQ_KEY_ROOT "Software\\WineHQ\\Wine\\Config" #endif --- /dev/null 2003-01-30 10:24:37.000000000 +0000 +++ programs/winecfg/x11drvdlg.c 2003-08-27 12:30:42.000000000 +0100 @@ -0,0 +1,110 @@ +/* + * 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 "x11drvdlg.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; +} --- /dev/null 2003-01-30 10:24:37.000000000 +0000 +++ programs/winecfg/x11drvdlg.h 2003-08-26 23:16:32.000000000 +0100 @@ -0,0 +1,10 @@ +#ifndef X11DRVDLG_H +#define X11DRVDLG_H + +#include "winecfg.h" + +void initX11DrvDlg (HWND hDlg); +void saveX11DrvDlgSettings (HWND hDlg); +INT_PTR CALLBACK X11DrvDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); + +#endif