aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Torri <vincent dot torri at gmail dot com>2015-10-19 20:43:36 +0200
committerNicolas Aguirre <aguirre.nicolas@gmail.com>2015-11-12 10:47:44 +0100
commite7843509b854918ebc665f00c510c28e23f210c1 (patch)
tree5c5acc7b7ba8670f192768bd8266650fa65df268
parentShutdown ecore_win32 subsystem (diff)
downloadelementary-devs/captainigloo/win32.tar.gz
Add cursor support on Windowsdevs/captainigloo/win32
@feature
-rw-r--r--src/lib/els_cursor.c214
1 files changed, 129 insertions, 85 deletions
diff --git a/src/lib/els_cursor.c b/src/lib/els_cursor.c
index 4e6a44327..db7cb05e9 100644
--- a/src/lib/els_cursor.c
+++ b/src/lib/els_cursor.c
@@ -12,104 +12,111 @@
#include <Ecore_X_Cursor.h>
#endif
+#ifdef HAVE_ELEMENTARY_WIN32
+#include <Ecore_Win32.h>
+#endif
+
#define _cursor_key "_elm_cursor"
struct _Cursor_Id
{
const char *name;
-#ifdef HAVE_ELEMENTARY_X
+#if defined HAVE_ELEMENTARY_X || defined HAVE_ELEMENTARY_WIN32
int id;
#endif
};
#ifdef HAVE_ELEMENTARY_X
-#define CURSOR(_name, _xid) \
- {_name , _xid}
-# else
-#define CURSOR(_name, _xid) \
+# define CURSOR(_name, _xid) \
+ {_name , ECORE_X_##_xid}
+#elif defined HAVE_ELEMENTARY_WIN32
+# define CURSOR(_name, _xid) \
+ {_name , ECORE_WIN32_CURSOR_X11_SHAPE_##_xid}
+#else
+# define CURSOR(_name, _xid) \
{_name}
#endif
/* Please keep order in sync with Ecore_X_Cursor.h values! */
struct _Cursor_Id _cursors[] =
{
- CURSOR(ELM_CURSOR_X , ECORE_X_CURSOR_X ),
- CURSOR(ELM_CURSOR_ARROW , ECORE_X_CURSOR_ARROW ),
- CURSOR(ELM_CURSOR_BASED_ARROW_DOWN , ECORE_X_CURSOR_BASED_ARROW_DOWN ),
- CURSOR(ELM_CURSOR_BASED_ARROW_UP , ECORE_X_CURSOR_UP ),
- CURSOR(ELM_CURSOR_BOAT , ECORE_X_CURSOR_BOAT ),
- CURSOR(ELM_CURSOR_BOGOSITY , ECORE_X_CURSOR_BOGOSITY ),
- CURSOR(ELM_CURSOR_BOTTOM_LEFT_CORNER , ECORE_X_CURSOR_BOTTOM_LEFT_CORNER ),
- CURSOR(ELM_CURSOR_BOTTOM_RIGHT_CORNER, ECORE_X_CURSOR_BOTTOM_RIGHT_CORNER),
- CURSOR(ELM_CURSOR_BOTTOM_SIDE , ECORE_X_CURSOR_BOTTOM_SIDE ),
- CURSOR(ELM_CURSOR_BOTTOM_TEE , ECORE_X_CURSOR_BOTTOM_TEE ),
- CURSOR(ELM_CURSOR_BOX_SPIRAL , ECORE_X_CURSOR_BOX_SPIRAL ),
- CURSOR(ELM_CURSOR_CENTER_PTR , ECORE_X_CURSOR_CENTER_PTR ),
- CURSOR(ELM_CURSOR_CIRCLE , ECORE_X_CURSOR_CIRCLE ),
- CURSOR(ELM_CURSOR_CLOCK , ECORE_X_CURSOR_CLOCK ),
- CURSOR(ELM_CURSOR_COFFEE_MUG , ECORE_X_CURSOR_COFFEE_MUG ),
- CURSOR(ELM_CURSOR_CROSS , ECORE_X_CURSOR_CROSS ),
- CURSOR(ELM_CURSOR_CROSS_REVERSE , ECORE_X_CURSOR_CROSS_REVERSE ),
- CURSOR(ELM_CURSOR_CROSSHAIR , ECORE_X_CURSOR_CROSSHAIR ),
- CURSOR(ELM_CURSOR_DIAMOND_CROSS , ECORE_X_CURSOR_DIAMOND_CROSS ),
- CURSOR(ELM_CURSOR_DOT , ECORE_X_CURSOR_DOT ),
- CURSOR(ELM_CURSOR_DOT_BOX_MASK , ECORE_X_CURSOR_DOT_BOX_MASK ),
- CURSOR(ELM_CURSOR_DOUBLE_ARROW , ECORE_X_CURSOR_DOUBLE_ARROW ),
- CURSOR(ELM_CURSOR_DRAFT_LARGE , ECORE_X_CURSOR_DRAFT_LARGE ),
- CURSOR(ELM_CURSOR_DRAFT_SMALL , ECORE_X_CURSOR_DRAFT_SMALL ),
- CURSOR(ELM_CURSOR_DRAPED_BOX , ECORE_X_CURSOR_DRAPED_BOX ),
- CURSOR(ELM_CURSOR_EXCHANGE , ECORE_X_CURSOR_EXCHANGE ),
- CURSOR(ELM_CURSOR_FLEUR , ECORE_X_CURSOR_FLEUR ),
- CURSOR(ELM_CURSOR_GOBBLER , ECORE_X_CURSOR_GOBBLER ),
- CURSOR(ELM_CURSOR_GUMBY , ECORE_X_CURSOR_GUMBY ),
- CURSOR(ELM_CURSOR_HAND1 , ECORE_X_CURSOR_HAND1 ),
- CURSOR(ELM_CURSOR_HAND2 , ECORE_X_CURSOR_HAND2 ),
- CURSOR(ELM_CURSOR_HEART , ECORE_X_CURSOR_HEART ),
- CURSOR(ELM_CURSOR_ICON , ECORE_X_CURSOR_ICON ),
- CURSOR(ELM_CURSOR_IRON_CROSS , ECORE_X_CURSOR_IRON_CROSS ),
- CURSOR(ELM_CURSOR_LEFT_PTR , ECORE_X_CURSOR_LEFT_PTR ),
- CURSOR(ELM_CURSOR_LEFT_SIDE , ECORE_X_CURSOR_LEFT_SIDE ),
- CURSOR(ELM_CURSOR_LEFT_TEE , ECORE_X_CURSOR_LEFT_TEE ),
- CURSOR(ELM_CURSOR_LEFTBUTTON , ECORE_X_CURSOR_LEFTBUTTON ),
- CURSOR(ELM_CURSOR_LL_ANGLE , ECORE_X_CURSOR_LL_ANGLE ),
- CURSOR(ELM_CURSOR_LR_ANGLE , ECORE_X_CURSOR_LR_ANGLE ),
- CURSOR(ELM_CURSOR_MAN , ECORE_X_CURSOR_MAN ),
- CURSOR(ELM_CURSOR_MIDDLEBUTTON , ECORE_X_CURSOR_MIDDLEBUTTON ),
- CURSOR(ELM_CURSOR_MOUSE , ECORE_X_CURSOR_MOUSE ),
- CURSOR(ELM_CURSOR_PENCIL , ECORE_X_CURSOR_PENCIL ),
- CURSOR(ELM_CURSOR_PIRATE , ECORE_X_CURSOR_PIRATE ),
- CURSOR(ELM_CURSOR_PLUS , ECORE_X_CURSOR_PLUS ),
- CURSOR(ELM_CURSOR_QUESTION_ARROW , ECORE_X_CURSOR_QUESTION_ARROW ),
- CURSOR(ELM_CURSOR_RIGHT_PTR , ECORE_X_CURSOR_RIGHT_PTR ),
- CURSOR(ELM_CURSOR_RIGHT_SIDE , ECORE_X_CURSOR_RIGHT_SIDE ),
- CURSOR(ELM_CURSOR_RIGHT_TEE , ECORE_X_CURSOR_RIGHT_TEE ),
- CURSOR(ELM_CURSOR_RIGHTBUTTON , ECORE_X_CURSOR_RIGHTBUTTON ),
- CURSOR(ELM_CURSOR_RTL_LOGO , ECORE_X_CURSOR_RTL_LOGO ),
- CURSOR(ELM_CURSOR_SAILBOAT , ECORE_X_CURSOR_SAILBOAT ),
- CURSOR(ELM_CURSOR_SB_DOWN_ARROW , ECORE_X_CURSOR_SB_DOWN_ARROW ),
- CURSOR(ELM_CURSOR_SB_H_DOUBLE_ARROW , ECORE_X_CURSOR_SB_H_DOUBLE_ARROW ),
- CURSOR(ELM_CURSOR_SB_LEFT_ARROW , ECORE_X_CURSOR_SB_LEFT_ARROW ),
- CURSOR(ELM_CURSOR_SB_RIGHT_ARROW , ECORE_X_CURSOR_SB_RIGHT_ARROW ),
- CURSOR(ELM_CURSOR_SB_UP_ARROW , ECORE_X_CURSOR_SB_UP_ARROW ),
- CURSOR(ELM_CURSOR_SB_V_DOUBLE_ARROW , ECORE_X_CURSOR_SB_V_DOUBLE_ARROW ),
- CURSOR(ELM_CURSOR_SHUTTLE , ECORE_X_CURSOR_SHUTTLE ),
- CURSOR(ELM_CURSOR_SIZING , ECORE_X_CURSOR_SIZING ),
- CURSOR(ELM_CURSOR_SPIDER , ECORE_X_CURSOR_SPIDER ),
- CURSOR(ELM_CURSOR_SPRAYCAN , ECORE_X_CURSOR_SPRAYCAN ),
- CURSOR(ELM_CURSOR_STAR , ECORE_X_CURSOR_STAR ),
- CURSOR(ELM_CURSOR_TARGET , ECORE_X_CURSOR_TARGET ),
- CURSOR(ELM_CURSOR_TCROSS , ECORE_X_CURSOR_TCROSS ),
- CURSOR(ELM_CURSOR_TOP_LEFT_ARROW , ECORE_X_CURSOR_TOP_LEFT_ARROW ),
- CURSOR(ELM_CURSOR_TOP_LEFT_CORNER , ECORE_X_CURSOR_TOP_LEFT_CORNER ),
- CURSOR(ELM_CURSOR_TOP_RIGHT_CORNER , ECORE_X_CURSOR_TOP_RIGHT_CORNER ),
- CURSOR(ELM_CURSOR_TOP_SIDE , ECORE_X_CURSOR_TOP_SIDE ),
- CURSOR(ELM_CURSOR_TOP_TEE , ECORE_X_CURSOR_TOP_TEE ),
- CURSOR(ELM_CURSOR_TREK , ECORE_X_CURSOR_TREK ),
- CURSOR(ELM_CURSOR_UL_ANGLE , ECORE_X_CURSOR_UL_ANGLE ),
- CURSOR(ELM_CURSOR_UMBRELLA , ECORE_X_CURSOR_UMBRELLA ),
- CURSOR(ELM_CURSOR_UR_ANGLE , ECORE_X_CURSOR_UR_ANGLE ),
- CURSOR(ELM_CURSOR_WATCH , ECORE_X_CURSOR_WATCH ),
- CURSOR(ELM_CURSOR_XTERM , ECORE_X_CURSOR_XTERM )
+ CURSOR(ELM_CURSOR_X , X ),
+ CURSOR(ELM_CURSOR_ARROW , ARROW ),
+ CURSOR(ELM_CURSOR_BASED_ARROW_DOWN , BASED_ARROW_DOWN ),
+ CURSOR(ELM_CURSOR_BASED_ARROW_UP , UP ),
+ CURSOR(ELM_CURSOR_BOAT , BOAT ),
+ CURSOR(ELM_CURSOR_BOGOSITY , BOGOSITY ),
+ CURSOR(ELM_CURSOR_BOTTOM_LEFT_CORNER , BOTTOM_LEFT_CORNER ),
+ CURSOR(ELM_CURSOR_BOTTOM_RIGHT_CORNER, BOTTOM_RIGHT_CORNER),
+ CURSOR(ELM_CURSOR_BOTTOM_SIDE , BOTTOM_SIDE ),
+ CURSOR(ELM_CURSOR_BOTTOM_TEE , BOTTOM_TEE ),
+ CURSOR(ELM_CURSOR_BOX_SPIRAL , BOX_SPIRAL ),
+ CURSOR(ELM_CURSOR_CENTER_PTR , CENTER_PTR ),
+ CURSOR(ELM_CURSOR_CIRCLE , CIRCLE ),
+ CURSOR(ELM_CURSOR_CLOCK , CLOCK ),
+ CURSOR(ELM_CURSOR_COFFEE_MUG , COFFEE_MUG ),
+ CURSOR(ELM_CURSOR_CROSS , CROSS ),
+ CURSOR(ELM_CURSOR_CROSS_REVERSE , CROSS_REVERSE ),
+ CURSOR(ELM_CURSOR_CROSSHAIR , CROSSHAIR ),
+ CURSOR(ELM_CURSOR_DIAMOND_CROSS , DIAMOND_CROSS ),
+ CURSOR(ELM_CURSOR_DOT , DOT ),
+ CURSOR(ELM_CURSOR_DOT_BOX_MASK , DOT_BOX_MASK ),
+ CURSOR(ELM_CURSOR_DOUBLE_ARROW , DOUBLE_ARROW ),
+ CURSOR(ELM_CURSOR_DRAFT_LARGE , DRAFT_LARGE ),
+ CURSOR(ELM_CURSOR_DRAFT_SMALL , DRAFT_SMALL ),
+ CURSOR(ELM_CURSOR_DRAPED_BOX , DRAPED_BOX ),
+ CURSOR(ELM_CURSOR_EXCHANGE , EXCHANGE ),
+ CURSOR(ELM_CURSOR_FLEUR , FLEUR ),
+ CURSOR(ELM_CURSOR_GOBBLER , GOBBLER ),
+ CURSOR(ELM_CURSOR_GUMBY , GUMBY ),
+ CURSOR(ELM_CURSOR_HAND1 , HAND1 ),
+ CURSOR(ELM_CURSOR_HAND2 , HAND2 ),
+ CURSOR(ELM_CURSOR_HEART , HEART ),
+ CURSOR(ELM_CURSOR_ICON , ICON ),
+ CURSOR(ELM_CURSOR_IRON_CROSS , IRON_CROSS ),
+ CURSOR(ELM_CURSOR_LEFT_PTR , LEFT_PTR ),
+ CURSOR(ELM_CURSOR_LEFT_SIDE , LEFT_SIDE ),
+ CURSOR(ELM_CURSOR_LEFT_TEE , LEFT_TEE ),
+ CURSOR(ELM_CURSOR_LEFTBUTTON , LEFTBUTTON ),
+ CURSOR(ELM_CURSOR_LL_ANGLE , LL_ANGLE ),
+ CURSOR(ELM_CURSOR_LR_ANGLE , LR_ANGLE ),
+ CURSOR(ELM_CURSOR_MAN , MAN ),
+ CURSOR(ELM_CURSOR_MIDDLEBUTTON , MIDDLEBUTTON ),
+ CURSOR(ELM_CURSOR_MOUSE , MOUSE ),
+ CURSOR(ELM_CURSOR_PENCIL , PENCIL ),
+ CURSOR(ELM_CURSOR_PIRATE , PIRATE ),
+ CURSOR(ELM_CURSOR_PLUS , PLUS ),
+ CURSOR(ELM_CURSOR_QUESTION_ARROW , QUESTION_ARROW ),
+ CURSOR(ELM_CURSOR_RIGHT_PTR , RIGHT_PTR ),
+ CURSOR(ELM_CURSOR_RIGHT_SIDE , RIGHT_SIDE ),
+ CURSOR(ELM_CURSOR_RIGHT_TEE , RIGHT_TEE ),
+ CURSOR(ELM_CURSOR_RIGHTBUTTON , RIGHTBUTTON ),
+ CURSOR(ELM_CURSOR_RTL_LOGO , RTL_LOGO ),
+ CURSOR(ELM_CURSOR_SAILBOAT , SAILBOAT ),
+ CURSOR(ELM_CURSOR_SB_DOWN_ARROW , SB_DOWN_ARROW ),
+ CURSOR(ELM_CURSOR_SB_H_DOUBLE_ARROW , SB_H_DOUBLE_ARROW ),
+ CURSOR(ELM_CURSOR_SB_LEFT_ARROW , SB_LEFT_ARROW ),
+ CURSOR(ELM_CURSOR_SB_RIGHT_ARROW , SB_RIGHT_ARROW ),
+ CURSOR(ELM_CURSOR_SB_UP_ARROW , SB_UP_ARROW ),
+ CURSOR(ELM_CURSOR_SB_V_DOUBLE_ARROW , SB_V_DOUBLE_ARROW ),
+ CURSOR(ELM_CURSOR_SHUTTLE , SHUTTLE ),
+ CURSOR(ELM_CURSOR_SIZING , SIZING ),
+ CURSOR(ELM_CURSOR_SPIDER , SPIDER ),
+ CURSOR(ELM_CURSOR_SPRAYCAN , SPRAYCAN ),
+ CURSOR(ELM_CURSOR_STAR , STAR ),
+ CURSOR(ELM_CURSOR_TARGET , TARGET ),
+ CURSOR(ELM_CURSOR_TCROSS , TCROSS ),
+ CURSOR(ELM_CURSOR_TOP_LEFT_ARROW , TOP_LEFT_ARROW ),
+ CURSOR(ELM_CURSOR_TOP_LEFT_CORNER , TOP_LEFT_CORNER ),
+ CURSOR(ELM_CURSOR_TOP_RIGHT_CORNER , TOP_RIGHT_CORNER ),
+ CURSOR(ELM_CURSOR_TOP_SIDE , TOP_SIDE ),
+ CURSOR(ELM_CURSOR_TOP_TEE , TOP_TEE ),
+ CURSOR(ELM_CURSOR_TREK , TREK ),
+ CURSOR(ELM_CURSOR_UL_ANGLE , UL_ANGLE ),
+ CURSOR(ELM_CURSOR_UMBRELLA , UMBRELLA ),
+ CURSOR(ELM_CURSOR_UR_ANGLE , UR_ANGLE ),
+ CURSOR(ELM_CURSOR_WATCH , WATCH ),
+ CURSOR(ELM_CURSOR_XTERM , XTERM )
};
static const int _cursors_count = sizeof(_cursors)/sizeof(struct _Cursor_Id);
@@ -151,6 +158,12 @@ struct _Elm_Cursor
Ecore_Wl_Window *win;
} wl;
#endif
+#ifdef HAVE_ELEMENTARY_WIN32
+ struct {
+ Ecore_Win32_Cursor *cursor;
+ Ecore_Win32_Window *win;
+ } win32;
+#endif
Eina_Bool visible:1;
Eina_Bool use_engine:1;
@@ -286,6 +299,10 @@ _elm_cursor_set(Elm_Cursor *cur)
if (cur->wl.win)
ecore_wl_window_cursor_from_name_set(cur->wl.win, cur->cursor_name);
#endif
+#ifdef HAVE_ELEMENTARY_WIN32
+ if (cur->win32.win)
+ ecore_win32_window_cursor_set(cur->win32.win, cur->win32.cursor);
+#endif
}
evas_event_thaw(cur->evas);
}
@@ -344,6 +361,10 @@ _elm_cursor_mouse_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_
if (cur->wl.win)
ecore_wl_window_cursor_default_restore(cur->wl.win);
#endif
+#ifdef HAVE_ELEMENTARY_WIN32
+ if (cur->win32.win)
+ ecore_win32_window_cursor_set(cur->win32.win, ecore_win32_cursor_shaped_new(ECORE_WIN32_CURSOR_SHAPE_ARROW));
+#endif
}
evas_event_thaw(cur->evas);
}
@@ -354,7 +375,7 @@ _elm_cursor_del(void *data EINA_UNUSED, Evas *evas EINA_UNUSED, Evas_Object *obj
elm_object_cursor_unset(obj);
}
-#ifdef HAVE_ELEMENTARY_X
+#if defined HAVE_ELEMENTARY_X || defined HAVE_ELEMENTARY_WIN32
static int
_elm_cursor_strcmp(const void *data1, const void *data2)
{
@@ -404,10 +425,10 @@ _elm_cursor_cur_set(Elm_Cursor *cur)
if (cur->x.win)
{
struct _Cursor_Id *cur_id;
-
+
cur_id = bsearch(&(cur->cursor_name), _cursors, _cursors_count,
sizeof(struct _Cursor_Id), _elm_cursor_strcmp);
-
+
if (!cur_id)
{
INF("X cursor couldn't be found: %s. Using default.",
@@ -421,6 +442,25 @@ _elm_cursor_cur_set(Elm_Cursor *cur)
#ifdef HAVE_ELEMENTARY_WAYLAND
cur->wl.win = elm_win_wl_window_get(top);
#endif
+#ifdef HAVE_ELEMENTARY_WIN32
+ cur->win32.win = elm_win_win32_window_get(top);
+ if (cur->win32.win)
+ {
+ struct _Cursor_Id *cur_id;
+
+ cur_id = bsearch(&(cur->cursor_name), _cursors, _cursors_count,
+ sizeof(struct _Cursor_Id), _elm_cursor_strcmp);
+
+ if (!cur_id)
+ {
+ INF("Win32 X cursor couldn't be found: %s. Using default.",
+ cur->cursor_name);
+ cur->win32.cursor = ecore_win32_cursor_shaped_new(ECORE_WIN32_CURSOR_SHAPE_ARROW);
+ }
+ else
+ cur->win32.cursor = ecore_win32_cursor_x11_shaped_get(cur_id->id);
+ }
+#endif
}
}
@@ -545,6 +585,10 @@ elm_object_cursor_unset(Evas_Object *obj)
else if (cur->wl.win)
ecore_wl_window_cursor_default_restore(cur->wl.win);
#endif
+#ifdef HAVE_ELEMENTARY_WIN32
+ else
+ ecore_win32_window_cursor_set(cur->win32.win, ecore_win32_cursor_shaped_new(ECORE_WIN32_CURSOR_SHAPE_ARROW));
+#endif
}
evas_object_event_callback_del_full(obj, EVAS_CALLBACK_MOUSE_IN,