summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Aguirre <aguirre.nicolas@gmail.com>2015-01-29 17:04:28 +0100
committerCedric BAIL <cedric@osg.samsung.com>2015-02-05 16:38:07 +0100
commit61fbb2ffd9e2b197041a776ec2e629b6cda7c97e (patch)
tree91b9176fd70230b23393ff83156fdbbbcfd50f07
parentff9eb2e8e7e33cf12688df5ce7221a32582f1f58 (diff)
ecore_cocoa: don't send mouse event with negative x or y values.
With cocoa you may have negatives values when Mouse Down or Up. This changes fix this behavior by sending mouse event only if x and y are inside the ecore_evas space. Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
-rw-r--r--src/lib/ecore_cocoa/ecore_cocoa.m37
1 files changed, 30 insertions, 7 deletions
diff --git a/src/lib/ecore_cocoa/ecore_cocoa.m b/src/lib/ecore_cocoa/ecore_cocoa.m
index c93a4b00b7..1a094bcbc7 100644
--- a/src/lib/ecore_cocoa/ecore_cocoa.m
+++ b/src/lib/ecore_cocoa/ecore_cocoa.m
@@ -150,15 +150,26 @@ ecore_cocoa_feed_events(void *anEvent)
150 { 150 {
151 if (_has_ecore_cocoa_window(event)) 151 if (_has_ecore_cocoa_window(event))
152 { 152 {
153 Ecore_Event_Mouse_Button * ev = calloc(1, sizeof(Ecore_Event_Mouse_Button));
154 if (!ev) return pass;
155
156 EcoreCocoaWindow *window = (EcoreCocoaWindow *)[event window]; 153 EcoreCocoaWindow *window = (EcoreCocoaWindow *)[event window];
157 NSView *view = [window contentView]; 154 NSView *view = [window contentView];
158 NSPoint pt = [event locationInWindow]; 155 NSPoint pt = [event locationInWindow];
159 156
157 int w = [view frame].size.width;
158 int h = [view frame].size.height;
159 int x = pt.x;
160 int y = h - pt.y;
161
162 if (y <= 0 || x <= 0 || y > h || x > w)
163 {
164 pass = EINA_TRUE;
165 break;
166 }
167
168 Ecore_Event_Mouse_Button * ev = calloc(1, sizeof(Ecore_Event_Mouse_Button));
169 if (!ev) return pass;
170
160 ev->x = pt.x; 171 ev->x = pt.x;
161 ev->y = [view frame].size.height - pt.y; 172 ev->y = y;
162 ev->root.x = ev->x; 173 ev->root.x = ev->x;
163 ev->root.y = ev->y; 174 ev->root.y = ev->y;
164 ev->timestamp = time; 175 ev->timestamp = time;
@@ -196,8 +207,6 @@ ecore_cocoa_feed_events(void *anEvent)
196 case NSRightMouseUp: 207 case NSRightMouseUp:
197 case NSOtherMouseUp: 208 case NSOtherMouseUp:
198 { 209 {
199 Ecore_Event_Mouse_Button * ev = calloc(1, sizeof(Ecore_Event_Mouse_Button));
200 if (!ev) return pass;
201 210
202 if (_has_ecore_cocoa_window(event)) 211 if (_has_ecore_cocoa_window(event))
203 { 212 {
@@ -205,8 +214,22 @@ ecore_cocoa_feed_events(void *anEvent)
205 NSView *view = [window contentView]; 214 NSView *view = [window contentView];
206 NSPoint pt = [event locationInWindow]; 215 NSPoint pt = [event locationInWindow];
207 216
217 int w = [view frame].size.width;
218 int h = [view frame].size.height;
219 int x = pt.x;
220 int y = h - pt.y;
221
222 if (y <= 0 || x <= 0 || y > h || x > w)
223 {
224 pass = EINA_TRUE;
225 break;
226 }
227
228 Ecore_Event_Mouse_Button * ev = calloc(1, sizeof(Ecore_Event_Mouse_Button));
229 if (!ev) return pass;
230
208 ev->x = pt.x; 231 ev->x = pt.x;
209 ev->y = [view frame].size.height - pt.y; 232 ev->y = y;
210 ev->root.x = ev->x; 233 ev->root.x = ev->x;
211 ev->root.y = ev->y; 234 ev->root.y = ev->y;
212 ev->timestamp = time; 235 ev->timestamp = time;