devilhorns pushed a commit to branch master. http://git.enlightenment.org/core/efl.git/commit/?id=5720a350f995c017efc1bf5d4472856dc7552962
commit 5720a350f995c017efc1bf5d4472856dc7552962 Author: Seunghun Lee <[email protected]> Date: Wed Dec 10 12:12:21 2014 -0500 ecore-drm: Add event to notify session activation state. Summary: this event is to notify session activation state to compositor. thus compositor can change composite state by this event. Reviewers: devilhorns Subscribers: torori, cedric Differential Revision: https://phab.enlightenment.org/D1767 --- src/lib/ecore_drm/Ecore_Drm.h | 10 +++++ src/lib/ecore_drm/ecore_drm.c | 21 ++++++++++ src/lib/ecore_drm/ecore_drm_dbus.c | 12 ++---- src/lib/ecore_drm/ecore_drm_logind.c | 75 ++++++++++++++++++++--------------- src/lib/ecore_drm/ecore_drm_private.h | 2 + src/lib/ecore_drm/ecore_drm_tty.c | 4 ++ 6 files changed, 85 insertions(+), 39 deletions(-) diff --git a/src/lib/ecore_drm/Ecore_Drm.h b/src/lib/ecore_drm/Ecore_Drm.h index 3238a20..7a65273 100644 --- a/src/lib/ecore_drm/Ecore_Drm.h +++ b/src/lib/ecore_drm/Ecore_Drm.h @@ -108,6 +108,11 @@ struct _Ecore_Drm_Device unsigned int window; }; +struct _Ecore_Drm_Event_Activate +{ + Eina_Bool active; +}; + /* opaque structure to represent a drm device */ typedef struct _Ecore_Drm_Device Ecore_Drm_Device; @@ -129,6 +134,11 @@ typedef struct _Ecore_Drm_Seat Ecore_Drm_Seat; /* opaque structure to represent a drm sprite */ typedef struct _Ecore_Drm_Sprite Ecore_Drm_Sprite; +/* sturcture to inform drm activation state */ +typedef struct _Ecore_Drm_Event_Activate Ecore_Drm_Event_Activate; + +EAPI extern int ECORE_DRM_EVENT_ACTIVATE; + /** * @file * @brief Ecore functions for dealing with drm, virtual terminals diff --git a/src/lib/ecore_drm/ecore_drm.c b/src/lib/ecore_drm/ecore_drm.c index 6413270..1bbd49c 100644 --- a/src/lib/ecore_drm/ecore_drm.c +++ b/src/lib/ecore_drm/ecore_drm.c @@ -2,6 +2,7 @@ # include "config.h" #endif +#include "Ecore_Drm.h" #include "ecore_drm_private.h" /* local variables */ @@ -10,6 +11,24 @@ static int _ecore_drm_init_count = 0; /* external variables */ int _ecore_drm_log_dom = -1; +EAPI int ECORE_DRM_EVENT_ACTIVATE = 0; + +static void +_ecore_drm_event_activate_free(void *data EINA_UNUSED, void *event) +{ + free(event); +} + +void +_ecore_drm_event_activate_send(Eina_Bool active) +{ + Ecore_Drm_Event_Activate *e; + + e = calloc(1, sizeof(Ecore_Drm_Event_Activate)); + e->active = active; + ecore_event_add(ECORE_DRM_EVENT_ACTIVATE, e, _ecore_drm_event_activate_free, NULL); +} + /** * @defgroup Ecore_Drm_Init_Group Drm Library Init and Shutdown Functions * @@ -67,6 +86,8 @@ ecore_drm_init(void) /* try to init eeze */ if (!eeze_init()) goto eeze_err; + ECORE_DRM_EVENT_ACTIVATE = ecore_event_type_new(); + /* return init count */ return _ecore_drm_init_count; diff --git a/src/lib/ecore_drm/ecore_drm_dbus.c b/src/lib/ecore_drm/ecore_drm_dbus.c index bfac33f..9eb7570 100644 --- a/src/lib/ecore_drm/ecore_drm_dbus.c +++ b/src/lib/ecore_drm/ecore_drm_dbus.c @@ -68,10 +68,8 @@ _cb_device_paused(void *ctxt EINA_UNUSED, const Eldbus_Message *msg) _ecore_drm_dbus_device_pause_done(maj, min); } - /* if (maj == DRM_MAJOR) */ - /* { */ - /* // emit paused to compositor */ - /* } */ + if (maj == DRM_MAJOR) + _ecore_drm_event_activate_send(EINA_FALSE); } } @@ -90,10 +88,8 @@ _cb_device_resumed(void *ctxt EINA_UNUSED, const Eldbus_Message *msg) if (eldbus_message_arguments_get(msg, "uuh", &maj, &min, &fd)) { - /* if (maj == DRM_MAJOR) */ - /* { */ - /* // emit active to compositor */ - /* } */ + if (maj == DRM_MAJOR) + _ecore_drm_event_activate_send(EINA_TRUE); } } diff --git a/src/lib/ecore_drm/ecore_drm_logind.c b/src/lib/ecore_drm/ecore_drm_logind.c index 45ac877..332eccb 100644 --- a/src/lib/ecore_drm/ecore_drm_logind.c +++ b/src/lib/ecore_drm/ecore_drm_logind.c @@ -10,6 +10,7 @@ # define KDSKBMUTE 0x4B51 #endif +Ecore_Event_Handler *active_hdl; static char *sid; static Eina_Bool @@ -52,15 +53,40 @@ _ecore_drm_logind_cb_vt_signal(void *data, int type EINA_UNUSED, void *event) if (ev->number == 1) { - Ecore_Drm_Input *input; - Ecore_Drm_Output *output; - Ecore_Drm_Sprite *sprite; - Eina_List *l; + if (!ecore_drm_tty_release(dev)) + ERR("Could not release VT: %m"); + } + else if (ev->number == 2) + { + if (!ecore_drm_tty_acquire(dev)) + ERR("Could not acquire VT: %m"); + } + + return ECORE_CALLBACK_PASS_ON; +} - /* disable inputs (suspends) */ - EINA_LIST_FOREACH(dev->inputs, l, input) - ecore_drm_inputs_disable(input); +static Eina_Bool +_ecore_drm_logind_cb_activate(void *data, int type EINA_UNUSED, void *event) +{ + Ecore_Drm_Event_Activate *e; + Ecore_Drm_Device *dev; + Ecore_Drm_Sprite *sprite; + Ecore_Drm_Output *output; + Eina_List *l; + + + if ((!event) || (!data)) return ECORE_CALLBACK_RENEW; + e = event; + dev = data; + if (e->active) + { + /* set output mode */ + EINA_LIST_FOREACH(dev->outputs, l, output) + ecore_drm_output_enable(output); + } + else + { /* disable hardware cursor */ EINA_LIST_FOREACH(dev->outputs, l, output) ecore_drm_output_cursor_size_set(output, 0, 0, 0); @@ -68,34 +94,12 @@ _ecore_drm_logind_cb_vt_signal(void *data, int type EINA_UNUSED, void *event) /* disable sprites */ EINA_LIST_FOREACH(dev->sprites, l, sprite) ecore_drm_sprites_fb_set(sprite, 0, 0); - - if (!ecore_drm_tty_release(dev)) - ERR("Could not release VT: %m"); - } - else if (ev->number == 2) - { - if (ecore_drm_tty_acquire(dev)) - { - Ecore_Drm_Output *output; - Ecore_Drm_Input *input; - Eina_List *l; - - /* set output mode */ - EINA_LIST_FOREACH(dev->outputs, l, output) - ecore_drm_output_enable(output); - - /* enable inputs */ - EINA_LIST_FOREACH(dev->inputs, l, input) - ecore_drm_inputs_enable(input); - } - else - ERR("Could not acquire VT: %m"); } return ECORE_CALLBACK_PASS_ON; } -static Eina_Bool +static Eina_Bool _ecore_drm_logind_tty_setup(Ecore_Drm_Device *dev) { struct stat st; @@ -160,7 +164,6 @@ err_kmode: return EINA_FALSE; } - static Eina_Bool _ecore_drm_logind_vt_open(Ecore_Drm_Device *dev, const char *name) { @@ -222,6 +225,10 @@ _ecore_drm_logind_vt_open(Ecore_Drm_Device *dev, const char *name) ecore_event_handler_add(ECORE_EVENT_KEY_DOWN, _ecore_drm_logind_cb_vt_switch, dev); + active_hdl = + ecore_event_handler_add(ECORE_DRM_EVENT_ACTIVATE, + _ecore_drm_logind_cb_activate, dev); + /* set current tty into env */ setenv("ECORE_DRM_TTY", tty, 1); @@ -278,6 +285,12 @@ _ecore_drm_logind_disconnect(Ecore_Drm_Device *dev) { _ecore_drm_logind_vt_close(dev); _ecore_drm_dbus_shutdown(); + + if (active_hdl) + { + ecore_event_handler_del(active_hdl); + active_hdl = NULL; + } } Eina_Bool diff --git a/src/lib/ecore_drm/ecore_drm_private.h b/src/lib/ecore_drm/ecore_drm_private.h index acd61f5..151303f 100644 --- a/src/lib/ecore_drm/ecore_drm_private.h +++ b/src/lib/ecore_drm/ecore_drm_private.h @@ -229,6 +229,8 @@ struct _Ecore_Drm_Sprite typedef void (*Ecore_Drm_Open_Cb)(void *data, int fd, Eina_Bool b); +void _ecore_drm_event_activate_send(Eina_Bool active); + Eina_Bool _ecore_drm_launcher_device_open(const char *device, Ecore_Drm_Open_Cb callback, void *data, int flags); int _ecore_drm_launcher_device_open_no_pending(const char *device, int flags); void _ecore_drm_launcher_device_close(const char *device, int fd); diff --git a/src/lib/ecore_drm/ecore_drm_tty.c b/src/lib/ecore_drm/ecore_drm_tty.c index 6b3652f..5e85a03 100644 --- a/src/lib/ecore_drm/ecore_drm_tty.c +++ b/src/lib/ecore_drm/ecore_drm_tty.c @@ -78,6 +78,8 @@ _ecore_drm_tty_cb_signal(void *data, int type EINA_UNUSED, void *event) } else ERR("Could not drop drm master: %m"); + + _ecore_drm_event_activate_send(EINA_FALSE); } else if (ev->number == 2) { @@ -99,6 +101,8 @@ _ecore_drm_tty_cb_signal(void *data, int type EINA_UNUSED, void *event) /* enable inputs */ EINA_LIST_FOREACH(dev->inputs, l, input) ecore_drm_inputs_enable(input); + + _ecore_drm_event_activate_send(EINA_TRUE); } else ERR("Could not acquire VT: %m"); --
