From 901ed3256863118b28bd843e56449b9ee51160da Mon Sep 17 00:00:00 2001 From: Viatcheslav Gachkaylo Date: Thu, 3 Feb 2011 14:51:20 +0600 Subject: [PATCH] Fixed bugs with mouse events. Enter/leave events are now being received. Mouse move events now work properly. Signed-off-by: Emmanuele Bassi http://bugzilla.clutter-project.org/show_bug.cgi?id=2545 --- clutter/Makefile.am | 2 ++ clutter/osx/clutter-backend-osx.c | 3 ++- clutter/osx/clutter-backend-osx.h | 7 +++++-- clutter/osx/clutter-device-manager-osx.h | 2 ++ clutter/osx/clutter-event-loop-osx.c | 2 +- clutter/osx/clutter-event-osx.c | 10 ++++++---- clutter/osx/clutter-stage-osx.c | 6 ++++++ 7 files changed, 24 insertions(+), 8 deletions(-) diff --git a/clutter/Makefile.am b/clutter/Makefile.am index 4fc246628..811a7c570 100644 --- a/clutter/Makefile.am +++ b/clutter/Makefile.am @@ -502,11 +502,13 @@ osx_source_h_priv = \ $(srcdir)/osx/clutter-backend-osx.h \ $(srcdir)/osx/clutter-event-loop-osx.h \ $(srcdir)/osx/clutter-stage-osx.h \ + $(srcdir)/osx/clutter-device-manager-osx.h \ $(NULL) osx_source_c_priv = \ $(srcdir)/osx/clutter-event-loop-osx.c \ $(srcdir)/osx/clutter-event-osx.c \ + $(srcdir)/osx/clutter-device-manager-osx.c \ $(NULL) if SUPPORT_OSX diff --git a/clutter/osx/clutter-backend-osx.c b/clutter/osx/clutter-backend-osx.c index 13dd09c57..425bd8729 100644 --- a/clutter/osx/clutter-backend-osx.c +++ b/clutter/osx/clutter-backend-osx.c @@ -3,6 +3,7 @@ * * Copyright (C) 2007-2008 Tommi Komulainen * Copyright (C) 2007 OpenedHand Ltd. + * Copyright (C) 2011 Crystalnix * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -95,7 +96,7 @@ clutter_backend_osx_create_device_manager (ClutterBackendOSX *backend_osx) return; backend_osx->device_manager = g_object_new (CLUTTER_TYPE_DEVICE_MANAGER_OSX, - "backend", backend, + "backend", CLUTTER_BACKEND(backend_osx), NULL); } diff --git a/clutter/osx/clutter-backend-osx.h b/clutter/osx/clutter-backend-osx.h index 339bcb8af..8651bbcf5 100644 --- a/clutter/osx/clutter-backend-osx.h +++ b/clutter/osx/clutter-backend-osx.h @@ -3,6 +3,7 @@ * * Copyright (C) 2007 Tommi Komulainen * Copyright (C) 2007 OpenedHand Ltd. + * Copyright (C) 2011 Crystalnix * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -23,6 +24,7 @@ #define __CLUTTER_BACKEND_OSX_H__ #include "clutter-backend-private.h" +#include "clutter-device-manager.h" @class NSOpenGLPixelFormat, NSOpenGLContext; @@ -42,8 +44,9 @@ struct _ClutterBackendOSX { ClutterBackend parent; - NSOpenGLPixelFormat *pixel_format; - NSOpenGLContext *context; + NSOpenGLPixelFormat *pixel_format; + NSOpenGLContext *context; + ClutterDeviceManager *device_manager; }; struct _ClutterBackendOSXClass diff --git a/clutter/osx/clutter-device-manager-osx.h b/clutter/osx/clutter-device-manager-osx.h index f9ca189e7..300513fc7 100644 --- a/clutter/osx/clutter-device-manager-osx.h +++ b/clutter/osx/clutter-device-manager-osx.h @@ -42,6 +42,8 @@ struct _ClutterDeviceManagerOSX { ClutterDeviceManager parent_instance; + GSList *devices; + ClutterInputDevice *core_pointer; ClutterInputDevice *core_keyboard; }; diff --git a/clutter/osx/clutter-event-loop-osx.c b/clutter/osx/clutter-event-loop-osx.c index 80f7332f1..c8fdd3f94 100644 --- a/clutter/osx/clutter-event-loop-osx.c +++ b/clutter/osx/clutter-event-loop-osx.c @@ -27,7 +27,7 @@ #include "clutter-stage-osx.h" #import -#include +#include #include #include #include diff --git a/clutter/osx/clutter-event-osx.c b/clutter/osx/clutter-event-osx.c index 67c24c7da..a06fa3b9b 100644 --- a/clutter/osx/clutter-event-osx.c +++ b/clutter/osx/clutter-event-osx.c @@ -278,6 +278,8 @@ clutter_event_osx_translate (NSEvent *nsevent, stage_osx = CLUTTER_STAGE_OSX (impl); manager_osx = CLUTTER_DEVICE_MANAGER_OSX (clutter_device_manager_get_default ()); + event->any.time = [nsevent clutterTime]; + switch ([nsevent type]) { case NSLeftMouseDown: @@ -324,7 +326,7 @@ clutter_event_osx_translate (NSEvent *nsevent, [nsevent clutterX:&(event->crossing.x) y:&(event->crossing.y)]; event->crossing.related = NULL; - event->crossing.actor = CLUTTER_ACTOR (stage); + event->crossing.source = CLUTTER_ACTOR (stage); clutter_event_set_device (event, manager_osx->core_pointer); _clutter_stage_add_device (stage, manager_osx->core_pointer); @@ -338,7 +340,7 @@ clutter_event_osx_translate (NSEvent *nsevent, [nsevent clutterX:&(event->crossing.x) y:&(event->crossing.y)]; event->crossing.related = NULL; - event->crossing.actor = CLUTTER_ACTOR (stage); + event->crossing.source = CLUTTER_ACTOR (stage); clutter_event_set_device (event, manager_osx->core_pointer); _clutter_stage_remove_device (stage, manager_osx->core_pointer); @@ -398,9 +400,9 @@ _clutter_event_osx_put (NSEvent *nsevent, event->any.stage = wrapper; event->any.time = [nsevent clutterTime]; - if (clutter_event_osx_translate (nsevent, &event)) + if (clutter_event_osx_translate (nsevent, event)) { - g_assert (event.type != CLUTTER_NOTHING); + g_assert (event->type != CLUTTER_NOTHING); _clutter_event_push (event, FALSE); } diff --git a/clutter/osx/clutter-stage-osx.c b/clutter/osx/clutter-stage-osx.c index 5d7a1faaa..56408dc22 100644 --- a/clutter/osx/clutter-stage-osx.c +++ b/clutter/osx/clutter-stage-osx.c @@ -3,6 +3,7 @@ * * Copyright (C) 2007-2008 Tommi Komulainen * Copyright (C) 2007 OpenedHand Ltd. + * Copyright (C) 2011 Crystalnix * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -135,6 +136,7 @@ clutter_stage_osx_get_wrapper (ClutterStageWindow *stage_window); @interface ClutterGLView : NSOpenGLView { ClutterStageOSX *stage_osx; + NSTrackingRectTag tracking_rect; } - (void) drawRect: (NSRect) bounds; @end @@ -145,6 +147,7 @@ clutter_stage_osx_get_wrapper (ClutterStageWindow *stage_window); if ((self = [super initWithFrame:aFrame pixelFormat:aFormat]) != nil) { self->stage_osx = aStage; + tracking_rect = [self addTrackingRect:[self bounds] owner:self userData:NULL assumeInside:NO]; } return self; @@ -176,6 +179,9 @@ clutter_stage_osx_get_wrapper (ClutterStageWindow *stage_window); stage_osx->requisition_height = [self bounds].size.height; clutter_actor_set_size (CLUTTER_ACTOR (self->stage_osx->wrapper), (int)[self bounds].size.width, (int)[self bounds].size.height); + + [self removeTrackingRect:tracking_rect]; + tracking_rect = [self addTrackingRect:[self bounds] owner:self userData:NULL assumeInside:NO]; } /* Simply forward all events that reach our view to clutter. */