WABA: Fixed "maximize" with MMB and RMB.

Based on a patch Boudewijn Rempt <boud2@rempt.xs4all.nl>

svn path=/trunk/kdebase/kwin/; revision=69005
This commit is contained in:
Waldo Bastian 2000-10-26 21:56:18 +00:00
parent 8fbc21d202
commit 8f36a1cb5c
4 changed files with 80 additions and 2 deletions

View file

@ -237,6 +237,19 @@ void B2Button::setPixmaps(KPixmap *pix, KPixmap *pixDown, KPixmap *iPix,
repaint(false);
}
void B2Button::mousePressEvent( QMouseEvent* e )
{
last_button = e->button();
QMouseEvent me ( e->type(), e->pos(), e->globalPos(), LeftButton, e->state() );
QButton::mousePressEvent( &me );
}
void B2Button::mouseReleaseEvent( QMouseEvent* e )
{
QMouseEvent me ( e->type(), e->pos(), e->globalPos(), LeftButton, e->state() );
QButton::mouseReleaseEvent( &me );
}
B2Titlebar::B2Titlebar(B2Client *parent)
: QWidget(parent)
{
@ -399,6 +412,21 @@ void B2Titlebar::mouseMoveEvent( QMouseEvent * e )
}
}
void B2Client::maxButtonClicked( )
{
switch ( button[BtnMax]->last_button ) {
case MidButton:
maximize( MaximizeVertical );
break;
case RightButton:
maximize( MaximizeHorizontal );
break;
default: //LeftButton:
maximize( MaximizeFull );
break;
}
}
B2Client::B2Client( Workspace *ws, WId w, QWidget *parent,
const char *name )
: Client( ws, w, parent, name, WResizeNoErase )
@ -482,13 +510,14 @@ B2Client::B2Client( Workspace *ws, WId w, QWidget *parent,
connect(button[BtnMenu], SIGNAL(clicked()), this, SLOT(menuButtonPressed()));
connect(button[BtnSticky], SIGNAL(clicked()), this, SLOT(toggleSticky()));
connect(button[BtnIconify], SIGNAL(clicked()), this, SLOT(iconify()));
connect(button[BtnMax], SIGNAL(clicked()), this, SLOT(maximize()));
connect(button[BtnMax], SIGNAL( clicked() ), this, SLOT( maxButtonClicked()));
connect(button[BtnClose], SIGNAL(clicked()), this, SLOT(closeWindow()));
connect(button[BtnHelp], SIGNAL(clicked()), this, SLOT(contextHelp()));
connect(options, SIGNAL(resetClients()), this, SLOT(slotReset()));
}
void B2Client::resizeEvent( QResizeEvent* e)
{
Client::resizeEvent( e );

View file

@ -12,6 +12,7 @@ class QGridLayout;
class B2Button : public QButton
{
Q_OBJECT
public:
B2Button(Client *_client=0, QWidget *parent=0, const char *name=0)
: QButton(parent, name){useMiniIcon = false; client = _client;}
@ -28,13 +29,21 @@ public:
protected:
virtual void drawButton(QPainter *p);
void drawButtonLabel(QPainter *){;}
bool useMiniIcon;
KPixmap *pNorm, *pDown, *iNorm, *iDown;
QColor bg; //only use one color (the rest is pixmap) so forget QPalette ;)
Client *client;
void mousePressEvent( QMouseEvent* e );
void mouseReleaseEvent( QMouseEvent* e );
public:
int last_button;
};
class B2Client;
class B2Titlebar : public QWidget
{
Q_OBJECT
@ -87,6 +96,7 @@ protected:
private slots:
void menuButtonPressed();
void slotReset();
void maxButtonClicked();
private:
void positionButtons();
enum ButtonType{BtnMenu=0, BtnSticky, BtnIconify, BtnMax, BtnClose,
@ -99,6 +109,7 @@ private:
int bar_x_ofs;
B2Titlebar *titlebar;
int in_unobs;
};

View file

@ -202,6 +202,20 @@ 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() );
QButton::mousePressEvent( &me );
}
void ModernButton::mouseReleaseEvent( QMouseEvent* e )
{
QMouseEvent me ( e->type(), e->pos(), e->globalPos(), LeftButton, e->state() );
QButton::mouseReleaseEvent( &me );
}
void ModernSys::slotReset()
{
if(aUpperGradient){
@ -262,7 +276,7 @@ ModernSys::ModernSys( Workspace *ws, WId w, QWidget *parent,
connect( button[0], SIGNAL( clicked() ), this, ( SLOT( closeWindow() ) ) );
connect( button[1], SIGNAL( clicked() ), this, ( SLOT( toggleSticky() ) ) );
connect( button[2], SIGNAL( clicked() ), this, ( SLOT( iconify() ) ) );
connect( button[3], SIGNAL( clicked() ), this, ( SLOT( maximize() ) ) );
connect( button[3], SIGNAL( clicked() ), this, ( SLOT( maxButtonClicked() ) ) );
QHBoxLayout* hb = new QHBoxLayout(0);
hb->setResizeMode(QLayout::FreeResize);
@ -290,6 +304,23 @@ ModernSys::ModernSys( Workspace *ws, WId w, QWidget *parent,
}
void ModernSys::maxButtonClicked( )
{
switch ( button[3]->last_button ) {
case MidButton:
maximize( MaximizeVertical );
break;
case RightButton:
maximize( MaximizeHorizontal );
break;
default: //LeftButton:
maximize( MaximizeFull );
break;
}
}
void ModernSys::resizeEvent( QResizeEvent* )
{
//Client::resizeEvent( e );

View file

@ -12,6 +12,7 @@ class QSpacerItem;
// get rid of autohide :P
class ModernButton : public QButton
{
Q_OBJECT
public:
ModernButton(Client *parent=0, const char *name=0,
const unsigned char *bitmap=NULL);
@ -19,10 +20,15 @@ public:
void reset();
QSize sizeHint() const;
protected:
void mousePressEvent( QMouseEvent* e );
void mouseReleaseEvent( QMouseEvent* e );
virtual void drawButton(QPainter *p);
void drawButtonLabel(QPainter *){;}
QBitmap deco;
Client *client;
public:
int last_button;
};
class ModernSys : public Client
@ -48,6 +54,7 @@ protected:
MousePosition mousePosition( const QPoint& ) const;
protected slots:
void slotReset();
void maxButtonClicked();
private:
ModernButton* button[5];
QSpacerItem* titlebar;