From 7008c0205104ee883c5e026b4ea9c4096d199ce1 Mon Sep 17 00:00:00 2001 From: Sandro Giessl Date: Sat, 1 Nov 2003 23:58:05 +0000 Subject: [PATCH] Make titlebar buttons only react on left-click, if they have one function only. (Bug #58220) svn path=/trunk/kdeartwork/kwin-styles/plastik/; revision=263816 --- clients/plastik/plastikbutton.cpp | 7 ++++--- clients/plastik/plastikbutton.h | 3 ++- clients/plastik/plastikclient.cpp | 4 ++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/clients/plastik/plastikbutton.cpp b/clients/plastik/plastikbutton.cpp index 05bdfced45..f16fc84ae8 100644 --- a/clients/plastik/plastikbutton.cpp +++ b/clients/plastik/plastikbutton.cpp @@ -54,10 +54,11 @@ static const uint TIMERINTERVAL = 50; // msec static const uint ANIMATIONSTEPS = 4; PlastikButton::PlastikButton(PlastikClient *parent, const char *name, - const QString& tip, ButtonType type, int size) + const QString& tip, ButtonType type, int size, int btns) : QButton(parent->widget(), name), m_client(parent), m_lastMouse(0), + m_realizeButtons(btns), m_size(size), m_type(type), m_aDecoLight(QImage() ), m_iDecoLight(QImage() ), @@ -214,7 +215,7 @@ void PlastikButton::mousePressEvent(QMouseEvent* e) m_lastMouse = e->button(); // pass on event after changing button to LeftButton QMouseEvent me(e->type(), e->pos(), e->globalPos(), - LeftButton, e->state()); + (e->button()&m_realizeButtons)?LeftButton:NoButton, e->state()); QButton::mousePressEvent(&me); } @@ -224,7 +225,7 @@ void PlastikButton::mouseReleaseEvent(QMouseEvent* e) m_lastMouse = e->button(); // pass on event after changing button to LeftButton QMouseEvent me(e->type(), e->pos(), e->globalPos(), - LeftButton, e->state()); + (e->button()&m_realizeButtons)?LeftButton:NoButton, e->state()); QButton::mouseReleaseEvent(&me); } diff --git a/clients/plastik/plastikbutton.h b/clients/plastik/plastikbutton.h index bbcfbd02cb..236c47c74d 100644 --- a/clients/plastik/plastikbutton.h +++ b/clients/plastik/plastikbutton.h @@ -37,7 +37,7 @@ class PlastikButton : public QButton { Q_OBJECT public: - PlastikButton(PlastikClient *parent=0, const char *name=0, const QString &tip=NULL, ButtonType type = HelpButton, int size = 18); + PlastikButton(PlastikClient *parent, const char *name, const QString &tip, ButtonType type, int size, int btns = LeftButton); ~PlastikButton(); void setOnAllDesktops(bool oad) { isOnAllDesktops = oad; repaint(false); } @@ -63,6 +63,7 @@ private: private: PlastikClient *m_client; int m_lastMouse; + int m_realizeButtons; int m_size; diff --git a/clients/plastik/plastikclient.cpp b/clients/plastik/plastikclient.cpp index c85bfbefc3..6f6d721a99 100644 --- a/clients/plastik/plastikclient.cpp +++ b/clients/plastik/plastikclient.cpp @@ -552,7 +552,7 @@ void PlastikClient::addButtons(QBoxLayout *layout, const QString& s, int buttonS switch (s[n]) { case 'M': // Menu button if (!m_button[MenuButton]){ - m_button[MenuButton] = new PlastikButton(this, "menu", i18n("Menu"), MenuButton, buttonSize); + m_button[MenuButton] = new PlastikButton(this, "menu", i18n("Menu"), MenuButton, buttonSize, LeftButton|RightButton); connect(m_button[MenuButton], SIGNAL(pressed()), SLOT(menuButtonPressed())); connect(m_button[MenuButton], SIGNAL(released()), this, SLOT(menuButtonReleased())); layout->addWidget(m_button[MenuButton], 0, Qt::AlignHCenter | Qt::AlignTop); @@ -581,7 +581,7 @@ void PlastikClient::addButtons(QBoxLayout *layout, const QString& s, int buttonS break; case 'A': // Maximize button if ((!m_button[MaxButton]) && isMaximizable()){ - m_button[MaxButton] = new PlastikButton(this, "maximize", i18n("Maximize"), MaxButton, buttonSize); + m_button[MaxButton] = new PlastikButton(this, "maximize", i18n("Maximize"), MaxButton, buttonSize, LeftButton|MidButton|RightButton); connect(m_button[MaxButton], SIGNAL(clicked()), SLOT(slotMaximize())); layout->addWidget(m_button[MaxButton], 0, Qt::AlignHCenter | Qt::AlignTop); }