summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 @@
12#include <Ecore_X_Cursor.h> 12#include <Ecore_X_Cursor.h>
13#endif 13#endif
14 14
15#ifdef HAVE_ELEMENTARY_WIN32
16#include <Ecore_Win32.h>
17#endif
18
15#define _cursor_key "_elm_cursor" 19#define _cursor_key "_elm_cursor"
16 20
17struct _Cursor_Id 21struct _Cursor_Id
18{ 22{
19 const char *name; 23 const char *name;
20#ifdef HAVE_ELEMENTARY_X 24#if defined HAVE_ELEMENTARY_X || defined HAVE_ELEMENTARY_WIN32
21 int id; 25 int id;
22#endif 26#endif
23}; 27};
24 28
25#ifdef HAVE_ELEMENTARY_X 29#ifdef HAVE_ELEMENTARY_X
26#define CURSOR(_name, _xid) \ 30# define CURSOR(_name, _xid) \
27 {_name , _xid} 31 {_name , ECORE_X_##_xid}
28# else 32#elif defined HAVE_ELEMENTARY_WIN32
29#define CURSOR(_name, _xid) \ 33# define CURSOR(_name, _xid) \
34 {_name , ECORE_WIN32_CURSOR_X11_SHAPE_##_xid}
35#else
36# define CURSOR(_name, _xid) \
30 {_name} 37 {_name}
31#endif 38#endif
32 39
33/* Please keep order in sync with Ecore_X_Cursor.h values! */ 40/* Please keep order in sync with Ecore_X_Cursor.h values! */
34struct _Cursor_Id _cursors[] = 41struct _Cursor_Id _cursors[] =
35{ 42{
36 CURSOR(ELM_CURSOR_X , ECORE_X_CURSOR_X ), 43 CURSOR(ELM_CURSOR_X , X ),
37 CURSOR(ELM_CURSOR_ARROW , ECORE_X_CURSOR_ARROW ), 44 CURSOR(ELM_CURSOR_ARROW , ARROW ),
38 CURSOR(ELM_CURSOR_BASED_ARROW_DOWN , ECORE_X_CURSOR_BASED_ARROW_DOWN ), 45 CURSOR(ELM_CURSOR_BASED_ARROW_DOWN , BASED_ARROW_DOWN ),
39 CURSOR(ELM_CURSOR_BASED_ARROW_UP , ECORE_X_CURSOR_UP ), 46 CURSOR(ELM_CURSOR_BASED_ARROW_UP , UP ),
40 CURSOR(ELM_CURSOR_BOAT , ECORE_X_CURSOR_BOAT ), 47 CURSOR(ELM_CURSOR_BOAT , BOAT ),
41 CURSOR(ELM_CURSOR_BOGOSITY , ECORE_X_CURSOR_BOGOSITY ), 48 CURSOR(ELM_CURSOR_BOGOSITY , BOGOSITY ),
42 CURSOR(ELM_CURSOR_BOTTOM_LEFT_CORNER , ECORE_X_CURSOR_BOTTOM_LEFT_CORNER ), 49 CURSOR(ELM_CURSOR_BOTTOM_LEFT_CORNER , BOTTOM_LEFT_CORNER ),
43 CURSOR(ELM_CURSOR_BOTTOM_RIGHT_CORNER, ECORE_X_CURSOR_BOTTOM_RIGHT_CORNER), 50 CURSOR(ELM_CURSOR_BOTTOM_RIGHT_CORNER, BOTTOM_RIGHT_CORNER),
44 CURSOR(ELM_CURSOR_BOTTOM_SIDE , ECORE_X_CURSOR_BOTTOM_SIDE ), 51 CURSOR(ELM_CURSOR_BOTTOM_SIDE , BOTTOM_SIDE ),
45 CURSOR(ELM_CURSOR_BOTTOM_TEE , ECORE_X_CURSOR_BOTTOM_TEE ), 52 CURSOR(ELM_CURSOR_BOTTOM_TEE , BOTTOM_TEE ),
46 CURSOR(ELM_CURSOR_BOX_SPIRAL , ECORE_X_CURSOR_BOX_SPIRAL ), 53 CURSOR(ELM_CURSOR_BOX_SPIRAL , BOX_SPIRAL ),
47 CURSOR(ELM_CURSOR_CENTER_PTR , ECORE_X_CURSOR_CENTER_PTR ), 54 CURSOR(ELM_CURSOR_CENTER_PTR , CENTER_PTR ),
48 CURSOR(ELM_CURSOR_CIRCLE , ECORE_X_CURSOR_CIRCLE ), 55 CURSOR(ELM_CURSOR_CIRCLE , CIRCLE ),
49 CURSOR(ELM_CURSOR_CLOCK , ECORE_X_CURSOR_CLOCK ), 56 CURSOR(ELM_CURSOR_CLOCK , CLOCK ),
50 CURSOR(ELM_CURSOR_COFFEE_MUG , ECORE_X_CURSOR_COFFEE_MUG ), 57 CURSOR(ELM_CURSOR_COFFEE_MUG , COFFEE_MUG ),
51 CURSOR(ELM_CURSOR_CROSS , ECORE_X_CURSOR_CROSS ), 58 CURSOR(ELM_CURSOR_CROSS , CROSS ),
52 CURSOR(ELM_CURSOR_CROSS_REVERSE , ECORE_X_CURSOR_CROSS_REVERSE ), 59 CURSOR(ELM_CURSOR_CROSS_REVERSE , CROSS_REVERSE ),
53 CURSOR(ELM_CURSOR_CROSSHAIR , ECORE_X_CURSOR_CROSSHAIR ), 60 CURSOR(ELM_CURSOR_CROSSHAIR , CROSSHAIR ),
54 CURSOR(ELM_CURSOR_DIAMOND_CROSS , ECORE_X_CURSOR_DIAMOND_CROSS ), 61 CURSOR(ELM_CURSOR_DIAMOND_CROSS , DIAMOND_CROSS ),
55 CURSOR(ELM_CURSOR_DOT , ECORE_X_CURSOR_DOT ), 62 CURSOR(ELM_CURSOR_DOT , DOT ),
56 CURSOR(ELM_CURSOR_DOT_BOX_MASK , ECORE_X_CURSOR_DOT_BOX_MASK ), 63 CURSOR(ELM_CURSOR_DOT_BOX_MASK , DOT_BOX_MASK ),
57 CURSOR(ELM_CURSOR_DOUBLE_ARROW , ECORE_X_CURSOR_DOUBLE_ARROW ), 64 CURSOR(ELM_CURSOR_DOUBLE_ARROW , DOUBLE_ARROW ),
58 CURSOR(ELM_CURSOR_DRAFT_LARGE , ECORE_X_CURSOR_DRAFT_LARGE ), 65 CURSOR(ELM_CURSOR_DRAFT_LARGE , DRAFT_LARGE ),
59 CURSOR(ELM_CURSOR_DRAFT_SMALL , ECORE_X_CURSOR_DRAFT_SMALL ), 66 CURSOR(ELM_CURSOR_DRAFT_SMALL , DRAFT_SMALL ),
60 CURSOR(ELM_CURSOR_DRAPED_BOX , ECORE_X_CURSOR_DRAPED_BOX ), 67 CURSOR(ELM_CURSOR_DRAPED_BOX , DRAPED_BOX ),
61 CURSOR(ELM_CURSOR_EXCHANGE , ECORE_X_CURSOR_EXCHANGE ), 68 CURSOR(ELM_CURSOR_EXCHANGE , EXCHANGE ),
62 CURSOR(ELM_CURSOR_FLEUR , ECORE_X_CURSOR_FLEUR ), 69 CURSOR(ELM_CURSOR_FLEUR , FLEUR ),
63 CURSOR(ELM_CURSOR_GOBBLER , ECORE_X_CURSOR_GOBBLER ), 70 CURSOR(ELM_CURSOR_GOBBLER , GOBBLER ),
64 CURSOR(ELM_CURSOR_GUMBY , ECORE_X_CURSOR_GUMBY ), 71 CURSOR(ELM_CURSOR_GUMBY , GUMBY ),
65 CURSOR(ELM_CURSOR_HAND1 , ECORE_X_CURSOR_HAND1 ), 72 CURSOR(ELM_CURSOR_HAND1 , HAND1 ),
66 CURSOR(ELM_CURSOR_HAND2 , ECORE_X_CURSOR_HAND2 ), 73 CURSOR(ELM_CURSOR_HAND2 , HAND2 ),
67 CURSOR(ELM_CURSOR_HEART , ECORE_X_CURSOR_HEART ), 74 CURSOR(ELM_CURSOR_HEART , HEART ),
68 CURSOR(ELM_CURSOR_ICON , ECORE_X_CURSOR_ICON ), 75 CURSOR(ELM_CURSOR_ICON , ICON ),
69 CURSOR(ELM_CURSOR_IRON_CROSS , ECORE_X_CURSOR_IRON_CROSS ), 76 CURSOR(ELM_CURSOR_IRON_CROSS , IRON_CROSS ),
70 CURSOR(ELM_CURSOR_LEFT_PTR , ECORE_X_CURSOR_LEFT_PTR ), 77 CURSOR(ELM_CURSOR_LEFT_PTR , LEFT_PTR ),
71 CURSOR(ELM_CURSOR_LEFT_SIDE , ECORE_X_CURSOR_LEFT_SIDE ), 78 CURSOR(ELM_CURSOR_LEFT_SIDE , LEFT_SIDE ),
72 CURSOR(ELM_CURSOR_LEFT_TEE , ECORE_X_CURSOR_LEFT_TEE ), 79 CURSOR(ELM_CURSOR_LEFT_TEE , LEFT_TEE ),
73 CURSOR(ELM_CURSOR_LEFTBUTTON , ECORE_X_CURSOR_LEFTBUTTON ), 80 CURSOR(ELM_CURSOR_LEFTBUTTON , LEFTBUTTON ),
74 CURSOR(ELM_CURSOR_LL_ANGLE , ECORE_X_CURSOR_LL_ANGLE ), 81 CURSOR(ELM_CURSOR_LL_ANGLE , LL_ANGLE ),
75 CURSOR(ELM_CURSOR_LR_ANGLE , ECORE_X_CURSOR_LR_ANGLE ), 82 CURSOR(ELM_CURSOR_LR_ANGLE , LR_ANGLE ),
76 CURSOR(ELM_CURSOR_MAN , ECORE_X_CURSOR_MAN ), 83 CURSOR(ELM_CURSOR_MAN , MAN ),
77 CURSOR(ELM_CURSOR_MIDDLEBUTTON , ECORE_X_CURSOR_MIDDLEBUTTON ), 84 CURSOR(ELM_CURSOR_MIDDLEBUTTON , MIDDLEBUTTON ),
78 CURSOR(ELM_CURSOR_MOUSE , ECORE_X_CURSOR_MOUSE ), 85 CURSOR(ELM_CURSOR_MOUSE , MOUSE ),
79 CURSOR(ELM_CURSOR_PENCIL , ECORE_X_CURSOR_PENCIL ), 86 CURSOR(ELM_CURSOR_PENCIL , PENCIL ),
80 CURSOR(ELM_CURSOR_PIRATE , ECORE_X_CURSOR_PIRATE ), 87 CURSOR(ELM_CURSOR_PIRATE , PIRATE ),
81 CURSOR(ELM_CURSOR_PLUS , ECORE_X_CURSOR_PLUS ), 88 CURSOR(ELM_CURSOR_PLUS , PLUS ),
82 CURSOR(ELM_CURSOR_QUESTION_ARROW , ECORE_X_CURSOR_QUESTION_ARROW ), 89 CURSOR(ELM_CURSOR_QUESTION_ARROW , QUESTION_ARROW ),
83 CURSOR(ELM_CURSOR_RIGHT_PTR , ECORE_X_CURSOR_RIGHT_PTR ), 90 CURSOR(ELM_CURSOR_RIGHT_PTR , RIGHT_PTR ),
84 CURSOR(ELM_CURSOR_RIGHT_SIDE , ECORE_X_CURSOR_RIGHT_SIDE ), 91 CURSOR(ELM_CURSOR_RIGHT_SIDE , RIGHT_SIDE ),
85 CURSOR(ELM_CURSOR_RIGHT_TEE , ECORE_X_CURSOR_RIGHT_TEE ), 92 CURSOR(ELM_CURSOR_RIGHT_TEE , RIGHT_TEE ),
86 CURSOR(ELM_CURSOR_RIGHTBUTTON , ECORE_X_CURSOR_RIGHTBUTTON ), 93 CURSOR(ELM_CURSOR_RIGHTBUTTON , RIGHTBUTTON ),
87 CURSOR(ELM_CURSOR_RTL_LOGO , ECORE_X_CURSOR_RTL_LOGO ), 94 CURSOR(ELM_CURSOR_RTL_LOGO , RTL_LOGO ),
88 CURSOR(ELM_CURSOR_SAILBOAT , ECORE_X_CURSOR_SAILBOAT ), 95 CURSOR(ELM_CURSOR_SAILBOAT , SAILBOAT ),
89 CURSOR(ELM_CURSOR_SB_DOWN_ARROW , ECORE_X_CURSOR_SB_DOWN_ARROW ), 96 CURSOR(ELM_CURSOR_SB_DOWN_ARROW , SB_DOWN_ARROW ),
90 CURSOR(ELM_CURSOR_SB_H_DOUBLE_ARROW , ECORE_X_CURSOR_SB_H_DOUBLE_ARROW ), 97 CURSOR(ELM_CURSOR_SB_H_DOUBLE_ARROW , SB_H_DOUBLE_ARROW ),
91 CURSOR(ELM_CURSOR_SB_LEFT_ARROW , ECORE_X_CURSOR_SB_LEFT_ARROW ), 98 CURSOR(ELM_CURSOR_SB_LEFT_ARROW , SB_LEFT_ARROW ),
92 CURSOR(ELM_CURSOR_SB_RIGHT_ARROW , ECORE_X_CURSOR_SB_RIGHT_ARROW ), 99 CURSOR(ELM_CURSOR_SB_RIGHT_ARROW , SB_RIGHT_ARROW ),
93 CURSOR(ELM_CURSOR_SB_UP_ARROW , ECORE_X_CURSOR_SB_UP_ARROW ), 100 CURSOR(ELM_CURSOR_SB_UP_ARROW , SB_UP_ARROW ),
94 CURSOR(ELM_CURSOR_SB_V_DOUBLE_ARROW , ECORE_X_CURSOR_SB_V_DOUBLE_ARROW ), 101 CURSOR(ELM_CURSOR_SB_V_DOUBLE_ARROW , SB_V_DOUBLE_ARROW ),
95 CURSOR(ELM_CURSOR_SHUTTLE , ECORE_X_CURSOR_SHUTTLE ), 102 CURSOR(ELM_CURSOR_SHUTTLE , SHUTTLE ),
96 CURSOR(ELM_CURSOR_SIZING , ECORE_X_CURSOR_SIZING ), 103 CURSOR(ELM_CURSOR_SIZING , SIZING ),
97 CURSOR(ELM_CURSOR_SPIDER , ECORE_X_CURSOR_SPIDER ), 104 CURSOR(ELM_CURSOR_SPIDER , SPIDER ),
98 CURSOR(ELM_CURSOR_SPRAYCAN , ECORE_X_CURSOR_SPRAYCAN ), 105 CURSOR(ELM_CURSOR_SPRAYCAN , SPRAYCAN ),
99 CURSOR(ELM_CURSOR_STAR , ECORE_X_CURSOR_STAR ), 106 CURSOR(ELM_CURSOR_STAR , STAR ),
100 CURSOR(ELM_CURSOR_TARGET , ECORE_X_CURSOR_TARGET ), 107 CURSOR(ELM_CURSOR_TARGET , TARGET ),
101 CURSOR(ELM_CURSOR_TCROSS , ECORE_X_CURSOR_TCROSS ), 108 CURSOR(ELM_CURSOR_TCROSS , TCROSS ),
102 CURSOR(ELM_CURSOR_TOP_LEFT_ARROW , ECORE_X_CURSOR_TOP_LEFT_ARROW ), 109 CURSOR(ELM_CURSOR_TOP_LEFT_ARROW , TOP_LEFT_ARROW ),
103 CURSOR(ELM_CURSOR_TOP_LEFT_CORNER , ECORE_X_CURSOR_TOP_LEFT_CORNER ), 110 CURSOR(ELM_CURSOR_TOP_LEFT_CORNER , TOP_LEFT_CORNER ),
104 CURSOR(ELM_CURSOR_TOP_RIGHT_CORNER , ECORE_X_CURSOR_TOP_RIGHT_CORNER ), 111 CURSOR(ELM_CURSOR_TOP_RIGHT_CORNER , TOP_RIGHT_CORNER ),
105 CURSOR(ELM_CURSOR_TOP_SIDE , ECORE_X_CURSOR_TOP_SIDE ), 112 CURSOR(ELM_CURSOR_TOP_SIDE , TOP_SIDE ),
106 CURSOR(ELM_CURSOR_TOP_TEE , ECORE_X_CURSOR_TOP_TEE ), 113 CURSOR(ELM_CURSOR_TOP_TEE , TOP_TEE ),
107 CURSOR(ELM_CURSOR_TREK , ECORE_X_CURSOR_TREK ), 114 CURSOR(ELM_CURSOR_TREK , TREK ),
108 CURSOR(ELM_CURSOR_UL_ANGLE , ECORE_X_CURSOR_UL_ANGLE ), 115 CURSOR(ELM_CURSOR_UL_ANGLE , UL_ANGLE ),
109 CURSOR(ELM_CURSOR_UMBRELLA , ECORE_X_CURSOR_UMBRELLA ), 116 CURSOR(ELM_CURSOR_UMBRELLA , UMBRELLA ),
110 CURSOR(ELM_CURSOR_UR_ANGLE , ECORE_X_CURSOR_UR_ANGLE ), 117 CURSOR(ELM_CURSOR_UR_ANGLE , UR_ANGLE ),
111 CURSOR(ELM_CURSOR_WATCH , ECORE_X_CURSOR_WATCH ), 118 CURSOR(ELM_CURSOR_WATCH , WATCH ),
112 CURSOR(ELM_CURSOR_XTERM , ECORE_X_CURSOR_XTERM ) 119 CURSOR(ELM_CURSOR_XTERM , XTERM )
113}; 120};
114static const int _cursors_count = sizeof(_cursors)/sizeof(struct _Cursor_Id); 121static const int _cursors_count = sizeof(_cursors)/sizeof(struct _Cursor_Id);
115 122
@@ -151,6 +158,12 @@ struct _Elm_Cursor
151 Ecore_Wl_Window *win; 158 Ecore_Wl_Window *win;
152 } wl; 159 } wl;
153#endif 160#endif
161#ifdef HAVE_ELEMENTARY_WIN32
162 struct {
163 Ecore_Win32_Cursor *cursor;
164 Ecore_Win32_Window *win;
165 } win32;
166#endif
154 167
155 Eina_Bool visible:1; 168 Eina_Bool visible:1;
156 Eina_Bool use_engine:1; 169 Eina_Bool use_engine:1;
@@ -286,6 +299,10 @@ _elm_cursor_set(Elm_Cursor *cur)
286 if (cur->wl.win) 299 if (cur->wl.win)
287 ecore_wl_window_cursor_from_name_set(cur->wl.win, cur->cursor_name); 300 ecore_wl_window_cursor_from_name_set(cur->wl.win, cur->cursor_name);
288#endif 301#endif
302#ifdef HAVE_ELEMENTARY_WIN32
303 if (cur->win32.win)
304 ecore_win32_window_cursor_set(cur->win32.win, cur->win32.cursor);
305#endif
289 } 306 }
290 evas_event_thaw(cur->evas); 307 evas_event_thaw(cur->evas);
291} 308}
@@ -344,6 +361,10 @@ _elm_cursor_mouse_out(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj EINA_
344 if (cur->wl.win) 361 if (cur->wl.win)
345 ecore_wl_window_cursor_default_restore(cur->wl.win); 362 ecore_wl_window_cursor_default_restore(cur->wl.win);
346#endif 363#endif
364#ifdef HAVE_ELEMENTARY_WIN32
365 if (cur->win32.win)
366 ecore_win32_window_cursor_set(cur->win32.win, ecore_win32_cursor_shaped_new(ECORE_WIN32_CURSOR_SHAPE_ARROW));
367#endif
347 } 368 }
348 evas_event_thaw(cur->evas); 369 evas_event_thaw(cur->evas);
349} 370}
@@ -354,7 +375,7 @@ _elm_cursor_del(void *data EINA_UNUSED, Evas *evas EINA_UNUSED, Evas_Object *obj
354 elm_object_cursor_unset(obj); 375 elm_object_cursor_unset(obj);
355} 376}
356 377
357#ifdef HAVE_ELEMENTARY_X 378#if defined HAVE_ELEMENTARY_X || defined HAVE_ELEMENTARY_WIN32
358static int 379static int
359_elm_cursor_strcmp(const void *data1, const void *data2) 380_elm_cursor_strcmp(const void *data1, const void *data2)
360{ 381{
@@ -404,10 +425,10 @@ _elm_cursor_cur_set(Elm_Cursor *cur)
404 if (cur->x.win) 425 if (cur->x.win)
405 { 426 {
406 struct _Cursor_Id *cur_id; 427 struct _Cursor_Id *cur_id;
407 428
408 cur_id = bsearch(&(cur->cursor_name), _cursors, _cursors_count, 429 cur_id = bsearch(&(cur->cursor_name), _cursors, _cursors_count,
409 sizeof(struct _Cursor_Id), _elm_cursor_strcmp); 430 sizeof(struct _Cursor_Id), _elm_cursor_strcmp);
410 431
411 if (!cur_id) 432 if (!cur_id)
412 { 433 {
413 INF("X cursor couldn't be found: %s. Using default.", 434 INF("X cursor couldn't be found: %s. Using default.",
@@ -421,6 +442,25 @@ _elm_cursor_cur_set(Elm_Cursor *cur)
421#ifdef HAVE_ELEMENTARY_WAYLAND 442#ifdef HAVE_ELEMENTARY_WAYLAND
422 cur->wl.win = elm_win_wl_window_get(top); 443 cur->wl.win = elm_win_wl_window_get(top);
423#endif 444#endif
445#ifdef HAVE_ELEMENTARY_WIN32
446 cur->win32.win = elm_win_win32_window_get(top);
447 if (cur->win32.win)
448 {
449 struct _Cursor_Id *cur_id;
450
451 cur_id = bsearch(&(cur->cursor_name), _cursors, _cursors_count,
452 sizeof(struct _Cursor_Id), _elm_cursor_strcmp);
453
454 if (!cur_id)
455 {
456 INF("Win32 X cursor couldn't be found: %s. Using default.",
457 cur->cursor_name);
458 cur->win32.cursor = ecore_win32_cursor_shaped_new(ECORE_WIN32_CURSOR_SHAPE_ARROW);
459 }
460 else
461 cur->win32.cursor = ecore_win32_cursor_x11_shaped_get(cur_id->id);
462 }
463#endif
424 } 464 }
425 } 465 }
426 466
@@ -545,6 +585,10 @@ elm_object_cursor_unset(Evas_Object *obj)
545 else if (cur->wl.win) 585 else if (cur->wl.win)
546 ecore_wl_window_cursor_default_restore(cur->wl.win); 586 ecore_wl_window_cursor_default_restore(cur->wl.win);
547#endif 587#endif
588#ifdef HAVE_ELEMENTARY_WIN32
589 else
590 ecore_win32_window_cursor_set(cur->win32.win, ecore_win32_cursor_shaped_new(ECORE_WIN32_CURSOR_SHAPE_ARROW));
591#endif
548 } 592 }
549 593
550 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_MOUSE_IN, 594 evas_object_event_callback_del_full(obj, EVAS_CALLBACK_MOUSE_IN,