Ejemplo n.º 1
0
static void
gtk_gesture_multi_press_cancel (GtkGesture       *gesture,
                                GdkEventSequence *sequence)
{
    _gtk_gesture_multi_press_stop (GTK_GESTURE_MULTI_PRESS (gesture));
    GTK_GESTURE_CLASS (gtk_gesture_multi_press_parent_class)->cancel (gesture, sequence);
}
Ejemplo n.º 2
0
static void
gtk_gesture_multi_press_begin (GtkGesture       *gesture,
                               GdkEventSequence *sequence)
{
    GtkGestureMultiPress *multi_press;
    GtkGestureMultiPressPrivate *priv;
    guint n_presses, button = 1;
    GdkEventSequence *current;
    const GdkEvent *event;
    GdkDevice *device;
    gdouble x, y;

    if (!gtk_gesture_handles_sequence (gesture, sequence))
        return;

    multi_press = GTK_GESTURE_MULTI_PRESS (gesture);
    priv = gtk_gesture_multi_press_get_instance_private (multi_press);
    event = gtk_gesture_get_last_event (gesture, sequence);
    current = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
    device = gdk_event_get_source_device (event);

    if (event->type == GDK_BUTTON_PRESS)
        button = event->button.button;
    else if (event->type == GDK_TOUCH_BEGIN)
        button = 1;
    else
        return;

    /* Reset the gesture if the button number changes mid-recognition */
    if (priv->n_presses > 0 &&
            priv->current_button != button)
        _gtk_gesture_multi_press_stop (multi_press);

    /* Reset also if the device changed */
    if (priv->current_device && priv->current_device != device)
        _gtk_gesture_multi_press_stop (multi_press);

    priv->current_device = device;
    priv->current_button = button;
    _gtk_gesture_multi_press_update_timeout (multi_press);
    gtk_gesture_get_point (gesture, current, &x, &y);

    if (!_gtk_gesture_multi_press_check_within_threshold (multi_press, x, y))
        _gtk_gesture_multi_press_stop (multi_press);

    /* Increment later the real counter, just if the gesture is
     * reset on the pressed handler */
    n_presses = priv->n_release = priv->n_presses + 1;

    g_signal_emit (gesture, signals[PRESSED], 0, n_presses, x, y);

    if (priv->n_presses == 0)
    {
        priv->initial_press_x = x;
        priv->initial_press_y = y;
    }

    priv->n_presses++;
}
Ejemplo n.º 3
0
static void
gtk_gesture_multi_press_update (GtkGesture       *gesture,
                                GdkEventSequence *sequence)
{
    GtkGestureMultiPress *multi_press;
    GdkEventSequence *current;
    gdouble x, y;

    multi_press = GTK_GESTURE_MULTI_PRESS (gesture);
    current = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
    gtk_gesture_get_point (gesture, current, &x, &y);

    if (!_gtk_gesture_multi_press_check_within_threshold (multi_press, x, y))
        _gtk_gesture_multi_press_stop (multi_press);
}
Ejemplo n.º 4
0
static gboolean
gtk_gesture_multi_press_check (GtkGesture *gesture)
{
    GtkGestureMultiPress *multi_press;
    GtkGestureMultiPressPrivate *priv;
    GList *sequences;
    gboolean active;

    multi_press = GTK_GESTURE_MULTI_PRESS (gesture);
    priv = gtk_gesture_multi_press_get_instance_private (multi_press);
    sequences = gtk_gesture_get_sequences (gesture);

    active = g_list_length (sequences) == 1 || priv->double_click_timeout_id;
    g_list_free (sequences);

    return active;
}
Ejemplo n.º 5
0
static void
gtk_gesture_multi_press_finalize (GObject *object)
{
    GtkGestureMultiPressPrivate *priv;
    GtkGestureMultiPress *gesture;

    gesture = GTK_GESTURE_MULTI_PRESS (object);
    priv = gtk_gesture_multi_press_get_instance_private (gesture);

    if (priv->double_click_timeout_id)
    {
        g_source_remove (priv->double_click_timeout_id);
        priv->double_click_timeout_id = 0;
    }

    G_OBJECT_CLASS (gtk_gesture_multi_press_parent_class)->finalize (object);
}
Ejemplo n.º 6
0
static void
gtk_gesture_multi_press_end (GtkGesture       *gesture,
                             GdkEventSequence *sequence)
{
    GtkGestureMultiPress *multi_press;
    GtkGestureMultiPressPrivate *priv;
    GdkEventSequence *current;
    gdouble x, y;

    multi_press = GTK_GESTURE_MULTI_PRESS (gesture);
    priv = gtk_gesture_multi_press_get_instance_private (multi_press);
    current = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
    gtk_gesture_get_point (gesture, current, &x, &y);

    g_signal_emit (gesture, signals[RELEASED], 0, priv->n_release, x, y);
    priv->n_release = 0;
}
Ejemplo n.º 7
0
static void
gtk_gesture_multi_press_end (GtkGesture       *gesture,
                             GdkEventSequence *sequence)
{
  GtkGestureMultiPress *multi_press;
  GtkGestureMultiPressPrivate *priv;
  GdkEventSequence *current;
  gdouble x, y;
  gboolean interpreted;
  GtkEventSequenceState state;

  multi_press = GTK_GESTURE_MULTI_PRESS (gesture);
  priv = gtk_gesture_multi_press_get_instance_private (multi_press);
  current = gtk_gesture_single_get_current_sequence (GTK_GESTURE_SINGLE (gesture));
  interpreted = gtk_gesture_get_point (gesture, current, &x, &y);
  state = gtk_gesture_get_sequence_state (gesture, current);

  if (state != GTK_EVENT_SEQUENCE_DENIED && interpreted)
    g_signal_emit (gesture, signals[RELEASED], 0, priv->n_release, x, y);

  priv->n_release = 0;
}
Ejemplo n.º 8
0
static void
gtk_gesture_multi_press_reset (GtkEventController *controller)
{
    _gtk_gesture_multi_press_stop (GTK_GESTURE_MULTI_PRESS (controller));
    GTK_EVENT_CONTROLLER_CLASS (gtk_gesture_multi_press_parent_class)->reset (controller);
}
Ejemplo n.º 9
0
static void
gtk_gesture_multi_press_cancel (GtkGesture       *gesture,
                                GdkEventSequence *sequence)
{
  _gtk_gesture_multi_press_stop (GTK_GESTURE_MULTI_PRESS (gesture));
}