Skip to content
This repository has been archived by the owner on Dec 19, 2023. It is now read-only.

Commit

Permalink
widgets module: fix two issues
Browse files Browse the repository at this point in the history
1. The top border has a one pixel gap under some circumstances, fixed
2. The zoomed property didn't get notified correctly sometimes, fixed

Signed-off-by: Yuhang Zhao <[email protected]>
  • Loading branch information
wangwenx190 committed Apr 22, 2022
1 parent 3f17626 commit 201f54e
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/widgets/framelesswidgetshelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,11 @@ void FramelessWidgetsHelper::changeEventHandler(QEvent *event)
updateSystemTitleBarStyleSheet();
}
q->update();
if (type == QEvent::WindowStateChange) {
QMetaObject::invokeMethod(q, "hiddenChanged");
QMetaObject::invokeMethod(q, "normalChanged");
QMetaObject::invokeMethod(q, "zoomedChanged");
}
}

void FramelessWidgetsHelper::paintEventHandler(QPaintEvent *event)
Expand All @@ -259,7 +264,11 @@ void FramelessWidgetsHelper::paintEventHandler(QPaintEvent *event)
pen.setColor(Utils::getFrameBorderColor(q->isActiveWindow()));
pen.setWidth(1);
painter.setPen(pen);
painter.drawLine(0, 0, (q->width() - 1), 0);
// We should use "q->width() - 1" actually but we can't because
// Qt's drawing system have some rounding error internally and
// if we minus one here we'll get a one pixel gap, so sad. But
// drawing a line with extra pixels won't hurt anyway.
painter.drawLine(0, 0, q->width(), 0);
painter.restore();
#else
Q_UNUSED(event);
Expand Down Expand Up @@ -468,11 +477,6 @@ void FramelessWidgetsHelper::initialize()
}
QMetaObject::invokeMethod(q, "systemThemeChanged");
});
connect(q->windowHandle(), &QWindow::visibilityChanged, this, [this](){
QMetaObject::invokeMethod(q, "hiddenChanged");
QMetaObject::invokeMethod(q, "normalChanged");
QMetaObject::invokeMethod(q, "zoomedChanged");
});
setupInitialUi();
if (m_settings.options & Option::CreateStandardWindowLayout) {
m_settings.minimizeButton = m_systemMinimizeButton.data();
Expand Down

0 comments on commit 201f54e

Please sign in to comment.