discomfitor pushed a commit to branch master.

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

commit 446f9c4b682085b6ee2af73ee4cf02d093a3645f
Author: Mike Blumenkrantz <zm...@osg.samsung.com>
Date:   Fri Jan 22 16:23:21 2016 -0500

    defer screenshot action execution using a job
    
    the drm screenshot action forcefully iterates the main loop, causing
    the current loop (which triggered the action) to return after the screenshot
    action has ended. during this time, it's possible for other actions to also
    trigger, including triggering subsequent screenshot actions, so it's 
necessary
    to defer the execution of the action until after the initial loop which 
triggered
    the action has returned
    
     #Recursion
---
 src/modules/shot/e_mod_main.c | 33 +++++++++++++++++++++++++++++----
 1 file changed, 29 insertions(+), 4 deletions(-)

diff --git a/src/modules/shot/e_mod_main.c b/src/modules/shot/e_mod_main.c
index 0174bbb..1663a9e 100644
--- a/src/modules/shot/e_mod_main.c
+++ b/src/modules/shot/e_mod_main.c
@@ -1193,10 +1193,31 @@ _e_mod_action_border_cb(E_Object *obj EINA_UNUSED, 
const char *params EINA_UNUSE
      _wl_shot_now(NULL, ec, NULL);
 }
 
+typedef struct
+{
+   E_Zone *zone;
+   char *params;
+} Delayed_Shot;
+
+static void
+_delayed_shot(void *data)
+{
+   Delayed_Shot *ds = data;
+
+   if (e_comp->comp_type == E_PIXMAP_TYPE_X)
+     _x_shot_now(ds->zone, NULL, ds->params);
+   else
+     _wl_shot_now(ds->zone, NULL, ds->params);
+   e_object_unref(E_OBJECT(ds->zone));
+   free(ds->params);
+   free(ds);
+}
+
 static void
 _e_mod_action_cb(E_Object *obj, const char *params)
 {
    E_Zone *zone = NULL;
+   Delayed_Shot *ds;
 
    if (obj)
      {
@@ -1210,10 +1231,14 @@ _e_mod_action_cb(E_Object *obj, const char *params)
    if (!zone) zone = e_zone_current_get();
    if (!zone) return;
    E_FREE_FUNC(timer, ecore_timer_del);
-   if (e_comp->comp_type == E_PIXMAP_TYPE_X)
-     _x_shot_now(zone, NULL, params);
-   else
-     _wl_shot_now(zone, NULL, params);
+   ds = E_NEW(Delayed_Shot, 1);
+   e_object_ref(E_OBJECT(zone));
+   ds->zone = zone;
+   ds->params = params ? strdup(params) : NULL;
+   /* forced main loop iteration in screenshots causes bugs if the action
+    * executes immediately
+    */
+   ecore_job_add(_delayed_shot, ds);
 }
 
 static void

-- 


Reply via email to