diff options
author | Seunghun Lee <shiin.lee@samsung.com> | 2015-01-05 09:08:27 -0500 |
---|---|---|
committer | Chris Michael <cp.michael@samsung.com> | 2015-01-05 09:08:27 -0500 |
commit | 2db6ed09456e433877c5be191a18c84d216ae3f6 (patch) | |
tree | dac97eb8cdc676d9a72504bee65a15f739fbca75 /src/lib/ecore_drm/ecore_drm_tty.c | |
parent | a5183ee424d65cf37343ea46f7982c74f60d6fbc (diff) |
ecore-drm: remove duplicated code from logind and tty.
Summary: integrates the code used in common.
Reviewers: devilhorns
Reviewed By: devilhorns
Subscribers: cedric
Differential Revision: https://phab.enlightenment.org/D1796
Diffstat (limited to 'src/lib/ecore_drm/ecore_drm_tty.c')
-rw-r--r-- | src/lib/ecore_drm/ecore_drm_tty.c | 119 |
1 files changed, 5 insertions, 114 deletions
diff --git a/src/lib/ecore_drm/ecore_drm_tty.c b/src/lib/ecore_drm/ecore_drm_tty.c index 11a074e0d6..2bf7027f9f 100644 --- a/src/lib/ecore_drm/ecore_drm_tty.c +++ b/src/lib/ecore_drm/ecore_drm_tty.c | |||
@@ -12,103 +12,12 @@ | |||
12 | # define KDSKBMUTE 0x4B51 | 12 | # define KDSKBMUTE 0x4B51 |
13 | #endif | 13 | #endif |
14 | 14 | ||
15 | static Eina_Bool | 15 | Eina_Bool |
16 | _ecore_drm_tty_cb_vt_switch(void *data, int type EINA_UNUSED, void *event) | 16 | _ecore_drm_tty_switch(Ecore_Drm_Device *dev, int activate_vt) |
17 | { | 17 | { |
18 | Ecore_Drm_Device *dev; | 18 | if (!ioctl(dev->tty.fd, VT_ACTIVATE, activate_vt) < 0) |
19 | Ecore_Event_Key *ev; | 19 | return EINA_FALSE; |
20 | int keycode; | 20 | return EINA_TRUE; |
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 | if (ioctl(dev->tty.fd, VT_ACTIVATE, vt) < 0) | ||
34 | ERR("Failed to activate vt: %m"); | ||
35 | } | ||
36 | |||
37 | return ECORE_CALLBACK_PASS_ON; | ||
38 | } | ||
39 | |||
40 | static Eina_Bool | ||
41 | _ecore_drm_tty_cb_signal(void *data, int type EINA_UNUSED, void *event) | ||
42 | { | ||
43 | Ecore_Drm_Device *dev; | ||
44 | Ecore_Event_Signal_User *ev; | ||
45 | siginfo_t sigdata; | ||
46 | |||
47 | dev = data; | ||
48 | ev = event; | ||
49 | |||
50 | sigdata = ev->data; | ||
51 | if (sigdata.si_code != SI_KERNEL) return ECORE_CALLBACK_RENEW; | ||
52 | |||
53 | if (ev->number == 1) | ||
54 | { | ||
55 | Ecore_Drm_Input *input; | ||
56 | Ecore_Drm_Output *output; | ||
57 | Ecore_Drm_Sprite *sprite; | ||
58 | Eina_List *l; | ||
59 | |||
60 | /* disable inputs (suspends) */ | ||
61 | EINA_LIST_FOREACH(dev->inputs, l, input) | ||
62 | ecore_drm_inputs_disable(input); | ||
63 | |||
64 | /* disable hardware cursor */ | ||
65 | EINA_LIST_FOREACH(dev->outputs, l, output) | ||
66 | ecore_drm_output_cursor_size_set(output, 0, 0, 0); | ||
67 | |||
68 | /* disable sprites */ | ||
69 | EINA_LIST_FOREACH(dev->sprites, l, sprite) | ||
70 | ecore_drm_sprites_fb_set(sprite, 0, 0); | ||
71 | |||
72 | /* drop drm master */ | ||
73 | if (ecore_drm_device_master_drop(dev)) | ||
74 | { | ||
75 | /* issue ioctl to release vt */ | ||
76 | if (!ecore_drm_tty_release(dev)) | ||
77 | ERR("Could not release VT: %m"); | ||
78 | } | ||
79 | else | ||
80 | ERR("Could not drop drm master: %m"); | ||
81 | |||
82 | _ecore_drm_event_activate_send(EINA_FALSE); | ||
83 | } | ||
84 | else if (ev->number == 2) | ||
85 | { | ||
86 | /* issue ioctl to acquire vt */ | ||
87 | if (ecore_drm_tty_acquire(dev)) | ||
88 | { | ||
89 | Ecore_Drm_Output *output; | ||
90 | Ecore_Drm_Input *input; | ||
91 | Eina_List *l; | ||
92 | |||
93 | /* set drm master */ | ||
94 | if (!ecore_drm_device_master_set(dev)) | ||
95 | ERR("Could not set drm master: %m"); | ||
96 | |||
97 | /* set output mode */ | ||
98 | EINA_LIST_FOREACH(dev->outputs, l, output) | ||
99 | ecore_drm_output_enable(output); | ||
100 | |||
101 | /* enable inputs */ | ||
102 | EINA_LIST_FOREACH(dev->inputs, l, input) | ||
103 | ecore_drm_inputs_enable(input); | ||
104 | |||
105 | _ecore_drm_event_activate_send(EINA_TRUE); | ||
106 | } | ||
107 | else | ||
108 | ERR("Could not acquire VT: %m"); | ||
109 | } | ||
110 | |||
111 | return ECORE_CALLBACK_RENEW; | ||
112 | } | 21 | } |
113 | 22 | ||
114 | static Eina_Bool | 23 | static Eina_Bool |
@@ -246,16 +155,6 @@ ecore_drm_tty_open(Ecore_Drm_Device *dev, const char *name) | |||
246 | return EINA_FALSE; | 155 | return EINA_FALSE; |
247 | } | 156 | } |
248 | 157 | ||
249 | /* setup handler for signals */ | ||
250 | dev->tty.event_hdlr = | ||
251 | ecore_event_handler_add(ECORE_EVENT_SIGNAL_USER, | ||
252 | _ecore_drm_tty_cb_signal, dev); | ||
253 | |||
254 | /* setup handler for key event of vt switch */ | ||
255 | dev->tty.switch_hdlr = | ||
256 | ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, | ||
257 | _ecore_drm_tty_cb_vt_switch, dev); | ||
258 | |||
259 | /* set current tty into env */ | 158 | /* set current tty into env */ |
260 | setenv("ECORE_DRM_TTY", tty, 1); | 159 | setenv("ECORE_DRM_TTY", tty, 1); |
261 | 160 | ||
@@ -301,14 +200,6 @@ ecore_drm_tty_close(Ecore_Drm_Device *dev) | |||
301 | 200 | ||
302 | dev->tty.fd = -1; | 201 | dev->tty.fd = -1; |
303 | 202 | ||
304 | /* destroy the event handler */ | ||
305 | if (dev->tty.event_hdlr) ecore_event_handler_del(dev->tty.event_hdlr); | ||
306 | dev->tty.event_hdlr = NULL; | ||
307 | |||
308 | /* destroy the event handler */ | ||
309 | if (dev->tty.switch_hdlr) ecore_event_handler_del(dev->tty.switch_hdlr); | ||
310 | dev->tty.switch_hdlr = NULL; | ||
311 | |||
312 | /* clear the tty name */ | 203 | /* clear the tty name */ |
313 | if (dev->tty.name) eina_stringshare_del(dev->tty.name); | 204 | if (dev->tty.name) eina_stringshare_del(dev->tty.name); |
314 | dev->tty.name = NULL; | 205 | dev->tty.name = NULL; |