- make maximized windows
- adjust to workarea changes - not movable or resizable - not show vertical borders if not necessary - new default style: middle mouse and right mouse for maximize button - now resize mouse cursors if the window is not resizable svn path=/trunk/kdebase/kwin/; revision=61240
This commit is contained in:
parent
49bb12bd95
commit
078b8b3ff4
5 changed files with 100 additions and 24 deletions
81
client.cpp
81
client.cpp
|
@ -492,7 +492,7 @@ bool Client::manage( bool isMapped, bool doNotShow )
|
|||
|
||||
if ( isMapped || session || isTransient() ) {
|
||||
placementDone = TRUE;
|
||||
if ( geom == QApplication::desktop()->geometry() )
|
||||
if ( geom == workspace()->geometry() )
|
||||
may_move = FALSE; // don't let fullscreen windows be moved around
|
||||
} else {
|
||||
QRect area = workspace()->clientArea();
|
||||
|
@ -1105,6 +1105,16 @@ bool Client::isResizable() const
|
|||
( xSizeHint.min_height != xSizeHint.max_height );
|
||||
}
|
||||
|
||||
/*
|
||||
Returns whether the window is maximizable or not
|
||||
*/
|
||||
bool Client::isMaximizable() const
|
||||
{
|
||||
if ( isMaximized() )
|
||||
return TRUE;
|
||||
return isResizable() && !isTransient();
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
Reimplemented to provide move/resize
|
||||
|
@ -1208,6 +1218,11 @@ void Client::mouseMoveEvent( QMouseEvent * e)
|
|||
QPoint p( e->pos() - moveOffset );
|
||||
if (p.manhattanLength() >= 6) {
|
||||
moveResizeMode = TRUE;
|
||||
if ( isMaximized() ) {
|
||||
// in case we were maximized, reset state
|
||||
geom_restore = QRect();
|
||||
maximizeChange(FALSE );
|
||||
}
|
||||
workspace()->setFocusChangeEnabled(false);
|
||||
Events::raise( isResize() ? Events::ResizeStart : Events::MoveStart );
|
||||
grabMouse( cursor() ); // to keep the right cursor
|
||||
|
@ -1534,20 +1549,24 @@ void Client::killWindow()
|
|||
|
||||
void Client::maximize( MaximizeMode m)
|
||||
{
|
||||
if (!isMovable() || !isResizable() )
|
||||
return;
|
||||
if ( !isMaximizable() )
|
||||
return;
|
||||
|
||||
QRect clientArea = workspace()->clientArea();
|
||||
|
||||
if (isShade())
|
||||
setShade( FALSE );
|
||||
|
||||
if ( !geom_restore.isNull() )
|
||||
m = MaximizeRestore;
|
||||
if ( m == MaximizeAdjust ) {
|
||||
m = max_mode;
|
||||
} else {
|
||||
if ( !geom_restore.isNull() )
|
||||
m = MaximizeRestore;
|
||||
|
||||
if ( m != MaximizeRestore ) {
|
||||
Events::raise( Events::Maximize );
|
||||
geom_restore = geometry();
|
||||
if ( m != MaximizeRestore ) {
|
||||
Events::raise( Events::Maximize );
|
||||
geom_restore = geometry();
|
||||
}
|
||||
}
|
||||
|
||||
switch (m) {
|
||||
|
@ -1573,19 +1592,28 @@ void Client::maximize( MaximizeMode m)
|
|||
case MaximizeRestore: {
|
||||
Events::raise( Events::UnMaximize );
|
||||
setGeometry(geom_restore);
|
||||
QRect invalid;
|
||||
geom_restore = invalid;
|
||||
geom_restore = QRect();
|
||||
info->setState( 0, NET::Max );
|
||||
} break;
|
||||
|
||||
case MaximizeFull:
|
||||
|
||||
setGeometry(
|
||||
QRect(clientArea.topLeft(), adjustedSize(clientArea.size()))
|
||||
);
|
||||
case MaximizeFull: {
|
||||
QRect r = QRect(clientArea.topLeft(), adjustedSize(clientArea.size()));
|
||||
|
||||
// hide right and left border of maximized windows
|
||||
if ( r.left() == 0 )
|
||||
r.setLeft( r.left() - windowWrapper()->x() );
|
||||
if ( r.right() == workspace()->geometry().right() )
|
||||
r.setRight( r.right() + width() - windowWrapper()->geometry().right() );
|
||||
setGeometry( r );
|
||||
|
||||
info->setState( NET::Max, NET::Max );
|
||||
} break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
max_mode = m;
|
||||
|
||||
maximizeChange( m != MaximizeRestore );
|
||||
}
|
||||
|
||||
|
@ -1703,7 +1731,7 @@ bool Client::x11Event( XEvent * e)
|
|||
workspace()->requestFocus( this );
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
if ( e->type == LeaveNotify && e->xcrossing.mode == NotifyNormal ) {
|
||||
if ( !buttonDown )
|
||||
setCursor( arrowCursor );
|
||||
|
@ -1717,7 +1745,7 @@ bool Client::x11Event( XEvent * e)
|
|||
workspace()->requestFocus( 0 ) ;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -1767,6 +1795,11 @@ Client::MousePosition Client::mousePosition( const QPoint& p ) const
|
|||
*/
|
||||
void Client::setMouseCursor( MousePosition m )
|
||||
{
|
||||
if ( !isResizable() ) {
|
||||
setCursor( arrowCursor );
|
||||
return;
|
||||
}
|
||||
|
||||
switch ( m ) {
|
||||
case TopLeft:
|
||||
case BottomRight:
|
||||
|
@ -2082,6 +2115,11 @@ bool Client::performMouseCommand( Options::MouseCommand command, QPoint globalPo
|
|||
break;
|
||||
mode = Center;
|
||||
moveResizeMode = TRUE;
|
||||
if ( isMaximized() ) {
|
||||
// in case we were maximized, reset state
|
||||
geom_restore = QRect();
|
||||
maximizeChange(FALSE );
|
||||
}
|
||||
workspace()->setFocusChangeEnabled(false);
|
||||
buttonDown = TRUE;
|
||||
moveOffset = mapFromGlobal( globalPos );
|
||||
|
@ -2095,6 +2133,11 @@ bool Client::performMouseCommand( Options::MouseCommand command, QPoint globalPo
|
|||
if (!isMovable())
|
||||
break;
|
||||
moveResizeMode = TRUE;
|
||||
if ( isMaximized() ) {
|
||||
// in case we were maximized, reset state
|
||||
geom_restore = QRect();
|
||||
maximizeChange(FALSE );
|
||||
}
|
||||
workspace()->setFocusChangeEnabled(false);
|
||||
buttonDown = TRUE;
|
||||
moveOffset = mapFromGlobal( globalPos );
|
||||
|
@ -2303,7 +2346,9 @@ bool Client::wantsTabFocus() const
|
|||
*/
|
||||
bool Client::isMovable() const
|
||||
{
|
||||
return may_move && ( windowType() == NET::Normal || windowType() == NET::Toolbar );
|
||||
return may_move &&
|
||||
( windowType() == NET::Normal || windowType() == NET::Toolbar ) &&
|
||||
( !isMaximized() || max_mode != MaximizeFull );
|
||||
}
|
||||
|
||||
bool Client::isDesktop() const
|
||||
|
|
5
client.h
5
client.h
|
@ -113,7 +113,8 @@ public:
|
|||
void giveUpShade();
|
||||
|
||||
bool isMaximized() const;
|
||||
enum MaximizeMode { MaximizeVertical, MaximizeHorizontal, MaximizeFull, MaximizeRestore };
|
||||
enum MaximizeMode { MaximizeVertical, MaximizeHorizontal, MaximizeFull, MaximizeRestore, MaximizeAdjust };
|
||||
bool isMaximizable() const;
|
||||
|
||||
bool isSticky() const;
|
||||
void setSticky( bool );
|
||||
|
@ -264,6 +265,7 @@ private:
|
|||
QPixmap icon_pix;
|
||||
QPixmap miniicon_pix;
|
||||
QRect geom_restore;
|
||||
MaximizeMode max_mode;
|
||||
QRegion mask;
|
||||
WinInfo* info;
|
||||
QTimer* autoRaiseTimer;
|
||||
|
@ -364,7 +366,6 @@ inline bool Client::shape() const
|
|||
return is_shape;
|
||||
}
|
||||
|
||||
|
||||
inline const QRegion& Client::getMask() const
|
||||
{
|
||||
return mask;
|
||||
|
|
|
@ -342,7 +342,7 @@ KDEClient::KDEClient( Workspace *ws, WId w, QWidget *parent,
|
|||
connect( button[BtnClose], SIGNAL( clicked() ), this, ( SLOT( closeWindow() ) ) );
|
||||
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( slotMaximize() ) ) );
|
||||
|
||||
hb = new QHBoxLayout();
|
||||
hb->setResizeMode(QLayout::FreeResize);
|
||||
|
@ -359,7 +359,7 @@ KDEClient::KDEClient( Workspace *ws, WId w, QWidget *parent,
|
|||
hb->addWidget( button[BtnSticky]);
|
||||
hb->addWidget( button[BtnIconify]);
|
||||
hb->addWidget( button[BtnMax]);
|
||||
|
||||
|
||||
if ( isTransient() ) {
|
||||
button[BtnSticky]->hide();
|
||||
button[BtnIconify]->hide();
|
||||
|
@ -369,6 +369,16 @@ KDEClient::KDEClient( Workspace *ws, WId w, QWidget *parent,
|
|||
hiddenItems = false;
|
||||
}
|
||||
|
||||
void KDEClient::slotMaximize()
|
||||
{
|
||||
if ( button[BtnMax]->last_button == MidButton )
|
||||
maximize( MaximizeVertical );
|
||||
else if ( button[BtnMax]->last_button == RightButton )
|
||||
maximize( MaximizeHorizontal );
|
||||
else
|
||||
maximize();
|
||||
}
|
||||
|
||||
void KDEClient::resizeEvent( QResizeEvent* e)
|
||||
{
|
||||
Client::resizeEvent( e );
|
||||
|
|
|
@ -19,7 +19,21 @@ public:
|
|||
void setBitmap(const unsigned char *bitmap);
|
||||
void reset();
|
||||
QSize sizeHint() const;
|
||||
int last_button;
|
||||
|
||||
protected:
|
||||
void mousePressEvent( QMouseEvent* e )
|
||||
{
|
||||
last_button = e->button();
|
||||
QMouseEvent me ( e->type(), e->pos(), e->globalPos(), LeftButton, e->state() );
|
||||
QButton::mousePressEvent( &me );
|
||||
}
|
||||
void mouseReleaseEvent( QMouseEvent* e )
|
||||
{
|
||||
last_button = e->button();
|
||||
QMouseEvent me ( e->type(), e->pos(), e->globalPos(), LeftButton, e->state() );
|
||||
QButton::mouseReleaseEvent( &me );
|
||||
}
|
||||
virtual void drawButton(QPainter *p);
|
||||
void drawButtonLabel(QPainter *){;}
|
||||
QSize defaultSize;
|
||||
|
@ -51,13 +65,14 @@ protected:
|
|||
void updateActiveBuffer();
|
||||
protected slots:
|
||||
void slotReset();
|
||||
void slotMaximize();
|
||||
private:
|
||||
SystemButton* button[5];
|
||||
QSpacerItem* titlebar;
|
||||
bool hiddenItems;
|
||||
QHBoxLayout *hb;
|
||||
KPixmap activeBuffer;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -2158,7 +2158,7 @@ void Workspace::clientPopupAboutToShow()
|
|||
return;
|
||||
popup->setItemEnabled( Options::ResizeOp, popup_client->isResizable() );
|
||||
popup->setItemEnabled( Options::MoveOp, popup_client->isMovable() );
|
||||
popup->setItemEnabled( Options::MaximizeOp, popup_client->isResizable() && !popup_client->isTransient() );
|
||||
popup->setItemEnabled( Options::MaximizeOp, popup_client->isMaximizable() );
|
||||
popup->setItemChecked( Options::MaximizeOp, popup_client->isMaximized() );
|
||||
popup->setItemChecked( Options::ShadeOp, popup_client->isShade() );
|
||||
popup->setItemChecked( Options::StaysOnTopOp, popup_client->staysOnTop() );
|
||||
|
@ -2700,6 +2700,11 @@ void Workspace::updateClientArea()
|
|||
r.size.height = area.height();
|
||||
for( int i = 1; i <= numberOfDesktops(); i++)
|
||||
rootInfo->setWorkArea( i, r );
|
||||
|
||||
for ( ClientList::ConstIterator it = clients.begin(); it != clients.end(); ++it) {
|
||||
if ( (*it)->isMaximized() )
|
||||
(*it)->maximize( Client::MaximizeAdjust );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue