From 05a8a4fde32504fa210df89cdec4f8c3473c4e9b Mon Sep 17 00:00:00 2001 From: Matthias Ettrich Date: Mon, 10 Jul 2000 15:54:17 +0000 Subject: [PATCH] mac menubar svn path=/trunk/kdebase/kwin/; revision=55967 --- client.cpp | 13 +++++++++++-- client.h | 1 + workspace.cpp | 35 ++++++++++++++++++++++++++++++++++- 3 files changed, 46 insertions(+), 3 deletions(-) diff --git a/client.cpp b/client.cpp index 0838c144bc..8aeceee6c3 100644 --- a/client.cpp +++ b/client.cpp @@ -1599,14 +1599,14 @@ bool Client::x11Event( XEvent * e) if ( options->focusPolicy == Options::ClickToFocus ) return TRUE; - if ( options->autoRaise && !isDesktop() && !isDock() ) { + if ( options->autoRaise && !isDesktop() && !isDock() && !isMenu() ) { delete autoRaiseTimer; autoRaiseTimer = new QTimer( this ); connect( autoRaiseTimer, SIGNAL( timeout() ), this, SLOT( autoRaise() ) ); autoRaiseTimer->start( options->autoRaiseInterval, TRUE ); } - if ( options->focusPolicy != Options::FocusStrictlyUnderMouse && ( isDesktop() || isDock() ) ) + if ( options->focusPolicy != Options::FocusStrictlyUnderMouse && ( isDesktop() || isDock() || isMenu() ) ) return TRUE; workspace()->requestFocus( this ); @@ -1875,6 +1875,9 @@ void Client::getWindowProtocols(){ */ void Client::takeFocus() { + if ( isMenu() ) + return; // menus don't take focus + if ( input ) XSetInputFocus( qt_xdisplay(), win, RevertToPointerRoot, kwin_time ); if ( Ptakefocus ) @@ -2216,6 +2219,12 @@ bool Client::isDock() const return windowType() == NET::Dock; } +bool Client::isMenu() const +{ + return windowType() == NET::Menu; +} + + /*! Returns \a area with the client's strut taken into account. diff --git a/client.h b/client.h index 1ab9250964..4148c9a26d 100644 --- a/client.h +++ b/client.h @@ -125,6 +125,7 @@ public: bool isMovable() const; bool isDesktop() const; bool isDock() const; + bool isMenu() const; void takeFocus(); diff --git a/workspace.cpp b/workspace.cpp index d1482ae031..d5dfa981a4 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -851,7 +851,7 @@ Client* Workspace::previousStaticClient( Client* c ) const Client* Workspace::topClientOnDesktop() const { for ( ClientList::ConstIterator it = stacking_order.fromLast(); it != stacking_order.end(); --it) { - if ( !(*it)->isDesktop() && !(*it)->isDock() ) + if ( !(*it)->isDesktop() && !(*it)->isDock() && !(*it)->isDock() ) return *it; } return 0; @@ -912,6 +912,39 @@ void Workspace::setActiveClient( Client* c ) if ( c->wantsTabFocus() ) focus_chain.append( c ); } + + // toplevel menubar handling + Client* main = 0; + if ( active_client ) + main = active_client->mainClient(); + + // show the new menu bar first... + Client* menubar = 0; + for ( ClientList::ConstIterator it = clients.begin(); it != clients.end(); ++it) { + if ( (*it)->isMenu() && (*it)->mainClient() == main ) { + menubar = *it; + break; + } + } + if ( !menubar && desktop_client ) { + for ( ClientList::ConstIterator it = clients.begin(); it != clients.end(); ++it) { + if ( (*it)->isMenu() && (*it)->mainClient() == desktop_client ) { + menubar = *it; + break; + } + } + } + + if ( menubar ) { + menubar->show(); + menubar->raise(); + } + + // ... then hide the other ones. Avoids flickers. + for ( ClientList::ConstIterator it = clients.begin(); it != clients.end(); ++it) { + if ( (*it)->isMenu() && (*it) != menubar ) + (*it)->hide(); + } rootInfo->setActiveWindow( active_client? active_client->window() : 0 ); }