static gboolean st_scroll_bar_scroll_event (ClutterActor *actor, ClutterScrollEvent *event) { StScrollBarPrivate *priv = ST_SCROLL_BAR (actor)->priv; if (clutter_event_is_pointer_emulated ((ClutterEvent *) event)) return TRUE; switch (event->direction) { case CLUTTER_SCROLL_SMOOTH: { gdouble delta_x, delta_y; clutter_event_get_scroll_delta ((ClutterEvent *)event, &delta_x, &delta_y); if (priv->vertical) st_adjustment_adjust_for_scroll_event (priv->adjustment, delta_y); else st_adjustment_adjust_for_scroll_event (priv->adjustment, delta_x); } break; case CLUTTER_SCROLL_UP: case CLUTTER_SCROLL_DOWN: case CLUTTER_SCROLL_LEFT: case CLUTTER_SCROLL_RIGHT: adjust_with_direction (priv->adjustment, event->direction); break; } return TRUE; }
static gboolean st_scroll_view_scroll_event (ClutterActor *self, ClutterScrollEvent *event) { StScrollViewPrivate *priv = ST_SCROLL_VIEW (self)->priv; /* don't handle scroll events if requested not to */ if (!priv->mouse_scroll) return FALSE; if (clutter_event_is_pointer_emulated ((ClutterEvent *) event)) return TRUE; switch (event->direction) { case CLUTTER_SCROLL_SMOOTH: { gdouble delta_x, delta_y; clutter_event_get_scroll_delta ((ClutterEvent *)event, &delta_x, &delta_y); st_adjustment_adjust_for_scroll_event (priv->hadjustment, delta_x); st_adjustment_adjust_for_scroll_event (priv->vadjustment, delta_y); } break; case CLUTTER_SCROLL_UP: case CLUTTER_SCROLL_DOWN: adjust_with_direction (priv->vadjustment, event->direction); break; case CLUTTER_SCROLL_LEFT: case CLUTTER_SCROLL_RIGHT: adjust_with_direction (priv->hadjustment, event->direction); break; } return TRUE; }
static gboolean st_button_touch_event (ClutterActor *actor, ClutterTouchEvent *event) { StButton *button = ST_BUTTON (actor); StButtonPrivate *priv = st_button_get_instance_private (button); StButtonMask mask = ST_BUTTON_MASK_FROM_BUTTON (1); ClutterEventSequence *sequence; ClutterInputDevice *device; if (priv->pressed != 0) return CLUTTER_EVENT_PROPAGATE; if ((priv->button_mask & mask) == 0) return CLUTTER_EVENT_PROPAGATE; device = clutter_event_get_device ((ClutterEvent*) event); sequence = clutter_event_get_event_sequence ((ClutterEvent*) event); if (event->type == CLUTTER_TOUCH_BEGIN && !priv->press_sequence) { clutter_input_device_sequence_grab (device, sequence, actor); if (!clutter_event_is_pointer_emulated ((ClutterEvent*) event)) st_button_press (button, device, 0, sequence); return CLUTTER_EVENT_STOP; } else if (event->type == CLUTTER_TOUCH_END && priv->device == device && priv->press_sequence == sequence) { if (!clutter_event_is_pointer_emulated ((ClutterEvent*) event)) st_button_release (button, device, mask, 0, sequence); clutter_input_device_sequence_ungrab (device, sequence); return CLUTTER_EVENT_STOP; } else if (event->type == CLUTTER_TOUCH_CANCEL) { st_button_fake_release (button); } return CLUTTER_EVENT_PROPAGATE; }
static gboolean sequence_is_pointer_emulated (MetaDisplay *display, const ClutterEvent *event) { ClutterEventSequence *sequence; sequence = clutter_event_get_event_sequence (event); if (!sequence) return FALSE; if (clutter_event_is_pointer_emulated (event)) return TRUE; #ifdef HAVE_NATIVE_BACKEND MetaBackend *backend = meta_get_backend (); /* When using Clutter's native input backend there is no concept of * pointer emulating sequence, we still must make up our own to be * able to implement single-touch (hence pointer alike) behavior. * * This is implemented similarly to X11, where only the first touch * on screen gets the "pointer emulated" flag, and it won't get assigned * to another sequence until the next first touch on an idle touchscreen. */ if (META_IS_BACKEND_NATIVE (backend)) { MetaGestureTracker *tracker; tracker = meta_display_get_gesture_tracker (display); if (event->type == CLUTTER_TOUCH_BEGIN && meta_gesture_tracker_get_n_current_touches (tracker) == 0) return TRUE; } #endif /* HAVE_NATIVE_BACKEND */ return FALSE; }