diff options
author | Chris Michael <cpmichael@osg.samsung.com> | 2016-01-21 11:20:29 -0500 |
---|---|---|
committer | Chris Michael <cpmichael@osg.samsung.com> | 2016-01-21 11:20:29 -0500 |
commit | cddc7ba445035040ee31685c1920327ca26f47d7 (patch) | |
tree | f861ad6d726b3d26b9629c2f9d644e6ed9fa395f | |
parent | 479bf37aecd60d519aa323eb3f2a93e1b0f3faa6 (diff) | |
download | efl-cddc7ba445035040ee31685c1920327ca26f47d7.tar.gz |
ecore-drm: Refactor logind code to use tty functions
This patch cleans up some of the logind code to make use of the
existing tty functions as they both did the same thing
@fix
Signed-off-by: Chris Michael <cpmichael@osg.samsung.com>
-rw-r--r-- | src/lib/ecore_drm/ecore_drm_logind.c | 78 |
1 files changed, 4 insertions, 74 deletions
diff --git a/src/lib/ecore_drm/ecore_drm_logind.c b/src/lib/ecore_drm/ecore_drm_logind.c index 47cb92f099..0797d0291f 100644 --- a/src/lib/ecore_drm/ecore_drm_logind.c +++ b/src/lib/ecore_drm/ecore_drm_logind.c @@ -27,77 +27,15 @@ _ecore_drm_logind_vt_get(Ecore_Drm_Device *dev) static Eina_Bool _ecore_drm_logind_vt_setup(Ecore_Drm_Device *dev) { - struct stat st; char buff[64]; - struct vt_mode vtmode = { 0, 0, SIGUSR1, SIGUSR2, 0 }; snprintf(buff, sizeof(buff), "/dev/tty%d", dev->vt); buff[sizeof(buff) - 1] = 0; - dev->tty.fd = open(buff, (O_RDWR | O_CLOEXEC | O_NONBLOCK)); - if (dev->tty.fd < 0) - { - ERR("Could not open VT %s %m", buff); - return EINA_FALSE; - } - - if ((fstat(dev->tty.fd, &st) == -1) || - (major(st.st_rdev) != TTY_MAJOR) || - (minor(st.st_rdev) <= 0) || (minor(st.st_rdev) >= 64)) - { - ERR("TTY %s is not a virtual terminal", buff); - goto stat_err; - } - - if (ioctl(dev->tty.fd, KDGKBMODE, &dev->tty.kbd_mode) < 0) - { - ERR("Could not read keyboard mode of %s: %m", buff); - dev->tty.kbd_mode = K_UNICODE; - } - else if (dev->tty.kbd_mode == K_OFF) - dev->tty.kbd_mode = K_UNICODE; - - if ((ioctl(dev->tty.fd, KDSKBMUTE, 1) < 0) && - (ioctl(dev->tty.fd, KDSKBMODE, K_OFF) < 0)) - { - ERR("Could not set K_OFF keyboard mode on %s: %m", buff); - goto stat_err; - } - - if (ioctl(dev->tty.fd, KDSETMODE, KD_GRAPHICS) < 0) - { - ERR("Could not set KD_GRAPHICS mode on %s: %m", buff); - goto kbdmode_err; - } - - vtmode.mode = VT_PROCESS; - vtmode.waitv = 0; - vtmode.relsig = SIGUSR1; - vtmode.acqsig = SIGUSR2; - - if (ioctl(dev->tty.fd, VT_SETMODE, &vtmode) < 0) - { - ERR("Could not take over virtual terminal: %m"); - goto mode_err; - } + if (!ecore_drm_tty_open(dev, buff)) + return EINA_FALSE; return EINA_TRUE; - -mode_err: - ioctl(dev->tty.fd, KDSETMODE, KD_TEXT); -kbdmode_err: - ioctl(dev->tty.fd, KDSKBMUTE, 0); - ioctl(dev->tty.fd, KDSKBMODE, dev->tty.kbd_mode); -stat_err: - close(dev->tty.fd); - return EINA_FALSE; -} - -static void -_ecore_drm_logind_vt_destroy(Ecore_Drm_Device *dev) -{ - _ecore_drm_logind_restore(dev); - close(dev->tty.fd); } static Eina_Bool @@ -252,7 +190,7 @@ _ecore_drm_logind_disconnect(Ecore_Drm_Device *dev) if (active_hdlr) ecore_event_handler_del(active_hdlr); active_hdlr = NULL; - _ecore_drm_logind_vt_destroy(dev); + ecore_drm_tty_close(dev); _ecore_drm_dbus_session_release(); _ecore_drm_dbus_shutdown(); } @@ -260,15 +198,7 @@ _ecore_drm_logind_disconnect(Ecore_Drm_Device *dev) void _ecore_drm_logind_restore(Ecore_Drm_Device *dev) { - struct vt_mode vtmode = { 0, 0, SIGUSR1, SIGUSR2, 0 }; - - if ((!dev) || (dev->tty.fd < 0)) return; - - ioctl(dev->tty.fd, KDSETMODE, KD_TEXT); - ioctl(dev->tty.fd, KDSKBMUTE, 0); - ioctl(dev->tty.fd, KDSKBMODE, dev->tty.kbd_mode); - vtmode.mode = VT_AUTO; - ioctl(dev->tty.fd, VT_SETMODE, &vtmode); + _ecore_drm_tty_restore(dev); } Eina_Bool |