parent
09100a1845
commit
7aae486ba9
|
@ -36,6 +36,7 @@
|
||||||
#include <QGuiApplication>
|
#include <QGuiApplication>
|
||||||
#include <QLibrary>
|
#include <QLibrary>
|
||||||
#include <QMargins>
|
#include <QMargins>
|
||||||
|
#include <QScreen>
|
||||||
#include <QWindow>
|
#include <QWindow>
|
||||||
#include <QtMath>
|
#include <QtMath>
|
||||||
#include <qt_windows.h>
|
#include <qt_windows.h>
|
||||||
|
@ -1119,6 +1120,29 @@ bool displaySystemMenu_internal(const HWND handle, const bool isRtl, const LPARA
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString getCurrentScreenSerialNumber(const HWND handle)
|
||||||
|
{
|
||||||
|
Q_ASSERT(handle);
|
||||||
|
ResolveWin32APIs();
|
||||||
|
if (WNEF_EXECUTE_WINAPI_RETURN(IsWindow, FALSE, handle)) {
|
||||||
|
QScreen *currentScreen = nullptr;
|
||||||
|
#ifdef QT_WIDGETS_LIB
|
||||||
|
const QWidget *widget = QWidget::find(reinterpret_cast<WId>(handle));
|
||||||
|
if (widget && widget->isTopLevel()) {
|
||||||
|
currentScreen = widget->screen();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (!currentScreen) {
|
||||||
|
const QWindow *window = findQWindowFromRawHandle(handle);
|
||||||
|
if (window) {
|
||||||
|
currentScreen = window->screen();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return currentScreen ? currentScreen->serialNumber().toUpper() : QString();
|
||||||
|
}
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
WinNativeEventFilter::WinNativeEventFilter()
|
WinNativeEventFilter::WinNativeEventFilter()
|
||||||
|
@ -1261,6 +1285,8 @@ bool WinNativeEventFilter::nativeEventFilter(const QByteArray &eventType,
|
||||||
if (!data->initialized) {
|
if (!data->initialized) {
|
||||||
// Avoid initializing a same window twice.
|
// Avoid initializing a same window twice.
|
||||||
data->initialized = true;
|
data->initialized = true;
|
||||||
|
// Record the current screen.
|
||||||
|
data->currentScreen = getCurrentScreenSerialNumber(msg->hwnd);
|
||||||
// Don't restore the window styles to default when you are
|
// Don't restore the window styles to default when you are
|
||||||
// developing Qt Quick applications because the QWindow
|
// developing Qt Quick applications because the QWindow
|
||||||
// will disappear once you do it. However, Qt Widgets applications
|
// will disappear once you do it. However, Qt Widgets applications
|
||||||
|
@ -1307,9 +1333,10 @@ bool WinNativeEventFilter::nativeEventFilter(const QByteArray &eventType,
|
||||||
0,
|
0,
|
||||||
LWA_COLORKEY)
|
LWA_COLORKEY)
|
||||||
}
|
}
|
||||||
setAcrylicEffectEnabled(msg->hwnd, data->enableBlurBehindWindow);
|
|
||||||
// Bring our frame shadow back through DWM, don't draw it manually.
|
// Bring our frame shadow back through DWM, don't draw it manually.
|
||||||
UpdateFrameMarginsForWindow(msg->hwnd);
|
UpdateFrameMarginsForWindow(msg->hwnd);
|
||||||
|
// Blur effect.
|
||||||
|
setAcrylicEffectEnabled(msg->hwnd, data->enableBlurBehindWindow);
|
||||||
}
|
}
|
||||||
switch (msg->message) {
|
switch (msg->message) {
|
||||||
case WM_NCCALCSIZE: {
|
case WM_NCCALCSIZE: {
|
||||||
|
@ -1539,8 +1566,9 @@ bool WinNativeEventFilter::nativeEventFilter(const QByteArray &eventType,
|
||||||
if (!shouldHaveWindowFrame() && !IsFullScreen(msg->hwnd) && !IsMaximized(msg->hwnd)
|
if (!shouldHaveWindowFrame() && !IsFullScreen(msg->hwnd) && !IsMaximized(msg->hwnd)
|
||||||
&& !IsMinimized(msg->hwnd)) {
|
&& !IsMinimized(msg->hwnd)) {
|
||||||
// Fix the flickering problem when resizing.
|
// Fix the flickering problem when resizing.
|
||||||
|
// Don't modify the left, right or bottom edge because
|
||||||
|
// a border line will be seen (at least on Win10).
|
||||||
clientRect->top -= 1;
|
clientRect->top -= 1;
|
||||||
//*result = 0;
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1965,6 +1993,14 @@ bool WinNativeEventFilter::nativeEventFilter(const QByteArray &eventType,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case WM_MOVE: {
|
||||||
|
const QString sn = getCurrentScreenSerialNumber(msg->hwnd);
|
||||||
|
if (data->currentScreen.toUpper() != sn) {
|
||||||
|
data->currentScreen = sn;
|
||||||
|
updateWindow(msg->hwnd, true, true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,7 @@ public:
|
||||||
QList<QRect> ignoreAreas = {}, draggableAreas = {};
|
QList<QRect> ignoreAreas = {}, draggableAreas = {};
|
||||||
QList<QPointer<QObject>> ignoreObjects = {}, draggableObjects = {};
|
QList<QPointer<QObject>> ignoreObjects = {}, draggableObjects = {};
|
||||||
QSize maximumSize = {}, minimumSize = {};
|
QSize maximumSize = {}, minimumSize = {};
|
||||||
|
QString currentScreen = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class SystemMetric { BorderWidth, BorderHeight, TitleBarHeight };
|
enum class SystemMetric { BorderWidth, BorderHeight, TitleBarHeight };
|
||||||
|
@ -137,7 +138,8 @@ public:
|
||||||
const int x,
|
const int x,
|
||||||
const int y);
|
const int y);
|
||||||
|
|
||||||
// a
|
// Enable or disable the blur effect for a specific window.
|
||||||
|
// On Win10 it's the Acrylic effect.
|
||||||
static bool setAcrylicEffectEnabled(void *handle /* HWND */, const bool enabled = true);
|
static bool setAcrylicEffectEnabled(void *handle /* HWND */, const bool enabled = true);
|
||||||
|
|
||||||
///////////////////////////////////////////////
|
///////////////////////////////////////////////
|
||||||
|
|
Loading…
Reference in New Issue