David 'onefang' Seikel <onefang@gmail.com>
Hisham 'CodeWarrior' Mardam Bey <hisham@hisham.cc>
Brian 'rephorm' Mattern <rephorm@rephorm.com>
+Tim Horton <hortont424@gmail.com>
ecore-x.pc \
ecore-win32.pc \
ecore-sdl.pc \
+ ecore-quartz.pc \
ecore-wince.pc \
ecore.pc
ecore-x.pc.in \
ecore-win32.pc.in \
ecore-sdl.pc.in \
+ ecore-quartz.pc.in \
ecore-wince.pc.in \
ecore.spec.in ecore.spec \
doc gendoc
pwince = ecore-wince.pc
endif
-
if BUILD_ECORE_SDL
psdl = ecore-sdl.pc
endif
+if BUILD_ECORE_QUARTZ
+pquartz = ecore-quartz.pc
+endif
+
if BUILD_ECORE_X_XCB
px = ecore-x.pc
endif
pkgconfig_DATA = \
ecore.pc $(pcon) $(pconfig) $(pdfb) $(pevas) \
$(pfb) $(pfile) $(pdesktop) $(pimf) $(pimfevas) $(pipc) $(pjob) $(ptxt) \
- $(px) $(pwin32) $(pwince) $(psdl)
+ $(px) $(pwin32) $(pwince) $(psdl) $(pquartz)
AC_C_BIGENDIAN
AC_PROG_CC
AM_PROG_CC_STDC
+m4_ifdef([AC_PROG_OBJC],
+ [AC_PROG_OBJC],
+ [AC_CHECK_TOOL([OBJC], [gcc])
+ AC_SUBST([OBJC])
+ AC_SUBST([OBJCFLAGS])
+ ])
+AC_PROG_OBJC
AC_HEADER_STDC
AC_C_CONST
AC_CHECK_SIZEOF(int, 4)
requirements_ecore_win32=""
requirements_ecore_wince=""
requirements_ecore_sdl=""
+requirements_ecore_quartz=""
dnl The first call to PKG_CHECK_MODULES is done conditionally,
dnl so we should include this here:
AC_DEFINE(EFL_ECORE_IMF_BUILD, 1, [Define to mention that ecore imf is built.])
AC_DEFINE(EFL_ECORE_JOB_BUILD, 1, [Define to mention that ecore job is built.])
AC_DEFINE(EFL_ECORE_SDL_BUILD, 1, [Define to mention that ecore SDL is built.])
+ AC_DEFINE(EFL_ECORE_QUARTZ_BUILD, 1, [Define to mention that ecore Quartz is built.])
AC_DEFINE(EFL_ECORE_TXT_BUILD, 1, [Define to mention that ecore txt is built.])
AC_DEFINE(EFL_ECORE_WIN32_BUILD, 1, [Define to mention that ecore Win32 is built.])
AC_DEFINE(HAVE_DLFCN_H, 1, [Define to 1 if you have the <dlfcn.h> header file.])
fi
fi
+dnl ecore_quartz
+
+quartz_cflags="";
+quartz_libs="";
+have_quartz="no"
+AC_CHECK_HEADER(Cocoa/Cocoa.h,
+ [ have_quartz="yes";
+ quartz_cflags="-framework Cocoa";
+ quartz_libs="-framework Cocoa" ],
+ [ have_quartz="no" ])
+
+ECORE_CHECK_MODULE([QUARTZ], [no], [$have_quartz])
+
+dnl ecore_evas_quartz
+have_ecore_evas_quartz="no";
+if test "x$have_ecore_quartz" = "xyes" -a "x$have_ecore_evas" = "xyes"; then
+ want_ecore_evas_quartz="yes";
+ AC_MSG_CHECKING([whether ecore_evas Quartz support is to be built])
+ AC_ARG_ENABLE(ecore-evas-quartz,
+ AC_HELP_STRING([--disable-ecore-evas-quartz], [disable Quartz in the ecore_evas module]),
+ [ want_ecore_evas_quartz=$enableval ]
+ )
+ AC_MSG_RESULT($want_ecore_evas_quartz)
+
+ if test "x$want_ecore_evas_quartz" = "xyes"; then
+ save_CFLAGS=$CFLAGS
+ QUARTZ_CFLAGS=`-framework Cocoa`
+ QUARTZ_LIBS=`-framework Cocoa`
+ CFLAGS="$CFLAGS $QUARTZ_CFLAGS"
+ AC_SUBST(QUARTZ_CFLAGS)
+ AC_SUBST(QUARTZ_LIBS)
+
+ PKG_CHECK_MODULES(EVAS_QUARTZ, evas-quartz, [
+ AC_DEFINE(BUILD_ECORE_EVAS_QUARTZ, 1, [Support for Quartz in Ecore_Evas])
+ have_ecore_evas_quartz="yes"
+ requirements_ecore_evas="$requirements_ecore_evas ecore-quartz"
+ ], [
+ have_ecore_evas_quartz="no"
+ ])
+ CFLAGS=$save_CFLAGS
+ fi
+fi
+
dnl ecore_evas_buffer
want_ecore_evas_buffer="yes";
have_ecore_evas_buffer="no";
AC_SUBST(requirements_ecore_txt)
AC_SUBST(requirements_ecore_x)
AC_SUBST(requirements_ecore_sdl)
+AC_SUBST(requirements_ecore_quartz)
# set up conditionals
AM_CONDITIONAL(BUILD_ECORE_X, test $have_ecore_x = yes)
ecore-x.pc
ecore-win32.pc
ecore-sdl.pc
+ecore-quartz.pc
ecore-wince.pc
ecore.pc
src/Makefile
src/lib/ecore_x/xcb/Makefile
src/lib/ecore_fb/Makefile
src/lib/ecore_sdl/Makefile
+src/lib/ecore_quartz/Makefile
src/lib/ecore_evas/Makefile
src/lib/ecore_con/Makefile
src/lib/ecore_imf/Makefile
fi
echo " Ecore_Win32..................: $have_ecore_win32"
echo " Ecore_SDL....................: $have_ecore_sdl"
+echo " Ecore_Quartz.................: $have_ecore_quartz"
echo " Ecore_FB.....................: $have_ecore_fb"
echo " Ecore_DFB....................: $have_ecore_directfb"
echo " Ecore_WinCE..................: $have_ecore_wince"
echo " Direct3D...................: $have_ecore_evas_direct3d"
echo " OpenGL Glew................: $have_ecore_evas_opengl_glew"
echo " Software SDL...............: $have_ecore_evas_sdl"
+ echo " Quartz.....................: $have_ecore_evas_quartz"
echo " DirectFB...................: $have_ecore_evas_dfb"
echo " Software Framebuffer.......: $have_ecore_evas_fb"
echo " Software 16bit X11.........: $have_ecore_evas_software_16_x11"
--- /dev/null
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@
+
+Name: ecore-quartz
+Description: E core library, Quartz module
+Requires: ecore @requirements_ecore_quartz@
+Version: @VERSION@
+Libs: -L${libdir} -lecore_quartz
+Cflags: -I${includedir}
ecore_win32 \
ecore_wince \
ecore_sdl \
+ecore_quartz \
ecore_ipc \
ecore_evas \
ecore_config \
ECORE_SDL_LIB =
endif
+if BUILD_ECORE_QUARTZ
+ECORE_QUARTZ_INC = -I$(top_srcdir)/src/lib/ecore_quartz @QUARTZ_CFLAGS@ -xobjective-c -framework Cocoa
+ECORE_QUARTZ_LIB = $(top_builddir)/src/lib/ecore_quartz/libecore_quartz.la
+else
+ECORE_QUARTZ_INC =
+ECORE_QUARTZ_LIB =
+endif
+
if BUILD_ECORE_WINCE
ECORE_WINCE_INC = -I$(top_srcdir)/src/lib/ecore_wince
ECORE_WINCE_LIB = $(top_builddir)/src/lib/ecore_wince/libecore_wince.la
$(ECORE_DIRECTFB_INC) \
$(ECORE_WIN32_INC) \
$(ECORE_SDL_INC) \
+$(ECORE_QUARTZ_INC) \
$(ECORE_WINCE_INC) \
@EVAS_CFLAGS@ \
@XCB_CFLAGS@
ecore_evas_directfb.c \
ecore_evas_win32.c \
ecore_evas_sdl.c \
+ecore_evas_quartz.c \
ecore_evas_wince.c
libecore_evas_la_LIBADD = \
$(ECORE_DIRECTFB_LIB) \
$(ECORE_WIN32_LIB) \
$(ECORE_SDL_LIB) \
+$(ECORE_QUARTZ_LIB) \
$(ECORE_WINCE_LIB) \
$(top_builddir)/src/lib/ecore/libecore.la \
@EVAS_LIBS@ \
@XCB_LIBS@ \
@SDL_LIBS@ \
+@QUARTZ_LIBS@ \
@EVIL_LIBS@
libecore_evas_la_LDFLAGS = @lt_no_undefined@ @lt_enable_auto_import@ -version-info @version_info@
$(ECORE_DIRECTFB_LIB) \
$(ECORE_WIN32_LIB) \
$(ECORE_SDL_LIB) \
+$(ECORE_QUARTZ_LIB) \
$(ECORE_WINCE_LIB) \
$(top_builddir)/src/lib/ecore/libecore.la
--- /dev/null
+#include "config.h"
+#ifdef BUILD_ECORE_EVAS_QUARTZ
+#import <Cocoa/Cocoa.h>
+#endif
+
+#include "Ecore.h"
+#include "ecore_private.h"
+#include "ecore_evas_private.h"
+#include "Ecore_Evas.h"
+
+#ifdef BUILD_ECORE_EVAS_QUARTZ
+#include "Ecore_Quartz.h"
+#include "Evas_Engine_Quartz.h"
+
+static int _ecore_evas_init_count = 0;
+static Ecore_Evas *ecore_evases = NULL;
+static Ecore_Event_Handler *ecore_evas_event_handlers[10] = {
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
+};
+static Ecore_Idle_Enterer *ecore_evas_idle_enterer = NULL;
+static Ecore_Idler *ecore_evas_event = NULL;
+
+static const char *ecore_evas_quartz_default = "EFL Quartz";
+
+@interface EvasView : NSView
+{
+ CGContextRef ctx;
+}
+@end
+
+static EvasView * evas_view;
+static NSWindow * main_window;
+
+@implementation EvasView
+
+- (id) init
+{
+ self = [super init];
+ if (self != nil)
+ {
+ ctx = NULL;
+ }
+ return self;
+}
+
+- (void)drawRect:(NSRect)rect
+{
+ if(ctx != NULL)
+ {
+ Ecore_List2 *l;
+
+ for (l = (Ecore_List2 *)ecore_evases; l; l = l->next)
+ {
+ Ecore_Evas *ee;
+
+ ee = (Ecore_Evas *)l;
+ if (ee->visible)
+ evas_damage_rectangle_add(ee->evas, 0, 0, 400, 400);
+ }
+ return;
+ }
+
+ ctx = [[NSGraphicsContext currentContext] graphicsPort];
+ CGContextRetain(ctx);
+}
+
+- (CGContextRef)context
+{
+ return ctx;
+}
+
+@end
+
+static void
+_ecore_evas_mouse_move_process(Ecore_Evas *ee, int x, int y, unsigned int timestamp)
+{
+ ee->mouse.x = x;
+ ee->mouse.y = y;
+ if (ee->prop.cursor.object)
+ {
+ evas_object_show(ee->prop.cursor.object);
+ evas_object_move(ee->prop.cursor.object, x - ee->prop.cursor.hot.x, y - ee->prop.cursor.hot.y);
+ }
+ evas_event_feed_mouse_move(ee->evas, x, y, timestamp, NULL);
+}
+
+static Ecore_Evas *
+_ecore_evas_quartz_match(void)
+{
+ return ecore_evases;
+}
+
+static int
+_ecore_evas_quartz_event_key_down(void *data __UNUSED__, int type __UNUSED__, void *event)
+{
+ Ecore_Quartz_Event_Key_Down *e;
+ Ecore_Evas *ee;
+
+ e = event;
+ ee = _ecore_evas_quartz_match();
+
+ if (!ee) return 1;
+ // pass on event
+ evas_event_feed_key_down(ee->evas, e->keyname, NULL, e->keycompose, NULL, e->time, NULL);
+
+ return 0; // dont pass it on
+}
+
+static int
+_ecore_evas_quartz_event_key_up(void *data __UNUSED__, int type __UNUSED__, void *event)
+{
+ Ecore_Quartz_Event_Key_Up *e;
+ Ecore_Evas *ee;
+
+ e = event;
+ ee = _ecore_evas_quartz_match();
+
+ if (!ee) return 1;
+ // pass on event
+ evas_event_feed_key_up(ee->evas, e->keyname, NULL, e->keycompose, NULL, e->time, NULL);
+
+ return 0;
+}
+
+static int
+_ecore_evas_quartz_event_mouse_move(void *data __UNUSED__, int type __UNUSED__, void *event)
+{
+ Ecore_Quartz_Event_Mouse_Move *e;
+ Ecore_Evas *ee;
+
+ e = event;
+ ee = _ecore_evas_quartz_match();
+
+ if (!ee) return 1; // pass on event
+
+ NSWindow * win = ((NSWindow*) (e->window));
+
+ // Also notify on entering or leaving the window
+ NSPoint mouseLoc = [win convertBaseToScreen:NSMakePoint(e->x, e->y)];
+
+ if(NSPointInRect(mouseLoc, [win frame]))
+ {
+ evas_event_feed_mouse_in(ee, 0, NULL);
+
+ int w, h;
+ evas_output_size_get(ee->evas, &w, &h);
+ e->y = h - e->y;
+
+ if (e->y >= 0) // Don't register movement in titlebar!
+ _ecore_evas_mouse_move_process(ee, e->x, e->y, e->time);
+ }
+ else
+ {
+ evas_event_feed_mouse_out(ee, 0, NULL);
+ }
+ return 0;
+}
+
+static int
+_ecore_evas_quartz_event_button_down(void *data __UNUSED__, int type __UNUSED__, void *event)
+{
+ Ecore_Quartz_Event_Mouse_Button_Down *e;
+ Ecore_Evas *ee;
+ Evas_Button_Flags flags;
+
+ e = event;
+ ee = _ecore_evas_quartz_match();
+ flags = EVAS_BUTTON_NONE;
+
+ if (!ee) return 1;
+
+ int w, h;
+ evas_output_size_get(ee->evas, &w, &h);
+ e->y = h - e->y;
+
+ // pass on event
+ _ecore_evas_mouse_move_process(ee, e->x, e->y, e->time);
+ if (e->double_click) flags |= EVAS_BUTTON_DOUBLE_CLICK;
+ if (e->triple_click) flags |= EVAS_BUTTON_TRIPLE_CLICK;
+
+ if (e->y >= 0) // Don't register clicks in titlebar!
+ evas_event_feed_mouse_down(ee->evas, e->button, flags, e->time, NULL);
+
+ return 0;
+}
+
+static int
+_ecore_evas_quartz_event_button_up(void *data __UNUSED__, int type __UNUSED__, void *event)
+{
+ Ecore_Quartz_Event_Mouse_Button_Up *e;
+ Ecore_Evas *ee;
+ Evas_Button_Flags flags;
+
+ e = event;
+ ee = _ecore_evas_quartz_match();
+ flags = EVAS_BUTTON_NONE;
+
+ if (!ee) return 1;
+
+ int w, h;
+ evas_output_size_get(ee->evas, &w, &h);
+ e->y = h - e->y;
+
+ // pass on event
+ _ecore_evas_mouse_move_process(ee, e->x, e->y, e->time);
+ if (e->double_click) flags |= EVAS_BUTTON_DOUBLE_CLICK;
+ if (e->triple_click) flags |= EVAS_BUTTON_TRIPLE_CLICK;
+
+ if (e->y >= 0) // Don't register clicks in titlebar!
+ evas_event_feed_mouse_up(ee->evas, e->button, flags, e->time, NULL);
+
+ return 0;
+}
+
+static int
+_ecore_evas_quartz_event_mouse_wheel(void *data __UNUSED__, int type __UNUSED__, void *event)
+{
+ /*Ecore_Quartz_Event_Mouse_Wheel *e;
+ Ecore_Evas *ee;
+
+ e = event;
+ ee = _ecore_evas_quartz_match();
+
+ if (!ee) return 1; // pass on event
+ _ecore_evas_mouse_move_process(ee, e->x, e->y, e->time);
+ evas_event_feed_mouse_wheel(ee->evas, e->direction, e->wheel, e->time, NULL);
+
+ return 0;*/
+}
+
+static int
+_ecore_evas_quartz_event_got_focus(void *data __UNUSED__, int type __UNUSED__, void *event)
+{
+ Ecore_Evas *ee;
+
+ ee = _ecore_evas_quartz_match();
+
+ if (!ee) return 1;
+ ee->prop.focused = 1;
+
+ return 0;
+}
+
+static int
+_ecore_evas_quartz_event_lost_focus(void *data __UNUSED__, int type __UNUSED__, void *event)
+{
+ Ecore_Evas *ee;
+
+ ee = _ecore_evas_quartz_match();
+
+ if (!ee) return 1;
+ ee->prop.focused = 0;
+
+ return 0;
+}
+
+static int
+_ecore_evas_quartz_event_video_resize(void *data __UNUSED__, int type __UNUSED__, void *event)
+{
+ /*Ecore_Quartz_Event_Video_Resize *e;
+ Ecore_Evas *ee;
+
+ e = event;
+ ee = _ecore_evas_quartz_match();
+
+ if (!ee) return 1; // pass on event
+ evas_output_size_set(ee->evas, e->w, e->h);
+
+ return 0;*/
+}
+
+static int
+_ecore_evas_quartz_event_video_expose(void *data __UNUSED__, int type __UNUSED__, void *event __UNUSED__)
+{
+ Ecore_Evas *ee;
+ int w;
+ int h;
+
+ ee = _ecore_evas_quartz_match();
+
+ if (!ee) return 1;
+ evas_output_size_get(ee->evas, &w, &h);
+ evas_damage_rectangle_add(ee->evas, 0, 0, w, h);
+
+ return 0;
+}
+
+static int
+_ecore_evas_idle_enter(void *data __UNUSED__)
+{
+ Ecore_List2 *l;
+ double t1 = 0.;
+ double t2 = 0.;
+
+ for (l = (Ecore_List2 *)ecore_evases; l; l = l->next)
+ {
+ Ecore_Evas *ee = (Ecore_Evas *)l;
+
+ if (ee->visible)
+ evas_render(ee->evas);
+ else
+ evas_norender(ee->evas);
+ }
+
+ return 1;
+}
+
+static int
+_ecore_evas_quartz_event(void *data)
+{
+ ecore_quartz_feed_events();
+
+ return 1;
+}
+
+static int
+_ecore_evas_quartz_init(int w, int h)
+{
+ _ecore_evas_init_count++;
+ if (_ecore_evas_init_count > 1) return _ecore_evas_init_count;
+
+ ecore_evas_idle_enterer = ecore_idle_enterer_add(_ecore_evas_idle_enter, NULL);
+ ecore_evas_event = ecore_timer_add(0.008, _ecore_evas_quartz_event, NULL);
+
+ ecore_evas_event_handlers[0] = ecore_event_handler_add(ECORE_QUARTZ_EVENT_KEY_DOWN, _ecore_evas_quartz_event_key_down, NULL);
+ ecore_evas_event_handlers[1] = ecore_event_handler_add(ECORE_QUARTZ_EVENT_KEY_UP, _ecore_evas_quartz_event_key_up, NULL);
+ ecore_evas_event_handlers[2] = ecore_event_handler_add(ECORE_QUARTZ_EVENT_MOUSE_BUTTON_DOWN, _ecore_evas_quartz_event_button_down, NULL);
+ ecore_evas_event_handlers[3] = ecore_event_handler_add(ECORE_QUARTZ_EVENT_MOUSE_BUTTON_UP, _ecore_evas_quartz_event_button_up, NULL);
+ ecore_evas_event_handlers[4] = ecore_event_handler_add(ECORE_QUARTZ_EVENT_MOUSE_MOVE, _ecore_evas_quartz_event_mouse_move, NULL);
+ ecore_evas_event_handlers[5] = ecore_event_handler_add(ECORE_QUARTZ_EVENT_MOUSE_WHEEL, _ecore_evas_quartz_event_mouse_wheel, NULL);
+ ecore_evas_event_handlers[6] = ecore_event_handler_add(ECORE_QUARTZ_EVENT_GOT_FOCUS, _ecore_evas_quartz_event_got_focus, NULL);
+ ecore_evas_event_handlers[7] = ecore_event_handler_add(ECORE_QUARTZ_EVENT_LOST_FOCUS, _ecore_evas_quartz_event_lost_focus, NULL);
+ ecore_evas_event_handlers[8] = ecore_event_handler_add(ECORE_QUARTZ_EVENT_RESIZE, _ecore_evas_quartz_event_video_resize, NULL);
+ ecore_evas_event_handlers[9] = ecore_event_handler_add(ECORE_QUARTZ_EVENT_EXPOSE, _ecore_evas_quartz_event_video_expose, NULL);
+
+ return _ecore_evas_init_count;
+}
+
+static int
+_ecore_evas_quartz_shutdown(void)
+{
+ _ecore_evas_init_count--;
+ if (_ecore_evas_init_count == 0)
+ {
+ int i;
+
+ while (ecore_evases) _ecore_evas_free(ecore_evases);
+
+ for (i = 0; i < sizeof (ecore_evas_event_handlers) / sizeof (Ecore_Event_Handler*); i++)
+ ecore_event_handler_del(ecore_evas_event_handlers[i]);
+
+ ecore_idle_enterer_del(ecore_evas_idle_enterer);
+ ecore_evas_idle_enterer = NULL;
+ ecore_timer_del(ecore_evas_event);
+ ecore_evas_event = NULL;
+ }
+ if (_ecore_evas_init_count < 0) _ecore_evas_init_count = 0;
+ return _ecore_evas_init_count;
+}
+
+static void
+_ecore_evas_quartz_free(Ecore_Evas *ee)
+{
+ ecore_evases = _ecore_list2_remove(ecore_evases, ee);
+ _ecore_evas_quartz_shutdown();
+ ecore_quartz_shutdown();
+}
+
+static void
+_ecore_evas_resize(Ecore_Evas *ee, int w, int h)
+{
+ if ((w == ee->w) && (h == ee->h)) return;
+ ee->w = w;
+ ee->h = h;
+
+ evas_output_size_set(ee->evas, ee->w, ee->h);
+ evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h);
+ evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
+
+ if (ee->func.fn_resize) ee->func.fn_resize(ee);
+}
+
+static void
+_ecore_evas_move_resize(Ecore_Evas *ee, int x __UNUSED__, int y __UNUSED__, int w, int h)
+{
+ if ((w == ee->w) && (h == ee->h)) return;
+ ee->w = w;
+ ee->h = h;
+
+ evas_output_size_set(ee->evas, ee->w, ee->h);
+ evas_output_viewport_set(ee->evas, 0, 0, ee->w, ee->h);
+ evas_damage_rectangle_add(ee->evas, 0, 0, ee->w, ee->h);
+
+ if (ee->func.fn_resize) ee->func.fn_resize(ee);
+}
+
+static void
+_ecore_evas_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int hot_x, int hot_y)
+{
+ int x, y;
+
+ if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object);
+
+ if (obj == NULL)
+ {
+ ee->prop.cursor.object = NULL;
+ ee->prop.cursor.layer = 0;
+ ee->prop.cursor.hot.x = 0;
+ ee->prop.cursor.hot.y = 0;
+ return;
+ }
+
+ ee->prop.cursor.object = obj;
+ ee->prop.cursor.layer = layer;
+ ee->prop.cursor.hot.x = hot_x;
+ ee->prop.cursor.hot.y = hot_y;
+
+ evas_pointer_output_xy_get(ee->evas, &x, &y);
+ evas_object_layer_set(ee->prop.cursor.object, ee->prop.cursor.layer);
+ evas_object_move(ee->prop.cursor.object,
+ x - ee->prop.cursor.hot.x,
+ y - ee->prop.cursor.hot.y);
+
+ evas_object_pass_events_set(ee->prop.cursor.object, 1);
+
+ if (evas_pointer_inside_get(ee->evas))
+ evas_object_show(ee->prop.cursor.object);
+}
+
+static const Ecore_Evas_Engine_Func _ecore_quartz_engine_func =
+{
+ _ecore_evas_quartz_free,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ _ecore_evas_resize,
+ _ecore_evas_move_resize,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ _ecore_evas_object_cursor_set,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+#endif
+
+EAPI Ecore_Evas*
+ecore_evas_quartz_new(const char* name, int w, int h)
+{
+#ifdef BUILD_ECORE_EVAS_QUARTZ
+ Evas_Engine_Info_Quartz *einfo;
+ Ecore_Evas *ee;
+ int rmethod;
+
+ if (!name)
+ name = ecore_evas_quartz_default;
+
+ rmethod = evas_render_method_lookup("quartz");
+ if (!rmethod) return NULL;
+
+ if (!ecore_quartz_init(name)) return NULL;
+
+ ee = calloc(1, sizeof(Ecore_Evas));
+ if (!ee) return NULL;
+
+ ECORE_MAGIC_SET(ee, ECORE_MAGIC_EVAS);
+
+ _ecore_evas_quartz_init(w, h);
+
+ ee->engine.func = (Ecore_Evas_Engine_Func *)&_ecore_quartz_engine_func;
+
+ ee->driver = "quartz";
+ if (name) ee->name = strdup(name);
+
+ if (w < 1) w = 1;
+ if (h < 1) h = 1;
+ ee->visible = 1;
+ ee->w = w;
+ ee->h = h;
+
+ ee->prop.max.w = 0;
+ ee->prop.max.h = 0;
+ ee->prop.layer = 0;
+ ee->prop.focused = 1;
+ ee->prop.borderless = 1;
+ ee->prop.override = 1;
+ ee->prop.maximized = 1;
+ ee->prop.withdrawn = 0;
+ ee->prop.sticky = 0;
+
+ // init evas here
+ ee->evas = evas_new();
+ evas_data_attach_set(ee->evas, ee);
+ evas_output_method_set(ee->evas, rmethod);
+
+ // Set up the Cocoa runtime
+ [[NSAutoreleasePool alloc] init];
+ [NSApplication sharedApplication];
+
+ // Register ourselves as a full-fledged Cocoa app, instead of a NSUIElement.
+ // This gives benefits like window focus and a dock icon!
+ ProcessSerialNumber psn = { 0, kCurrentProcess };
+ TransformProcessType (&psn, kProcessTransformToForegroundApplication);
+
+ [NSApp finishLaunching];
+
+ // Create our main window, and embed an EvasView in it
+ main_window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0,0,w,h) styleMask:(NSTitledWindowMask | NSClosableWindowMask | NSResizableWindowMask | NSMiniaturizableWindowMask) backing:NSBackingStoreBuffered defer:NO screen:nil];
+ [main_window makeKeyAndOrderFront:NSApp];
+ [main_window setTitle:[NSString stringWithUTF8String:name]];
+ [main_window makeMainWindow];
+ [main_window setAcceptsMouseMovedEvents:YES];
+ [NSApp activateIgnoringOtherApps:YES];
+
+ evas_view = [[EvasView alloc] initWithFrame:NSMakeRect(0,0,w,h)];
+ [[main_window contentView] addSubview:evas_view];
+
+ // drawRect: must be run at least once, to make sure we've set ctx
+ [evas_view display];
+
+ evas_output_size_set(ee->evas, w, h);
+ evas_output_viewport_set(ee->evas, 0, 0, w, h);
+
+ einfo = (Evas_Engine_Info_Quartz*) evas_engine_info_get(ee->evas);
+ if (einfo)
+ {
+ einfo->info.context = [[evas_view context] retain];
+ evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo);
+ }
+
+ evas_key_modifier_add(ee->evas, "Shift");
+ evas_key_modifier_add(ee->evas, "Control");
+ evas_key_modifier_add(ee->evas, "Alt");
+ evas_key_modifier_add(ee->evas, "Meta");
+ evas_key_modifier_add(ee->evas, "Hyper");
+ evas_key_modifier_add(ee->evas, "Super");
+ evas_key_lock_add(ee->evas, "Caps_Lock");
+ evas_key_lock_add(ee->evas, "Num_Lock");
+ evas_key_lock_add(ee->evas, "Scroll_Lock");
+
+ evas_event_feed_mouse_in(ee->evas, (unsigned int)((unsigned long long)(ecore_time_get() * 1000.0) & 0xffffffff), NULL);
+
+ ecore_evases = _ecore_list2_prepend(ecore_evases, ee);
+ return ee;
+#else
+ fprintf(stderr, "OUTCH !\n");
+ return NULL;
+#endif
+}
--- /dev/null
+/*
+* vim:ts=8:sw=3:sts=8:noexpandtab:cino=>5n-3f0^-2{2
+*/
+
+#ifndef _ECORE_QUARTZ_H
+#define _ECORE_QUARTZ_H
+
+#ifdef EAPI
+# undef EAPI
+#endif
+
+# ifdef __GNUC__
+# if __GNUC__ >= 4
+# define EAPI __attribute__ ((visibility("default")))
+# else
+# define EAPI
+# endif
+# else
+# define EAPI
+# endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+EAPI extern int ECORE_QUARTZ_EVENT_KEY_DOWN;
+EAPI extern int ECORE_QUARTZ_EVENT_KEY_UP;
+EAPI extern int ECORE_QUARTZ_EVENT_MOUSE_BUTTON_DOWN;
+EAPI extern int ECORE_QUARTZ_EVENT_MOUSE_BUTTON_UP;
+EAPI extern int ECORE_QUARTZ_EVENT_MOUSE_MOVE;
+EAPI extern int ECORE_QUARTZ_EVENT_MOUSE_WHEEL;
+EAPI extern int ECORE_QUARTZ_EVENT_GOT_FOCUS;
+EAPI extern int ECORE_QUARTZ_EVENT_LOST_FOCUS;
+EAPI extern int ECORE_QUARTZ_EVENT_RESIZE;
+EAPI extern int ECORE_QUARTZ_EVENT_EXPOSE;
+
+typedef struct _Ecore_Quartz_Event_Key_Down Ecore_Quartz_Event_Key_Down;
+struct _Ecore_Quartz_Event_Key_Down /** Quartz Key Down event */
+{
+ const char *keyname; /**< The name of the key that was pressed */
+ const char *keycompose; /**< The UTF-8 string conversion if any */
+ unsigned int time;
+};
+
+typedef struct _Ecore_Quartz_Event_Key_Up Ecore_Quartz_Event_Key_Up;
+struct _Ecore_Quartz_Event_Key_Up /** Quartz Key Up event */
+{
+ const char *keyname; /**< The name of the key that was released */
+ const char *keycompose; /**< The UTF-8 string conversion if any */
+ unsigned int time;
+};
+
+typedef struct _Ecore_Quartz_Event_Mouse_Button_Down Ecore_Quartz_Event_Mouse_Button_Down;
+struct _Ecore_Quartz_Event_Mouse_Button_Down /** Quartz Mouse Down event */
+{
+ int button; /**< Mouse button that was pressed (1 - 32) */
+ int x; /**< Mouse co-ordinates when mouse button was pressed */
+ int y; /**< Mouse co-ordinates when mouse button was pressed */
+ int double_click : 1; /**< Set if click was a double click */
+ int triple_click : 1; /**< Set if click was a triple click */
+ unsigned int time;
+};
+
+typedef struct _Ecore_Quartz_Event_Mouse_Button_Up Ecore_Quartz_Event_Mouse_Button_Up;
+struct _Ecore_Quartz_Event_Mouse_Button_Up /** Quartz Mouse Up event */
+{
+ int button; /**< Mouse button that was released (1 - 32) */
+ int x; /**< Mouse co-ordinates when mouse button was raised */
+ int y; /**< Mouse co-ordinates when mouse button was raised */
+ int double_click : 1; /**< Set if click was a double click */
+ int triple_click : 1; /**< Set if click was a triple click */
+ unsigned int time;
+};
+
+typedef struct _Ecore_Quartz_Event_Mouse_Move Ecore_Quartz_Event_Mouse_Move;
+struct _Ecore_Quartz_Event_Mouse_Move /** Quartz Mouse Move event */
+{
+ int x; /**< Mouse co-ordinates where the mouse cursor moved to */
+ int y; /**< Mouse co-ordinates where the mouse cursor moved to */
+ unsigned int time;
+ void *window; /**< Need the NSWindow in order to convert coords */
+};
+
+typedef struct _Ecore_Quartz_Event_Mouse_Wheel Ecore_Quartz_Event_Mouse_Wheel;
+struct _Ecore_Quartz_Event_Mouse_Wheel /** Quartz Mouse Wheel event */
+{
+ int x,y;
+ int direction; /* 0 = vertical, 1 = horizontal */
+ int wheel; /* value 1 (left/up), -1 (right/down) */
+ unsigned int time;
+};
+
+typedef struct _Ecore_Quartz_Event_Video_Resize Ecore_Quartz_Event_Video_Resize;
+struct _Ecore_Quartz_Event_Video_Resize
+{
+ int w;
+ int h;
+};
+
+EAPI int ecore_quartz_init(const char *name);
+EAPI int ecore_quartz_shutdown(void);
+EAPI void ecore_quartz_feed_events(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
--- /dev/null
+#ifndef ECORE_QUARTZ_KEYS_H__
+#define ECORE_QUARTZ_KEYS_H__
+
+struct _ecore_quartz_keys_s
+{
+ int code;
+ const char *name;
+ const char *compose;
+};
+
+static const struct _ecore_quartz_keys_s keystable[] =
+{
+
+{ 0, "0x00", "" },
+{ 0, "First", "" },
+{ 3, "Return", "\015" },
+{ 8, "BackSpace", "\010" },
+{ 9, "Tab", "\011" },
+{ 12, "Clear", "" },
+{ 13, "Return", "\015" },
+{ 19, "Pause", "" },
+{ 25, "BackTab", ""},
+{ 27, "Escape", "" },
+{ 32, "space", " " },
+{ 33, "exclam", "!" },
+{ 34, "quotedbl", "\"" },
+{ 35, "numbersign", "#" },
+{ 36, "dollar", "$" },
+{ 37, "percent", "%%" },
+{ 38, "ampersand", "&" },
+{ 39, "apostrophe", "'" },
+{ 40, "parenleft", "(" },
+{ 41, "parenright", ")" },
+{ 42, "asterik", "*" },
+{ 43, "plus", "+" },
+{ 44, "comma", "," },
+{ 45, "minus", "-" },
+{ 46, "period", "." },
+{ 47, "slash", "/" },
+{ 48, "0", "0" },
+{ 49, "1", "1" },
+{ 50, "2", "2" },
+{ 51, "3", "3" },
+{ 52, "4", "4" },
+{ 53, "5", "5" },
+{ 54, "6", "6" },
+{ 55, "7", "7" },
+{ 56, "8", "8" },
+{ 57, "9", "9" },
+{ 58, "colon", ";" },
+{ 59, "semicolon", ";" },
+{ 60, "less", "<" },
+{ 61, "equal", "=" },
+{ 62, "greater", ">" },
+{ 63, "question", "?" },
+{ 64, "at", "@" },
+
+{ 91, "bracketleft", "[" },
+{ 92, "backslash", "\\" },
+{ 93, "bracketright", "]" },
+{ 94, "asciicircumm", "^" },
+{ 95, "underscore", "_" },
+{ 96, "backquote", "`" },
+{ 97, "a", "a" },
+{ 98, "b", "b" },
+{ 99, "c", "c" },
+{ 100, "d", "d" },
+{ 101, "e", "e" },
+{ 102, "f", "f" },
+{ 103, "g", "g" },
+{ 104, "h", "h" },
+{ 105, "i", "i" },
+{ 106, "j", "j" },
+{ 107, "k", "k" },
+{ 108, "l", "l" },
+{ 109, "m", "m" },
+{ 110, "n", "n" },
+{ 111, "o", "o" },
+{ 112, "p", "p" },
+{ 113, "q", "q" },
+{ 114, "r", "r" },
+{ 115, "s", "s" },
+{ 116, "t", "t" },
+{ 117, "u", "u" },
+{ 118, "v", "v" },
+{ 119, "w", "w" },
+{ 120, "x", "x" },
+{ 121, "y", "y" },
+{ 122, "z", "z" },
+{ 123, "braceleft", "" },
+{ 124, "pipe", "" },
+{ 125, "braceright", "" },
+{ 127, "Delete", "\177" },
+{ 126, "asciitilde", "~" },
+
+{ 160, "w0", "" },
+{ 161, "w1", "" },
+{ 162, "w2", "" },
+{ 163, "w3", "" },
+{ 164, "w4", "" },
+{ 165, "w5", "" },
+{ 166, "w6", "" },
+{ 167, "w7", "" },
+{ 168, "w8", "" },
+{ 169, "w9", "" },
+{ 170, "w10", "" },
+{ 171, "w11", "" },
+{ 172, "w12", "" },
+{ 173, "w13", "" },
+{ 174, "w14", "" },
+{ 175, "w15", "" },
+{ 176, "w16", "" },
+{ 177, "w17", "" },
+{ 178, "w18", "" },
+{ 179, "w19", "" },
+{ 180, "w20", "" },
+{ 181, "w21", "" },
+{ 182, "w22", "" },
+{ 183, "w23", "" },
+{ 184, "w24", "" },
+{ 185, "w25", "" },
+{ 186, "w26", "" },
+{ 187, "w27", "" },
+{ 188, "w28", "" },
+{ 189, "w29", "" },
+{ 190, "w30", "" },
+{ 191, "w31", "" },
+{ 192, "w32", "" },
+{ 193, "w33", "" },
+{ 194, "w34", "" },
+{ 195, "w35", "" },
+{ 196, "w36", "" },
+{ 197, "w37", "" },
+{ 198, "w38", "" },
+{ 199, "w39", "" },
+{ 200, "w40", "" },
+{ 201, "w41", "" },
+{ 202, "w42", "" },
+{ 203, "w43", "" },
+{ 204, "w44", "" },
+{ 205, "w45", "" },
+{ 206, "w46", "" },
+{ 207, "w47", "" },
+{ 208, "w48", "" },
+{ 209, "w49", "" },
+{ 210, "w50", "" },
+{ 211, "w51", "" },
+{ 212, "w52", "" },
+{ 213, "w53", "" },
+{ 214, "w54", "" },
+{ 215, "w55", "" },
+{ 216, "w56", "" },
+{ 217, "w57", "" },
+{ 218, "w58", "" },
+{ 219, "w59", "" },
+{ 220, "w60", "" },
+{ 221, "w61", "" },
+{ 222, "w62", "" },
+{ 223, "w63", "" },
+{ 224, "w64", "" },
+{ 225, "w65", "" },
+{ 226, "w66", "" },
+{ 227, "w67", "" },
+{ 228, "w68", "" },
+{ 229, "w69", "" },
+{ 230, "w70", "" },
+{ 231, "w71", "" },
+{ 232, "w72", "" },
+{ 233, "w73", "" },
+{ 234, "w74", "" },
+{ 235, "w75", "" },
+{ 236, "w76", "" },
+{ 237, "w77", "" },
+{ 238, "w78", "" },
+{ 239, "w79", "" },
+{ 240, "w80", "" },
+{ 241, "w81", "" },
+{ 242, "w82", "" },
+{ 243, "w83", "" },
+{ 244, "w84", "" },
+{ 245, "w85", "" },
+{ 246, "w86", "" },
+{ 247, "w87", "" },
+{ 248, "w88", "" },
+{ 249, "w89", "" },
+{ 250, "w90", "" },
+{ 251, "w91", "" },
+{ 252, "w92", "" },
+{ 253, "w93", "" },
+{ 254, "w94", "" },
+{ 255, "w95", "" },
+
+{ 256, "KP0", "0" },
+{ 257, "KP1", "1" },
+{ 258, "KP2", "2" },
+{ 259, "KP3", "3" },
+{ 260, "KP4", "4" },
+{ 261, "KP5", "5" },
+{ 262, "KP6", "6" },
+{ 263, "KP7", "7" },
+{ 264, "KP8", "8" },
+{ 265, "KP9", "9" },
+{ 266, "period", "." },
+{ 267, "KP_Divide", "/" },
+{ 268, "KP_Multiply", "*" },
+{ 269, "KP_Minus", "-" },
+{ 270, "KP_Plus", "+" },
+{ 271, "KP_Enter", "\015" },
+{ 272, "KP_Equals", "=" },
+
+{ NSUpArrowFunctionKey, "Up", "" },
+{ NSDownArrowFunctionKey, "Down", "" },
+{ NSRightArrowFunctionKey, "Right", "" },
+{ NSLeftArrowFunctionKey, "Left", "" },
+{ NSInsertFunctionKey, "Insert", "" },
+{ NSHomeFunctionKey, "Home", "" },
+{ NSEndFunctionKey, "End", "" },
+{ NSPageUpFunctionKey, "Page_Up", "" },
+{ NSPageDownFunctionKey, "Page_Down", "" },
+
+{ NSF1FunctionKey, "F1", "" },
+{ NSF2FunctionKey, "F2", "" },
+{ NSF3FunctionKey, "F3", "" },
+{ NSF4FunctionKey, "F4", "" },
+{ NSF5FunctionKey, "F5", "" },
+{ NSF6FunctionKey, "F6", "" },
+{ NSF7FunctionKey, "F7", "" },
+{ NSF8FunctionKey, "F8", "" },
+{ NSF9FunctionKey, "F9", "" },
+{ NSF10FunctionKey, "F10", "" },
+{ NSF11FunctionKey, "F11", "" },
+{ NSF12FunctionKey, "F12", "" },
+{ NSF13FunctionKey, "F13", "" },
+{ NSF14FunctionKey, "F14", "" },
+{ NSF15FunctionKey, "F15", "" },
+{ NSF16FunctionKey, "F16", "" },
+{ NSF17FunctionKey, "F17", "" },
+{ NSF18FunctionKey, "F18", "" },
+{ NSF19FunctionKey, "F19", "" },
+{ NSF20FunctionKey, "F20", "" },
+{ NSF21FunctionKey, "F21", "" },
+{ NSF22FunctionKey, "F22", "" },
+{ NSF23FunctionKey, "F23", "" },
+{ NSF24FunctionKey, "F24", "" },
+{ NSF25FunctionKey, "F25", "" },
+{ NSF26FunctionKey, "F26", "" },
+{ NSF27FunctionKey, "F27", "" },
+{ NSF28FunctionKey, "F28", "" },
+{ NSF29FunctionKey, "F29", "" },
+{ NSF30FunctionKey, "F30", "" },
+{ NSF31FunctionKey, "F31", "" },
+{ NSF32FunctionKey, "F32", "" },
+{ NSF33FunctionKey, "F33", "" },
+{ NSF34FunctionKey, "F34", "" },
+{ NSF35FunctionKey, "F35", "" },
+
+{ NSClearLineFunctionKey, "Num_Lock", "" },
+{ 301, "Caps_Lock", "" },
+{ NSScrollLockFunctionKey, "Scroll_Lock", "" },
+{ 303, "Shift_R", "" },
+{ 304, "Shift_L", "" },
+{ 305, "Control_R", "" },
+{ 306, "Control_L", "" },
+{ 307, "Alt_R", "" },
+{ 308, "Alt_L", "" },
+{ 309, "Meta_R", "" },
+{ 310, "Meta_L", "" },
+{ 311, "Super_L", "" },
+{ 312, "Super_R", "" },
+
+{ NSModeSwitchFunctionKey, "Mode", "" },
+{ 314, "Compose", "" },
+
+{ NSHelpFunctionKey, "Help", "" },
+{ NSPrintFunctionKey, "Print", "" },
+{ NSSysReqFunctionKey, "SysReq", "" },
+{ NSBreakFunctionKey, "Break", "" },
+{ NSMenuFunctionKey, "Menu", "" },
+{ 320, "Power", "" },
+{ 321, "Euro", "" },
+{ NSUndoFunctionKey, "Undo", "" }
+
+};
+
+#endif /* ECORE_QUARTZ_KEYS_H__ */
--- /dev/null
+MAINTAINERCLEANFILES = Makefile.in
+
+AM_CPPFLAGS = \
+-I$(top_srcdir)/src/lib/ecore \
+-I$(top_builddir)/src/lib/ecore \
+@QUARTZ_CFLAGS@
+
+if BUILD_ECORE_QUARTZ
+
+lib_LTLIBRARIES = libecore_quartz.la
+include_HEADERS = \
+Ecore_Quartz.h
+
+libecore_quartz_la_SOURCES = \
+Ecore_Quartz.h
+
+### add to SOURCES one we know how to fix:
+# /usr/share/automake-1.9/am/depend2.am: am__fastdepOBJC does not appear in
+# AM_CONDITIONAL
+# ecore_quartz.m
+
+libecore_quartz_la_LIBADD = \
+$(top_builddir)/src/lib/ecore/libecore.la \
+@QUARTZ_LIBS@
+
+libecore_quartz_la_LDFLAGS = @lt_no_undefined@ @lt_enable_auto_import@ -version-info @version_info@
+
+libecore_quartz_la_DEPENDENCIES = \
+$(top_builddir)/src/lib/ecore/libecore.la
+
+endif
+
+EXTRA_DIST = \
+Ecore_Quartz.h \
+ecore_quartz.m
--- /dev/null
+#include <Cocoa/Cocoa.h>
+
+#include "Ecore_Quartz.h"
+#include "ecore_private.h"
+#include "Ecore.h"
+#include "Ecore_Data.h"
+#include "Ecore_Quartz_Keys.h"
+
+EAPI int ECORE_QUARTZ_EVENT_KEY_DOWN = 0;
+EAPI int ECORE_QUARTZ_EVENT_KEY_UP = 0;
+EAPI int ECORE_QUARTZ_EVENT_MOUSE_BUTTON_DOWN = 0;
+EAPI int ECORE_QUARTZ_EVENT_MOUSE_BUTTON_UP = 0;
+EAPI int ECORE_QUARTZ_EVENT_MOUSE_MOVE = 0;
+EAPI int ECORE_QUARTZ_EVENT_MOUSE_WHEEL = 0;
+EAPI int ECORE_QUARTZ_EVENT_GOT_FOCUS = 0;
+EAPI int ECORE_QUARTZ_EVENT_LOST_FOCUS = 0;
+EAPI int ECORE_QUARTZ_EVENT_RESIZE = 0;
+EAPI int ECORE_QUARTZ_EVENT_EXPOSE = 0;
+
+static int _ecore_quartz_init_count = 0;
+
+static int old_flags;
+
+EAPI int
+ecore_quartz_init(const char *name __UNUSED__)
+{
+ if (!_ecore_quartz_init_count)
+ {
+ ECORE_QUARTZ_EVENT_KEY_DOWN = ecore_event_type_new();
+ ECORE_QUARTZ_EVENT_KEY_UP = ecore_event_type_new();
+ ECORE_QUARTZ_EVENT_MOUSE_BUTTON_DOWN = ecore_event_type_new();
+ ECORE_QUARTZ_EVENT_MOUSE_BUTTON_UP = ecore_event_type_new();
+ ECORE_QUARTZ_EVENT_MOUSE_MOVE = ecore_event_type_new();
+ ECORE_QUARTZ_EVENT_MOUSE_WHEEL = ecore_event_type_new();
+ ECORE_QUARTZ_EVENT_GOT_FOCUS = ecore_event_type_new();
+ ECORE_QUARTZ_EVENT_LOST_FOCUS = ecore_event_type_new();
+ ECORE_QUARTZ_EVENT_RESIZE = ecore_event_type_new();
+ ECORE_QUARTZ_EVENT_EXPOSE = ecore_event_type_new();
+ }
+ return ++_ecore_quartz_init_count;
+}
+
+/**
+ * Shuts down the Ecore_Quartz library.
+ * @return @c The number of times the system has been initialised without
+ * being shut down.
+ * @ingroup Ecore_Quartz_Library_Group
+ */
+EAPI int
+ecore_quartz_shutdown(void)
+{
+ _ecore_quartz_init_count--;
+ return _ecore_quartz_init_count;
+}
+
+EAPI void
+ecore_quartz_feed_events(void)
+{
+ NSDate *date = [NSDate dateWithTimeIntervalSinceNow:0.001];
+ NSEvent *event = [NSApp nextEventMatchingMask:NSAnyEventMask
+ untilDate:date
+ inMode:NSDefaultRunLoopMode
+ dequeue:YES];
+ [date release];
+ if (!event) return; // SDL loops until null; maybe we should do that too. or not.
+
+ unsigned int time = (unsigned int)((unsigned long long)(ecore_time_get() * 1000.0) & 0xffffffff);
+
+ switch([event type])
+ {
+ case NSMouseMoved:
+ case NSLeftMouseDragged:
+ case NSRightMouseDragged:
+ case NSOtherMouseDragged:
+ {
+ Ecore_Quartz_Event_Mouse_Move * ev = malloc(sizeof(Ecore_Quartz_Event_Mouse_Move));
+ ev->x = [event locationInWindow].x;
+ ev->y = [event locationInWindow].y;
+ ev->time = time;
+ ev->window = [event window];
+
+ ecore_event_add(ECORE_QUARTZ_EVENT_MOUSE_MOVE, ev, NULL, NULL);
+
+ [NSApp sendEvent:event]; // pass along mouse events, for window manager
+ break;
+ }
+ case NSLeftMouseDown:
+ case NSRightMouseDown:
+ case NSOtherMouseDown:
+ {
+ Ecore_Quartz_Event_Mouse_Button_Down * ev = malloc(sizeof(Ecore_Quartz_Event_Mouse_Button_Down));
+ ev->x = [event locationInWindow].x;
+ ev->y = [event locationInWindow].y;
+ ev->button = [event buttonNumber] + 1; // Apple indexes buttons from 0
+
+ if ([event clickCount] == 2)
+ ev->double_click = 1;
+ else
+ ev->double_click = 0;
+
+ if ([event clickCount] >= 3)
+ ev->triple_click = 1;
+ else
+ ev->triple_click = 0;
+
+ ev->time = time;
+
+ ecore_event_add(ECORE_QUARTZ_EVENT_MOUSE_BUTTON_DOWN, ev, NULL, NULL);
+
+ [NSApp sendEvent:event]; // pass along mouse events, for window manager
+ break;
+ }
+ case NSLeftMouseUp:
+ case NSRightMouseUp:
+ case NSOtherMouseUp:
+ {
+ Ecore_Quartz_Event_Mouse_Button_Up * ev = malloc(sizeof(Ecore_Quartz_Event_Mouse_Button_Up));
+ ev->x = [event locationInWindow].x;
+ ev->y = [event locationInWindow].y;
+ ev->button = [event buttonNumber] + 1; // Apple indexes buttons from 0
+
+ if ([event clickCount] == 2)
+ ev->double_click = 1;
+ else
+ ev->double_click = 0;
+
+ if ([event clickCount] >= 3)
+ ev->triple_click = 1;
+ else
+ ev->triple_click = 0;
+
+ ev->time = time;
+
+ ecore_event_add(ECORE_QUARTZ_EVENT_MOUSE_BUTTON_UP, ev, NULL, NULL);
+
+ [NSApp sendEvent:event]; // pass along mouse events, for window manager
+ break;
+ }
+ case NSKeyDown:
+ {
+ Ecore_Quartz_Event_Key_Down *ev;
+ unsigned int i;
+
+ ev = malloc(sizeof (Ecore_Quartz_Event_Key_Down));
+ ev->time = time;
+
+ for (i = 0; i < sizeof (keystable) / sizeof (struct _ecore_quartz_keys_s); ++i)
+ {
+ if (keystable[i].code == tolower([[event charactersIgnoringModifiers] characterAtIndex:0]))
+ {
+ ev->keyname = keystable[i].name;
+ ev->keycompose = keystable[i].compose;
+
+ ecore_event_add(ECORE_QUARTZ_EVENT_KEY_DOWN, ev, NULL, NULL);
+ return;
+ }
+ }
+
+ free(ev);
+ break;
+ }
+ case NSKeyUp:
+ {
+ Ecore_Quartz_Event_Key_Up *ev;
+ unsigned int i;
+
+ ev = malloc(sizeof (Ecore_Quartz_Event_Key_Up));
+ ev->time = time;
+
+ for (i = 0; i < sizeof (keystable) / sizeof (struct _ecore_quartz_keys_s); ++i)
+ {
+ if (keystable[i].code == tolower([[event charactersIgnoringModifiers] characterAtIndex:0]))
+ {
+ ev->keyname = keystable[i].name;
+ ev->keycompose = keystable[i].compose;
+
+ ecore_event_add(ECORE_QUARTZ_EVENT_KEY_UP, ev, NULL, NULL);
+ return;
+ }
+ }
+
+ free(ev);
+ break;
+ }
+ case NSFlagsChanged:
+ {
+ int flags = [event modifierFlags];
+
+ Ecore_Quartz_Event_Key_Down *evDown = NULL;
+ Ecore_Quartz_Event_Key_Up *evUp = NULL;
+
+ evDown = malloc(sizeof (Ecore_Quartz_Event_Key_Down));
+ evDown->keyname = NULL;
+
+ evUp = malloc(sizeof (Ecore_Quartz_Event_Key_Up));
+ evUp->keyname = NULL;
+
+ // Turn special key flags on
+ if (flags & NSShiftKeyMask)
+ evDown->keyname = "Shift_L";
+ else if (flags & NSControlKeyMask)
+ evDown->keyname = "Control_L";
+ else if (flags & NSAlternateKeyMask)
+ evDown->keyname = "Alt_L";
+ else if (flags & NSCommandKeyMask)
+ evDown->keyname = "Super_L";
+ else if (flags & NSAlphaShiftKeyMask)
+ evDown->keyname = "Caps_Lock";
+
+ if (evDown->keyname)
+ {
+ evDown->time = time;
+ evDown->keycompose = "";
+ ecore_event_add(ECORE_QUARTZ_EVENT_KEY_DOWN, evDown, NULL, NULL);
+ old_flags = flags;
+ break;
+ }
+
+ int changed_flags = flags ^ old_flags;
+
+ // Turn special key flags off
+ if (changed_flags & NSShiftKeyMask)
+ evUp->keyname = "Shift_L";
+ else if (changed_flags & NSControlKeyMask)
+ evUp->keyname = "Control_L";
+ else if (changed_flags & NSAlternateKeyMask)
+ evUp->keyname = "Alt_L";
+ else if (changed_flags & NSCommandKeyMask)
+ evUp->keyname = "Super_L";
+ else if (changed_flags & NSAlphaShiftKeyMask)
+ evUp->keyname = "Caps_Lock";
+
+ if (evUp->keyname)
+ {
+ evUp->time = time;
+ evUp->keycompose = "";
+ ecore_event_add(ECORE_QUARTZ_EVENT_KEY_UP, evUp, NULL, NULL);
+ old_flags = flags;
+ break;
+ }
+
+ break;
+ }
+ case NSAppKitDefined:
+ {
+ if ([event subtype] == NSApplicationActivatedEventType)
+ ecore_event_add(ECORE_QUARTZ_EVENT_GOT_FOCUS, NULL, NULL, NULL);
+ else if ([event subtype] == NSApplicationDeactivatedEventType)
+ ecore_event_add(ECORE_QUARTZ_EVENT_LOST_FOCUS, NULL, NULL, NULL);
+ [NSApp sendEvent:event]; // pass along AppKit events, for window manager
+ break;
+ }
+ case NSScrollWheel:
+ {
+ break;
+ }
+ default:
+ {
+ [NSApp sendEvent:event];
+ break;
+ }
+ }
+
+ [event release];
+}
\ No newline at end of file