raster pushed a commit to branch master.

http://git.enlightenment.org/core/enlightenment.git/commit/?id=cbe3858b159b8620cd51f0ea549a98ae108afaa1

commit cbe3858b159b8620cd51f0ea549a98ae108afaa1
Author: Carsten Haitzler (Rasterman) <[email protected]>
Date:   Sat Dec 15 15:54:46 2018 +0000

    desklock - add explicit manually invoked api and a blocking api
    
    this is so parts of e (moduels etc.) could block a lock for some
    reason and differentiate between an automatic lock and a manually
    invoked one.
---
 src/bin/e_actions.c                 |  2 +-
 src/bin/e_desklock.c                | 68 ++++++++++++++++++++++++++++++++++---
 src/bin/e_desklock.h                |  5 +++
 src/bin/e_main.c                    |  2 +-
 src/modules/msgbus/msgbus_desktop.c |  2 +-
 5 files changed, 72 insertions(+), 7 deletions(-)

diff --git a/src/bin/e_actions.c b/src/bin/e_actions.c
index 1e3f525f1..bdf823172 100644
--- a/src/bin/e_actions.c
+++ b/src/bin/e_actions.c
@@ -2543,7 +2543,7 @@ ACT_FN_GO(desk_lock, EINA_UNUSED)
 
    zone = _e_actions_zone_get(obj);
    if (zone)*/
-   e_desklock_show(EINA_FALSE);
+   e_desklock_show_manual(EINA_FALSE);
 }
 
 /***************************************************************************/
diff --git a/src/bin/e_desklock.c b/src/bin/e_desklock.c
index d3fd342b0..fa2a47ec6 100644
--- a/src/bin/e_desklock.c
+++ b/src/bin/e_desklock.c
@@ -35,6 +35,10 @@ static Eina_List *desklock_ifaces = NULL;
 static E_Desklock_Interface *current_iface = NULL;
 static Eina_Bool demo = EINA_FALSE;
 
+static Eina_Bool _e_desklock_want = EINA_FALSE;
+static int _e_desklock_block = 0;
+static Eina_Bool desklock_manual = EINA_FALSE;
+
 /***********************************************************************/
 static Eina_Bool _e_desklock_cb_custom_desklock_exit(void *data EINA_UNUSED, 
int type EINA_UNUSED, void *event);
 static Eina_Bool _e_desklock_cb_idle_poller(void *data EINA_UNUSED);
@@ -237,8 +241,8 @@ e_desklock_demo(void)
    return EINA_FALSE;
 }
 
-E_API int
-e_desklock_show(Eina_Bool suspend)
+static int
+_desklock_show_internal(Eina_Bool suspend)
 {
    const Eina_List *l;
    E_Event_Desklock *ev;
@@ -372,8 +376,16 @@ fail:
    return 0;
 }
 
-E_API void
-e_desklock_hide(void)
+E_API int
+e_desklock_show(Eina_Bool suspend)
+{
+   _e_desklock_want = EINA_TRUE;
+   if ((_e_desklock_block > 0) && (!desklock_manual)) return;
+   return _desklock_show_internal(suspend);
+}
+
+static void
+_desklock_hide_internal(void)
 {
    Eina_List *l;
    E_Event_Desklock *ev;
@@ -458,12 +470,60 @@ e_desklock_hide(void)
    if (getenv("E_START_MANAGER")) kill(getppid(), SIGHUP);
 }
 
+E_API int
+e_desklock_show_manual(Eina_Bool suspend)
+{
+   desklock_manual = EINA_TRUE;
+   return e_desklock_show(suspend);
+}
+
+E_API Eina_Bool
+e_desklock_manual_get(void)
+{
+   return desklock_manual;
+}
+
+E_API void
+e_desklock_hide(void)
+{
+   desklock_manual = EINA_FALSE;
+   _e_desklock_want = EINA_FALSE;
+   _desklock_hide_internal();
+}
+
 E_API Eina_Bool
 e_desklock_state_get(void)
 {
    return _e_desklock_state;
 }
 
+E_API void
+e_desklock_block(void)
+{
+   _e_desklock_block++;
+   if (_e_desklock_block == 1)
+     {
+        if (!desklock_manual)
+          {
+             if (_e_desklock_state) _desklock_hide_internal();
+          }
+     }
+}
+
+E_API void
+e_desklock_unblock(void)
+{
+   _e_desklock_block--;
+   if (_e_desklock_block == 0)
+     {
+        if (_e_desklock_want) e_desklock_show(EINA_FALSE);
+     }
+   else if (_e_desklock_block < 0)
+     {
+        ERR("desklock block going below zero");
+     }
+}
+
 static Eina_Bool
 _e_desklock_cb_custom_desklock_exit(void *data EINA_UNUSED, int type 
EINA_UNUSED, void *event)
 {
diff --git a/src/bin/e_desklock.h b/src/bin/e_desklock.h
index 10cd24888..48c03ce58 100644
--- a/src/bin/e_desklock.h
+++ b/src/bin/e_desklock.h
@@ -49,9 +49,14 @@ EINTERN int e_desklock_shutdown(void);
 E_API Eina_Bool e_desklock_demo(void);
 E_API int e_desklock_show(Eina_Bool suspend);
 E_API int e_desklock_show_autolocked(void);
+E_API int e_desklock_show_manual(Eina_Bool suspend);
+E_API Eina_Bool e_desklock_manual_get(void);
 E_API void e_desklock_hide(void);
 E_API Eina_Bool e_desklock_state_get(void);
 
+E_API void e_desklock_block(void);
+E_API void e_desklock_unblock(void);
+
 E_API void e_desklock_interface_append(E_Desklock_Interface *iface);
 E_API void e_desklock_interface_remove(E_Desklock_Interface *iface);
 EINTERN E_Desklock_Interface *e_desklock_interface_current_get(void);
diff --git a/src/bin/e_main.c b/src/bin/e_main.c
index be0d9901a..73be9f84d 100644
--- a/src/bin/e_main.c
+++ b/src/bin/e_main.c
@@ -820,7 +820,7 @@ main(int argc, char **argv)
 
    if (waslocked || (locked && ((!after_restart))))
      {
-        e_desklock_show(EINA_TRUE);
+        e_desklock_show_manual(EINA_TRUE);
         e_screensaver_update();
      }
 
diff --git a/src/modules/msgbus/msgbus_desktop.c 
b/src/modules/msgbus/msgbus_desktop.c
index cb298e9ca..ddae5d659 100644
--- a/src/modules/msgbus/msgbus_desktop.c
+++ b/src/modules/msgbus/msgbus_desktop.c
@@ -79,7 +79,7 @@ cb_desktop_lock(const Eldbus_Service_Interface *iface 
EINA_UNUSED,
                 const Eldbus_Message *msg)
 {
    DBG("desklock requested");
-   e_desklock_show(EINA_FALSE);
+   e_desklock_show_manual(EINA_FALSE);
    return eldbus_message_method_return_new(msg);
 }
 

-- 


Reply via email to