diff --git a/effects.cpp b/effects.cpp index c40c8ca855..13872286dc 100644 --- a/effects.cpp +++ b/effects.cpp @@ -295,6 +295,12 @@ void EffectsHandlerImpl::tabBoxUpdated() ep.second->tabBoxUpdated(); } +void EffectsHandlerImpl::tabBoxKeyEvent( QKeyEvent* event ) + { + foreach( const EffectPair &ep, loaded_effects ) + ep.second->tabBoxKeyEvent( event ); + } + void EffectsHandlerImpl::setActiveFullScreenEffect( Effect* e ) { fullscreen_effect = e; diff --git a/effects.h b/effects.h index 6813ff0092..c1dfcc4285 100644 --- a/effects.h +++ b/effects.h @@ -152,6 +152,7 @@ class EffectsHandlerImpl : public EffectsHandler void tabBoxAdded( int mode ); void tabBoxClosed(); void tabBoxUpdated(); + void tabBoxKeyEvent( QKeyEvent* event ); bool borderActivated( ElectricBorder border ); void mouseChanged( const QPoint& pos, const QPoint& oldpos, Qt::MouseButtons buttons, Qt::MouseButtons oldbuttons, diff --git a/effects/presentwindows/presentwindows.cpp b/effects/presentwindows/presentwindows.cpp index 25d9f079b8..67d104a3bf 100644 --- a/effects/presentwindows/presentwindows.cpp +++ b/effects/presentwindows/presentwindows.cpp @@ -673,6 +673,44 @@ void PresentWindowsEffect::tabBoxUpdated() setHighlightedWindow( effects->currentTabBoxWindow() ); } +void PresentWindowsEffect::tabBoxKeyEvent( QKeyEvent* event ) + { + // not using the "normal" grabbedKeyboardEvent as we don't want to filter in tabbox + if( event->type() == QEvent::KeyPress ) + { + switch( event->key() ) + { // Wrap only if not auto-repeating + case Qt::Key_Left: + setHighlightedWindow( relativeWindow( m_highlightedWindow, -1, 0, !event->isAutoRepeat() )); + break; + case Qt::Key_Right: + setHighlightedWindow( relativeWindow( m_highlightedWindow, 1, 0, !event->isAutoRepeat() )); + break; + case Qt::Key_Up: + setHighlightedWindow( relativeWindow( m_highlightedWindow, 0, -1, !event->isAutoRepeat() )); + break; + case Qt::Key_Down: + setHighlightedWindow( relativeWindow( m_highlightedWindow, 0, 1, !event->isAutoRepeat() )); + break; + case Qt::Key_Home: + setHighlightedWindow( relativeWindow( m_highlightedWindow, -1000, 0, false )); + break; + case Qt::Key_End: + setHighlightedWindow( relativeWindow( m_highlightedWindow, 1000, 0, false )); + break; + case Qt::Key_PageUp: + setHighlightedWindow( relativeWindow( m_highlightedWindow, 0, -1000, false )); + break; + case Qt::Key_PageDown: + setHighlightedWindow( relativeWindow( m_highlightedWindow, 0, 1000, false )); + break; + default: + // nothing + break; + } + } + } + //----------------------------------------------------------------------------- // Atom handling void PresentWindowsEffect::propertyNotify( EffectWindow* w, long a ) diff --git a/effects/presentwindows/presentwindows.h b/effects/presentwindows/presentwindows.h index c6354dd912..4ca90cb1bf 100644 --- a/effects/presentwindows/presentwindows.h +++ b/effects/presentwindows/presentwindows.h @@ -87,6 +87,7 @@ class PresentWindowsEffect virtual void tabBoxAdded( int mode ); virtual void tabBoxClosed(); virtual void tabBoxUpdated(); + virtual void tabBoxKeyEvent( QKeyEvent* event ); // atoms virtual void propertyNotify( EffectWindow* w, long atom ); diff --git a/lib/kwineffects.cpp b/lib/kwineffects.cpp index 1b4ce750d0..dffbb6cd7f 100644 --- a/lib/kwineffects.cpp +++ b/lib/kwineffects.cpp @@ -186,6 +186,11 @@ void Effect::tabBoxClosed() void Effect::tabBoxUpdated() { } + +void Effect::tabBoxKeyEvent( QKeyEvent* ) + { + } + bool Effect::borderActivated( ElectricBorder ) { return false; diff --git a/lib/kwineffects.h b/lib/kwineffects.h index 66b64b365a..5894e9e208 100644 --- a/lib/kwineffects.h +++ b/lib/kwineffects.h @@ -170,7 +170,7 @@ X-KDE-Library=kwin4_effect_cooleffect #define KWIN_EFFECT_API_MAKE_VERSION( major, minor ) (( major ) << 8 | ( minor )) #define KWIN_EFFECT_API_VERSION_MAJOR 0 -#define KWIN_EFFECT_API_VERSION_MINOR 104 +#define KWIN_EFFECT_API_VERSION_MINOR 105 #define KWIN_EFFECT_API_VERSION KWIN_EFFECT_API_MAKE_VERSION( \ KWIN_EFFECT_API_VERSION_MAJOR, KWIN_EFFECT_API_VERSION_MINOR ) @@ -411,6 +411,7 @@ class KWIN_EXPORT Effect virtual void tabBoxAdded( int mode ); virtual void tabBoxClosed(); virtual void tabBoxUpdated(); + virtual void tabBoxKeyEvent( QKeyEvent* event ); virtual bool borderActivated( ElectricBorder border ); static int displayWidth(); diff --git a/tabbox.cpp b/tabbox.cpp index e54d6083ad..dbf827560d 100644 --- a/tabbox.cpp +++ b/tabbox.cpp @@ -601,7 +601,8 @@ void TabBox::TabBox::grabbedKeyEvent( QKeyEvent* event ) { if( !m_isShown && isDisplayed() ) { // tabbox has been replaced, check effects - // TODO: pass keyevent to effects + if( effects ) + static_cast(effects)->tabBoxKeyEvent( event ); return; } setCurrentIndex( m_tabBox->grabbedKeyEvent( event ) );