diff --git a/client.cpp b/client.cpp index 388783b857..746420aee3 100644 --- a/client.cpp +++ b/client.cpp @@ -375,6 +375,8 @@ Client::Client( Workspace *ws, WId w, QWidget *parent, const char *name, WFlags Client::~Client() { releaseWindow(); + if (workspace()->activeClient() == this) + workspace()->setEnableFocusChange(true); // Safety } @@ -937,6 +939,7 @@ void Client::mouseReleaseEvent( QMouseEvent * e) setGeometry( geom ); Events::raise( isResize() ? Events::ResizeEnd : Events::MoveEnd ); moveResizeMode = FALSE; + workspace()->setEnableFocusChange(true); releaseMouse(); releaseKeyboard(); } @@ -971,6 +974,7 @@ void Client::mouseMoveEvent( QMouseEvent * e) QPoint p( e->pos() - moveOffset ); if (p.manhattanLength() >= 6) { moveResizeMode = TRUE; + workspace()->setEnableFocusChange(false); Events::raise( isResize() ? Events::ResizeStart : Events::MoveStart ); grabMouse( cursor() ); // to keep the right cursor if ( ( isMove() && options->moveMode != Options::Opaque ) @@ -1778,6 +1782,7 @@ bool Client::performMouseCommand( Options::MouseCommand command, QPoint globalPo break; mode = Center; moveResizeMode = TRUE; + workspace()->setEnableFocusChange(false); buttonDown = TRUE; moveOffset = mapFromGlobal( globalPos ); invertedMoveOffset = rect().bottomRight() - moveOffset; @@ -1790,6 +1795,7 @@ bool Client::performMouseCommand( Options::MouseCommand command, QPoint globalPo if (!mayMove()) break; moveResizeMode = TRUE; + workspace()->setEnableFocusChange(false); buttonDown = TRUE; moveOffset = mapFromGlobal( globalPos ); if ( moveOffset.x() < width()/2) { @@ -1923,6 +1929,7 @@ void Client::keyPressEvent( QKeyEvent * e ) XUngrabServer( qt_xdisplay() ); setGeometry( geom ); moveResizeMode = FALSE; + workspace()->setEnableFocusChange(true); releaseMouse(); releaseKeyboard(); buttonDown = FALSE; diff --git a/workspace.cpp b/workspace.cpp index 529d209412..3d8fa34dfe 100644 --- a/workspace.cpp +++ b/workspace.cpp @@ -168,6 +168,7 @@ Workspace::Workspace( bool restore ) control_grab (false), tab_grab (false), mouse_emulation (false), + focus_change (true), tab_box (0), popup (0), desk_popup (0), @@ -935,6 +936,8 @@ bool Workspace::hasCaption( const QString& caption ) */ void Workspace::requestFocus( Client* c) { + if (!focusChangeEnabled()) + return; //TODO will be different for non-root clients. (subclassing?) if ( !c ) { focusToNull(); diff --git a/workspace.h b/workspace.h index 69dfad168c..2888c710ed 100644 --- a/workspace.h +++ b/workspace.h @@ -115,6 +115,9 @@ public: void activateClient( Client* ); void requestFocus( Client* c); + void setEnableFocusChange(bool b) { focus_change = b; } + bool focusChangeEnabled() { return focus_change; } + void doPlacement( Client* c ); QPoint adjustClientPosition( Client* c, QPoint pos ); void raiseClient( Client* c ); @@ -286,6 +289,7 @@ private: bool control_grab; bool tab_grab; bool mouse_emulation; + bool focus_change; TabBox* tab_box;