Bug 803633 - Add basic support for new scrollbar behavior in GTK+ [Part 1]. r=mstange, r=karlt

This commit is contained in:
Alexander Seleznev 2014-08-10 16:05:51 +07:00
parent 2dc6881d41
commit 7c18aef885
3 changed files with 56 additions and 7 deletions

View File

@ -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;
}

View File

@ -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);

View File

@ -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;