WABA: Keep focus with same window after switching desktops
svn path=/trunk/kdebase/kwin/; revision=51128
This commit is contained in:
parent
59e4a2c8fc
commit
c3d3c81d64
2 changed files with 42 additions and 26 deletions
8
client.h
8
client.h
|
@ -122,6 +122,13 @@ public:
|
||||||
bool mayMove() const { return may_move; }
|
bool mayMove() const { return may_move; }
|
||||||
void setMayMove( bool m) { may_move = m; }
|
void setMayMove( bool m) { may_move = m; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A window with passive focus will only get focus when
|
||||||
|
* the user explicitly selects the window.
|
||||||
|
**/
|
||||||
|
bool passiveFocus() const { return passive_focus; }
|
||||||
|
void setPassiveFocus( bool p) { passive_focus = p; }
|
||||||
|
|
||||||
void takeFocus();
|
void takeFocus();
|
||||||
|
|
||||||
void setMask( const QRegion & );
|
void setMask( const QRegion & );
|
||||||
|
@ -238,6 +245,7 @@ private:
|
||||||
bool is_sticky;
|
bool is_sticky;
|
||||||
bool is_shape;
|
bool is_shape;
|
||||||
bool may_move;
|
bool may_move;
|
||||||
|
bool passive_focus;
|
||||||
void getWMHints();
|
void getWMHints();
|
||||||
void getWindowProtocols();
|
void getWindowProtocols();
|
||||||
uint Pdeletewindow :1; // does the window understand the DeleteWindow protocol?
|
uint Pdeletewindow :1; // does the window understand the DeleteWindow protocol?
|
||||||
|
|
|
@ -126,18 +126,21 @@ Client* Workspace::clientFactory( Workspace *ws, WId w )
|
||||||
c->setSticky( TRUE );
|
c->setSticky( TRUE );
|
||||||
c->setMayMove( FALSE );
|
c->setMayMove( FALSE );
|
||||||
ws->setDesktopClient( c );
|
ws->setDesktopClient( c );
|
||||||
|
c->setPassiveFocus( TRUE );
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
if ( s.lower().right(6) == "kicker" ) {
|
if ( s.lower().right(6) == "kicker" ) {
|
||||||
Client * c = new NoBorderClient( ws, w);
|
Client * c = new NoBorderClient( ws, w);
|
||||||
c->setSticky( TRUE );
|
c->setSticky( TRUE );
|
||||||
c->setMayMove( FALSE );
|
c->setMayMove( FALSE );
|
||||||
|
c->setPassiveFocus( TRUE );
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
if ( s == "MAC MENU [menu]" ) {
|
if ( s == "MAC MENU [menu]" ) {
|
||||||
Client * c = new NoBorderClient( ws, w);
|
Client * c = new NoBorderClient( ws, w);
|
||||||
c->setSticky( TRUE );
|
c->setSticky( TRUE );
|
||||||
c->setMayMove( FALSE );
|
c->setMayMove( FALSE );
|
||||||
|
c->setPassiveFocus( TRUE );
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
if ( ( s.right(6) == "[menu]" ) || ( s.right(7) == "[tools]" ) ) {
|
if ( ( s.right(6) == "[menu]" ) || ( s.right(7) == "[tools]" ) ) {
|
||||||
|
@ -1537,29 +1540,28 @@ void Workspace::setDesktopClient( Client* c)
|
||||||
propages the new desktop to the world
|
propages the new desktop to the world
|
||||||
*/
|
*/
|
||||||
void Workspace::setCurrentDesktop( int new_desktop ){
|
void Workspace::setCurrentDesktop( int new_desktop ){
|
||||||
if (new_desktop == current_desktop || new_desktop < 1 || new_desktop > number_of_desktops )
|
if (new_desktop < 1 || new_desktop > number_of_desktops )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
active_client = 0;
|
|
||||||
block_focus = TRUE;
|
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) {
|
for ( ClientList::ConstIterator it = stacking_order.begin(); it != stacking_order.end(); ++it) {
|
||||||
if ( (*it)->isVisible() && !(*it)->isOnDesktop( new_desktop ) ) {
|
if ( (*it)->isVisible() && !(*it)->isOnDesktop( new_desktop ) ) {
|
||||||
(*it)->hide();
|
(*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.fromLast(); it != stacking_order.end(); --it) {
|
|
||||||
if ( (*it)->isOnDesktop( new_desktop ) && !(*it)->isIconified() ) {
|
|
||||||
(*it)->show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
current_desktop = new_desktop;
|
current_desktop = new_desktop;
|
||||||
|
|
||||||
XChangeProperty(qt_xdisplay(), qt_xrootwin(),
|
XChangeProperty(qt_xdisplay(), qt_xrootwin(),
|
||||||
|
@ -1569,25 +1571,31 @@ void Workspace::setCurrentDesktop( int new_desktop ){
|
||||||
|
|
||||||
// restore the focus on this desktop
|
// restore the focus on this desktop
|
||||||
block_focus = FALSE;
|
block_focus = FALSE;
|
||||||
Client* c = active_client?active_client:previousClient(0);
|
Client* c = active_client;
|
||||||
Client* stop = c;
|
|
||||||
while ( c && !c->isVisible() ) {
|
if ( !c || !c->isVisible() || c->passiveFocus()) {
|
||||||
c = previousClient( c );
|
c = nextClient(0);
|
||||||
if ( c == stop )
|
Client* stop = c;
|
||||||
break;
|
while ( c && (!c->isVisible() || c->passiveFocus()) ) {
|
||||||
|
c = nextClient( c );
|
||||||
|
if ( c == stop )
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !c || !c->isVisible() ) {
|
if ( !c || !c->isVisible() || c->passiveFocus()) {
|
||||||
// there's no suitable client in the focus chain. Try to find any other client then.
|
// 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) {
|
for ( ClientList::ConstIterator it = stacking_order.begin(); it != stacking_order.end(); ++it) {
|
||||||
if ( (*it)->isVisible() ) {
|
if ( (*it)->isVisible() && !(*it)->passiveFocus() ) {
|
||||||
c = *it;
|
c = *it;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( c && c->isVisible() )
|
if ( c && c->isVisible() && !c->passiveFocus())
|
||||||
requestFocus( c );
|
requestFocus( c );
|
||||||
|
else
|
||||||
|
focusToNull();
|
||||||
|
|
||||||
QApplication::syncX();
|
QApplication::syncX();
|
||||||
KWM::switchToDesktop( current_desktop ); // ### compatibility
|
KWM::switchToDesktop( current_desktop ); // ### compatibility
|
||||||
|
|
Loading…
Reference in a new issue