From: Gabriel Ivăncescu gabrielopcode@gmail.com
Fixes a regression introduced by 62c6646d8f44cee55ffdef6d2bede19f681dc9b8, because SetParent will unconditionally activate the window, causing newly added icons to deactivate the foreground window.
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- programs/explorer/systray.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/programs/explorer/systray.c b/programs/explorer/systray.c index 3b4e5bdc8ac..7d2d3795575 100644 --- a/programs/explorer/systray.c +++ b/programs/explorer/systray.c @@ -540,6 +540,15 @@ static LRESULT WINAPI tray_icon_wndproc( HWND hwnd, UINT msg, WPARAM wparam, LPA break; }
+ case WM_WINDOWPOSCHANGING: + if (icon->display == ICON_DISPLAY_HIDDEN) + { + /* Changing the icon's parent via SetParent would activate it, stealing the focus. */ + WINDOWPOS *wp = (WINDOWPOS*)lparam; + wp->flags |= SWP_NOACTIVATE; + } + break; + case WM_WINDOWPOSCHANGED: update_systray_balloon_position(); break; @@ -563,9 +572,9 @@ static void systray_add_icon( struct icon *icon )
if (icon->display != ICON_DISPLAY_HIDDEN) return; /* already added */
- icon->display = nb_displayed++; SetWindowLongW( icon->window, GWL_STYLE, GetWindowLongW( icon->window, GWL_STYLE ) | WS_CHILD ); SetParent( icon->window, tray_window ); + icon->display = nb_displayed++; pos = get_icon_pos( icon ); SetWindowPos( icon->window, 0, pos.x, pos.y, 0, 0, SWP_NOSIZE | SWP_NOACTIVATE | SWP_NOZORDER | SWP_SHOWWINDOW );
From: Gabriel Ivăncescu gabrielopcode@gmail.com
Fixes a regression introduced by 229b4561d9a8f10cbb49342dff0b6a3472d81c68, which caused the icons to not be visible initially in the virtual desktop systray.
Signed-off-by: Gabriel Ivăncescu gabrielopcode@gmail.com --- programs/explorer/systray.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/programs/explorer/systray.c b/programs/explorer/systray.c index 7d2d3795575..1d8a83536ca 100644 --- a/programs/explorer/systray.c +++ b/programs/explorer/systray.c @@ -621,6 +621,7 @@ static BOOL show_icon(struct icon *icon) { icon->display = ICON_DISPLAY_DOCKED; icon->layered = TRUE; + SetWindowLongW( icon->window, GWL_EXSTYLE, GetWindowLongW( icon->window, GWL_EXSTYLE ) | WS_EX_LAYERED ); SendMessageW( icon->window, WM_SIZE, SIZE_RESTORED, MAKELONG( icon_cx, icon_cy ) ); } systray_add_icon( icon ); @@ -642,6 +643,7 @@ static BOOL hide_icon(struct icon *icon) { icon->display = ICON_DISPLAY_HIDDEN; icon->layered = FALSE; + SetWindowLongW( icon->window, GWL_EXSTYLE, GetWindowLongW( icon->window, GWL_EXSTYLE ) & ~WS_EX_LAYERED ); } ShowWindow( icon->window, SW_HIDE ); systray_remove_icon( icon ); @@ -729,7 +731,7 @@ static BOOL add_icon(NOTIFYICONDATAW *nid) icon->owner = nid->hWnd; icon->display = ICON_DISPLAY_HIDDEN;
- CreateWindowExW( WS_EX_LAYERED, tray_icon_class.lpszClassName, NULL, WS_CLIPSIBLINGS | WS_POPUP, + CreateWindowExW( 0, tray_icon_class.lpszClassName, NULL, WS_CLIPSIBLINGS | WS_POPUP, 0, 0, icon_cx, icon_cy, 0, NULL, NULL, icon ); if (!icon->window) ERR( "Failed to create systray icon window\n" );