forked from github_mirror/framelesshelper
parent
e6f0822175
commit
91e7351ea3
|
@ -32,7 +32,6 @@
|
||||||
#endif
|
#endif
|
||||||
#include <QLibrary>
|
#include <QLibrary>
|
||||||
#include <QOperatingSystemVersion>
|
#include <QOperatingSystemVersion>
|
||||||
#include <QTimer>
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <windowsx.h>
|
#include <windowsx.h>
|
||||||
|
|
||||||
|
@ -215,7 +214,7 @@ QVector<HWND> m_framelessWindows;
|
||||||
|
|
||||||
WinNativeEventFilter::WinNativeEventFilter() { initWin32Api(); }
|
WinNativeEventFilter::WinNativeEventFilter() { initWin32Api(); }
|
||||||
|
|
||||||
WinNativeEventFilter::~WinNativeEventFilter() = default;
|
WinNativeEventFilter::~WinNativeEventFilter() { removeUserData(); };
|
||||||
|
|
||||||
void WinNativeEventFilter::install() {
|
void WinNativeEventFilter::install() {
|
||||||
if (m_instance.isNull()) {
|
if (m_instance.isNull()) {
|
||||||
|
@ -494,7 +493,7 @@ bool WinNativeEventFilter::nativeEventFilter(const QByteArray &eventType,
|
||||||
const auto isInSpecificAreas = [](int x, int y,
|
const auto isInSpecificAreas = [](int x, int y,
|
||||||
const QVector<QRect> &areas,
|
const QVector<QRect> &areas,
|
||||||
qreal dpr) -> bool {
|
qreal dpr) -> bool {
|
||||||
for (auto &&area : qAsConst(areas)) {
|
for (auto &&area : std::as_const(areas)) {
|
||||||
if (!area.isValid()) {
|
if (!area.isValid()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -914,3 +913,15 @@ qreal WinNativeEventFilter::getPreferedNumber(qreal num) {
|
||||||
#endif
|
#endif
|
||||||
return result;
|
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;
|
~WinNativeEventFilter() override;
|
||||||
|
|
||||||
// Make all top level windows become frameless, unconditionally.
|
// 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();
|
static void install();
|
||||||
// Make all top level windows back to normal.
|
// Make all top level windows back to normal.
|
||||||
static void uninstall();
|
static void uninstall();
|
||||||
|
@ -107,4 +110,5 @@ private:
|
||||||
static UINT getDotsPerInchForWindow(HWND handle);
|
static UINT getDotsPerInchForWindow(HWND handle);
|
||||||
static qreal getDevicePixelRatioForWindow(HWND handle);
|
static qreal getDevicePixelRatioForWindow(HWND handle);
|
||||||
static int getSystemMetricsForWindow(HWND handle, int index);
|
static int getSystemMetricsForWindow(HWND handle, int index);
|
||||||
|
void removeUserData();
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue