cedric pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=61fbb2ffd9e2b197041a776ec2e629b6cda7c97e
commit 61fbb2ffd9e2b197041a776ec2e629b6cda7c97e Author: Nicolas Aguirre <aguirre.nico...@gmail.com> Date: Thu Jan 29 17:04:28 2015 +0100 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 <ced...@osg.samsung.com> --- src/lib/ecore_cocoa/ecore_cocoa.m | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/src/lib/ecore_cocoa/ecore_cocoa.m b/src/lib/ecore_cocoa/ecore_cocoa.m index c93a4b0..1a094bc 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) { if (_has_ecore_cocoa_window(event)) { - Ecore_Event_Mouse_Button * ev = calloc(1, sizeof(Ecore_Event_Mouse_Button)); - if (!ev) return pass; - EcoreCocoaWindow *window = (EcoreCocoaWindow *)[event window]; NSView *view = [window contentView]; NSPoint pt = [event locationInWindow]; + int w = [view frame].size.width; + int h = [view frame].size.height; + int x = pt.x; + int y = h - pt.y; + + if (y <= 0 || x <= 0 || y > h || x > w) + { + pass = EINA_TRUE; + break; + } + + Ecore_Event_Mouse_Button * ev = calloc(1, sizeof(Ecore_Event_Mouse_Button)); + if (!ev) return pass; + ev->x = pt.x; - ev->y = [view frame].size.height - pt.y; + ev->y = y; ev->root.x = ev->x; ev->root.y = ev->y; ev->timestamp = time; @@ -196,8 +207,6 @@ ecore_cocoa_feed_events(void *anEvent) case NSRightMouseUp: case NSOtherMouseUp: { - Ecore_Event_Mouse_Button * ev = calloc(1, sizeof(Ecore_Event_Mouse_Button)); - if (!ev) return pass; if (_has_ecore_cocoa_window(event)) { @@ -205,8 +214,22 @@ ecore_cocoa_feed_events(void *anEvent) NSView *view = [window contentView]; NSPoint pt = [event locationInWindow]; + int w = [view frame].size.width; + int h = [view frame].size.height; + int x = pt.x; + int y = h - pt.y; + + if (y <= 0 || x <= 0 || y > h || x > w) + { + pass = EINA_TRUE; + break; + } + + Ecore_Event_Mouse_Button * ev = calloc(1, sizeof(Ecore_Event_Mouse_Button)); + if (!ev) return pass; + ev->x = pt.x; - ev->y = [view frame].size.height - pt.y; + ev->y = y; ev->root.x = ev->x; ev->root.y = ev->y; ev->timestamp = time; --