From 7826261e191da515d5cb5df3cdeb7a8225e2539b Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Wed, 31 Oct 2012 07:50:10 +0000 Subject: [PATCH] e: e_alert now find the composite window by looking at X property insteed of relying on E. SVN revision: 78692 --- src/bin/e.h | 2 +- src/bin/e_alert.c | 18 ++++++++++++--- src/bin/e_alert_main.c | 42 +++++++++++++++++++++++++++++++++-- src/modules/comp/e_mod_comp.c | 4 ++-- 4 files changed, 58 insertions(+), 8 deletions(-) diff --git a/src/bin/e.h b/src/bin/e.h index ca358e2fd..e56c788fb 100644 --- a/src/bin/e.h +++ b/src/bin/e.h @@ -282,7 +282,7 @@ extern EAPI Eina_Bool restart; extern EAPI Eina_Bool e_precache_end; extern EAPI Eina_Bool x_fatal; -extern EAPI unsigned long e_alert_composite_win; +EAPI void e_alert_composite_win(Ecore_X_Window root, Ecore_X_Window win); //#define SMARTERR(args...) abort() #define SMARTERRNR() return diff --git a/src/bin/e_alert.c b/src/bin/e_alert.c index 05f846b80..e24c63f99 100644 --- a/src/bin/e_alert.c +++ b/src/bin/e_alert.c @@ -2,7 +2,7 @@ #include /* public variables */ -EAPI unsigned long e_alert_composite_win = 0; +EAPI unsigned long _e_alert_composite_win = 0; EINTERN int e_alert_init(void) @@ -16,6 +16,19 @@ e_alert_shutdown(void) return 1; } +EAPI void +e_alert_composite_win(Ecore_X_Window root, Ecore_X_Window comp) +{ + Ecore_X_Atom composite_win; + + composite_win = ecore_x_atom_get("_E_COMP_WINDOW"); + + if (comp == 0) + ecore_x_window_prop_property_del(root, composite_win); + else + ecore_x_window_prop_card32_set(root, composite_win, &comp, 1); +} + EAPI void e_alert_show(int sig) { @@ -34,8 +47,7 @@ e_alert_show(int sig) args[2] = alloca(21); snprintf(args[2], 21, "%lu", (long unsigned int)getpid()); - args[3] = alloca(21); - snprintf(args[3], 21, "%lu", e_alert_composite_win); + args[3] = NULL; pid = fork(); if (pid < -1) diff --git a/src/bin/e_alert_main.c b/src/bin/e_alert_main.c index 54eb74e06..5e4112e51 100644 --- a/src/bin/e_alert_main.c +++ b/src/bin/e_alert_main.c @@ -72,8 +72,6 @@ main(int argc, char **argv) sig = atoi(argv[i]); // signal else if (i == 2) pid = atoi(argv[i]); // E's pid - else if (i == 3) - comp_win = atoi(argv[i]); // Composite Alert Window } tmp = getenv("E17_TAINTED"); @@ -181,6 +179,45 @@ _e_alert_create(void) xcb_create_gc(conn, gc, win, mask, mask_list); } +static int +_e_alert_atom_get(const char *name) +{ + xcb_intern_atom_cookie_t cookie; + xcb_intern_atom_reply_t *reply; + int a; + + cookie = xcb_intern_atom_unchecked(conn, 0, strlen(name), name); + reply = xcb_intern_atom_reply(conn, cookie, NULL); + if (!reply) return XCB_ATOM_NONE; + a = reply->atom; + free(reply); + return a; +} + +static int +_e_alert_comp_win_get(void) +{ + xcb_get_property_cookie_t cookie; + xcb_get_property_reply_t *reply; + uint32_t *v; + int r; + int atom_cardinal, atom_composite_win; + + atom_cardinal = _e_alert_atom_get("CARDINAL"); + atom_composite_win = _e_alert_atom_get("_E_COMP_WINDOW"); + + cookie = xcb_get_property_unchecked(conn, 0, screen->root, atom_composite_win, + atom_cardinal, 0, 0x7fffffff); + reply = xcb_get_property_reply(conn, cookie, NULL); + if (!reply) return -1; + + v = xcb_get_property_value(reply); + r = v[0]; + + free(reply); + return r; +} + static void _e_alert_display(void) { @@ -213,6 +250,7 @@ _e_alert_display(void) _e_alert_button_move_resize(btn2, x, WINDOW_HEIGHT - 20 - (fh + 20), w, (fh + 20)); + comp_win = _e_alert_comp_win_get(); if (comp_win) { xcb_rectangle_t rect; diff --git a/src/modules/comp/e_mod_comp.c b/src/modules/comp/e_mod_comp.c index 80aa4fc2f..fdd8f2a2e 100644 --- a/src/modules/comp/e_mod_comp.c +++ b/src/modules/comp/e_mod_comp.c @@ -3685,7 +3685,7 @@ _e_mod_comp_add(E_Manager *man) */ } - if (c->man->num == 0) e_alert_composite_win = c->win; + if (c->man->num == 0) e_alert_composite_win(c->man->root, c->win); if (_comp_mod->conf->engine == ENGINE_GL) { @@ -3891,7 +3891,7 @@ _e_mod_comp_del(E_Comp *c) ecore_x_composite_unredirect_subwindows (c->man->root, ECORE_X_COMPOSITE_UPDATE_MANUAL); ecore_x_composite_render_window_disable(c->win); - if (c->man->num == 0) e_alert_composite_win = 0; + if (c->man->num == 0) e_alert_composite_win(c->man->root, 0); if (c->render_animator) ecore_animator_del(c->render_animator); if (c->new_up_timer) ecore_timer_del(c->new_up_timer); if (c->update_job) ecore_job_del(c->update_job);