Commit cd0b7897 authored by Mike Hearn's avatar Mike Hearn Committed by Alexandre Julliard

- Remove "PerfectGraphics", "Use XSHM extension", and "Use a private

colour map". - Implement a simple transaction system for instant apply. - Complete the desktop size code, this now reads and writes to the registry correctly. - Remove const modifier from version accessor functions. - Change registry root to Wine/WineCfg for testing purposes.
parent 2a3d5fc1
...@@ -62,28 +62,24 @@ IDD_X11DRVCFG DIALOG DISCARDABLE 0, 0, 260, 250 ...@@ -62,28 +62,24 @@ IDD_X11DRVCFG DIALOG DISCARDABLE 0, 0, 260, 250
STYLE WS_CHILD | WS_DISABLED STYLE WS_CHILD | WS_DISABLED
FONT 8, "MS Sans Serif" FONT 8, "MS Sans Serif"
BEGIN BEGIN
EDITTEXT IDC_SYSCOLORS,100,41,40,12,ES_AUTOHSCROLL | ES_NUMBER
CONTROL "Use a private color map",IDC_PRIVATEMAP,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,15,62,91,10
CONTROL "Favor correctness over speed",IDC_PERFECTGRAPH,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,15,76,117,10
CONTROL "Use XFree DGA extension",IDC_XDGA,"Button", CONTROL "Use XFree DGA extension",IDC_XDGA,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,141,62,97,10 BS_AUTOCHECKBOX | WS_TABSTOP,145,44,97,10
CONTROL "Use XFree Shm extension",IDC_XSHM,"Button", CONTROL "Enable Wine desktop",IDC_ENABLE_DESKTOP,"Button",
BS_AUTOCHECKBOX | WS_TABSTOP,141,76,96,10 BS_AUTOCHECKBOX | WS_TABSTOP,17,110,84,10
CONTROL "Enable Wine desktop",IDC_MANAGED,"Button", EDITTEXT IDC_DESKTOP_WIDTH,64,125,40,14,ES_AUTOHSCROLL | ES_NUMBER | WS_DISABLED
BS_AUTOCHECKBOX | WS_TABSTOP,17,143,84,10 EDITTEXT IDC_DESKTOP_HEIGHT,117,125,40,14,ES_AUTOHSCROLL | ES_NUMBER | WS_DISABLED
EDITTEXT IDC_DESKTOP_WIDTH,64,159,40,14,ES_AUTOHSCROLL | ES_NUMBER | WS_DISABLED GROUPBOX "Render Settings",IDC_STATIC,8,4,244,60
EDITTEXT IDC_DESKTOP_HEIGHT,117,159,40,14,ES_AUTOHSCROLL | ES_NUMBER | WS_DISABLED
GROUPBOX "Render Settings",IDC_STATIC,8,4,244,90
LTEXT "The driver color and render settings are used to optimise the way in which colors and applications are displayed.", LTEXT "The driver color and render settings are used to optimise the way in which colors and applications are displayed.",
IDC_STATIC,15,17,228,22 IDC_STATIC,15,17,228,22
LTEXT "Allocated system colors:",IDC_STATIC,15,43,76,8 LTEXT "Allocated system colors:",IDC_STATIC,15,43,76,8
GROUPBOX "Wine Desktop",IDC_STATIC,8,99,244,83 EDITTEXT IDC_SYSCOLORS,90,41,40,14,ES_AUTOHSCROLL | ES_NUMBER
GROUPBOX "Wine Desktop",IDC_STATIC,8,65,244,83
LTEXT "Wine can be setup to emulate a windows desktop, or can be run in ""Managed"" mode (default) where the default X11 windows manager/environment is resposible for placing the windows.", LTEXT "Wine can be setup to emulate a windows desktop, or can be run in ""Managed"" mode (default) where the default X11 windows manager/environment is resposible for placing the windows.",
IDC_STATIC,15,112,228,28 IDC_STATIC,15,77,228,28
LTEXT "Desktop size:",IDC_DESKTOP_SIZE,17,161,44,8,WS_DISABLED LTEXT "Desktop size:",IDC_DESKTOP_SIZE,17,125,44,8,WS_DISABLED
LTEXT "X",IDC_DESKTOP_BY,108,161,8,8,WS_DISABLED LTEXT "X",IDC_DESKTOP_BY,108,125,8,8,WS_DISABLED
END END
IDD_DLLCFG DIALOG DISCARDABLE 0, 0, 260, 250 IDD_DLLCFG DIALOG DISCARDABLE 0, 0, 260, 250
......
...@@ -62,6 +62,9 @@ initGeneralDlg (HWND hDlg) ...@@ -62,6 +62,9 @@ initGeneralDlg (HWND hDlg)
{ {
int i; int i;
const VERSION_DESC *pVer = NULL; const VERSION_DESC *pVer = NULL;
char *curWinVer = getConfigValue("Version", "Windows", "win98");
char *curDOSVer = getConfigValue("Version", "DOS", "6.22");
char *curWineLook = getConfigValue("Tweak.Layout", "WineLook", "win95");
if ((pVer = getWinVersions ())) if ((pVer = getWinVersions ()))
{ {
...@@ -69,7 +72,7 @@ initGeneralDlg (HWND hDlg) ...@@ -69,7 +72,7 @@ initGeneralDlg (HWND hDlg)
{ {
SendDlgItemMessage (hDlg, IDC_WINVER, CB_ADDSTRING, SendDlgItemMessage (hDlg, IDC_WINVER, CB_ADDSTRING,
0, (LPARAM) pVer->szDescription); 0, (LPARAM) pVer->szDescription);
if (!strcmp (pVer->szVersion, config.szWinVer)) if (!strcmp (pVer->szVersion, curWinVer))
SendDlgItemMessage (hDlg, IDC_WINVER, CB_SETCURSEL, SendDlgItemMessage (hDlg, IDC_WINVER, CB_SETCURSEL,
(WPARAM) i, 0); (WPARAM) i, 0);
} }
...@@ -80,7 +83,7 @@ initGeneralDlg (HWND hDlg) ...@@ -80,7 +83,7 @@ initGeneralDlg (HWND hDlg)
{ {
SendDlgItemMessage (hDlg, IDC_DOSVER, CB_ADDSTRING, SendDlgItemMessage (hDlg, IDC_DOSVER, CB_ADDSTRING,
0, (LPARAM) pVer->szDescription); 0, (LPARAM) pVer->szDescription);
if (!strcmp (pVer->szVersion, config.szDOSVer)) if (!strcmp (pVer->szVersion, curDOSVer))
SendDlgItemMessage (hDlg, IDC_DOSVER, CB_SETCURSEL, SendDlgItemMessage (hDlg, IDC_DOSVER, CB_SETCURSEL,
(WPARAM) i, 0); (WPARAM) i, 0);
} }
...@@ -91,11 +94,15 @@ initGeneralDlg (HWND hDlg) ...@@ -91,11 +94,15 @@ initGeneralDlg (HWND hDlg)
{ {
SendDlgItemMessage (hDlg, IDC_WINELOOK, CB_ADDSTRING, SendDlgItemMessage (hDlg, IDC_WINELOOK, CB_ADDSTRING,
0, (LPARAM) pVer->szDescription); 0, (LPARAM) pVer->szDescription);
if (!strcmp (pVer->szVersion, config.szWinLook)) if (!strcmp (pVer->szVersion, curWineLook))
SendDlgItemMessage (hDlg, IDC_WINELOOK, CB_SETCURSEL, SendDlgItemMessage (hDlg, IDC_WINELOOK, CB_SETCURSEL,
(WPARAM) i, 0); (WPARAM) i, 0);
} }
} }
free(curWinVer);
free(curDOSVer);
free(curWineLook);
} }
INT_PTR CALLBACK INT_PTR CALLBACK
...@@ -112,12 +119,12 @@ GeneralDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) ...@@ -112,12 +119,12 @@ GeneralDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
case IDC_WINVER: if (HIWORD(wParam) == CBN_SELCHANGE) { case IDC_WINVER: if (HIWORD(wParam) == CBN_SELCHANGE) {
/* user changed the wine version combobox */ /* user changed the wine version combobox */
int selection = SendDlgItemMessage( hDlg, IDC_WINVER, CB_GETCURSEL, 0, 0); int selection = SendDlgItemMessage( hDlg, IDC_WINVER, CB_GETCURSEL, 0, 0);
const VERSION_DESC *desc = getWinVersions(); VERSION_DESC *desc = getWinVersions();
while (selection > 0) { while (selection > 0) {
desc++; selection--; desc++; selection--;
} }
strcpy(config.szWinVer, desc->szVersion); addTransaction("Version", "Windows", ACTION_SET, desc->szVersion);
} }
break; break;
} }
...@@ -264,12 +271,12 @@ WinMain (HINSTANCE hInstance, HINSTANCE hPrev, LPSTR szCmdLine, int nShow) ...@@ -264,12 +271,12 @@ WinMain (HINSTANCE hInstance, HINSTANCE hPrev, LPSTR szCmdLine, int nShow)
/* Until winecfg is fully functional, warn users that it is incomplete and doesn't do anything */ /* 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("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.\n"); 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 (&config);
if (initialize() != 0) {
WINE_ERR("initialization failed, aborting\n");
ExitProcess(1);
}
/* /*
* The next 3 lines should be all that is needed * The next 3 lines should be all that is needed
* for the Wine Configuration property sheet * for the Wine Configuration property sheet
...@@ -277,7 +284,6 @@ WinMain (HINSTANCE hInstance, HINSTANCE hPrev, LPSTR szCmdLine, int nShow) ...@@ -277,7 +284,6 @@ WinMain (HINSTANCE hInstance, HINSTANCE hPrev, LPSTR szCmdLine, int nShow)
InitCommonControls (); InitCommonControls ();
if (doPropertySheet (hInstance, NULL) > 0) { if (doPropertySheet (hInstance, NULL) > 0) {
WINE_TRACE("OK\n"); WINE_TRACE("OK\n");
saveConfig(&config);
} else } else
WINE_TRACE("Cancel\n"); WINE_TRACE("Cancel\n");
......
...@@ -80,7 +80,7 @@ static DLL_DESC sDLLType[] = { ...@@ -80,7 +80,7 @@ static DLL_DESC sDLLType[] = {
/***************************************************************************** /*****************************************************************************
*/ */
const VERSION_DESC* getWinVersions(void) VERSION_DESC* getWinVersions(void)
{ {
return sWinVersions; return sWinVersions;
} }
...@@ -88,7 +88,7 @@ const VERSION_DESC* getWinVersions(void) ...@@ -88,7 +88,7 @@ const VERSION_DESC* getWinVersions(void)
/***************************************************************************** /*****************************************************************************
*/ */
const VERSION_DESC* getDOSVersions(void) VERSION_DESC* getDOSVersions(void)
{ {
return sDOSVersions; return sDOSVersions;
} }
...@@ -96,7 +96,7 @@ const VERSION_DESC* getDOSVersions(void) ...@@ -96,7 +96,7 @@ const VERSION_DESC* getDOSVersions(void)
/***************************************************************************** /*****************************************************************************
*/ */
const VERSION_DESC* getWinelook(void) VERSION_DESC* getWinelook(void)
{ {
return sWineLook; return sWineLook;
} }
...@@ -104,7 +104,7 @@ const VERSION_DESC* getWinelook(void) ...@@ -104,7 +104,7 @@ const VERSION_DESC* getWinelook(void)
/***************************************************************************** /*****************************************************************************
*/ */
const DLL_DESC* getDLLDefaults(void) DLL_DESC* getDLLDefaults(void)
{ {
return sDLLType; return sDLLType;
} }
...@@ -93,9 +93,9 @@ typedef struct ...@@ -93,9 +93,9 @@ typedef struct
int nSynchronous; int nSynchronous;
} X11DRV_DESC; } X11DRV_DESC;
const VERSION_DESC *getWinVersions(void); VERSION_DESC *getWinVersions(void);
const VERSION_DESC *getDOSVersions(void); VERSION_DESC *getDOSVersions(void);
const VERSION_DESC *getWinelook(void); VERSION_DESC *getWinelook(void);
const DLL_DESC *getDLLDefaults(void); DLL_DESC *getDLLDefaults(void);
#endif #endif
...@@ -101,3 +101,4 @@ ...@@ -101,3 +101,4 @@
#define IDC_BOX_LABELSERIAL 1071 #define IDC_BOX_LABELSERIAL 1071
#define IDC_STATIC_SERIAL 1072 #define IDC_STATIC_SERIAL 1072
#define IDC_STATIC_LABEL 1073 #define IDC_STATIC_LABEL 1073
#define IDC_ENABLE_DESKTOP 1074
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
* *
*/ */
#include <assert.h>
#include <stdio.h> #include <stdio.h>
#include <limits.h> #include <limits.h>
#include <windows.h> #include <windows.h>
...@@ -33,77 +34,42 @@ WINE_DEFAULT_DEBUG_CHANNEL(winecfg); ...@@ -33,77 +34,42 @@ WINE_DEFAULT_DEBUG_CHANNEL(winecfg);
HKEY configKey = NULL; HKEY configKey = NULL;
/*****************************************************************************
*/
WINECFG_DESC* allocConfig(void)
{
WINECFG_DESC* pWineCfg = malloc (sizeof (WINECFG_DESC));
if (!pWineCfg) goto fail;
ZeroMemory(pWineCfg, sizeof(*pWineCfg));
pWineCfg->pDlls = DPA_Create(100);
if (!pWineCfg->pDlls) goto fail;
pWineCfg->pApps = DPA_Create(100);
if (!pWineCfg->pApps) goto fail;
return pWineCfg;
fail:
/* FIXME: do something nice */
printf("Out of memory");
exit(1);
}
/*****************************************************************************
*/
int freeConfig (WINECFG_DESC* pCfg)
{
int i;
for (i = 0; i < pCfg->pDlls->nItemCount; i++)
free (DPA_GetPtr(pCfg->pDlls, i));
DPA_Destroy(pCfg->pDlls);
for (i = 0; i < pCfg->pApps->nItemCount; i++)
free (DPA_GetPtr(pCfg->pApps, i));
DPA_Destroy(pCfg->pApps);
free (pCfg);
int initialize(void) {
DWORD res = RegCreateKey(HKEY_LOCAL_MACHINE, WINE_KEY_ROOT, &configKey);
if (res != ERROR_SUCCESS) {
WINE_ERR("RegOpenKey failed on wine config key (%ld)\n", res);
return 1;
}
return 0; return 0;
} }
/***************************************************************************** /*****************************************************************************
* getConfigValue: Retrieves a configuration value from the registry * getConfigValue: Retrieves a configuration value from the registry
* *
* HKEY hCurrent : the registry key that the configuration is rooted at
* char *subKey : the name of the config section * char *subKey : the name of the config section
* char *valueName : the name of the config value * char *valueName : the name of the config value
* char *retVal : pointer to the start of a buffer that has room for >= length chars
* int length : length of the buffer pointed to by retVal
* char *defaultResult : if the key isn't found, return this value instead * char *defaultResult : if the key isn't found, return this value instead
* *
* Returns 0 upon success, non-zero otherwise * Returns a buffer holding the value if successful, NULL if not. Caller is responsible for freeing the result.
* *
*/ */
int getConfigValue (HKEY hCurrent, char *subkey, char *valueName, char *retVal, int length, char *defaultResult) char *getConfigValue (char *subkey, char *valueName, char *defaultResult)
{ {
CHAR *buffer; char *buffer = NULL;
DWORD dataLength; DWORD dataLength;
HKEY hSubKey = NULL; HKEY hSubKey = NULL;
DWORD res = 1; /* assume failure */ DWORD res;
WINE_TRACE("subkey=%s, valueName=%s, defaultResult=%s\n", subkey, valueName, defaultResult); WINE_TRACE("subkey=%s, valueName=%s, defaultResult=%s\n", subkey, valueName, defaultResult);
if( (res=RegOpenKeyEx( hCurrent, subkey, 0, KEY_ALL_ACCESS, &hSubKey )) res = RegOpenKeyEx( configKey, subkey, 0, KEY_ALL_ACCESS, &hSubKey );
!=ERROR_SUCCESS ) if(res != ERROR_SUCCESS) {
{
if( res==ERROR_FILE_NOT_FOUND ) if( res==ERROR_FILE_NOT_FOUND )
{ {
WINE_TRACE("Section key not present - using default\n"); WINE_TRACE("Section key not present - using default\n");
strncpy(retVal, defaultResult, length); return strdup(defaultResult);
} }
else else
{ {
...@@ -113,20 +79,16 @@ int getConfigValue (HKEY hCurrent, char *subkey, char *valueName, char *retVal, ...@@ -113,20 +79,16 @@ int getConfigValue (HKEY hCurrent, char *subkey, char *valueName, char *retVal,
} }
res = RegQueryValueExA( hSubKey, valueName, NULL, NULL, NULL, &dataLength); res = RegQueryValueExA( hSubKey, valueName, NULL, NULL, NULL, &dataLength);
if( res == ERROR_FILE_NOT_FOUND ) if( res == ERROR_FILE_NOT_FOUND ) {
{
WINE_TRACE("Value not present - using default\n"); WINE_TRACE("Value not present - using default\n");
strncpy(retVal, defaultResult, length); buffer = strdup(defaultResult);
goto end; goto end;
} } else if( res!=ERROR_SUCCESS ) {
if( res!=ERROR_SUCCESS )
{
WINE_ERR("Couldn't query value's length (res=%ld)\n", res ); WINE_ERR("Couldn't query value's length (res=%ld)\n", res );
goto end; goto end;
} }
buffer=malloc( dataLength ); buffer = malloc(dataLength);
if( buffer==NULL ) if( buffer==NULL )
{ {
WINE_ERR("Couldn't allocate %lu bytes for the value\n", dataLength ); WINE_ERR("Couldn't allocate %lu bytes for the value\n", dataLength );
...@@ -134,15 +96,12 @@ int getConfigValue (HKEY hCurrent, char *subkey, char *valueName, char *retVal, ...@@ -134,15 +96,12 @@ int getConfigValue (HKEY hCurrent, char *subkey, char *valueName, char *retVal,
} }
RegQueryValueEx(hSubKey, valueName, NULL, NULL, (LPBYTE)buffer, &dataLength); RegQueryValueEx(hSubKey, valueName, NULL, NULL, (LPBYTE)buffer, &dataLength);
strncpy(retVal, buffer, length);
free(buffer);
res = 0;
end: end:
if( hSubKey!=NULL ) if( hSubKey!=NULL )
RegCloseKey( hSubKey ); RegCloseKey( hSubKey );
return res; return buffer;
} }
...@@ -157,13 +116,17 @@ end: ...@@ -157,13 +116,17 @@ end:
* Returns 0 on success, non-zero otherwise * Returns 0 on success, non-zero otherwise
* *
*/ */
int setConfigValue (HKEY hCurrent, char *subkey, char *valueName, const char *value) { int setConfigValue (char *subkey, char *valueName, const char *value) {
DWORD res = 1; DWORD res = 1;
HKEY key = NULL; HKEY key = NULL;
WINE_TRACE("subkey=%s, valueName=%s, value=%s\n", subkey, valueName, value); WINE_TRACE("subkey=%s, valueName=%s, value=%s\n", subkey, valueName, value);
assert( subkey != NULL );
assert( valueName != NULL );
assert( value != NULL );
res = RegCreateKey(hCurrent, subkey, &key); res = RegCreateKey(configKey, subkey, &key);
if (res != ERROR_SUCCESS) goto end; if (res != ERROR_SUCCESS) goto end;
res = RegSetValueEx(key, valueName, 0, REG_SZ, value, strlen(value) + 1); res = RegSetValueEx(key, valueName, 0, REG_SZ, value, strlen(value) + 1);
...@@ -176,6 +139,45 @@ end: ...@@ -176,6 +139,45 @@ end:
return res; return res;
} }
/* returns 0 on success, an HRESULT from the registry funtions otherwise */
HRESULT doesConfigValueExist(char *subkey, char *valueName) {
HRESULT hr;
HKEY key;
WINE_TRACE("subkey=%s, valueName=%s - ", subkey, valueName);
hr = RegOpenKeyEx(configKey, subkey, 0, KEY_READ, &key);
if (hr != S_OK) {
WINE_TRACE("no: subkey does not exist\n");
return hr;
}
hr = RegQueryValueEx(key, valueName, NULL, NULL, NULL, NULL);
if (hr != S_OK) {
WINE_TRACE("no: key does not exist\n");
return hr;
}
RegCloseKey(key);
WINE_TRACE("yes\n");
return S_OK;
}
/* removes the requested value from the registry, however, does not remove the section if empty. Returns S_OK (0) on success. */
HRESULT removeConfigValue(char *subkey, char *valueName) {
HRESULT hr;
HKEY key;
WINE_TRACE("subkey=%s, valueName=%s\n", subkey, valueName);
hr = RegOpenKeyEx(configKey, subkey, 0, KEY_READ, &key);
if (hr != S_OK) return hr;
hr = RegDeleteValue(key, valueName);
if (hr != ERROR_SUCCESS) return hr;
return S_OK;
}
/***************************************************************************** /*****************************************************************************
* Name : loadConfig * Name : loadConfig
...@@ -183,9 +185,6 @@ end: ...@@ -183,9 +185,6 @@ end:
* Parameters : pCfg * Parameters : pCfg
* Returns : 0 on success, -1 otherwise * Returns : 0 on success, -1 otherwise
* *
* FIXME: We are supposed to load these values from the registry.
* This is not active yet, so just setup some (hopefully)
* sane defaults
*/ */
int loadConfig (WINECFG_DESC* pCfg) int loadConfig (WINECFG_DESC* pCfg)
{ {
...@@ -196,63 +195,29 @@ int loadConfig (WINECFG_DESC* pCfg) ...@@ -196,63 +195,29 @@ int loadConfig (WINECFG_DESC* pCfg)
WINE_TRACE("\n"); WINE_TRACE("\n");
res = RegCreateKey(HKEY_LOCAL_MACHINE, WINE_KEY_ROOT, &configKey); return_if_fail( initialize() == 0 , 1 );
if (res != ERROR_SUCCESS)
{
WINE_ERR("RegOpenKey failed on wine config key (%ld)\n", res);
return -1;
}
/* Windows and DOS versions */
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 */ /* System Paths */
getConfigValue(configKey, "Wine", "Windows", pCfg->szWinDir, MAX_PATH, "c:\\Windows"); /* getConfigValue(configKey, "Wine", "Windows", pCfg->szWinDir, MAX_PATH, "c:\\Windows");
getConfigValue(configKey, "Wine", "System", pCfg->szWinSysDir, MAX_PATH, "c:\\Windows\\System"); 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", "Temp", pCfg->szWinTmpDir, MAX_PATH, "c:\\Windows\\Temp");
getConfigValue(configKey, "Wine", "Profile", pCfg->szWinProfDir, MAX_PATH, "c:\\Windows\\Profiles\\Administrator"); 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"); getConfigValue(configKey, "Wine", "Path", pCfg->szWinPath, MAX_PATH, "c:\\Windows;c:\\Windows\\System");
*/
/* Graphics driver */ /* Graphics driver */
getConfigValue(configKey, "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 * DLL defaults for all applications is built using
* the default DLL structure * the default DLL structure
*/ */
for (pDllDefaults = getDLLDefaults (); *pDllDefaults->szName; pDllDefaults++) /* for (pDllDefaults = getDLLDefaults (); *pDllDefaults->szName; pDllDefaults++)
{ {
DLL_DESC *pDll = malloc(sizeof(DLL_DESC)); DLL_DESC *pDll = malloc(sizeof(DLL_DESC));
memcpy (pDll, pDllDefaults, sizeof(DLL_DESC)); memcpy (pDll, pDllDefaults, sizeof(DLL_DESC));
DPA_InsertPtr(pCfg->pDlls, INT_MAX, pDll); DPA_InsertPtr(pCfg->pDlls, INT_MAX, pDll);
} }
*/
/*
* Application defaults on a per application
* level (if not set, this defaults to what
* is already there)
*/
/* FIXME: Finish these off. Do we actually need GUI for all of them? */
/*
* X11Drv defaults
*/
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.nTextCP = 0;
pCfg->sX11Drv.nXVideoPort = 43; pCfg->sX11Drv.nXVideoPort = 43;
...@@ -271,7 +236,7 @@ int loadConfig (WINECFG_DESC* pCfg) ...@@ -271,7 +236,7 @@ int loadConfig (WINECFG_DESC* pCfg)
/* /*
* Drive mappings * Drive mappings
*/ */
pCfg->pDrives = DPA_Create(26); /* pCfg->pDrives = DPA_Create(26);
for (i = 0; for (i = 0;
RegEnumKeyExA(configKey, i, subKeyName, &sizeOfSubKeyName, NULL, NULL, NULL, NULL ) != ERROR_NO_MORE_ITEMS; RegEnumKeyExA(configKey, i, subKeyName, &sizeOfSubKeyName, NULL, NULL, NULL, NULL ) != ERROR_NO_MORE_ITEMS;
++i, sizeOfSubKeyName=50) { ++i, sizeOfSubKeyName=50) {
...@@ -359,35 +324,77 @@ int loadConfig (WINECFG_DESC* pCfg) ...@@ -359,35 +324,77 @@ int loadConfig (WINECFG_DESC* pCfg)
} }
} }
WINE_TRACE("loaded %d drives\n", pCfg->driveCount); WINE_TRACE("loaded %d drives\n", pCfg->driveCount);
*/
RegCloseKey( configKey );
return 0; return 0;
} }
/*****************************************************************************
* saveConfig : Stores the configuration structure
*
* Returns : 0 on success, -1 otherwise
*
* FIXME: This is where we are to write the changes to the registry.
* This is not setup yet, so do nothing and say ok.
*/
int saveConfig (const WINECFG_DESC* pCfg)
{
HKEY key;
DWORD res;
WINE_TRACE("\n");
/* ========================================================================= */
/* Transaction management code */
struct transaction *tqhead, *tqtail;
int instantApply = 1;
void destroyTransaction(struct transaction *trans) {
assert( trans != NULL );
res = RegOpenKeyEx(HKEY_LOCAL_MACHINE, WINE_KEY_ROOT, 0, KEY_ALL_ACCESS, &key); WINE_TRACE("destroying %p\n", trans);
if (res != ERROR_SUCCESS) {
WINE_ERR("Failed to open Wine config registry branch, res=%ld\n", res); free(trans->section);
return -1; free(trans->key);
} if (trans->newValue) free(trans->newValue);
if (trans->next) trans->next->prev = trans->prev;
if (trans->prev) trans->prev->next = trans->next;
if (trans == tqhead) tqhead = NULL;
if (trans == tqtail) tqtail = NULL;
free(trans);
}
/* Windows and DOS versions */ void addTransaction(char *section, char *key, enum transaction_action action, char *newValue) {
setConfigValue(key, "Version", "Windows", pCfg->szWinVer); struct transaction *trans = malloc(sizeof(struct transaction));
WINE_FIXME("We don't write out the entire configuration yet\n"); assert( section != NULL );
return 0; assert( key != NULL );
if (action == ACTION_SET) assert( newValue != NULL );
trans->section = section;
trans->key = key;
trans->newValue = newValue;
trans->action = action;
trans->next = NULL;
trans->prev = NULL;
if (tqtail == NULL) {
tqtail = trans;
tqhead = tqtail;
} else {
tqhead->next = trans;
trans->prev = tqhead;
tqhead = trans;
}
if (instantApply) processTransaction(trans);
}
void processTransaction(struct transaction *trans) {
if (trans->action == ACTION_SET) {
WINE_TRACE("Setting %s\\%s to '%s'\n", trans->section, trans->key, trans->newValue);
setConfigValue(trans->section, trans->key, trans->newValue);
} else if (trans->action == ACTION_REMOVE) {
WINE_TRACE("Removing %s\\%s", trans->section, trans->key);
removeConfigValue(trans->section, trans->key);
}
/* TODO: implement notifications here */
}
void processTransQueue() {
WINE_TRACE("\n");
while (tqhead != NULL) {
processTransaction(tqhead);
tqhead = tqhead->next;
destroyTransaction(tqhead->prev);
}
} }
...@@ -37,6 +37,60 @@ ...@@ -37,6 +37,60 @@
#define IS_OPTION_FALSE(ch) \ #define IS_OPTION_FALSE(ch) \
((ch) == 'n' || (ch) == 'N' || (ch) == 'f' || (ch) == 'F' || (ch) == '0') ((ch) == 'n' || (ch) == 'N' || (ch) == 'f' || (ch) == 'F' || (ch) == '0')
#define return_if_fail(try, ret) \
if (!(try)) { \
WINE_ERR("assertion (##try) failed, returning\n"); \
return ret; \
}
/* Transaction management */
enum transaction_action {
ACTION_SET,
ACTION_REMOVE
};
struct transaction {
char *section;
char *key;
char *newValue;
enum transaction_action action;
struct transaction *next, *prev;
};
extern struct transaction *tqhead, *tqtail;
extern int instantApply; /* non-zero means apply all changes instantly */
/* Commits a transaction to the registry */
void processTransaction(struct transaction *trans);
/* Processes every pending transaction in the queue, removing them as it works from head to tail */
void processTransQueue();
/* Adds a transaction to the head of the queue. If we're using instant apply, this calls processTransaction
* action can be either:
* ACTION_SET -> this transaction will change a registry key, newValue is the replacement value
* ACTION_REMOVE -> this transaction will remove a registry key. In this case, newValue is ignored.
*/
void addTransaction(char *section, char *key, enum transaction_action action, char *newValue);
/* frees the transaction structure, all fields, and removes it from the queue if in it */
void destroyTransaction(struct transaction *trans);
/* Initializes the transaction system */
int initialize(void);
typedef struct structWineCfg typedef struct structWineCfg
{ {
char szWinVer[MAX_VERSION_LENGTH]; char szWinVer[MAX_VERSION_LENGTH];
...@@ -68,11 +122,13 @@ int freeConfig(WINECFG_DESC *pCfg); ...@@ -68,11 +122,13 @@ int freeConfig(WINECFG_DESC *pCfg);
int loadConfig(WINECFG_DESC *pCfg); int loadConfig(WINECFG_DESC *pCfg);
int saveConfig(const WINECFG_DESC *pCfg); int saveConfig(const WINECFG_DESC *pCfg);
int setConfigValue (HKEY hCurrent, char *subkey, char *valueName, const char *value); int setConfigValue (char *subkey, char *valueName, const char *value);
int getConfigValue (HKEY hCurrent, char *subkey, char *valueName, char *retVal, int length, char *defaultResult); char *getConfigValue (char *subkey, char *valueName, char *defaultResult);
HRESULT doesConfigValueExist (char *subkey, char *valueName);
HRESULT removeConfigValue (char *subkey, char *valueName);
/* X11DRV */ /* X11DRV */
void initX11DrvDlg (HWND hDlg); void initX11DrvDlg (HWND hDlg);
void saveX11DrvDlgSettings (HWND hDlg); void saveX11DrvDlgSettings (HWND hDlg);
INT_PTR CALLBACK X11DrvDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); INT_PTR CALLBACK X11DrvDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
...@@ -84,6 +140,6 @@ void saveDriveSettings (HWND hDlg); ...@@ -84,6 +140,6 @@ void saveDriveSettings (HWND hDlg);
INT_PTR CALLBACK DriveDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); INT_PTR CALLBACK DriveDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
INT_PTR CALLBACK DriveEditDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); INT_PTR CALLBACK DriveEditDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
#define WINE_KEY_ROOT "Software\\Wine\\Wine\\Config" #define WINE_KEY_ROOT "Software\\Wine\\WineCfg\\Config"
#endif #endif
...@@ -34,67 +34,139 @@ ...@@ -34,67 +34,139 @@
WINE_DEFAULT_DEBUG_CHANNEL(winecfg); 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? */
int updatingUI;
void updateGUIForDesktopMode(HWND hDlg) {
WINE_TRACE("\n");
updatingUI = TRUE;
/* do we have desktop mode enabled? */
if (doesConfigValueExist("x11drv", "Desktop") == S_OK) {
CheckDlgButton(hDlg, IDC_ENABLE_DESKTOP, BST_CHECKED);
/* enable the controls */
EnableWindow(GetDlgItem(hDlg, IDC_DESKTOP_WIDTH), 1);
EnableWindow(GetDlgItem(hDlg, IDC_DESKTOP_HEIGHT), 1);
EnableWindow(GetDlgItem(hDlg, IDC_DESKTOP_SIZE), 1);
EnableWindow(GetDlgItem(hDlg, IDC_DESKTOP_BY), 1);
SetWindowText(GetDlgItem(hDlg, IDC_DESKTOP_WIDTH), "640");
SetWindowText(GetDlgItem(hDlg, IDC_DESKTOP_HEIGHT), "480");
}
else {
CheckDlgButton(hDlg, IDC_ENABLE_DESKTOP, BST_UNCHECKED);
/* disable the controls */
EnableWindow(GetDlgItem(hDlg, IDC_DESKTOP_WIDTH), 0);
EnableWindow(GetDlgItem(hDlg, IDC_DESKTOP_HEIGHT), 0);
EnableWindow(GetDlgItem(hDlg, IDC_DESKTOP_SIZE), 0);
EnableWindow(GetDlgItem(hDlg, IDC_DESKTOP_BY), 0);
SetWindowText(GetDlgItem(hDlg, IDC_DESKTOP_WIDTH), "");
SetWindowText(GetDlgItem(hDlg, IDC_DESKTOP_HEIGHT), "");
}
updatingUI = FALSE;
}
/* pokes the win32 api to setup the dialog from the config struct */ /* pokes the win32 api to setup the dialog from the config struct */
void initX11DrvDlg (HWND hDlg) void initX11DrvDlg (HWND hDlg)
{ {
char szBuf[20]; char *buf;
int x, y;
char *i;
updatingUI = TRUE;
updateGUIForDesktopMode(hDlg);
/* desktop size */
buf = getConfigValue("x11drv", "Desktop", "640x480");
i = strchr(buf, 'x');
*i = '\0';
i++;
SetWindowText(GetDlgItem(hDlg, IDC_DESKTOP_WIDTH), buf);
SetWindowText(GetDlgItem(hDlg, IDC_DESKTOP_HEIGHT), i);
free(buf);
SendDlgItemMessage(hDlg, IDC_DESKTOP_WIDTH, EM_LIMITTEXT, RES_MAXLEN, 0);
SendDlgItemMessage(hDlg, IDC_DESKTOP_HEIGHT, EM_LIMITTEXT, RES_MAXLEN, 0);
updatingUI = FALSE;
}
/* 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 */ void setFromDesktopSizeEdits(HWND hDlg) {
if (config.sX11Drv.nPerfect) char *width = malloc(RES_MAXLEN+1);
SendDlgItemMessage( hDlg, IDC_PERFECTGRAPH, BM_SETCHECK, BST_CHECKED, 0); char *height = malloc(RES_MAXLEN+1);
char *newStr = malloc((RES_MAXLEN*2) + 2);
/* desktop size */ if (updatingUI) return;
sprintf (szBuf, "%d", config.sX11Drv.nDesktopSizeX);
SendDlgItemMessage (hDlg, IDC_DESKTOP_WIDTH, WM_SETTEXT, 0, (LPARAM) szBuf); WINE_TRACE("\n");
sprintf (szBuf, "%d", config.sX11Drv.nDesktopSizeY);
SendDlgItemMessage (hDlg, IDC_DESKTOP_HEIGHT, WM_SETTEXT, 0, (LPARAM) szBuf); GetWindowText(GetDlgItem(hDlg, IDC_DESKTOP_WIDTH), width, RES_MAXLEN+1);
GetWindowText(GetDlgItem(hDlg, IDC_DESKTOP_HEIGHT), height, RES_MAXLEN+1);
if (config.sX11Drv.nDGA) SendDlgItemMessage( hDlg, IDC_XDGA, BM_SETCHECK, BST_CHECKED, 0); if (strcmp(width, "") == 0) strcpy(width, "640");
if (config.sX11Drv.nXShm) SendDlgItemMessage( hDlg, IDC_XSHM, BM_SETCHECK, BST_CHECKED, 0); if (strcmp(height, "") == 0) strcpy(height, "480");
}
sprintf(newStr, "%sx%s", width, height);
addTransaction("x11drv", "Desktop", ACTION_SET, newStr);
void free(width);
saveX11DrvDlgSettings (HWND hDlg) free(height);
{ free(newStr);
} }
void onEnableDesktopClicked(HWND hDlg) {
WINE_TRACE("\n");
if (IsDlgButtonChecked(hDlg, IDC_ENABLE_DESKTOP) == BST_CHECKED) {
/* it was just unchecked, so read the values of the edit boxes, set the config value */
setFromDesktopSizeEdits(hDlg);
} else {
/* it was just checked, so remove the config values */
addTransaction("x11drv", "Desktop", ACTION_REMOVE, NULL);
}
updateGUIForDesktopMode(hDlg);
}
INT_PTR CALLBACK INT_PTR CALLBACK
X11DrvDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) X11DrvDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
switch (uMsg) { switch (uMsg) {
case WM_INITDIALOG: case WM_INITDIALOG:
break; break;
case WM_COMMAND: case WM_COMMAND:
switch(HIWORD(wParam)) { switch(HIWORD(wParam)) {
case EN_CHANGE: { case EN_CHANGE: {
SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0); SendMessage(GetParent(hDlg), PSM_CHANGED, 0, 0);
if ( (LOWORD(wParam) == IDC_DESKTOP_WIDTH) || (LOWORD(wParam) == IDC_DESKTOP_HEIGHT) ) setFromDesktopSizeEdits(hDlg);
break; break;
} }
case BN_CLICKED: {
WINE_TRACE("%ld\n", LOWORD(wParam));
switch(LOWORD(wParam)) {
case IDC_ENABLE_DESKTOP: onEnableDesktopClicked(hDlg); break;
};
break;
}
default: default:
break; break;
} }
break; break;
case WM_NOTIFY: case WM_NOTIFY:
switch (((LPNMHDR)lParam)->code) { switch (((LPNMHDR)lParam)->code) {
case PSN_KILLACTIVE: { case PSN_KILLACTIVE: {
/* validate user info. Lets just assume everything is okay for now */
SetWindowLong(hDlg, DWL_MSGRESULT, FALSE); SetWindowLong(hDlg, DWL_MSGRESULT, FALSE);
break; break;
} }
case PSN_APPLY: { case PSN_APPLY: {
/* should probably check everything is really all rosy :) */
saveX11DrvDlgSettings (hDlg);
SetWindowLong(hDlg, DWL_MSGRESULT, PSNRET_NOERROR); SetWindowLong(hDlg, DWL_MSGRESULT, PSNRET_NOERROR);
break; break;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment