diff options
author | MinJeong Kim <minjjj.kim@samsung.com> | 2014-09-15 12:03:52 -0400 |
---|---|---|
committer | Chris Michael <cp.michael@samsung.com> | 2014-09-15 12:03:52 -0400 |
commit | 96a83aecfa59528e4e200ef7dcc3740b82625705 (patch) | |
tree | 32a6a753d7cce23a0cbe2fa8bc683512a3927cd4 /src/lib/ecore_drm/ecore_drm_tty.c | |
parent | 11237fd8584b0aa1706bfa1d37ec8b78727736c0 (diff) |
ecore-drm: added vt switch key event handler
Summary:
Because vt mode of tty is set to VT_PROCESS,
ecore-drm is responsible for managing switch-to or switch-from other vt.
For that, ecore-drm has to handshake with kernel(tty driver).
On switch-from side(A):
1. Listen key event to satisfy vt switch key binding.
2. ioctl(fd, VT_ACTIVE, switch-to-vt) for activating switch-to vt.
3. Receive SIGUSR1(relsig) from kernel.
4. Prepare releasing vt, and ioctl(fd, VT_RELDISP, 1).
On switch-to side(B):
0. Kernel receive VT_RELDISP with value 1(ok) from switch-from vt.
1. Receive SIGUSR2(acqsig) from kernel.
2. ioctl(fd, VT_RELDISP, VT_ACKACQ), and start to setup vt.
This revision added A-1 step on above.
Test Plan:
On booted PC with systemd.
1. launch enlightenment_start with drm and wayland
ex) ECORE_DRM_TTY=/dev/tty1 \
E_WL_FORCE=drm \
ELM_ENGINE=wayland_shm enlightenment_start
2. try to switch vt by pressing "Ctrl + Alt + (F1 ~ F8)"
Reviewers: gwanglim, stefan_schmidt, devilhorns
Subscribers: cedric
Differential Revision: https://phab.enlightenment.org/D1280
Diffstat (limited to 'src/lib/ecore_drm/ecore_drm_tty.c')
-rw-r--r-- | src/lib/ecore_drm/ecore_drm_tty.c | 50 |
1 files changed, 49 insertions, 1 deletions
diff --git a/src/lib/ecore_drm/ecore_drm_tty.c b/src/lib/ecore_drm/ecore_drm_tty.c index f4a4d30870..cf19b89c86 100644 --- a/src/lib/ecore_drm/ecore_drm_tty.c +++ b/src/lib/ecore_drm/ecore_drm_tty.c | |||
@@ -12,6 +12,33 @@ | |||
12 | # define KDSKBMUTE 0x4B51 | 12 | # define KDSKBMUTE 0x4B51 |
13 | #endif | 13 | #endif |
14 | 14 | ||
15 | static Eina_Bool | ||
16 | _ecore_drm_tty_cb_vt_switch(void *data, int type EINA_UNUSED, void *event) | ||
17 | { | ||
18 | Ecore_Drm_Device *dev; | ||
19 | Ecore_Event_Key *ev; | ||
20 | int keycode; | ||
21 | int vt; | ||
22 | |||
23 | dev = data; | ||
24 | ev = event; | ||
25 | keycode = ev->keycode - 8; | ||
26 | |||
27 | if ((ev->modifiers & ECORE_EVENT_MODIFIER_CTRL) && | ||
28 | (ev->modifiers & ECORE_EVENT_MODIFIER_ALT) && | ||
29 | (keycode >= KEY_F1) && (keycode <= KEY_F8)) | ||
30 | { | ||
31 | vt = (keycode - KEY_F1 + 1); | ||
32 | |||
33 | /* make a vt #vt active */ | ||
34 | ioctl(dev->tty.fd, VT_ACTIVATE, vt); | ||
35 | |||
36 | return ECORE_CALLBACK_DONE; | ||
37 | } | ||
38 | |||
39 | return ECORE_CALLBACK_PASS_ON; | ||
40 | } | ||
41 | |||
15 | static Eina_Bool | 42 | static Eina_Bool |
16 | _ecore_drm_tty_cb_signal(void *data, int type EINA_UNUSED, void *event) | 43 | _ecore_drm_tty_cb_signal(void *data, int type EINA_UNUSED, void *event) |
17 | { | 44 | { |
@@ -22,8 +49,11 @@ _ecore_drm_tty_cb_signal(void *data, int type EINA_UNUSED, void *event) | |||
22 | dev = data; | 49 | dev = data; |
23 | ev = event; | 50 | ev = event; |
24 | 51 | ||
52 | /* FIXME: this sigdata doesn't have pid or uid info | ||
53 | * si_code is single value to get from sigdata | ||
54 | */ | ||
25 | sigdata = ev->data; | 55 | sigdata = ev->data; |
26 | if (sigdata.si_pid != getpid()) return ECORE_CALLBACK_RENEW; | 56 | if (sigdata.si_code != SI_KERNEL) return ECORE_CALLBACK_RENEW; |
27 | 57 | ||
28 | if (ev->number == 1) | 58 | if (ev->number == 1) |
29 | { | 59 | { |
@@ -54,6 +84,13 @@ _ecore_drm_tty_cb_signal(void *data, int type EINA_UNUSED, void *event) | |||
54 | /* issue ioctl to release vt */ | 84 | /* issue ioctl to release vt */ |
55 | if (!ecore_drm_tty_release(dev)) | 85 | if (!ecore_drm_tty_release(dev)) |
56 | ERR("Could not release VT: %m"); | 86 | ERR("Could not release VT: %m"); |
87 | |||
88 | /* remove switch handler */ | ||
89 | if (dev->tty.switch_hdlr) | ||
90 | { | ||
91 | ecore_event_handler_del(dev->tty.switch_hdlr); | ||
92 | dev->tty.switch_hdlr = NULL; | ||
93 | } | ||
57 | } | 94 | } |
58 | else | 95 | else |
59 | ERR("Could not drop drm master: %m"); | 96 | ERR("Could not drop drm master: %m"); |
@@ -80,6 +117,12 @@ _ecore_drm_tty_cb_signal(void *data, int type EINA_UNUSED, void *event) | |||
80 | /* enable inputs */ | 117 | /* enable inputs */ |
81 | EINA_LIST_FOREACH(dev->inputs, l, input) | 118 | EINA_LIST_FOREACH(dev->inputs, l, input) |
82 | ecore_drm_inputs_enable(input); | 119 | ecore_drm_inputs_enable(input); |
120 | |||
121 | /* listen key event for vt switch */ | ||
122 | if (!dev->tty.switch_hdlr) | ||
123 | ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, | ||
124 | _ecore_drm_tty_cb_vt_switch, dev); | ||
125 | |||
83 | } | 126 | } |
84 | else | 127 | else |
85 | ERR("Could not acquire VT: %m"); | 128 | ERR("Could not acquire VT: %m"); |
@@ -212,6 +255,11 @@ ecore_drm_tty_open(Ecore_Drm_Device *dev, const char *name) | |||
212 | ecore_event_handler_add(ECORE_EVENT_SIGNAL_USER, | 255 | ecore_event_handler_add(ECORE_EVENT_SIGNAL_USER, |
213 | _ecore_drm_tty_cb_signal, dev); | 256 | _ecore_drm_tty_cb_signal, dev); |
214 | 257 | ||
258 | /* setup handler for key event of vt switch */ | ||
259 | dev->tty.switch_hdlr = | ||
260 | ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, | ||
261 | _ecore_drm_tty_cb_vt_switch, dev); | ||
262 | |||
215 | /* set current tty into env */ | 263 | /* set current tty into env */ |
216 | setenv("ECORE_DRM_TTY", tty, 1); | 264 | setenv("ECORE_DRM_TTY", tty, 1); |
217 | 265 | ||