Adding mouse wheel support to effects. First one to use is cube effect.

CCMAIL: marco.gulino@gmail.com

svn path=/trunk/KDE/kdebase/workspace/; revision=922031
This commit is contained in:
Martin Gräßlin 2009-02-06 09:45:34 +00:00
parent a3c57fcab0
commit daa32a53fb
3 changed files with 62 additions and 0 deletions

View file

@ -1900,6 +1900,59 @@ void CubeEffect::mouseChanged( const QPoint& pos, const QPoint& oldpos, Qt::Mous
}
}
void CubeEffect::windowInputMouseEvent( Window w, QEvent* e )
{
assert( w == input );
QMouseEvent *mouse = dynamic_cast< QMouseEvent* >( e );
if( mouse && mouse->type() == QEvent::MouseButtonRelease )
{
if( mouse->button() == Qt::XButton1 )
{
if( !rotating && !start )
{
rotating = true;
if( invertMouse )
rotationDirection = Right;
else
rotationDirection = Left;
}
else
{
if( rotations.count() < effects->numberOfDesktops() )
{
if( invertMouse )
rotations.enqueue( Right );
else
rotations.enqueue( Left );
}
}
effects->addRepaintFull();
}
if( mouse->button() == Qt::XButton2 )
{
if( !rotating && !start )
{
rotating = true;
if( invertMouse )
rotationDirection = Left;
else
rotationDirection = Right;
}
else
{
if( rotations.count() < effects->numberOfDesktops() )
{
if( invertMouse )
rotations.enqueue( Left );
else
rotations.enqueue( Right );
}
}
effects->addRepaintFull();
}
}
}
void CubeEffect::desktopChanged( int old )
{
if( effects->activeFullScreenEffect() && effects->activeFullScreenEffect() != this )

View file

@ -47,6 +47,7 @@ class CubeEffect
virtual void grabbedKeyboardEvent( QKeyEvent* e );
virtual void mouseChanged( const QPoint& pos, const QPoint& oldpos, Qt::MouseButtons buttons,
Qt::MouseButtons oldbuttons, Qt::KeyboardModifiers modifiers, Qt::KeyboardModifiers oldmodifiers );
virtual void windowInputMouseEvent( Window w, QEvent* e );
virtual void desktopChanged( int old );
virtual void tabBoxAdded( int mode );
virtual void tabBoxUpdated();

View file

@ -334,6 +334,10 @@ Qt::MouseButton x11ToQtMouseButton( int button )
return Qt::MidButton;
if( button == Button3 )
return Qt::RightButton;
if( button == Button4 )
return Qt::XButton1;
if( button == Button5 )
return Qt::XButton2;
return Qt::NoButton;
}
@ -366,6 +370,10 @@ Qt::MouseButtons x11ToQtMouseButtons( int state )
ret |= Qt::MidButton;
if( state & Button3Mask )
ret |= Qt::RightButton;
if( state & Button4Mask )
ret |= Qt::XButton1;
if( state & Button5Mask )
ret |= Qt::XButton2;
return ret;
}