forked from enlightenment/efl
Compare commits
46 Commits
master
...
devs/capta
Author | SHA1 | Date |
---|---|---|
Jean Guyomarc'h | 4d1e7d97c4 | |
Jean Guyomarc'h | 3f1114d829 | |
Jean Guyomarc'h | 1811704a90 | |
Jean Guyomarc'h | 6c296b3d16 | |
Jean Guyomarc'h | 60e2a6cbbb | |
Jean Guyomarc'h | 267c8ea18a | |
Jean Guyomarc'h | 731ab05a28 | |
Jean Guyomarc'h | c85f867415 | |
Jean Guyomarc'h | d12ded45d6 | |
Jean Guyomarc'h | bf02510024 | |
Jean Guyomarc'h | dbe57695ef | |
Jean Guyomarc'h | c17971bc80 | |
Jean Guyomarc'h | 243bd5116f | |
Jean Guyomarc'h | 255c5f064e | |
Jean Guyomarc'h | 5e1456f61f | |
Jean Guyomarc'h | f362d30777 | |
Jean Guyomarc'h | 8f5581c704 | |
Jean Guyomarc'h | 20af977266 | |
Jean Guyomarc'h | df3b7a6302 | |
Jean Guyomarc'h | a591cea8d2 | |
Jean Guyomarc'h | 18a1c202cc | |
Jean Guyomarc'h | 8bbdb2511e | |
Jean Guyomarc'h | 226709745a | |
Jean Guyomarc'h | 1f1afce94e | |
Jean Guyomarc'h | 70ad7994a8 | |
Jean Guyomarc'h | 0435ba7c77 | |
Jean Guyomarc'h | 358165b41f | |
Jean Guyomarc'h | a439f71965 | |
Jean Guyomarc'h | f1679e259a | |
Jean Guyomarc'h | 14775bc8c4 | |
Jean Guyomarc'h | e621b2d1d4 | |
Jean Guyomarc'h | 29ccf7fbf8 | |
Jean Guyomarc'h | 3dc7677c91 | |
Jean Guyomarc'h | 7ab47f9614 | |
Jean Guyomarc'h | 3331526dc8 | |
Jean Guyomarc'h | 825e316ac5 | |
Jean Guyomarc'h | c7a482f8a3 | |
Jean Guyomarc'h | 5c699924f4 | |
Jean Guyomarc'h | a51dc81d1f | |
Jean Guyomarc'h | 650852fd8d | |
Jean Guyomarc'h | 4c3134c97f | |
Vincent Torri | 0bec83d667 | |
Vincent Torri | 5f056dc2b3 | |
Vincent Torri | 65b71bcea7 | |
Vincent Torri | 65c82ea15c | |
Nicolas Aguirre | 0c12f9d881 |
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 \
|
||||
|
|
|
@ -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;
|
||||
|
||||
EAPI int ecore_cocoa_init(void);
|
||||
EAPI int ecore_cocoa_shutdown(void);
|
||||
EAPI Eina_Bool ecore_cocoa_feed_events(void *anEvent);
|
||||
|
||||
/* Screen */
|
||||
/*============================================================================*
|
||||
* 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);
|
||||
|
||||
|
||||
/*============================================================================*
|
||||
* 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
|
||||
}
|
||||
|
|
|
@ -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__ */
|
||||
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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?
|
||||
return nil;
|
||||
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;
|
||||
|
|
|
@ -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];
|
||||
}
|
||||
|
|
@ -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;
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
@ -18,19 +23,19 @@
|
|||
backing: (NSBackingStoreType) bufferingType
|
||||
defer: (BOOL) flag
|
||||
{
|
||||
if (![super initWithContentRect: contentRect
|
||||
styleMask: aStyle
|
||||
backing: bufferingType
|
||||
defer: flag]) return nil;
|
||||
if (![super initWithContentRect: contentRect
|
||||
styleMask: aStyle
|
||||
backing: bufferingType
|
||||
defer: flag]) return nil;
|
||||
|
||||
[self setBackgroundColor: [NSColor whiteColor]];
|
||||
[self makeKeyWindow];
|
||||
[self setDelegate:self];
|
||||
[self setAcceptsMouseMovedEvents:YES];
|
||||
[self setBackgroundColor: [NSColor whiteColor]];
|
||||
[self makeKeyWindow];
|
||||
[self setDelegate:self];
|
||||
[self setAcceptsMouseMovedEvents:YES];
|
||||
|
||||
[self setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
|
||||
[self setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
|
||||
|
||||
return self;
|
||||
return self;
|
||||
}
|
||||
|
||||
- (BOOL)isFullScreen
|
||||
|
@ -45,34 +50,33 @@
|
|||
|
||||
- (BOOL)canBecomeKeyWindow
|
||||
{
|
||||
return YES;
|
||||
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");
|
||||
return;
|
||||
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,34 +84,55 @@
|
|||
(([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;
|
||||
Ecore_Cocoa_Event_Window *e;
|
||||
|
||||
e = malloc(sizeof(Ecore_Cocoa_Event_Window));
|
||||
if (!e)
|
||||
{
|
||||
DBG("GOT_FOCUS: Failed to allocate Ecore_Cocoa_Event_Window\n");
|
||||
return;
|
||||
}
|
||||
e->wid = [notification object];
|
||||
ecore_event_add(ECORE_COCOA_EVENT_GOT_FOCUS, e, NULL, NULL);
|
||||
e = malloc(sizeof(*e));
|
||||
if (EINA_UNLIKELY(e == NULL))
|
||||
{
|
||||
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;
|
||||
Ecore_Cocoa_Event_Window *e;
|
||||
|
||||
e = malloc(sizeof(Ecore_Cocoa_Event_Window));
|
||||
if (!e)
|
||||
{
|
||||
DBG("LOST_FOCUS: Failed to allocate Ecore_Cocoa_Event_Window\n");
|
||||
return;
|
||||
}
|
||||
e->wid = [notification object];
|
||||
ecore_event_add(ECORE_COCOA_EVENT_LOST_FOCUS, e, NULL, NULL);
|
||||
e = malloc(sizeof(*e));
|
||||
if (EINA_UNLIKELY(e == NULL))
|
||||
{
|
||||
CRI("Failed to allocate Ecore_Cocoa_Event_Window");
|
||||
return;
|
||||
}
|
||||
e->wid = [notification object];
|
||||
ecore_event_add(ECORE_COCOA_EVENT_LOST_FOCUS, e, NULL, NULL);
|
||||
}
|
||||
|
||||
- (void) mouseDown:(NSEvent*) event
|
||||
|
@ -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;
|
||||
|
@ -161,12 +191,12 @@
|
|||
|
||||
- (void) rightMouseDown:(NSEvent*) event
|
||||
{
|
||||
[self mouseDown: event];
|
||||
[self mouseDown: event];
|
||||
}
|
||||
|
||||
- (void) otherMouseDown:(NSEvent*) event
|
||||
{
|
||||
[self mouseDown: event];
|
||||
[self mouseDown: event];
|
||||
}
|
||||
|
||||
- (void) mouseUp:(NSEvent*) event
|
||||
|
@ -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;
|
||||
|
@ -214,19 +248,23 @@
|
|||
|
||||
- (void) rightMouseUp:(NSEvent*) event
|
||||
{
|
||||
[self mouseUp: event];
|
||||
[self mouseUp: event];
|
||||
}
|
||||
|
||||
- (void) otherMouseUp:(NSEvent*) event
|
||||
{
|
||||
[self mouseUp: event];
|
||||
[self mouseUp: event];
|
||||
}
|
||||
|
||||
- (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,202 +289,196 @@
|
|||
|
||||
@end
|
||||
|
||||
Ecore_Cocoa_Window *
|
||||
EAPI Ecore_Cocoa_Window *
|
||||
ecore_cocoa_window_new(int x,
|
||||
int y,
|
||||
int width,
|
||||
int height)
|
||||
int y,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
Ecore_Cocoa_Window *w;
|
||||
Ecore_Cocoa_Window *w;
|
||||
EcoreCocoaWindow *window;
|
||||
NSRect frame = NSMakeRect(x, y, width, height);
|
||||
NSUInteger style =
|
||||
NSTitledWindowMask |
|
||||
NSClosableWindowMask |
|
||||
NSResizableWindowMask |
|
||||
NSMiniaturizableWindowMask;
|
||||
|
||||
EcoreCocoaWindow *window = [[EcoreCocoaWindow alloc] initWithContentRect:NSMakeRect(x, y, width, height)
|
||||
styleMask:(NSTitledWindowMask |
|
||||
NSClosableWindowMask |
|
||||
NSResizableWindowMask |
|
||||
NSMiniaturizableWindowMask)
|
||||
backing:NSBackingStoreBuffered
|
||||
defer:NO];
|
||||
window = [[EcoreCocoaWindow alloc] initWithContentRect:frame
|
||||
styleMask:style
|
||||
backing:NSBackingStoreBuffered
|
||||
defer:NO];
|
||||
if (EINA_UNLIKELY(!window))
|
||||
{
|
||||
CRI("Failed to create EcoreCocoaWindow");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!window)
|
||||
return NULL;
|
||||
w = calloc(1, sizeof(Ecore_Cocoa_Window));
|
||||
if (EINA_UNLIKELY(w == NULL))
|
||||
{
|
||||
CRI("Failed to allocate Ecore_Cocoa_Window");
|
||||
[window release];
|
||||
return NULL;
|
||||
}
|
||||
w->window = window;
|
||||
w->borderless = 0;
|
||||
|
||||
//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];
|
||||
window.ecore_window_data = w;
|
||||
|
||||
|
||||
w = calloc(1, sizeof(Ecore_Cocoa_Window));
|
||||
if (w == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
w->window = window;
|
||||
w->borderless = 0;
|
||||
|
||||
window.ecore_window_data = w;
|
||||
|
||||
return w;
|
||||
return w;
|
||||
}
|
||||
|
||||
void
|
||||
EAPI void
|
||||
ecore_cocoa_window_free(Ecore_Cocoa_Window *window)
|
||||
{
|
||||
if (!window)
|
||||
return;
|
||||
if (!window)
|
||||
return;
|
||||
|
||||
[window->window release];
|
||||
free(window);
|
||||
[window->window release];
|
||||
free(window);
|
||||
}
|
||||
|
||||
void
|
||||
EAPI void
|
||||
ecore_cocoa_window_size_min_set(Ecore_Cocoa_Window *window,
|
||||
unsigned int w,
|
||||
unsigned int h)
|
||||
{
|
||||
if (!window)
|
||||
return;
|
||||
NSSize size = {w,h};
|
||||
window->window.contentMinSize = size;
|
||||
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;
|
||||
NSSize size = {w,h};
|
||||
window->window.contentMaxSize = size;
|
||||
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;
|
||||
NSSize size = {w,h};
|
||||
window->window.contentResizeIncrements = size;
|
||||
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)
|
||||
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;
|
||||
win_frame.origin.y = y;
|
||||
win_frame = [window->window frame];
|
||||
win_frame.origin.x = x;
|
||||
win_frame.origin.y = y;
|
||||
|
||||
[window->window setFrame:win_frame display:YES];
|
||||
[window->window setFrame:win_frame display:YES];
|
||||
}
|
||||
|
||||
void
|
||||
EAPI void
|
||||
ecore_cocoa_window_resize(Ecore_Cocoa_Window *window,
|
||||
int width,
|
||||
int height)
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
if (!window) return;
|
||||
EINA_SAFETY_ON_NULL_RETURN(window);
|
||||
|
||||
NSRect win_frame;
|
||||
NSRect win_frame;
|
||||
|
||||
win_frame = [window->window frame];
|
||||
win_frame.size.height = height +
|
||||
(([window->window isFullScreen] == YES) ? 0 : ecore_cocoa_titlebar_height_get());
|
||||
win_frame.size.width = width;
|
||||
win_frame = [window->window frame];
|
||||
win_frame.size.height = height +
|
||||
(([window->window isFullScreen] == YES) ? 0 : ecore_cocoa_titlebar_height_get());
|
||||
win_frame.size.width = width;
|
||||
|
||||
[window->window setFrame:win_frame display:YES];
|
||||
[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)
|
||||
int x,
|
||||
int y,
|
||||
int width,
|
||||
int height)
|
||||
{
|
||||
if (!window) return;
|
||||
EINA_SAFETY_ON_NULL_RETURN(window);
|
||||
|
||||
NSRect win_frame;
|
||||
NSRect win_frame;
|
||||
|
||||
win_frame = [window->window frame];
|
||||
win_frame.size.height = height +
|
||||
(([window->window isFullScreen] == YES) ? 0 : ecore_cocoa_titlebar_height_get());
|
||||
win_frame.size.width = width;
|
||||
win_frame.origin.x = x;
|
||||
win_frame.origin.y = y;
|
||||
win_frame = [window->window frame];
|
||||
win_frame.size.height = height +
|
||||
(([window->window isFullScreen] == YES) ? 0 : ecore_cocoa_titlebar_height_get());
|
||||
win_frame.size.width = width;
|
||||
win_frame.origin.x = x;
|
||||
win_frame.origin.y = y;
|
||||
|
||||
[window->window setFrame:win_frame display:YES];
|
||||
[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]];
|
||||
[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);
|
||||
|
||||
[window->window makeKeyAndOrderFront:NSApp];
|
||||
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);
|
||||
|
||||
[window->window orderOut:NSApp];
|
||||
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;
|
||||
|
||||
[window->window orderFront:nil];
|
||||
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,
|
||||
int on)
|
||||
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,46 +490,91 @@ 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];
|
||||
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)
|
||||
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;
|
||||
[window->window setContentView:view];
|
||||
//[[window->window contentView] addSubview:view];
|
||||
NSView *v = view;
|
||||
[window->window setContentView:view];
|
||||
|
||||
NSTrackingArea *area = [[NSTrackingArea alloc] initWithRect:[v frame]
|
||||
options:NSTrackingMouseMoved |
|
||||
NSTrackingActiveInActiveApp |
|
||||
NSTrackingInVisibleRect
|
||||
owner:v
|
||||
userInfo:nil];
|
||||
[v addTrackingArea:area];
|
||||
NSTrackingArea *area = [[NSTrackingArea alloc] initWithRect:[v frame]
|
||||
options:NSTrackingMouseMoved |
|
||||
NSTrackingActiveInActiveApp |
|
||||
NSTrackingInVisibleRect
|
||||
owner:v
|
||||
userInfo:nil];
|
||||
[v addTrackingArea:area];
|
||||
|
||||
[area release];
|
||||
[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);
|
||||
|
||||
return 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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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__ */
|
||||
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
|
|
@ -24,10 +24,18 @@
|
|||
* @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
|
||||
# include <basetyps.h>
|
||||
#define INITGUID
|
||||
#include <basetyps.h>
|
||||
DEFINE_OLEGUID(IID_IEnumFORMATETC, 0x00000103L, 0, 0);
|
||||
DEFINE_OLEGUID(IID_IDataObject, 0x0000010EL, 0, 0);
|
||||
DEFINE_OLEGUID(IID_IDropSource, 0x00000121L, 0, 0);
|
||||
|
@ -36,7 +44,10 @@ DEFINE_OLEGUID(IID_IUnknown, 0x00000000L, 0, 0);
|
|||
|
||||
#define IDI_ICON 101
|
||||
|
||||
static int _ecore_win32_init_count = 0;
|
||||
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
|
||||
_ecore_win32_window_procedure(HWND window,
|
||||
|
@ -194,13 +205,33 @@ _ecore_win32_window_procedure(HWND window,
|
|||
return 0;
|
||||
/* Window notifications */
|
||||
case WM_CREATE:
|
||||
INF("create window message");
|
||||
{
|
||||
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:
|
||||
INF("destroy window message");
|
||||
_ecore_win32_event_handle_destroy_notify(data);
|
||||
return 0;
|
||||
{
|
||||
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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
|
@ -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
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -12,41 +12,30 @@
|
|||
|
||||
#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")))
|
||||
# else
|
||||
# define EAPI
|
||||
# endif
|
||||
#ifdef __GNUC__
|
||||
# if __GNUC__ >= 4
|
||||
# define EAPI __attribute__ ((visibility("default")))
|
||||
# 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
|
||||
#else
|
||||
# define EAPI
|
||||
#endif
|
||||
|
||||
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)
|
||||
|
@ -55,11 +44,11 @@ _render_updates_process(Ecore_Evas *ee, Eina_List *updates)
|
|||
|
||||
if (ee->prop.avoid_damage)
|
||||
{
|
||||
if (updates)
|
||||
{
|
||||
_ecore_evas_idle_timeout_update(ee);
|
||||
rend = 1;
|
||||
}
|
||||
if (updates)
|
||||
{
|
||||
_ecore_evas_idle_timeout_update(ee);
|
||||
rend = 1;
|
||||
}
|
||||
|
||||
}
|
||||
else if (((ee->visible) && (ee->draw_ok)) ||
|
||||
|
@ -70,11 +59,11 @@ _render_updates_process(Ecore_Evas *ee, Eina_List *updates)
|
|||
{
|
||||
if (ee->shaped)
|
||||
{
|
||||
//TODO
|
||||
//TODO
|
||||
}
|
||||
if (ee->alpha)
|
||||
{
|
||||
//TODO
|
||||
//TODO
|
||||
}
|
||||
_ecore_evas_idle_timeout_update(ee);
|
||||
rend = 1;
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -190,61 +164,73 @@ _ecore_evas_cocoa_render(Ecore_Evas *ee)
|
|||
static Ecore_Evas *
|
||||
_ecore_evas_cocoa_match(Ecore_Cocoa_Window_Id wid)
|
||||
{
|
||||
Eina_List *it;
|
||||
Ecore_Evas *ee;
|
||||
Eina_List *it;
|
||||
Ecore_Evas *ee;
|
||||
|
||||
DBG("Match");
|
||||
EINA_LIST_FOREACH(ecore_evases, it, ee)
|
||||
{
|
||||
if (ecore_cocoa_window_get_window_id((Ecore_Cocoa_Window *)ee->prop.window) == wid)
|
||||
return ee;
|
||||
}
|
||||
return NULL;
|
||||
DBG("");
|
||||
EINA_LIST_FOREACH(ecore_evases, it, ee)
|
||||
{
|
||||
if (ecore_cocoa_window_get_window_id((Ecore_Cocoa_Window *)ee->prop.window) == wid)
|
||||
return ee;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static Eina_Bool
|
||||
_ecore_evas_cocoa_event_got_focus(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
|
||||
{
|
||||
Ecore_Cocoa_Event_Window *e = event;
|
||||
Ecore_Evas *ee;
|
||||
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;
|
||||
|
||||
ee = _ecore_evas_cocoa_match(e->wid);
|
||||
ee->prop.focused = EINA_TRUE;
|
||||
evas_focus_in(ee->evas);
|
||||
if (ee->func.fn_focus_in) ee->func.fn_focus_in(ee);
|
||||
|
||||
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);
|
||||
|
||||
return ECORE_CALLBACK_PASS_ON;
|
||||
return ECORE_CALLBACK_PASS_ON;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_ecore_evas_cocoa_event_lost_focus(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
|
||||
{
|
||||
Ecore_Cocoa_Event_Window *e = event;
|
||||
Ecore_Evas *ee;
|
||||
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;
|
||||
|
||||
ee = _ecore_evas_cocoa_match(e->wid);
|
||||
evas_focus_out(ee->evas);
|
||||
ee->prop.focused = EINA_FALSE;
|
||||
if (ee->func.fn_focus_out) ee->func.fn_focus_out(ee);
|
||||
|
||||
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);
|
||||
return ECORE_CALLBACK_PASS_ON;
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -253,61 +239,36 @@ _ecore_evas_cocoa_event_video_resize(void *data EINA_UNUSED, int type EINA_UNUSE
|
|||
Ecore_Cocoa_Event_Video_Resize *e = event;
|
||||
Ecore_Evas *ee;
|
||||
|
||||
DBG("Video resize");
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
/* Do the resize */
|
||||
_ecore_evas_resize_common(ee, e->w, e->h, EINA_FALSE);
|
||||
|
||||
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");
|
||||
|
||||
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;
|
||||
}
|
||||
evas_output_size_get(ee->evas, &w, &h);
|
||||
evas_damage_rectangle_add(ee->evas, 0, 0, w, h);
|
||||
|
||||
return ECORE_CALLBACK_PASS_ON;
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
_ecore_evas_cocoa_event_window_destroy(void *data EINA_UNUSED, int type EINA_UNUSED, void *event)
|
||||
{
|
||||
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,79 +277,53 @@ _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");
|
||||
_ecore_evas_init_count++;
|
||||
if (_ecore_evas_init_count > 1)
|
||||
return _ecore_evas_init_count;
|
||||
DBG("");
|
||||
_ecore_evas_init_count++;
|
||||
if (_ecore_evas_init_count > 1)
|
||||
return _ecore_evas_init_count;
|
||||
|
||||
ecore_event_evas_init();
|
||||
ecore_event_evas_init();
|
||||
|
||||
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[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_WINDOW_DESTROY, _ecore_evas_cocoa_event_window_destroy, NULL);
|
||||
|
||||
return _ecore_evas_init_count;
|
||||
return _ecore_evas_init_count;
|
||||
}
|
||||
|
||||
static int
|
||||
_ecore_evas_cocoa_shutdown(void)
|
||||
{
|
||||
Ecore_Evas *ee;
|
||||
DBG("Cocoa Shutdown");
|
||||
_ecore_evas_init_count--;
|
||||
if (_ecore_evas_init_count == 0)
|
||||
{
|
||||
unsigned int i;
|
||||
Ecore_Evas *ee;
|
||||
DBG("");
|
||||
_ecore_evas_init_count--;
|
||||
if (_ecore_evas_init_count == 0)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
EINA_LIST_FREE(ecore_evases, ee)
|
||||
_ecore_evas_free(ee);
|
||||
EINA_LIST_FREE(ecore_evases, ee)
|
||||
_ecore_evas_free(ee);
|
||||
|
||||
for (i = 0; i < sizeof (ecore_evas_event_handlers) / sizeof (Ecore_Event_Handler*); 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;
|
||||
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();
|
||||
}
|
||||
if (_ecore_evas_init_count < 0) _ecore_evas_init_count = 0;
|
||||
return _ecore_evas_init_count;
|
||||
ecore_event_evas_shutdown();
|
||||
}
|
||||
return _ecore_evas_init_count;
|
||||
}
|
||||
|
||||
static void
|
||||
_ecore_evas_cocoa_free(Ecore_Evas *ee)
|
||||
{
|
||||
DBG("Cocoa Free");
|
||||
ecore_evases = eina_list_remove(ecore_evases, ee);
|
||||
ecore_event_window_unregister(0);
|
||||
_ecore_evas_cocoa_shutdown();
|
||||
ecore_cocoa_shutdown();
|
||||
DBG("");
|
||||
ecore_evases = eina_list_remove(ecore_evases, ee);
|
||||
ecore_event_window_unregister(0);
|
||||
_ecore_evas_cocoa_shutdown();
|
||||
ecore_cocoa_shutdown();
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -412,61 +347,47 @@ _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");
|
||||
if ((ee->w == w) && (ee->h == h) && (x == ee->x) && (y == ee->y))
|
||||
return;
|
||||
DBG("");
|
||||
if ((ee->w == w) && (ee->h == h) && (x == ee->x) && (y == ee->y))
|
||||
return;
|
||||
|
||||
ee->req.x = x;
|
||||
ee->req.y = y;
|
||||
ee->req.w = w;
|
||||
ee->req.h = h;
|
||||
ee->w = w;
|
||||
ee->h = h;
|
||||
ee->x = x;
|
||||
ee->y = y;
|
||||
ee->req.x = x;
|
||||
ee->req.y = y;
|
||||
ee->req.w = w;
|
||||
ee->req.h = h;
|
||||
ee->w = w;
|
||||
ee->h = h;
|
||||
ee->x = x;
|
||||
ee->y = y;
|
||||
|
||||
ecore_cocoa_window_move_resize((Ecore_Cocoa_Window *)ee->prop.window, x, y, w, h);
|
||||
ecore_cocoa_window_move_resize((Ecore_Cocoa_Window *)ee->prop.window, x, y, 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);
|
||||
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);
|
||||
if (ee->func.fn_resize) ee->func.fn_resize(ee);
|
||||
}
|
||||
|
||||
|
||||
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,15 +409,15 @@ _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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
@ -533,13 +454,13 @@ _ecore_evas_title_set(Ecore_Evas *ee, const char *title)
|
|||
static void
|
||||
_ecore_evas_object_cursor_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ecore_Evas *ee;
|
||||
Ecore_Evas *ee;
|
||||
|
||||
DBG("Cursor DEL");
|
||||
DBG("");
|
||||
|
||||
ee = data;
|
||||
if (ee)
|
||||
ee->prop.cursor.object = NULL;
|
||||
ee = data;
|
||||
if (ee)
|
||||
ee->prop.cursor.object = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -551,45 +472,58 @@ _ecore_evas_object_cursor_unset(Ecore_Evas *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;
|
||||
DBG("Cursor Set");
|
||||
if (ee->prop.cursor.object) evas_object_del(ee->prop.cursor.object);
|
||||
int x, y;
|
||||
Evas_Object *old;
|
||||
Ecore_Cocoa_Window *win = (Ecore_Cocoa_Window *)(ee->prop.window);
|
||||
DBG("");
|
||||
|
||||
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;
|
||||
}
|
||||
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;
|
||||
ecore_cocoa_window_cursor_show(win, EINA_TRUE);
|
||||
goto end;
|
||||
}
|
||||
|
||||
ee->prop.cursor.object = obj;
|
||||
ee->prop.cursor.layer = layer;
|
||||
ee->prop.cursor.hot.x = hot_x;
|
||||
ee->prop.cursor.hot.y = hot_y;
|
||||
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_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
|
||||
_ecore_evas_withdrawn_set(Ecore_Evas *ee, Eina_Bool on)
|
||||
{
|
||||
if (on)
|
||||
_ecore_evas_hide(ee);
|
||||
else
|
||||
_ecore_evas_show(ee);
|
||||
if (on)
|
||||
_ecore_evas_hide(ee);
|
||||
else
|
||||
_ecore_evas_show(ee);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
@ -701,120 +632,133 @@ static Ecore_Evas_Engine_Func _ecore_cocoa_engine_func =
|
|||
NULL, // profiles_set
|
||||
NULL, // profile_set
|
||||
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
|
||||
NULL, // render
|
||||
_ecore_evas_screen_geometry_get,
|
||||
NULL, // screen_dpi_get
|
||||
NULL,
|
||||
NULL // msg_send
|
||||
NULL, // render
|
||||
_ecore_evas_screen_geometry_get,
|
||||
NULL, // screen_dpi_get
|
||||
NULL,
|
||||
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;
|
||||
Ecore_Evas *ee;
|
||||
Ecore_Evas_Interface_Cocoa *iface;
|
||||
|
||||
DBG("Cocoa new");
|
||||
if (!ecore_cocoa_init())
|
||||
return NULL;
|
||||
|
||||
if (!ecore_cocoa_init())
|
||||
return NULL;
|
||||
DBG("");
|
||||
|
||||
ee = calloc(1, sizeof(Ecore_Evas));
|
||||
if (!ee)
|
||||
goto shutdown_ecore_cocoa;
|
||||
|
||||
ee = calloc(1, sizeof(Ecore_Evas));
|
||||
if (!ee)
|
||||
goto shutdown_ecore_cocoa;
|
||||
ECORE_MAGIC_SET(ee, ECORE_MAGIC_EVAS);
|
||||
|
||||
ECORE_MAGIC_SET(ee, ECORE_MAGIC_EVAS);
|
||||
_ecore_evas_cocoa_init();
|
||||
|
||||
_ecore_evas_cocoa_init();
|
||||
ee->engine.func = (Ecore_Evas_Engine_Func *)&_ecore_cocoa_engine_func;
|
||||
|
||||
ee->engine.func = (Ecore_Evas_Engine_Func *)&_ecore_cocoa_engine_func;
|
||||
if (w < 1) w = 1;
|
||||
if (h < 1) h = 1;
|
||||
ee->visible = 1;
|
||||
ee->x = x;
|
||||
ee->y = y;
|
||||
ee->w = w;
|
||||
ee->h = h;
|
||||
ee->req.x = ee->x;
|
||||
ee->req.y = ee->y;
|
||||
ee->req.w = ee->w - ee->y;
|
||||
ee->req.h = ee->h;
|
||||
|
||||
if (w < 1) w = 1;
|
||||
if (h < 1) h = 1;
|
||||
ee->visible = 1;
|
||||
ee->x = x;
|
||||
ee->y = y;
|
||||
ee->w = w;
|
||||
ee->h = h;
|
||||
ee->req.x = ee->x;
|
||||
ee->req.y = ee->y;
|
||||
ee->req.w = ee->w - ee->y;
|
||||
ee->req.h = ee->h;
|
||||
ee->semi_sync = 1;
|
||||
|
||||
ee->semi_sync = 1;
|
||||
ee->prop.max.w = 32767;
|
||||
ee->prop.max.h = 32767;
|
||||
ee->prop.layer = 4;
|
||||
ee->prop.request_pos = EINA_FALSE;
|
||||
ee->prop.sticky = EINA_FALSE;
|
||||
ee->prop.window = 0;
|
||||
ee->prop.withdrawn = EINA_TRUE;
|
||||
|
||||
ee->evas = evas_new();
|
||||
|
||||
ee->prop.max.w = 32767;
|
||||
ee->prop.max.h = 32767;
|
||||
ee->prop.layer = 4;
|
||||
ee->prop.request_pos = EINA_FALSE;
|
||||
ee->prop.sticky = EINA_FALSE;
|
||||
ee->prop.window = 0;
|
||||
ee->prop.withdrawn = EINA_TRUE;
|
||||
if (!ee->evas)
|
||||
goto free_name;
|
||||
|
||||
printf("Create New Evas\n");
|
||||
evas_data_attach_set(ee->evas, ee);
|
||||
evas_output_size_set(ee->evas, w, h);
|
||||
evas_output_viewport_set(ee->evas, 0, 0, w, h);
|
||||
|
||||
ee->evas = evas_new();
|
||||
ee->prop.window = (Ecore_Window)ecore_cocoa_window_new(x, y, w, h);
|
||||
|
||||
if (!ee->evas)
|
||||
goto free_name;
|
||||
if (!ee->prop.window)
|
||||
{
|
||||
_ecore_evas_cocoa_shutdown();
|
||||
free(ee);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
evas_data_attach_set(ee->evas, ee);
|
||||
evas_output_size_set(ee->evas, w, h);
|
||||
evas_output_viewport_set(ee->evas, 0, 0, w, h);
|
||||
if (!_ecore_evas_engine_cocoa_init(ee))
|
||||
{
|
||||
_ecore_evas_cocoa_shutdown();
|
||||
free(ee);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
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();
|
||||
free(ee);
|
||||
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);
|
||||
|
||||
printf("Init Evas engine cocoa\n");
|
||||
if (!_ecore_evas_engine_cocoa_init(ee))
|
||||
{
|
||||
_ecore_evas_cocoa_shutdown();
|
||||
free(ee);
|
||||
return NULL;
|
||||
}
|
||||
ee->engine.func->fn_render = _ecore_evas_cocoa_render;
|
||||
_ecore_evas_register(ee);
|
||||
ecore_event_window_register(ee->prop.window, ee, ee->evas,
|
||||
(Ecore_Event_Mouse_Move_Cb)_ecore_evas_mouse_move_process,
|
||||
(Ecore_Event_Multi_Move_Cb)_ecore_evas_mouse_multi_move_process,
|
||||
(Ecore_Event_Multi_Down_Cb)_ecore_evas_mouse_multi_down_process,
|
||||
(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);
|
||||
ecore_evases = eina_list_append(ecore_evases, ee);
|
||||
|
||||
ee->engine.func->fn_render = _ecore_evas_cocoa_render;
|
||||
_ecore_evas_register(ee);
|
||||
ecore_event_window_register(ee->prop.window, ee, ee->evas,
|
||||
(Ecore_Event_Mouse_Move_Cb)_ecore_evas_mouse_move_process,
|
||||
(Ecore_Event_Multi_Move_Cb)_ecore_evas_mouse_multi_move_process,
|
||||
(Ecore_Event_Multi_Down_Cb)_ecore_evas_mouse_multi_down_process,
|
||||
(Ecore_Event_Multi_Up_Cb)_ecore_evas_mouse_multi_up_process);
|
||||
return ee;
|
||||
|
||||
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;
|
||||
|
||||
//free_window:
|
||||
/* FIXME: free window here */
|
||||
//free_evas:
|
||||
// free(ee->evas);
|
||||
free_name:
|
||||
free(ee->name);
|
||||
//free_ee:
|
||||
_ecore_evas_cocoa_shutdown();
|
||||
free(ee);
|
||||
//free_window:
|
||||
/* FIXME: free window here */
|
||||
//free_evas:
|
||||
// free(ee->evas);
|
||||
free_name:
|
||||
free(ee->name);
|
||||
//free_ee:
|
||||
_ecore_evas_cocoa_shutdown();
|
||||
free(ee);
|
||||
shutdown_ecore_cocoa:
|
||||
ecore_cocoa_shutdown();
|
||||
ecore_cocoa_shutdown();
|
||||
|
||||
return NULL;
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ struct _Render_Engine_GL_Surface
|
|||
struct _Render_Engine_GL_Context
|
||||
{
|
||||
int initialized;
|
||||
// EGLContext context;
|
||||
// EGLContext context;
|
||||
|
||||
GLuint fbo;
|
||||
|
||||
|
@ -104,8 +104,8 @@ eng_setup(Evas *eo_e, void *in)
|
|||
|
||||
e->engine.data.output = re;
|
||||
re->win = eng_window_new(info->window,
|
||||
e->output.w,
|
||||
e->output.h);
|
||||
e->output.w,
|
||||
e->output.h);
|
||||
info->view = re->win->view;
|
||||
if (!re->win)
|
||||
{
|
||||
|
@ -121,8 +121,8 @@ eng_setup(Evas *eo_e, void *in)
|
|||
re = e->engine.data.output;
|
||||
eng_window_free(re->win);
|
||||
re->win = eng_window_new(info->window,
|
||||
e->output.w,
|
||||
e->output.h);
|
||||
e->output.w,
|
||||
e->output.h);
|
||||
info->view = re->win->view;
|
||||
}
|
||||
if (!e->engine.data.output) return 0;
|
||||
|
@ -166,7 +166,7 @@ eng_output_resize(void *data, int w, int h)
|
|||
static void
|
||||
eng_output_tile_size_set(void *data EINA_UNUSED, int w EINA_UNUSED, int h EINA_UNUSED)
|
||||
{
|
||||
DBG("tile size set");
|
||||
DBG("tile size set");
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -235,10 +236,10 @@ eng_output_redraws_next_update_get(void *data, int *x, int *y, int *w, int *h, i
|
|||
/* get the upate rect surface - return engine data as dummy */
|
||||
if (!re->win->draw.redraw)
|
||||
{
|
||||
// printf("GL: NO updates!\n");
|
||||
// printf("GL: NO updates!\n");
|
||||
return NULL;
|
||||
}
|
||||
// printf("GL: update....!\n");
|
||||
// printf("GL: update....!\n");
|
||||
#ifdef SLOW_GL_COPY_RECT
|
||||
/* if any update - just return the whole canvas - works with swap
|
||||
* buffers then */
|
||||
|
@ -266,10 +267,10 @@ eng_output_redraws_next_update_get(void *data, int *x, int *y, int *w, int *h, i
|
|||
if (cw) *cw = re->win->draw.x2 - re->win->draw.x1 + 1;
|
||||
if (ch) *ch = re->win->draw.y2 - re->win->draw.y1 + 1;
|
||||
#endif
|
||||
// clear buffer. only needed for dest alpha
|
||||
// glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
// glClear(GL_COLOR_BUFFER_BIT);
|
||||
//x// printf("frame -> new\n");
|
||||
// clear buffer. only needed for dest alpha
|
||||
// glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
// glClear(GL_COLOR_BUFFER_BIT);
|
||||
//x// printf("frame -> new\n");
|
||||
return re->win->gl_context->def_surface;
|
||||
}
|
||||
|
||||
|
@ -382,10 +383,10 @@ eng_polygon_draw(void *data, void *context, void *surface EINA_UNUSED, void *pol
|
|||
static int
|
||||
eng_image_alpha_get(void *data EINA_UNUSED, void *image)
|
||||
{
|
||||
// Render_Engine *re;
|
||||
// Render_Engine *re;
|
||||
Evas_GL_Image *im;
|
||||
|
||||
// re = (Render_Engine *)data;
|
||||
// re = (Render_Engine *)data;
|
||||
if (!image) return 1;
|
||||
im = image;
|
||||
return im->alpha;
|
||||
|
@ -394,10 +395,10 @@ eng_image_alpha_get(void *data EINA_UNUSED, void *image)
|
|||
static Evas_Colorspace
|
||||
eng_image_colorspace_get(void *data EINA_UNUSED, void *image)
|
||||
{
|
||||
// Render_Engine *re;
|
||||
// Render_Engine *re;
|
||||
Evas_GL_Image *im;
|
||||
|
||||
// re = (Render_Engine *)data;
|
||||
// re = (Render_Engine *)data;
|
||||
if (!image) return EVAS_COLORSPACE_ARGB8888;
|
||||
im = image;
|
||||
return im->cs.space;
|
||||
|
@ -437,10 +438,10 @@ eng_image_alpha_set(void *data, void *image, int has_alpha)
|
|||
evas_cache_image_load_data(&im->im->cache_entry);
|
||||
evas_gl_common_image_alloc_ensure(im);
|
||||
im_new = evas_gl_common_image_new_from_copied_data
|
||||
(im->gc, im->im->cache_entry.w, im->im->cache_entry.h,
|
||||
im->im->image.data,
|
||||
eng_image_alpha_get(data, image),
|
||||
eng_image_colorspace_get(data, image));
|
||||
(im->gc, im->im->cache_entry.w, im->im->cache_entry.h,
|
||||
im->im->image.data,
|
||||
eng_image_alpha_get(data, image),
|
||||
eng_image_colorspace_get(data, image));
|
||||
if (!im_new) return im;
|
||||
evas_gl_common_image_free(im);
|
||||
im = im_new;
|
||||
|
@ -448,34 +449,34 @@ eng_image_alpha_set(void *data, void *image, int has_alpha)
|
|||
else
|
||||
evas_gl_common_image_dirty(im, 0, 0, 0, 0);
|
||||
return evas_gl_common_image_alpha_set(im, has_alpha ? 1 : 0);
|
||||
// im->im->cache_entry.flags.alpha = has_alpha ? 1 : 0;
|
||||
// return image;
|
||||
// im->im->cache_entry.flags.alpha = has_alpha ? 1 : 0;
|
||||
// return image;
|
||||
}
|
||||
|
||||
static void *
|
||||
eng_image_border_set(void *data EINA_UNUSED, void *image, int l EINA_UNUSED, int r EINA_UNUSED, int t EINA_UNUSED, int b EINA_UNUSED)
|
||||
{
|
||||
// Render_Engine *re;
|
||||
//
|
||||
// re = (Render_Engine *)data;
|
||||
// Render_Engine *re;
|
||||
//
|
||||
// re = (Render_Engine *)data;
|
||||
return image;
|
||||
}
|
||||
|
||||
static void
|
||||
eng_image_border_get(void *data EINA_UNUSED, void *image EINA_UNUSED, int *l EINA_UNUSED, int *r EINA_UNUSED, int *t EINA_UNUSED, int *b EINA_UNUSED)
|
||||
{
|
||||
// Render_Engine *re;
|
||||
//
|
||||
// re = (Render_Engine *)data;
|
||||
// Render_Engine *re;
|
||||
//
|
||||
// re = (Render_Engine *)data;
|
||||
}
|
||||
|
||||
static char *
|
||||
eng_image_comment_get(void *data EINA_UNUSED, void *image, char *key EINA_UNUSED)
|
||||
{
|
||||
// Render_Engine *re;
|
||||
// Render_Engine *re;
|
||||
Evas_GL_Image *im;
|
||||
|
||||
// re = (Render_Engine *)data;
|
||||
// re = (Render_Engine *)data;
|
||||
if (!image) return NULL;
|
||||
im = image;
|
||||
if (!im->im) return NULL;
|
||||
|
@ -485,10 +486,10 @@ eng_image_comment_get(void *data EINA_UNUSED, void *image, char *key EINA_UNUSED
|
|||
static char *
|
||||
eng_image_format_get(void *data EINA_UNUSED, void *image)
|
||||
{
|
||||
// Render_Engine *re;
|
||||
// Render_Engine *re;
|
||||
Evas_GL_Image *im;
|
||||
|
||||
// re = (Render_Engine *)data;
|
||||
// re = (Render_Engine *)data;
|
||||
im = image;
|
||||
return NULL;
|
||||
}
|
||||
|
@ -511,34 +512,34 @@ eng_image_colorspace_set(void *data, void *image, Evas_Colorspace cspace)
|
|||
switch (cspace)
|
||||
{
|
||||
case EVAS_COLORSPACE_ARGB8888:
|
||||
if (im->cs.data)
|
||||
{
|
||||
if (!im->cs.no_free) free(im->cs.data);
|
||||
im->cs.data = NULL;
|
||||
im->cs.no_free = 0;
|
||||
}
|
||||
break;
|
||||
if (im->cs.data)
|
||||
{
|
||||
if (!im->cs.no_free) free(im->cs.data);
|
||||
im->cs.data = NULL;
|
||||
im->cs.no_free = 0;
|
||||
}
|
||||
break;
|
||||
case EVAS_COLORSPACE_YCBCR422P601_PL:
|
||||
case EVAS_COLORSPACE_YCBCR422P709_PL:
|
||||
case EVAS_COLORSPACE_YCBCR422601_PL:
|
||||
case EVAS_COLORSPACE_YCBCR420NV12601_PL:
|
||||
case EVAS_COLORSPACE_YCBCR420TM12601_PL:
|
||||
if (im->tex) evas_gl_common_texture_free(im->tex, EINA_TRUE);
|
||||
im->tex = NULL;
|
||||
if (im->cs.data)
|
||||
{
|
||||
if (!im->cs.no_free) free(im->cs.data);
|
||||
}
|
||||
if (im->im->cache_entry.h > 0)
|
||||
im->cs.data =
|
||||
calloc(1, im->im->cache_entry.h * sizeof(unsigned char *) * 2);
|
||||
else
|
||||
im->cs.data = NULL;
|
||||
im->cs.no_free = 0;
|
||||
break;
|
||||
if (im->tex) evas_gl_common_texture_free(im->tex, EINA_TRUE);
|
||||
im->tex = NULL;
|
||||
if (im->cs.data)
|
||||
{
|
||||
if (!im->cs.no_free) free(im->cs.data);
|
||||
}
|
||||
if (im->im->cache_entry.h > 0)
|
||||
im->cs.data =
|
||||
calloc(1, im->im->cache_entry.h * sizeof(unsigned char *) * 2);
|
||||
else
|
||||
im->cs.data = NULL;
|
||||
im->cs.no_free = 0;
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
break;
|
||||
abort();
|
||||
break;
|
||||
}
|
||||
im->cs.space = cspace;
|
||||
}
|
||||
|
@ -660,9 +661,9 @@ eng_image_size_set(void *data, void *image, int w, int h)
|
|||
case EVAS_COLORSPACE_YCBCR422601_PL:
|
||||
case EVAS_COLORSPACE_YCBCR420NV12601_PL:
|
||||
case EVAS_COLORSPACE_YCBCR420TM12601_PL:
|
||||
w &= ~0x1;
|
||||
w &= ~0x1;
|
||||
default:
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
evas_gl_common_image_alloc_ensure(im_old);
|
||||
|
@ -726,41 +727,41 @@ eng_image_data_get(void *data, void *image, int to_write, DATA32 **image_data, i
|
|||
switch (im->cs.space)
|
||||
{
|
||||
case EVAS_COLORSPACE_ARGB8888:
|
||||
if (to_write)
|
||||
{
|
||||
if (im->references > 1)
|
||||
{
|
||||
Evas_GL_Image *im_new;
|
||||
if (to_write)
|
||||
{
|
||||
if (im->references > 1)
|
||||
{
|
||||
Evas_GL_Image *im_new;
|
||||
|
||||
im_new = evas_gl_common_image_new_from_copied_data
|
||||
im_new = evas_gl_common_image_new_from_copied_data
|
||||
(im->gc, im->im->cache_entry.w, im->im->cache_entry.h,
|
||||
im->im->image.data,
|
||||
eng_image_alpha_get(data, image),
|
||||
eng_image_colorspace_get(data, image));
|
||||
if (!im_new)
|
||||
{
|
||||
*image_data = NULL;
|
||||
if (err) *err = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
|
||||
return im;
|
||||
}
|
||||
evas_gl_common_image_free(im);
|
||||
im = im_new;
|
||||
}
|
||||
else
|
||||
evas_gl_common_image_dirty(im, 0, 0, 0, 0);
|
||||
}
|
||||
*image_data = im->im->image.data;
|
||||
break;
|
||||
im->im->image.data,
|
||||
eng_image_alpha_get(data, image),
|
||||
eng_image_colorspace_get(data, image));
|
||||
if (!im_new)
|
||||
{
|
||||
*image_data = NULL;
|
||||
if (err) *err = EVAS_LOAD_ERROR_RESOURCE_ALLOCATION_FAILED;
|
||||
return im;
|
||||
}
|
||||
evas_gl_common_image_free(im);
|
||||
im = im_new;
|
||||
}
|
||||
else
|
||||
evas_gl_common_image_dirty(im, 0, 0, 0, 0);
|
||||
}
|
||||
*image_data = im->im->image.data;
|
||||
break;
|
||||
case EVAS_COLORSPACE_YCBCR422P601_PL:
|
||||
case EVAS_COLORSPACE_YCBCR422P709_PL:
|
||||
case EVAS_COLORSPACE_YCBCR422601_PL:
|
||||
case EVAS_COLORSPACE_YCBCR420NV12601_PL:
|
||||
case EVAS_COLORSPACE_YCBCR420TM12601_PL:
|
||||
*image_data = im->cs.data;
|
||||
break;
|
||||
*image_data = im->cs.data;
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
break;
|
||||
abort();
|
||||
break;
|
||||
}
|
||||
if (err) *err = error;
|
||||
return im;
|
||||
|
@ -803,34 +804,34 @@ eng_image_data_put(void *data, void *image, DATA32 *image_data)
|
|||
switch (im->cs.space)
|
||||
{
|
||||
case EVAS_COLORSPACE_ARGB8888:
|
||||
if (image_data != im->im->image.data)
|
||||
{
|
||||
int w, h;
|
||||
if (image_data != im->im->image.data)
|
||||
{
|
||||
int w, h;
|
||||
|
||||
w = im->im->cache_entry.w;
|
||||
h = im->im->cache_entry.h;
|
||||
im2 = eng_image_new_from_data(data, w, h, image_data,
|
||||
eng_image_alpha_get(data, image),
|
||||
eng_image_colorspace_get(data, image));
|
||||
if (!im2) return im;
|
||||
evas_gl_common_image_free(im);
|
||||
im = im2;
|
||||
}
|
||||
break;
|
||||
w = im->im->cache_entry.w;
|
||||
h = im->im->cache_entry.h;
|
||||
im2 = eng_image_new_from_data(data, w, h, image_data,
|
||||
eng_image_alpha_get(data, image),
|
||||
eng_image_colorspace_get(data, image));
|
||||
if (!im2) return im;
|
||||
evas_gl_common_image_free(im);
|
||||
im = im2;
|
||||
}
|
||||
break;
|
||||
case EVAS_COLORSPACE_YCBCR422P601_PL:
|
||||
case EVAS_COLORSPACE_YCBCR422P709_PL:
|
||||
if (image_data != im->cs.data)
|
||||
{
|
||||
if (im->cs.data)
|
||||
{
|
||||
if (!im->cs.no_free) free(im->cs.data);
|
||||
}
|
||||
im->cs.data = image_data;
|
||||
}
|
||||
break;
|
||||
if (image_data != im->cs.data)
|
||||
{
|
||||
if (im->cs.data)
|
||||
{
|
||||
if (!im->cs.no_free) free(im->cs.data);
|
||||
}
|
||||
im->cs.data = image_data;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
abort();
|
||||
break;
|
||||
abort();
|
||||
break;
|
||||
}
|
||||
/* hmmm - but if we wrote... why bother? */
|
||||
evas_gl_common_image_dirty(im, 0, 0, 0, 0);
|
||||
|
@ -1030,31 +1031,31 @@ eng_font_draw(void *data, void *context, void *surface, Evas_Font_Set *font EINA
|
|||
|
||||
evas_gl_common_context_target_surface_set(re->win->gl_context, surface);
|
||||
re->win->gl_context->dc = context;
|
||||
{
|
||||
if (!re->win->gl_context->font_surface)
|
||||
re->win->gl_context->font_surface = (RGBA_Image *)evas_cache_image_empty(evas_common_image_cache_get());
|
||||
re->win->gl_context->font_surface->cache_entry.w = re->win->gl_context->shared->w;
|
||||
re->win->gl_context->font_surface->cache_entry.h = re->win->gl_context->shared->h;
|
||||
{
|
||||
if (!re->win->gl_context->font_surface)
|
||||
re->win->gl_context->font_surface = (RGBA_Image *)evas_cache_image_empty(evas_common_image_cache_get());
|
||||
re->win->gl_context->font_surface->cache_entry.w = re->win->gl_context->shared->w;
|
||||
re->win->gl_context->font_surface->cache_entry.h = re->win->gl_context->shared->h;
|
||||
|
||||
evas_common_draw_context_font_ext_set(context,
|
||||
re->win->gl_context,
|
||||
evas_gl_font_texture_new,
|
||||
evas_gl_font_texture_free,
|
||||
evas_gl_font_texture_draw,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
evas_common_font_draw_prepare(intl_props);
|
||||
evas_common_font_draw(re->win->gl_context->font_surface, context, x, y, intl_props->glyphs);
|
||||
evas_common_draw_context_font_ext_set(context,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
evas_common_draw_context_font_ext_set(context,
|
||||
re->win->gl_context,
|
||||
evas_gl_font_texture_new,
|
||||
evas_gl_font_texture_free,
|
||||
evas_gl_font_texture_draw,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
evas_common_font_draw_prepare(intl_props);
|
||||
evas_common_font_draw(re->win->gl_context->font_surface, context, x, y, intl_props->glyphs);
|
||||
evas_common_draw_context_font_ext_set(context,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
}
|
||||
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
@ -1138,7 +1139,7 @@ evgl_glShaderBinary(GLsizei n, const GLuint* shaders, GLenum binaryformat, const
|
|||
#ifdef GL_GLES
|
||||
glShaderBinary(n, shaders, binaryformat, binary, length);
|
||||
#else
|
||||
// FIXME: need to dlsym/getprocaddress for this
|
||||
// FIXME: need to dlsym/getprocaddress for this
|
||||
return;
|
||||
n = binaryformat = length = 0;
|
||||
shaders = binary = 0;
|
||||
|
@ -1172,7 +1173,7 @@ eng_gl_api_get(void *data, int version EINA_UNUSED)
|
|||
ORD(glCheckFramebufferStatus);
|
||||
ORD(glClear);
|
||||
ORD(glClearColor);
|
||||
// ORD(glClearDepthf);
|
||||
// ORD(glClearDepthf);
|
||||
ORD(glClearStencil);
|
||||
ORD(glColorMask);
|
||||
ORD(glCompileShader);
|
||||
|
@ -1191,7 +1192,7 @@ eng_gl_api_get(void *data, int version EINA_UNUSED)
|
|||
ORD(glDeleteTextures);
|
||||
ORD(glDepthFunc);
|
||||
ORD(glDepthMask);
|
||||
// ORD(glDepthRangef);
|
||||
// ORD(glDepthRangef);
|
||||
ORD(glDetachShader);
|
||||
ORD(glDisable);
|
||||
ORD(glDisableVertexAttribArray);
|
||||
|
@ -1224,7 +1225,7 @@ eng_gl_api_get(void *data, int version EINA_UNUSED)
|
|||
ORD(glGetRenderbufferParameteriv);
|
||||
ORD(glGetShaderiv);
|
||||
ORD(glGetShaderInfoLog);
|
||||
// ORD(glGetShaderPrecisionFormat);
|
||||
// ORD(glGetShaderPrecisionFormat);
|
||||
ORD(glGetShaderSource);
|
||||
ORD(glGetString);
|
||||
ORD(glGetTexParameterfv);
|
||||
|
@ -1248,11 +1249,11 @@ eng_gl_api_get(void *data, int version EINA_UNUSED)
|
|||
ORD(glPixelStorei);
|
||||
ORD(glPolygonOffset);
|
||||
ORD(glReadPixels);
|
||||
// ORD(glReleaseShaderCompiler);
|
||||
// ORD(glReleaseShaderCompiler);
|
||||
ORD(glRenderbufferStorage);
|
||||
ORD(glSampleCoverage);
|
||||
ORD(glScissor);
|
||||
// ORD(glShaderBinary);
|
||||
// ORD(glShaderBinary);
|
||||
ORD(glShaderSource);
|
||||
ORD(glStencilFunc);
|
||||
ORD(glStencilFuncSeparate);
|
||||
|
@ -1299,12 +1300,12 @@ eng_gl_api_get(void *data, int version EINA_UNUSED)
|
|||
ORD(glViewport);
|
||||
#undef ORD
|
||||
|
||||
// Override functions wrapped by Evas_GL
|
||||
// Override functions wrapped by Evas_GL
|
||||
#define ORD(f) EVAS_API_OVERRIDE(f, &gl_funcs, evgl_)
|
||||
ORD(glBindFramebuffer);
|
||||
ORD(glBindRenderbuffer);
|
||||
|
||||
// GLES2.0 API compat on top of desktop gl
|
||||
// GLES2.0 API compat on top of desktop gl
|
||||
ORD(glClearDepthf);
|
||||
ORD(glDepthRangef);
|
||||
ORD(glGetShaderPrecisionFormat);
|
||||
|
@ -1340,16 +1341,16 @@ 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.");
|
||||
return 0;
|
||||
EINA_LOG_ERR("Impossible to create a log domain for GL (Cocoa) engine.");
|
||||
return 0;
|
||||
}
|
||||
/* store it for later use */
|
||||
func = pfunc;
|
||||
/* now to override methods */
|
||||
#define ORD(f) EVAS_API_OVERRIDE(f, &func, eng_)
|
||||
#define ORD(f) EVAS_API_OVERRIDE(f, &func, eng_)
|
||||
ORD(info);
|
||||
ORD(info_free);
|
||||
ORD(setup);
|
||||
|
@ -1417,7 +1418,7 @@ module_open(Evas_Module *em)
|
|||
|
||||
ORD(image_load_error_get);
|
||||
|
||||
#define LINK2GENERIC(sym) \
|
||||
#define LINK2GENERIC(sym) \
|
||||
glsym_##sym = dlsym(RTLD_DEFAULT, #sym);
|
||||
|
||||
LINK2GENERIC(evas_gl_symbols);
|
||||
|
@ -1431,20 +1432,20 @@ module_open(Evas_Module *em)
|
|||
static void
|
||||
module_close(Evas_Module *em EINA_UNUSED)
|
||||
{
|
||||
eina_log_domain_unregister(_evas_engine_gl_cocoa_log_dom);
|
||||
evas_gl_common_module_close();
|
||||
eina_log_domain_unregister(_evas_engine_gl_cocoa_log_dom);
|
||||
evas_gl_common_module_close();
|
||||
}
|
||||
|
||||
static Evas_Module_Api evas_modapi =
|
||||
{
|
||||
EVAS_MODULE_API_VERSION,
|
||||
"gl_cocoa",
|
||||
"none",
|
||||
{
|
||||
module_open,
|
||||
module_close
|
||||
}
|
||||
};
|
||||
{
|
||||
EVAS_MODULE_API_VERSION,
|
||||
"gl_cocoa",
|
||||
"none",
|
||||
{
|
||||
module_open,
|
||||
module_close
|
||||
}
|
||||
};
|
||||
|
||||
EVAS_MODULE_DEFINE(EVAS_MODULE_TYPE_ENGINE, engine, gl_cocoa);
|
||||
|
||||
|
|
|
@ -26,13 +26,13 @@ static NSOpenGLContext *_evas_gl_cocoa_shared_context = NULL;
|
|||
+ (NSOpenGLPixelFormat*) basicPixelFormat
|
||||
{
|
||||
NSOpenGLPixelFormatAttribute attributes [] = {
|
||||
NSOpenGLPFAWindow,
|
||||
NSOpenGLPFAAccelerated,
|
||||
NSOpenGLPFADoubleBuffer,
|
||||
/*NSOpenGLPFAColorSize, 24,
|
||||
NSOpenGLPFAAlphaSize, 8,
|
||||
NSOpenGLPFADepthSize, 24,*/
|
||||
0
|
||||
NSOpenGLPFAWindow,
|
||||
NSOpenGLPFAAccelerated,
|
||||
NSOpenGLPFADoubleBuffer,
|
||||
/*NSOpenGLPFAColorSize, 24,
|
||||
NSOpenGLPFAAlphaSize, 8,
|
||||
NSOpenGLPFADepthSize, 24,*/
|
||||
0
|
||||
};
|
||||
return [[[NSOpenGLPixelFormat alloc] initWithAttributes:attributes] autorelease];
|
||||
}
|
||||
|
@ -47,10 +47,10 @@ static NSOpenGLContext *_evas_gl_cocoa_shared_context = NULL;
|
|||
|
||||
NSOpenGLContext *ctx;
|
||||
if (!_evas_gl_cocoa_shared_context) {
|
||||
_evas_gl_cocoa_shared_context = [[NSOpenGLContext alloc] initWithFormat: [EvasGLView basicPixelFormat] shareContext: nil];
|
||||
ctx = _evas_gl_cocoa_shared_context;
|
||||
_evas_gl_cocoa_shared_context = [[NSOpenGLContext alloc] initWithFormat: [EvasGLView basicPixelFormat] shareContext: nil];
|
||||
ctx = _evas_gl_cocoa_shared_context;
|
||||
} else {
|
||||
ctx = [[NSOpenGLContext alloc] initWithFormat: [EvasGLView basicPixelFormat] shareContext: _evas_gl_cocoa_shared_context];
|
||||
ctx = [[NSOpenGLContext alloc] initWithFormat: [EvasGLView basicPixelFormat] shareContext: _evas_gl_cocoa_shared_context];
|
||||
}
|
||||
[self setOpenGLContext: ctx];
|
||||
[ctx setView: self];
|
||||
|
@ -109,11 +109,11 @@ void
|
|||
eng_window_free(Evas_GL_Cocoa_Window *gw)
|
||||
{
|
||||
if (gw == _evas_gl_cocoa_window)
|
||||
_evas_gl_cocoa_window = NULL;
|
||||
_evas_gl_cocoa_window = NULL;
|
||||
|
||||
evas_gl_common_context_free(gw->gl_context);
|
||||
[(EvasGLView*)gw->view release];
|
||||
free(gw);
|
||||
free(gw);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -146,27 +146,26 @@ eng_window_vsync_set(int on EINA_UNUSED)
|
|||
void
|
||||
eng_window_resize(Evas_GL_Cocoa_Window *gw, int width, int height)
|
||||
{
|
||||
NSRect view_frame;
|
||||
NSRect view_frame;
|
||||
|
||||
INF("Resize %d %d\n", width, 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];
|
||||
view_frame = [(EvasGLView*)gw->view frame];
|
||||
view_frame.size.height = height;
|
||||
view_frame.size.width = width;
|
||||
|
||||
[(EvasGLView*)gw->view setFrame:view_frame];
|
||||
[[(NSOpenGLView*)gw->view openGLContext] flushBuffer];
|
||||
}
|
||||
|
||||
void
|
||||
eng_window_lock_focus(Evas_GL_Cocoa_Window *gw)
|
||||
{
|
||||
[(NSOpenGLView*)gw->view lockFocus];
|
||||
[(NSOpenGLView*)gw->view lockFocus];
|
||||
}
|
||||
|
||||
void
|
||||
eng_window_unlock_focus(Evas_GL_Cocoa_Window *gw)
|
||||
{
|
||||
[(NSOpenGLView*)gw->view unlockFocus];
|
||||
[(NSOpenGLView*)gw->view unlockFocus];
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue