Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build without shadows enabled #118

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 8 additions & 17 deletions src/decoration/qgnomeplatformdecoration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@
#define BUTTON_WIDTH 28

// Decoration sizing
#ifdef DECORATION_SHADOWS_SUPPORT // Qt 6.2.0+ or patched QtWayland
#define SHADOWS_WIDTH 10
#else
#define SHADOWS_WIDTH 0
#endif
#define TITLEBAR_HEIGHT 37
#define WINDOW_BORDER_WIDTH 1

Expand Down Expand Up @@ -141,7 +145,6 @@ QRectF QGnomePlatformDecoration::minimizeButtonRect() const
}
}

#ifdef DECORATION_SHADOWS_SUPPORT // Qt 6.2.0+ or patched QtWayland
QMargins QGnomePlatformDecoration::margins(MarginsType marginsType) const
{
const bool maximized = waylandWindow()->windowStates() & Qt::WindowMaximized;
Expand Down Expand Up @@ -179,18 +182,6 @@ QMargins QGnomePlatformDecoration::margins(MarginsType marginsType) const
return QMargins(tiledLeft ? 0 : SHADOWS_WIDTH, tiledTop ? 0 : SHADOWS_WIDTH, tiledRight ? 0 : SHADOWS_WIDTH, tiledBottom ? 0 : SHADOWS_WIDTH);
}
}
#else
QMargins QGnomePlatformDecoration::margins() const
{
if ((window()->windowStates() & Qt::WindowMaximized)) {
return QMargins(0, TITLEBAR_HEIGHT, 0, 0);
}

return QMargins(WINDOW_BORDER_WIDTH, // Left
TITLEBAR_HEIGHT + WINDOW_BORDER_WIDTH, // Top
WINDOW_BORDER_WIDTH, // Right
WINDOW_BORDER_WIDTH); // Bottom
#endif
}

void QGnomePlatformDecoration::paint(QPaintDevice *device)
Expand Down Expand Up @@ -372,7 +363,7 @@ void QGnomePlatformDecoration::paint(QPaintDevice *device)
// * *
// ********************************
QPainterPath borderRect;
if (!(window()->windowStates() & Qt::WindowMaximized)) {
if (!(waylandWindow()->windowStates() & Qt::WindowMaximized)) {
borderRect.addRoundedRect(0, 0, surfaceRect.width(), margins().top() + 8, 10, 10);
p.fillPath(borderRect.simplified(), borderColor);
}
Expand All @@ -390,7 +381,7 @@ void QGnomePlatformDecoration::paint(QPaintDevice *device)
// * *
// ********************************
QPainterPath roundedRect;
if ((window()->windowStates() & Qt::WindowMaximized)) {
if ((waylandWindow()->windowStates() & Qt::WindowMaximized)) {
roundedRect.addRect(0, 0, surfaceRect.width(), margins().top() + 8);
} else {
roundedRect
Expand All @@ -414,7 +405,7 @@ void QGnomePlatformDecoration::paint(QPaintDevice *device)
// *| |*
// *------------------------------*
// ********************************
if (!(window()->windowStates() & Qt::WindowMaximized)) {
if (!(waylandWindow()->windowStates() & Qt::WindowMaximized)) {
QPainterPath borderPath;
// Left
borderPath.addRect(0, margins().top(), margins().left(), surfaceRect.height() - margins().top() - WINDOW_BORDER_WIDTH);
Expand Down Expand Up @@ -499,7 +490,7 @@ void QGnomePlatformDecoration::paint(QPaintDevice *device)
if (GnomeSettings::getInstance().titlebarButtons().testFlag(GnomeSettings::getInstance().MaximizeButton)) {
renderButton(&p,
maximizeButtonRect(),
(window()->windowStates() & Qt::WindowMaximized) ? Adwaita::ButtonType::ButtonRestore : Adwaita::ButtonType::ButtonMaximize,
(waylandWindow()->windowStates() & Qt::WindowMaximized) ? Adwaita::ButtonType::ButtonRestore : Adwaita::ButtonType::ButtonMaximize,
m_maximizeButtonHovered && active,
m_clicking == Button::Maximize || m_clicking == Button::Restore);
}
Expand Down
4 changes: 0 additions & 4 deletions src/decoration/qgnomeplatformdecoration.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,7 @@ class QGnomePlatformDecoration : public QWaylandAbstractDecoration
virtual ~QGnomePlatformDecoration() override = default;

protected:
#ifdef DECORATION_SHADOWS_SUPPORT // Qt 6.2.0+ or patched QtWayland
QMargins margins(MarginsType marginsType = Full) const override;
#else
QMargins margins() const override;
#endif
void paint(QPaintDevice *device) override;
bool handleMouse(QWaylandInputDevice *inputDevice, const QPointF &local, const QPointF &global, Qt::MouseButtons b, Qt::KeyboardModifiers mods) override;
#if QT_VERSION >= 0x060000
Expand Down