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:
qt/src/gui/text/qtextcontrol.cpp
void QTextControlPrivate::mouseReleaseEvent (...
...
} else if (button == Qt::MidButton
&& (interactionFlags & Qt::TextEditable)
&& QApplication::clipboard()->supportsSelection()) {
setCursorPosition(pos);
const QMimeData *md = QApplication::clipboard()->mimeData(QClipboard::Selection);
if (md)
q->insertFromMimeData(md);
Also here for lineedit: qt/src/gui/widgets/qlineedit.cpp
void QLineEdit::mouseReleaseEvent(QMouseEvent* e)
...
} else if (!d->readOnly && e->button() == Qt::MidButton) {
d->deselect();
insert(QApplication::clipboard()->text(QClipboard::Selection));
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.