Compare commits

...

46 Commits

Author SHA1 Message Date
Jean Guyomarc'h 4d1e7d97c4 eina: fix missing header
This caused functions from eina_util to be undefined at compile time.
The compiler would make implicit casts of return values into ints,
which had major side effects (e.g. segfault edje_cc)

@fix
2015-11-10 08:32:49 +01:00
Jean Guyomarc'h 3f1114d829 ecore_cocoa: fix live resize of windows
This was a tricky little bastard!
When a window is live resized, the NSWindow which is the target of
the live resize will wait for a kevent from the window manager,
until live resizing is done. So... live resizing is synchronous
and blocks the main thread... hence ecore_main_loop.

- When live resize starts, the Ecore_Timer which polls NSRunLoop
is paused.
- When the window is resized, the ecore_main_loop is run manually
with ecore_main_loop_iterate() to process Ecore events (mostly
Ecore_Evas)
- When live resize finished, the Ecore_Timer which polls NSRunLoop
is resumed.

@fix
2015-11-10 08:32:49 +01:00
Jean Guyomarc'h 1811704a90 ecore_cocoa_app: don't override init 2015-11-10 08:32:49 +01:00
Jean Guyomarc'h 6c296b3d16 ecore_cocoa: don't make ecore_cocoa_feed_events() a public API 2015-11-10 08:32:49 +01:00
Jean Guyomarc'h 60e2a6cbbb ecore_cocoa: NSApp must be configured in the App wrapper 2015-11-10 08:32:49 +01:00
Jean Guyomarc'h 267c8ea18a ecore_cocoa_window: cosmetic changes 2015-11-10 08:32:49 +01:00
Jean Guyomarc'h 731ab05a28 ecore_cocoa: don't export Ecore_Cocoa_Keys.h 2015-11-10 08:32:49 +01:00
Jean Guyomarc'h c85f867415 ecore_x: factorize multiple calls to strlen() 2015-11-10 08:32:49 +01:00
Jean Guyomarc'h d12ded45d6 ecore_cocoa: factorize code 2015-11-10 08:32:49 +01:00
Jean Guyomarc'h bf02510024 evas_gl_cocoa: make sure focus is always unlocked after locking it 2015-11-10 08:32:49 +01:00
Jean Guyomarc'h dbe57695ef ecore_cocoa_cnp: make API thread-safe 2015-11-10 08:32:49 +01:00
Jean Guyomarc'h c17971bc80 ecore_cocoa_cnp: clear the clipboard only if writable 2015-11-10 08:32:49 +01:00
Jean Guyomarc'h 243bd5116f edje: on Mac OS X, use Apple's key bindings with entries 2015-11-10 08:32:49 +01:00
Jean Guyomarc'h 255c5f064e ecore_cocoa_cnp: remove trailing whitespace 2015-11-10 08:32:49 +01:00
Jean Guyomarc'h 5e1456f61f ecore_cocoa: NSEvent modifiers are of type NSUInteger 2015-11-10 08:32:49 +01:00
Jean Guyomarc'h f362d30777 ecore_evas_cocoa: factorize code 2015-11-10 08:32:49 +01:00
Jean Guyomarc'h 8f5581c704 ecore_cocoa: report error when [super init] fails 2015-11-10 08:32:49 +01:00
Jean Guyomarc'h 20af977266 ecore_evas_cocoa: remove dead code 2015-11-10 08:32:49 +01:00
Jean Guyomarc'h df3b7a6302 ecore_cocoa: remove EINA_UNUSED because parameter is used 2015-11-10 08:32:49 +01:00
Jean Guyomarc'h a591cea8d2 ecore_cocoa: remove debug log 2015-11-10 08:32:49 +01:00
Jean Guyomarc'h 18a1c202cc ecore_cocoa: reindent file 2015-11-10 08:32:49 +01:00
Jean Guyomarc'h 8bbdb2511e ecore_cocoa: add more safety checks 2015-11-10 08:32:49 +01:00
Jean Guyomarc'h 226709745a ecore_cocoa: remove EINA_UNUSED because parameter is actually used 2015-11-10 08:32:49 +01:00
Jean Guyomarc'h 1f1afce94e ecore_cocoa: prevent Ecore_Cocoa_Window to be re-defined 2015-11-10 08:32:49 +01:00
Jean Guyomarc'h 70ad7994a8 ecore_cocoa: remove ECORE_COCOA_EVENT_EXPOSE 2015-11-10 08:32:49 +01:00
Jean Guyomarc'h 0435ba7c77 ecore_cocoa: remove unused events 2015-11-10 08:32:49 +01:00
Jean Guyomarc'h 358165b41f ecore_cocoa: start doxygen 2015-11-10 08:32:49 +01:00
Jean Guyomarc'h a439f71965 ecore_evas_cocoa: focus: handle ignore_events 2015-11-10 08:32:49 +01:00
Jean Guyomarc'h f1679e259a ecore_cocoa: don't track NSAppKitDefined event
Currently, it was used only to get track of focus, howver focus was
already handled (and better) in ecore_cocoa_window (with
NSWindowDelegate).
This led to the LOST_FOCUS event to be posted twice, with different
values, which messed up the focus stack.

@fix
2015-11-10 08:32:49 +01:00
Jean Guyomarc'h 14775bc8c4 ecore_evas_cocoa: don't reset the init count if negative 2015-11-10 08:32:49 +01:00
Jean Guyomarc'h e621b2d1d4 ecore_evas_cocoa: use Eina macro to determine the size of a static array 2015-11-10 08:32:49 +01:00
Jean Guyomarc'h 29ccf7fbf8 ecore_evas_cocoa: don't shutdown ecore_event_evas() twice 2015-11-10 08:32:49 +01:00
Jean Guyomarc'h 3dc7677c91 ecore_evas_cocoa: EAPI cannot be set for WIN32 2015-11-10 08:32:49 +01:00
Jean Guyomarc'h 7ab47f9614 ecore_cocoa: fix types 2015-11-10 08:32:49 +01:00
Jean Guyomarc'h 3331526dc8 ecore_evas_cocoa: remove dead code 2015-11-10 08:32:49 +01:00
Jean Guyomarc'h 825e316ac5 ecore_cocoa: copy and paste support 2015-11-10 08:32:49 +01:00
Jean Guyomarc'h c7a482f8a3 ecore_cocoa: silent warning: unused parameter 2015-11-10 08:32:49 +01:00
Jean Guyomarc'h 5c699924f4 ecore_cocoa: use EAPI in implementation 2015-11-10 08:32:49 +01:00
Jean Guyomarc'h a51dc81d1f ecore_cocoa: improve const-correctness 2015-11-10 08:32:49 +01:00
Jean Guyomarc'h 650852fd8d ecore_cocoa: don't specify inline 2015-11-10 08:32:49 +01:00
Jean Guyomarc'h 4c3134c97f ecore_cocoa: add support for system cursors
- Ecore_Cocoa_Cursor enum which references system cursors;
- API to show/hide cursor: ecore_cocoa_window_cursor_show();
- API to set system cursor: ecore_cocoa_window_cursor_set();
- Ecore_Evas interface to get Ecore_Cocoa_Window from Ecore_Evas.
2015-11-10 08:32:49 +01:00
Vincent Torri 0bec83d667 Ecore_Win32: add support of X11 shaped cursors
@feature
2015-11-10 08:32:49 +01:00
Vincent Torri 5f056dc2b3 Ecore_Win32: add clipboard management
@feature
2015-11-10 08:32:49 +01:00
Vincent Torri 65b71bcea7 Eina: use eina_file_path_join() and eina_environment_tmp_get() when needed 2015-11-10 08:32:49 +01:00
Vincent Torri 65c82ea15c Ecore_File: fix ecore_file_file_get() on Windows
@fix
2015-11-10 08:32:49 +01:00
Nicolas Aguirre 0c12f9d881 ecore_cocoa/evas_gl_cocoa: Fix indent, remove printf, and add DBG messages 2015-11-10 08:32:49 +01:00
33 changed files with 7419 additions and 854 deletions

View File

@ -2807,6 +2807,8 @@ EFL_INTERNAL_DEPEND_PKG([ECORE_COCOA], [ecore-input])
EFL_INTERNAL_DEPEND_PKG([ECORE_COCOA], [ecore])
EFL_INTERNAL_DEPEND_PKG([ECORE_COCOA], [eo])
EFL_INTERNAL_DEPEND_PKG([ECORE_COCOA], [eina])
EFL_INTERNAL_DEPEND_PKG([ECORE_COCOA], [evas])
EFL_INTERNAL_DEPEND_PKG([ECORE_COCOA], [emile])
### Checks for header files

View File

@ -7,12 +7,14 @@ lib_LTLIBRARIES += lib/ecore_cocoa/libecore_cocoa.la
installed_ecorecocoamainheadersdir = $(includedir)/ecore-cocoa-@VMAJ@
dist_installed_ecorecocoamainheaders_DATA = \
lib/ecore_cocoa/Ecore_Cocoa.h \
lib/ecore_cocoa/Ecore_Cocoa_Keys.h
lib/ecore_cocoa/Ecore_Cocoa_Cursor.h
lib_ecore_cocoa_libecore_cocoa_la_SOURCES = \
lib/ecore_cocoa/ecore_cocoa.m \
lib/ecore_cocoa/ecore_cocoa_keys.h \
lib/ecore_cocoa/ecore_cocoa_window.h \
lib/ecore_cocoa/ecore_cocoa_window.m \
lib/ecore_cocoa/ecore_cocoa_cnp.m \
lib/ecore_cocoa/ecore_cocoa_app.m \
lib/ecore_cocoa/ecore_cocoa_app.h \
lib/ecore_cocoa/ecore_cocoa_private.h

View File

@ -20,6 +20,7 @@ lib/ecore_evas/ecore_evas_private.h \
lib/ecore_evas/ecore_evas_extn.h \
lib/ecore_evas/ecore_evas_extn.c \
lib/ecore_evas/ecore_evas_wayland.h \
lib/ecore_evas/ecore_evas_cocoa.h \
lib/ecore_evas/ecore_evas_win32.h \
lib/ecore_evas/ecore_evas_x11.h \
lib/ecore_evas/ecore_evas_util.c

View File

@ -10,6 +10,7 @@ lib/ecore_win32/Ecore_Win32.h
lib_ecore_win32_libecore_win32_la_SOURCES = \
lib/ecore_win32/ecore_win32.c \
lib/ecore_win32/ecore_win32_clipboard.c \
lib/ecore_win32/ecore_win32_cursor.c \
lib/ecore_win32/ecore_win32_dnd.c \
lib/ecore_win32/ecore_win32_dnd_enumformatetc.cpp \

View File

@ -1,3 +1,10 @@
/**
* @file Ecore_Cocoa.h
*
* @brief Ecore_Cocoa Wrapper Library to interact with the Cocoa
* envirnement (Mac OS X) from the E environment
*
*/
#ifndef __ECORE_COCOA_H__
#define __ECORE_COCOA_H__
@ -26,27 +33,58 @@
#endif
#include <Eina.h>
#include "Ecore_Cocoa_Cursor.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @typedef Ecore_Cocoa_Window
* Opaque handler to manipulate a Cocoa Window through Ecore
*/
#ifndef _ECORE_COCOA_WINDOW_PREDEF
typedef struct _Ecore_Cocoa_Window Ecore_Cocoa_Window;
#endif /* ! _ECORE_COCOA_WINDOW_PREDEF */
/**
* @typedef Ecore_Cocoa_Screen
* Opaque handler to manipulate a Cocoa Screen through Ecore
*/
typedef struct _Ecore_Cocoa_Screen Ecore_Cocoa_Screen;
/**
* @typedef Ecore_Cocoa_Window_Id
* Opaque handler to reference the actual Cocoa window
*/
typedef void * Ecore_Cocoa_Window_Id;
/**
* @typedef Ecore_Cocoa_Event_Video_Resize
* Type of event thrown when a window is resized
*/
typedef struct _Ecore_Cocoa_Event_Video_Resize Ecore_Cocoa_Event_Video_Resize;
/** Event triggered when a window receives focus */
EAPI extern int ECORE_COCOA_EVENT_GOT_FOCUS;
/** Event triggered when a window loses focus */
EAPI extern int ECORE_COCOA_EVENT_LOST_FOCUS;
/** Event triggered when a window is resized */
EAPI extern int ECORE_COCOA_EVENT_RESIZE;
EAPI extern int ECORE_COCOA_EVENT_EXPOSE;
EAPI extern int ECORE_COCOA_EVENT_WINDOW_DESTROY;
typedef void * Ecore_Cocoa_Window_Id;
typedef struct _Ecore_Cocoa_Event_Video_Resize Ecore_Cocoa_Event_Video_Resize;
/**
* @struct _Ecore_Cocoa_Event_Video_Resize
* Data available when a window is resized
*/
struct _Ecore_Cocoa_Event_Video_Resize
{
int w;
int h;
Ecore_Cocoa_Window_Id wid;
int w; /**< Current width of the window */
int h; /**< Current height of the window */
Ecore_Cocoa_Window_Id wid; /**< Handler of the Cocoa window */
};
typedef struct _Ecore_Cocoa_Event_Window Ecore_Cocoa_Event_Window;
@ -60,35 +98,106 @@ struct _Ecore_Cocoa_Screen
int dummy;
};
/* Core */
/**
* @typedef Ecore_Cocoa_Cnp_Type
* Type used to interact with the Cocoa pasteboard.
* It hold types that can apply to a context.
*/
typedef enum
{
ECORE_COCOA_CNP_TYPE_UNKNOWN = 0, /**< Undefined type */
ECORE_COCOA_CNP_TYPE_STRING = (1 << 0), /**< String type (pure text) */
ECORE_COCOA_CNP_TYPE_MARKUP = (1 << 1), /**< Elementary markup */
ECORE_COCOA_CNP_TYPE_IMAGE = (1 << 2), /**< Image (all formats) */
ECORE_COCOA_CNP_TYPE_HTML = (1 << 3) /**< HTML */
} Ecore_Cocoa_Cnp_Type;
/*============================================================================*
* Core *
*============================================================================*/
/**
* Inits the Ecore_Cocoa library
* @return How many times Ecore_Cocoa has been initted
*/
EAPI int ecore_cocoa_init(void);
/**
* Shuts the Ecore_Cocoa library down
* @return How many times Ecore_Cocoa has been initted
*/
EAPI int ecore_cocoa_shutdown(void);
EAPI Eina_Bool ecore_cocoa_feed_events(void *anEvent);
/* Screen */
/*============================================================================*
* Screen *
*============================================================================*/
/**
* Retrieves the size of a Cocoa screen
* @param screen The screen which size must be retrieved
* @param [out] w The width of the screen
* @param [out] h The height of the screen
*/
EAPI void ecore_cocoa_screen_size_get(Ecore_Cocoa_Screen *screen, int *w, int *h);
/* Window */
/*============================================================================*
* Window *
*============================================================================*/
/**
* Creates a Cocoa window
* @param x The origin (X) where the window must be created
* @param y The origin (Y) where the window must be created
* @param width The width of the window
* @param height The height of the window
* @return A handler on the window. NULL on failure
*/
EAPI Ecore_Cocoa_Window *ecore_cocoa_window_new(int x,
int y,
int width,
int height);
/**
* Releases a Cocoa window
* @param window The window to be released
*/
EAPI void ecore_cocoa_window_free(Ecore_Cocoa_Window *window);
EAPI void *ecore_cocoa_window_hwnd_get(Ecore_Cocoa_Window *window);
/**
* Moves a Cocoa window to a given point
* @param window The window to be moved
* @param x The new origin of the window (X)
* @param y The new origin of the window (Y)
*/
EAPI void ecore_cocoa_window_move(Ecore_Cocoa_Window *window,
int x,
int y);
/**
* Resizes a Cocoa window to a given size
* @param window The window to be moved
* @param width The new width of the window
* @param height The new height of the window
*/
EAPI void ecore_cocoa_window_resize(Ecore_Cocoa_Window *window,
int width,
int height);
/**
* Moves and resizes a Cocoa window to a given point and size
* @param window The window to be moved
* @param x The new origin of the window (X)
* @param y The new origin of the window (Y)
* @param width The new width of the window
* @param height The new height of the window
* @see ecore_cocoa_window_resize()
* @see ecore_cocoa_window_move()
*/
EAPI void ecore_cocoa_window_move_resize(Ecore_Cocoa_Window *window,
int x,
int y,
@ -163,7 +272,18 @@ EAPI void ecore_cocoa_window_view_set(Ecore_Cocoa_Window *window,
EAPI int ecore_cocoa_titlebar_height_get(void);
EAPI Ecore_Cocoa_Window_Id ecore_cocoa_window_get_window_id(Ecore_Cocoa_Window *window);
EAPI Ecore_Cocoa_Window_Id ecore_cocoa_window_get_window_id(const Ecore_Cocoa_Window *window);
EAPI Eina_Bool ecore_cocoa_selection_clipboard_set(const void *data, int size, Ecore_Cocoa_Cnp_Type type);
EAPI void *ecore_cocoa_selection_clipboard_get(int *size, Ecore_Cocoa_Cnp_Type type,
Ecore_Cocoa_Cnp_Type *retrieved_types);
EAPI void ecore_cocoa_selection_clipboard_clear(void);
EAPI void ecore_cocoa_window_cursor_set(Ecore_Cocoa_Window *win, Ecore_Cocoa_Cursor c);
EAPI void ecore_cocoa_window_cursor_show(Ecore_Cocoa_Window *win, Eina_Bool show);
#ifdef __cplusplus
}

View File

@ -0,0 +1,32 @@
#ifndef __ECORE_COCOA_CURSOR_H__
#define __ECORE_COCOA_CURSOR_H__
typedef enum
{
ECORE_COCOA_CURSOR_ARROW = 0,
ECORE_COCOA_CURSOR_CONTEXTUAL_MENU,
ECORE_COCOA_CURSOR_CLOSED_HAND,
ECORE_COCOA_CURSOR_CROSSHAIR,
ECORE_COCOA_CURSOR_DISAPPEARING_ITEM,
ECORE_COCOA_CURSOR_DRAG_COPY,
ECORE_COCOA_CURSOR_DRAG_LINK,
ECORE_COCOA_CURSOR_IBEAM,
ECORE_COCOA_CURSOR_OPEN_HAND,
ECORE_COCOA_CURSOR_OPERATION_NOT_ALLOWED,
ECORE_COCOA_CURSOR_POINTING_HAND,
ECORE_COCOA_CURSOR_RESIZE_DOWN,
ECORE_COCOA_CURSOR_RESIZE_LEFT,
ECORE_COCOA_CURSOR_RESIZE_LEFT_RIGHT,
ECORE_COCOA_CURSOR_RESIZE_RIGHT,
ECORE_COCOA_CURSOR_RESIZE_UP,
ECORE_COCOA_CURSOR_RESIZE_UP_DOWN,
ECORE_COCOA_CURSOR_IBEAM_VERTICAL,
__ECORE_COCOA_CURSOR_LAST, /* Sentinel */
ECORE_COCOA_CURSOR_DEFAULT = ECORE_COCOA_CURSOR_ARROW
} Ecore_Cocoa_Cursor;
#endif /* ! __ECORE_COCOA_CURSOR_H__ */

View File

@ -12,13 +12,16 @@
#include <Ecore_Input.h>
#include "Ecore_Cocoa.h"
#include "Ecore_Cocoa_Keys.h"
#define _ECORE_COCOA_KEYS_MANUAL_GUARD_
#include "ecore_cocoa_keys.h"
#undef _ECORE_COCOA_KEYS_MANUAL_GUARD_
#include "ecore_cocoa_private.h"
EAPI int ECORE_COCOA_EVENT_GOT_FOCUS = 0;
EAPI int ECORE_COCOA_EVENT_LOST_FOCUS = 0;
EAPI int ECORE_COCOA_EVENT_RESIZE = 0;
EAPI int ECORE_COCOA_EVENT_EXPOSE = 0;
EAPI int ECORE_COCOA_EVENT_WINDOW_DESTROY = 0;
static int _ecore_cocoa_init_count = 0;
@ -33,8 +36,6 @@ ecore_cocoa_init(void)
if (++_ecore_cocoa_init_count != 1)
return _ecore_cocoa_init_count;
DBG("Ecore Cocoa Init");
if (!ecore_init())
return --_ecore_cocoa_init_count;
@ -48,12 +49,14 @@ ecore_cocoa_init(void)
return 0;
}
DBG("");
ECORE_COCOA_EVENT_GOT_FOCUS = ecore_event_type_new();
ECORE_COCOA_EVENT_LOST_FOCUS = ecore_event_type_new();
ECORE_COCOA_EVENT_RESIZE = ecore_event_type_new();
ECORE_COCOA_EVENT_EXPOSE = ecore_event_type_new();
ECORE_COCOA_EVENT_WINDOW_DESTROY = ecore_event_type_new();
/* Init the Application handler */
[Ecore_Cocoa_Application sharedApplication];
[NSApp setDelegate:[Ecore_Cocoa_AppDelegate appDelegate]];
@ -61,6 +64,9 @@ ecore_cocoa_init(void)
/* Start events monitoring */
[NSApp run];
if (!_ecore_cocoa_window_init())
return --_ecore_cocoa_init_count;
return _ecore_cocoa_init_count;
}
@ -85,7 +91,7 @@ ecore_cocoa_shutdown(void)
}
static unsigned int
_ecore_cocoa_event_modifiers(unsigned int mod)
_ecore_cocoa_event_modifiers(NSUInteger mod)
{
unsigned int modifiers = 0;
@ -95,13 +101,15 @@ _ecore_cocoa_event_modifiers(unsigned int mod)
if(mod & NSCommandKeyMask) modifiers |= ECORE_EVENT_MODIFIER_WIN;
if(mod & NSNumericPadKeyMask) modifiers |= ECORE_EVENT_LOCK_NUM;
DBG("key modifiers: %d, %d", mod, modifiers);
DBG("key modifiers: 0x%lx, %u", mod, modifiers);
return modifiers;
}
static inline Ecore_Event_Key*
_ecore_cocoa_event_key(NSEvent *event, int keyType)
static Ecore_Event_Key*
_ecore_cocoa_event_key(NSEvent *event,
NSEventType keyType,
unsigned int time)
{
static Eina_Bool compose = EINA_FALSE;
static NSText *edit;
@ -113,7 +121,7 @@ _ecore_cocoa_event_key(NSEvent *event, int keyType)
NSString *keychar = [event charactersIgnoringModifiers];
NSString *keycharRaw = [event characters];
DBG("Event Key, keyTpe : %d", keyType);
DBG("Event Key, keyType : %lu", keyType);
ev = calloc(1, sizeof (Ecore_Event_Key));
if (!ev) return NULL;
@ -124,6 +132,7 @@ _ecore_cocoa_event_key(NSEvent *event, int keyType)
compose=EINA_FALSE;
}
ev->timestamp = time;
ev->modifiers = _ecore_cocoa_event_modifiers([event modifierFlags]);
ev->keycode = event.keyCode;
@ -163,22 +172,8 @@ _ecore_cocoa_event_key(NSEvent *event, int keyType)
return ev;
}
static inline Eina_Bool
_nsevent_window_is_type_of(NSEvent *event, Class class)
{
/* An NSPeriodic event has no window (undefined behaviour) */
if ([event type] == NSPeriodic) return EINA_FALSE;
return [[event window] isKindOfClass:class];
}
static inline Eina_Bool
_has_ecore_cocoa_window(NSEvent *event)
{
return _nsevent_window_is_type_of(event, [EcoreCocoaWindow class]);
}
EAPI Eina_Bool
ecore_cocoa_feed_events(void *anEvent)
Eina_Bool
_ecore_cocoa_feed_events(void *anEvent)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(anEvent, EINA_FALSE);
@ -186,7 +181,7 @@ ecore_cocoa_feed_events(void *anEvent)
unsigned int time = (unsigned int)((unsigned long long)(ecore_time_get() * 1000.0) & 0xffffffff);
Eina_Bool pass = EINA_FALSE;
DBG("Feed events, event type ; %d", [event type]);
DBG("Feed events, event type ; %lu", [event type]);
switch ([event type])
{
@ -208,10 +203,9 @@ ecore_cocoa_feed_events(void *anEvent)
{
Ecore_Event_Key *ev;
ev = _ecore_cocoa_event_key(event, NSKeyDown);
ev = _ecore_cocoa_event_key(event, NSKeyDown, time);
if (ev == NULL) return EINA_TRUE;
ev->timestamp = time;
ecore_event_add(ECORE_EVENT_KEY_DOWN, ev, NULL, NULL);
break;
@ -220,17 +214,16 @@ ecore_cocoa_feed_events(void *anEvent)
{
Ecore_Event_Key *ev;
ev = _ecore_cocoa_event_key(event, NSKeyUp);
ev = _ecore_cocoa_event_key(event, NSKeyUp, time);
if (ev == NULL) return EINA_TRUE;
ev->timestamp = time;
ecore_event_add(ECORE_EVENT_KEY_UP, ev, NULL, NULL);
break;
}
case NSFlagsChanged:
{
int flags = [event modifierFlags];
NSUInteger flags = [event modifierFlags];
Ecore_Event_Key *evDown = NULL;
Ecore_Event_Key *evUp = NULL;
@ -268,7 +261,7 @@ ecore_cocoa_feed_events(void *anEvent)
return pass;
}
int changed_flags = flags ^ old_flags;
NSUInteger changed_flags = flags ^ old_flags;
// Turn special key flags off
if (changed_flags & NSShiftKeyMask)
@ -294,37 +287,6 @@ ecore_cocoa_feed_events(void *anEvent)
break;
}
case NSAppKitDefined:
{
if ([event subtype] == NSApplicationActivatedEventType)
{
Ecore_Cocoa_Event_Window *ev;
ev = malloc(sizeof(Ecore_Cocoa_Event_Window));
if (!ev)
{
pass = EINA_FALSE;
break;
}
ev->wid = [event window];
ecore_event_add(ECORE_COCOA_EVENT_GOT_FOCUS, ev, NULL, NULL);
}
else if ([event subtype] == NSApplicationDeactivatedEventType)
{
Ecore_Cocoa_Event_Window *ev;
ev = malloc(sizeof(Ecore_Cocoa_Event_Window));
if (!ev)
{
pass = EINA_FALSE;
break;
}
ev->wid = [event window];
ecore_event_add(ECORE_COCOA_EVENT_LOST_FOCUS, ev, NULL, NULL);
}
pass = EINA_TRUE; // pass along AppKit events, for window manager
break;
}
case NSScrollWheel:
{
DBG("Scroll Wheel");
@ -381,14 +343,14 @@ ecore_cocoa_feed_events(void *anEvent)
}
EAPI void
ecore_cocoa_screen_size_get(Ecore_Cocoa_Screen *screen, int *w, int *h)
ecore_cocoa_screen_size_get(Ecore_Cocoa_Screen *screen EINA_UNUSED, int *w, int *h)
{
NSSize pt = [[[NSScreen screens] objectAtIndex:0] frame].size;
DBG("Screen size get : %dx%d", w, h);
if (w) *w = (int)pt.width;
if (h) *h = (int)pt.height;
DBG("Screen size get : %dx%d", (int)pt.width, (int)pt.height);
}
EAPI int

View File

@ -18,13 +18,15 @@
- (id)init;
- (void)internalUpdate;
- (void) pauseNSRunLoopMonitoring;
- (void) resumeNSRunLoopMonitoring;
@end
@interface Ecore_Cocoa_AppDelegate : NSObject <NSApplicationDelegate>
+ (Ecore_Cocoa_AppDelegate *)appDelegate;
- (id)init;
@end

View File

@ -52,10 +52,17 @@ _ecore_cocoa_run_loop_cb(void *data EINA_UNUSED)
{
self = [super init];
if (self == nil) {
// XXX Critical error. Abort right now! Log?
CRI("Failed to [super init]");
return nil;
}
NSApp = self; // NSApp is used EVERYWHERE! Set it right now!
/* Set the process to be a foreground process,
* without that it prevents the window to become the key window and
* receive all mouse mouve events. */
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
[NSApp activateIgnoringOtherApps:YES];
return NSApp;
}
@ -83,11 +90,26 @@ _ecore_cocoa_run_loop_cb(void *data EINA_UNUSED)
/* Some events shall be handled by Ecore (like single non-command keys).
* If we dispatch all events right to NSApplication, it will complain
* with NSBeep() when an event is not authorized */
to_super = ecore_cocoa_feed_events(anEvent);
to_super = _ecore_cocoa_feed_events(anEvent);
if (to_super)
[super sendEvent:anEvent];
}
- (void) pauseNSRunLoopMonitoring
{
/*
* After calling this method, we will run an iteration of
* the main loop. We don't want this timer to be fired while
* calling manually the ecore loop, because it will query the
* NSRunLoop, which blocks during live resize.
*/
ecore_timer_freeze(_timer);
}
- (void) resumeNSRunLoopMonitoring
{
ecore_timer_thaw(_timer);
}
@end
@ -105,13 +127,7 @@ static Ecore_Cocoa_AppDelegate *_appDelegate = nil;
return _appDelegate;
}
- (id)init
{
self = [super init];
return self;
}
- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *)sender
- (BOOL)applicationShouldTerminateAfterLastWindowClosed:(NSApplication *) EINA_UNUSED sender
{
// XXX This should be alterable (by Elm_Window policy)
return YES;

View File

@ -0,0 +1,173 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <Eina.h>
#include <Evas.h>
#import <Cocoa/Cocoa.h>
#import "ecore_cocoa_window.h"
#include "ecore_cocoa_private.h"
#import "ecore_cocoa_app.h"
EAPI Eina_Bool
ecore_cocoa_selection_clipboard_set(const void *data,
int size,
Ecore_Cocoa_Cnp_Type type)
{
NSMutableArray *objects;
NSString *str = nil;
BOOL ok = YES;
objects = [[NSMutableArray alloc] init];
if (type & ECORE_COCOA_CNP_TYPE_STRING)
{
str = [[NSString alloc] initWithBytes: data
length: size
encoding: NSUTF8StringEncoding];
[objects addObject: str];
}
if (type & ECORE_COCOA_CNP_TYPE_MARKUP)
{
char *utf8;
utf8 = evas_textblock_text_markup_to_utf8(NULL, (const char *)data);
str = [[NSString alloc] initWithBytes: utf8
length: strlen(utf8) // XXX strlen() ?
encoding: NSUTF8StringEncoding];
free(utf8);
[objects addObject: str];
}
if (type & ECORE_COCOA_CNP_TYPE_IMAGE)
{
WRN("Image CNP: NOT IMPLEMENTED");
}
if (type & ECORE_COCOA_CNP_TYPE_HTML)
{
WRN("HTML CNP: NOT IMPLEMENTED");
}
/* Write to pasteboard */
if ([objects count] > 0)
{
NSPasteboard *pb;
pb = [NSPasteboard generalPasteboard];
[pb clearContents];
ok = [pb writeObjects: objects];
[objects removeAllObjects];
}
return (ok) ? EINA_TRUE : EINA_FALSE;
}
EAPI void *
ecore_cocoa_selection_clipboard_get(int *size,
Ecore_Cocoa_Cnp_Type type,
Ecore_Cocoa_Cnp_Type *retrieved_types)
{
NSMutableArray *classes;
void *data;
NSDictionary *options;
NSPasteboard *pb;
NSArray *items;
unsigned int len;
BOOL string_class = NO;
Ecore_Cocoa_Cnp_Type types = 0;
classes = [[NSMutableArray alloc] init];
if ((type & ECORE_COCOA_CNP_TYPE_STRING) ||
(type & ECORE_COCOA_CNP_TYPE_MARKUP))
{
string_class = YES;
[classes addObject: [NSString class]];
}
if (type & ECORE_COCOA_CNP_TYPE_IMAGE)
{
WRN("Image CNP: NOT IMPLEMENTED");
}
if (type & ECORE_COCOA_CNP_TYPE_HTML)
{
WRN("HTML CNP: NOT IMPLEMENTED");
}
if ([classes count] <= 0)
{
ERR("No registered classes... got nothing from pasteboard");
goto fail;
}
pb = [NSPasteboard generalPasteboard];
options = [NSDictionary dictionary];
items = [pb readObjectsForClasses: classes
options: options];
if (!items)
{
ERR("No items in the clipboard");
goto remove_fail;
}
if ([items count] != 1)
{
ERR("%lu items in pasteboard. Only one at the time can be handled",
[items count]);
goto fail;
}
if (string_class)
{
NSString *str = [items objectAtIndex: 0];
data = (void *)[str UTF8String];
len = [str lengthOfBytesUsingEncoding: NSUTF8StringEncoding];
data = strndup((const char *)data, len);
if (EINA_UNLIKELY(!data))
{
CRI("Failed to strndup() string \"%s\" (len: %u)",
(const char *)data, len);
goto remove_fail;
}
types |= ECORE_COCOA_CNP_TYPE_STRING;
// if (type & ECORE_COCOA_CNP_TYPE_MARKUP)
// {
// char *markup;
// markup = evas_textblock_text_utf8_to_markup(NULL, data);
// free(data);
// data = markup;
// if (EINA_UNLIKELY(!data))
// {
// CRI("Failed to retrieve markup from UTF8");
// goto remove_fail;
// }
// len = strlen(markup);
// }
}
if (!types)
{
ERR("No types retrieved!");
goto remove_fail;
}
[classes removeAllObjects];
if (size) *size = len;
if (retrieved_types) *retrieved_types = types;
return data;
remove_fail:
[classes removeAllObjects];
fail:
if (size) *size = 0;
if (retrieved_types) *retrieved_types = 0;
return NULL;
}
EAPI void
ecore_cocoa_selection_clipboard_clear(void)
{
[[NSPasteboard generalPasteboard] clearContents];
}

View File

@ -1,6 +1,12 @@
#ifndef ECORE_COCOA_KEYS_H__
#define ECORE_COCOA_KEYS_H__
/* Prevent innocent devs to include this directly. */
#ifndef _ECORE_COCOA_KEYS_MANUAL_GUARD_
# error This header must be be included directly!
#endif
struct _ecore_cocoa_keys_s
{
int code;

View File

@ -62,4 +62,11 @@ struct _Ecore_Cocoa_Window
};
/* Internal init */
Eina_Bool _ecore_cocoa_window_init(void);
Eina_Bool _ecore_cocoa_feed_events(void *anEvent);
#endif

View File

@ -6,9 +6,14 @@
#include <Ecore.h>
#include <Ecore_Cocoa.h>
#include <Ecore_Cocoa_Cursor.h>
#import "ecore_cocoa_window.h"
#import "ecore_cocoa_app.h"
#include "ecore_cocoa_private.h"
static NSCursor *_cursors[__ECORE_COCOA_CURSOR_LAST];
@implementation EcoreCocoaWindow
@synthesize ecore_window_data;
@ -48,31 +53,30 @@
return YES;
}
- (void)windowWillClose:(NSNotification *) EINA_UNUSED notification
- (void)windowWillClose:(NSNotification *) notification
{
NSLog(@"window is going to be closed");
Ecore_Cocoa_Event_Window *event;
event = malloc(sizeof(Ecore_Cocoa_Event_Window));
if (event == NULL)
event = malloc(sizeof(*event));
if (EINA_UNLIKELY(event == NULL))
{
// FIXME Use Eina_Log
printf("Failed to allocate Ecore_Cocoa_Event_Window_destroy\n");
CRI("Failed to allocate Ecore_Cocoa_Event_Window");
return;
}
event->wid = [notification object];
ecore_event_add(ECORE_COCOA_EVENT_WINDOW_DESTROY, event, NULL, NULL);
}
- (void)windowDidResize:(NSNotification *) EINA_UNUSED notif
- (void)windowDidResize:(NSNotification *) notif
{
Ecore_Cocoa_Event_Video_Resize *event;
NSSize size = self.frame.size;
event = malloc(sizeof(Ecore_Cocoa_Event_Video_Resize));
if (event == NULL)
event = malloc(sizeof(*event));
if (EINA_UNLIKELY(event == NULL))
{
DBG("Failed to allocate Ecore_Cocoa_Event_Video_Resize\n");
CRI("Failed to allocate Ecore_Cocoa_Event_Video_Resize");
return;
}
event->w = size.width;
@ -80,30 +84,51 @@
(([self isFullScreen] == YES) ? 0 : ecore_cocoa_titlebar_height_get());
event->wid = [notif object];
ecore_event_add(ECORE_COCOA_EVENT_RESIZE, event, NULL, NULL);
/*
* During live resize, NSRunLoop blocks, and prevent the ecore_main_loop
* to be run.
* This, combined with the -pauseNSRunLoopMonitoring and
* -resumeNSRunLoopMonitoring methods invoked in
* -windowWillStartLiveResize and -windowDidEndLiveResize
* allow the ecore_main_loop to run withing NSRunLoop during the
* live resizing of a window.
*/
ecore_main_loop_iterate();
}
- (void)windowDidBecomeKey:(NSNotification *)notification
{
Ecore_Cocoa_Event_Window *e;
e = malloc(sizeof(Ecore_Cocoa_Event_Window));
if (!e)
e = malloc(sizeof(*e));
if (EINA_UNLIKELY(e == NULL))
{
DBG("GOT_FOCUS: Failed to allocate Ecore_Cocoa_Event_Window\n");
CRI("Failed to allocate Ecore_Cocoa_Event_Window");
return;
}
e->wid = [notification object];
ecore_event_add(ECORE_COCOA_EVENT_GOT_FOCUS, e, NULL, NULL);
}
- (void) windowWillStartLiveResize:(NSNotification *) EINA_UNUSED notification
{
[NSApp pauseNSRunLoopMonitoring];
}
- (void) windowDidEndLiveResize:(NSNotification *) EINA_UNUSED notification
{
[NSApp resumeNSRunLoopMonitoring];
}
- (void)windowDidResignKey:(NSNotification *)notification
{
Ecore_Cocoa_Event_Window *e;
e = malloc(sizeof(Ecore_Cocoa_Event_Window));
if (!e)
e = malloc(sizeof(*e));
if (EINA_UNLIKELY(e == NULL))
{
DBG("LOST_FOCUS: Failed to allocate Ecore_Cocoa_Event_Window\n");
CRI("Failed to allocate Ecore_Cocoa_Event_Window");
return;
}
e->wid = [notification object];
@ -129,7 +154,12 @@
}
Ecore_Event_Mouse_Button * ev = calloc(1, sizeof(Ecore_Event_Mouse_Button));
if (!ev) return;
if (EINA_UNLIKELY(!ev))
{
CRI("Failed to allocate Ecore_Event_Mouse_Button");
return;
}
ev->x = x;
ev->y = y;
@ -181,8 +211,12 @@
int x = pt.x;
int y = h - pt.y;
Ecore_Event_Mouse_Button * ev = calloc(1, sizeof(Ecore_Event_Mouse_Button));
if (!ev) return;
Ecore_Event_Mouse_Button *ev = calloc(1, sizeof(*ev));
if (EINA_UNLIKELY(!ev))
{
CRI("Failed to allocate Ecore_Event_Mouse_Button");
return;
}
ev->x = x;
ev->y = y;
@ -225,8 +259,12 @@
- (void) mouseMoved:(NSEvent*) event
{
unsigned int time = (unsigned int)((unsigned long long)(ecore_time_get() * 1000.0) & 0xffffffff);
Ecore_Event_Mouse_Move * ev = calloc(1, sizeof(Ecore_Event_Mouse_Move));
if (!ev) return;
Ecore_Event_Mouse_Move *ev = calloc(1, sizeof(*ev));
if (EINA_UNLIKELY(!ev))
{
CRI("Failed to allocate Ecore_Event_Mouse_Move");
return;
}
NSView *view = [self contentView];
NSPoint event_location = [event locationInWindow];
@ -251,35 +289,36 @@
@end
Ecore_Cocoa_Window *
EAPI Ecore_Cocoa_Window *
ecore_cocoa_window_new(int x,
int y,
int width,
int height)
{
Ecore_Cocoa_Window *w;
EcoreCocoaWindow *window = [[EcoreCocoaWindow alloc] initWithContentRect:NSMakeRect(x, y, width, height)
styleMask:(NSTitledWindowMask |
EcoreCocoaWindow *window;
NSRect frame = NSMakeRect(x, y, width, height);
NSUInteger style =
NSTitledWindowMask |
NSClosableWindowMask |
NSResizableWindowMask |
NSMiniaturizableWindowMask)
NSMiniaturizableWindowMask;
window = [[EcoreCocoaWindow alloc] initWithContentRect:frame
styleMask:style
backing:NSBackingStoreBuffered
defer:NO];
if (!window)
if (EINA_UNLIKELY(!window))
{
CRI("Failed to create EcoreCocoaWindow");
return NULL;
//Set the process to be a foreground process,
//without that it prevents the window to become the key window and
//receive all mouse mouve events.
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
[NSApp activateIgnoringOtherApps:YES];
}
w = calloc(1, sizeof(Ecore_Cocoa_Window));
if (w == NULL)
if (EINA_UNLIKELY(w == NULL))
{
CRI("Failed to allocate Ecore_Cocoa_Window");
[window release];
return NULL;
}
w->window = window;
@ -290,7 +329,7 @@ ecore_cocoa_window_new(int x,
return w;
}
void
EAPI void
ecore_cocoa_window_free(Ecore_Cocoa_Window *window)
{
if (!window)
@ -300,48 +339,47 @@ ecore_cocoa_window_free(Ecore_Cocoa_Window *window)
free(window);
}
void
EAPI void
ecore_cocoa_window_size_min_set(Ecore_Cocoa_Window *window,
unsigned int w,
unsigned int h)
{
if (!window)
return;
EINA_SAFETY_ON_NULL_RETURN(window);
NSSize size = {w,h};
window->window.contentMinSize = size;
}
void
EAPI void
ecore_cocoa_window_size_max_set(Ecore_Cocoa_Window *window,
unsigned int w,
unsigned int h)
{
if (!window)
return;
EINA_SAFETY_ON_NULL_RETURN(window);
NSSize size = {w,h};
window->window.contentMaxSize = size;
}
void
EAPI void
ecore_cocoa_window_size_step_set(Ecore_Cocoa_Window *window,
unsigned int w,
unsigned int h)
{
if (!window)
return;
EINA_SAFETY_ON_NULL_RETURN(window);
NSSize size = {w,h};
window->window.contentResizeIncrements = size;
}
void
EAPI void
ecore_cocoa_window_move(Ecore_Cocoa_Window *window,
int x,
int y)
{
NSRect win_frame;
EINA_SAFETY_ON_NULL_RETURN(window);
if (!window)
return;
NSRect win_frame;
win_frame = [window->window frame];
win_frame.origin.x = x;
@ -350,12 +388,12 @@ ecore_cocoa_window_move(Ecore_Cocoa_Window *window,
[window->window setFrame:win_frame display:YES];
}
void
EAPI void
ecore_cocoa_window_resize(Ecore_Cocoa_Window *window,
int width,
int height)
{
if (!window) return;
EINA_SAFETY_ON_NULL_RETURN(window);
NSRect win_frame;
@ -367,14 +405,14 @@ ecore_cocoa_window_resize(Ecore_Cocoa_Window *window,
[window->window setFrame:win_frame display:YES];
}
void
EAPI void
ecore_cocoa_window_move_resize(Ecore_Cocoa_Window *window,
int x,
int y,
int width,
int height)
{
if (!window) return;
EINA_SAFETY_ON_NULL_RETURN(window);
NSRect win_frame;
@ -388,65 +426,59 @@ ecore_cocoa_window_move_resize(Ecore_Cocoa_Window *window,
[window->window setFrame:win_frame display:YES];
}
void
EAPI void
ecore_cocoa_window_title_set(Ecore_Cocoa_Window *window, const char *title)
{
if (!window || !title)
return;
EINA_SAFETY_ON_NULL_RETURN(window);
EINA_SAFETY_ON_NULL_RETURN(title);
[window->window setTitle:[NSString stringWithUTF8String:title]];
}
void
EAPI void
ecore_cocoa_window_show(Ecore_Cocoa_Window *window)
{
if (!window || [window->window isVisible])
{
DBG("Window(%p) is not visible\n", window->window);
return;
}
EINA_SAFETY_ON_NULL_RETURN(window);
if (![window->window isVisible])
[window->window makeKeyAndOrderFront:NSApp];
}
void
EAPI void
ecore_cocoa_window_hide(Ecore_Cocoa_Window *window)
{
if (!window || ![window->window isVisible])
return;
EINA_SAFETY_ON_NULL_RETURN(window);
if (![window->window isVisible])
[window->window orderOut:NSApp];
}
void ecore_cocoa_window_raise(Ecore_Cocoa_Window *window)
EAPI void
ecore_cocoa_window_raise(Ecore_Cocoa_Window *window)
{
if (!window)
return;
EINA_SAFETY_ON_NULL_RETURN(window);
[window->window orderFront:nil];
}
void ecore_cocoa_window_lower(Ecore_Cocoa_Window *window)
EAPI void
ecore_cocoa_window_lower(Ecore_Cocoa_Window *window)
{
if (!window)
return;
EINA_SAFETY_ON_NULL_RETURN(window);
[window->window orderBack:nil];
}
void ecore_cocoa_window_activate(Ecore_Cocoa_Window *window)
EAPI void
ecore_cocoa_window_activate(Ecore_Cocoa_Window *window)
{
if (!window)
return;
EINA_SAFETY_ON_NULL_RETURN(window);
[window->window makeKeyAndOrderFront:nil];
}
void ecore_cocoa_window_iconified_set(Ecore_Cocoa_Window *window,
EAPI void
ecore_cocoa_window_iconified_set(Ecore_Cocoa_Window *window,
int on)
{
if (!window)
return;
EINA_SAFETY_ON_NULL_RETURN(window);
if (on)
{
@ -458,24 +490,23 @@ void ecore_cocoa_window_iconified_set(Ecore_Cocoa_Window *window,
}
}
void
EAPI void
ecore_cocoa_window_borderless_set(Ecore_Cocoa_Window *window,
int on)
{
if (!window)
return;
EINA_SAFETY_ON_NULL_RETURN(window);
if (on)
[window->window setContentBorderThickness:0.0
forEdge:NSMinXEdge | NSMinYEdge | NSMaxXEdge | NSMaxYEdge];
}
void
EAPI void
ecore_cocoa_window_view_set(Ecore_Cocoa_Window *window,
void *view)
{
if (!window || !view)
return;
EINA_SAFETY_ON_NULL_RETURN(window);
EINA_SAFETY_ON_NULL_RETURN(view);
//[[window->window contentView] addSubview:view];
NSView *v = view;
@ -492,12 +523,58 @@ ecore_cocoa_window_view_set(Ecore_Cocoa_Window *window,
[area release];
}
Ecore_Cocoa_Window_Id ecore_cocoa_window_get_window_id(Ecore_Cocoa_Window *window)
EAPI Ecore_Cocoa_Window_Id
ecore_cocoa_window_get_window_id(const Ecore_Cocoa_Window *window)
{
if (!window)
return 0;
DBG("Return : %p", window->window);
EINA_SAFETY_ON_NULL_RETURN_VAL(window, NULL);
return window->window;
}
EAPI void
ecore_cocoa_window_cursor_set(Ecore_Cocoa_Window *win,
Ecore_Cocoa_Cursor c)
{
EINA_SAFETY_ON_NULL_RETURN(win);
EINA_SAFETY_ON_FALSE_RETURN((c >= 0) && (c <= __ECORE_COCOA_CURSOR_LAST));
NSCursor *cursor = _cursors[c];
DBG("Setting cursor %i (%s)", c, [[cursor description] UTF8String]);
[cursor set];
}
EAPI void
ecore_cocoa_window_cursor_show(Ecore_Cocoa_Window *win,
Eina_Bool show)
{
EINA_SAFETY_ON_NULL_RETURN(win);
if (show) [NSCursor unhide];
else [NSCursor hide];
}
Eina_Bool
_ecore_cocoa_window_init(void)
{
_cursors[ECORE_COCOA_CURSOR_ARROW] = [NSCursor arrowCursor];
_cursors[ECORE_COCOA_CURSOR_CONTEXTUAL_MENU] = [NSCursor contextualMenuCursor];
_cursors[ECORE_COCOA_CURSOR_CLOSED_HAND] = [NSCursor closedHandCursor];
_cursors[ECORE_COCOA_CURSOR_CROSSHAIR] = [NSCursor crosshairCursor];
_cursors[ECORE_COCOA_CURSOR_DISAPPEARING_ITEM] = [NSCursor disappearingItemCursor];
_cursors[ECORE_COCOA_CURSOR_DRAG_COPY] = [NSCursor dragCopyCursor];
_cursors[ECORE_COCOA_CURSOR_DRAG_LINK] = [NSCursor dragLinkCursor];
_cursors[ECORE_COCOA_CURSOR_IBEAM] = [NSCursor IBeamCursor];
_cursors[ECORE_COCOA_CURSOR_OPEN_HAND] = [NSCursor openHandCursor];
_cursors[ECORE_COCOA_CURSOR_OPERATION_NOT_ALLOWED] = [NSCursor operationNotAllowedCursor];
_cursors[ECORE_COCOA_CURSOR_POINTING_HAND] = [NSCursor pointingHandCursor];
_cursors[ECORE_COCOA_CURSOR_RESIZE_DOWN] = [NSCursor resizeDownCursor];
_cursors[ECORE_COCOA_CURSOR_RESIZE_LEFT] = [NSCursor resizeLeftCursor];
_cursors[ECORE_COCOA_CURSOR_RESIZE_LEFT_RIGHT] = [NSCursor resizeLeftRightCursor];
_cursors[ECORE_COCOA_CURSOR_RESIZE_RIGHT] = [NSCursor resizeRightCursor];
_cursors[ECORE_COCOA_CURSOR_RESIZE_UP] = [NSCursor resizeUpCursor];
_cursors[ECORE_COCOA_CURSOR_RESIZE_UP_DOWN] = [NSCursor resizeUpDownCursor];
_cursors[ECORE_COCOA_CURSOR_IBEAM_VERTICAL] = [NSCursor IBeamCursorForVerticalLayout];
return EINA_TRUE;
}

View File

@ -1317,6 +1317,8 @@ EAPI void ecore_evas_wayland_pointer_set(Ecore_Evas *ee, int hot_x, i
EAPI void ecore_evas_wayland_type_set(Ecore_Evas *ee, int type);
EAPI Ecore_Wl_Window *ecore_evas_wayland_window_get(const Ecore_Evas *ee);
EAPI Ecore_Cocoa_Window *ecore_evas_cocoa_window_get(const Ecore_Evas *ee);
EAPI Ecore_Evas *ecore_evas_drm_new(const char *device, unsigned int parent, int x, int y, int w, int h);
EAPI Ecore_Evas *ecore_evas_gl_drm_new(const char *device, unsigned int parent, int x, int y, int w, int h); /** @since 1.12 */

View File

@ -33,6 +33,7 @@ typedef struct _Ecore_WinCE_Window Ecore_WinCE_Window;
#endif
#ifndef __ECORE_COCOA_H__
# define _ECORE_COCOA_WINDOW_PREDEF
typedef struct _Ecore_Cocoa_Window Ecore_Cocoa_Window;
#endif

View File

@ -30,6 +30,7 @@
#include "ecore_evas_private.h"
#include "ecore_evas_x11.h"
#include "ecore_evas_wayland.h"
#include "ecore_evas_cocoa.h"
#include "ecore_evas_extn.h"
#include "ecore_evas_win32.h"
@ -3983,6 +3984,15 @@ ecore_evas_wayland_window_get(const Ecore_Evas *ee)
return iface->window_get(ee);
}
EAPI Ecore_Cocoa_Window *
ecore_evas_cocoa_window_get(const Ecore_Evas *ee)
{
Ecore_Evas_Interface_Cocoa *iface;
iface = (Ecore_Evas_Interface_Cocoa *)_ecore_evas_interface_get(ee, "opengl_cocoa");
EINA_SAFETY_ON_NULL_RETURN_VAL(iface, NULL);
return iface->window_get(ee);
}
EAPI Ecore_Evas *
ecore_evas_drm_new(const char *disp_name, unsigned int parent,
int x, int y, int w, int h)

View File

@ -0,0 +1,14 @@
#ifndef __ECORE_EVAS_COCOA_H__
#define __ECORE_EVAS_COCOA_H__
typedef struct _Ecore_Evas_Interface_Cocoa Ecore_Evas_Interface_Cocoa;
struct _Ecore_Evas_Interface_Cocoa
{
Ecore_Evas_Interface base;
Ecore_Cocoa_Window *(*window_get)(const Ecore_Evas *ee);
};
#endif /* ! __ECORE_EVAS_COCOA_H__ */

View File

@ -29,7 +29,6 @@
/*
* FIXME: the following functions will certainly not work on Windows:
* ecore_file_file_get()
* ecore_file_app_exe_get()
* ecore_file_escape_name()
*/
@ -773,6 +772,23 @@ ecore_file_file_get(const char *path)
char *result = NULL;
if (!path) return NULL;
#ifdef _WIN32
{
char buf[MAX_PATH];
memcpy(buf, path, strlen(path) + 1);
EVIL_PATH_SEP_UNIX_TO_WIN32(buf);
if ((result = strrchr(buf, '\\')))
{
result++;
return path + (result - buf);
}
else
return path;
}
#endif
if ((result = strrchr(path, '/'))) result++;
else result = (char *)path;

View File

@ -116,6 +116,91 @@ typedef enum
ECORE_WIN32_CURSOR_SHAPE_WAIT /**< Hourglass */
} Ecore_Win32_Cursor_Shape;
/**
* @typedef Ecore_Win32_Cursor_X11_Shape
* Shape of an X11 cursor.
*/
typedef enum
{
ECORE_WIN32_CURSOR_X11_SHAPE_X,
ECORE_WIN32_CURSOR_X11_SHAPE_ARROW,
ECORE_WIN32_CURSOR_X11_SHAPE_BASED_ARROW_DOWN,
ECORE_WIN32_CURSOR_X11_SHAPE_UP,
ECORE_WIN32_CURSOR_X11_SHAPE_BOAT,
ECORE_WIN32_CURSOR_X11_SHAPE_BOGOSITY,
ECORE_WIN32_CURSOR_X11_SHAPE_BOTTOM_LEFT_CORNER,
ECORE_WIN32_CURSOR_X11_SHAPE_BOTTOM_RIGHT_CORNER,
ECORE_WIN32_CURSOR_X11_SHAPE_BOTTOM_SIDE,
ECORE_WIN32_CURSOR_X11_SHAPE_BOTTOM_TEE,
ECORE_WIN32_CURSOR_X11_SHAPE_BOX_SPIRAL,
ECORE_WIN32_CURSOR_X11_SHAPE_CENTER_PTR,
ECORE_WIN32_CURSOR_X11_SHAPE_CIRCLE,
ECORE_WIN32_CURSOR_X11_SHAPE_CLOCK,
ECORE_WIN32_CURSOR_X11_SHAPE_COFFEE_MUG,
ECORE_WIN32_CURSOR_X11_SHAPE_CROSS,
ECORE_WIN32_CURSOR_X11_SHAPE_CROSS_REVERSE,
ECORE_WIN32_CURSOR_X11_SHAPE_CROSSHAIR,
ECORE_WIN32_CURSOR_X11_SHAPE_DIAMOND_CROSS,
ECORE_WIN32_CURSOR_X11_SHAPE_DOT,
ECORE_WIN32_CURSOR_X11_SHAPE_DOT_BOX_MASK,
ECORE_WIN32_CURSOR_X11_SHAPE_DOUBLE_ARROW,
ECORE_WIN32_CURSOR_X11_SHAPE_DRAFT_LARGE,
ECORE_WIN32_CURSOR_X11_SHAPE_DRAFT_SMALL,
ECORE_WIN32_CURSOR_X11_SHAPE_DRAPED_BOX,
ECORE_WIN32_CURSOR_X11_SHAPE_EXCHANGE,
ECORE_WIN32_CURSOR_X11_SHAPE_FLEUR,
ECORE_WIN32_CURSOR_X11_SHAPE_GOBBLER,
ECORE_WIN32_CURSOR_X11_SHAPE_GUMBY,
ECORE_WIN32_CURSOR_X11_SHAPE_HAND1,
ECORE_WIN32_CURSOR_X11_SHAPE_HAND2,
ECORE_WIN32_CURSOR_X11_SHAPE_HEART,
ECORE_WIN32_CURSOR_X11_SHAPE_ICON,
ECORE_WIN32_CURSOR_X11_SHAPE_IRON_CROSS,
ECORE_WIN32_CURSOR_X11_SHAPE_LEFT_PTR,
ECORE_WIN32_CURSOR_X11_SHAPE_LEFT_SIDE,
ECORE_WIN32_CURSOR_X11_SHAPE_LEFT_TEE,
ECORE_WIN32_CURSOR_X11_SHAPE_LEFTBUTTON,
ECORE_WIN32_CURSOR_X11_SHAPE_LL_ANGLE,
ECORE_WIN32_CURSOR_X11_SHAPE_LR_ANGLE,
ECORE_WIN32_CURSOR_X11_SHAPE_MAN,
ECORE_WIN32_CURSOR_X11_SHAPE_MIDDLEBUTTON,
ECORE_WIN32_CURSOR_X11_SHAPE_MOUSE,
ECORE_WIN32_CURSOR_X11_SHAPE_PENCIL,
ECORE_WIN32_CURSOR_X11_SHAPE_PIRATE,
ECORE_WIN32_CURSOR_X11_SHAPE_PLUS,
ECORE_WIN32_CURSOR_X11_SHAPE_QUESTION_ARROW,
ECORE_WIN32_CURSOR_X11_SHAPE_RIGHT_PTR,
ECORE_WIN32_CURSOR_X11_SHAPE_RIGHT_SIDE,
ECORE_WIN32_CURSOR_X11_SHAPE_RIGHT_TEE,
ECORE_WIN32_CURSOR_X11_SHAPE_RIGHTBUTTON,
ECORE_WIN32_CURSOR_X11_SHAPE_RTL_LOGO,
ECORE_WIN32_CURSOR_X11_SHAPE_SAILBOAT,
ECORE_WIN32_CURSOR_X11_SHAPE_SB_DOWN_ARROW,
ECORE_WIN32_CURSOR_X11_SHAPE_SB_H_DOUBLE_ARROW,
ECORE_WIN32_CURSOR_X11_SHAPE_SB_LEFT_ARROW,
ECORE_WIN32_CURSOR_X11_SHAPE_SB_RIGHT_ARROW,
ECORE_WIN32_CURSOR_X11_SHAPE_SB_UP_ARROW,
ECORE_WIN32_CURSOR_X11_SHAPE_SB_V_DOUBLE_ARROW,
ECORE_WIN32_CURSOR_X11_SHAPE_SHUTTLE,
ECORE_WIN32_CURSOR_X11_SHAPE_SIZING,
ECORE_WIN32_CURSOR_X11_SHAPE_SPIDER,
ECORE_WIN32_CURSOR_X11_SHAPE_SPRAYCAN,
ECORE_WIN32_CURSOR_X11_SHAPE_STAR,
ECORE_WIN32_CURSOR_X11_SHAPE_TARGET,
ECORE_WIN32_CURSOR_X11_SHAPE_TCROSS,
ECORE_WIN32_CURSOR_X11_SHAPE_TOP_LEFT_ARROW,
ECORE_WIN32_CURSOR_X11_SHAPE_TOP_LEFT_CORNER,
ECORE_WIN32_CURSOR_X11_SHAPE_TOP_RIGHT_CORNER,
ECORE_WIN32_CURSOR_X11_SHAPE_TOP_SIDE,
ECORE_WIN32_CURSOR_X11_SHAPE_TOP_TEE,
ECORE_WIN32_CURSOR_X11_SHAPE_TREK,
ECORE_WIN32_CURSOR_X11_SHAPE_UL_ANGLE,
ECORE_WIN32_CURSOR_X11_SHAPE_UMBRELLA,
ECORE_WIN32_CURSOR_X11_SHAPE_UR_ANGLE,
ECORE_WIN32_CURSOR_X11_SHAPE_WATCH,
ECORE_WIN32_CURSOR_X11_SHAPE_XTERM,
} Ecore_Win32_Cursor_X11_Shape;
/**
* @typedef Ecore_Win32_DnD_State
* State of a DnD operation.
@ -128,6 +213,21 @@ typedef enum
ECORE_WIN32_DND_EVENT_DROP = 4 /**< Drop */
} Ecore_Win32_DnD_State;
/**
* @typedef Ecore_Win32_Selection
* Type of the selection.
*
* @since 1.16
*/
typedef enum
{
ECORE_WIN32_SELECTION_PRIMARY,
ECORE_WIN32_SELECTION_SECONDARY,
ECORE_WIN32_SELECTION_DND,
ECORE_WIN32_SELECTION_CLIPBOARD,
ECORE_WIN32_SELECTION_OTHER
} Ecore_Win32_Selection;
/**
* @typedef Ecore_Win32_Window
* Abstract type for a window.
@ -213,6 +313,22 @@ typedef struct _Ecore_Win32_Event_Window_Resize Ecore_Win32_Event_Window
*/
typedef struct _Ecore_Win32_Event_Window_Delete_Request Ecore_Win32_Event_Window_Delete_Request;
/**
* @typedef Ecore_Win32_Event_Selection_Clear
* Event sent when the content of the clipboard has been removed.
*
* @since 1.16
*/
typedef struct _Ecore_Win32_Event_Selection_Clear Ecore_Win32_Event_Selection_Clear;
/**
* @typedef Ecore_Win32_Event_Selection_Notify
* Event sent when the content of the clipboard has been added.
*
* @since 1.16
*/
typedef struct _Ecore_Win32_Event_Selection_Notify Ecore_Win32_Event_Selection_Notify;
/**
* @struct _Ecore_Win32_Event_Mouse_In
* Event sent when the mouse enters the window.
@ -350,6 +466,33 @@ struct _Ecore_Win32_Event_Window_Delete_Request
unsigned long timestamp; /**< The time the event occurred */
};
/**
* @struct _Ecore_Win32_Event_Selection_Clear
* Event sent when the content of the clipboard has been removed.
*
* @since 1.16
*/
struct _Ecore_Win32_Event_Selection_Clear
{
Ecore_Win32_Window *window; /**< The window that received the event */
unsigned long timestamp; /**< The time the event occurred */
Ecore_Win32_Selection selection; /**< The type of the selection */
};
/**
* @struct _Ecore_Win32_Event_Selection_Notify
* Event sent when the content of the clipboard has been added.
*
* @since 1.16
*/
struct _Ecore_Win32_Event_Selection_Notify
{
Ecore_Win32_Window *window; /**< The window that received the event */
unsigned long timestamp; /**< The time the event occurred */
Ecore_Win32_Selection selection; /**< The type of the selection */
void *data; /**< The data of the selection */
};
/**
* @typedef Ecore_Win32_Dnd_DropTarget_Callback
* Callback type for Drop operations. See ecore_win32_dnd_register_drop_target().
@ -368,6 +511,8 @@ EAPI extern int ECORE_WIN32_EVENT_WINDOW_SHOW; /**< Ecore_Event for the Ecore_Wi
EAPI extern int ECORE_WIN32_EVENT_WINDOW_CONFIGURE; /**< Ecore_Event for the Ecore_Win32_Event_Configure event */
EAPI extern int ECORE_WIN32_EVENT_WINDOW_RESIZE; /**< Ecore_Event for the Ecore_Win32_Event_Resize event */
EAPI extern int ECORE_WIN32_EVENT_WINDOW_DELETE_REQUEST; /**< Ecore_Event for the #Ecore_Win32_Event_Window_Delete_Request event */
EAPI extern int ECORE_WIN32_EVENT_SELECTION_CLEAR; /**< Ecore_Event for the #Ecore_Win32_Event_Selection_Clear event @since 1.16 */
EAPI extern int ECORE_WIN32_EVENT_SELECTION_NOTIFY; /**< Ecore_Event for the #Ecore_Win32_Event_Selection_Notify event @since 1.16 */
/* Core */
@ -503,6 +648,8 @@ EAPI void ecore_win32_cursor_free(Ecore_Win32_Cursor *cursor);
EAPI Ecore_Win32_Cursor *ecore_win32_cursor_shaped_new(Ecore_Win32_Cursor_Shape shape);
EAPI Ecore_Win32_Cursor *ecore_win32_cursor_x11_shaped_new(Ecore_Win32_Cursor_X11_Shape shape);
EAPI void ecore_win32_cursor_size_get(int *width, int *height);
@ -516,6 +663,60 @@ EAPI Eina_Bool ecore_win32_dnd_register_drop_target(Ecore_Win32_Window
Ecore_Win32_Dnd_DropTarget_Callback callback);
EAPI void ecore_win32_dnd_unregister_drop_target(Ecore_Win32_Window *window);
/* Clipboard */
/**
* @brief Set data to the clipboard.
*
* @param[in] window The window that owns the clipboard.
* @param[in] data The data to set.
* @param[in] size The size of the data.
* @return #EINA_TRUE on success, #EINA_FALSE otherwise.
*
* This function sets @p data of size @p size in the clipboard owned by
* @p window. This function returns #EINA_TRUE on success, and
* #EINA_FALSE otherwise. If @p window or @p data are @c NULL, or @p size
* is less than or equal to 0, this function returns #EINA_FALSE.
*
* @since 1.16
*/
EAPI Eina_Bool ecore_win32_clipboard_set(const Ecore_Win32_Window *window,
const void *data,
int size);
/**
* @brief Get data from the clipboard.
*
* @param[in] window The window that owns the clipboard.
* @param[out] data The retrieved data.
* @param[out] size The size of the data.
* @return #EINA_TRUE on success, #EINA_FALSE otherwise.
*
* This function gets @p data of size @p size from the clipboard owned by
* @p window. This function returns #EINA_TRUE on success, and
* #EINA_FALSE otherwise. If @p window is @c NULL, this function returns
* #EINA_FALSE. @p data and @p size must be valid buffers.
*
* @since 1.16
*/
EAPI Eina_Bool ecore_win32_clipboard_get(const Ecore_Win32_Window *window,
void **data,
int *size);
/**
* @brief Cleat the clipboard.
*
* @param[in] window The window that owns the clipboard.
* @return #EINA_TRUE on success, #EINA_FALSE otherwise.
*
* This function clears the clipboard owned by @p window. This
* function returns #EINA_TRUE on success, and #EINA_FALSE otherwise.
* If @p window is @c NULL, this function returns #EINA_FALSE.
*
* @since 1.16
*/
EAPI Eina_Bool ecore_win32_clipboard_clear(const Ecore_Win32_Window *window);
/**
* @}
*/

View File

@ -24,6 +24,14 @@
* @cond LOCAL
*/
/* FIXME: uncomment when mingw-w64 will be updated in win-builds */
/* #if _WIN32_WINNT >= 0x0600 */
/* # ifndef WM_CLIPBOARDUPDATE */
# define WM_CLIPBOARDUPDATE 0x031D
/* # endif */
/* #endif */
/* OLE IID for Drag'n Drop */
#define INITGUID
@ -36,6 +44,9 @@ DEFINE_OLEGUID(IID_IUnknown, 0x00000000L, 0, 0);
#define IDI_ICON 101
typedef BOOL WINAPI (*efl_AddClipboardFormatListener)(_In_ HWND hwnd);
typedef BOOL WINAPI (*efl_RemoveClipboardFormatListener)(_In_ HWND hwnd);
static int _ecore_win32_init_count = 0;
LRESULT CALLBACK
@ -194,13 +205,33 @@ _ecore_win32_window_procedure(HWND window,
return 0;
/* Window notifications */
case WM_CREATE:
{
efl_AddClipboardFormatListener acfl;
INF("create window message");
acfl = (efl_AddClipboardFormatListener)GetProcAddress(GetModuleHandle("user32.dll"),
"AddClipboardFormatListener");
if (acfl)
{
if (!acfl(window))
INF("can not create clipboard format listener; no clipboard notification will be sent");
}
_ecore_win32_event_handle_create_notify(data);
return 0;
}
case WM_DESTROY:
{
efl_RemoveClipboardFormatListener rcfl;
INF("destroy window message");
_ecore_win32_event_handle_destroy_notify(data);
rcfl = (efl_RemoveClipboardFormatListener)GetProcAddress(GetModuleHandle("user32.dll"),
"RemoveClipboardFormatListener");
if (rcfl)
rcfl(window);
return 0;
}
case WM_SHOWWINDOW:
INF("show window message");
if ((data->data_param == SW_OTHERUNZOOM) ||
@ -299,6 +330,10 @@ _ecore_win32_window_procedure(HWND window,
return 0;
}
return DefWindowProc(window, message, window_param, data_param);
case WM_CLIPBOARDUPDATE:
INF("clipboard data updated");
_ecore_win32_event_handle_selection_notify(data);
return 0;
/* GDI notifications */
case WM_PAINT:
{
@ -358,6 +393,8 @@ int ECORE_WIN32_EVENT_WINDOW_HIDE = 0;
int ECORE_WIN32_EVENT_WINDOW_CONFIGURE = 0;
int ECORE_WIN32_EVENT_WINDOW_RESIZE = 0;
int ECORE_WIN32_EVENT_WINDOW_DELETE_REQUEST = 0;
int ECORE_WIN32_EVENT_SELECTION_CLEAR = 0;
int ECORE_WIN32_EVENT_SELECTION_NOTIFY = 0;
/*============================================================================*
* API *
@ -504,6 +541,8 @@ ecore_win32_init()
ECORE_WIN32_EVENT_WINDOW_CONFIGURE = ecore_event_type_new();
ECORE_WIN32_EVENT_WINDOW_RESIZE = ecore_event_type_new();
ECORE_WIN32_EVENT_WINDOW_DELETE_REQUEST = ecore_event_type_new();
ECORE_WIN32_EVENT_SELECTION_CLEAR = ecore_event_type_new();
ECORE_WIN32_EVENT_SELECTION_NOTIFY = ecore_event_type_new();
}
return _ecore_win32_init_count;

View File

@ -0,0 +1,188 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#undef WIN32_LEAN_AND_MEAN
#include <Eina.h>
#include "Ecore_Win32.h"
#include "ecore_win32_private.h"
/*============================================================================*
* Local *
*============================================================================*/
/**
* @cond LOCAL
*/
/**
* @endcond
*/
/*============================================================================*
* Global *
*============================================================================*/
/*============================================================================*
* API *
*============================================================================*/
EAPI Eina_Bool
ecore_win32_clipboard_set(const Ecore_Win32_Window *window,
const void *data,
int size)
{
HGLOBAL global;
char *d;
/*
* See: https://msdn.microsoft.com/en-us/library/windows/desktop/ms649016%28v=vs.85%29.aspx#_win32_Copying_Information_to_the_Clipboard
* 1. Open the clipboard
* 2. Empty the clipboard
* 3. Set the data
* 4. Close the clipboard
*/
INF("setting data to the clipboard");
if (!window || !data || (size <= 0))
return EINA_FALSE;
if (!OpenClipboard(window->window))
return EINA_FALSE;
if (!EmptyClipboard())
goto close_clipboard;
global = GlobalAlloc(GMEM_MOVEABLE, size + 1);
if (!global)
goto close_clipboard;
d = (char *)GlobalLock(global);
if (!d)
goto unlock_global;
memcpy(d, data, size);
d[size] = '\0';
GlobalUnlock(global);
SetClipboardData(CF_TEXT, global);
CloseClipboard();
return EINA_TRUE;
unlock_global:
GlobalUnlock(global);
close_clipboard:
CloseClipboard();
return EINA_FALSE;
}
EAPI Eina_Bool
ecore_win32_clipboard_get(const Ecore_Win32_Window *window,
void **data,
int *size)
{
HGLOBAL global;
void *d;
void *p;
/*
* See https://msdn.microsoft.com/en-us/library/windows/desktop/ms649016%28v=vs.85%29.aspx#_win32_Pasting_Information_from_the_Clipboard
* 1. Open Clipboard
* 2. Determine format
* 3. Retrieve data
* 4. Manage data
* 5. Close clipboard
*/
INF("getting data from the clipboard");
if (!window)
return EINA_FALSE;
if (!IsClipboardFormatAvailable(CF_TEXT))
return EINA_FALSE;
if (!OpenClipboard(window->window))
goto set_val;
/* { */
/* UINT fmt = 0; */
/* while (1) */
/* { */
/* fmt = EnumClipboardFormats(fmt); */
/* printf(" $ Format : %x\n", fmt); */
/* if (!fmt) */
/* break; */
/* } */
/* } */
global = GetClipboardData(CF_TEXT);
if (!global)
goto close_clipboard;
d = GlobalLock(global);
if (!d)
goto unlock_global;
*size = strlen(d);
p = malloc(*size);
if (!p)
goto unlock_global;
memcpy(p, d, *size);
*data = p;
GlobalUnlock(global);
CloseClipboard();
return EINA_TRUE;
unlock_global:
GlobalUnlock(global);
close_clipboard:
CloseClipboard();
set_val:
*data = NULL;
*size = 0;
return EINA_FALSE;
}
EAPI Eina_Bool
ecore_win32_clipboard_clear(const Ecore_Win32_Window *window)
{
INF("clearing the clipboard");
if (!window)
return EINA_FALSE;
if (!OpenClipboard(window->window))
return EINA_FALSE;
if (!EmptyClipboard())
goto close_clipboard;
CloseClipboard();
return EINA_TRUE;
close_clipboard:
CloseClipboard();
return EINA_FALSE;
}
/**
* @}
*/

View File

@ -10,6 +10,7 @@
#include "Ecore_Win32.h"
#include "ecore_win32_private.h"
#include "ecore_win32_cursor_x11.c"
/*============================================================================*
* Local *
@ -157,7 +158,11 @@
* };
*
* Ecore_Win32_Cursor *cursor = ecore_win32_cursor_new(pixels_and, pixels_xor, 32, 32, 19, 2);
* ecore_win32_window_cursor_set(window, cursor);
* @endcode
*
* @see ecore_win32_cursor_free()
* @see ecore_win32_window_cursor_set()
*/
EAPI Ecore_Win32_Cursor *
ecore_win32_cursor_new(const void *pixels_and,
@ -199,13 +204,19 @@ ecore_win32_cursor_new(const void *pixels_and,
* @param cursor The cursor to free.
*
* This function free @p cursor. @p cursor must have been obtained
* with ecore_win32_cursor_new().
* with ecore_win32_cursor_new() or ecore_win32_cursor_x11_shaped_new().
*
* @see ecore_win32_cursor_new()
* @see ecore_win32_cursor_x11_shaped_new()
*/
EAPI void
ecore_win32_cursor_free(Ecore_Win32_Cursor *cursor)
{
INF("destroying cursor");
if (!cursor)
return;
DestroyCursor(cursor);
}
@ -217,7 +228,7 @@ ecore_win32_cursor_free(Ecore_Win32_Cursor *cursor)
*
* This function returns a pre-defined cursor with a specified
* @p shape. This cursor does not need to be freed, as it is loaded
* from an existing resource.
* from an existing resource. On error @c NULL is returned.
*/
EAPI Ecore_Win32_Cursor *
ecore_win32_cursor_shaped_new(Ecore_Win32_Cursor_Shape shape)
@ -281,6 +292,36 @@ ecore_win32_cursor_shaped_new(Ecore_Win32_Cursor_Shape shape)
return cursor;
}
/**
* @brief Create a X11 cursor from a X Id.
*
* @param[in] shape The defined X11 shape of the cursor.
* @return The new cursor.
*
* This function returns a defined cursor with a specified X11
* @p shape. Once the cursor is not used anymore, use
* ecore_win32_cursor_free() to free the ressources.
*
* @see ecore_win32_cursor_free()
*
* @since 1.16
*/
EAPI Ecore_Win32_Cursor *
ecore_win32_cursor_x11_shaped_new(Ecore_Win32_Cursor_X11_Shape shape)
{
INF("getting X11 shape cursor");
if ((shape < ECORE_WIN32_CURSOR_X11_SHAPE_X) ||
(shape > ECORE_WIN32_CURSOR_X11_SHAPE_XTERM))
return NULL;
return ecore_win32_cursor_new(_ecore_win32_cursors_x11[shape].mask_and,
_ecore_win32_cursors_x11[shape].mask_xor,
32, 32,
_ecore_win32_cursors_x11[shape].hotspot_x,
_ecore_win32_cursors_x11[shape].hotspot_y);
}
/**
* @brief Retrieve the size of a valid cursor.
*

File diff suppressed because it is too large Load Diff

View File

@ -40,6 +40,7 @@ static int _ecore_win32_mouse_down_did_triple = 0;
static int _ecore_win32_mouse_up_count = 0;
static Ecore_Win32_Key_Mask _ecore_win32_key_mask = 0;
static Eina_Bool _ecore_win32_ctrl_fake = EINA_FALSE;
static Eina_Bool _ecore_win32_clipboard_has_data = EINA_FALSE;
static unsigned int
_ecore_win32_modifiers_get(void)
@ -1895,3 +1896,72 @@ _ecore_win32_event_handle_delete_request(Ecore_Win32_Callback_Data *msg)
ecore_event_add(ECORE_WIN32_EVENT_WINDOW_DELETE_REQUEST, e, NULL, NULL);
}
void
_ecore_win32_event_handle_selection_notify(Ecore_Win32_Callback_Data *msg)
{
Ecore_Win32_Event_Selection_Notify *e;
HGLOBAL global;
char *str;
INF("selection_notify");
/*
* we have text data in clipboard but no data before,
* so text data has just been added
*/
if (IsClipboardFormatAvailable(CF_TEXT) && !_ecore_win32_clipboard_has_data)
{
e = calloc(1, sizeof(Ecore_Win32_Event_Selection_Notify));
if (!e) return;
e->window = (void *)GetWindowLongPtr(msg->window, GWLP_USERDATA);
e->timestamp = _ecore_win32_event_last_time;
e->selection = ECORE_WIN32_SELECTION_CLIPBOARD;
if (!OpenClipboard(msg->window))
goto free_e;
global = GetClipboardData(CF_TEXT);
if (!global)
goto close_clipboard;
str = GlobalLock(global);
if (str)
{
e->data = strdup(str);
GlobalUnlock(global);
}
CloseClipboard();
ecore_event_add(ECORE_WIN32_EVENT_SELECTION_NOTIFY, e, NULL, NULL);
_ecore_win32_clipboard_has_data = EINA_TRUE;
}
/*
* we have no more text data in clipboard and data before,
* so text data has just been removed
*/
if (!IsClipboardFormatAvailable(CF_TEXT) && _ecore_win32_clipboard_has_data)
{
e = calloc(1, sizeof(Ecore_Win32_Event_Selection_Clear));
if (!e) return;
e->window = (void *)GetWindowLongPtr(msg->window, GWLP_USERDATA);
e->timestamp = _ecore_win32_event_last_time;
e->selection = ECORE_WIN32_SELECTION_CLIPBOARD;
ecore_event_add(ECORE_WIN32_EVENT_SELECTION_CLEAR, e, NULL, NULL);
_ecore_win32_clipboard_has_data = EINA_FALSE;
}
return;
close_clipboard:
CloseClipboard();
free_e:
free(e);
}

View File

@ -164,6 +164,7 @@ void _ecore_win32_event_handle_unmap_notify(Ecore_Win32_Callback_Data *msg);
void _ecore_win32_event_handle_configure_notify(Ecore_Win32_Callback_Data *msg);
void _ecore_win32_event_handle_resize(Ecore_Win32_Callback_Data *msg);
void _ecore_win32_event_handle_delete_request(Ecore_Win32_Callback_Data *msg);
void _ecore_win32_event_handle_selection_notify(Ecore_Win32_Callback_Data *msg);
void *_ecore_win32_dnd_data_object_new(void *fmtetc, void *stgmeds, int count);
void _ecore_win32_dnd_data_object_free(void *data_object);

View File

@ -1436,8 +1436,13 @@ ecore_win32_window_fullscreen_set(Ecore_Win32_Window *window,
*
* This function sets @p cursor to @p window. @p cursor must have been
* obtained by ecore_win32_cursor_new() or
* ecore_win32_cursor_shaped_new(). If @p window or @p cursor is
* ecore_win32_cursor_shaped_new() or
* ecore_win32_cursor_x11_shaped_new(). If @p window or @p cursor is
* @c NULL, the function does nothing.
*
* @see ecore_win32_cursor_new()
* @see ecore_win32_cursor_shaped_new()
* @see ecore_win32_cursor_x11_shaped_new()
*/
EAPI void
ecore_win32_window_cursor_set(Ecore_Win32_Window *window,

View File

@ -334,6 +334,7 @@ _ecore_key_press(int event,
KeySym sym;
XComposeStatus status;
int val;
int key_len, keyname_len, compose_len;
_ecore_x_last_event_mouse_move = 0;
keyname = XKeysymToString(_ecore_x_XKeycodeToKeysym(xevent->display,
@ -370,14 +371,18 @@ _ecore_key_press(int event,
if (!key)
key = keyname;
e = calloc(1, sizeof(Ecore_Event_Key) + strlen(key) + strlen(keyname) +
(compose ? strlen(compose) : 0) + 3);
key_len = strlen(key);
keyname_len = strlen(keyname);
compose_len = (compose) ? strlen(compose) : 0;
e = calloc(1, sizeof(Ecore_Event_Key) + key_len + keyname_len +
compose_len + 3);
if (!e)
goto on_error;
e->keyname = (char *)(e + 1);
e->key = e->keyname + strlen(keyname) + 1;
e->compose = (compose) ? e->key + strlen(key) + 1 : NULL;
e->key = e->keyname + keyname_len + 1;
e->compose = (compose) ? e->key + key_len + 1 : NULL;
e->string = e->compose;
strcpy((char *)e->keyname, keyname);

View File

@ -1392,6 +1392,7 @@ _compose_seq_reset(Entry *en)
en->composing = EINA_FALSE;
}
static void
_edje_key_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
{
@ -1399,7 +1400,7 @@ _edje_key_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
Evas_Event_Key_Down *ev = event_info;
Edje_Real_Part *rp = ed->focused_part;
Entry *en;
Eina_Bool control, alt, shift;
Eina_Bool control, alt, shift, apple_cmd, apple;
Eina_Bool multiline;
Eina_Bool cursor_changed;
int old_cur_pos;
@ -1434,10 +1435,21 @@ _edje_key_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
old_cur_pos = evas_textblock_cursor_pos_get(en->cursor);
control = evas_key_modifier_is_set(ev->modifiers, "Control");
#if HAVE_ECORE_COCOA
# define ACTION_KEY_PRESSED (apple_cmd == EINA_TRUE)
apple_cmd = (evas_key_modifier_is_set(ev->modifiers, "Super") &&
evas_key_modifier_is_set(ev->modifiers, "Hyper"));
apple = EINA_TRUE;
#else
# define ACTION_KEY_PRESSED (control == EINA_TRUE)
apple_cmd = EINA_FALSE;
apple = EINA_FALSE;
#endif
alt = evas_key_modifier_is_set(ev->modifiers, "Alt");
shift = evas_key_modifier_is_set(ev->modifiers, "Shift");
multiline = rp->part->multiline;
cursor_changed = EINA_FALSE;
if (!strcmp(ev->key, "Escape"))
{
_compose_seq_reset(en);
@ -1596,7 +1608,8 @@ _edje_key_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
else if (!strcmp(ev->key, "BackSpace"))
{
_compose_seq_reset(en);
if (control && !en->have_selection)
if (((!apple && control) || (apple && alt)) &&
(!en->have_selection))
{
// del to start of previous word
_sel_start(en->cursor, rp->object, en);
@ -1635,7 +1648,7 @@ _edje_key_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
(!strcmp(ev->key, "KP_Delete") && !ev->string))
{
_compose_seq_reset(en);
if (control)
if ((!apple && control) || (apple && alt))
{
// del to end of next word
_sel_start(en->cursor, rp->object, en);
@ -1711,14 +1724,14 @@ _edje_key_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
_edje_emit(ed, "cursor,changed,manual", rp->part->name);
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
}
else if ((control) && (!shift) && (!strcmp(ev->keyname, "v")))
else if (ACTION_KEY_PRESSED && (!shift) && (!strcmp(ev->keyname, "v")))
{
_compose_seq_reset(en);
_edje_emit(ed, "entry,paste,request", rp->part->name);
_edje_emit(ed, "entry,paste,request,3", rp->part->name);
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
}
else if ((control) && (!strcmp(ev->keyname, "a")))
else if (ACTION_KEY_PRESSED && (!strcmp(ev->keyname, "a")))
{
_compose_seq_reset(en);
if (shift)
@ -1732,19 +1745,19 @@ _edje_key_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
}
}
else if ((control) && (((!shift) && !strcmp(ev->keyname, "c")) || !strcmp(ev->key, "Insert")))
else if (ACTION_KEY_PRESSED && (((!shift) && !strcmp(ev->keyname, "c")) || !strcmp(ev->key, "Insert")))
{
_compose_seq_reset(en);
_edje_emit(ed, "entry,copy,notify", rp->part->name);
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
}
else if ((control) && (!shift) && ((!strcmp(ev->keyname, "x") || (!strcmp(ev->keyname, "m")))))
else if (ACTION_KEY_PRESSED && (!shift) && ((!strcmp(ev->keyname, "x") || (!strcmp(ev->keyname, "m")))))
{
_compose_seq_reset(en);
_edje_emit(ed, "entry,cut,notify", rp->part->name);
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
}
else if ((control) && (!strcmp(ev->keyname, "z")))
else if (ACTION_KEY_PRESSED && (!strcmp(ev->keyname, "z")))
{
_compose_seq_reset(en);
if (shift)
@ -1759,7 +1772,8 @@ _edje_key_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
}
ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
}
else if ((control) && (!shift) && (!strcmp(ev->keyname, "y")))
else if (((!apple) && (control) && (!shift) && (!strcmp(ev->keyname, "y"))) ||
((apple) && ACTION_KEY_PRESSED && (shift) && (!strcmp(ev->keyname, "z"))))
{
_compose_seq_reset(en);
// redo

View File

@ -920,20 +920,8 @@ eina_file_mkstemp(const char *templatename, Eina_Tmpstr **path)
mode_t old_umask;
#endif
#ifndef HAVE_EVIL
#if defined(HAVE_GETUID) && defined(HAVE_GETEUID)
if (getuid() == geteuid())
#endif
{
tmpdir = getenv("TMPDIR");
if (!tmpdir) tmpdir = getenv("XDG_RUNTIME_DIR");
}
if (!tmpdir) tmpdir = "/tmp";
#else
tmpdir = (char *)evil_tmpdir_get();
#endif /* ! HAVE_EVIL */
len = snprintf(buffer, PATH_MAX, "%s/%s", tmpdir, templatename);
len = eina_file_path_join(buffer, sizeof(buffer),
eina_environment_tmp_get(), templatename);
/*
* Unix:
@ -972,17 +960,8 @@ eina_file_mkdtemp(const char *templatename, Eina_Tmpstr **path)
const char *tmpdir = NULL;
char *tmpdirname;
#ifndef HAVE_EVIL
#if defined(HAVE_GETUID) && defined(HAVE_GETEUID)
if (getuid() == geteuid())
#endif
tmpdir = getenv("TMPDIR");
if (!tmpdir) tmpdir = "/tmp";
#else
tmpdir = (char *)evil_tmpdir_get();
#endif /* ! HAVE_EVIL */
snprintf(buffer, PATH_MAX, "%s/%s", tmpdir, templatename);
eina_file_path_join(buffer, sizeof(buffer),
eina_environment_tmp_get(), templatename);
tmpdirname = mkdtemp(buffer);
if (path) *path = eina_tmpstr_add(buffer);

View File

@ -23,6 +23,7 @@
#include "eina_tmpstr.h"
#include "eina_lock.h"
#include "eina_list.h"
#include "eina_util.h"
#define EINA_FILE_MAGIC 0xFEEDBEEF

View File

@ -12,18 +12,12 @@
#include "Ecore_Evas.h"
#include "ecore_evas_private.h"
#include "ecore_evas_cocoa.h"
#ifdef EAPI
# undef EAPI
#endif
#ifdef _WIN32
# ifdef DLL_EXPORT
# define EAPI __declspec(dllexport)
# else
# define EAPI
# endif /* ! DLL_EXPORT */
#else
#ifdef __GNUC__
# if __GNUC__ >= 4
# define EAPI __attribute__ ((visibility("default")))
@ -33,20 +27,15 @@
#else
# define EAPI
#endif
#endif /* ! _WIN32 */
// FIXME: this engine has lots of problems. only 1 window at a time, drawRect looks wrong, doesnt handle resizes and more
static int _ecore_evas_init_count = 0;
// FIXME: In case we have a lot of windows per app, we should probably use another container
// like a rbtree or a dictionnary-based container
static Eina_List *ecore_evases = NULL;
static Ecore_Event_Handler *ecore_evas_event_handlers[5] = {
0
};
static Ecore_Idle_Enterer *ecore_evas_idle_enterer = NULL;
static Ecore_Event_Handler *ecore_evas_event_handlers[4];
//static const char *ecore_evas_cocoa_default = "EFL Cocoa";
static const char *_iface_name = "opengl_cocoa";
static const int _iface_version = 1;
static int
_render_updates_process(Ecore_Evas *ee, Eina_List *updates)
@ -97,7 +86,7 @@ _render_updates_process(Ecore_Evas *ee, Eina_List *updates)
if ((t - t0) > 1.0)
{
td = t - t0;
printf("FPS: %3.3f\n", (double)frames / td);
DBG("FPS: %3.3f", (double)frames / td);
frames = 0;
t0 = t;
}
@ -106,25 +95,10 @@ _render_updates_process(Ecore_Evas *ee, Eina_List *updates)
return rend;
}
static int
_ecore_evas_render(Ecore_Evas *ee)
{
Eina_List *updates;
updates = evas_render_updates(ee->evas);
if (updates)
{
evas_render_updates_free(updates);
_ecore_evas_idle_timeout_update(ee);
}
return updates ? 1 : 0;
}
static int
_ecore_evas_cocoa_render(Ecore_Evas *ee)
{
int rend = 0;
Eina_List *updates = NULL;
Eina_List *ll;
Ecore_Evas *ee2;
static int render2 = -1;
@ -134,7 +108,7 @@ _ecore_evas_cocoa_render(Ecore_Evas *ee)
if (ee->in_async_render)
{
//EDBG("ee=%p is rendering asynchronously, skip.", ee);
DBG("ee=%p is rendering asynchronously, skip.", ee);
return 0;
}
@ -177,7 +151,7 @@ _ecore_evas_cocoa_render(Ecore_Evas *ee)
}
else if (evas_render_async(ee->evas))
{
//EDBG("ee=%p started asynchronous render.", ee);
DBG("ee=%p started asynchronous render.", ee);
ee->in_async_render = EINA_TRUE;
rend = 1;
}
@ -193,7 +167,7 @@ _ecore_evas_cocoa_match(Ecore_Cocoa_Window_Id wid)
Eina_List *it;
Ecore_Evas *ee;
DBG("Match");
DBG("");
EINA_LIST_FOREACH(ecore_evases, it, ee)
{
if (ecore_cocoa_window_get_window_id((Ecore_Cocoa_Window *)ee->prop.window) == wid)
@ -209,15 +183,9 @@ _ecore_evas_cocoa_event_got_focus(void *data EINA_UNUSED, int type EINA_UNUSED,
Ecore_Cocoa_Event_Window *e = event;
Ecore_Evas *ee;
DBG("Got Focus");
ee = _ecore_evas_cocoa_match(e->wid);
if ((!ee) || (ee->ignore_events)) return ECORE_CALLBACK_PASS_ON;
if (!ee)
{
printf("%s: Unregistered Ecore_Evas for window Id %p\n", __func__, e->wid);
return ECORE_CALLBACK_PASS_ON;
}
ee->prop.focused = EINA_TRUE;
evas_focus_in(ee->evas);
if (ee->func.fn_focus_in) ee->func.fn_focus_in(ee);
@ -231,15 +199,9 @@ _ecore_evas_cocoa_event_lost_focus(void *data EINA_UNUSED, int type EINA_UNUSED,
Ecore_Cocoa_Event_Window *e = event;
Ecore_Evas *ee;
DBG("Lost Focus");
ee = _ecore_evas_cocoa_match(e->wid);
if ((!ee) || (ee->ignore_events)) return ECORE_CALLBACK_PASS_ON;
if (!ee)
{
printf("%s: Unregistered Ecore_Evas for window Id %p\n", __func__, e->wid);
return ECORE_CALLBACK_PASS_ON;
}
evas_focus_out(ee->evas);
ee->prop.focused = EINA_FALSE;
if (ee->func.fn_focus_out) ee->func.fn_focus_out(ee);
@ -247,51 +209,47 @@ _ecore_evas_cocoa_event_lost_focus(void *data EINA_UNUSED, int type EINA_UNUSED,
return ECORE_CALLBACK_PASS_ON;
}
static void
_ecore_evas_resize_common(Ecore_Evas *ee,
int w,
int h,
Eina_Bool resize_cocoa)
{
if ((w == ee->w) && (h == ee->h)) return;
ee->req.w = w;
ee->req.h = h;
ee->w = w;
ee->h = h;
DBG("Ecore_Evas Resize %d %d", w, h);
if (resize_cocoa)
ecore_cocoa_window_resize((Ecore_Cocoa_Window *)ee->prop.window, w, 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 Eina_Bool
_ecore_evas_cocoa_event_video_resize(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
{
Ecore_Cocoa_Event_Video_Resize *e = event;
Ecore_Evas *ee;
DBG("Video resize");
ee = _ecore_evas_cocoa_match(e->wid);
if (!ee)
{
printf("%s: Unregistered Ecore_Evas for window Id %p\n", __func__, e->wid);
return ECORE_CALLBACK_PASS_ON;
}
ee->req.w = ee->w = e->w;
ee->req.h = ee->h = e->h;
evas_output_size_set(ee->evas, e->w, e->h);
evas_output_viewport_set(ee->evas, 0, 0, e->w, e->h);
evas_damage_rectangle_add(ee->evas, 0, 0, e->w, e->h);
if (ee->func.fn_resize) ee->func.fn_resize(ee);
return ECORE_CALLBACK_PASS_ON;
}
static Eina_Bool
_ecore_evas_cocoa_event_video_expose(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
{
Ecore_Cocoa_Event_Window *e = event;
Ecore_Evas *ee;
int w;
int h;
DBG("Video Expose");
DBG("");
ee = _ecore_evas_cocoa_match(e->wid);
if (!ee)
if (EINA_UNLIKELY(!ee))
{
printf("%s: Unregistered Ecore_Evas for window Id %p\n", __func__, e->wid);
ERR("Unregistered Ecore_Evas for window Id %p", e->wid);
return ECORE_CALLBACK_PASS_ON;
}
evas_output_size_get(ee->evas, &w, &h);
evas_damage_rectangle_add(ee->evas, 0, 0, w, h);
/* Do the resize */
_ecore_evas_resize_common(ee, e->w, e->h, EINA_FALSE);
return ECORE_CALLBACK_PASS_ON;
}
@ -302,12 +260,15 @@ _ecore_evas_cocoa_event_window_destroy(void *data EINA_UNUSED, int type EINA_UNU
Ecore_Cocoa_Event_Window *e = event;
Ecore_Evas *ee;
DBG("Window destroy");
DBG("");
if (!e->wid)
return ECORE_CALLBACK_PASS_ON;
ee = _ecore_evas_cocoa_match(e->wid);
if (!ee)
{
WRN("%s: Unregistered Ecore_Evas for window Id %p\n", __func__, e->wid);
ERR("Unregistered Ecore_Evas for window Id %p", e->wid);
return ECORE_CALLBACK_PASS_ON;
}
@ -316,31 +277,10 @@ _ecore_evas_cocoa_event_window_destroy(void *data EINA_UNUSED, int type EINA_UNU
return ECORE_CALLBACK_PASS_ON;
}
//static int
//_ecore_evas_idle_enter(void *data EINA_UNUSED)
//{
// Ecore_Evas *ee;
// Eina_List *l;
//
// DBG("Idle enter");
//
// EINA_LIST_FOREACH(ecore_evases, l, ee)
// {
// if (ee->visible)
// evas_render(ee->evas);
// else
// evas_norender(ee->evas);
// }
//
// return EINA_TRUE;
//}
static int
_ecore_evas_cocoa_init(void)
{
DBG("Cocoa Init");
DBG("");
_ecore_evas_init_count++;
if (_ecore_evas_init_count > 1)
return _ecore_evas_init_count;
@ -350,8 +290,7 @@ _ecore_evas_cocoa_init(void)
ecore_evas_event_handlers[0] = ecore_event_handler_add(ECORE_COCOA_EVENT_GOT_FOCUS, _ecore_evas_cocoa_event_got_focus, NULL);
ecore_evas_event_handlers[1] = ecore_event_handler_add(ECORE_COCOA_EVENT_LOST_FOCUS, _ecore_evas_cocoa_event_lost_focus, NULL);
ecore_evas_event_handlers[2] = ecore_event_handler_add(ECORE_COCOA_EVENT_RESIZE, _ecore_evas_cocoa_event_video_resize, NULL);
ecore_evas_event_handlers[3] = ecore_event_handler_add(ECORE_COCOA_EVENT_EXPOSE, _ecore_evas_cocoa_event_video_expose, NULL);
ecore_evas_event_handlers[4] = ecore_event_handler_add(ECORE_COCOA_EVENT_WINDOW_DESTROY, _ecore_evas_cocoa_event_window_destroy, NULL);
ecore_evas_event_handlers[3] = ecore_event_handler_add(ECORE_COCOA_EVENT_WINDOW_DESTROY, _ecore_evas_cocoa_event_window_destroy, NULL);
return _ecore_evas_init_count;
}
@ -360,7 +299,7 @@ static int
_ecore_evas_cocoa_shutdown(void)
{
Ecore_Evas *ee;
DBG("Cocoa Shutdown");
DBG("");
_ecore_evas_init_count--;
if (_ecore_evas_init_count == 0)
{
@ -369,22 +308,18 @@ _ecore_evas_cocoa_shutdown(void)
EINA_LIST_FREE(ecore_evases, ee)
_ecore_evas_free(ee);
for (i = 0; i < sizeof (ecore_evas_event_handlers) / sizeof (Ecore_Event_Handler*); i++)
for (i = 0; i < EINA_C_ARRAY_LENGTH(ecore_evas_event_handlers); i++)
ecore_event_handler_del(ecore_evas_event_handlers[i]);
ecore_event_evas_shutdown();
ecore_idle_enterer_del(ecore_evas_idle_enterer);
ecore_evas_idle_enterer = NULL;
ecore_event_evas_shutdown();
}
if (_ecore_evas_init_count < 0) _ecore_evas_init_count = 0;
return _ecore_evas_init_count;
}
static void
_ecore_evas_cocoa_free(Ecore_Evas *ee)
{
DBG("Cocoa Free");
DBG("");
ecore_evases = eina_list_remove(ecore_evases, ee);
ecore_event_window_unregister(0);
_ecore_evas_cocoa_shutdown();
@ -412,35 +347,21 @@ _ecore_evas_size_step_set(Ecore_Evas *ee, int w, int h)
static void
_ecore_evas_move(Ecore_Evas *ee, int x, int y)
{
DBG("Move");
DBG("");
ecore_cocoa_window_move((Ecore_Cocoa_Window *)ee->prop.window, x, y);
}
static void
_ecore_evas_resize(Ecore_Evas *ee, int w, int h)
{
DBG("Resize");
if ((w == ee->w) && (h == ee->h)) return;
ee->req.w = w;
ee->req.h = h;
ee->w = w;
ee->h = h;
printf("Ecore_Evas Resize %d %d\n", w, h);
ecore_cocoa_window_resize((Ecore_Cocoa_Window *)ee->prop.window, w, 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);
DBG("");
_ecore_evas_resize_common(ee, w, h, EINA_TRUE);
}
static void
_ecore_evas_move_resize(Ecore_Evas *ee, int x, int y, int w, int h)
{
DBG("Move Resize");
DBG("");
if ((ee->w == w) && (ee->h == h) && (x == ee->x) && (y == ee->y))
return;
@ -466,7 +387,7 @@ _ecore_evas_move_resize(Ecore_Evas *ee, int x, int y, int w, int h)
static void
_ecore_evas_show(Ecore_Evas *ee)
{
DBG("Show");
DBG("");
ee->should_be_visible = 1;
if (ee->prop.avoid_damage)
_ecore_evas_cocoa_render(ee);
@ -479,7 +400,7 @@ _ecore_evas_show(Ecore_Evas *ee)
static void
_ecore_evas_hide(Ecore_Evas *ee)
{
DBG("Hide");
DBG("");
ecore_cocoa_window_hide((Ecore_Cocoa_Window *)ee->prop.window);
ee->should_be_visible = 0;
@ -488,7 +409,7 @@ _ecore_evas_hide(Ecore_Evas *ee)
static void
_ecore_evas_raise(Ecore_Evas *ee)
{
DBG("Raise");
DBG("");
ecore_cocoa_window_raise((Ecore_Cocoa_Window *)ee->prop.window);
}
@ -496,7 +417,7 @@ _ecore_evas_raise(Ecore_Evas *ee)
static void
_ecore_evas_lower(Ecore_Evas *ee)
{
DBG("Lower");
DBG("");
ecore_cocoa_window_lower((Ecore_Cocoa_Window *)ee->prop.window);
}
@ -504,7 +425,7 @@ _ecore_evas_lower(Ecore_Evas *ee)
static void
_ecore_evas_activate(Ecore_Evas *ee)
{
DBG("Activate");
DBG("");
ecore_cocoa_window_activate((Ecore_Cocoa_Window *)ee->prop.window);
}
@ -512,7 +433,7 @@ _ecore_evas_activate(Ecore_Evas *ee)
static void
_ecore_evas_iconified_set(Ecore_Evas *ee, Eina_Bool on)
{
DBG("IconifiedSet");
DBG("");
ecore_cocoa_window_iconified_set((Ecore_Cocoa_Window *)ee->prop.window, on);
}
@ -535,7 +456,7 @@ _ecore_evas_object_cursor_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj
{
Ecore_Evas *ee;
DBG("Cursor DEL");
DBG("");
ee = data;
if (ee)
@ -552,16 +473,19 @@ static void
_ecore_evas_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int hot_x, int hot_y)
{
int x, y;
DBG("Cursor Set");
if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object);
Evas_Object *old;
Ecore_Cocoa_Window *win = (Ecore_Cocoa_Window *)(ee->prop.window);
DBG("");
old = 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;
ecore_cocoa_window_cursor_show(win, EINA_TRUE);
goto end;
}
ee->prop.cursor.object = obj;
@ -570,17 +494,27 @@ _ecore_evas_object_cursor_set(Ecore_Evas *ee, Evas_Object *obj, int layer, int h
ee->prop.cursor.hot.y = hot_y;
evas_pointer_output_xy_get(ee->evas, &x, &y);
if (obj != old)
{
ecore_cocoa_window_cursor_show(win, EINA_FALSE);
evas_object_layer_set(ee->prop.cursor.object, ee->prop.cursor.layer);
evas_object_pass_events_set(ee->prop.cursor.object, 1);
if (evas_pointer_inside_get(ee->evas))
evas_object_show(ee->prop.cursor.object);
evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL,
_ecore_evas_object_cursor_del, ee);
}
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);
evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL, _ecore_evas_object_cursor_del, ee);
end:
if ((old) && (obj != old))
{
evas_object_event_callback_del_full(old, EVAS_CALLBACK_DEL,
_ecore_evas_object_cursor_del, ee);
evas_object_del(old);
}
}
static void
@ -599,7 +533,7 @@ _ecore_evas_engine_cocoa_init(Ecore_Evas *ee)
const char *driver;
int rmethod;
DBG("Cocoa Init");
DBG("");
driver = "gl_cocoa";
@ -613,10 +547,7 @@ _ecore_evas_engine_cocoa_init(Ecore_Evas *ee)
einfo = (Evas_Engine_Info_GL_Cocoa *)evas_engine_info_get(ee->evas);
if (einfo)
{
/* FIXME: REDRAW_DEBUG missing for now */
einfo->window = (void *)ee->prop.window;
//einfo->info.depth = ecore_win32_screen_depth_get();
//einfo->info.rotation = 0;
if (!evas_engine_info_set(ee->evas, (Evas_Engine_Info *)einfo))
{
ERR("evas_engine_info_set() for engine '%s' failed.", ee->driver);
@ -639,7 +570,7 @@ _ecore_evas_screen_geometry_get(const Ecore_Evas *ee EINA_UNUSED, int *x, int *y
if (x) *x = 0;
if (y) *y = 0;
ecore_cocoa_screen_size_get(NULL, w, h);
printf("screen geometry_get %dx%d\n", *w, *h);
DBG("screen geometry_get %dx%d", *w, *h);
}
@ -715,17 +646,25 @@ static Ecore_Evas_Engine_Func _ecore_cocoa_engine_func =
NULL // msg_send
};
static Ecore_Cocoa_Window *
_ecore_evas_cocoa_window_get(const Ecore_Evas *ee)
{
/* See affectation of ee->prop.window in ecore_evas_cocoa_new_internal */
return (Ecore_Cocoa_Window *)(ee->prop.window);
}
EAPI Ecore_Evas *
ecore_evas_cocoa_new_internal(Ecore_Cocoa_Window *parent EINA_UNUSED, int x, int y, int w, int h)
{
// Evas_Engine_Info_GL_Cocoa *einfo;
Ecore_Evas *ee;
DBG("Cocoa new");
Ecore_Evas_Interface_Cocoa *iface;
if (!ecore_cocoa_init())
return NULL;
DBG("");
ee = calloc(1, sizeof(Ecore_Evas));
if (!ee)
goto shutdown_ecore_cocoa;
@ -750,7 +689,6 @@ ecore_evas_cocoa_new_internal(Ecore_Cocoa_Window *parent EINA_UNUSED, int x, int
ee->semi_sync = 1;
ee->prop.max.w = 32767;
ee->prop.max.h = 32767;
ee->prop.layer = 4;
@ -759,8 +697,6 @@ ecore_evas_cocoa_new_internal(Ecore_Cocoa_Window *parent EINA_UNUSED, int x, int
ee->prop.window = 0;
ee->prop.withdrawn = EINA_TRUE;
printf("Create New Evas\n");
ee->evas = evas_new();
if (!ee->evas)
@ -770,9 +706,8 @@ ecore_evas_cocoa_new_internal(Ecore_Cocoa_Window *parent EINA_UNUSED, int x, int
evas_output_size_set(ee->evas, w, h);
evas_output_viewport_set(ee->evas, 0, 0, w, h);
printf("Create New Cocoa Window\n");
ee->prop.window = (Ecore_Window)ecore_cocoa_window_new(x, y, w, h);
printf("Window Created %p\n", (Ecore_Cocoa_Window *)ee->prop.window);
if (!ee->prop.window)
{
_ecore_evas_cocoa_shutdown();
@ -780,7 +715,6 @@ ecore_evas_cocoa_new_internal(Ecore_Cocoa_Window *parent EINA_UNUSED, int x, int
return NULL;
}
printf("Init Evas engine cocoa\n");
if (!_ecore_evas_engine_cocoa_init(ee))
{
_ecore_evas_cocoa_shutdown();
@ -788,6 +722,18 @@ ecore_evas_cocoa_new_internal(Ecore_Cocoa_Window *parent EINA_UNUSED, int x, int
return NULL;
}
/* Interface setup */
iface = calloc(1, sizeof(*iface));
if (EINA_UNLIKELY(!iface))
{
_ecore_evas_cocoa_shutdown();
free(ee);
return NULL;
}
iface->base.name = _iface_name;
iface->base.version = _iface_version;
iface->window_get = _ecore_evas_cocoa_window_get;
ee->engine.ifaces = eina_list_append(ee->engine.ifaces, iface);
ee->engine.func->fn_render = _ecore_evas_cocoa_render;
_ecore_evas_register(ee);
@ -798,8 +744,6 @@ ecore_evas_cocoa_new_internal(Ecore_Cocoa_Window *parent EINA_UNUSED, int x, int
(Ecore_Event_Multi_Up_Cb)_ecore_evas_mouse_multi_up_process);
evas_event_feed_mouse_in(ee->evas, (unsigned int)((unsigned long long)(ecore_time_get() * 1000.0) & 0xffffffff), NULL);
printf("Ecore Evas returned : %p\n", ee);
ecore_evases = eina_list_append(ecore_evases, ee);
return ee;

View File

@ -180,7 +180,7 @@ eng_output_redraws_rect_add(void *data, int x, int y, int w, int h)
evas_gl_common_context_resize(re->win->gl_context, re->win->width, re->win->height, 0);
/* simple bounding box */
RECTS_CLIP_TO_RECT(x, y, w, h, 0, 0, re->win->width, re->win->height);
if ((w <= 0) || (h <= 0)) return;
if ((w <= 0) || (h <= 0)) goto end;
if (!re->win->draw.redraw)
{
#if 0
@ -203,6 +203,7 @@ eng_output_redraws_rect_add(void *data, int x, int y, int w, int h)
if ((y + h - 1) > re->win->draw.y2) re->win->draw.y2 = y + h - 1;
}
re->win->draw.redraw = 1;
end:
eng_window_unlock_focus(re->win);
}
@ -1340,7 +1341,7 @@ module_open(Evas_Module *em)
if (!evas_gl_common_module_open()) return 0;
/* get whatever engine module we inherit from */
if (!_evas_module_engine_inherit(&pfunc, "software_generic")) return 0;
_evas_engine_gl_cocoa_log_dom = eina_log_domain_register("EvasGLCocoa", EVAS_DEFAULT_LOG_COLOR);
_evas_engine_gl_cocoa_log_dom = eina_log_domain_register("evas-gl_cocoa", EVAS_DEFAULT_LOG_COLOR);
if(_evas_engine_gl_cocoa_log_dom < 0)
{
EINA_LOG_ERR("Impossible to create a log domain for GL (Cocoa) engine.");

View File

@ -151,10 +151,9 @@ eng_window_resize(Evas_GL_Cocoa_Window *gw, int width, int height)
INF("Resize %d %d\n", width, height);
view_frame = [(EvasGLView*)gw->view frame];
printf("view_frame : %3.3f %3.3f\n", view_frame.size.height, view_frame.size.width);
view_frame.size.height = height;
view_frame.size.width = width;
printf("view_frame : %3.3f %3.3f\n", view_frame.size.height, view_frame.size.width);
[(EvasGLView*)gw->view setFrame:view_frame];
[[(NSOpenGLView*)gw->view openGLContext] flushBuffer];
}