Mouse wheel workspace switching behavior

Stephen Dowdy sdowdy at ucar.edu
Wed Sep 19 22:23:50 BST 2012


Mirko K. wrote, On 09/19/2012 01:42 PM:
> On 19.09.2012 19:27, Duncan wrote:
>> Mirko K. posted on Wed, 19 Sep 2012 18:39:21 +0200 as excerpted:
>>
>>> I'm using KDE 4.8.4 on Ubuntu 12.04 with a 3x2 virtual desktop. The
>>> mouse wheel is bound to switch to the next/previous Desktop, and it goes
>>> through all desktops.
>>>
>>> I'd like a different behavior: Wheel without modifier should switch one
>>> desktop to the left/right, and wheel plus some modifier (Alt or Super)
>>> should switch one desktop up/down.
>>>
>>> Any idea how to do that?
>>
>> You don't mention whether you already know about the mouse actions
>> settings, which let you assign various mouse events (modified or not) to
> 
> Thanks for your reply, and sorry for not mentioning where all I had looked, which is pretty much everywhere. System Settings up and down, Hotkeys and Gestures, Mouse, Desktop behaviour, etc. The settings of the Folderview and other Activities. Grepped the KDE config files in $HOME and /usr/share, etc. But nothing. :-)
> 
> The mouse actions don't work, as the only related option is the standard "Switch Desktop" (Arbeitsfläche wechseln, in my German system).
> 
> The cube doesn't help either, as there also no option to make the mouse wheel to only switch horizontal.
> 
> I think there's really no way yet, which actually isn't that much of a problem. I've just recently started to use the 3x2 layout after years with a 4x1 layout. Perhaps I try to get used to the Activities which could give me a somewhat similar workflow as I intend here.
> 
> Anyway, if anybody knows a solution, I'm all ears.

I use Keybindings to switch to Desktop N (CTRL-F{n} -> Desktop N).
With a fixed pager layout, not a problem.

KWin has a dbus interface that supports several desktop/pager switching options:

$ qdbus org.kde.kwin /KWin | grep -i 'org.kde.kwin.*desktop'
method Q_NOREPLY void org.kde.KWin.cascadeDesktop()
method void org.kde.KWin.circulateDesktopApplications()
method int org.kde.KWin.currentDesktop()
method void org.kde.KWin.nextDesktop()
method void org.kde.KWin.previousDesktop()
method bool org.kde.KWin.setCurrentDesktop(int desktop)
method Q_NOREPLY void org.kde.KWin.unclutterDesktop()

What desktop am i currently on?
$ qdbus org.kde.kwin /KWin currentDesktop     
1
Switch to Desktop 4
$ qdbus org.kde.kwin /KWin setCurrentDesktop 4
true

Unfortunately, there's no method "RowsByColumns()" or such, so no way to get
how many rows/columns you have to figure out what desktop would be adjacent
on a horizontal or vertical move (without reading the kwinrc config)

So, the trick here would be to find a tool that would allow input actions to
bind to a script that would issue those functions, along with figuring out
what desktop was adjacent based on the input and currentDesktop().

   kcmshell4 khotkeys

lets you map key inputs to various actions, including DBus, or exec
a command.  Unfortunately, for me, at least, i can't get it to
recognize a scroll event as an acceptable input, either modified or
not. (so you're back to keys, if you can't get mouse actions), and
that's already handled in:

    kcmshell4 keys  [ select [Kwin] component]

which DOES have key actions defined for relative
    Switch One Desktop to the (up,down,left,right)
desktop switch motions.  (so, this would really
be the place to assign a {un,}modified mouse action.

'xev' shows my mouse generating:

    MotionNotify event, serial 34, synthetic NO, window 0x3600001,
        root 0x290, subw 0x0, time 1909453451, (145,33), root:(149,1051),
        state 0x0, is_hint 0, same_screen YES

    LeaveNotify event, serial 34, synthetic NO, window 0x3600001,
        root 0x290, subw 0x0, time 1909453451, (145,33), root:(149,1051),
        mode NotifyGrab, detail NotifyAncestor, same_screen YES,
        focus NO, state 2048

    EnterNotify event, serial 34, synthetic NO, window 0x3600001,
        root 0x290, subw 0x0, time 1909453451, (145,33), root:(149,1051),
        mode NotifyUngrab, detail NotifyAncestor, same_screen YES,
        focus NO, state 2048

    KeymapNotify event, serial 34, synthetic NO, window 0x0,
        keys:  4294967184 0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   
               0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   0   

    ButtonPress event, serial 34, synthetic NO, window 0x3600001,
        root 0x290, subw 0x0, time 1909453451, (145,33), root:(149,1051),
        state 0x0, button 4, same_screen YES

    ButtonRelease event, serial 34, synthetic NO, window 0x3600001,
        root 0x290, subw 0x0, time 1909453451, (145,33), root:(149,1051),
        state 0x800, button 4, same_screen YES

for a single-click scroll-up action.  Not sure if it's (easily) possible
to get that sequence of events to map to a key input sequence where you
might be able to do something like:

kwriteconfig \
    --file kglobalshortcutsrc \
    --group kwin \
    --key "Switch One Desktop to the Right"
            "Ctrl+Alt+Shift+Right"

which assigns those 4 keys chorded (right=right-arrow) to invoke that function.

This might give you more ideas:

http://marian.schedenig.name/2012/06/07/mapping-kde-actions-to-extra-mouse-buttons/

and here's something using qdbus {prev,next}Desktop i described above (but, that
doesn't answer your question about relative up/down/left/right motion)
http://krisko210.blogspot.com/2011/06/kde-46-desktop-switching-with-mouse.html

Good luck!
--stephen
-- 
Stephen Dowdy  -  Systems Administrator  -  NCAR/RAL
303.497.2869   -  sdowdy at ucar.edu        -  http://www.ral.ucar.edu/~sdowdy/

___________________________________________________
This message is from the kde mailing list.
Account management:  https://mail.kde.org/mailman/listinfo/kde.
Archives: http://lists.kde.org/.
More info: http://www.kde.org/faq.html.


More information about the kde mailing list