Bug 1439247 [Linux] Allow to disable middle mouse button events by pref r=emilio
authorstransky <stransky@redhat.com>
Wed, 13 Mar 2024 12:15:32 +0000 (16 months ago)
changeset 699102 7e0cd6e234ecb47de644b8dbbc6615e84273aacd
parent 699101 b8bdd0ebb46bca1c767fb2b0cd62ebf0eaeb6cf3
child 699103 a4c759fbea74dc1f1bf2e6a2c0e1294c95ee6659
push id41646
push userncsoregi@mozilla.com
push dateWed, 13 Mar 2024 21:33:25 +0000 (16 months ago)
treeherdermozilla-central@35c5c892ca1e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersemilio
bugs1439247
milestone125.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1439247 [Linux] Allow to disable middle mouse button events by pref r=emilio Differential Revision: https://phabricator.services.mozilla.com/D204493
modules/libpref/init/StaticPrefList.yaml
widget/gtk/nsWindow.cpp
--- a/modules/libpref/init/StaticPrefList.yaml
+++ b/modules/libpref/init/StaticPrefList.yaml
@@ -15978,16 +15978,22 @@
 
 # Whether to use gtk titlebar actions for middle click instead of Firefox
 # build in one
 - name: widget.gtk.titlebar-action-middle-click-enabled
   type: bool
   value: false
   mirror: always
 
+# Whether to ignore middle click events on widget level.
+- name: widget.gtk.middle-click-enabled
+  type: bool
+  value: true
+  mirror: always
+
 # Whether we enable rounded bottom corners on GTK by default.
 #
 # The implementation is a bit hacky (see details in bug 1850827) so behind a
 # pref for emergency purposes.
 - name: widget.gtk.rounded-bottom-corners.enabled
   type: bool
   value: false
   mirror: always
--- a/widget/gtk/nsWindow.cpp
+++ b/widget/gtk/nsWindow.cpp
@@ -8212,16 +8212,20 @@ static gboolean motion_notify_event_cb(G
 
   return TRUE;
 }
 
 static gboolean button_press_event_cb(GtkWidget* widget,
                                       GdkEventButton* event) {
   UpdateLastInputEventTime(event);
 
+  if (event->button == 2 && !StaticPrefs::widget_gtk_middle_click_enabled()) {
+    return FALSE;
+  }
+
   RefPtr<nsWindow> window = GetFirstNSWindowForGDKWindow(event->window);
   if (!window) {
     return FALSE;
   }
 
   window->OnButtonPressEvent(event);
 
   if (GdkIsWaylandDisplay()) {
@@ -8230,16 +8234,20 @@ static gboolean button_press_event_cb(Gt
 
   return TRUE;
 }
 
 static gboolean button_release_event_cb(GtkWidget* widget,
                                         GdkEventButton* event) {
   UpdateLastInputEventTime(event);
 
+  if (event->button == 2 && !StaticPrefs::widget_gtk_middle_click_enabled()) {
+    return FALSE;
+  }
+
   RefPtr<nsWindow> window = GetFirstNSWindowForGDKWindow(event->window);
   if (!window) {
     return FALSE;
   }
 
   window->OnButtonReleaseEvent(event);
 
   return TRUE;