summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorJean Guyomarc'h <jean.guyomarch@openwide.fr>2015-10-08 11:58:46 +0200
committerCedric BAIL <cedric@osg.samsung.com>2015-12-01 12:15:31 -0800
commit2c93c73cbd1966e8cead7e7856044a2eb12138d7 (patch)
tree51897e9c1001d71e92f3ad3bdf086e114be1038f /src/lib
parentba4fbb99bc99734b81925793f47cc2601be5bd5b (diff)
ecore_cocoa: add support for system cursors
- Ecore_Cocoa_Cursor enum which references system cursors; - API to show/hide cursor: ecore_cocoa_window_cursor_show(); - API to set system cursor: ecore_cocoa_window_cursor_set(); - Ecore_Evas interface to get Ecore_Cocoa_Window from Ecore_Evas. @feature Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/ecore_cocoa/Ecore_Cocoa.h5
-rw-r--r--src/lib/ecore_cocoa/Ecore_Cocoa_Cursor.h32
-rw-r--r--src/lib/ecore_cocoa/ecore_cocoa.m3
-rw-r--r--src/lib/ecore_cocoa/ecore_cocoa_private.h4
-rw-r--r--src/lib/ecore_cocoa/ecore_cocoa_window.m53
-rw-r--r--src/lib/ecore_evas/Ecore_Evas.h2
-rw-r--r--src/lib/ecore_evas/ecore_evas.c10
-rw-r--r--src/lib/ecore_evas/ecore_evas_cocoa.h14
8 files changed, 123 insertions, 0 deletions
diff --git a/src/lib/ecore_cocoa/Ecore_Cocoa.h b/src/lib/ecore_cocoa/Ecore_Cocoa.h
index 78d15ced48..4341389ce2 100644
--- a/src/lib/ecore_cocoa/Ecore_Cocoa.h
+++ b/src/lib/ecore_cocoa/Ecore_Cocoa.h
@@ -26,6 +26,7 @@
26#endif 26#endif
27 27
28#include <Eina.h> 28#include <Eina.h>
29#include "Ecore_Cocoa_Cursor.h"
29 30
30#ifdef __cplusplus 31#ifdef __cplusplus
31extern "C" { 32extern "C" {
@@ -165,6 +166,10 @@ EAPI int ecore_cocoa_titlebar_height_get(void);
165 166
166EAPI Ecore_Cocoa_Window_Id ecore_cocoa_window_get_window_id(Ecore_Cocoa_Window *window); 167EAPI Ecore_Cocoa_Window_Id ecore_cocoa_window_get_window_id(Ecore_Cocoa_Window *window);
167 168
169
170EAPI void ecore_cocoa_window_cursor_set(Ecore_Cocoa_Window *win, Ecore_Cocoa_Cursor c);
171EAPI void ecore_cocoa_window_cursor_show(Ecore_Cocoa_Window *win, Eina_Bool show);
172
168#ifdef __cplusplus 173#ifdef __cplusplus
169} 174}
170#endif 175#endif
diff --git a/src/lib/ecore_cocoa/Ecore_Cocoa_Cursor.h b/src/lib/ecore_cocoa/Ecore_Cocoa_Cursor.h
new file mode 100644
index 0000000000..6bca47f6aa
--- /dev/null
+++ b/src/lib/ecore_cocoa/Ecore_Cocoa_Cursor.h
@@ -0,0 +1,32 @@
1#ifndef __ECORE_COCOA_CURSOR_H__
2#define __ECORE_COCOA_CURSOR_H__
3
4typedef enum
5{
6 ECORE_COCOA_CURSOR_ARROW = 0,
7 ECORE_COCOA_CURSOR_CONTEXTUAL_MENU,
8 ECORE_COCOA_CURSOR_CLOSED_HAND,
9 ECORE_COCOA_CURSOR_CROSSHAIR,
10 ECORE_COCOA_CURSOR_DISAPPEARING_ITEM,
11 ECORE_COCOA_CURSOR_DRAG_COPY,
12 ECORE_COCOA_CURSOR_DRAG_LINK,
13 ECORE_COCOA_CURSOR_IBEAM,
14 ECORE_COCOA_CURSOR_OPEN_HAND,
15 ECORE_COCOA_CURSOR_OPERATION_NOT_ALLOWED,
16 ECORE_COCOA_CURSOR_POINTING_HAND,
17 ECORE_COCOA_CURSOR_RESIZE_DOWN,
18 ECORE_COCOA_CURSOR_RESIZE_LEFT,
19 ECORE_COCOA_CURSOR_RESIZE_LEFT_RIGHT,
20 ECORE_COCOA_CURSOR_RESIZE_RIGHT,
21 ECORE_COCOA_CURSOR_RESIZE_UP,
22 ECORE_COCOA_CURSOR_RESIZE_UP_DOWN,
23 ECORE_COCOA_CURSOR_IBEAM_VERTICAL,
24
25 __ECORE_COCOA_CURSOR_LAST, /* Sentinel */
26
27 ECORE_COCOA_CURSOR_DEFAULT = ECORE_COCOA_CURSOR_ARROW
28
29} Ecore_Cocoa_Cursor;
30
31#endif /* ! __ECORE_COCOA_CURSOR_H__ */
32
diff --git a/src/lib/ecore_cocoa/ecore_cocoa.m b/src/lib/ecore_cocoa/ecore_cocoa.m
index d4e85804b2..1227f2a2a9 100644
--- a/src/lib/ecore_cocoa/ecore_cocoa.m
+++ b/src/lib/ecore_cocoa/ecore_cocoa.m
@@ -61,6 +61,9 @@ ecore_cocoa_init(void)
61 /* Start events monitoring */ 61 /* Start events monitoring */
62 [NSApp run]; 62 [NSApp run];
63 63
64 if (!_ecore_cocoa_window_init())
65 return --_ecore_cocoa_init_count;
66
64 return _ecore_cocoa_init_count; 67 return _ecore_cocoa_init_count;
65} 68}
66 69
diff --git a/src/lib/ecore_cocoa/ecore_cocoa_private.h b/src/lib/ecore_cocoa/ecore_cocoa_private.h
index ffe48ab074..9952278cea 100644
--- a/src/lib/ecore_cocoa/ecore_cocoa_private.h
+++ b/src/lib/ecore_cocoa/ecore_cocoa_private.h
@@ -62,4 +62,8 @@ struct _Ecore_Cocoa_Window
62}; 62};
63 63
64 64
65/* Internal init */
66Eina_Bool _ecore_cocoa_window_init(void);
67
68
65#endif 69#endif
diff --git a/src/lib/ecore_cocoa/ecore_cocoa_window.m b/src/lib/ecore_cocoa/ecore_cocoa_window.m
index 53137a0a84..de905c53ee 100644
--- a/src/lib/ecore_cocoa/ecore_cocoa_window.m
+++ b/src/lib/ecore_cocoa/ecore_cocoa_window.m
@@ -6,9 +6,13 @@
6 6
7#include <Ecore.h> 7#include <Ecore.h>
8#include <Ecore_Cocoa.h> 8#include <Ecore_Cocoa.h>
9#include <Ecore_Cocoa_Cursor.h>
9#import "ecore_cocoa_window.h" 10#import "ecore_cocoa_window.h"
10#include "ecore_cocoa_private.h" 11#include "ecore_cocoa_private.h"
11 12
13static NSCursor *_cursors[__ECORE_COCOA_CURSOR_LAST];
14
15
12@implementation EcoreCocoaWindow 16@implementation EcoreCocoaWindow
13 17
14@synthesize ecore_window_data; 18@synthesize ecore_window_data;
@@ -501,3 +505,52 @@ Ecore_Cocoa_Window_Id ecore_cocoa_window_get_window_id(Ecore_Cocoa_Window *windo
501 505
502 return window->window; 506 return window->window;
503} 507}
508
509EAPI void
510ecore_cocoa_window_cursor_set(Ecore_Cocoa_Window *win,
511 Ecore_Cocoa_Cursor c)
512{
513 EINA_SAFETY_ON_NULL_RETURN(win);
514 EINA_SAFETY_ON_FALSE_RETURN((c >= 0) && (c <= __ECORE_COCOA_CURSOR_LAST));
515
516 NSCursor *cursor = _cursors[c];
517
518 DBG("Setting cursor %i (%s)", c, [[cursor description] UTF8String]);
519 [cursor set];
520}
521
522EAPI void
523ecore_cocoa_window_cursor_show(Ecore_Cocoa_Window *win,
524 Eina_Bool show)
525{
526 EINA_SAFETY_ON_NULL_RETURN(win);
527
528 if (show) [NSCursor unhide];
529 else [NSCursor hide];
530}
531
532Eina_Bool
533_ecore_cocoa_window_init(void)
534{
535 _cursors[ECORE_COCOA_CURSOR_ARROW] = [NSCursor arrowCursor];
536 _cursors[ECORE_COCOA_CURSOR_CONTEXTUAL_MENU] = [NSCursor contextualMenuCursor];
537 _cursors[ECORE_COCOA_CURSOR_CLOSED_HAND] = [NSCursor closedHandCursor];
538 _cursors[ECORE_COCOA_CURSOR_CROSSHAIR] = [NSCursor crosshairCursor];
539 _cursors[ECORE_COCOA_CURSOR_DISAPPEARING_ITEM] = [NSCursor disappearingItemCursor];
540 _cursors[ECORE_COCOA_CURSOR_DRAG_COPY] = [NSCursor dragCopyCursor];
541 _cursors[ECORE_COCOA_CURSOR_DRAG_LINK] = [NSCursor dragLinkCursor];
542 _cursors[ECORE_COCOA_CURSOR_IBEAM] = [NSCursor IBeamCursor];
543 _cursors[ECORE_COCOA_CURSOR_OPEN_HAND] = [NSCursor openHandCursor];
544 _cursors[ECORE_COCOA_CURSOR_OPERATION_NOT_ALLOWED] = [NSCursor operationNotAllowedCursor];
545 _cursors[ECORE_COCOA_CURSOR_POINTING_HAND] = [NSCursor pointingHandCursor];
546 _cursors[ECORE_COCOA_CURSOR_RESIZE_DOWN] = [NSCursor resizeDownCursor];
547 _cursors[ECORE_COCOA_CURSOR_RESIZE_LEFT] = [NSCursor resizeLeftCursor];
548 _cursors[ECORE_COCOA_CURSOR_RESIZE_LEFT_RIGHT] = [NSCursor resizeLeftRightCursor];
549 _cursors[ECORE_COCOA_CURSOR_RESIZE_RIGHT] = [NSCursor resizeRightCursor];
550 _cursors[ECORE_COCOA_CURSOR_RESIZE_UP] = [NSCursor resizeUpCursor];
551 _cursors[ECORE_COCOA_CURSOR_RESIZE_UP_DOWN] = [NSCursor resizeUpDownCursor];
552 _cursors[ECORE_COCOA_CURSOR_IBEAM_VERTICAL] = [NSCursor IBeamCursorForVerticalLayout];
553
554 return EINA_TRUE;
555}
556
diff --git a/src/lib/ecore_evas/Ecore_Evas.h b/src/lib/ecore_evas/Ecore_Evas.h
index 1a035ab1fa..1aef27be7d 100644
--- a/src/lib/ecore_evas/Ecore_Evas.h
+++ b/src/lib/ecore_evas/Ecore_Evas.h
@@ -1317,6 +1317,8 @@ EAPI void ecore_evas_wayland_pointer_set(Ecore_Evas *ee, int hot_x, i
1317EAPI void ecore_evas_wayland_type_set(Ecore_Evas *ee, int type); 1317EAPI void ecore_evas_wayland_type_set(Ecore_Evas *ee, int type);
1318EAPI Ecore_Wl_Window *ecore_evas_wayland_window_get(const Ecore_Evas *ee); 1318EAPI Ecore_Wl_Window *ecore_evas_wayland_window_get(const Ecore_Evas *ee);
1319 1319
1320EAPI Ecore_Cocoa_Window *ecore_evas_cocoa_window_get(const Ecore_Evas *ee);
1321
1320EAPI Ecore_Evas *ecore_evas_drm_new(const char *device, unsigned int parent, int x, int y, int w, int h); 1322EAPI Ecore_Evas *ecore_evas_drm_new(const char *device, unsigned int parent, int x, int y, int w, int h);
1321EAPI Ecore_Evas *ecore_evas_gl_drm_new(const char *device, unsigned int parent, int x, int y, int w, int h); /** @since 1.12 */ 1323EAPI Ecore_Evas *ecore_evas_gl_drm_new(const char *device, unsigned int parent, int x, int y, int w, int h); /** @since 1.12 */
1322 1324
diff --git a/src/lib/ecore_evas/ecore_evas.c b/src/lib/ecore_evas/ecore_evas.c
index d702cccbad..f0a784ac7b 100644
--- a/src/lib/ecore_evas/ecore_evas.c
+++ b/src/lib/ecore_evas/ecore_evas.c
@@ -30,6 +30,7 @@
30#include "ecore_evas_private.h" 30#include "ecore_evas_private.h"
31#include "ecore_evas_x11.h" 31#include "ecore_evas_x11.h"
32#include "ecore_evas_wayland.h" 32#include "ecore_evas_wayland.h"
33#include "ecore_evas_cocoa.h"
33#include "ecore_evas_extn.h" 34#include "ecore_evas_extn.h"
34#include "ecore_evas_win32.h" 35#include "ecore_evas_win32.h"
35 36
@@ -3983,6 +3984,15 @@ ecore_evas_wayland_window_get(const Ecore_Evas *ee)
3983 return iface->window_get(ee); 3984 return iface->window_get(ee);
3984} 3985}
3985 3986
3987EAPI Ecore_Cocoa_Window *
3988ecore_evas_cocoa_window_get(const Ecore_Evas *ee)
3989{
3990 Ecore_Evas_Interface_Cocoa *iface;
3991 iface = (Ecore_Evas_Interface_Cocoa *)_ecore_evas_interface_get(ee, "opengl_cocoa");
3992 EINA_SAFETY_ON_NULL_RETURN_VAL(iface, NULL);
3993 return iface->window_get(ee);
3994}
3995
3986EAPI Ecore_Evas * 3996EAPI Ecore_Evas *
3987ecore_evas_drm_new(const char *disp_name, unsigned int parent, 3997ecore_evas_drm_new(const char *disp_name, unsigned int parent,
3988 int x, int y, int w, int h) 3998 int x, int y, int w, int h)
diff --git a/src/lib/ecore_evas/ecore_evas_cocoa.h b/src/lib/ecore_evas/ecore_evas_cocoa.h
new file mode 100644
index 0000000000..edc8e051f3
--- /dev/null
+++ b/src/lib/ecore_evas/ecore_evas_cocoa.h
@@ -0,0 +1,14 @@
1#ifndef __ECORE_EVAS_COCOA_H__
2#define __ECORE_EVAS_COCOA_H__
3
4typedef struct _Ecore_Evas_Interface_Cocoa Ecore_Evas_Interface_Cocoa;
5
6struct _Ecore_Evas_Interface_Cocoa
7{
8 Ecore_Evas_Interface base;
9
10 Ecore_Cocoa_Window *(*window_get)(const Ecore_Evas *ee);
11};
12
13#endif /* ! __ECORE_EVAS_COCOA_H__ */
14