[gnome-shell] st: Add rudimentary support for CLUTTER_SCROLL_SMOOTH events
- From: Florian MÃllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] st: Add rudimentary support for CLUTTER_SCROLL_SMOOTH events
- Date: Mon, 19 Mar 2012 23:40:48 +0000 (UTC)
commit a7d4c7d8de78f0ba2224ffa47db311105d6615e9
Author: Florian MÃllner <fmuellner gnome org>
Date: Mon Mar 19 21:30:09 2012 +0100
st: Add rudimentary support for CLUTTER_SCROLL_SMOOTH events
Currently compilation fails with -Werror, as we don't handle the
(newly introduced) smooth scroll events in switch statements; add
some basic support, which should make the compiler happy.
https://bugzilla.gnome.org/show_bug.cgi?id=672413
src/st/st-scroll-bar.c | 11 ++++++++++-
src/st/st-scroll-view.c | 16 +++++++++++++++-
2 files changed, 25 insertions(+), 2 deletions(-)
---
diff --git a/src/st/st-scroll-bar.c b/src/st/st-scroll-bar.c
index 0309a8c..b8f4f72 100644
--- a/src/st/st-scroll-bar.c
+++ b/src/st/st-scroll-bar.c
@@ -32,6 +32,7 @@
#include "config.h"
#endif
+#include <math.h>
#include <clutter/clutter.h>
#include "st-scroll-bar.h"
@@ -443,7 +444,7 @@ st_scroll_bar_scroll_event (ClutterActor *actor,
ClutterScrollEvent *event)
{
StScrollBarPrivate *priv = ST_SCROLL_BAR (actor)->priv;
- gdouble lower, step, upper, value;
+ gdouble lower, step, upper, value, delta_x, delta_y;
if (priv->adjustment)
{
@@ -461,6 +462,14 @@ st_scroll_bar_scroll_event (ClutterActor *actor,
switch (event->direction)
{
+ case CLUTTER_SCROLL_SMOOTH:
+ clutter_event_get_scroll_delta ((ClutterEvent *)event,
+ &delta_x, &delta_y);
+ if (fabs (delta_x) > fabs (delta_y))
+ st_adjustment_set_value (priv->adjustment, value + delta_x);
+ else
+ st_adjustment_set_value (priv->adjustment, value + delta_y);
+ break;
case CLUTTER_SCROLL_UP:
case CLUTTER_SCROLL_LEFT:
if (value == lower)
diff --git a/src/st/st-scroll-view.c b/src/st/st-scroll-view.c
index ce6b0cd..4ff7918 100644
--- a/src/st/st-scroll-view.c
+++ b/src/st/st-scroll-view.c
@@ -687,7 +687,7 @@ st_scroll_view_scroll_event (ClutterActor *self,
ClutterScrollEvent *event)
{
StScrollViewPrivate *priv = ST_SCROLL_VIEW (self)->priv;
- gdouble lower, value, upper, step;
+ gdouble lower, value, upper, step, hvalue, vvalue, delta_x, delta_y;
/* don't handle scroll events if requested not to */
if (!priv->mouse_scroll)
@@ -695,6 +695,16 @@ st_scroll_view_scroll_event (ClutterActor *self,
switch (event->direction)
{
+ case CLUTTER_SCROLL_SMOOTH:
+ clutter_event_get_scroll_delta ((ClutterEvent *)event,
+ &delta_x, &delta_y);
+ g_object_get (priv->hadjustment,
+ "value", &hvalue,
+ NULL);
+ g_object_get (priv->vadjustment,
+ "value", &vvalue,
+ NULL);
+ break;
case CLUTTER_SCROLL_UP:
case CLUTTER_SCROLL_DOWN:
g_object_get (priv->vadjustment,
@@ -717,6 +727,10 @@ st_scroll_view_scroll_event (ClutterActor *self,
switch (event->direction)
{
+ case CLUTTER_SCROLL_SMOOTH:
+ st_adjustment_set_value (priv->hadjustment, hvalue + delta_x);
+ st_adjustment_set_value (priv->vadjustment, vvalue + delta_y);
+ break;
case CLUTTER_SCROLL_UP:
if (value == lower)
return FALSE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]