diff --git a/client.cpp b/client.cpp index a334bdd747..388783b857 100644 --- a/client.cpp +++ b/client.cpp @@ -350,6 +350,7 @@ Client::Client( Workspace *ws, WId w, QWidget *parent, const char *name, WFlags active = FALSE; shaded = FALSE; transient_for = None; + passive_focus = FALSE; is_shape = FALSE; is_sticky = FALSE; may_move = TRUE; @@ -1428,7 +1429,9 @@ void Client::gravitate( bool invert ) bool Client::x11Event( XEvent * e) { if ( e->type == EnterNotify ) { - if ( options->focusPolicy != Options::ClickToFocus ) + if (( options->focusPolicy != Options::ClickToFocus ) && + (( options->focusPolicy != Options::FocusFollowsMouse) || + !passiveFocus())) workspace()->requestFocus( this ); return TRUE; } diff --git a/tabbox.cpp b/tabbox.cpp index 6499e9463e..407df3789e 100644 --- a/tabbox.cpp +++ b/tabbox.cpp @@ -12,12 +12,14 @@ Copyright (C) 1999, 2000 Matthias Ettrich #undef Bool // f**king X11 #include #include +#include const bool options_traverse_all = FALSE; // TODO TabBox::TabBox( Workspace *ws, const char *name ) : QWidget( 0, name, WStyle_Customize | WStyle_NoBorder ) { + no_tasks = i18n("*** No Tasks ***"); wspace = ws; reset(); connect(&delayedShowTimer, SIGNAL(timeout()), this, SLOT(show())); @@ -58,7 +60,7 @@ void TabBox::reset() Client* c = workspace()->nextClient( client ); Client* stop = c; QFontMetrics fm( fontMetrics() ); - int cw = 0; + int cw = fm.width(no_tasks)+20; while ( c ) { if ( (options_traverse_all ||c->isOnDesktop(workspace()->currentDesktop())) && (!c->isIconified() || c->mainClient() == c ) ) { @@ -94,15 +96,23 @@ void TabBox::reset() void TabBox::nextPrev( bool next) { if ( mode() == WindowsMode ) { - Client* sign = client; + Client* firstClient = 0; do { - if (client != sign && !sign) - sign = client; if ( next ) client = workspace()->nextClient(client); else client = workspace()->previousClient(client); - } while (client != sign && client && + if (!firstClient) { + // When we see our first client for the second time, + // it's time to stop. + firstClient = client; + } + else if (client == firstClient) { + // No candidates found. + client = 0; + break; + } + } while (client && (( !options_traverse_all && !client->isOnDesktop(workspace()->currentDesktop()) ) || ( client->isIconified() && client->mainClient() != client )) @@ -112,7 +122,6 @@ void TabBox::nextPrev( bool next) if (!options_traverse_all && client && !client->isOnDesktop(workspace()->currentDesktop())) client = 0; - } else { // DesktopMode if ( next ) { @@ -223,7 +232,7 @@ void TabBox::paintContents() } else { r.setBottom( r.bottom() + 20 ); - p.drawText( r, AlignCenter, "*** No Tasks ***" ); + p.drawText( r, AlignCenter, no_tasks); } int x = (width() - clients.count() * 20 )/2; diff --git a/tabbox.h b/tabbox.h index ab25ff8b68..6a491ca713 100644 --- a/tabbox.h +++ b/tabbox.h @@ -50,6 +50,7 @@ private: QLabel* icon; int wmax; QTimer delayedShowTimer; + QString no_tasks; }; diff --git a/workspace.cpp b/workspace.cpp index f500710703..529d209412 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -966,32 +966,26 @@ void Workspace::requestFocus( Client* c) */ void Workspace::clientHidden( Client* c ) { - if ( c == active_client || ( !active_client && c == should_get_focus ) ) + if ( c == active_client || ( !active_client && c == should_get_focus ) ) + { + active_client = 0; + should_get_focus = 0; + if (!block_focus && + options->focusPolicyIsReasonable() && + !focus_chain.isEmpty() + ) { - active_client = 0; - should_get_focus = 0; - if ( clients.contains( c ) ) { - focus_chain.remove( c ); - focus_chain.prepend( c ); - } - if ( - !block_focus && - options->focusPolicyIsReasonable() && - !focus_chain.isEmpty() - ) - { - - ClientList::ConstIterator it = focus_chain.fromLast(); - - do { - if ((*it)->isVisible()) { - requestFocus(*it); - break; - } - it--; - } while (it != focus_chain.begin()); - } - } + for (ClientList::ConstIterator it = focus_chain.fromLast(); + it != focus_chain.end(); + --it) + { + if ((*it)->isVisible()) { + requestFocus(*it); + break; + } + } + } + } } @@ -1543,24 +1537,25 @@ void Workspace::setCurrentDesktop( int new_desktop ){ if (new_desktop < 1 || new_desktop > number_of_desktops ) return; + active_client = 0; block_focus = TRUE; if (new_desktop != current_desktop) { - /* - optimized Desktop switching: unmapping done from back to front - mapping done from front to back => less exposure events - */ + /* + optimized Desktop switching: unmapping done from back to front + mapping done from front to back => less exposure events + */ - for ( ClientList::ConstIterator it = stacking_order.begin(); it != stacking_order.end(); ++it) { - if ( (*it)->isVisible() && !(*it)->isOnDesktop( new_desktop ) ) { - (*it)->hide(); - } - } - for ( ClientList::ConstIterator it = stacking_order.fromLast(); it != stacking_order.end(); --it) { - if ( (*it)->isOnDesktop( new_desktop ) && !(*it)->isIconified() ) { - (*it)->show(); - } - } + for ( ClientList::ConstIterator it = stacking_order.begin(); it != stacking_order.end(); ++it) { + if ( (*it)->isVisible() && !(*it)->isOnDesktop( new_desktop ) ) { + (*it)->hide(); + } + } + for ( ClientList::ConstIterator it = stacking_order.fromLast(); it != stacking_order.end(); --it) { + if ( (*it)->isOnDesktop( new_desktop ) && !(*it)->isIconified() ) { + (*it)->show(); + } + } } current_desktop = new_desktop; @@ -1571,31 +1566,35 @@ void Workspace::setCurrentDesktop( int new_desktop ){ // restore the focus on this desktop block_focus = FALSE; - Client* c = active_client; + Client* c = 0; - if ( !c || !c->isVisible() || c->passiveFocus()) { - c = nextClient(0); - Client* stop = c; - while ( c && (!c->isVisible() || c->passiveFocus()) ) { - c = nextClient( c ); - if ( c == stop ) - break; - } + if ( options->focusPolicyIsReasonable()) { + if (options->focusPolicy == Options::FocusFollowsMouse) { + // Search in focus chain + for( ClientList::ConstIterator it = focus_chain.fromLast(); it != focus_chain.end(); --it) { + if ( (*it)->isVisible() && !(*it)->passiveFocus() ) { + c = *it; + break; + } + } + } + + + if (!c) { + // Search top-most visible window + for ( ClientList::ConstIterator it = stacking_order.fromLast(); it != stacking_order.end(); --it) { + if ( (*it)->isVisible() && !(*it)->passiveFocus() ) { + c = *it; + break; + } + } + } } - if ( !c || !c->isVisible() || c->passiveFocus()) { - // there's no suitable client in the focus chain. Try to find any other client then. - for ( ClientList::ConstIterator it = stacking_order.begin(); it != stacking_order.end(); ++it) { - if ( (*it)->isVisible() && !(*it)->passiveFocus() ) { - c = *it; - break; - } - } - } - if ( c && c->isVisible() && !c->passiveFocus()) - requestFocus( c ); + if ( c ) + requestFocus( c ); else - focusToNull(); + focusToNull(); QApplication::syncX(); KWM::switchToDesktop( current_desktop ); // ### compatibility