diff options
author | Chris Michael <cpmichael@osg.samsung.com> | 2016-05-09 11:35:48 -0400 |
---|---|---|
committer | Chris Michael <cpmichael@osg.samsung.com> | 2016-05-09 11:35:48 -0400 |
commit | f9149c1699515c060d004225c6a2c5653cebe322 (patch) | |
tree | d334079803dda24320ac438e07ee4859a3cb37e3 | |
parent | a96266c42272bd6b8d3a27d7fdd7575199772c85 (diff) |
elput: Add API function to switch to a given vt
This patch adds a new API function to Elput that can be used to switch
to a given VT. This allows drm2 or enlightenment to switch to a given
virtual terminal in response to keybindings.
@feature
Signed-off-by: Chris Michael <cpmichael@osg.samsung.com>
-rw-r--r-- | src/lib/elput/Elput.h | 13 | ||||
-rw-r--r-- | src/lib/elput/elput_logind.c | 50 | ||||
-rw-r--r-- | src/lib/elput/elput_manager.c | 13 | ||||
-rw-r--r-- | src/lib/elput/elput_private.h | 1 |
4 files changed, 77 insertions, 0 deletions
diff --git a/src/lib/elput/Elput.h b/src/lib/elput/Elput.h index 95adfce052..d38569d344 100644 --- a/src/lib/elput/Elput.h +++ b/src/lib/elput/Elput.h | |||
@@ -206,6 +206,19 @@ EAPI int elput_manager_open(Elput_Manager *manager, const char *path, int flags) | |||
206 | EAPI void elput_manager_close(Elput_Manager *manager, int fd); | 206 | EAPI void elput_manager_close(Elput_Manager *manager, int fd); |
207 | 207 | ||
208 | /** | 208 | /** |
209 | * Request to switch to a given vt | ||
210 | * | ||
211 | * @param manager | ||
212 | * @param vt | ||
213 | * | ||
214 | * @return EINA_TRUE on success, EINA_FALSE otherwise | ||
215 | * | ||
216 | * @ingroup Elput_Manager_Group | ||
217 | * @since 1.18 | ||
218 | */ | ||
219 | EAPI Eina_Bool elput_manager_vt_set(Elput_Manager *manager, int vt); | ||
220 | |||
221 | /** | ||
209 | * @defgroup Elput_Input_Group Elput input functions | 222 | * @defgroup Elput_Input_Group Elput input functions |
210 | * | 223 | * |
211 | * Functions that deal with setup of inputs | 224 | * Functions that deal with setup of inputs |
diff --git a/src/lib/elput/elput_logind.c b/src/lib/elput/elput_logind.c index 123861a5ff..394fca5465 100644 --- a/src/lib/elput/elput_logind.c +++ b/src/lib/elput/elput_logind.c | |||
@@ -574,12 +574,62 @@ _logind_close(Elput_Manager *em, int fd) | |||
574 | _logind_device_release(em, major(st.st_rdev), minor(st.st_rdev)); | 574 | _logind_device_release(em, major(st.st_rdev), minor(st.st_rdev)); |
575 | } | 575 | } |
576 | 576 | ||
577 | static Eina_Bool | ||
578 | _logind_vt_set(Elput_Manager *em, int vt) | ||
579 | { | ||
580 | Eldbus_Object *obj; | ||
581 | Eldbus_Proxy *proxy; | ||
582 | Eldbus_Message *msg; | ||
583 | char self[PATH_MAX]; | ||
584 | |||
585 | snprintf(self, sizeof(self), "/org/freedesktop/login1/seat/self"); | ||
586 | |||
587 | obj = eldbus_object_get(em->dbus.conn, "org.freedesktop.login1", self); | ||
588 | if (!obj) | ||
589 | { | ||
590 | ERR("Could not get dbus object"); | ||
591 | goto obj_err; | ||
592 | } | ||
593 | |||
594 | proxy = eldbus_proxy_get(obj, "org.freedesktop.login1.Seat"); | ||
595 | if (!proxy) | ||
596 | { | ||
597 | ERR("Could not get dbus proxy"); | ||
598 | goto proxy_err; | ||
599 | } | ||
600 | |||
601 | msg = eldbus_proxy_method_call_new(proxy, "SwitchTo"); | ||
602 | if (!msg) | ||
603 | { | ||
604 | ERR("Could not create method call for proxy"); | ||
605 | goto msg_err; | ||
606 | } | ||
607 | |||
608 | eldbus_message_arguments_append(msg, "u", &vt); | ||
609 | |||
610 | eldbus_proxy_send(proxy, msg, NULL, NULL, -1); | ||
611 | |||
612 | eldbus_message_unref(msg); | ||
613 | eldbus_proxy_unref(proxy); | ||
614 | eldbus_object_unref(obj); | ||
615 | |||
616 | return EINA_TRUE; | ||
617 | |||
618 | msg_err: | ||
619 | eldbus_proxy_unref(proxy); | ||
620 | proxy_err: | ||
621 | eldbus_object_unref(obj); | ||
622 | obj_err: | ||
623 | return EINA_FALSE; | ||
624 | } | ||
625 | |||
577 | Elput_Interface _logind_interface = | 626 | Elput_Interface _logind_interface = |
578 | { | 627 | { |
579 | _logind_connect, | 628 | _logind_connect, |
580 | _logind_disconnect, | 629 | _logind_disconnect, |
581 | _logind_open, | 630 | _logind_open, |
582 | _logind_close, | 631 | _logind_close, |
632 | _logind_vt_set, | ||
583 | }; | 633 | }; |
584 | 634 | ||
585 | #endif | 635 | #endif |
diff --git a/src/lib/elput/elput_manager.c b/src/lib/elput/elput_manager.c index 3dc67d9594..e267951b30 100644 --- a/src/lib/elput/elput_manager.c +++ b/src/lib/elput/elput_manager.c | |||
@@ -62,3 +62,16 @@ elput_manager_close(Elput_Manager *manager, int fd) | |||
62 | if (manager->interface->close) | 62 | if (manager->interface->close) |
63 | manager->interface->close(manager, fd); | 63 | manager->interface->close(manager, fd); |
64 | } | 64 | } |
65 | |||
66 | EAPI Eina_Bool | ||
67 | elput_manager_vt_set(Elput_Manager *manager, int vt) | ||
68 | { | ||
69 | EINA_SAFETY_ON_NULL_RETURN_VAL(manager, EINA_FALSE); | ||
70 | EINA_SAFETY_ON_NULL_RETURN_VAL(manager->interface, EINA_FALSE); | ||
71 | EINA_SAFETY_ON_TRUE_RETURN_VAL((vt < 0), EINA_FALSE); | ||
72 | |||
73 | if (manager->interface->vt_set) | ||
74 | return manager->interface->vt_set(manager, vt); | ||
75 | |||
76 | return EINA_FALSE; | ||
77 | } | ||
diff --git a/src/lib/elput/elput_private.h b/src/lib/elput/elput_private.h index 05ee0b1a37..769d23c82d 100644 --- a/src/lib/elput/elput_private.h +++ b/src/lib/elput/elput_private.h | |||
@@ -72,6 +72,7 @@ typedef struct _Elput_Interface | |||
72 | void (*disconnect)(Elput_Manager *manager); | 72 | void (*disconnect)(Elput_Manager *manager); |
73 | int (*open)(Elput_Manager *manager, const char *path, int flags); | 73 | int (*open)(Elput_Manager *manager, const char *path, int flags); |
74 | void (*close)(Elput_Manager *manager, int fd); | 74 | void (*close)(Elput_Manager *manager, int fd); |
75 | Eina_Bool (*vt_set)(Elput_Manager *manager, int vt); | ||
75 | } Elput_Interface; | 76 | } Elput_Interface; |
76 | 77 | ||
77 | typedef struct _Elput_Input | 78 | typedef struct _Elput_Input |