Fixed bugs with mouse events.

Enter/leave events are now being received. Mouse move events
now work properly.

Signed-off-by: Emmanuele Bassi <ebassi@linux.intel.com>

http://bugzilla.clutter-project.org/show_bug.cgi?id=2545
This commit is contained in:
Viatcheslav Gachkaylo 2011-02-03 14:51:20 +06:00 committed by Emmanuele Bassi
parent cef380040d
commit 901ed32568
7 changed files with 24 additions and 8 deletions

View File

@ -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

View File

@ -3,6 +3,7 @@
*
* Copyright (C) 2007-2008 Tommi Komulainen <tommi.komulainen@iki.fi>
* Copyright (C) 2007 OpenedHand Ltd.
* Copyright (C) 2011 Crystalnix <vgachkaylo@crystalnix.com>
*
* 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);
}

View File

@ -3,6 +3,7 @@
*
* Copyright (C) 2007 Tommi Komulainen <tommi.komulainen@iki.fi>
* Copyright (C) 2007 OpenedHand Ltd.
* Copyright (C) 2011 Crystalnix <vgachkaylo@crystalnix.com>
*
* 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;
@ -44,6 +46,7 @@ struct _ClutterBackendOSX
NSOpenGLPixelFormat *pixel_format;
NSOpenGLContext *context;
ClutterDeviceManager *device_manager;
};
struct _ClutterBackendOSXClass

View File

@ -42,6 +42,8 @@ struct _ClutterDeviceManagerOSX
{
ClutterDeviceManager parent_instance;
GSList *devices;
ClutterInputDevice *core_pointer;
ClutterInputDevice *core_keyboard;
};

View File

@ -27,7 +27,7 @@
#include "clutter-stage-osx.h"
#import <AppKit/AppKit.h>
#include <glib/gmain.h>
#include <glib.h>
#include <pthread.h>
#include <sys/types.h>
#include <sys/uio.h>

View File

@ -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);
}

View File

@ -3,6 +3,7 @@
*
* Copyright (C) 2007-2008 Tommi Komulainen <tommi.komulainen@iki.fi>
* Copyright (C) 2007 OpenedHand Ltd.
* Copyright (C) 2011 Crystalnix <vgachkaylo@gmail.com>
*
* 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. */