summaryrefslogtreecommitdiff
path: root/src/lib/elput
diff options
context:
space:
mode:
authorChris Michael <cpmichael@osg.samsung.com>2016-05-09 12:00:35 -0400
committerChris Michael <cpmichael@osg.samsung.com>2016-05-09 12:00:35 -0400
commitd734cd4cada136add5d66e126c659223897fe487 (patch)
tree77db447a0bd152a5efd182bd1f6aefaba28a4444 /src/lib/elput
parentf9149c1699515c060d004225c6a2c5653cebe322 (diff)
elput: Add code to handle keybindings for vt switching
This patch makes elput handle receiving the key combinations for vt switching and perform the actual switch itself. This is done so that ecore_drm2, ecore_fb, etc, etc do not each need their own code to handle vt switching. @feature Signed-off-by: Chris Michael <cpmichael@osg.samsung.com>
Diffstat (limited to 'src/lib/elput')
-rw-r--r--src/lib/elput/elput_manager.c45
-rw-r--r--src/lib/elput/elput_private.h1
2 files changed, 42 insertions, 4 deletions
diff --git a/src/lib/elput/elput_manager.c b/src/lib/elput/elput_manager.c
index e267951b30..13db80973f 100644
--- a/src/lib/elput/elput_manager.c
+++ b/src/lib/elput/elput_manager.c
@@ -5,11 +5,35 @@ static Elput_Interface *_ifaces[] =
5#ifdef HAVE_SYSTEMD 5#ifdef HAVE_SYSTEMD
6 &_logind_interface, 6 &_logind_interface,
7#endif 7#endif
8 NULL, // launcher
9 NULL, // direct
10 NULL, 8 NULL,
11}; 9};
12 10
11static Eina_Bool
12_cb_key_down(void *data, int type EINA_UNUSED, void *event)
13{
14 Elput_Manager *em;
15 Ecore_Event_Key *ev;
16 int code = 0, vt = 0;
17
18 em = data;
19 ev = event;
20 code = (ev->keycode - 8);
21
22 if ((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) &&
23 (ev->modifiers & ECORE_EVENT_MODIFIER_ALT) &&
24 (code >= KEY_F1) && (code <= KEY_F8))
25 {
26 vt = (code - KEY_F1 + 1);
27 if (em->interface->vt_set)
28 {
29 if (!em->interface->vt_set(em, vt))
30 ERR("Failed to switch to virtual terminal %d", vt);
31 }
32 }
33
34 return ECORE_CALLBACK_RENEW;
35}
36
13EAPI Elput_Manager * 37EAPI Elput_Manager *
14elput_manager_connect(const char *seat, unsigned int tty, Eina_Bool sync) 38elput_manager_connect(const char *seat, unsigned int tty, Eina_Bool sync)
15{ 39{
@@ -41,6 +65,8 @@ elput_manager_disconnect(Elput_Manager *manager)
41EAPI int 65EAPI int
42elput_manager_open(Elput_Manager *manager, const char *path, int flags) 66elput_manager_open(Elput_Manager *manager, const char *path, int flags)
43{ 67{
68 int ret = -1;
69
44 EINA_SAFETY_ON_NULL_RETURN_VAL(manager, -1); 70 EINA_SAFETY_ON_NULL_RETURN_VAL(manager, -1);
45 EINA_SAFETY_ON_NULL_RETURN_VAL(manager->interface, -1); 71 EINA_SAFETY_ON_NULL_RETURN_VAL(manager->interface, -1);
46 EINA_SAFETY_ON_NULL_RETURN_VAL(path, -1); 72 EINA_SAFETY_ON_NULL_RETURN_VAL(path, -1);
@@ -48,9 +74,17 @@ elput_manager_open(Elput_Manager *manager, const char *path, int flags)
48 if (flags < 0) flags = O_RDWR; 74 if (flags < 0) flags = O_RDWR;
49 75
50 if (manager->interface->open) 76 if (manager->interface->open)
51 return manager->interface->open(manager, path, flags); 77 {
78 ret = manager->interface->open(manager, path, flags);
79 if (ret)
80 {
81 manager->vt_hdlr =
82 ecore_event_handler_add(ECORE_EVENT_KEY_DOWN,
83 _cb_key_down, manager);
84 }
85 }
52 86
53 return -1; 87 return ret;
54} 88}
55 89
56EAPI void 90EAPI void
@@ -59,6 +93,9 @@ elput_manager_close(Elput_Manager *manager, int fd)
59 EINA_SAFETY_ON_NULL_RETURN(manager); 93 EINA_SAFETY_ON_NULL_RETURN(manager);
60 EINA_SAFETY_ON_NULL_RETURN(manager->interface); 94 EINA_SAFETY_ON_NULL_RETURN(manager->interface);
61 95
96 if (manager->vt_hdlr) ecore_event_handler_del(manager->vt_hdlr);
97 manager->vt_hdlr = NULL;
98
62 if (manager->interface->close) 99 if (manager->interface->close)
63 manager->interface->close(manager, fd); 100 manager->interface->close(manager, fd);
64} 101}
diff --git a/src/lib/elput/elput_private.h b/src/lib/elput/elput_private.h
index 769d23c82d..d3297fad00 100644
--- a/src/lib/elput/elput_private.h
+++ b/src/lib/elput/elput_private.h
@@ -222,6 +222,7 @@ struct _Elput_Manager
222 char *sid; 222 char *sid;
223 const char *seat; 223 const char *seat;
224 unsigned int vt_num; 224 unsigned int vt_num;
225 Ecore_Event_Handler *vt_hdlr;
225 226
226 struct 227 struct
227 { 228 {