Commit 12472258 authored by Alexandre Julliard's avatar Alexandre Julliard

user32: Refresh the desktop when the wallpaper is changed.

parent 3a1f31ea
......@@ -148,7 +148,7 @@ extern struct dce *set_class_dce( struct tagCLASS *class, struct dce *dce ) DECL
extern HBRUSH DEFWND_ControlColor( HDC hDC, UINT ctlType ) DECLSPEC_HIDDEN;
/* desktop */
extern BOOL DESKTOP_SetPattern( LPCWSTR pattern ) DECLSPEC_HIDDEN;
extern BOOL update_wallpaper( const WCHAR *wallpaper, const WCHAR *pattern ) DECLSPEC_HIDDEN;
/* icon title */
extern HWND ICONTITLE_Create( HWND hwnd ) DECLSPEC_HIDDEN;
......
......@@ -56,12 +56,10 @@ const struct builtin_class_descr DESKTOP_builtin_class =
/***********************************************************************
* DESKTOP_LoadBitmap
*/
static HBITMAP DESKTOP_LoadBitmap(void)
static HBITMAP DESKTOP_LoadBitmap( const WCHAR *filename )
{
HBITMAP hbitmap;
WCHAR filename[MAX_PATH];
if (!SystemParametersInfoW( SPI_GETDESKWALLPAPER, MAX_PATH, filename, 0 )) return 0;
if (!filename[0]) return 0;
hbitmap = LoadImageW( 0, filename, IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION | LR_LOADFROMFILE );
if (!hbitmap)
......@@ -78,9 +76,9 @@ static HBITMAP DESKTOP_LoadBitmap(void)
/***********************************************************************
* init_wallpaper
*/
static void init_wallpaper(void)
static void init_wallpaper( const WCHAR *wallpaper )
{
HBITMAP hbitmap = DESKTOP_LoadBitmap();
HBITMAP hbitmap = DESKTOP_LoadBitmap( wallpaper );
if (hbitmapWallPaper) DeleteObject( hbitmapWallPaper );
hbitmapWallPaper = hbitmap;
......@@ -172,11 +170,9 @@ BOOL WINAPI SetDeskWallPaper( LPCSTR filename )
/***********************************************************************
* DESKTOP_SetPattern
*
* Set the desktop pattern.
* update_wallpaper
*/
BOOL DESKTOP_SetPattern( LPCWSTR pattern )
BOOL update_wallpaper( const WCHAR *wallpaper, const WCHAR *pattern )
{
int pat[8];
......@@ -201,6 +197,7 @@ BOOL DESKTOP_SetPattern( LPCWSTR pattern )
DeleteObject( hbitmap );
}
}
init_wallpaper();
init_wallpaper( wallpaper );
RedrawWindow( GetDesktopWindow(), 0, 0, RDW_INVALIDATE | RDW_ERASE | RDW_NOCHILDREN );
return TRUE;
}
......@@ -1293,6 +1293,7 @@ static union sysparam_all_entry * const default_entries[] =
(union sysparam_all_entry *)&entry_CAPTIONHEIGHT,
(union sysparam_all_entry *)&entry_CAPTIONWIDTH,
(union sysparam_all_entry *)&entry_CARETWIDTH,
(union sysparam_all_entry *)&entry_DESKWALLPAPER,
(union sysparam_all_entry *)&entry_DOUBLECLICKTIME,
(union sysparam_all_entry *)&entry_DOUBLECLKHEIGHT,
(union sysparam_all_entry *)&entry_DOUBLECLKWIDTH,
......@@ -1374,6 +1375,23 @@ void SYSPARAMS_Init(void)
}
}
static BOOL update_desktop_wallpaper(void)
{
DWORD pid;
if (GetWindowThreadProcessId( GetDesktopWindow(), &pid ) && pid == GetCurrentProcessId())
{
WCHAR wallpaper[MAX_PATH], pattern[256];
entry_DESKWALLPAPER.hdr.loaded = entry_DESKPATTERN.hdr.loaded = FALSE;
if (get_entry( &entry_DESKWALLPAPER, MAX_PATH, wallpaper ) &&
get_entry( &entry_DESKPATTERN, 256, pattern ))
update_wallpaper( wallpaper, pattern );
}
else SendMessageW( GetDesktopWindow(), WM_SETTINGCHANGE, SPI_SETDESKWALLPAPER, 0 );
return TRUE;
}
/***********************************************************************
* SystemParametersInfoW (USER32.@)
*
......@@ -1484,14 +1502,12 @@ BOOL WINAPI SystemParametersInfoW( UINT uiAction, UINT uiParam,
ret = set_entry( &entry_GRIDGRANULARITY, uiParam, pvParam, fWinIni );
break;
case SPI_SETDESKWALLPAPER:
ret = set_entry( &entry_DESKWALLPAPER, uiParam, pvParam, fWinIni );
if (!pvParam || set_entry( &entry_DESKWALLPAPER, uiParam, pvParam, fWinIni ))
ret = update_desktop_wallpaper();
break;
case SPI_SETDESKPATTERN:
if (!pvParam || set_entry( &entry_DESKPATTERN, uiParam, pvParam, fWinIni ))
{
WCHAR buf[256];
ret = get_entry( &entry_DESKPATTERN, 256, buf ) && DESKTOP_SetPattern( buf );
}
ret = update_desktop_wallpaper();
break;
case SPI_GETKEYBOARDDELAY:
ret = get_entry( &entry_KEYBOARDDELAY, uiParam, pvParam );
......
......@@ -85,6 +85,11 @@ static LRESULT WINAPI desktop_wnd_proc( HWND hwnd, UINT message, WPARAM wp, LPAR
if (!using_root) PaintDesktop( (HDC)wp );
return TRUE;
case WM_SETTINGCHANGE:
if (wp == SPI_SETDESKWALLPAPER)
SystemParametersInfoW( SPI_SETDESKWALLPAPER, 0, NULL, FALSE );
return 0;
case WM_PAINT:
{
PAINTSTRUCT ps;
......@@ -311,7 +316,7 @@ void manage_desktop( WCHAR *arg )
SetWindowLongPtrW( hwnd, GWLP_WNDPROC, (LONG_PTR)desktop_wnd_proc );
SendMessageW( hwnd, WM_SETICON, ICON_BIG, (LPARAM)LoadIconW( 0, MAKEINTRESOURCEW(OIC_WINLOGO)));
if (name) set_desktop_window_title( hwnd, name );
SystemParametersInfoA( SPI_SETDESKPATTERN, -1, NULL, FALSE );
SystemParametersInfoW( SPI_SETDESKWALLPAPER, 0, NULL, FALSE );
ClipCursor( NULL );
initialize_display_settings( hwnd );
initialize_appbar();
......
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