mouse 1.0.5 → 1.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/History.markdown CHANGED
@@ -1,3 +1,8 @@
1
+ # 1.0.6 - Boogs
2
+
3
+ * Fix `Mouse.scroll` assuming arguments always included units
4
+ * Fix `Mouse.scroll` assuming amount was always positive (d'oh)
5
+
1
6
  # 1.0.5 - Tweaks for AXElements
2
7
 
3
8
  * Coerce `CGPoint.new` arguments using `#to_f`
data/README.markdown CHANGED
@@ -56,6 +56,7 @@ change in the future if there are enough complaints.
56
56
 
57
57
  * Support for mouse gestures
58
58
  * Make animation duration accurate (current naiveté has a bit of error)
59
+ * Import test app and specialize so we can have better tests
59
60
 
60
61
 
61
62
  ## Copyright
data/ext/mouse/mouse.c CHANGED
@@ -9,6 +9,7 @@ static ID sel_to_point;
9
9
  static ID sel_to_i;
10
10
  static ID sel_new;
11
11
  static ID unit_pixel;
12
+ static ID unit_line;
12
13
 
13
14
  #define CURRENT_POSITION rb_mouse_wrap_point(mouse_current_position())
14
15
 
@@ -118,8 +119,6 @@ rb_mouse_drag_to(int argc, VALUE *argv, VALUE self)
118
119
  * Returns number of lines scrolled. A positive `amount` will scroll up
119
120
  * and a negative `amount` will scroll down.
120
121
  *
121
- * An invalid type of `units` will default to `:line`.
122
- *
123
122
  * @param amount [Number]
124
123
  * @param units [Symbol] `:pixel` or `:line` (_default_: `:line` ) (__optional__)
125
124
  * @return [Number]
@@ -131,19 +130,23 @@ rb_mouse_scroll(int argc, VALUE *argv, VALUE self)
131
130
  if (argc == 0 || argc > 3)
132
131
  rb_raise(rb_eArgError, "scroll requires 1..3 arguments, you gave %d", argc);
133
132
 
134
- VALUE amount = rb_funcall(argv[0], sel_to_i, 0);
135
- size_t amt = NUM2SIZET(amount);
133
+ VALUE amount = rb_funcall(argv[0], sel_to_i, 0);
134
+ int amt = NUM2INT(amount);
136
135
 
137
- if (argc == 1)
138
- mouse_scroll(NUM2SIZET(amt));
136
+ if (argc == 1) {
137
+ mouse_scroll(amt);
138
+ return amount;
139
+ }
139
140
 
140
141
  ID units = rb_to_id(argv[1]);
141
142
 
142
143
  if (argc == 2) {
143
144
  if (units == unit_pixel)
144
145
  mouse_scroll2(amt, kCGScrollEventUnitPixel);
145
- else
146
+ else if (units == unit_line)
146
147
  mouse_scroll2(amt, kCGScrollEventUnitLine);
148
+ else
149
+ rb_raise(rb_eArgError, "unknown units `%s'", rb_id2name(units));
147
150
  }
148
151
 
149
152
  if (argc == 3) {
@@ -151,8 +154,10 @@ rb_mouse_scroll(int argc, VALUE *argv, VALUE self)
151
154
 
152
155
  if (units == unit_pixel)
153
156
  mouse_scroll3(amt, kCGScrollEventUnitPixel, duration);
154
- else
157
+ else if (units == unit_line)
155
158
  mouse_scroll3(amt, kCGScrollEventUnitLine, duration);
159
+ else
160
+ rb_raise(rb_eArgError, "unknown units `%s'", rb_id2name(units));
156
161
  }
157
162
 
158
163
  return amount;
@@ -456,6 +461,7 @@ Init_mouse()
456
461
  sel_new = rb_intern("new");
457
462
 
458
463
  unit_pixel = rb_intern("pixel");
464
+ unit_line = rb_intern("line");
459
465
 
460
466
  /*
461
467
  * Document-module: Mouse
data/ext/mouse/mouser.c CHANGED
@@ -148,7 +148,7 @@ mouse_drag_to(CGPoint point)
148
148
 
149
149
 
150
150
  void
151
- mouse_scroll3(size_t amount, CGScrollEventUnit units, double duration)
151
+ mouse_scroll3(int amount, CGScrollEventUnit units, double duration)
152
152
  {
153
153
  size_t steps = round(FPS * duration);
154
154
  double current = 0.0;
@@ -165,13 +165,13 @@ mouse_scroll3(size_t amount, CGScrollEventUnit units, double duration)
165
165
  }
166
166
 
167
167
  void
168
- mouse_scroll2(size_t amount, CGScrollEventUnit units)
168
+ mouse_scroll2(int amount, CGScrollEventUnit units)
169
169
  {
170
170
  mouse_scroll3(amount, units, DEFAULT_DURATION);
171
171
  }
172
172
 
173
173
  void
174
- mouse_scroll(size_t amount)
174
+ mouse_scroll(int amount)
175
175
  {
176
176
  mouse_scroll2(amount, kCGScrollEventUnitLine);
177
177
  }
data/ext/mouse/mouser.h CHANGED
@@ -18,9 +18,9 @@ void mouse_move_to2(CGPoint point, double duration);
18
18
  void mouse_drag_to(CGPoint point);
19
19
  void mouse_drag_to2(CGPoint point, double duration);
20
20
 
21
- void mouse_scroll(size_t amount);
22
- void mouse_scroll2(size_t amount, CGScrollEventUnit units);
23
- void mouse_scroll3(size_t amount, CGScrollEventUnit units, double duration);
21
+ void mouse_scroll(int amount);
22
+ void mouse_scroll2(int amount, CGScrollEventUnit units);
23
+ void mouse_scroll3(int amount, CGScrollEventUnit units, double duration);
24
24
 
25
25
  void mouse_click_down();
26
26
  void mouse_click_down2(CGPoint point);
data/lib/mouse/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Mouse
2
- VERSION = '1.0.5'
2
+ VERSION = '1.0.6'
3
3
  end
4
4
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mouse
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -98,18 +98,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
98
98
  - - ! '>='
99
99
  - !ruby/object:Gem::Version
100
100
  version: '0'
101
- segments:
102
- - 0
103
- hash: -2345337379390693889
104
101
  required_rubygems_version: !ruby/object:Gem::Requirement
105
102
  none: false
106
103
  requirements:
107
104
  - - ! '>='
108
105
  - !ruby/object:Gem::Version
109
106
  version: '0'
110
- segments:
111
- - 0
112
- hash: -2345337379390693889
113
107
  requirements: []
114
108
  rubyforge_project:
115
109
  rubygems_version: 1.8.24