diff --git a/geometry.cpp b/geometry.cpp index 1accbe9746..f05cb86da3 100644 --- a/geometry.cpp +++ b/geometry.cpp @@ -22,6 +22,7 @@ License. See the file "COPYING" for the exact licensing terms. #include #include #include +#include #include "placement.h" #include "notifications.h" @@ -113,7 +114,7 @@ void Workspace::updateClientArea( bool force ) rootInfo->setWorkArea( i, r ); } - updateTopMenuSpaceGeometry(); + updateTopMenuGeometry(); for( ClientList::ConstIterator it = clients.begin(); it != clients.end(); ++it) @@ -347,14 +348,38 @@ void Workspace::unclutterDesktop() } -void Workspace::updateTopMenuSpaceGeometry() +void Workspace::updateTopMenuGeometry( Client* c ) { if( !managingTopMenus()) return; + if( c != NULL ) + { + XEvent ev; + ev.xclient.display = qt_xdisplay(); + ev.xclient.type = ClientMessage; + ev.xclient.window = c->window(); + static Atom msg_type_atom = XInternAtom( qt_xdisplay(), "_KDE_TOPMENU_MINSIZE", False ); + ev.xclient.message_type = msg_type_atom; + ev.xclient.format = 32; + ev.xclient.data.l[0] = qt_x_time; + ev.xclient.data.l[1] = topmenu_space->width(); + ev.xclient.data.l[2] = topmenu_space->height(); + ev.xclient.data.l[3] = 0; + ev.xclient.data.l[4] = 0; + XSendEvent( qt_xdisplay(), c->window(), False, NoEventMask, &ev ); + KWin::setStrut( c->window(), 0, 0, topmenu_height, 0 ); // so that kicker etc. know + c->checkWorkspacePosition(); + return; + } + // c == NULL - update all, including topmenu_space QRect area; area = clientArea( MaximizeFullArea, QPoint( 0, 0 ), 1 ); // HACK desktop ? area.setHeight( topMenuHeight()); topmenu_space->setGeometry( area ); + for( ClientList::ConstIterator it = topmenus.begin(); + it != topmenus.end(); + ++it ) + updateTopMenuGeometry( *it ); } //******************************************** diff --git a/workspace.cpp b/workspace.cpp index fd1775f903..cccef6f1f9 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -27,7 +27,6 @@ License. See the file "COPYING" for the exact licensing terms. #include #include #include -#include #include "plugins.h" #include "client.h" @@ -743,11 +742,7 @@ void Workspace::slotReconfigure() topmenu_height = 0; // invalidate used menu height if( managingTopMenus()) { - updateTopMenuSpaceGeometry(); - for( ClientList::ConstIterator it = topmenus.begin(); - it != topmenus.end(); - ++it ) - (*it)->checkWorkspacePosition(); + updateTopMenuGeometry(); updateCurrentTopMenu(); } } @@ -1824,20 +1819,16 @@ void Workspace::addTopMenu( Client* c ) assert( c->isTopMenu()); assert( !topmenus.contains( c )); topmenus.append( c ); - int minsize = c->minSize().height(); - if( minsize > topMenuHeight()) + if( managingTopMenus()) { - topmenu_height = minsize; - updateTopMenuSpaceGeometry(); - for( ClientList::ConstIterator it = topmenus.begin(); - it != topmenus.end(); - ++it ) + int minsize = c->minSize().height(); + if( minsize > topMenuHeight()) { - KWin::setStrut( (*it)->window(), 0, 0, topmenu_height, 0 ); // so that kicker etc. know - (*it)->checkWorkspacePosition(); + topmenu_height = minsize; + updateTopMenuGeometry(); } + updateTopMenuGeometry( c ); } - c->checkWorkspacePosition(); // kdDebug() << "NEW TOPMENU:" << c << endl; } @@ -1870,6 +1861,8 @@ void Workspace::lostTopMenuSelection() void Workspace::lostTopMenuOwner() { + if( !options->topMenuEnabled()) + return; // kdDebug() << "TopMenu selection lost owner" << endl; if( !topmenu_selection->claim( false )) { @@ -1888,13 +1881,9 @@ void Workspace::setupTopMenuHandling() disconnect( topmenu_watcher, SIGNAL( lostOwner()), this, SLOT( lostTopMenuOwner())); managing_topmenus = true; topmenu_space = new QWidget; - updateTopMenuSpaceGeometry(); + updateTopMenuGeometry(); topmenu_space->show(); updateClientArea(); - for( ClientList::ConstIterator it = topmenus.begin(); - it != topmenus.end(); - ++it ) - (*it)->checkWorkspacePosition(); } int Workspace::topMenuHeight() const diff --git a/workspace.h b/workspace.h index 9d018bfab5..544860c8f3 100644 --- a/workspace.h +++ b/workspace.h @@ -342,7 +342,7 @@ class Workspace : public QObject, public KWinInterface, public KDecorationDefine void addTopMenu( Client* c ); void removeTopMenu( Client* c ); void setupTopMenuHandling(); - void updateTopMenuSpaceGeometry(); + void updateTopMenuGeometry( Client* c = NULL ); void updateToolWindows( bool also_hide ); // this is the right way to create a new client