Hopefully final fixes for topmenus managed by KWin to work (#66152).

Written by Schizo, reviewed by Frenia. As it was broken anyway, I don't
think this can break it more.

svn path=/trunk/kdebase/kwin/; revision=266813
This commit is contained in:
Luboš Luňák 2003-11-13 14:34:05 +00:00
parent 0ec4c11585
commit d46c7413c4
3 changed files with 38 additions and 24 deletions

View file

@ -22,6 +22,7 @@ License. See the file "COPYING" for the exact licensing terms.
#include <kapplication.h>
#include <kglobal.h>
#include <qpainter.h>
#include <kwin.h>
#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 );
}
//********************************************

View file

@ -27,7 +27,6 @@ License. See the file "COPYING" for the exact licensing terms.
#include <kmenubar.h>
#include <kprocess.h>
#include <kglobalaccel.h>
#include <kwin.h>
#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

View file

@ -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