From daa32a53fb7fdd619596097d96f9d07719b1bcea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Fri, 6 Feb 2009 09:45:34 +0000 Subject: [PATCH] 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 --- effects/cube/cube.cpp | 53 +++++++++++++++++++++++++++++++++++++++++++ effects/cube/cube.h | 1 + utils.cpp | 8 +++++++ 3 files changed, 62 insertions(+) diff --git a/effects/cube/cube.cpp b/effects/cube/cube.cpp index 53890e68a4..caa918b35c 100644 --- a/effects/cube/cube.cpp +++ b/effects/cube/cube.cpp @@ -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 ) diff --git a/effects/cube/cube.h b/effects/cube/cube.h index 0e67a71781..0e61ba55ce 100644 --- a/effects/cube/cube.h +++ b/effects/cube/cube.h @@ -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(); diff --git a/utils.cpp b/utils.cpp index e9dc085941..a1d0ca80c9 100644 --- a/utils.cpp +++ b/utils.cpp @@ -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; }