parent
e6f0822175
commit
91e7351ea3
|
@ -32,7 +32,6 @@
|
|||
#endif
|
||||
#include <QLibrary>
|
||||
#include <QOperatingSystemVersion>
|
||||
#include <QTimer>
|
||||
#include <cmath>
|
||||
#include <windowsx.h>
|
||||
|
||||
|
@ -215,7 +214,7 @@ QVector<HWND> m_framelessWindows;
|
|||
|
||||
WinNativeEventFilter::WinNativeEventFilter() { initWin32Api(); }
|
||||
|
||||
WinNativeEventFilter::~WinNativeEventFilter() = default;
|
||||
WinNativeEventFilter::~WinNativeEventFilter() { removeUserData(); };
|
||||
|
||||
void WinNativeEventFilter::install() {
|
||||
if (m_instance.isNull()) {
|
||||
|
@ -494,7 +493,7 @@ bool WinNativeEventFilter::nativeEventFilter(const QByteArray &eventType,
|
|||
const auto isInSpecificAreas = [](int x, int y,
|
||||
const QVector<QRect> &areas,
|
||||
qreal dpr) -> bool {
|
||||
for (auto &&area : qAsConst(areas)) {
|
||||
for (auto &&area : std::as_const(areas)) {
|
||||
if (!area.isValid()) {
|
||||
continue;
|
||||
}
|
||||
|
@ -914,3 +913,15 @@ qreal WinNativeEventFilter::getPreferedNumber(qreal num) {
|
|||
#endif
|
||||
return result;
|
||||
}
|
||||
|
||||
void WinNativeEventFilter::removeUserData() {
|
||||
// TODO: all top level windows of QGuiApplication.
|
||||
if (!m_framelessWindows.isEmpty()) {
|
||||
for (auto &&window : std::as_const(m_framelessWindows)) {
|
||||
const auto userData = reinterpret_cast<WINDOW *>(m_lpGetWindowLongPtrW(window, GWLP_USERDATA));
|
||||
if (userData) {
|
||||
delete userData;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,6 +54,9 @@ public:
|
|||
~WinNativeEventFilter() override;
|
||||
|
||||
// Make all top level windows become frameless, unconditionally.
|
||||
// Use setFramelessWindows or addFramelessWindow if possible,
|
||||
// because this method will cause strange behavior, currently
|
||||
// don't know why.
|
||||
static void install();
|
||||
// Make all top level windows back to normal.
|
||||
static void uninstall();
|
||||
|
@ -107,4 +110,5 @@ private:
|
|||
static UINT getDotsPerInchForWindow(HWND handle);
|
||||
static qreal getDevicePixelRatioForWindow(HWND handle);
|
||||
static int getSystemMetricsForWindow(HWND handle, int index);
|
||||
void removeUserData();
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue