some work on the new default style. Better, but not there yet.

The class still duplicates too much functionality of the base class (Client).
IMO the ResizeBar widgets have to go, it can all be done by painting directly
on the main Manager.

svn path=/trunk/kdebase/kwin/; revision=59127
This commit is contained in:
Matthias Ettrich 2000-07-28 22:06:22 +00:00
parent e87c06989b
commit d7d265452b
12 changed files with 72 additions and 104 deletions

View file

@ -1139,6 +1139,14 @@ void Client::resizeEvent( QResizeEvent * e)
}
void Client::giveUpShade()
{
wwrap->show();
workspace()->requestFocus( this );
shaded = FALSE;
}
/*!
Reimplemented to provide move/resize
*/
@ -1169,11 +1177,8 @@ void Client::mouseMoveEvent( QMouseEvent * e)
return;
}
if ( mode != Center && shaded ) {
wwrap->show();
workspace()->requestFocus( this );
shaded = FALSE;
}
if ( mode != Center && shaded )
giveUpShade();
QPoint globalPos = e->globalPos(); // pos() + geometry().topLeft();

View file

@ -110,6 +110,7 @@ public:
bool isShade() const;
virtual void setShade( bool );
void giveUpShade();
bool isMaximized() const;
enum MaximizeMode { MaximizeVertical, MaximizeHorizontal, MaximizeFull, MaximizeRestore };

View file

@ -433,7 +433,7 @@ StdToolClient::StdToolClient( Workspace *ws, WId w, QWidget *parent, const char
g->addColSpacing(0, 1);
g->addColSpacing(2, 1);
g->addRowSpacing(2, 2);
g->addRowoSpacing(2, 2);
closeBtn = new QToolButton( this );
connect( closeBtn, SIGNAL( clicked() ), this, ( SLOT( closeWindow() ) ) );

View file

@ -1,6 +1,6 @@
/*
Default KWin client
Copyright 2000
Rik Hemsley <rik@kde.org>
@ -26,11 +26,9 @@ namespace Default
{
DBWidget::DBWidget(QWidget * parent, const char * name)
: QWidget(parent, name, WResizeNoErase | WRepaintNoErase | WPaintUnclipped |
WNorthWestGravity)
: QWidget(parent, name, WResizeNoErase | WRepaintNoErase | WPaintUnclipped | WNorthWestGravity)
{
buf_.resize(20, 20);
setBackgroundMode(NoBackground);
}
void

View file

@ -1,6 +1,6 @@
/*
Default KWin client
Copyright 2000
Rik Hemsley <rik@kde.org>
@ -50,14 +50,24 @@ Manager::Manager(
)
: Client(workSpace, id, parent, name)
{
shaded_ = false;
connect(options, SIGNAL(resetClients()), this, SLOT(slotReset()));
titleBar_ = new TitleBar(this);
titleBar_->setFixedHeight( Static::instance()->titleHeight() );
resizeBar_ = new ResizeBar(this, this);
resizeBar_->setFixedHeight( RESIZE_BAR_HEIGHT );
activateLayout();
QVBoxLayout* vbox = new QVBoxLayout( this );
vbox->addWidget( titleBar_ );
QHBoxLayout* hbox = new QHBoxLayout;
vbox->addLayout( hbox, 10 );
hbox->addSpacing( 3 );
hbox->addWidget( windowWrapper(), 10 );
hbox->addSpacing( 3 );
vbox->addWidget( resizeBar_ );
_updateDisplay();
}
Manager::~Manager()
@ -68,9 +78,10 @@ Manager::~Manager()
Manager::slotReset()
{
Static::instance()->update();
titleBar_->setFixedHeight( Static::instance()->titleHeight() );
_updateDisplay();
}
void
Manager::captionChange(const QString &)
{
@ -86,7 +97,7 @@ Manager::stickyChange(bool b)
void
Manager::paletteChange(const QPalette &)
{
Static::instance()->update();
Static::instance()->update();
_updateDisplay();
}
@ -133,12 +144,6 @@ Manager::paintEvent(QPaintEvent * e)
}
}
void
Manager::toggleSticky()
{
setSticky(!isSticky());
}
void
Manager::raise()
{
@ -155,69 +160,18 @@ Manager::vMax()
Manager::resizeEvent(QResizeEvent * e)
{
Client::resizeEvent(e);
_updateLayout();
}
void
Manager::_updateLayout()
{
titleBar_ -> setGeometry(
0,
0,
width(),
Static::instance()->titleHeight()
);
windowWrapper() -> setGeometry(
3,
Static::instance()->titleHeight(),
width() - 6,
height() - Static::instance()->titleHeight() - RESIZE_BAR_HEIGHT
);
resizeBar_ -> setGeometry(
0,
height() - RESIZE_BAR_HEIGHT,
width(),
RESIZE_BAR_HEIGHT
);
_updateDisplay();
}
void
Manager::activateLayout()
{
_updateLayout();
}
void
Manager::fakeMouseEvent(QMouseEvent * e, QWidget * w)
{
QPoint adjustedPos = w->pos() + e->pos();
if (e->type() == QEvent::MouseButtonDblClick)
toggleShaded();
QMouseEvent fake(e->type(), adjustedPos, e->button(), e->state());
Client::event(&fake);
}
void
Manager::toggleShaded()
{
if (shaded_)
resize(oldSize_);
else {
oldSize_ = size();
resize(width(), Static::instance()->titleHeight() + RESIZE_BAR_HEIGHT);
}
_updateLayout();
shaded_ = !shaded_;
}
} // End namespace

View file

@ -1,6 +1,6 @@
/*
Default KWin client
Copyright 2000
Rik Hemsley <rik@kde.org>
@ -49,7 +49,6 @@ class Manager : public Client
public slots:
void toggleSticky();
void raise();
void vMax();
@ -60,9 +59,7 @@ class Manager : public Client
void maximizeChange(bool);
void paintEvent(QPaintEvent *);
void resizeEvent(QResizeEvent *);
void activateLayout();
void toggleShaded();
protected slots:
void captionChange(const QString &);
@ -72,13 +69,10 @@ class Manager : public Client
private:
void _updateDisplay();
void _updateLayout();
TitleBar * titleBar_;
ResizeBar * resizeBar_;
bool shaded_;
QSize oldSize_;
};
class ToolManager : public Manager

View file

@ -1,6 +1,6 @@
/*
Default KWin client
Copyright 2000
Rik Hemsley <rik@kde.org>
@ -30,18 +30,17 @@ namespace Default
{
ResizeBar::ResizeBar(QWidget * parent, Manager * client)
: QWidget (parent, "ResizeBar"),
: QWidget (parent, "ResizeBar", WResizeNoErase | WRepaintNoErase),
client_ (client)
{
setBackgroundMode(NoBackground);
left_ = new ResizeSide(this, client_, ResizeSide::Left);
mid_ = new ResizeMid(this, client_);
right_ = new ResizeSide(this, client_, ResizeSide::Right);
mid_->move(30, 0);
}
void
ResizeBar::updateDisplay()
{

View file

@ -1,6 +1,6 @@
/*
Default KWin client
Copyright 2000
Rik Hemsley <rik@kde.org>
@ -71,11 +71,12 @@ ResizeMid::mouseMoveEvent(QMouseEvent * e)
QRect g = client_->geometry();
g.setBottom(e->globalPos().y());
if ( client_->isShade() )
client_->giveUpShade();
QSize adjustedSize = client_->adjustedSize(g.size());
if (adjustedSize != client_->size()) {
g.setBottom(g.top() + adjustedSize.height());
client_->setGeometry(g);
client_->resize( adjustedSize );
}
}

View file

@ -1,6 +1,6 @@
/*
Default KWin client
Copyright 2000
Rik Hemsley <rik@kde.org>
@ -44,6 +44,8 @@ ResizeSide::ResizeSide(QWidget * parent, Manager * client, Side s)
void
ResizeSide::mouseMoveEvent(QMouseEvent * e)
{
if ( client_->isShade() )
client_->giveUpShade();
QRect g = client_->geometry();
g.setBottom(e->globalPos().y());
if (side_ == Left)
@ -51,16 +53,16 @@ ResizeSide::mouseMoveEvent(QMouseEvent * e)
else
g.setRight(e->globalPos().x());
QSize adjustedSize = client_->adjustedSize(g.size());
QSize adjustedSize = client_->adjustedSize(g.size());
if (adjustedSize != client_->size()) {
if (side_ == Left)
g.setLeft(g.right() - adjustedSize.width());
g.setLeft(g.right() - adjustedSize.width() + 1);
else
g.setRight(g.left() + adjustedSize.width());
g.setRight(g.left() + adjustedSize.width() - 1);
g.setBottom(g.top() + adjustedSize.height());
g.setBottom(g.top() + adjustedSize.height() - 1);
client_->setGeometry(g);
}

View file

@ -1,6 +1,6 @@
/*
Default KWin client
Copyright 2000
Rik Hemsley <rik@kde.org>
@ -107,8 +107,16 @@ TitleBar::TitleBar(Manager * client)
question_, SIGNAL(contextHelp()),
client, SLOT(contextHelp())
);
if ( client->isTransient() ) {
// lighter decoration for transient windows
sticky_->hide();
iconify_->hide();
maximise_->hide();
}
}
void
TitleBar::updateDisplay()
{
@ -139,13 +147,16 @@ TitleBar::resizeEvent(QResizeEvent *)
if (width() < 120) sizeProblem = 3;
else if (width() < 160) sizeProblem = 2;
else if (width() < 200) sizeProblem = 1;
bool transient = ( (Client*) parentWidget() )->isTransient();
switch (sizeProblem) {
case 1:
close_ ->show();
sticky_ ->hide();
iconify_ ->show();
if ( !transient )
iconify_ ->show();
if (0 != question_)
question_ ->hide();
maximise_ ->hide();
@ -174,9 +185,11 @@ TitleBar::resizeEvent(QResizeEvent *)
close_ ->show();
if (0 != question_)
question_->show();
sticky_ ->show();
iconify_ ->show();
maximise_ ->show();
if ( !transient ) {
sticky_ ->show();
iconify_ ->show();
maximise_ ->show();
}
break;
}
}

View file

@ -1,6 +1,6 @@
/*
Default KWin client
Copyright 2000
Rik Hemsley <rik@kde.org>
@ -56,7 +56,7 @@ TitleText::updatePixmap()
QPainter p(&buf());
Static * s = Static::instance();
p.drawPixmap(0, 0, s->titleLeft(active_));
p.drawPixmap(width() - 2, 0, s->titleRight(active_));
p.drawTiledPixmap(2, 0, width() - 2, height(), s->title(active_));
@ -96,7 +96,7 @@ TitleText::mouseMoveEvent(QMouseEvent * e)
}
void
TitleText::mouseDoubleClickEvent(QMouseEvent * e)
TitleText::mouseDoubleClickEvent(QMouseEvent * )
{
client_->workspace()->performWindowOperation(
client_,

View file

@ -2130,10 +2130,11 @@ void Workspace::clientPopupAboutToShow()
if ( !popup_client || !popup )
return;
popup->setItemEnabled( Options::ResizeOp, popup_client->isResizable() );
popup->setItemEnabled( Options::MaximizeOp, popup_client->isResizable() );
popup->setItemEnabled( Options::MaximizeOp, popup_client->isResizable() && !popup_client->isTransient() );
popup->setItemChecked( Options::MaximizeOp, popup_client->isMaximized() );
popup->setItemChecked( Options::ShadeOp, popup_client->isShade() );
popup->setItemChecked( Options::StaysOnTopOp, popup_client->staysOnTop() );
popup->setItemEnabled( Options::IconifyOp, !popup_client->isTransient() );
}