2007-10-26 18:06:45 -04:00
|
|
|
/* Clutter - An OpenGL based 'interactive canvas' library.
|
|
|
|
* OSX backend - event loops integration
|
|
|
|
*
|
OSX: add multistage support
Bug #911 - OSX: add multistage support
* clutter/osx/clutter-backend-osx.{c,h}
(clutter_backend_osx_init_stage, clutter_backend_osx_get_stage,
clutter_backend_osx_redraw, clutter_backend_osx_create_stage,
clutter_backend_osx_ensure_context, clutter_backend_osx_class_init,
clutter_backend_osx_dispose, ClutterGLView:drawRect:):
* clutter/osx/clutter-stage-osx.{c,h} (clutter_stage_osx_realize,
ClutterGLWindow:setFrameSize:):
Adapt to new multistage backend API. Don't keep a pointer to
default stage. Derive from ClutterActor instead of ClutterStage.
Implement ClutterStageWindow interface. Paint, resize and
otherwise manipulate the wrapper rather than self when necessary.
(clutter_backend_post_parse): Create our singleton GL context
here. We could probably create the context when the default
stage is created, but I think this is more clean.
* clutter/osx/clutter-event-osx.c (clutter_event_osx_translate)
* clutter/osx/clutter-stage-osx.c (clutter_stage_osx_state_update,
ClutterGLWindow:windowShouldClose:):
* clutter/osx/clutter-stage-osx.h: Export ClutterGLWindow interface
for clutter-event-osx.c to easily get the stage for NSWindow.
Fill in ClutterEventAny::stage on our events.
Consistently use 'stage_osx' and 'wrapper' as variable names
when referring to ClutterStageOSX and ClutterStage objects
respectively.
2008-06-05 17:27:58 -04:00
|
|
|
* Copyright (C) 2007-2008 Tommi Komulainen <tommi.komulainen@iki.fi>
|
2007-10-26 18:06:45 -04:00
|
|
|
* Copyright (C) 2007 OpenedHand Ltd.
|
2011-01-28 07:56:57 -05:00
|
|
|
* Copyright (C) 2011 Crystalnix <vgachkaylo@crystalnix.com>
|
2007-10-26 18:06:45 -04:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2010-03-01 07:56:10 -05:00
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*
|
2007-10-26 18:06:45 -04:00
|
|
|
*/
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include "clutter-osx.h"
|
2011-01-28 09:53:08 -05:00
|
|
|
|
|
|
|
#include "clutter-device-manager-osx.h"
|
OSX: add multistage support
Bug #911 - OSX: add multistage support
* clutter/osx/clutter-backend-osx.{c,h}
(clutter_backend_osx_init_stage, clutter_backend_osx_get_stage,
clutter_backend_osx_redraw, clutter_backend_osx_create_stage,
clutter_backend_osx_ensure_context, clutter_backend_osx_class_init,
clutter_backend_osx_dispose, ClutterGLView:drawRect:):
* clutter/osx/clutter-stage-osx.{c,h} (clutter_stage_osx_realize,
ClutterGLWindow:setFrameSize:):
Adapt to new multistage backend API. Don't keep a pointer to
default stage. Derive from ClutterActor instead of ClutterStage.
Implement ClutterStageWindow interface. Paint, resize and
otherwise manipulate the wrapper rather than self when necessary.
(clutter_backend_post_parse): Create our singleton GL context
here. We could probably create the context when the default
stage is created, but I think this is more clean.
* clutter/osx/clutter-event-osx.c (clutter_event_osx_translate)
* clutter/osx/clutter-stage-osx.c (clutter_stage_osx_state_update,
ClutterGLWindow:windowShouldClose:):
* clutter/osx/clutter-stage-osx.h: Export ClutterGLWindow interface
for clutter-event-osx.c to easily get the stage for NSWindow.
Fill in ClutterEventAny::stage on our events.
Consistently use 'stage_osx' and 'wrapper' as variable names
when referring to ClutterStageOSX and ClutterStage objects
respectively.
2008-06-05 17:27:58 -04:00
|
|
|
#include "clutter-stage-osx.h"
|
2007-10-26 18:06:45 -04:00
|
|
|
|
|
|
|
#import <AppKit/AppKit.h>
|
2010-10-15 07:40:43 -04:00
|
|
|
|
|
|
|
#include <glib.h>
|
2011-02-18 11:27:49 -05:00
|
|
|
|
|
|
|
#include "clutter-debug.h"
|
|
|
|
#include "clutter-device-manager.h"
|
|
|
|
#include "clutter-event-private.h"
|
|
|
|
#include "clutter-keysyms.h"
|
|
|
|
#include "clutter-private.h"
|
|
|
|
#include "clutter-stage-private.h"
|
2007-10-26 18:06:45 -04:00
|
|
|
|
2011-01-28 07:56:57 -05:00
|
|
|
#include "clutter-event-loop-osx.h"
|
2007-10-26 18:06:45 -04:00
|
|
|
|
2011-01-28 07:56:57 -05:00
|
|
|
#define WHEEL_DELTA 1
|
2007-10-26 18:06:45 -04:00
|
|
|
|
|
|
|
/*************************************************************************/
|
|
|
|
@interface NSEvent (Clutter)
|
|
|
|
- (gint)clutterTime;
|
|
|
|
- (gint)clutterButton;
|
2009-07-26 15:13:36 -04:00
|
|
|
- (void)clutterX:(gfloat*)ptrX y:(gfloat*)ptrY;
|
2007-10-26 18:06:45 -04:00
|
|
|
- (gint)clutterModifierState;
|
|
|
|
- (guint)clutterKeyVal;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation NSEvent (Clutter)
|
|
|
|
- (gint)clutterTime
|
|
|
|
{
|
|
|
|
return [self timestamp] * 1000;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (gint)clutterButton
|
|
|
|
{
|
|
|
|
switch ([self buttonNumber])
|
|
|
|
{
|
|
|
|
case 0: return 1; /* left */
|
|
|
|
case 1: return 3; /* right */
|
|
|
|
case 2: return 2; /* middle */
|
|
|
|
default: return 1 + [self buttonNumber];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-26 15:13:36 -04:00
|
|
|
- (void)clutterX:(gfloat*)ptrX y:(gfloat*)ptrY
|
2007-10-26 18:06:45 -04:00
|
|
|
{
|
|
|
|
NSView *view = [[self window] contentView];
|
|
|
|
NSPoint pt = [view convertPoint:[self locationInWindow] fromView:nil];
|
|
|
|
|
2009-07-26 15:13:36 -04:00
|
|
|
*ptrX = pt.x;
|
|
|
|
*ptrY = pt.y;
|
2007-10-26 18:06:45 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
- (gint)clutterModifierState
|
|
|
|
{
|
|
|
|
guint mods = [self modifierFlags];
|
2010-10-14 13:23:02 -04:00
|
|
|
guint type = [self type];
|
2007-10-26 18:06:45 -04:00
|
|
|
gint rv = 0;
|
|
|
|
|
2010-10-14 13:23:02 -04:00
|
|
|
/* add key masks */
|
2007-10-26 18:06:45 -04:00
|
|
|
if (mods & NSAlphaShiftKeyMask)
|
|
|
|
rv |= CLUTTER_LOCK_MASK;
|
|
|
|
if (mods & NSShiftKeyMask)
|
|
|
|
rv |= CLUTTER_SHIFT_MASK;
|
|
|
|
if (mods & NSControlKeyMask)
|
|
|
|
rv |= CLUTTER_CONTROL_MASK;
|
|
|
|
if (mods & NSAlternateKeyMask)
|
|
|
|
rv |= CLUTTER_MOD1_MASK;
|
|
|
|
if (mods & NSCommandKeyMask)
|
|
|
|
rv |= CLUTTER_MOD2_MASK;
|
|
|
|
|
2010-10-14 13:23:02 -04:00
|
|
|
/* add button mask */
|
|
|
|
if ((type == NSLeftMouseDragged) ||
|
|
|
|
(type == NSRightMouseDragged) ||
|
|
|
|
(type == NSOtherMouseDragged))
|
|
|
|
rv |= CLUTTER_BUTTON1_MASK << [self buttonNumber];
|
|
|
|
|
2007-10-26 18:06:45 -04:00
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (guint)clutterKeyVal
|
|
|
|
{
|
|
|
|
/* FIXME: doing this right is a lot of work, see gdkkeys-quartz.c in gtk+
|
|
|
|
* For now handle some common/simple keys only. Might not work with other
|
|
|
|
* hardware than mine (MacBook Pro, finnish layout). Sorry.
|
2008-06-29 06:31:05 -04:00
|
|
|
*
|
|
|
|
* charactersIgnoringModifiers ignores most modifiers, not Shift though.
|
|
|
|
* So, for all Shift-modified keys we'll end up reporting 'keyval' identical
|
|
|
|
* to 'unicode_value' Instead of <Shift>a or <Shift>3 you'd get <Shift>A
|
|
|
|
* and <Shift>#
|
2007-10-26 18:06:45 -04:00
|
|
|
*/
|
2008-06-10 06:57:50 -04:00
|
|
|
unichar c = [[self charactersIgnoringModifiers] characterAtIndex:0];
|
2007-10-26 18:06:45 -04:00
|
|
|
|
|
|
|
/* Latin-1 characters, 1:1 mapping - this ought to be reliable */
|
|
|
|
if ((c >= 0x0020 && c <= 0x007e) ||
|
|
|
|
(c >= 0x00a0 && c <= 0x00ff))
|
|
|
|
return c;
|
|
|
|
|
|
|
|
switch (c)
|
|
|
|
{
|
|
|
|
/* these should be fairly standard */
|
|
|
|
/* (maybe add 0x0008 (Ctrl+H) for backspace too) */
|
2010-10-10 04:31:55 -04:00
|
|
|
case 0x000d:
|
|
|
|
return CLUTTER_KEY_Return;
|
|
|
|
case 0x001b:
|
|
|
|
return CLUTTER_KEY_Escape;
|
|
|
|
case 0x007f:
|
|
|
|
return CLUTTER_KEY_BackSpace;
|
2007-10-26 18:06:45 -04:00
|
|
|
/* Defined in NSEvent.h */
|
2010-10-10 04:31:55 -04:00
|
|
|
case NSUpArrowFunctionKey:
|
|
|
|
return CLUTTER_KEY_Up;
|
|
|
|
case NSDownArrowFunctionKey:
|
|
|
|
return CLUTTER_KEY_Down;
|
|
|
|
case NSLeftArrowFunctionKey:
|
|
|
|
return CLUTTER_KEY_Left;
|
|
|
|
case NSRightArrowFunctionKey:
|
|
|
|
return CLUTTER_KEY_Right;
|
|
|
|
case NSF1FunctionKey:
|
|
|
|
return CLUTTER_KEY_F1;
|
|
|
|
case NSF2FunctionKey:
|
|
|
|
return CLUTTER_KEY_F2;
|
|
|
|
case NSF3FunctionKey:
|
|
|
|
return CLUTTER_KEY_F3;
|
|
|
|
case NSF4FunctionKey:
|
|
|
|
return CLUTTER_KEY_F4;
|
|
|
|
case NSF5FunctionKey:
|
|
|
|
return CLUTTER_KEY_F5;
|
|
|
|
case NSF6FunctionKey:
|
|
|
|
return CLUTTER_KEY_F6;
|
|
|
|
case NSF7FunctionKey:
|
|
|
|
return CLUTTER_KEY_F7;
|
|
|
|
case NSF8FunctionKey:
|
|
|
|
return CLUTTER_KEY_F8;
|
|
|
|
case NSF9FunctionKey:
|
|
|
|
return CLUTTER_KEY_F9;
|
|
|
|
case NSF10FunctionKey:
|
|
|
|
return CLUTTER_KEY_F10;
|
|
|
|
case NSF11FunctionKey:
|
|
|
|
return CLUTTER_KEY_F11;
|
|
|
|
case NSF12FunctionKey:
|
|
|
|
return CLUTTER_KEY_F12;
|
|
|
|
case NSInsertFunctionKey:
|
|
|
|
return CLUTTER_KEY_Insert;
|
|
|
|
case NSDeleteFunctionKey:
|
|
|
|
return CLUTTER_KEY_Delete;
|
|
|
|
case NSHomeFunctionKey:
|
|
|
|
return CLUTTER_KEY_Home;
|
|
|
|
case NSEndFunctionKey:
|
|
|
|
return CLUTTER_KEY_End;
|
|
|
|
case NSPageUpFunctionKey:
|
|
|
|
return CLUTTER_KEY_Page_Up;
|
|
|
|
case NSPageDownFunctionKey:
|
|
|
|
return CLUTTER_KEY_Page_Down;
|
2007-10-26 18:06:45 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
CLUTTER_NOTE (BACKEND, "unhandled unicode key 0x%x (%d)", c, c);
|
|
|
|
|
|
|
|
/* hardware dependent, worksforme(tm) Redundant due to above, left around as
|
|
|
|
* example.
|
|
|
|
*/
|
|
|
|
switch ([self keyCode])
|
|
|
|
{
|
2010-10-10 04:31:55 -04:00
|
|
|
case 115:
|
|
|
|
return CLUTTER_KEY_Home;
|
|
|
|
case 116:
|
|
|
|
return CLUTTER_KEY_Page_Up;
|
|
|
|
case 117:
|
|
|
|
return CLUTTER_KEY_Delete;
|
|
|
|
case 119:
|
|
|
|
return CLUTTER_KEY_End;
|
|
|
|
case 121:
|
|
|
|
return CLUTTER_KEY_Page_Down;
|
|
|
|
case 123:
|
|
|
|
return CLUTTER_KEY_Left;
|
|
|
|
case 124:
|
|
|
|
return CLUTTER_KEY_Right;
|
|
|
|
case 125:
|
|
|
|
return CLUTTER_KEY_Down;
|
|
|
|
case 126:
|
|
|
|
return CLUTTER_KEY_Up;
|
2007-10-26 18:06:45 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
@end
|
|
|
|
|
|
|
|
/*************************************************************************/
|
2011-01-28 07:56:57 -05:00
|
|
|
|
|
|
|
static void
|
|
|
|
take_and_queue_event (ClutterEvent *event)
|
|
|
|
{
|
2011-02-02 09:43:38 -05:00
|
|
|
_clutter_event_push (event, FALSE);
|
2011-01-28 07:56:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-01-28 09:53:08 -05:00
|
|
|
process_scroll_event (ClutterEvent *event,
|
|
|
|
gboolean isVertical)
|
2011-01-28 07:56:57 -05:00
|
|
|
{
|
2011-02-15 06:34:21 -05:00
|
|
|
ClutterStageWindow *impl;
|
2011-01-28 07:56:57 -05:00
|
|
|
ClutterStageOSX *stage_osx;
|
2011-02-15 06:34:21 -05:00
|
|
|
gfloat *scroll_pos;
|
|
|
|
|
|
|
|
impl = _clutter_stage_get_window (event->any.stage);
|
|
|
|
stage_osx = CLUTTER_STAGE_OSX (impl);
|
2011-01-28 07:56:57 -05:00
|
|
|
|
2011-02-15 06:34:21 -05:00
|
|
|
scroll_pos = isVertical
|
|
|
|
? &(stage_osx->scroll_pos_y)
|
|
|
|
: &(stage_osx->scroll_pos_x);
|
2011-01-28 07:56:57 -05:00
|
|
|
|
|
|
|
while (abs (*scroll_pos) >= WHEEL_DELTA)
|
|
|
|
{
|
|
|
|
ClutterEvent *event_gen = clutter_event_new (CLUTTER_SCROLL);
|
|
|
|
|
|
|
|
event_gen->scroll.time = event->any.time;
|
|
|
|
event_gen->scroll.modifier_state = event->scroll.modifier_state;
|
|
|
|
event_gen->any.stage = event->any.stage;
|
|
|
|
|
|
|
|
event_gen->scroll.x = event->scroll.x;
|
|
|
|
event_gen->scroll.y = event->scroll.y;
|
|
|
|
|
|
|
|
if (*scroll_pos > 0)
|
|
|
|
{
|
|
|
|
event_gen->scroll.direction = isVertical ? CLUTTER_SCROLL_UP : CLUTTER_SCROLL_RIGHT;
|
|
|
|
*scroll_pos -= WHEEL_DELTA;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
event_gen->scroll.direction = isVertical ? CLUTTER_SCROLL_DOWN : CLUTTER_SCROLL_LEFT;
|
|
|
|
*scroll_pos += WHEEL_DELTA;
|
|
|
|
}
|
|
|
|
|
2011-01-28 09:53:08 -05:00
|
|
|
clutter_event_set_device (event_gen, clutter_event_get_device (event));
|
|
|
|
|
2011-01-28 07:56:57 -05:00
|
|
|
take_and_queue_event (event_gen);
|
|
|
|
|
|
|
|
CLUTTER_NOTE (EVENT, "scroll %s at %f,%f",
|
|
|
|
(event_gen->scroll.direction == CLUTTER_SCROLL_UP) ? "UP" :
|
|
|
|
(
|
|
|
|
(event_gen->scroll.direction == CLUTTER_SCROLL_DOWN) ? "DOWN" :
|
|
|
|
(
|
|
|
|
(event_gen->scroll.direction == CLUTTER_SCROLL_RIGHT) ? "RIGHT" : "LEFT")),
|
2011-01-28 09:53:08 -05:00
|
|
|
event->scroll.x, event->scroll.y);
|
2011-01-28 07:56:57 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-26 18:06:45 -04:00
|
|
|
static gboolean
|
2011-01-28 09:53:08 -05:00
|
|
|
clutter_event_osx_translate (NSEvent *nsevent,
|
|
|
|
ClutterEvent *event)
|
|
|
|
{
|
|
|
|
ClutterDeviceManagerOSX *manager_osx;
|
2011-01-28 07:56:57 -05:00
|
|
|
ClutterStageOSX *stage_osx;
|
2011-01-28 09:53:08 -05:00
|
|
|
ClutterStageWindow *impl;
|
|
|
|
ClutterStage *stage;
|
|
|
|
|
|
|
|
stage = event->any.stage;
|
2011-01-28 07:56:57 -05:00
|
|
|
impl = _clutter_stage_get_window (event->any.stage);
|
|
|
|
stage_osx = CLUTTER_STAGE_OSX (impl);
|
2011-01-28 09:53:08 -05:00
|
|
|
manager_osx = CLUTTER_DEVICE_MANAGER_OSX (clutter_device_manager_get_default ());
|
2007-10-26 18:06:45 -04:00
|
|
|
|
2011-02-03 03:51:20 -05:00
|
|
|
event->any.time = [nsevent clutterTime];
|
|
|
|
|
2007-10-26 18:06:45 -04:00
|
|
|
switch ([nsevent type])
|
|
|
|
{
|
|
|
|
case NSLeftMouseDown:
|
|
|
|
case NSRightMouseDown:
|
|
|
|
case NSOtherMouseDown:
|
|
|
|
event->type = CLUTTER_BUTTON_PRESS;
|
|
|
|
/* fall through */
|
|
|
|
case NSLeftMouseUp:
|
|
|
|
case NSRightMouseUp:
|
|
|
|
case NSOtherMouseUp:
|
|
|
|
if (event->type != CLUTTER_BUTTON_PRESS)
|
|
|
|
event->type = CLUTTER_BUTTON_RELEASE;
|
|
|
|
|
|
|
|
event->button.button = [nsevent clutterButton];
|
|
|
|
event->button.click_count = [nsevent clickCount];
|
|
|
|
event->motion.modifier_state = [nsevent clutterModifierState];
|
|
|
|
[nsevent clutterX:&(event->button.x) y:&(event->button.y)];
|
2011-01-28 09:53:08 -05:00
|
|
|
clutter_event_set_device (event, manager_osx->core_pointer);
|
2007-10-26 18:06:45 -04:00
|
|
|
|
2010-07-24 00:54:19 -04:00
|
|
|
CLUTTER_NOTE (EVENT, "button %d %s at %f,%f clicks=%d",
|
|
|
|
(int)[nsevent buttonNumber],
|
2007-10-26 18:06:45 -04:00
|
|
|
event->type == CLUTTER_BUTTON_PRESS ? "press" : "release",
|
2011-01-28 09:53:08 -05:00
|
|
|
event->button.x, event->button.y,
|
2007-10-26 18:06:45 -04:00
|
|
|
event->button.click_count);
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
case NSMouseMoved:
|
|
|
|
case NSLeftMouseDragged:
|
|
|
|
case NSRightMouseDragged:
|
|
|
|
case NSOtherMouseDragged:
|
|
|
|
event->type = CLUTTER_MOTION;
|
|
|
|
|
2009-07-26 15:13:36 -04:00
|
|
|
[nsevent clutterX:&(event->motion.x) y:&(event->motion.y)];
|
2007-10-26 18:06:45 -04:00
|
|
|
event->motion.modifier_state = [nsevent clutterModifierState];
|
2011-01-28 09:53:08 -05:00
|
|
|
clutter_event_set_device (event, manager_osx->core_pointer);
|
2007-10-26 18:06:45 -04:00
|
|
|
|
2010-07-24 00:54:19 -04:00
|
|
|
CLUTTER_NOTE (EVENT, "motion %d at %f,%f",
|
|
|
|
(int)[nsevent buttonNumber],
|
2011-01-28 09:53:08 -05:00
|
|
|
event->button.x, event->button.y);
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
case NSMouseEntered:
|
|
|
|
event->type = CLUTTER_ENTER;
|
|
|
|
|
|
|
|
[nsevent clutterX:&(event->crossing.x) y:&(event->crossing.y)];
|
|
|
|
event->crossing.related = NULL;
|
2011-02-03 03:51:20 -05:00
|
|
|
event->crossing.source = CLUTTER_ACTOR (stage);
|
2011-01-28 09:53:08 -05:00
|
|
|
clutter_event_set_device (event, manager_osx->core_pointer);
|
|
|
|
|
|
|
|
_clutter_stage_add_device (stage, manager_osx->core_pointer);
|
|
|
|
|
|
|
|
CLUTTER_NOTE (EVENT, "enter at %f,%f",
|
|
|
|
event->crossing.x, event->crossing.y);
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
case NSMouseExited:
|
|
|
|
event->type = CLUTTER_LEAVE;
|
|
|
|
|
|
|
|
[nsevent clutterX:&(event->crossing.x) y:&(event->crossing.y)];
|
|
|
|
event->crossing.related = NULL;
|
2011-02-03 03:51:20 -05:00
|
|
|
event->crossing.source = CLUTTER_ACTOR (stage);
|
2011-01-28 09:53:08 -05:00
|
|
|
clutter_event_set_device (event, manager_osx->core_pointer);
|
|
|
|
|
|
|
|
_clutter_stage_remove_device (stage, manager_osx->core_pointer);
|
|
|
|
|
|
|
|
CLUTTER_NOTE (EVENT, "exit at %f,%f",
|
|
|
|
event->crossing.x, event->crossing.y);
|
2007-10-26 18:06:45 -04:00
|
|
|
return TRUE;
|
|
|
|
|
2011-01-28 07:56:57 -05:00
|
|
|
case NSScrollWheel:
|
|
|
|
stage_osx->scroll_pos_x += [nsevent deltaX];
|
|
|
|
stage_osx->scroll_pos_y += [nsevent deltaY];
|
|
|
|
|
|
|
|
[nsevent clutterX:&(event->scroll.x) y:&(event->scroll.y)];
|
|
|
|
event->scroll.modifier_state = [nsevent clutterModifierState];
|
2011-01-28 09:53:08 -05:00
|
|
|
clutter_event_set_device (event, manager_osx->core_pointer);
|
2011-01-28 07:56:57 -05:00
|
|
|
|
2011-01-28 09:53:08 -05:00
|
|
|
process_scroll_event (event, TRUE);
|
|
|
|
process_scroll_event (event, FALSE);
|
|
|
|
break;
|
2011-01-28 07:56:57 -05:00
|
|
|
|
2007-10-26 18:06:45 -04:00
|
|
|
case NSKeyDown:
|
|
|
|
event->type = CLUTTER_KEY_PRESS;
|
|
|
|
/* fall through */
|
|
|
|
case NSKeyUp:
|
|
|
|
if (event->type != CLUTTER_KEY_PRESS)
|
|
|
|
event->type = CLUTTER_KEY_RELEASE;
|
|
|
|
|
|
|
|
event->key.hardware_keycode = [nsevent keyCode];
|
|
|
|
event->key.modifier_state = [nsevent clutterModifierState];
|
|
|
|
event->key.keyval = [nsevent clutterKeyVal];
|
2008-06-10 06:57:50 -04:00
|
|
|
event->key.unicode_value = [[nsevent characters] characterAtIndex:0];
|
2011-01-28 09:53:08 -05:00
|
|
|
clutter_event_set_device (event, manager_osx->core_keyboard);
|
2007-10-26 18:06:45 -04:00
|
|
|
|
|
|
|
CLUTTER_NOTE (EVENT, "key %d (%s) (%s) %s, keyval %d",
|
|
|
|
[nsevent keyCode],
|
|
|
|
[[nsevent characters] UTF8String],
|
|
|
|
[[nsevent charactersIgnoringModifiers] UTF8String],
|
|
|
|
event->type == CLUTTER_KEY_PRESS ? "press" : "release",
|
|
|
|
event->key.keyval);
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
default:
|
2010-07-24 00:54:19 -04:00
|
|
|
CLUTTER_NOTE (EVENT, "unhandled event %d", (int)[nsevent type]);
|
2007-10-26 18:06:45 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2011-02-02 09:41:57 -05:00
|
|
|
_clutter_event_osx_put (NSEvent *nsevent,
|
2011-01-28 09:53:08 -05:00
|
|
|
ClutterStage *wrapper)
|
2007-10-26 18:06:45 -04:00
|
|
|
{
|
2011-01-28 09:53:08 -05:00
|
|
|
ClutterEvent *event = clutter_event_new (CLUTTER_NOTHING);
|
2008-06-29 06:31:31 -04:00
|
|
|
|
2011-02-02 09:41:57 -05:00
|
|
|
/* common fields */
|
2011-01-28 09:53:08 -05:00
|
|
|
event->any.stage = wrapper;
|
2011-02-02 09:41:57 -05:00
|
|
|
event->any.time = [nsevent clutterTime];
|
2008-06-29 06:31:31 -04:00
|
|
|
|
2011-02-03 03:51:20 -05:00
|
|
|
if (clutter_event_osx_translate (nsevent, event))
|
2007-10-26 18:06:45 -04:00
|
|
|
{
|
2011-02-03 03:51:20 -05:00
|
|
|
g_assert (event->type != CLUTTER_NOTHING);
|
2011-01-28 09:53:08 -05:00
|
|
|
|
|
|
|
_clutter_event_push (event, FALSE);
|
2007-10-26 18:06:45 -04:00
|
|
|
}
|
2011-01-28 09:53:08 -05:00
|
|
|
else
|
|
|
|
clutter_event_free (event);
|
2007-10-26 18:06:45 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_clutter_events_osx_init (void)
|
|
|
|
{
|
2011-01-28 07:56:57 -05:00
|
|
|
_clutter_osx_event_loop_init ();
|
2007-10-26 18:06:45 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
_clutter_events_osx_uninit (void)
|
|
|
|
{
|
2011-01-28 07:56:57 -05:00
|
|
|
g_assert_not_reached ();
|
2007-10-26 18:06:45 -04:00
|
|
|
}
|