Check for the global shortcut in the effects so that the shortcut actually toggles the effect. This is a workaround needed because the keyboard grab disables the global shortcut.
FEATURE: 156155 svn path=/trunk/KDE/kdebase/workspace/; revision=946787
This commit is contained in:
parent
7d7beedaff
commit
69b8e33fce
6 changed files with 109 additions and 0 deletions
|
@ -233,15 +233,21 @@ void CubeEffect::loadConfig( QString config )
|
|||
KAction* cubeAction = static_cast< KAction* >( actionCollection->addAction( "Cube" ));
|
||||
cubeAction->setText( i18n("Desktop Cube" ));
|
||||
cubeAction->setGlobalShortcut( KShortcut( Qt::CTRL + Qt::Key_F11 ));
|
||||
cubeShortcut = cubeAction->globalShortcut();
|
||||
KAction* cylinderAction = static_cast< KAction* >( actionCollection->addAction( "Cylinder" ));
|
||||
cylinderAction->setText( i18n("Desktop Cylinder" ));
|
||||
cylinderAction->setGlobalShortcut( KShortcut( Qt::CTRL + Qt::SHIFT + Qt::Key_F11 ));
|
||||
cylinderShortcut = cylinderAction->globalShortcut();
|
||||
KAction* sphereAction = static_cast< KAction* >( actionCollection->addAction( "Sphere" ));
|
||||
sphereAction->setText( i18n("Desktop Sphere" ));
|
||||
sphereAction->setGlobalShortcut( KShortcut( Qt::CTRL + Qt::META + Qt::Key_F11 ));
|
||||
sphereShortcut = sphereAction->globalShortcut();
|
||||
connect( cubeAction, SIGNAL( triggered( bool )), this, SLOT( toggleCube()));
|
||||
connect( cylinderAction, SIGNAL( triggered( bool )), this, SLOT( toggleCylinder()));
|
||||
connect( sphereAction, SIGNAL( triggered( bool )), this, SLOT( toggleSphere()));
|
||||
connect( cubeAction, SIGNAL( globalShortcutChanged( QKeySequence )), this, SLOT( cubeShortcutChanged(QKeySequence)));
|
||||
connect( cylinderAction, SIGNAL( globalShortcutChanged( QKeySequence )), this, SLOT( cylinderShortcutChanged(QKeySequence)));
|
||||
connect( sphereAction, SIGNAL( globalShortcutChanged( QKeySequence )), this, SLOT( sphereShortcutChanged(QKeySequence)));
|
||||
shortcutsRegistered = true;
|
||||
}
|
||||
}
|
||||
|
@ -1639,6 +1645,24 @@ void CubeEffect::grabbedKeyboardEvent( QKeyEvent* e )
|
|||
// taken from desktopgrid.cpp
|
||||
if( e->type() == QEvent::KeyPress )
|
||||
{
|
||||
// check for global shortcuts
|
||||
// HACK: keyboard grab disables the global shortcuts so we have to check for global shortcut (bug 156155)
|
||||
if( mode == Cube && cubeShortcut.contains( e->key() + e->modifiers() ) )
|
||||
{
|
||||
toggleCube();
|
||||
return;
|
||||
}
|
||||
if( mode == Cylinder && cylinderShortcut.contains( e->key() + e->modifiers() ) )
|
||||
{
|
||||
toggleCylinder();
|
||||
return;
|
||||
}
|
||||
if( mode == Sphere && sphereShortcut.contains( e->key() + e->modifiers() ) )
|
||||
{
|
||||
toggleSphere();
|
||||
return;
|
||||
}
|
||||
|
||||
int desktop = -1;
|
||||
// switch by F<number> or just <number>
|
||||
if( e->key() >= Qt::Key_F1 && e->key() <= Qt::Key_F35 )
|
||||
|
@ -2116,4 +2140,19 @@ void CubeEffect::windowAdded( EffectWindow* )
|
|||
useList = false;
|
||||
}
|
||||
|
||||
void CubeEffect::cubeShortcutChanged( const QKeySequence& seq )
|
||||
{
|
||||
cubeShortcut = KShortcut( seq );
|
||||
}
|
||||
|
||||
void CubeEffect::cylinderShortcutChanged( const QKeySequence& seq )
|
||||
{
|
||||
cylinderShortcut = KShortcut( seq );
|
||||
}
|
||||
|
||||
void CubeEffect::sphereShortcutChanged( const QKeySequence& seq )
|
||||
{
|
||||
sphereShortcut = KShortcut( seq );
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -23,6 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
|
||||
#include <kwineffects.h>
|
||||
#include <kwinglutils.h>
|
||||
#include <kshortcut.h>
|
||||
#include <QObject>
|
||||
#include <QQueue>
|
||||
#include <QSet>
|
||||
|
@ -58,6 +59,11 @@ class CubeEffect
|
|||
void toggleCube();
|
||||
void toggleCylinder();
|
||||
void toggleSphere();
|
||||
// slots for global shortcut changed
|
||||
// needed to toggle the effect
|
||||
void cubeShortcutChanged( const QKeySequence& seq );
|
||||
void cylinderShortcutChanged( const QKeySequence& seq );
|
||||
void sphereShortcutChanged( const QKeySequence& seq );
|
||||
private:
|
||||
enum RotationDirection
|
||||
{
|
||||
|
@ -152,6 +158,11 @@ class CubeEffect
|
|||
bool capListCreated;
|
||||
bool recompileList;
|
||||
GLuint glList;
|
||||
|
||||
// Shortcuts - needed to toggle the effect
|
||||
KShortcut cubeShortcut;
|
||||
KShortcut cylinderShortcut;
|
||||
KShortcut sphereShortcut;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -61,7 +61,9 @@ DesktopGridEffect::DesktopGridEffect()
|
|||
KAction* a = (KAction*) actionCollection->addAction( "ShowDesktopGrid" );
|
||||
a->setText( i18n( "Show Desktop Grid" ));
|
||||
a->setGlobalShortcut( KShortcut( Qt::CTRL + Qt::Key_F8 ));
|
||||
shortcut = a->globalShortcut();
|
||||
connect( a, SIGNAL( triggered( bool )), this, SLOT( toggle() ));
|
||||
connect( a, SIGNAL( globalShortcutChanged( QKeySequence )), this, SLOT( globalShortcutChanged(QKeySequence)));
|
||||
|
||||
// Load all other configuration details
|
||||
reconfigure( ReconfigureAll );
|
||||
|
@ -381,6 +383,14 @@ void DesktopGridEffect::grabbedKeyboardEvent( QKeyEvent* e )
|
|||
{
|
||||
if( e->type() == QEvent::KeyPress )
|
||||
{
|
||||
// check for global shortcuts
|
||||
// HACK: keyboard grab disables the global shortcuts so we have to check for global shortcut (bug 156155)
|
||||
if( shortcut.contains( e->key() + e->modifiers() ) )
|
||||
{
|
||||
toggle();
|
||||
return;
|
||||
}
|
||||
|
||||
int desktop = -1;
|
||||
// switch by F<number> or just <number>
|
||||
if( e->key() >= Qt::Key_F1 && e->key() <= Qt::Key_F35 )
|
||||
|
@ -855,6 +865,11 @@ void DesktopGridEffect::finish()
|
|||
effects->setActiveFullScreenEffect( 0 );
|
||||
}
|
||||
|
||||
void DesktopGridEffect::globalShortcutChanged( const QKeySequence& seq )
|
||||
{
|
||||
shortcut = KShortcut( seq );
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
#include "desktopgrid.moc"
|
||||
|
|
|
@ -23,6 +23,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#define KWIN_DESKTOPGRID_H
|
||||
|
||||
#include <kwineffects.h>
|
||||
#include <kshortcut.h>
|
||||
#include <QObject>
|
||||
|
||||
namespace KWin
|
||||
|
@ -50,6 +51,9 @@ class DesktopGridEffect
|
|||
|
||||
private slots:
|
||||
void toggle();
|
||||
// slots for global shortcut changed
|
||||
// needed to toggle the effect
|
||||
void globalShortcutChanged( const QKeySequence& seq );
|
||||
|
||||
private:
|
||||
QPointF scalePos( const QPoint& pos, int desktop, int screen = -1 ) const;
|
||||
|
@ -97,6 +101,9 @@ class DesktopGridEffect
|
|||
QList<QSizeF> scaledSize;
|
||||
QList<QPointF> scaledOffset;
|
||||
|
||||
// Shortcut - needed to toggle the effect
|
||||
KShortcut shortcut;
|
||||
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -60,11 +60,15 @@ PresentWindowsEffect::PresentWindowsEffect()
|
|||
KAction* a = ( KAction* )actionCollection->addAction( "Expose" );
|
||||
a->setText( i18n( "Toggle Present Windows (Current desktop)" ));
|
||||
a->setGlobalShortcut( KShortcut( Qt::CTRL + Qt::Key_F9 ));
|
||||
shortcut = a->globalShortcut();
|
||||
connect( a, SIGNAL( triggered(bool) ), this, SLOT( toggleActive() ));
|
||||
connect( a, SIGNAL( globalShortcutChanged(QKeySequence) ), this, SLOT( globalShortcutChanged(QKeySequence)));
|
||||
KAction* b = ( KAction* )actionCollection->addAction( "ExposeAll" );
|
||||
b->setText( i18n( "Toggle Present Windows (All desktops)" ));
|
||||
b->setGlobalShortcut( KShortcut( Qt::CTRL + Qt::Key_F10 ));
|
||||
shortcutAll = b->globalShortcut();
|
||||
connect( b, SIGNAL( triggered(bool) ), this, SLOT( toggleActiveAllDesktops() ));
|
||||
connect( b, SIGNAL( globalShortcutChanged(QKeySequence) ), this, SLOT( globalShortcutChangedAll(QKeySequence)));
|
||||
reconfigure( ReconfigureAll );
|
||||
}
|
||||
|
||||
|
@ -363,6 +367,19 @@ void PresentWindowsEffect::grabbedKeyboardEvent( QKeyEvent *e )
|
|||
{
|
||||
if( e->type() == QEvent::KeyPress )
|
||||
{
|
||||
// check for global shortcuts
|
||||
// HACK: keyboard grab disables the global shortcuts so we have to check for global shortcut (bug 156155)
|
||||
if( !m_allDesktops && shortcut.contains( e->key() + e->modifiers() ) )
|
||||
{
|
||||
toggleActive();
|
||||
return;
|
||||
}
|
||||
if( m_allDesktops && shortcutAll.contains( e->key() + e->modifiers() ) )
|
||||
{
|
||||
toggleActiveAllDesktops();
|
||||
return;
|
||||
}
|
||||
|
||||
switch( e->key() )
|
||||
{ // Wrap only if not auto-repeating
|
||||
case Qt::Key_Left:
|
||||
|
@ -1504,6 +1521,16 @@ EffectWindow* PresentWindowsEffect::findFirstWindow() const
|
|||
return topLeft;
|
||||
}
|
||||
|
||||
void PresentWindowsEffect::globalShortcutChanged( const QKeySequence& seq )
|
||||
{
|
||||
shortcut = KShortcut( seq );
|
||||
}
|
||||
|
||||
void PresentWindowsEffect::globalShortcutChangedAll( const QKeySequence& seq )
|
||||
{
|
||||
shortcutAll = KShortcut( seq );
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
#include "presentwindows.moc"
|
||||
|
|
|
@ -25,6 +25,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include "presentwindows_proxy.h"
|
||||
|
||||
#include <kwineffects.h>
|
||||
#include <kshortcut.h>
|
||||
|
||||
namespace KWin
|
||||
{
|
||||
|
@ -92,6 +93,11 @@ class PresentWindowsEffect
|
|||
void toggleActive() { m_allDesktops = false; setActive( !m_activated ); }
|
||||
void toggleActiveAllDesktops() { m_allDesktops = true; setActive( !m_activated ); }
|
||||
|
||||
// slots for global shortcut changed
|
||||
// needed to toggle the effect
|
||||
void globalShortcutChanged( const QKeySequence& seq );
|
||||
void globalShortcutChangedAll( const QKeySequence& seq );
|
||||
|
||||
protected:
|
||||
// Window rearranging
|
||||
void rearrangeWindows();
|
||||
|
@ -156,6 +162,10 @@ class PresentWindowsEffect
|
|||
// Filter box
|
||||
EffectFrame m_filterFrame;
|
||||
QString m_windowFilter;
|
||||
|
||||
// Shortcut - needed to toggle the effect
|
||||
KShortcut shortcut;
|
||||
KShortcut shortcutAll;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
|
Loading…
Reference in a new issue