summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean Guyomarc'h <jean.guyomarch@openwide.fr>2015-10-15 10:38:15 +0200
committerNicolas Aguirre <aguirre.nicolas@gmail.com>2015-11-10 08:32:49 +0100
commit243bd5116f0e1ca414a69fc46d5c23a38e9417a0 (patch)
tree6caca3672e26c261752334bcea2766cbd1056ebe
parent255c5f064e0b42967e15e1bc8a9d57b4cf273efe (diff)
edje: on Mac OS X, use Apple's key bindings with entries
-rw-r--r--src/lib/edje/edje_entry.c32
1 files changed, 23 insertions, 9 deletions
diff --git a/src/lib/edje/edje_entry.c b/src/lib/edje/edje_entry.c
index b6cbf84736..09aef62051 100644
--- a/src/lib/edje/edje_entry.c
+++ b/src/lib/edje/edje_entry.c
@@ -1392,6 +1392,7 @@ _compose_seq_reset(Entry *en)
1392 en->composing = EINA_FALSE; 1392 en->composing = EINA_FALSE;
1393} 1393}
1394 1394
1395
1395static void 1396static void
1396_edje_key_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info) 1397_edje_key_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
1397{ 1398{
@@ -1399,7 +1400,7 @@ _edje_key_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
1399 Evas_Event_Key_Down *ev = event_info; 1400 Evas_Event_Key_Down *ev = event_info;
1400 Edje_Real_Part *rp = ed->focused_part; 1401 Edje_Real_Part *rp = ed->focused_part;
1401 Entry *en; 1402 Entry *en;
1402 Eina_Bool control, alt, shift; 1403 Eina_Bool control, alt, shift, apple_cmd, apple;
1403 Eina_Bool multiline; 1404 Eina_Bool multiline;
1404 Eina_Bool cursor_changed; 1405 Eina_Bool cursor_changed;
1405 int old_cur_pos; 1406 int old_cur_pos;
@@ -1434,10 +1435,21 @@ _edje_key_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
1434 old_cur_pos = evas_textblock_cursor_pos_get(en->cursor); 1435 old_cur_pos = evas_textblock_cursor_pos_get(en->cursor);
1435 1436
1436 control = evas_key_modifier_is_set(ev->modifiers, "Control"); 1437 control = evas_key_modifier_is_set(ev->modifiers, "Control");
1438#if HAVE_ECORE_COCOA
1439# define ACTION_KEY_PRESSED (apple_cmd == EINA_TRUE)
1440 apple_cmd = (evas_key_modifier_is_set(ev->modifiers, "Super") &&
1441 evas_key_modifier_is_set(ev->modifiers, "Hyper"));
1442 apple = EINA_TRUE;
1443#else
1444# define ACTION_KEY_PRESSED (control == EINA_TRUE)
1445 apple_cmd = EINA_FALSE;
1446 apple = EINA_FALSE;
1447#endif
1437 alt = evas_key_modifier_is_set(ev->modifiers, "Alt"); 1448 alt = evas_key_modifier_is_set(ev->modifiers, "Alt");
1438 shift = evas_key_modifier_is_set(ev->modifiers, "Shift"); 1449 shift = evas_key_modifier_is_set(ev->modifiers, "Shift");
1439 multiline = rp->part->multiline; 1450 multiline = rp->part->multiline;
1440 cursor_changed = EINA_FALSE; 1451 cursor_changed = EINA_FALSE;
1452
1441 if (!strcmp(ev->key, "Escape")) 1453 if (!strcmp(ev->key, "Escape"))
1442 { 1454 {
1443 _compose_seq_reset(en); 1455 _compose_seq_reset(en);
@@ -1596,7 +1608,8 @@ _edje_key_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
1596 else if (!strcmp(ev->key, "BackSpace")) 1608 else if (!strcmp(ev->key, "BackSpace"))
1597 { 1609 {
1598 _compose_seq_reset(en); 1610 _compose_seq_reset(en);
1599 if (control && !en->have_selection) 1611 if (((!apple && control) || (apple && alt)) &&
1612 (!en->have_selection))
1600 { 1613 {
1601 // del to start of previous word 1614 // del to start of previous word
1602 _sel_start(en->cursor, rp->object, en); 1615 _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,
1635 (!strcmp(ev->key, "KP_Delete") && !ev->string)) 1648 (!strcmp(ev->key, "KP_Delete") && !ev->string))
1636 { 1649 {
1637 _compose_seq_reset(en); 1650 _compose_seq_reset(en);
1638 if (control) 1651 if ((!apple && control) || (apple && alt))
1639 { 1652 {
1640 // del to end of next word 1653 // del to end of next word
1641 _sel_start(en->cursor, rp->object, en); 1654 _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,
1711 _edje_emit(ed, "cursor,changed,manual", rp->part->name); 1724 _edje_emit(ed, "cursor,changed,manual", rp->part->name);
1712 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; 1725 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1713 } 1726 }
1714 else if ((control) && (!shift) && (!strcmp(ev->keyname, "v"))) 1727 else if (ACTION_KEY_PRESSED && (!shift) && (!strcmp(ev->keyname, "v")))
1715 { 1728 {
1716 _compose_seq_reset(en); 1729 _compose_seq_reset(en);
1717 _edje_emit(ed, "entry,paste,request", rp->part->name); 1730 _edje_emit(ed, "entry,paste,request", rp->part->name);
1718 _edje_emit(ed, "entry,paste,request,3", rp->part->name); 1731 _edje_emit(ed, "entry,paste,request,3", rp->part->name);
1719 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; 1732 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1720 } 1733 }
1721 else if ((control) && (!strcmp(ev->keyname, "a"))) 1734 else if (ACTION_KEY_PRESSED && (!strcmp(ev->keyname, "a")))
1722 { 1735 {
1723 _compose_seq_reset(en); 1736 _compose_seq_reset(en);
1724 if (shift) 1737 if (shift)
@@ -1732,19 +1745,19 @@ _edje_key_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
1732 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; 1745 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1733 } 1746 }
1734 } 1747 }
1735 else if ((control) && (((!shift) && !strcmp(ev->keyname, "c")) || !strcmp(ev->key, "Insert"))) 1748 else if (ACTION_KEY_PRESSED && (((!shift) && !strcmp(ev->keyname, "c")) || !strcmp(ev->key, "Insert")))
1736 { 1749 {
1737 _compose_seq_reset(en); 1750 _compose_seq_reset(en);
1738 _edje_emit(ed, "entry,copy,notify", rp->part->name); 1751 _edje_emit(ed, "entry,copy,notify", rp->part->name);
1739 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; 1752 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1740 } 1753 }
1741 else if ((control) && (!shift) && ((!strcmp(ev->keyname, "x") || (!strcmp(ev->keyname, "m"))))) 1754 else if (ACTION_KEY_PRESSED && (!shift) && ((!strcmp(ev->keyname, "x") || (!strcmp(ev->keyname, "m")))))
1742 { 1755 {
1743 _compose_seq_reset(en); 1756 _compose_seq_reset(en);
1744 _edje_emit(ed, "entry,cut,notify", rp->part->name); 1757 _edje_emit(ed, "entry,cut,notify", rp->part->name);
1745 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; 1758 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1746 } 1759 }
1747 else if ((control) && (!strcmp(ev->keyname, "z"))) 1760 else if (ACTION_KEY_PRESSED && (!strcmp(ev->keyname, "z")))
1748 { 1761 {
1749 _compose_seq_reset(en); 1762 _compose_seq_reset(en);
1750 if (shift) 1763 if (shift)
@@ -1759,7 +1772,8 @@ _edje_key_down_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
1759 } 1772 }
1760 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD; 1773 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1761 } 1774 }
1762 else if ((control) && (!shift) && (!strcmp(ev->keyname, "y"))) 1775 else if (((!apple) && (control) && (!shift) && (!strcmp(ev->keyname, "y"))) ||
1776 ((apple) && ACTION_KEY_PRESSED && (shift) && (!strcmp(ev->keyname, "z"))))
1763 { 1777 {
1764 _compose_seq_reset(en); 1778 _compose_seq_reset(en);
1765 // redo 1779 // redo