From e5e2a7cca4bf86ee70444b52ec0640888601d503 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Fri, 22 Jan 2016 16:23:21 -0500 Subject: [PATCH] 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 0174bbb6b..1663a9ee7 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