Fix stale taskbar preview thumbnails after closing child windows.
This commit is contained in:
parent
e11f5b7eaa
commit
8b7a6d38b9
|
|
@ -853,6 +853,7 @@ target_link_libraries(gui PRIVATE
|
|||
md4c-html
|
||||
winmm
|
||||
wininet
|
||||
dwmapi
|
||||
)
|
||||
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 4) # x86
|
||||
|
|
|
|||
|
|
@ -148,6 +148,7 @@ private-link-libraries = [
|
|||
"::md4c-html",
|
||||
"winmm",
|
||||
"wininet",
|
||||
"dwmapi"
|
||||
]
|
||||
x86.private-link-libraries = [
|
||||
"src/gui/Src/ThirdPartyLibs/ldconvert/ldconvert_x86.lib",
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
#include <QDebug>
|
||||
#include <QDir>
|
||||
#include "MiscUtil.h"
|
||||
#include <dwmapi.h>
|
||||
|
||||
MyApplication::MyApplication(int & argc, char** argv)
|
||||
: QApplication(argc, argv)
|
||||
|
|
@ -28,6 +29,21 @@ bool MyApplication::globalEventFilter(void* message)
|
|||
}
|
||||
#endif
|
||||
|
||||
static void invalidateParentThumbnail(QDialog* dialog)
|
||||
{
|
||||
// Find the top-level parent window
|
||||
auto parent = dialog->parentWidget();
|
||||
while(parent && parent->parentWidget())
|
||||
{
|
||||
parent = parent->parentWidget();
|
||||
}
|
||||
|
||||
if(parent && parent->windowHandle())
|
||||
{
|
||||
DwmInvalidateIconicBitmaps((HWND)parent->winId());
|
||||
}
|
||||
}
|
||||
|
||||
bool MyApplication::notify(QObject* receiver, QEvent* event)
|
||||
{
|
||||
bool done = true;
|
||||
|
|
@ -41,7 +57,20 @@ bool MyApplication::notify(QObject* receiver, QEvent* event)
|
|||
MainWindow::updateDarkTitleBar(widget);
|
||||
}
|
||||
}
|
||||
|
||||
done = QApplication::notify(receiver, event);
|
||||
|
||||
// Fix stale taskbar preview thumbnails after closing child windows.
|
||||
// Windows DWM caches the preview bitmap while hovering the taskbar, but Qt
|
||||
// doesn't notify DWM when modal dialogs close, leaving the cached thumbnail
|
||||
// showing the now-closed dialog. Force DWM to refresh by invalidating it.
|
||||
if(event->type() == QEvent::Hide)
|
||||
{
|
||||
if(auto dialog = qobject_cast<QDialog*>(receiver))
|
||||
{
|
||||
invalidateParentThumbnail(dialog);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(const std::exception & ex)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -33,12 +33,12 @@ extern thread_local TranslatedStringStorage TLS_TranslatedString;
|
|||
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
|
||||
class MyEventFilter : public QAbstractNativeEventFilter
|
||||
{
|
||||
public:
|
||||
virtual bool nativeEventFilter(const QByteArray & eventType, void* message, long* result) Q_DECL_OVERRIDE
|
||||
protected:
|
||||
bool nativeEventFilter(const QByteArray & eventType, void* message, long* result) override
|
||||
{
|
||||
if(eventType == "windows_dispatcher_MSG")
|
||||
return DbgWinEventGlobal((MSG*)message);
|
||||
else if(eventType == "windows_generic_MSG")
|
||||
if(eventType == "windows_generic_MSG")
|
||||
return DbgWinEvent((MSG*)message, result);
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue