From 07b08d5d9964589bbfb70a966fe1073607b0cc8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Mon, 10 Nov 2003 18:08:04 +0000 Subject: [PATCH] Don't use struts if KWin itself restricts workarea size by topmenus. svn path=/trunk/kdebase/kwin/; revision=266150 --- client.h | 6 ++++++ geometry.cpp | 17 +++++------------ workspace.cpp | 44 ++++++++++++++++++++++++++++++++++---------- workspace.h | 2 ++ 4 files changed, 47 insertions(+), 22 deletions(-) diff --git a/client.h b/client.h index e9d6655687..79b50651d6 100644 --- a/client.h +++ b/client.h @@ -67,6 +67,7 @@ class Client : public QObject, public KDecorationDefines QRect geometry() const; QSize size() const; + QSize minSize() const; QPoint pos() const; QRect rect() const; int x() const; @@ -731,6 +732,11 @@ inline QSize Client::size() const return frame_geometry.size(); } +inline QSize Client::minSize() const + { + return QSize( xSizeHint.min_width, xSizeHint.min_height ); + } + inline QPoint Client::pos() const { return frame_geometry.topLeft(); diff --git a/geometry.cpp b/geometry.cpp index e05da0b934..3afe51bded 100644 --- a/geometry.cpp +++ b/geometry.cpp @@ -351,6 +351,11 @@ void Workspace::unclutterDesktop() QRect Client::adjustedClientArea( const QRect& area ) const { QRect r = area; + if( isTopMenu() && workspace()->managingTopMenus()) + { + r.setTop( r.top() + workspace()->topMenuHeight()); + return r; + } NETStrut strut = info->strut(); if ( strut.left > 0 ) r.setLeft( r.left() + (int) strut.left ); @@ -431,18 +436,6 @@ void Client::checkWorkspacePosition() // kdDebug() << "TOPMENU size adjust: " << area << ":" << this << endl; setGeometry( area ); } - NETStrut strut = info->strut(); - int top = workspace()->managingTopMenus() ? workspace()->topMenuHeight() : 0; - if( strut.left != 0 || strut.right != 0 || strut.bottom != 0 || strut.top != top ) - { - NETStrut new_strut; - new_strut.left = 0; - new_strut.right = 0; - new_strut.top = top; - new_strut.bottom = 0; - info->setStrut( new_strut ); - workspace()->updateClientArea(); - } return; } diff --git a/workspace.cpp b/workspace.cpp index 310a393d2d..84406b1569 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -432,6 +432,11 @@ void Workspace::addClient( Client* c, allowed_t ) } if( !unconstrained_stacking_order.contains( c )) unconstrained_stacking_order.append( c ); + if( c->isTopMenu()) + { + addTopMenu( c ); + updateCurrentTopMenu(); // SELI make sure this is called correctly WRT things done in manage() + } updateClientArea(); // this cannot be in manage(), because the client got added only now updateClientLayer( c ); if( c->isDesktop()) @@ -441,13 +446,6 @@ void Workspace::addClient( Client* c, allowed_t ) if( activeClient() == NULL && should_get_focus.count() == 0 ) activateClient( findDesktop( true, currentDesktop())); } - if( c->isTopMenu()) - { - topmenus.append( c ); - c->checkWorkspacePosition(); -// kdDebug() << "NEW TOPMENU:" << c << endl; - updateCurrentTopMenu(); // SELI make sure this is called correctly WRT things done in manage() - } if( c->isUtility() || c->isMenu() || c->isToolbar()) updateToolWindows( true ); checkTransients( c->window()); // SELI does this really belong here? @@ -478,9 +476,8 @@ void Workspace::removeClient( Client* c, allowed_t ) stacking_order.remove( c ); focus_chain.remove( c ); attention_chain.remove( c ); -// if( c->isTopMenu()) -// kdDebug() << "REMOVE TOPMENU:" << c << endl; - topmenus.remove( c ); + if( c->isTopMenu()) + removeTopMenu( c ); Group* group = findGroup( c->window()); if( group != NULL ) group->lostLeader(); @@ -1804,6 +1801,33 @@ void Workspace::raiseElectricBorders() } } +void Workspace::addTopMenu( Client* c ) + { + assert( c->isTopMenu()); + assert( !topmenus.contains( c )); + topmenus.append( c ); + int minsize = c->minSize().height(); + if( minsize > topMenuHeight()) + { + topmenu_height = minsize; + for( ClientList::ConstIterator it = topmenus.begin(); + it != topmenus.end(); + ++it ) + (*it)->checkWorkspacePosition(); + } + c->checkWorkspacePosition(); +// kdDebug() << "NEW TOPMENU:" << c << endl; + } + +void Workspace::removeTopMenu( Client* c ) + { +// if( c->isTopMenu()) +// kdDebug() << "REMOVE TOPMENU:" << c << endl; + assert( c->isTopMenu()); + assert( topmenus.contains( c )); + topmenus.remove( c ); + // TODO reduce topMenuHeight() if possible? + } void Workspace::lostTopMenuSelection() { diff --git a/workspace.h b/workspace.h index 13d395c230..5e2dc16586 100644 --- a/workspace.h +++ b/workspace.h @@ -339,6 +339,8 @@ class Workspace : public QObject, public KWinInterface, public KDecorationDefine bool keepTransientAbove( const Client* mainwindow, const Client* transient ); void blockStackingUpdates( bool block ); void updateCurrentTopMenu(); + void addTopMenu( Client* c ); + void removeTopMenu( Client* c ); void updateToolWindows( bool also_hide ); // this is the right way to create a new client