Make titlebar buttons only react on left-click, if they have one function

only.

CCMAIL: 58220-done@bugs.kde.org

svn path=/trunk/kdebase/kwin/; revision=263874
icc-effect-5.14.5
Sandro Giessl 2003-11-02 11:03:41 +00:00
parent 7008c02051
commit 69f858427e
14 changed files with 226 additions and 204 deletions

View File

@ -355,7 +355,7 @@ void B2Client::addButtons(const QString& s, const QString tips[],
switch (s[i].latin1()) {
case 'M': // Menu button
if (!button[BtnMenu]) {
button[BtnMenu] = new B2Button(this, tb, tips[BtnMenu]);
button[BtnMenu] = new B2Button(this, tb, tips[BtnMenu], LeftButton|RightButton);
button[BtnMenu]->setPixmaps(P_MENU);
button[BtnMenu]->setUseMiniIcon();
connect(button[BtnMenu], SIGNAL(clicked()),
@ -394,7 +394,7 @@ void B2Client::addButtons(const QString& s, const QString tips[],
break;
case 'A': // Maximize button
if (isMaximizable() && (!button[BtnMax])) {
button[BtnMax]= new B2Button(this, tb, tips[BtnMax]);
button[BtnMax]= new B2Button(this, tb, tips[BtnMax], LeftButton|MidButton|RightButton);
button[BtnMax]->setPixmaps(maximizeMode() == MaximizeFull ?
P_NORMALIZE : P_MAX);
connect(button[BtnMax], SIGNAL(clicked()),
@ -1005,10 +1005,11 @@ bool B2Client::eventFilter(QObject *o, QEvent *e)
// =====================================
B2Button::B2Button(B2Client *_client, QWidget *parent, const QString& tip)
B2Button::B2Button(B2Client *_client, QWidget *parent, const QString& tip, const int realizeBtns)
: QButton(parent, 0)
{
setBackgroundMode(NoBackground);
realizeButtons = realizeBtns;
client = _client;
useMiniIcon = false;
setFixedSize(buttonSize, buttonSize);
@ -1081,7 +1082,7 @@ void B2Button::mousePressEvent( QMouseEvent* e )
{
last_button = e->button();
QMouseEvent me(e->type(), e->pos(), e->globalPos(),
LeftButton, e->state());
(e->button()&realizeButtons)?LeftButton:NoButton, e->state());
QButton::mousePressEvent(&me);
}
@ -1089,7 +1090,7 @@ void B2Button::mouseReleaseEvent( QMouseEvent* e )
{
last_button = e->button();
QMouseEvent me(e->type(), e->pos(), e->globalPos(),
LeftButton, e->state());
(e->button()&realizeButtons)?LeftButton:NoButton, e->state());
QButton::mouseReleaseEvent(&me);
}

View File

@ -27,7 +27,7 @@ class B2Client;
class B2Button : public QButton
{
public:
B2Button(B2Client *_client=0, QWidget *parent=0, const QString& tip=NULL);
B2Button(B2Client *_client=0, QWidget *parent=0, const QString& tip=NULL, const int realizeBtns = LeftButton);
~B2Button() {};
void setBg(const QColor &c){bg = c;}
@ -53,6 +53,7 @@ protected:
public:
B2Client* client;
int last_button;
int realizeButtons;
};
class B2Titlebar : public QWidget

View File

@ -515,9 +515,11 @@ QValueList< KDEDefaultHandler::BorderSize > KDEDefaultHandler::borderSizes() con
KDEDefaultButton::KDEDefaultButton(KDEDefaultClient *parent, const char *name,
bool largeButton, bool isLeftButton, bool isStickyButton,
const unsigned char *bitmap, const QString& tip )
const unsigned char *bitmap, const QString& tip, const int realizeBtns )
: QButton(parent->widget(), name)
{
realizeButtons = realizeBtns;
QToolTip::add( this, tip );
setCursor( arrowCursor );
setBackgroundMode( QWidget::NoBackground );
@ -685,7 +687,7 @@ void KDEDefaultButton::mousePressEvent( QMouseEvent* e )
{
last_button = e->button();
QMouseEvent me( e->type(), e->pos(), e->globalPos(),
LeftButton, e->state() );
(e->button()&realizeButtons)?LeftButton:NoButton, e->state() );
QButton::mousePressEvent( &me );
}
@ -694,7 +696,7 @@ void KDEDefaultButton::mouseReleaseEvent( QMouseEvent* e )
{
last_button = e->button();
QMouseEvent me( e->type(), e->pos(), e->globalPos(),
LeftButton, e->state() );
(e->button()&realizeButtons)?LeftButton:NoButton, e->state() );
QButton::mouseReleaseEvent( &me );
}
@ -778,7 +780,7 @@ void KDEDefaultClient::addClientButtons( const QString& s, bool isLeft )
if (!button[BtnMenu])
{
button[BtnMenu] = new KDEDefaultButton(this, "menu",
largeButtons, isLeft, false, NULL, i18n("Menu"));
largeButtons, isLeft, false, NULL, i18n("Menu"), LeftButton|RightButton);
connect( button[BtnMenu], SIGNAL(pressed()),
this, SLOT(menuButtonPressed()) );
connect( button[BtnMenu], SIGNAL(released()),
@ -832,7 +834,7 @@ void KDEDefaultClient::addClientButtons( const QString& s, bool isLeft )
{
button[BtnMax] = new KDEDefaultButton(this, "maximize",
largeButtons, isLeft, true, maximize_bits,
i18n("Maximize"));
i18n("Maximize"), LeftButton|MidButton|RightButton);
connect( button[BtnMax], SIGNAL( clicked()),
this, SLOT(slotMaximize()) );
hb->addWidget( button[BtnMax] );

View File

@ -53,7 +53,7 @@ class KDEDefaultButton : public QButton, public KDecorationDefines
KDEDefaultButton(KDEDefaultClient *parent=0, const char *name=0,
bool largeButton=true, bool isLeftButton=true,
bool isStickyButton=false, const unsigned char *bitmap=NULL,
const QString& tip=NULL);
const QString& tip=NULL, const int realizeBtns = LeftButton);
~KDEDefaultButton();
int last_button;
@ -75,6 +75,8 @@ class KDEDefaultButton : public QButton, public KDecorationDefines
bool isSticky;
bool isMouseOver;
KDEDefaultClient* client;
int realizeButtons;
};

View File

@ -685,10 +685,12 @@ QValueList< KeramikHandler::BorderSize > KeramikHandler::borderSizes() const
KeramikButton::KeramikButton( KeramikClient* c, const char *name, Button btn, const QString &tip )
KeramikButton::KeramikButton( KeramikClient* c, const char *name, Button btn, const QString &tip, const int realizeBtns )
: QButton( c->widget(), name ),
client( c ), button( btn ), hover( false ), lastbutton( 0 )
{
realizeButtons = realizeBtns;
QToolTip::add( this, tip ); // FRAME
setBackgroundMode( NoBackground );
setCursor( arrowCursor );
@ -726,7 +728,7 @@ void KeramikButton::leaveEvent( QEvent *e )
void KeramikButton::mousePressEvent( QMouseEvent *e )
{
lastbutton = e->button();
QMouseEvent me( e->type(), e->pos(), e->globalPos(), LeftButton, e->state() );
QMouseEvent me( e->type(), e->pos(), e->globalPos(), (e->button()&realizeButtons)?LeftButton:NoButton, e->state() );
QButton::mousePressEvent( &me );
}
@ -734,7 +736,7 @@ void KeramikButton::mousePressEvent( QMouseEvent *e )
void KeramikButton::mouseReleaseEvent( QMouseEvent *e )
{
lastbutton = e->button();
QMouseEvent me( e->type(), e->pos(), e->globalPos(), LeftButton, e->state() );
QMouseEvent me( e->type(), e->pos(), e->globalPos(), (e->button()&realizeButtons)?LeftButton:NoButton, e->state() );
QButton::mouseReleaseEvent( &me );
}
@ -945,7 +947,7 @@ void KeramikClient::addButtons( QBoxLayout *layout, const QString &s )
// Menu button
case 'M' :
if ( !button[MenuButton] ) {
button[MenuButton] = new KeramikButton( this, "menu", MenuButton, i18n("Menu") );
button[MenuButton] = new KeramikButton( this, "menu", MenuButton, i18n("Menu"), LeftButton|RightButton );
connect( button[MenuButton], SIGNAL( pressed() ), SLOT( menuButtonPressed() ) );
layout->addWidget( button[MenuButton] );
}
@ -982,7 +984,7 @@ void KeramikClient::addButtons( QBoxLayout *layout, const QString &s )
// Maximize button
case 'A' :
if ( !button[MaxButton] && isMaximizable() ) {
button[MaxButton] = new KeramikButton( this, "maximize", MaxButton, i18n("Maximize") );
button[MaxButton] = new KeramikButton( this, "maximize", MaxButton, i18n("Maximize"), LeftButton|MidButton|RightButton );
connect( button[MaxButton], SIGNAL( clicked() ), SLOT( slotMaximize() ) );
layout->addWidget( button[MaxButton] );
}

View File

@ -113,7 +113,7 @@ namespace Keramik {
class KeramikButton : public QButton
{
public:
KeramikButton( KeramikClient *, const char *, Button, const QString & );
KeramikButton( KeramikClient *, const char *, Button, const QString &, const int realizeBtns = LeftButton );
~KeramikButton();
int lastButton() const { return lastbutton; }
@ -130,6 +130,7 @@ namespace Keramik {
Button button;
bool hover;
int lastbutton;
int realizeButtons;
}; // class KeramikButton

View File

@ -248,9 +248,11 @@ static void delete_pixmaps()
LaptopButton::LaptopButton(int w, int h, LaptopClient *parent,
const char *name, const unsigned char *bitmap,
const QString& tip)
const QString& tip, const int realizeBtns)
: QButton(parent->widget(), name), client(parent)
{
realizeButtons = realizeBtns;
setCursor( arrowCursor );
defaultSize = QSize(w, h);
setFixedHeight(h);
@ -377,7 +379,7 @@ void LaptopClient::init()
button[BtnIconify] = new LaptopButton(btnWidth2, th, this, "iconify",
iconify_bits, i18n("Minimize"));
button[BtnMax] = new LaptopButton(btnWidth2, th, this, "maximize",
maximize_bits, i18n("Maximize"));
maximize_bits, i18n("Maximize"), LeftButton|MidButton|RightButton);
if (help) {
button[BtnHelp] = new LaptopButton(btnWidth1, th, this, "help",
question_bits, i18n("Help"));

View File

@ -25,7 +25,7 @@ class LaptopButton : public QButton
{
public:
LaptopButton(int w, int h, LaptopClient *parent=0, const char *name=0,
const unsigned char *bitmap=NULL, const QString& tip=NULL);
const unsigned char *bitmap=NULL, const QString& tip=NULL, const int realizeBtns = LeftButton);
void setBitmap(const unsigned char *bitmap);
void reset();
QSize sizeHint() const;
@ -35,13 +35,13 @@ protected:
void mousePressEvent( QMouseEvent* e )
{
last_button = e->button();
QMouseEvent me ( e->type(), e->pos(), e->globalPos(), LeftButton, e->state() );
QMouseEvent me ( e->type(), e->pos(), e->globalPos(), (e->button()&realizeButtons)?LeftButton:NoButton, e->state() );
QButton::mousePressEvent( &me );
}
void mouseReleaseEvent( QMouseEvent* e )
{
last_button = e->button();
QMouseEvent me ( e->type(), e->pos(), e->globalPos(), LeftButton, e->state() );
QMouseEvent me ( e->type(), e->pos(), e->globalPos(), (e->button()&realizeButtons)?LeftButton:NoButton, e->state() );
QButton::mouseReleaseEvent( &me );
}
virtual void drawButton(QPainter *p);
@ -49,6 +49,7 @@ protected:
LaptopClient *client;
QSize defaultSize;
QBitmap deco;
int realizeButtons;
};
class LaptopClient : public KDecoration

View File

@ -278,11 +278,12 @@ QValueList< ModernSysFactory::BorderSize > ModernSysFactory::borderSizes() const
}
ModernButton::ModernButton(ModernSys *parent, const char *name,
const unsigned char *bitmap, const QString& tip)
const unsigned char *bitmap, const QString& tip, const int realizeBtns)
: QButton(parent->widget(), name)
{
setBackgroundMode( NoBackground );
setCursor( arrowCursor );
realizeButtons = realizeBtns;
QBitmap mask(14, 15, QPixmap::defaultDepth() > 8 ?
btnhighcolor_mask_bits : lowcolor_mask_bits, true);
resize(14, 15);
@ -332,13 +333,13 @@ void ModernButton::drawButton(QPainter *p)
void ModernButton::mousePressEvent( QMouseEvent* e )
{
last_button = e->button();
QMouseEvent me ( e->type(), e->pos(), e->globalPos(), LeftButton, e->state() );
QMouseEvent me ( e->type(), e->pos(), e->globalPos(), (e->button()&realizeButtons)?LeftButton:NoButton, e->state() );
QButton::mousePressEvent( &me );
}
void ModernButton::mouseReleaseEvent( QMouseEvent* e )
{
QMouseEvent me ( e->type(), e->pos(), e->globalPos(), LeftButton, e->state() );
QMouseEvent me ( e->type(), e->pos(), e->globalPos(), (e->button()&realizeButtons)?LeftButton:NoButton, e->state() );
QButton::mouseReleaseEvent( &me );
}
@ -385,7 +386,7 @@ void ModernSys::init()
button[BtnClose] = new ModernButton(this, "close", close_bits, i18n("Close"));
button[BtnSticky] = new ModernButton(this, "sticky", NULL, i18n("Sticky"));
button[BtnMinimize] = new ModernButton(this, "iconify", iconify_bits, i18n("Minimize"));
button[BtnMaximize] = new ModernButton(this, "maximize", maximize_bits, i18n("Maximize"));
button[BtnMaximize] = new ModernButton(this, "maximize", maximize_bits, i18n("Maximize"), LeftButton|MidButton|RightButton);
button[BtnHelp] = new ModernButton(this, "help", question_bits, i18n("Help"));
connect( button[BtnClose], SIGNAL(clicked()), this, SLOT( closeWindow() ) );

View File

@ -22,7 +22,7 @@ class ModernButton : public QButton
public:
ModernButton( ModernSys *parent=0, const char *name=0,
const unsigned char *bitmap=NULL,
const QString& tip=NULL);
const QString& tip=NULL, const int realizeBtns = LeftButton);
void setBitmap(const unsigned char *bitmap);
void reset();
QSize sizeHint() const;
@ -34,6 +34,8 @@ protected:
void drawButtonLabel(QPainter *){;}
QBitmap deco;
ModernSys* client;
int realizeButtons;
public:
int last_button;
};

View File

@ -335,7 +335,7 @@ QValueList< QuartzHandler::BorderSize > QuartzHandler::borderSizes() const
QuartzButton::QuartzButton(QuartzClient *parent, const char *name, bool largeButton,
bool isLeftButton, bool isOnAllDesktopsButton, const unsigned char *bitmap,
const QString& tip)
const QString& tip, const int realizeBtns)
: QButton(parent->widget(), name)
{
setTipText(tip);
@ -345,6 +345,8 @@ QuartzButton::QuartzButton(QuartzClient *parent, const char *name, bool largeBut
setBackgroundMode( QWidget::NoBackground );
setToggleButton( isOnAllDesktopsButton );
realizeButtons = realizeBtns;
deco = NULL;
large = largeButton;
isLeft = isLeftButton;
@ -469,7 +471,7 @@ void QuartzButton::mousePressEvent( QMouseEvent* e )
{
last_button = e->button();
QMouseEvent me( e->type(), e->pos(), e->globalPos(),
LeftButton, e->state() );
(e->button()&realizeButtons)?LeftButton:NoButton, e->state() );
QButton::mousePressEvent( &me );
}
@ -478,7 +480,7 @@ void QuartzButton::mouseReleaseEvent( QMouseEvent* e )
{
last_button = e->button();
QMouseEvent me( e->type(), e->pos(), e->globalPos(),
LeftButton, e->state() );
(e->button()&realizeButtons)?LeftButton:NoButton, e->state() );
QButton::mouseReleaseEvent( &me );
}
@ -578,7 +580,7 @@ void QuartzClient::addClientButtons( const QString& s, bool isLeft )
if (!button[BtnMenu])
{
button[BtnMenu] = new QuartzButton(this, "menu",
largeButtons, isLeft, false, NULL, i18n("Menu"));
largeButtons, isLeft, false, NULL, i18n("Menu"), LeftButton|RightButton);
connect( button[BtnMenu], SIGNAL(pressed()),
this, SLOT(menuButtonPressed()) );
hb->addWidget( button[BtnMenu] );
@ -629,7 +631,7 @@ void QuartzClient::addClientButtons( const QString& s, bool isLeft )
if ( (!button[BtnMax]) && isMaximizable())
{
button[BtnMax] = new QuartzButton(this, "maximize",
largeButtons, isLeft, true, maximize_bits, i18n("Maximize"));
largeButtons, isLeft, true, maximize_bits, i18n("Maximize"), LeftButton|MidButton|RightButton);
connect( button[BtnMax], SIGNAL( clicked()),
this, SLOT(slotMaximize()) );
hb->addWidget( button[BtnMax] );

View File

@ -54,7 +54,7 @@ class QuartzButton : public QButton
public:
QuartzButton(QuartzClient *parent=0, const char *name=0, bool largeButton=true,
bool isLeftButton=true, bool isOnAllDesktopsButton=false,
const unsigned char *bitmap=NULL, const QString& tip=NULL);
const unsigned char *bitmap=NULL, const QString& tip=NULL, const int realizeBtns = LeftButton);
~QuartzButton();
void setBitmap(const unsigned char *bitmap);
void setTipText(const QString &tip);
@ -73,6 +73,8 @@ class QuartzButton : public QButton
bool isLeft;
bool isOnAllDesktops;
QuartzClient* client;
int realizeButtons;
};

View File

@ -236,7 +236,7 @@ void delete_pixmaps()
RedmondButton::RedmondButton(RedmondDeco *parent, const char *name,
const unsigned char *bitmap, bool menuButton, bool isMini, int size, const QString& tip)
const unsigned char *bitmap, bool menuButton, bool isMini, int size, const QString& tip, const int realizeBtns)
: QButton(parent->widget(), name)
{
// Eliminate background flicker
@ -247,6 +247,7 @@ RedmondButton::RedmondButton(RedmondDeco *parent, const char *name,
miniBtn = isMini;
client = parent;
this->size = size;
realizeButtons = realizeBtns;
// Use larger button for the menu, or mini-buttons for toolwindows.
if ( isMini || menuButton ) {
@ -307,7 +308,7 @@ void RedmondButton::mousePressEvent( QMouseEvent* e )
{
last_button = e->button();
QMouseEvent me(e->type(), e->pos(), e->globalPos(),
LeftButton, e->state());
(e->button()&realizeButtons)?LeftButton:NoButton, e->state());
QButton::mousePressEvent( &me );
}
@ -316,7 +317,7 @@ void RedmondButton::mouseReleaseEvent( QMouseEvent* e )
{
last_button = e->button();
QMouseEvent me ( e->type(), e->pos(), e->globalPos(),
LeftButton, e->state() );
(e->button()&realizeButtons)?LeftButton:NoButton, e->state() );
QButton::mouseReleaseEvent( &me );
}
@ -402,10 +403,10 @@ void RedmondDeco::init()
g->addColSpacing(0, borderWidth);
g->addColSpacing(2, borderWidth);
button[BtnMenu] = new RedmondButton(this, "menu", NULL, true, smallButtons, titleHeight-2, i18n("Menu"));
button[BtnMenu] = new RedmondButton(this, "menu", NULL, true, smallButtons, titleHeight-2, i18n("Menu"), LeftButton|RightButton);
button[BtnClose] = new RedmondButton(this, "close", close_bits, false, smallButtons, titleHeight-2, i18n("Close"));
button[BtnMin] = new RedmondButton(this, "iconify", iconify_bits, false, smallButtons, titleHeight-2, i18n("Minimize"));
button[BtnMax] = new RedmondButton(this, "maximize", maximize_bits, false, smallButtons, titleHeight-2, i18n("Maximize"));
button[BtnMax] = new RedmondButton(this, "maximize", maximize_bits, false, smallButtons, titleHeight-2, i18n("Maximize"), LeftButton|MidButton|RightButton);
// Connect required stuff together
connect(button[BtnMenu], SIGNAL(pressed()), this, SLOT(menuButtonPressed()));

View File

@ -41,7 +41,7 @@ public:
RedmondButton(RedmondDeco *parent=0, const char *name=0,
const unsigned char *bitmap=NULL,
bool menuButton=false, bool isMini=false, int size = 16,
const QString& tip=NULL);
const QString& tip=NULL, const int realizeBtns = LeftButton);
void setBitmap(const unsigned char *bitmap);
void setPixmap(const QPixmap &p);
void reset();
@ -61,6 +61,8 @@ protected:
bool miniBtn;
RedmondDeco *client;
int size;
int realizeButtons;
};