summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiulio Camuffo <giulio.camuffo@jollamobile.com>2015-04-24 20:51:14 +0300
committerGiulio Camuffo <giulio.camuffo@jollamobile.com>2015-06-09 08:23:11 +0000
commitb350b3112c549fe75a54880bf5e58bb274eb874d (patch)
tree61eef3deb6387a86863660ca41568cc4ac7341e7
parent8d691291a77ff0d3d24f3c8858c91c4daa805984 (diff)
downloadqtwayland-b350b3112c549fe75a54880bf5e58bb274eb874d.tar.gz
bradient: Activate the decoration's buttons on mouse release, not press
Change-Id: I5a161119b20301a405bdde9bbea6bfbdcc4b9fa0 Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@gmail.com> Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
-rw-r--r--src/plugins/decorations/bradient/main.cpp42
1 files changed, 36 insertions, 6 deletions
diff --git a/src/plugins/decorations/bradient/main.cpp b/src/plugins/decorations/bradient/main.cpp
index 00a91e24..ea298699 100644
--- a/src/plugins/decorations/bradient/main.cpp
+++ b/src/plugins/decorations/bradient/main.cpp
@@ -116,6 +116,14 @@ static const char * const qt_normalizeup_xpm[] = {
# define BUTTON_WIDTH 22
#endif
+enum Button
+{
+ None,
+ Close,
+ Maximize,
+ Minimize
+};
+
class Q_WAYLAND_CLIENT_EXPORT QWaylandBradientDecoration : public QWaylandAbstractDecoration
{
public:
@@ -130,6 +138,7 @@ private:
void processMouseBottom(QWaylandInputDevice *inputDevice, const QPointF &local, Qt::MouseButtons b,Qt::KeyboardModifiers mods);
void processMouseLeft(QWaylandInputDevice *inputDevice, const QPointF &local, Qt::MouseButtons b,Qt::KeyboardModifiers mods);
void processMouseRight(QWaylandInputDevice *inputDevice, const QPointF &local, Qt::MouseButtons b,Qt::KeyboardModifiers mods);
+ bool clickButton(Qt::MouseButtons b, Button btn);
QRectF closeButtonRect() const;
QRectF maximizeButtonRect() const;
@@ -138,12 +147,14 @@ private:
QColor m_foregroundColor;
QColor m_backgroundColor;
QStaticText m_windowTitle;
+ Button m_clicking;
};
QWaylandBradientDecoration::QWaylandBradientDecoration()
: QWaylandAbstractDecoration()
+ , m_clicking(None)
{
QPalette palette;
m_foregroundColor = palette.color(QPalette::Active, QPalette::HighlightedText);
@@ -315,18 +326,37 @@ void QWaylandBradientDecoration::paint(QPaintDevice *device)
#endif
}
+bool QWaylandBradientDecoration::clickButton(Qt::MouseButtons b, Button btn)
+{
+ if (isLeftClicked(b)) {
+ m_clicking = btn;
+ return false;
+ } else if (isLeftReleased(b)) {
+ if (m_clicking == btn) {
+ m_clicking = None;
+ return true;
+ } else {
+ m_clicking = None;
+ }
+ }
+ return false;
+}
+
bool QWaylandBradientDecoration::handleMouse(QWaylandInputDevice *inputDevice, const QPointF &local, const QPointF &global, Qt::MouseButtons b, Qt::KeyboardModifiers mods)
{
Q_UNUSED(global);
// Figure out what area mouse is in
- if (closeButtonRect().contains(local) && isLeftClicked(b)) {
- QWindowSystemInterface::handleCloseEvent(window());
- } else if (maximizeButtonRect().contains(local) && isLeftClicked(b)) {
- window()->setWindowState(waylandWindow()->isMaximized() ? Qt::WindowNoState : Qt::WindowMaximized);
- } else if (minimizeButtonRect().contains(local) && isLeftClicked(b)) {
- window()->setWindowState(Qt::WindowMinimized);
+ if (closeButtonRect().contains(local)) {
+ if (clickButton(b, Close))
+ QWindowSystemInterface::handleCloseEvent(window());
+ } else if (maximizeButtonRect().contains(local)) {
+ if (clickButton(b, Maximize))
+ window()->setWindowState(waylandWindow()->isMaximized() ? Qt::WindowNoState : Qt::WindowMaximized);
+ } else if (minimizeButtonRect().contains(local)) {
+ if (clickButton(b, Minimize))
+ window()->setWindowState(Qt::WindowMinimized);
} else if (local.y() <= margins().top()) {
processMouseTop(inputDevice,local,b,mods);
} else if (local.y() > window()->height() - margins().bottom() + margins().top()) {