From 0d499313e263055a8dc53bc476e7e19dde2c4e51 Mon Sep 17 00:00:00 2001 From: fourtf Date: Sun, 24 Jun 2018 21:57:03 +0200 Subject: [PATCH] fixed maximized mode margin on windows --- src/widgets/basewindow.cpp | 14 ++++++++++++++ src/widgets/basewindow.hpp | 1 + 2 files changed, 15 insertions(+) diff --git a/src/widgets/basewindow.cpp b/src/widgets/basewindow.cpp index 676a25249..ec7d14053 100644 --- a/src/widgets/basewindow.cpp +++ b/src/widgets/basewindow.cpp @@ -83,6 +83,7 @@ void BaseWindow::init() if (this->hasCustomWindowFrame()) { // CUSTOM WINDOW FRAME QVBoxLayout *layout = new QVBoxLayout(); + this->ui_.windowLayout = layout; layout->setContentsMargins(0, 1, 0, 0); layout->setSpacing(0); this->setLayout(layout); @@ -464,6 +465,19 @@ bool BaseWindow::nativeEvent(const QByteArray &eventType, void *message, long *r return QWidget::nativeEvent(eventType, message, result); } } break; + case WM_SIZE: { + if (this->ui_.windowLayout) { + if (msg->wParam == SIZE_MAXIMIZED) { + auto offset = int(this->getScale() * 8); + + this->ui_.windowLayout->setContentsMargins(offset, offset, offset, offset); + } else { + this->ui_.windowLayout->setContentsMargins(0, 1, 0, 0); + } + } + + return QWidget::nativeEvent(eventType, message, result); + } case WM_NCHITTEST: { const LONG border_width = 8; // in pixels RECT winrect; diff --git a/src/widgets/basewindow.hpp b/src/widgets/basewindow.hpp index b88bbccc4..ebb771546 100644 --- a/src/widgets/basewindow.hpp +++ b/src/widgets/basewindow.hpp @@ -84,6 +84,7 @@ private: float nativeScale_ = 1; struct { + QLayout *windowLayout = nullptr; QHBoxLayout *titlebarBox = nullptr; QWidget *titleLabel = nullptr; TitleBarButton *minButton = nullptr;