From 116045fb8c7b1f5b5686153453f081178b8160d7 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Thu, 20 Feb 2014 15:04:59 +0000 Subject: [PATCH] Tiling2: Merge all the tiling callbacks and checks to 1 place. --- src/modules/tiling/e_mod_tiling.c | 84 +++++++++++++++------------------------ 1 file changed, 31 insertions(+), 53 deletions(-) diff --git a/src/modules/tiling/e_mod_tiling.c b/src/modules/tiling/e_mod_tiling.c index f9320f5..19777f5 100644 --- a/src/modules/tiling/e_mod_tiling.c +++ b/src/modules/tiling/e_mod_tiling.c @@ -187,6 +187,9 @@ is_tilable(const E_Client *ec) if (ec->iconic) return false; + if (ec->sticky) + return false; + if (e_client_util_ignored_get(ec)) return false; @@ -1116,24 +1119,33 @@ _remove_hook(void *data EINA_UNUSED, int type EINA_UNUSED, return true; } -static bool -_iconify_hook(void *data EINA_UNUSED, int type EINA_UNUSED, - E_Event_Client *event) +static void +_toggle_tiling_based_on_state(E_Client *ec, Eina_Bool restore) { - E_Client *ec = event->ec; - - DBG("iconify hook: %p", ec); - - if (ec->deskshow) - return true; + Client_Extra *extra = eina_hash_find(_G.client_extras, &ec); - _remove_client(ec); + if (!extra) + { + return; + } - return true; + /* This is the new state, act accordingly. */ + if (extra->tiled && !is_tilable(ec)) + { + if (restore) + { + _restore_client(ec); + } + _remove_client(ec); + } + else if (!extra->tiled && is_tilable(ec)) + { + _add_client(ec); + } } static bool -_uniconify_hook(void *data EINA_UNUSED, int type EINA_UNUSED, +_iconify_hook(void *data EINA_UNUSED, int type EINA_UNUSED, E_Event_Client *event) { E_Client *ec = event->ec; @@ -1141,63 +1153,29 @@ _uniconify_hook(void *data EINA_UNUSED, int type EINA_UNUSED, if (ec->deskshow) return true; - _add_client(ec); + _toggle_tiling_based_on_state(ec, EINA_FALSE); return true; } static bool -_fullscreen_hook(void *data EINA_UNUSED, int type EINA_UNUSED, +_toggle_tiling_hook(void *data EINA_UNUSED, int type EINA_UNUSED, E_Event_Client *event) { E_Client *ec = event->ec; - _restore_client_no_sizing(ec); - _remove_client(ec); - - return true; -} - -static bool -_unfullscreen_hook(void *data EINA_UNUSED, int type EINA_UNUSED, - E_Event_Client *event) -{ - E_Client *ec = event->ec; - - _add_client(ec); + _toggle_tiling_based_on_state(ec, EINA_TRUE); return true; } -static void -toggle_sticky(E_Client *ec) -{ - Client_Extra *extra = tiling_entry_func(ec); - - if (!extra) - { - return; - } - - /* This is the new state, act accordingly. */ - if (ec->sticky) - { - _restore_client(ec); - _remove_client(ec); - } - else - { - _add_client(ec); - } -} - static Eina_Bool _property_hook(void *data EINA_UNUSED, int type EINA_UNUSED, E_Event_Client_Property *event) { if (event->property & E_CLIENT_PROPERTY_STICKY) { - toggle_sticky(event->ec); + _toggle_tiling_based_on_state(event->ec, EINA_TRUE); } return true; } @@ -1342,9 +1320,9 @@ e_modapi_init(E_Module *m) HANDLER(_G.handler_client_remove, CLIENT_REMOVE, _remove_hook); HANDLER(_G.handler_client_iconify, CLIENT_ICONIFY, _iconify_hook); - HANDLER(_G.handler_client_uniconify, CLIENT_UNICONIFY, _uniconify_hook); - HANDLER(_G.handler_client_fullscreen, CLIENT_FULLSCREEN, _fullscreen_hook); - HANDLER(_G.handler_client_unfullscreen, CLIENT_UNFULLSCREEN, _unfullscreen_hook); + HANDLER(_G.handler_client_uniconify, CLIENT_UNICONIFY, _iconify_hook); + HANDLER(_G.handler_client_fullscreen, CLIENT_FULLSCREEN, _toggle_tiling_hook); + HANDLER(_G.handler_client_unfullscreen, CLIENT_UNFULLSCREEN, _toggle_tiling_hook); HANDLER(_G.handler_client_property, CLIENT_PROPERTY, _property_hook); HANDLER(_G.handler_desk_set, CLIENT_DESK_SET, _desk_set_hook); -- 2.7.4