This solution worked for me:
Disable middle click to paste in Firefox
On the URL bar, type “about:config“, press Enter
Click the “I’ll be careful, I promise” button.
Select for “middlemouse.paste“.
Double click on it to change the value from “true” to “false”.
Disable middle click to paste in Firefox
Patching the gtk source file
Also instruction for patching GTK3 (Ubuntu 20.04) also works for me.
Open a terminal and type the following:
sudo apt-get update
sudo apt-get upgrade
Next, grab the necessary files for compiling the code:
sudo apt-get build-dep gtk+3.0
sudo apt-get install build-essential
Create the patch file
mkdir /tmp/gtk
cd /tmp/gtk
nano gtk_disable_middle_mouse_button_paste.patch
And paste the following:
diff -ur gtk+2.0-2.20.1/gtk/gtkselection.c gtk+2.0-2.20.1-patched/gtk/gtkselection.c
--- gtk+2.0-2.20.1/gtk/gtkselection.c 2010-05-01 22:14:29.000000000 -0500
+++ gtk+2.0-2.20.1-patched/gtk/gtkselection.c 2011-09-17 10:45:37.000000000 -0500
@@ -1065,6 +1065,24 @@
display = gtk_widget_get_display (widget);
owner_window = gdk_selection_owner_get_for_display (display, selection);
+ if (selection == gdk_atom_intern("PRIMARY", TRUE)) {
+ GtkSelectionData selection_data;
+
+ selection_data.selection = selection;
+ selection_data.target = target;
+ selection_data.type = gdk_atom_intern("STRING", TRUE);
+ selection_data.format = 8;
+ selection_data.data = (unsigned char *)"";
+ selection_data.length = 0;
+ selection_data.display = display;
+
+ gtk_selection_retrieval_report(info, selection_data.type,
+ selection_data.format, selection_data.data,
+ selection_data.length, time_);
+
+ return TRUE;
+ }
+
if (owner_window != NULL)
{
GtkWidget *owner_widget;
Now, we are going to grab the gtk 3.0 source code
apt-get source libgtk-3-0
cd gtk+3.0-{your-version}
Apply the patch:
patch -p1 < /tmp/gtk/gtk_disable_middle_mouse_button_paste.patch
Recompile the source code:
sudo apt-get install cdbs
sudo dpkg-buildpackage -uc -us
Install the patched file:
sudo dpkg -i ../libgtk-3-{your-version}.deb
Log out and login again. The mouse middle-click to paste feature should be disabled now.
Instruction for GTK2