diff --git a/layout/xul/nsSliderFrame.cpp b/layout/xul/nsSliderFrame.cpp index 5bb1720d7e6..6bd31a5a26f 100644 --- a/layout/xul/nsSliderFrame.cpp +++ b/layout/xul/nsSliderFrame.cpp @@ -534,6 +534,21 @@ nsSliderFrame::HandleEvent(nsPresContext* aPresContext, mDragStart = pos - mThumbStart; } +#ifdef MOZ_WIDGET_GTK + else if (ShouldScrollForEvent(aEvent) && + aEvent->mClass == eMouseEventClass && + aEvent->AsMouseEvent()->button == WidgetMouseEvent::eRightButton) { + // HandlePress and HandleRelease are usually called via + // nsFrame::HandleEvent, but only for the left mouse button. + if (aEvent->message == NS_MOUSE_BUTTON_DOWN) { + HandlePress(aPresContext, aEvent, aEventStatus); + } else if (aEvent->message == NS_MOUSE_BUTTON_UP) { + HandleRelease(aPresContext, aEvent, aEventStatus); + } + + return NS_OK; + } +#endif // XXX hack until handle release is actually called in nsframe. // if (aEvent->message == NS_MOUSE_EXIT_SYNTH || aEvent->message == NS_MOUSE_RIGHT_BUTTON_UP || aEvent->message == NS_MOUSE_LEFT_BUTTON_UP) @@ -955,8 +970,14 @@ nsSliderFrame::ShouldScrollForEvent(WidgetGUIEvent* aEvent) case NS_MOUSE_BUTTON_DOWN: case NS_MOUSE_BUTTON_UP: { uint16_t button = aEvent->AsMouseEvent()->button; +#ifdef MOZ_WIDGET_GTK + return (button == WidgetMouseEvent::eLeftButton) || + (button == WidgetMouseEvent::eRightButton && GetScrollToClick()) || + (button == WidgetMouseEvent::eMiddleButton && gMiddlePref && !GetScrollToClick()); +#else return (button == WidgetMouseEvent::eLeftButton) || (button == WidgetMouseEvent::eMiddleButton && gMiddlePref); +#endif } default: return false; @@ -978,8 +999,8 @@ nsSliderFrame::ShouldScrollToClickForEvent(WidgetGUIEvent* aEvent) return false; } -#ifdef XP_MACOSX - // On Mac, clicking the scrollbar thumb should never scroll to click. +#if defined(XP_MACOSX) || defined(MOZ_WIDGET_GTK) + // On Mac and Linux, clicking the scrollbar thumb should never scroll to click. if (IsEventOverThumb(aEvent)) { return false; } @@ -995,6 +1016,12 @@ nsSliderFrame::ShouldScrollToClickForEvent(WidgetGUIEvent* aEvent) return GetScrollToClick() != invertPref; } +#ifdef MOZ_WIDGET_GTK + if (mouseEvent->button == WidgetMouseEvent::eRightButton) { + return !GetScrollToClick(); + } +#endif + return true; } diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index ba6c82c5ea7..7fb9caee964 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -574,16 +574,18 @@ pref("accessibility.browsewithcaret_shortcut.enabled", true); // unless accessibility.tabfocus is set by the user. pref("accessibility.tabfocus", 7); pref("accessibility.tabfocus_applies_to_xul", false); - -// On OS X, we follow the "Click in the scrollbar to:" system preference -// unless this preference was set manually -pref("ui.scrollToClick", 0); - #else // Only on mac tabfocus is expected to handle UI widgets as well as web content pref("accessibility.tabfocus_applies_to_xul", true); #endif +// We follow the "Click in the scrollbar to:" system preference on OS X and +// "gtk-primary-button-warps-slider" property with GTK (since 2.24 / 3.6), +// unless this preference is explicitly set. +#if !defined(XP_MACOSX) && !defined(MOZ_WIDGET_GTK) +pref("ui.scrollToClick", 0); +#endif + // provide ability to turn on support for canvas focus rings pref("canvas.focusring.enabled", true); pref("canvas.customfocusring.enabled", false); diff --git a/widget/gtk/nsLookAndFeel.cpp b/widget/gtk/nsLookAndFeel.cpp index 01343406cc3..93066b4f110 100644 --- a/widget/gtk/nsLookAndFeel.cpp +++ b/widget/gtk/nsLookAndFeel.cpp @@ -555,6 +555,26 @@ nsLookAndFeel::GetIntImpl(IntID aID, int32_t &aResult) g_object_unref(entry); } break; + case eIntID_ScrollToClick: + { + GtkSettings *settings; + gboolean warps_slider = FALSE; + + settings = gtk_settings_get_default (); + if (g_object_class_find_property (G_OBJECT_GET_CLASS(settings), + "gtk-primary-button-warps-slider")) { + g_object_get (settings, + "gtk-primary-button-warps-slider", + &warps_slider, + nullptr); + } + + if (warps_slider) + aResult = 1; + else + aResult = 0; + } + break; case eIntID_SubmenuDelay: { GtkSettings *settings;