[PATCH] mouse wheel on desktop pager
Scott Wheeler
scott at slackorama.net
Wed May 8 22:11:03 BST 2002
During a discussion today on #kde someone, while asking for the mouse wheel
scrolling through desktops, was misunderstood as asking for mouse wheel support
for the pager. However, after a bit of contemplation, this seemed like a good
compromise to the recent discussion on the matter (of whether or not to support
Enlightenment-style mouse wheel support on the desktop).
Anyway, this patch makes the mouse wheel scroll through the desktops when used
over the pager. Any objections to this being committed to HEAD?
-Scott
p.s. I don't have a network connection on my machine (just a friend's computer
and a floppy drive ;-) ) where I'm staying (just at work and I tomorrow is a
holiday) so this is a "normal" patch rather than a 'cvs diff'. It's against
kdebase/kicker/applets/minipager.
-------------- next part --------------
diff -Naur minipager-cvs/pagerapplet.cpp minipager/pagerapplet.cpp
--- minipager-cvs/pagerapplet.cpp Wed May 8 22:07:34 2002
+++ minipager/pagerapplet.cpp Wed May 8 22:01:25 2002
@@ -497,6 +497,21 @@
updateGeometry();
}
+void KMiniPager::wheelEvent( QWheelEvent* e )
+{
+ if( e->delta() < 0 ) {
+ // this could be "( curDesk - 1 ) + 1" for clarity, but that seems superfluous
+ const int next = curDesk % KWin::numberOfDesktops() + 1;
+ KWin::setCurrentDesktop( next );
+ }
+ else {
+ // again, a little ugly -- the addition of the number of desktops makes sure that we are
+ // not taking the modulo of a negative number and the "curDesk - 2" could be "curDesk - 1 - 1"
+ const int previous = ( KWin::numberOfDesktops() + curDesk - 2 ) % KWin::numberOfDesktops() + 1;
+ KWin::setCurrentDesktop( previous );
+ }
+}
+
void KMiniPager::allocateButtons()
{
int i;
diff -Naur minipager-cvs/pagerapplet.h minipager/pagerapplet.h
--- minipager-cvs/pagerapplet.h Wed May 8 22:07:34 2002
+++ minipager/pagerapplet.h Wed May 8 21:07:32 2002
@@ -117,6 +117,7 @@
void updateDesktopLayout(int,int,int);
void popupDirectionChange( Direction d );
void resizeEvent(QResizeEvent*);
+ void wheelEvent( QWheelEvent* e );
void showKPager(bool toggleShow);
protected slots:
More information about the kde-core-devel
mailing list