5#include <QtGui/QCursor>
6#include <QtGui/QPainter>
7#include <QtGui/QPainterPath>
8#include <QtGui/QPalette>
9#include <QtGui/QLinearGradient>
10#include <QtGui/QPainterPath>
12#include <qpa/qwindowsysteminterface.h>
14#include <QtWaylandClient/private/qwaylanddecorationplugin_p.h>
15#include <QtWaylandClient/private/qwaylandabstractdecoration_p.h>
16#include <QtWaylandClient/private/qwaylandwindow_p.h>
17#include <QtWaylandClient/private/qwaylandshellsurface_p.h>
23#define BUTTON_SPACING 5
24#define BUTTON_WIDTH 18
25#define BUTTONS_RIGHT_MARGIN 8
45 enum class PointerType {
54 bool clickButton(Qt::MouseButtons
b,
Button btn);
56 QRectF closeButtonRect()
const;
57 QRectF maximizeButtonRect()
const;
58 QRectF minimizeButtonRect()
const;
74QRectF QWaylandBradientDecoration::closeButtonRect()
const
81QRectF QWaylandBradientDecoration::maximizeButtonRect()
const
88QRectF QWaylandBradientDecoration::minimizeButtonRect()
const
129 for (
int i = 0;
i < 4; ++
i) {
131 p.setClipRect(clips[
i]);
132 p.fillPath(roundedRect, backgroundColor);
139 QRectF iconRect(0, 0, 22, 22);
147 if (!windowTitleText.isEmpty()) {
148 if (m_windowTitle.
text() != windowTitleText) {
149 m_windowTitle.
setText(windowTitleText);
159 p.setClipRect(titleBar);
160 p.setPen(active ? foregroundColor : foregroundInactiveColor);
162 int dx = (
top.width() -
size.width()) /2;
163 int dy = (
top.height()-
size.height()) /2;
167 QPoint windowTitlePoint(
top.topLeft().x() + dx,
168 top.topLeft().y() + dy);
169 p.drawStaticText(windowTitlePoint, m_windowTitle);
176 QPen pen(active ? foregroundColor : foregroundInactiveColor);
181 rect = closeButtonRect();
184 QRectF crossRect(crossCenter.x() - crossSize / 2, crossCenter.y() - crossSize / 2, crossSize, crossSize);
187 p.drawLine(crossRect.topLeft(), crossRect.bottomRight());
188 p.drawLine(crossRect.bottomLeft(), crossRect.topRight());
200 p.setBrush(backgroundColor);
214 p.drawLine(
rect.bottomLeft(),
rect.bottomRight());
218bool QWaylandBradientDecoration::clickButton(Qt::MouseButtons
b,
Button btn)
224 if (m_clicking ==
btn) {
242 processPointerTop(inputDevice, local,
b, mods, PointerType::Mouse);
244 processPointerBottom(inputDevice, local,
b, mods, PointerType::Mouse);
246 processPointerLeft(inputDevice, local,
b, mods, PointerType::Mouse);
248 processPointerRight(inputDevice, local,
b, mods, PointerType::Mouse);
269 processPointerTop(inputDevice, local,
Qt::LeftButton, mods, PointerType::Touch);
271 processPointerBottom(inputDevice, local,
Qt::LeftButton, mods, PointerType::Touch);
273 processPointerLeft(inputDevice, local,
Qt::LeftButton, mods, PointerType::Touch);
275 processPointerRight(inputDevice, local,
Qt::LeftButton, mods, PointerType::Touch);
287 Qt::KeyboardModifiers mods,
290#if !QT_CONFIG(cursor)
300 if (
type == PointerType::Mouse)
307 if (
type == PointerType::Mouse)
314 if (
type == PointerType::Mouse)
320 processPointerLeft(inputDevice, local,
b, mods,
type);
322 processPointerRight(inputDevice, local,
b, mods,
type);
325 }
else if (closeButtonRect().
contains(local)) {
326 if (
type == PointerType::Touch || clickButton(
b,
Close))
328 }
else if (maximizeButtonRect().
contains(local)) {
331 }
else if (minimizeButtonRect().
contains(local)) {
336 if (
type == PointerType::Mouse)
343void QWaylandBradientDecoration::processPointerBottom(QWaylandInputDevice *inputDevice,
346 Qt::KeyboardModifiers mods,
350#if !QT_CONFIG(cursor)
358 if (
type == PointerType::Mouse)
365 if (
type == PointerType::Mouse)
372 if (
type == PointerType::Mouse)
379void QWaylandBradientDecoration::processPointerLeft(QWaylandInputDevice *inputDevice,
382 Qt::KeyboardModifiers mods,
388 if (
type == PointerType::Mouse)
396void QWaylandBradientDecoration::processPointerRight(QWaylandInputDevice *inputDevice,
399 Qt::KeyboardModifiers mods,
405 if (
type == PointerType::Mouse)
IOBluetoothDevice * device
The QColor class provides colors based on RGB, HSV or CMYK values.
State
Specifies the state of this event point.
void setPixelSize(int)
Sets the font size to pixelSize pixels, with a maxiumum size of an unsigned 16-bit integer.
The QIcon class provides scalable icons in different modes and states.
void paint(QPainter *painter, const QRect &rect, Qt::Alignment alignment=Qt::AlignCenter, Mode mode=Normal, State state=Off) const
Uses the painter to paint the icon with specified alignment, required mode, and state into the rectan...
bool isNull() const
Returns true if the icon is empty; otherwise returns false.
constexpr int right() const noexcept
Returns the right margin.
void addRoundedRect(const QRectF &rect, qreal xRadius, qreal yRadius, Qt::SizeMode mode=Qt::AbsoluteSize)
The QPainter class performs low-level painting on widgets and other paint devices.
The QPalette class contains color groups for each widget state.
void setWidth(int width)
Sets the pen width to the given width in pixels with integer precision.
\inmodule QtCore\reentrant
constexpr qreal x() const noexcept
Returns the x coordinate of this point.
constexpr qreal y() const noexcept
Returns the y coordinate of this point.
\inmodule QtCore\reentrant
\inmodule QtCore\reentrant
constexpr QRectF adjusted(qreal x1, qreal y1, qreal x2, qreal y2) const noexcept
Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of ...
constexpr qreal left() const noexcept
Returns the x-coordinate of the rectangle's left edge.
\inmodule QtCore\reentrant
constexpr int height() const noexcept
Returns the height of the rectangle.
constexpr int bottom() const noexcept
Returns the y-coordinate of the rectangle's bottom edge.
constexpr QRect marginsRemoved(const QMargins &margins) const noexcept
Removes the margins from the rectangle, shrinking it.
constexpr void setRight(int pos) noexcept
Sets the right edge of the rectangle to the given x coordinate.
constexpr int top() const noexcept
Returns the y-coordinate of the rectangle's top edge.
constexpr void setLeft(int pos) noexcept
Sets the left edge of the rectangle to the given x coordinate.
constexpr int right() const noexcept
Returns the x-coordinate of the rectangle's right edge.
constexpr int width() const noexcept
Returns the width.
The QStaticText class enables optimized drawing of text when the text and its layout is updated rarel...
void setText(const QString &text)
Sets the text of the QStaticText to text.
void prepare(const QTransform &matrix=QTransform(), const QFont &font=QFont())
Prepares the QStaticText object for being painted with the given matrix and the given font to avoid o...
void setTextFormat(Qt::TextFormat textFormat)
Sets the text format of the QStaticText to textFormat.
QSizeF size() const
Returns the size of the bounding rect for this QStaticText.
void setTextOption(const QTextOption &textOption)
Sets the text option structure that controls the layout process to the given textOption.
QString text() const
Returns the text of the QStaticText.
\macro QT_RESTRICTED_CAST_FROM_ASCII
static bool handleCloseEvent(QWindow *window)
bool isRightClicked(Qt::MouseButtons newMouseButtonState)
QWaylandWindow * waylandWindow() const
void startResize(QWaylandInputDevice *inputDevice, Qt::Edges edges, Qt::MouseButtons buttons)
bool isLeftClicked(Qt::MouseButtons newMouseButtonState)
void setMouseButtons(Qt::MouseButtons mb)
void showWindowMenu(QWaylandInputDevice *inputDevice)
bool isLeftReleased(Qt::MouseButtons newMouseButtonState)
void startMove(QWaylandInputDevice *inputDevice, Qt::MouseButtons buttons)
QWaylandAbstractDecoration * create(const QString &, const QStringList &) override
QWaylandBradientDecoration()
void paint(QPaintDevice *device) override
bool handleMouse(QWaylandInputDevice *inputDevice, const QPointF &local, const QPointF &global, Qt::MouseButtons b, Qt::KeyboardModifiers mods) override
bool handleTouch(QWaylandInputDevice *inputDevice, const QPointF &local, const QPointF &global, QEventPoint::State state, Qt::KeyboardModifiers mods) override
QMargins margins(MarginsType marginsType=Full) const override
QString windowTitle() const
QSize surfaceSize() const
Size, with decorations (including including eventual shadows) in wl_surface coordinates.
const QStyleOptionButton * btn
[3]
Combined button and popup list for selecting options.
static bool contains(const QJsonArray &haystack, unsigned needle)
GLboolean GLboolean GLboolean b
GLenum GLuint GLintptr GLsizeiptr size
[1]
GLdouble GLdouble GLdouble GLdouble top
#define BUTTONS_RIGHT_MARGIN
#define QWaylandDecorationFactoryInterface_iid