Bug 507032 - "Set As Desktop Background..." doesn't work on Windows CE, r=robert.bugzilla

This commit is contained in:
Paul O’Shannessy 2009-08-01 16:21:58 -07:00
Родитель 0baea5a5b1
Коммит 2698f8b357
2 изменённых файлов: 30 добавлений и 4 удалений

Просмотреть файл

@ -77,7 +77,9 @@
<menupopup>
<menuitem label="&center.label;" value="CENTER"/>
<menuitem label="&tile.label;" value="TILE"/>
#ifndef WINCE
<menuitem label="&stretch.label;" value="STRETCH"/>
#endif
</menupopup>
</menulist>
<spacer flex="1"/>

Просмотреть файл

@ -26,6 +26,7 @@
* Robert Strong <robert.bugzilla@gmail.com>
* Asaf Romano <mano@mozilla.com>
* Ryan Jones <sciguyryan@gmail.com>
* Paul O'Shannessy <paul@oshannessy.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
@ -215,9 +216,11 @@ typedef struct {
#define APP_REG_NAME L"Firefox"
#define CLS_HTML "FirefoxHTML"
#define CLS_URL "FirefoxURL"
#define CPL_DESKTOP L"\\Control Panel\\Desktop"
#define VAL_OPEN "\"%APPPATH%\" -requestPending -osint -url \"%1\""
#define VAL_FILE_ICON "%APPPATH%,1"
#else
#define CPL_DESKTOP L"\\ControlPanel\\Desktop"
#define VAL_OPEN "\"%APPPATH%\" -osint -url \"%1\""
#define VAL_FILE_ICON "%APPPATH%,-2"
#endif
@ -656,12 +659,12 @@ nsWindowsShellService::SetDesktopBackground(nsIDOMElement* aElement,
PRBool result = PR_FALSE;
DWORD dwDisp = 0;
HKEY key;
// Try to create/open a subkey under HKLM.
DWORD res = ::RegCreateKeyExW(HKEY_CURRENT_USER,
L"Control Panel\\Desktop",
// Try to create/open a subkey under HKCU.
DWORD res = ::RegCreateKeyExW(HKEY_CURRENT_USER, CPL_DESKTOP,
0, NULL, REG_OPTION_NON_VOLATILE,
KEY_WRITE, NULL, &key, &dwDisp);
if (REG_SUCCEEDED(res)) {
#ifndef WINCE
PRUnichar tile[2], style[2];
switch (aPosition) {
case BACKGROUND_TILE:
@ -688,8 +691,25 @@ nsWindowsShellService::SetDesktopBackground(nsIDOMElement* aElement,
0, REG_SZ, (const BYTE *)style, size);
::SystemParametersInfoW(SPI_SETDESKWALLPAPER, 0, (PVOID)path.get(),
SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
#else
DWORD tile = (aPosition == BACKGROUND_TILE);
::RegSetValueExW(key, L"Tile",
0, REG_DWORD, (const BYTE *)&tile, sizeof(DWORD));
// On WinCE SPI_SETDESKWALLPAPER isn't available, so set the registry
// entry ourselves and then broadcast UI change
PRInt32 size = (path.Length() + 1) * sizeof(PRUnichar);
::RegSetValueExW(key, L"Wallpaper",
0, REG_SZ, (const BYTE *)path.get(), size);
::SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, NULL, 0);
#endif
// Close the key we opened.
::RegCloseKey(key);
#ifdef WINCE
// Ensure that the writes are flushed in case of hard reboot
::RegFlushKey(HKEY_CURRENT_USER);
#endif
}
}
return rv;
@ -815,10 +835,13 @@ nsWindowsShellService::SetDesktopBackgroundColor(PRUint32 aColor)
::SetSysColors(sizeof(aParameters) / sizeof(int), aParameters, colors);
// SetSysColors is persisting across sessions on Windows CE, so no need to
// write to registry
#ifndef WINCE
PRBool result = PR_FALSE;
DWORD dwDisp = 0;
HKEY key;
// Try to create/open a subkey under HKLM.
// Try to create/open a subkey under HKCU.
DWORD rv = ::RegCreateKeyExW(HKEY_CURRENT_USER,
L"Control Panel\\Colors", 0, NULL,
REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL,
@ -836,6 +859,7 @@ nsWindowsShellService::SetDesktopBackgroundColor(PRUint32 aColor)
// Close the key we opened.
::RegCloseKey(key);
#endif
return NS_OK;
}