~jpakkane/+junk/geis_multiopen_crash

« back to all changes in this revision

Viewing changes to src/gripgesturemanager.c

  • Committer: Jussi Pakkanen
  • Date: 2011-06-16 07:32:24 UTC
  • mfrom: (41.1.2 libgrip)
  • Revision ID: jussi.pakkanen@canonical.com-20110616073224-euxty627u9d617zz
Merged deduplication.

Show diffs side-by-side

added added

removed removed

Lines of Context:
489
489
  return (x >= ax && x < ax + alloc.width && y >= ay && y < ay + alloc.height);
490
490
}
491
491
 
 
492
 
 
493
static void process_gesture (void         *cookie,
 
494
                       GeisGestureType    type,
 
495
                       GeisGestureId      id,
 
496
                       GeisSize           attr_count,
 
497
                       GeisGestureAttr   *attrs,
 
498
                       GripTimeType       time_type)
 
499
{
 
500
  GripGestureRegistration *reg = (GripGestureRegistration *)cookie;
 
501
  GList *l = NULL;
 
502
 
 
503
  for (l = reg->bindings; l != NULL; l = l->next)
 
504
    {
 
505
      GripGestureBinding *binding = (GripGestureBinding *)l->data;
 
506
 
 
507
      if (binding->type == type)
 
508
        {
 
509
          GripGestureEvent *event = grip_gesture_event_new (type);
 
510
 
 
511
          if (type == GRIP_GESTURE_DRAG)
 
512
            {
 
513
              GripEventGestureDrag *drag = (GripEventGestureDrag *)event;
 
514
 
 
515
              drag->type    = type;
 
516
              drag->id      = id;
 
517
              drag->fingers = drag_gesture_handle_properties (drag,
 
518
                  attr_count,
 
519
                  attrs);
 
520
 
 
521
              if (drag->fingers == binding->touches)
 
522
                {
 
523
                  if (matches_widget (binding->widget,
 
524
                                      gtk_widget_get_window(GTK_WIDGET (reg->window)),
 
525
                                      (gint)drag->focus_x,
 
526
                                      (gint)drag->focus_y))
 
527
                    {
 
528
                      binding->callback (binding->widget,
 
529
                                         time_type,
 
530
                                         event,
 
531
                                         binding->data);
 
532
                    }
 
533
                }
 
534
            }
 
535
          else if (type == GRIP_GESTURE_PINCH)
 
536
            {
 
537
              GripEventGesturePinch *pinch = (GripEventGesturePinch *)event;
 
538
 
 
539
              pinch->type    = type;
 
540
              pinch->id      = id;
 
541
              pinch->fingers = pinch_gesture_handle_properties (pinch,
 
542
                  attr_count,
 
543
                  attrs);
 
544
 
 
545
              if (pinch->fingers == binding->touches)
 
546
                {
 
547
                  if (matches_widget (binding->widget,
 
548
                                      gtk_widget_get_window(GTK_WIDGET(reg->window)),
 
549
                                      (gint)pinch->focus_x,
 
550
                                      (gint)pinch->focus_y))
 
551
                    {
 
552
                      binding->callback (binding->widget,
 
553
                                         time_type,
 
554
                                         event,
 
555
                                         binding->data);
 
556
                    }
 
557
                }
 
558
            }
 
559
          else if (type == GRIP_GESTURE_ROTATE)
 
560
            {
 
561
              GripEventGestureRotate *rotate = (GripEventGestureRotate *)event;
 
562
 
 
563
              rotate->type    = type;
 
564
              rotate->id      = id;
 
565
              rotate->fingers = rotate_gesture_handle_properties (rotate,
 
566
                  attr_count,
 
567
                  attrs);
 
568
 
 
569
              if (rotate->fingers == binding->touches)
 
570
                {
 
571
                  if (matches_widget (binding->widget,
 
572
                                      gtk_widget_get_window(GTK_WIDGET (reg->window)),
 
573
                                      (gint)rotate->focus_x,
 
574
                                      (gint)rotate->focus_y))
 
575
                    {
 
576
                      binding->callback (binding->widget,
 
577
                                         time_type,
 
578
                                         event,
 
579
                                         binding->data);
 
580
                    }
 
581
                }
 
582
            }
 
583
          else if (type == GRIP_GESTURE_TAP)
 
584
            {
 
585
              GripEventGestureTap *tap = (GripEventGestureTap *)event;
 
586
 
 
587
              tap->type    = type;
 
588
              tap->id      = id;
 
589
              tap->fingers = tap_gesture_handle_properties (tap,
 
590
                  attr_count,
 
591
                  attrs);
 
592
 
 
593
              if (tap->fingers == binding->touches)
 
594
                {
 
595
                  if (matches_widget (binding->widget,
 
596
                                      gtk_widget_get_window(GTK_WIDGET (reg->window)),
 
597
                                      (gint)tap->focus_x,
 
598
                                      (gint)tap->focus_y))
 
599
                    {
 
600
                      binding->callback (binding->widget,
 
601
                                         time_type,
 
602
                                         event,
 
603
                                         binding->data);
 
604
                    }
 
605
                }
 
606
            }
 
607
 
 
608
          grip_gesture_event_free (event);
 
609
        }
 
610
    }
 
611
}
 
612
 
492
613
static void
493
614
gesture_start (void              *cookie,
494
615
               GeisGestureType    type,
496
617
               GeisSize           attr_count,
497
618
               GeisGestureAttr   *attrs)
498
619
{
499
 
  GripGestureRegistration *reg = (GripGestureRegistration *)cookie;
500
 
  GList *l = NULL;
501
 
 
502
 
  for (l = reg->bindings; l != NULL; l = l->next)
503
 
    {
504
 
      GripGestureBinding *binding = (GripGestureBinding *)l->data;
505
 
 
506
 
      if (binding->type == type)
507
 
        {
508
 
          GripGestureEvent *event = grip_gesture_event_new (type);
509
 
 
510
 
          if (type == GRIP_GESTURE_DRAG)
511
 
            {
512
 
              GripEventGestureDrag *drag = (GripEventGestureDrag *)event;
513
 
 
514
 
              drag->type    = type;
515
 
              drag->id      = id;
516
 
              drag->fingers = drag_gesture_handle_properties (drag,
517
 
                                                              attr_count,
518
 
                                                              attrs);
519
 
 
520
 
              if (drag->fingers == binding->touches)
521
 
                {
522
 
                  if (matches_widget (binding->widget,
523
 
                                      gtk_widget_get_window(GTK_WIDGET (reg->window)),
524
 
                                      (gint)drag->focus_x,
525
 
                                      (gint)drag->focus_y))
526
 
                    {
527
 
                      binding->callback (binding->widget,
528
 
                                         GRIP_TIME_START,
529
 
                                         event,
530
 
                                         binding->data);
531
 
                    }
532
 
                }
533
 
            }
534
 
          else if (type == GRIP_GESTURE_PINCH)
535
 
            {
536
 
              GripEventGesturePinch *pinch = (GripEventGesturePinch *)event;
537
 
 
538
 
              pinch->type    = type;
539
 
              pinch->id      = id;
540
 
              pinch->fingers = pinch_gesture_handle_properties (pinch,
541
 
                                                                attr_count,
542
 
                                                                attrs);
543
 
 
544
 
              if (pinch->fingers == binding->touches)
545
 
                {
546
 
                  if (matches_widget (binding->widget,
547
 
                                      gtk_widget_get_window(GTK_WIDGET(reg->window)),
548
 
                                      (gint)pinch->focus_x,
549
 
                                      (gint)pinch->focus_y))
550
 
                    {
551
 
                      binding->callback (binding->widget,
552
 
                                         GRIP_TIME_START,
553
 
                                         event,
554
 
                                         binding->data);
555
 
                    }
556
 
                }
557
 
            }
558
 
          else if (type == GRIP_GESTURE_ROTATE)
559
 
            {
560
 
              GripEventGestureRotate *rotate = (GripEventGestureRotate *)event;
561
 
 
562
 
              rotate->type    = type;
563
 
              rotate->id      = id;
564
 
              rotate->fingers = rotate_gesture_handle_properties (rotate,
565
 
                                                                  attr_count,
566
 
                                                                  attrs);
567
 
 
568
 
              if (rotate->fingers == binding->touches)
569
 
                {
570
 
                  if (matches_widget (binding->widget,
571
 
                                      gtk_widget_get_window(GTK_WIDGET (reg->window)),
572
 
                                      (gint)rotate->focus_x,
573
 
                                      (gint)rotate->focus_y))
574
 
                    {
575
 
                      binding->callback (binding->widget,
576
 
                                         GRIP_TIME_START,
577
 
                                         event,
578
 
                                         binding->data);
579
 
                    }
580
 
                }
581
 
            }
582
 
          else if (type == GRIP_GESTURE_TAP)
583
 
            {
584
 
              GripEventGestureTap *tap = (GripEventGestureTap *)event;
585
 
 
586
 
              tap->type    = type;
587
 
              tap->id      = id;
588
 
              tap->fingers = tap_gesture_handle_properties (tap,
589
 
                                                            attr_count,
590
 
                                                            attrs);
591
 
 
592
 
              if (tap->fingers == binding->touches)
593
 
                {
594
 
                  if (matches_widget (binding->widget,
595
 
                                      gtk_widget_get_window(GTK_WIDGET (reg->window)),
596
 
                                      (gint)tap->focus_x,
597
 
                                      (gint)tap->focus_y))
598
 
                    {
599
 
                      binding->callback (binding->widget,
600
 
                                         GRIP_TIME_START,
601
 
                                         event,
602
 
                                         binding->data);
603
 
                    }
604
 
                }
605
 
            }
606
 
 
607
 
          grip_gesture_event_free (event);
608
 
        }
609
 
    }
 
620
  process_gesture(cookie, type, id, attr_count, attrs, GRIP_TIME_START);
610
621
}
611
622
 
612
623
static void
616
627
                GeisSize           attr_count,
617
628
                GeisGestureAttr   *attrs)
618
629
{
619
 
  GripGestureRegistration *reg = (GripGestureRegistration *)cookie;
620
 
  GList *l = NULL;
621
 
 
622
 
  for (l = reg->bindings; l != NULL; l = l->next)
623
 
    {
624
 
      GripGestureBinding *binding = (GripGestureBinding *)l->data;
625
 
 
626
 
      if (binding->type == type)
627
 
        {
628
 
          GripGestureEvent *event = grip_gesture_event_new (type);
629
 
 
630
 
          if (type == GRIP_GESTURE_DRAG)
631
 
            {
632
 
              GripEventGestureDrag *drag = (GripEventGestureDrag *)event;
633
 
 
634
 
              drag->type    = type;
635
 
              drag->id      = id;
636
 
              drag->fingers = drag_gesture_handle_properties (drag,
637
 
                                                              attr_count,
638
 
                                                              attrs);
639
 
 
640
 
              if (drag->fingers == binding->touches)
641
 
                {
642
 
                  if (matches_widget (binding->widget,
643
 
                                      gtk_widget_get_window(GTK_WIDGET (reg->window)),
644
 
                                      (gint)drag->focus_x,
645
 
                                      (gint)drag->focus_y))
646
 
                    {
647
 
                      binding->callback (binding->widget,
648
 
                                         GRIP_TIME_UPDATE,
649
 
                                         event,
650
 
                                         binding->data);
651
 
                    }
652
 
                }
653
 
            }
654
 
          else if (type == GRIP_GESTURE_PINCH)
655
 
            {
656
 
              GripEventGesturePinch *pinch = (GripEventGesturePinch *)event;
657
 
 
658
 
              pinch->type    = type;
659
 
              pinch->id      = id;
660
 
              pinch->fingers = pinch_gesture_handle_properties (pinch,
661
 
                                                                attr_count,
662
 
                                                                attrs);
663
 
 
664
 
              if (pinch->fingers == binding->touches)
665
 
                {
666
 
                  if (matches_widget (binding->widget,
667
 
                                      gtk_widget_get_window(GTK_WIDGET (reg->window)),
668
 
                                      (gint)pinch->focus_x,
669
 
                                      (gint)pinch->focus_y))
670
 
                    {
671
 
                      binding->callback (binding->widget,
672
 
                                         GRIP_TIME_UPDATE,
673
 
                                         event,
674
 
                                         binding->data);
675
 
                    }
676
 
                }
677
 
            }
678
 
          else if (type == GRIP_GESTURE_ROTATE)
679
 
            {
680
 
              GripEventGestureRotate *rotate = (GripEventGestureRotate *)event;
681
 
 
682
 
              rotate->type    = type;
683
 
              rotate->id      = id;
684
 
              rotate->fingers = rotate_gesture_handle_properties (rotate,
685
 
                                                                  attr_count,
686
 
                                                                  attrs);
687
 
 
688
 
              if (rotate->fingers == binding->touches)
689
 
                {
690
 
                  if (matches_widget (binding->widget,
691
 
                                      gtk_widget_get_window(GTK_WIDGET (reg->window)),
692
 
                                      (gint)rotate->focus_x,
693
 
                                      (gint)rotate->focus_y))
694
 
                    {
695
 
                      binding->callback (binding->widget,
696
 
                                         GRIP_TIME_UPDATE,
697
 
                                         event,
698
 
                                         binding->data);
699
 
                    }
700
 
                }
701
 
            }
702
 
          else if (type == GRIP_GESTURE_TAP)
703
 
            {
704
 
              GripEventGestureTap *tap = (GripEventGestureTap *)event;
705
 
 
706
 
              tap->type    = type;
707
 
              tap->id      = id;
708
 
              tap->fingers = tap_gesture_handle_properties (tap,
709
 
                                                            attr_count,
710
 
                                                            attrs);
711
 
 
712
 
              if (tap->fingers == binding->touches)
713
 
                {
714
 
                  if (matches_widget (binding->widget,
715
 
                                      gtk_widget_get_window(GTK_WIDGET (reg->window)),
716
 
                                      (gint)tap->focus_x,
717
 
                                      (gint)tap->focus_y))
718
 
                    {
719
 
                      binding->callback (binding->widget,
720
 
                                         GRIP_TIME_UPDATE,
721
 
                                         event,
722
 
                                         binding->data);
723
 
                    }
724
 
                }
725
 
            }
726
 
 
727
 
          grip_gesture_event_free (event);
728
 
        }
729
 
    }
 
630
  process_gesture(cookie, type, id, attr_count, attrs, GRIP_TIME_UPDATE);
730
631
}
731
632
 
732
633
static void
736
637
                GeisSize           attr_count,
737
638
                GeisGestureAttr   *attrs)
738
639
{
739
 
  GripGestureRegistration *reg = (GripGestureRegistration *)cookie;
740
 
  GList *l = NULL;
741
 
 
742
 
  for (l = reg->bindings; l != NULL; l = l->next)
743
 
    {
744
 
      GripGestureBinding *binding = (GripGestureBinding *)l->data;
745
 
 
746
 
      if (binding->type == type)
747
 
        {
748
 
          GripGestureEvent *event = grip_gesture_event_new (type);
749
 
 
750
 
          if (type == GRIP_GESTURE_DRAG)
751
 
            {
752
 
              GripEventGestureDrag *drag = (GripEventGestureDrag *)event;
753
 
 
754
 
              drag->type    = type;
755
 
              drag->id      = id;
756
 
              drag->fingers = drag_gesture_handle_properties (drag,
757
 
                                                              attr_count,
758
 
                                                              attrs);
759
 
 
760
 
              if (drag->fingers == binding->touches)
761
 
                {
762
 
                  if (matches_widget (binding->widget,
763
 
                                      gtk_widget_get_window(GTK_WIDGET (reg->window)),
764
 
                                      (gint)drag->focus_x,
765
 
                                      (gint)drag->focus_y))
766
 
                    {
767
 
                      binding->callback (binding->widget,
768
 
                                         GRIP_TIME_END,
769
 
                                         event,
770
 
                                         binding->data);
771
 
                    }
772
 
                }
773
 
            }
774
 
          else if (type == GRIP_GESTURE_PINCH)
775
 
            {
776
 
              GripEventGesturePinch *pinch = (GripEventGesturePinch *)event;
777
 
 
778
 
              pinch->type    = type;
779
 
              pinch->id      = id;
780
 
              pinch->fingers = pinch_gesture_handle_properties (pinch,
781
 
                                                                attr_count,
782
 
                                                                attrs);
783
 
 
784
 
              if (pinch->fingers == binding->touches)
785
 
                {
786
 
                  if (matches_widget (binding->widget,
787
 
                                      gtk_widget_get_window(GTK_WIDGET (reg->window)),
788
 
                                      (gint)pinch->focus_x,
789
 
                                      (gint)pinch->focus_y))
790
 
                    {
791
 
                      binding->callback (binding->widget,
792
 
                                         GRIP_TIME_END,
793
 
                                         event,
794
 
                                         binding->data);
795
 
                    }
796
 
                }
797
 
            }
798
 
          else if (type == GRIP_GESTURE_ROTATE)
799
 
            {
800
 
              GripEventGestureRotate *rotate = (GripEventGestureRotate *)event;
801
 
 
802
 
              rotate->type    = type;
803
 
              rotate->id      = id;
804
 
              rotate->fingers = rotate_gesture_handle_properties (rotate,
805
 
                                                                  attr_count,
806
 
                                                                  attrs);
807
 
 
808
 
              if (rotate->fingers == binding->touches)
809
 
                {
810
 
                  if (matches_widget (binding->widget,
811
 
                                      gtk_widget_get_window(GTK_WIDGET (reg->window)),
812
 
                                      (gint)rotate->focus_x,
813
 
                                      (gint)rotate->focus_y))
814
 
                    {
815
 
                      binding->callback (binding->widget,
816
 
                                         GRIP_TIME_END,
817
 
                                         event,
818
 
                                         binding->data);
819
 
                    }
820
 
                }
821
 
            }
822
 
          else if (type == GRIP_GESTURE_TAP)
823
 
            {
824
 
              GripEventGestureTap *tap = (GripEventGestureTap *)event;
825
 
 
826
 
              tap->type    = type;
827
 
              tap->id      = id;
828
 
              tap->fingers = tap_gesture_handle_properties (tap,
829
 
                                                            attr_count,
830
 
                                                            attrs);
831
 
 
832
 
              if (tap->fingers == binding->touches)
833
 
                {
834
 
                  if (matches_widget (binding->widget,
835
 
                                      gtk_widget_get_window(GTK_WIDGET (reg->window)),
836
 
                                      (gint)tap->focus_x,
837
 
                                      (gint)tap->focus_y))
838
 
                    {
839
 
                      binding->callback (binding->widget,
840
 
                                         GRIP_TIME_END,
841
 
                                         event,
842
 
                                         binding->data);
843
 
                    }
844
 
                }
845
 
            }
846
 
 
847
 
          grip_gesture_event_free (event);
848
 
        }
849
 
    }
 
640
  process_gesture(cookie, type, id, attr_count, attrs, GRIP_TIME_END);
850
641
}
851
642
 
852
643
static void