WABA: Don't allow change of focus while resizing / moving.

This prevents a lot of stupid focus changes when you move a window
around with focusFollowsMouse.
(mouse moves -> focus changes -> window moves -> focus changes back)

svn path=/trunk/kdebase/kwin/; revision=51574
This commit is contained in:
Waldo Bastian 2000-06-02 00:20:41 +00:00
parent fc5367e74d
commit dc5bf6c01c
3 changed files with 14 additions and 0 deletions

View file

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

View file

@ -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();

View file

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