Mouse

Revision / Modified: June 12, 2002
Author: Tom Berger

Original documents:
http://www.mandrakeuser.org/docs/xwin/xmouse.html
http://www.mandrakeuser.org/docs/xwin/xmouse2.html

Cut and Paste

Cut and paste via the keyboard is the old standard procedure: mark the text, press <CTRL c> to copy (or <CTRL x> to cut) and then <CTRL v> to paste (to paste into terminals use SHIFT-INS).

Cut and paste using a mouse works differently, though: Mark the line(s) with your mouse. This will automatically write the marked lines to the cut & paste buffer. All you have to do now, is go the place where you want to paste these lines and press the middle mouse button. Et voila, there it is.

If you do not have a three-button mouse, just hold down one button and press the other to paste. Actually this works better with a good two-button mouse than with a mediocre three-button mouse, because low-quality three-button mice tend to insert the content of the buffer twice. This almost never happens with two-button models.
If this doesn't work with your two-button model, run 'mousedrake' again (as 'root') and see if you've checked the option 'Emulate Third Button'. You must have this option enabled to get cut and paste working for two-button mice! You can adjust the interval during which X recognizes an 'emulated' click by changing the value of Option "Emulate3Timeout" in '/etc/X11/XF86Config-4'.

If you need more than one buffer at a time, you might consider having a closer look at programs like 'XClipboard', 'Klipper' or 'GClipper'.

Keyboard Mouse

X comes with a keyboard mouse, activated by pressing CTRL-SHIFT-NUMLOCK. Now the keypad will emulate mouse actions:

The emulated movement is *very* slow, but you can increase its speed considerably by pressing any other key while moving. This takes some exercise, though... Note that this features times out after a while, so you might have to press CTRL-SHIFT-NUMLOCK again to reactivate it.

Making The Mouse Faster

Mice are usually not as responsive in X as in MS-Windows. PS\2 / USB mice are better than serial mice and there are vast differences between different brands. If you can spare the bucks, go for an optical mouse.

Most window managers allow changing the mouse speed from their respective configuration tools. Other ways to do this are:

Using A Wheel Mouse In X

X itself has been supporting wheel mice since version 3.3.3.1. by mapping 'scroll up' and 'scroll down' to a new pair of mouse keys. To have mouse wheel support on the application level, however, the application toolkit has to support it, too. GTK+ (GNOME, Gimp) and Qt (KDE) support wheel mice natively, so all applications using either one of these have built-in mouse wheel support if the developer(s) used the appropriate hooks.

Other applications like Netscape Communicator can get mouse wheel support via the 'imwheel' utility. Notice that 'imwheel' is no longer needed (indeed deprecated) in Mandrake Linux 8.2 and later.

If the wheel of your mouse doesn't work, do these steps (check again after each step be restarting X):

  1. Run 'mousedrake' again and check if you've chosen the correct mouse model.

  2. Have a look at your '/etc/X11/XF86Config(-4)' file, 'Pointer section'. Check if this section has the lines

    Protocol "IMPS/2"
    ZAxisMapping "4 5"

    or (in 'XF86Config-4'):

    Option "Protocol" "IMPS/2"
    Option "ZAxisMapping" "4 5"

    Also make sure that there are hashes (#) in front of the 'Emulate3' options.

  3. Copy the file '/etc/X11/imwheelrc' to your home directory and rename it to '.imwheelrc'.

  4. Execute the imwheel command from your X startup file ('.xinitrc', '.xsession') or the 'Autostart' folder of your desktop environment.

If it still doesn't work, mail Mandrake's support ;-). And in case you are wondering, yes, the 'IMPS/2' driver also works for USB mice.

Have a look at the 'imwheelrc' file, since this is the place where configuration takes place, even for applications which are supported natively by their toolkits. The trouble with 'imwheel' is that is has to be told to not interfere with these kinds of applications:

"konqueror"
@Exclude

This line in 'imwheelrc' tells 'imwheel' to not do anything about mouse wheel events in 'Konqueror'.

It is not possible to exclude applications by widget set, it is almost as impossible to list all applications which 'imwheel' should ignore in 'imwheelrc'. This leaves you with two choices if the mouse wheel is acting 'funny' in your applications:

Of course, you can also edit 'imwheelrc' with the target of adding functionality. The syntax is quite simple:

"Konsole.*"
None,   Up,     Shift_L|Page_Up
None,   Down,   Shift_L|Page_Down

The first line sets the window name (usually that's the application name), the next lines determine the events in 'Modifier Event' pairs. 'None' is a special modifier: it tells imwheel what to do in case the mouse wheel is scrolled without any modifier key pressed. Here it is scrolling up and down (this is what 'Konsole' would do anyway, even without 'imwheel').
The next pair defines a modifier key, the left SHIFT key. If you press the left SHIFT key and then use the wheel, you'll notice that 'scroll up' now scrolls up the command line history and that you now can use the wheel in pagers like 'less', too.

This is just a tiny fraction of what 'imwheel' can do, check out man imwheel for the full scope.

More information on wheel mice in GNU/Linux can be found on Colas Nahaboo X mouse wheel scroll page, although it's somewhat outdated in parts (doesn't cover XFree 4).

Switching Mouse Buttons

The usual scheme for a three-button mouse is

If you want to reverse this order (e.g. because you are a left-hander), use the command xmodmap -e "pointer = 3 2 1". To have that executed automatically every time you start X, create a file called '.Xmodmap' in your home directory and put the line pointer = 3 2 1 in it. Now create an automatic startup script.

Putting Side Buttons To Work

(Note: This is a work in progress. If you know more let me know.)

Some mice have two extra buttons, usually located on each side of the mouse. For X, this increases the number of buttons on that mouse to seven (the wheel counts as two buttons). To check if all seven buttons are recognized by X, run

xmodmap -pp

If you see only five buttons and you have a Microsoft Explorer / Optical PS/2 or USB mouse, it's time to edit '/etc/X11/XF86Config-4' (this does not work with XFree86 3), as 'root'.

Go to the 'Pointer section' and edit the 'Options' lines for 'Protocol' and 'ZAxisMapping' thus:

Option "Protocol" "ExplorerPS/2"
Option "ZAxisMapping" "6 7"

Add the option:

Option "Buttons" "7"

If you now restart X, you will notice something strange: the mouse wheel won't work anymore, but instead you can scroll by using the side buttons. On the other hand, if you set the 'ZAxisMapping' option back to '4 5', buttons 6 and 7 will vanish again. The only workaround for this odd behavior seems to be using 'xmodmap' to remap the buttons:

xmodmap -e "pointer = 1 2 3 6 7 4 5"

Now everything's at its right place again. You might want to create an automatic startup script to have this mapping executed automatically every time you start X.

But what do those two buttons do? So far I've discovered that they scroll sidewards in 'Konsole', 'Galeon' and 'Opera' (not in 'Konqueror', though, I assume that's because it's excluded from 'imwheel').
In 'gvim' and 'KWrite' they move the cursor back and forth by one position, by two positions when the CTRL key is pressed, four positions when the left ALT key is pressed and when you press the right SHIFT key, the cursor is moved to the start or the end of the current line.

Mandrake user Roger Wilco adds: "I find it convenient to map button 3 to the thumb button, it is easier to press than the wheel :-) This way I can paste text by pressing the thumb button, in Galeon it opens a new tab, in Netscape a new window, etc.

Yes, that's certainly something to spend a lazy afternoon with ... ;-)

Mouse Utilities

In this section I'm introducing some less known mouse utilities you might find useful.

Mouse cursors

Creating, editing and installing mouse cursors is explained in Scott Brady's Mouse-Cursor -Configuration Mini-HOWTO.
DeCurs comes with a selection of mouse cursors for instant replacement and allows you to create new cursors via an image editing program. In order to use this program, you will have to compile the sources since there's no RPM available at this time.

Mandrake Linux 8.2 comes with the icoutils package which allows you to use MS Windows icons and cursors in Linux. Install it and read '/usr/share/doc/icoutils-0.13.0/icoutils.html' for instructions.

Mouse gestures

KDE includes kgesture (menu: 'Applications' - 'Accessibility'). It looks like development has ceased after version 0.3.
'kgesture' allows you bind commands of KDE's internal DCOP (Desktop COmmunication Protocol) to mouse gestures. For this, you will have to find out the command DCOP executes to perform a certain task.
Let's say you want to bind the function 'kill window' to a gesture:

  1. Start 'kdcop' from the command line.

  2. Since killing windows is a task related to the window manager (kwin), open that subtree.

  3. Open 'KWinInterface' and you will find ASYNC killWindow()

  4. The command you have to supply for the gesture is

    dcop kwin KWinInterface killWindow

    (i.e.: "run dcop, go into the kwin subtree, go into the KWinInterface subtree, execute function 'killWindow'").

From this example it should be obvious that 'kgesture' isn't all that useful ;-). It is further restrained by the fact that you can't bind the DCOP commands of most applications, since their DCOP name has a unique session number attached (which changes for every instance of that application).

The FVWM window manager as of version 2.4.x and later supports executing commands via mouse gestures.

xstroke allows you to draw every character with the mouse and have it sent to an application window of your choice. It's a bit like 'graffiti' on handheld devices with the notable exception that gestures can be written in the applications themselves. You can define your own gestures and you can even configure it to draw translucent strokes with drop shadows *grin*. Only available in source format.

Clickless

KMouseTool relieves you from the tedious task of clicking the mouse button several hundred times a day. Every time the mouse movement is paused, a click is sent and clickless drag 'n' drop can be enabled, too. Currently only available in source format, the RPM available on the website does not work.

Cursor control

I don't know any real use for this one, but I found it a cute idea: xwarppointer allows you to control the cursor position from the command line (e.g. if you want the cursor at a certain position after X started). Check the page for instructions.
MoveMouse is a similar utility.


Legal: This text is covered by the GNU Free Documentation License. Standard disclaimers of warranty apply. Copyright LSTB (Tom Berger) and Mandrakesoft 1999-2002.