In mouse focus policies, change active window only when the mouse actually

moves, not as a result of window changes (#92290).


svn path=/trunk/KDE/kdebase/workspace/; revision=704202
icc-effect-5.14.5
Luboš Luňák 2007-08-24 09:46:56 +00:00
parent f3997b2739
commit ca87a4bae2
3 changed files with 32 additions and 6 deletions

View File

@ -220,6 +220,7 @@ void Workspace::setActiveClient( Client* c, allowed_t )
closeActivePopup(); closeActivePopup();
StackingUpdatesBlocker blocker( this ); StackingUpdatesBlocker blocker( this );
++set_active_client_recursion; ++set_active_client_recursion;
updateFocusMousePosition( QCursor::pos());
if( active_client != NULL ) if( active_client != NULL )
{ // note that this may call setActiveClient( NULL ), therefore the recursion counter { // note that this may call setActiveClient( NULL ), therefore the recursion counter
active_client->setActive( false ); active_client->setActive( false );

View File

@ -637,6 +637,7 @@ bool Client::windowEvent( XEvent* e )
case MotionNotify: case MotionNotify:
motionNotifyEvent( e->xmotion.window, e->xmotion.state, motionNotifyEvent( e->xmotion.window, e->xmotion.state,
e->xmotion.x, e->xmotion.y, e->xmotion.x_root, e->xmotion.y_root ); e->xmotion.x, e->xmotion.y, e->xmotion.x_root, e->xmotion.y_root );
workspace()->updateFocusMousePosition( QPoint( e->xmotion.x_root, e->xmotion.y_root ));
break; break;
case EnterNotify: case EnterNotify:
enterNotifyEvent( &e->xcrossing ); enterNotifyEvent( &e->xcrossing );
@ -647,11 +648,14 @@ bool Client::windowEvent( XEvent* e )
// events simpler (Qt does that too). // events simpler (Qt does that too).
motionNotifyEvent( e->xcrossing.window, e->xcrossing.state, motionNotifyEvent( e->xcrossing.window, e->xcrossing.state,
e->xcrossing.x, e->xcrossing.y, e->xcrossing.x_root, e->xcrossing.y_root ); e->xcrossing.x, e->xcrossing.y, e->xcrossing.x_root, e->xcrossing.y_root );
workspace()->updateFocusMousePosition( QPoint( e->xcrossing.x_root, e->xcrossing.y_root ));
break; break;
case LeaveNotify: case LeaveNotify:
motionNotifyEvent( e->xcrossing.window, e->xcrossing.state, motionNotifyEvent( e->xcrossing.window, e->xcrossing.state,
e->xcrossing.x, e->xcrossing.y, e->xcrossing.x_root, e->xcrossing.y_root ); e->xcrossing.x, e->xcrossing.y, e->xcrossing.x_root, e->xcrossing.y_root );
leaveNotifyEvent( &e->xcrossing ); leaveNotifyEvent( &e->xcrossing );
// not here, it'd break following enter notify handling
// workspace()->updateFocusMousePosition( QPoint( e->xcrossing.x_root, e->xcrossing.y_root ));
break; break;
case FocusIn: case FocusIn:
focusInEvent( &e->xfocus ); focusInEvent( &e->xfocus );
@ -951,13 +955,19 @@ void Client::enterNotifyEvent( XCrossingEvent* e )
autoRaiseTimer->start( options->autoRaiseInterval ); autoRaiseTimer->start( options->autoRaiseInterval );
} }
if ( options->focusPolicy != Options::FocusStrictlyUnderMouse && ( isDesktop() || isDock() || isTopMenu() ) ) QPoint currentPos( e->x_root, e->y_root );
if ( options->focusPolicy != Options::FocusStrictlyUnderMouse && ( isDesktop() || isDock() || isTopMenu() ) )
return; return;
if ( options->delayFocus ) // for FocusFollowsMouse, change focus only if the mouse has actually been moved, not if the focus
workspace()->requestDelayFocus( this ); // change came because of window changes (e.g. closing a window) - #92290
else if( options->focusPolicy != Options::FocusFollowsMouse
workspace()->requestFocus( this ); || currentPos != workspace()->focusMousePosition())
{
if ( options->delayFocus )
workspace()->requestDelayFocus( this );
else
workspace()->requestFocus( this );
}
return; return;
} }
} }

View File

@ -292,6 +292,8 @@ class Workspace : public QObject, public KDecorationDefines
void cancelDelayFocus(); void cancelDelayFocus();
void requestDelayFocus( Client* ); void requestDelayFocus( Client* );
void updateFocusMousePosition( const QPoint& pos );
QPoint focusMousePosition() const;
void toggleTopDockShadows(bool on); void toggleTopDockShadows(bool on);
@ -581,6 +583,7 @@ class Workspace : public QObject, public KDecorationDefines
// delay(ed) window focus timer and client // delay(ed) window focus timer and client
QTimer* delayFocusTimer; QTimer* delayFocusTimer;
Client* delayfocus_client; Client* delayfocus_client;
QPoint focusMousePos;
ClientList clients; ClientList clients;
ClientList desktops; ClientList desktops;
@ -870,6 +873,18 @@ void Workspace::forceRestacking()
StackingUpdatesBlocker blocker( this ); // do restacking if not blocked StackingUpdatesBlocker blocker( this ); // do restacking if not blocked
} }
inline
void Workspace::updateFocusMousePosition( const QPoint& pos )
{
focusMousePos = pos;
}
inline
QPoint Workspace::focusMousePosition() const
{
return focusMousePos;
}
template< typename T > template< typename T >
inline Client* Workspace::findClient( T predicate ) inline Client* Workspace::findClient( T predicate )
{ {