Get rid of _nativeFrame variable, _title->isHidden is enough

This commit is contained in:
Ilya Fedin 2021-08-08 00:44:30 +04:00 committed by John Preston
parent 381bfc43c5
commit 98c7979e67
4 changed files with 11 additions and 15 deletions

View file

@ -146,7 +146,7 @@ DefaultWindowHelper::DefaultWindowHelper(not_null<RpWidget*> window)
}
void DefaultWindowHelper::init() {
_title->show(); // Be consistent with _nativeFrame == false.
_title->show();
window()->setWindowFlag(Qt::FramelessWindowHint);
if (WindowExtentsSupported()) {
@ -251,7 +251,7 @@ bool DefaultWindowHelper::hasShadow() const {
QMargins DefaultWindowHelper::resizeArea() const {
if (window()->isMaximized()
|| window()->isFullScreen()
|| _nativeFrame) {
|| _title->isHidden()) {
return QMargins();
}
@ -329,7 +329,6 @@ void DefaultWindowHelper::setTitleStyle(const style::WindowTitle &st) {
}
void DefaultWindowHelper::setNativeFrame(bool enabled) {
_nativeFrame = enabled;
window()->windowHandle()->setFlag(Qt::FramelessWindowHint, !enabled);
_title->setVisible(!enabled);
updateWindowExtents();
@ -395,7 +394,7 @@ void DefaultWindowHelper::paintBorders(QPainter &p) {
}
void DefaultWindowHelper::updateWindowExtents() {
if (hasShadow() && !_nativeFrame) {
if (hasShadow() && !_title->isHidden()) {
Platform::SetWindowExtents(
window()->windowHandle(),
resizeArea());

View file

@ -90,7 +90,6 @@ private:
const not_null<DefaultTitleWidget*> _title;
const not_null<RpWidget*> _body;
bool _extentsSet = false;
bool _nativeFrame = false;
rpl::variable<Qt::WindowStates> _windowState = Qt::WindowNoState;
};

View file

@ -172,7 +172,6 @@ void WindowHelper::setTitleStyle(const style::WindowTitle &st) {
}
void WindowHelper::setNativeFrame(bool enabled) {
_nativeFrame = enabled;
_title->setVisible(!enabled);
if (enabled) {
_shadow.reset();
@ -217,7 +216,7 @@ void WindowHelper::showNormal() {
}
void WindowHelper::init() {
_title->show(); // Be consistent with _nativeFrame == false.
_title->show();
GetNativeFilter()->registerWindow(_handle, this);
style::PaletteChanged(
@ -290,14 +289,14 @@ bool WindowHelper::handleNativeEvent(
} return false;
case WM_NCPAINT: {
if (::Platform::IsWindows8OrGreater() || _nativeFrame) {
if (::Platform::IsWindows8OrGreater() || _title->isHidden()) {
return false;
}
if (result) *result = 0;
} return true;
case WM_NCCALCSIZE: {
if (_nativeFrame) {
if (_title->isHidden()) {
return false;
}
WINDOWPLACEMENT wp;
@ -343,7 +342,7 @@ bool WindowHelper::handleNativeEvent(
} return true;
case WM_NCACTIVATE: {
if (_nativeFrame) {
if (_title->isHidden()) {
return false;
}
if (IsCompositionEnabled()) {
@ -416,7 +415,7 @@ bool WindowHelper::handleNativeEvent(
} return false;
case WM_NCHITTEST: {
if (!result || _nativeFrame) {
if (!result || _title->isHidden()) {
return false;
}
@ -449,7 +448,7 @@ bool WindowHelper::handleNativeEvent(
} return true;
case WM_NCRBUTTONUP: {
if (_nativeFrame) {
if (_title->isHidden()) {
return false;
}
SendMessage(_handle, WM_SYSCOMMAND, SC_MOUSEMENU, lParam);
@ -566,9 +565,9 @@ void WindowHelper::updateMargins() {
_marginsDelta = QMargins();
}
if (_isFullScreen || _nativeFrame) {
if (_isFullScreen || _title->isHidden()) {
margins = QMargins();
if (_nativeFrame) {
if (_title->isHidden()) {
_marginsDelta = QMargins();
}
}

View file

@ -58,7 +58,6 @@ private:
QMargins _marginsDelta;
HMENU _menu = nullptr;
bool _isFullScreen = false;
bool _nativeFrame = false;
};