This question already has an answer here:

I am using Slackware 13.1 (kernel 2.6) with FVWM as my desktop manager.

I have frequently had issues when coding where my over-sensitive mouse registers a middle-button (mouse-wheel) click while scrolling with the mouse-wheel.

Is there any way to modify the shortcut so that middle-click no longer pastes using the built-in clipboard with X11/Xorg/Xfree86? I would prefer if it were re-mapped to something like +MiddleClick, or something similar.

I have searched through the forums already, and have found some suggestions using XMODMAP, but none have worked so far.

Thank you all in advance for your time and assistance.

marked as duplicate by Sparhawk, Mr Shunz, JigglyNaga, lgeorget, Thomas Dec 14 '18 at 16:54

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

migrated from stackoverflow.com Nov 16 '11 at 23:27

This question came from our site for professional and enthusiast programmers.

  • It could help if you tell what you tried. – Luc M Nov 16 '11 at 20:33
  • Can you say what was tried by you? And give links to forums. I was only able to find this askubuntu.com/questions/4507/… – osgx Nov 16 '11 at 22:55

You can modify ButtonMapping Option in X config: http://www.linuxquestions.org/questions/linux-newbie-8/disable-xorgs-highlight-to-copy-middle-click-to-paste-clipboard-647810/

Option "ButtonMapping" "1 1 3 4 5"

Update: in the thread: https://askubuntu.com/questions/4507/how-do-i-disable-middle-mouse-button-click-paste

the patch to gtk is linked, which will disable middle button as paste: http://subversion.assembla.com/svn/slipstream/patches/gtk_disable_middle_mouse_button_paste.patch

There is an overview of middle button action in different graphic libs/applications: http://os.livejournal.com/811721.html - so I can assume that middleButton action as XA_PRIMARY Paste is not hardcoded in Xorg/Xserver itself (after searching in sources for hour)

And here is likely the handling of middle button in QT:


void QTextControlPrivate::mouseReleaseEvent (...
} else if (button == Qt::MidButton
           && (interactionFlags & Qt::TextEditable)
           && QApplication::clipboard()->supportsSelection()) {
    const QMimeData *md = QApplication::clipboard()->mimeData(QClipboard::Selection);
    if (md)

Also here for lineedit: qt/src/gui/widgets/qlineedit.cpp

void QLineEdit::mouseReleaseEvent(QMouseEvent* e)
    } else if (!d->readOnly && e->button() == Qt::MidButton) {

and may be here for qt3 compat layer: qt/src/qt3support/text/q3textedit.cpp

void Q3TextEdit::contentsMouseReleaseEvent(QMouseEvent * e)
else if (e->button() == Qt::MidButton && !isReadOnly()) {
    // only do middle-click pasting on systems that have selections (ie. X11)
    if (QApplication::clipboard()->supportsSelection()) {

So, you can download QT sources and comment this if branch to disable Midbutton action as paste.

After patching QT & GTK you should only compile them and install instead system's gtk and QT (or place in some dir e.g. /usr/local/lib and put this dir in /etc/ld.so.conf) earlier. Then every dynamically linked application will use patched gtk/QT lib and will not paste anything for middle button press.

If the application linked statically, you should recompile it with patched static library or to recompile it into dynamically linked.

If you need more graphic toolkits to be patched just say name of the toolkit and I will try to find source point of middle button handling as paste.

  • 2
    Unfortunately, this disables my ability to use the middle-mouse button (ie: clicking the scrollwheel) in things like Firefox to open a new tab with one click. – user1022889 Nov 16 '11 at 21:52
  • @user1022889: stop using mouse! Setup nice keybindings, boosts your performance a lot! Plus, muscle memory doesn't need to synchronize with ice and position of the cursor on the screen that much, and move your hand to and from the mouse... Highly recommended! – user3832 Nov 16 '11 at 23:20
  • 2
    Vlad Lazarenko, this question about disabling middle button click-as-paste, and not about how to use keyboard and mouse. I'd just used PC w/o the mouse (no mouse at all) for a week and it was a bad experience. Just got new mouse from ebay and browsing is happy (without buggy Vimperatior) and Google Earth is "easy to draw any number of paths" now. – osgx Nov 16 '11 at 23:33
  • Except for the first couple of lines (which applies to fvwm), this deals with different libraries than fvwm actually uses. – Thomas Dickey Sep 30 '18 at 20:57

Here's what you can do if you want to keep middle click functional (for clicking to open links in new tabs for example) without it pasting things.

First install sxhkd and xsel.

Then configure ./.config/.sxhkd/sxhkdrc like so

    echo -n | xsel -n -i
~control + c
    echo -n | xsel -n -i
~control + x
    echo -n | xsel -n -i

And that's basically it.

Now start sxhkd (or configure it to launch on startup). Now, middle mouse will no longer paste anything but will otherwise function like normal. (As long as you use only ctrl+c and ctrl+x to copy things that is, if you copy things with the mouse it can paste once.)

Not the answer you're looking for? Browse other questions tagged or ask your own question.