~ubuntu-branches/ubuntu/precise/libgrip/precise

« back to all changes in this revision

Viewing changes to examples/rectangle-mover/gesture.c

  • Committer: Bazaar Package Importer
  • Author(s): Chase Douglas
  • Date: 2011-08-09 16:33:26 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20110809163326-p2ky362j7dbl0d99
Tags: 0.3.0-0ubuntu1
* New upstream release.
  - Add documentation (LP: #744911)
  - Expose device type and attributes

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <math.h>
1
2
#include <stdlib.h>
2
3
#include <string.h>
3
4
#include <signal.h>
71
72
        case GRIP_GESTURE_PINCH:
72
73
          {
73
74
            GripEventGesturePinch *e = (GripEventGesturePinch *)event;
74
 
 
75
 
            scale += e->radius_delta / 100;
 
75
            GtkWindow *toplevel = (GtkWindow *)gtk_widget_get_toplevel (widget);
 
76
            gint window_width, window_height;
 
77
            AxisExtents *x = grip_input_device_get_x_extents (e->input_device);
 
78
            AxisExtents *y = grip_input_device_get_y_extents (e->input_device);
 
79
            gfloat width = 0;
 
80
            gfloat height = 0;
 
81
            gfloat factor = 0;
 
82
 
 
83
            gtk_window_get_size (toplevel, &window_width, &window_height);
 
84
            width = window_width / (x->maximum - x->minimum);
 
85
            height = window_height / (y->maximum - y->minimum);
 
86
            factor = sqrtf (width * width + height * height) / 5.2723;
 
87
 
 
88
            scale += e->radius_delta * factor;
76
89
          }
77
90
          break;
78
91