From 2caf69bffbeefa70ee5ceace3d76b3cb6fe50fa0 Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Mon, 2 Mar 2020 04:34:45 +0000 Subject: [PATCH] Bug 1617803 - Support 4th and 5th mouse button disabling pref on Linux r=karlt Some users may want to disable 4th and 5th button of mouse. This feature has already been implemented on Windows, and our GTK widget can support this with this simple patch. Differential Revision: https://phabricator.services.mozilla.com/D64721 --HG-- extra : moz-landing-system : lando --- modules/libpref/init/all.js | 2 +- widget/gtk/nsWindow.cpp | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index 719535861615..0517b207aa63 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -2387,7 +2387,7 @@ pref("middlemouse.scrollbarPosition", false); // Clipboard only supports text/plain pref("clipboard.plainTextOnly", false); -#ifdef XP_WIN +#if defined(XP_WIN) || defined(MOZ_WIDGET_GTK) // Setting false you can disable 4th button and/or 5th button of your mouse. // 4th button is typically mapped to "Back" and 5th button is typically mapped // to "Forward" button. diff --git a/widget/gtk/nsWindow.cpp b/widget/gtk/nsWindow.cpp index 00677d496fef..3929f3da1f0a 100644 --- a/widget/gtk/nsWindow.cpp +++ b/widget/gtk/nsWindow.cpp @@ -3027,9 +3027,15 @@ void nsWindow::OnButtonPressEvent(GdkEventButton* aEvent) { return; // Map buttons 8-9 to back/forward case 8: + if (!Preferences::GetBool("mousebutton.4th.enabled", true)) { + return; + } DispatchCommandEvent(nsGkAtoms::Back); return; case 9: + if (!Preferences::GetBool("mousebutton.5th.enabled", true)) { + return; + } DispatchCommandEvent(nsGkAtoms::Forward); return; default: