diff options
author | Sergey Udaltsov <svu@gnome.org> | 2004-12-25 00:48:13 +0000 |
---|---|---|
committer | Sergey Udaltsov <svu@gnome.org> | 2004-12-25 00:48:13 +0000 |
commit | effcfb0b8028238117712191eba99846530a4f5e (patch) | |
tree | dff58737ce9d97ac79e0a4481bfbbd0f9772b008 | |
parent | 44758002791716ba0ee3ac323f6908f782883378 (diff) | |
download | libxklavier-effcfb0b8028238117712191eba99846530a4f5e.tar.gz |
some fixes for the tracking mode
-rw-r--r-- | libxklavier/xklavier_evt.c | 65 |
1 files changed, 41 insertions, 24 deletions
diff --git a/libxklavier/xklavier_evt.c b/libxklavier/xklavier_evt.c index 0ef3886..9202b20 100644 --- a/libxklavier/xklavier_evt.c +++ b/libxklavier/xklavier_evt.c @@ -378,7 +378,7 @@ void _XklStateModificationHandler( XklStateChange changeType, Window focused, focusedApp; XklState oldState; int revert; - Bool haveState; + Bool haveOldState = True; Bool setGroup = changeType == GROUP_CHANGED; XGetInputFocus( _xklDpy, &focused, &revert ); @@ -389,44 +389,61 @@ void _XklStateModificationHandler( XklStateChange changeType, return; } - if( !_XklGetAppWindow( focused, &focusedApp ) ) + /** + * Only if we manage states - otherwise _xklCurClient does not make sense + */ + if( !_XklGetAppWindow( focused, &focusedApp ) && + _xklListenerType & XKLL_MANAGE_WINDOW_STATES ) focusedApp = _xklCurClient; /* what else can I do */ XklDebug( 150, "Focused window: " WINID_FORMAT ", '%s'\n", focusedApp, _XklGetDebugWindowTitle( focusedApp ) ); - XklDebug( 150, "CurClient: " WINID_FORMAT ", '%s'\n", _xklCurClient, - _XklGetDebugWindowTitle( _xklCurClient ) ); - - if( focusedApp != _xklCurClient ) + if( _xklListenerType & XKLL_MANAGE_WINDOW_STATES ) { - if ( !_XklGetAppState( focusedApp, &oldState ) ) - { - _XklUpdateCurState( grp, inds, - "Updating the state from new focused window" ); - if( _xklListenerType & XKLL_MANAGE_WINDOW_STATES ) - _XklAddAppWindow( focusedApp, ( Window ) NULL, False, &_xklCurState ); - } - else + XklDebug( 150, "CurClient: " WINID_FORMAT ", '%s'\n", _xklCurClient, + _XklGetDebugWindowTitle( _xklCurClient ) ); + + if( focusedApp != _xklCurClient ) { - grp = oldState.group; - inds = oldState.indicators; + /** + * If not state - we got the new window + */ + if ( !_XklGetAppState( focusedApp, &oldState ) ) + { + _XklUpdateCurState( grp, inds, + "Updating the state from new focused window" ); + if( _xklListenerType & XKLL_MANAGE_WINDOW_STATES ) + _XklAddAppWindow( focusedApp, ( Window ) NULL, False, &_xklCurState ); + } + /** + * There is state - just get the state from the window + */ + else + { + grp = oldState.group; + inds = oldState.indicators; + } + _xklCurClient = focusedApp; + XklDebug( 160, "CurClient:changed to " WINID_FORMAT ", '%s'\n", + _xklCurClient, _XklGetDebugWindowTitle( _xklCurClient ) ); } - _xklCurClient = focusedApp; - XklDebug( 160, "CurClient:changed to " WINID_FORMAT ", '%s'\n", - _xklCurClient, _XklGetDebugWindowTitle( _xklCurClient ) ); + /* If the window already has this this state - we are just restoring it! + (see the second parameter of stateCallback */ + haveOldState = _XklGetAppState( _xklCurClient, &oldState ); + } else /* just tracking the stuff, no smart things */ + { + XklDebug( 160, "Just updating the current state in the tracking mode\n" ); + memcpy( &oldState, &_xklCurState, sizeof( XklState ) ); } - /* if the window already has this this state - we are just restoring it! - (see the second parameter of stateCallback */ - haveState = _XklGetAppState( _xklCurClient, &oldState ); - if( setGroup || haveState ) + if( setGroup || haveOldState ) { _XklUpdateCurState( setGroup ? grp : oldState.group, setInds ? inds : oldState.indicators, "Restoring the state from the window" ); } - if( haveState ) + if( haveOldState ) _XklTryCallStateCallback( changeType, &oldState ); if( _xklListenerType & XKLL_MANAGE_WINDOW_STATES ) |