Act on KeyPress, not KeyRelease, the release may come

from the activating shortcut.


svn path=/trunk/KDE/kdebase/workspace/; revision=746327
This commit is contained in:
Luboš Luňák 2007-12-08 17:57:53 +00:00
parent 864dea425e
commit 0b2a40e150
2 changed files with 23 additions and 43 deletions

View file

@ -557,6 +557,22 @@ void DesktopGridEffect::grabbedKeyboardEvent( QKeyEvent* e )
{
if( e->type() == QEvent::KeyPress )
{
int desktop = -1;
// switch by F<number> or just <number>
if( e->key() >= Qt::Key_F1 && e->key() <= Qt::Key_F35 )
desktop = e->key() - Qt::Key_F1 + 1;
else if( e->key() >= Qt::Key_0 && e->key() <= Qt::Key_9 )
desktop = e->key() == Qt::Key_0 ? 10 : e->key() - Qt::Key_0;
if( desktop != -1 )
{
if( desktop <= effects->numberOfDesktops())
{
setHighlightedDesktop( desktop );
effects->setCurrentDesktop( desktop );
setActive( false );
}
return;
}
switch( e->key())
{ // wrap only on autorepeat
case Qt::Key_Left:
@ -575,30 +591,6 @@ void DesktopGridEffect::grabbedKeyboardEvent( QKeyEvent* e )
setHighlightedDesktop( effects->desktopDown( highlighted_desktop,
!e->isAutoRepeat()));
break;
default:
break;
}
}
else if( e->type() == QEvent::KeyRelease )
{
int desktop = -1;
// switch by F<number> or just <number>
if( e->key() >= Qt::Key_F1 && e->key() <= Qt::Key_F35 )
desktop = e->key() - Qt::Key_F1 + 1;
else if( e->key() >= Qt::Key_0 && e->key() <= Qt::Key_9 )
desktop = e->key() == Qt::Key_0 ? 10 : e->key() - Qt::Key_0;
if( desktop != -1 )
{
if( desktop <= effects->numberOfDesktops())
{
setHighlightedDesktop( desktop );
effects->setCurrentDesktop( desktop );
setActive( false );
}
return;
}
switch( e->key())
{
case Qt::Key_Escape:
setActive( false );
return;

View file

@ -812,25 +812,6 @@ void PresentWindowsEffect::grabbedKeyboardEvent( QKeyEvent* e )
rearrangeWindows();
}
return;
case Qt::Key_Escape:
case Qt::Key_Return:
case Qt::Key_Enter:
break;
default:
if( !e->text().isEmpty())
{
windowFilter.append( e->text());
updateFilterTexture();
rearrangeWindows();
return;
}
break;
}
}
else if( e->type() == QEvent::KeyRelease )
{
switch( e->key())
{
case Qt::Key_Escape:
setActive( false );
return;
@ -849,6 +830,13 @@ void PresentWindowsEffect::grabbedKeyboardEvent( QKeyEvent* e )
}
return;
default:
if( !e->text().isEmpty())
{
windowFilter.append( e->text());
updateFilterTexture();
rearrangeWindows();
return;
}
break;
}
}