forked from github_mirror/framelesshelper
parent
136b865853
commit
57d2667c5e
|
@ -84,7 +84,7 @@ void FramelessHelper::updateQtFrame(QWindow *const window,
|
||||||
// window.
|
// window.
|
||||||
window->setProperty("_q_windowsCustomMargins", marginsVar);
|
window->setProperty("_q_windowsCustomMargins", marginsVar);
|
||||||
// If a platform window exists, change via native interface.
|
// If a platform window exists, change via native interface.
|
||||||
QPlatformWindow *platformWindow = window->handle();
|
QPlatformWindow *const platformWindow = window->handle();
|
||||||
if (platformWindow) {
|
if (platformWindow) {
|
||||||
QGuiApplication::platformNativeInterface()->setWindowProperty(
|
QGuiApplication::platformNativeInterface()->setWindowProperty(
|
||||||
platformWindow, QString::fromUtf8("WindowsCustomMargins"),
|
platformWindow, QString::fromUtf8("WindowsCustomMargins"),
|
||||||
|
@ -204,7 +204,7 @@ void FramelessHelper::removeWindowFrame(QObject *const obj) {
|
||||||
if (obj) {
|
if (obj) {
|
||||||
// Don't miss the Qt::Window flag.
|
// Don't miss the Qt::Window flag.
|
||||||
const Qt::WindowFlags flags = Qt::Window | Qt::FramelessWindowHint;
|
const Qt::WindowFlags flags = Qt::Window | Qt::FramelessWindowHint;
|
||||||
QWindow *window = getWindowHandle(obj);
|
QWindow *const window = getWindowHandle(obj);
|
||||||
if (window) {
|
if (window) {
|
||||||
window->setFlags(flags);
|
window->setFlags(flags);
|
||||||
// MouseTracking is always enabled for QWindow.
|
// MouseTracking is always enabled for QWindow.
|
||||||
|
@ -418,7 +418,7 @@ bool FramelessHelper::eventFilter(QObject *object, QEvent *event) {
|
||||||
const auto moveOrResize = [&getWindowEdges, &isResizePermitted,
|
const auto moveOrResize = [&getWindowEdges, &isResizePermitted,
|
||||||
&isInTitlebarArea](const QPointF &point,
|
&isInTitlebarArea](const QPointF &point,
|
||||||
QObject *const object) {
|
QObject *const object) {
|
||||||
QWindow *window = getWindowHandle(object);
|
QWindow *const window = getWindowHandle(object);
|
||||||
if (window) {
|
if (window) {
|
||||||
const Qt::Edges edges =
|
const Qt::Edges edges =
|
||||||
getWindowEdges(point, window->width(), window->height());
|
getWindowEdges(point, window->width(), window->height());
|
||||||
|
@ -500,7 +500,7 @@ bool FramelessHelper::eventFilter(QObject *object, QEvent *event) {
|
||||||
case QEvent::MouseMove: {
|
case QEvent::MouseMove: {
|
||||||
const auto mouseEvent = static_cast<QMouseEvent *>(event);
|
const auto mouseEvent = static_cast<QMouseEvent *>(event);
|
||||||
if (mouseEvent) {
|
if (mouseEvent) {
|
||||||
QWindow *window = getWindowHandle(object);
|
QWindow *const window = getWindowHandle(object);
|
||||||
if (window) {
|
if (window) {
|
||||||
if (window->windowStates().testFlag(
|
if (window->windowStates().testFlag(
|
||||||
Qt::WindowState::WindowNoState)) {
|
Qt::WindowState::WindowNoState)) {
|
||||||
|
|
|
@ -1682,7 +1682,7 @@ void WinNativeEventFilter::updateQtFrame(QWindow *const window,
|
||||||
// window.
|
// window.
|
||||||
window->setProperty("_q_windowsCustomMargins", marginsVar);
|
window->setProperty("_q_windowsCustomMargins", marginsVar);
|
||||||
// If a platform window exists, change via native interface.
|
// If a platform window exists, change via native interface.
|
||||||
QPlatformWindow *platformWindow = window->handle();
|
QPlatformWindow *const platformWindow = window->handle();
|
||||||
if (platformWindow) {
|
if (platformWindow) {
|
||||||
QGuiApplication::platformNativeInterface()->setWindowProperty(
|
QGuiApplication::platformNativeInterface()->setWindowProperty(
|
||||||
platformWindow, QString::fromUtf8("WindowsCustomMargins"),
|
platformWindow, QString::fromUtf8("WindowsCustomMargins"),
|
||||||
|
@ -1707,6 +1707,12 @@ void WinNativeEventFilter::updateQtFrame_internal(const HWND handle) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
// ### FIXME: Doesn't really work for QWindow.
|
||||||
|
// How to get the corresponding QWindow from
|
||||||
|
// it's window handle? Most blogs on the Internet
|
||||||
|
// say use QWindow::fromWinId(), but it doesn't
|
||||||
|
// work as expected. We can get a QWindow, but
|
||||||
|
// it's not the QWindow we created.
|
||||||
QWindow *const window = QWindow::fromWinId(wid);
|
QWindow *const window = QWindow::fromWinId(wid);
|
||||||
if (window) {
|
if (window) {
|
||||||
updateQtFrame(window, tbh);
|
updateQtFrame(window, tbh);
|
||||||
|
|
Loading…
Reference in New Issue