Windows: regenerate systray icon when screen resolution changes
When the screen resolution or scale factor changes, then we have to recreate the system tray icon so that it doesn't get blurry. Such changes generate a WM_TASKBARCREATED message, which we already handle through a self-registered message ID to re-add the icon when the task bar/explorer crashed. So call updateIcon there to recreate the HICON before adding it again. For this to work, we have to actually store the QIcon in the already present (but so far unused) m_icon member, and reset that member before calling updateIcon, which would otherwise be a no-op. Fixes: QTBUG-108641 Change-Id: If3dd042416b7f61bbb3b43f7d563e52b406136a2 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> (cherry picked from commit 9bc36308c77e10c6a890c3dd6a72dd2f23a72288) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
bd7f23f347
commit
49d6a259cd
@ -171,6 +171,7 @@ void QWindowsSystemTrayIcon::updateIcon(const QIcon &icon)
|
|||||||
qCDebug(lcQpaTrayIcon) << __FUNCTION__ << '(' << icon << ')' << this;
|
qCDebug(lcQpaTrayIcon) << __FUNCTION__ << '(' << icon << ')' << this;
|
||||||
if (icon.cacheKey() == m_icon.cacheKey())
|
if (icon.cacheKey() == m_icon.cacheKey())
|
||||||
return;
|
return;
|
||||||
|
m_icon = icon;
|
||||||
const HICON hIconToDestroy = createIcon(icon);
|
const HICON hIconToDestroy = createIcon(icon);
|
||||||
if (ensureInstalled())
|
if (ensureInstalled())
|
||||||
sendTrayMessage(NIM_MODIFY);
|
sendTrayMessage(NIM_MODIFY);
|
||||||
@ -409,8 +410,15 @@ bool QWindowsSystemTrayIcon::winEvent(const MSG &message, long *result)
|
|||||||
QWindowsPopupMenu::notifyTriggered(LOWORD(message.wParam));
|
QWindowsPopupMenu::notifyTriggered(LOWORD(message.wParam));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (message.message == MYWM_TASKBARCREATED) // self-registered message id (tray crashed)
|
if (message.message == MYWM_TASKBARCREATED) {
|
||||||
|
// self-registered message id to handle that
|
||||||
|
// - screen resolution/DPR changed
|
||||||
|
const QIcon oldIcon = m_icon;
|
||||||
|
m_icon = QIcon(); // updateIcon is a no-op if the icon doesn't change
|
||||||
|
updateIcon(oldIcon);
|
||||||
|
// - or tray crashed
|
||||||
sendTrayMessage(NIM_ADD);
|
sendTrayMessage(NIM_ADD);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user