From 94e1f82e232a1be3615e0f5c702b521609ec7624 Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Sun, 17 Feb 2013 14:45:00 +0000 Subject: [PATCH] some work on contact... SVN revision: 84024 --- src/modules/contact/e_mod_main.c | 48 ++++++++++++++++++++++++++++ src/modules/contact/e_policy.c | 54 +++++++++++++++++++++++++++++--- src/modules/contact/e_policy.h | 2 ++ 3 files changed, 100 insertions(+), 4 deletions(-) diff --git a/src/modules/contact/e_mod_main.c b/src/modules/contact/e_mod_main.c index bdad7e4ec..186e34c56 100644 --- a/src/modules/contact/e_mod_main.c +++ b/src/modules/contact/e_mod_main.c @@ -7,6 +7,30 @@ _cb_in_left(void *data, int d, double v) { // show PREV window in list from urrent focused window on top of current // window but in an inital "off to the right" state in comp + Eina_List *borders = (Eina_List *)e_policy_borders_get(); + E_Border *bd_active = (E_Border *)e_polict_border_active_get(); + E_Border *bd = NULL; + Eina_List *bd_active_l = NULL; + if (!bd_active) + { + if (!borders) return; + bd = eina_list_last(borders)->data; + } + if (!bd) + { + if (bd_active) + bd_active_l = eina_list_data_find_list(borders, bd_active); + if ((bd_active_l) && (bd_active_l->prev)) bd = bd_active_l->prev->data; + } + if ((!bd) && (bd_active)) + { + e_border_iconify(bd_active); + return; + } + if (!bd) return; + e_border_uniconify(bd); + e_border_raise(bd); + e_border_show(bd); } static void @@ -21,6 +45,30 @@ _cb_in_right(void *data, int d, double v) { // show NEXT window in list from urrent focused window on top of current // window but in an inital "off to the right" state in comp + Eina_List *borders = (Eina_List *)e_policy_borders_get(); + E_Border *bd_active = (E_Border *)e_polict_border_active_get(); + E_Border *bd = NULL; + Eina_List *bd_active_l = NULL; + if (!bd_active) + { + if (!borders) return; + bd = borders->data; + } + if (!bd) + { + if (bd_active) + bd_active_l = eina_list_data_find_list(borders, bd_active); + if ((bd_active_l) && (bd_active_l->next)) bd = bd_active_l->next->data; + } + if ((!bd) && (bd_active)) + { + e_border_iconify(bd_active); + return; + } + if (!bd) return; + e_border_uniconify(bd); + e_border_raise(bd); + e_border_show(bd); } static void diff --git a/src/modules/contact/e_policy.c b/src/modules/contact/e_policy.c index c5dd4b3b4..f4c40d08a 100644 --- a/src/modules/contact/e_policy.c +++ b/src/modules/contact/e_policy.c @@ -1,5 +1,7 @@ #include "e_mod_main.h" +static Eina_Bool _cb_event_add(void *data __UNUSED__, int type __UNUSED__, void *event); +static Eina_Bool _cb_event_del(void *data __UNUSED__, int type __UNUSED__, void *event); static Eina_Bool _cb_event_focus_in(void *data __UNUSED__, int type __UNUSED__, void *event); static Eina_Bool _cb_event_focus_out(void *data __UNUSED__, int type __UNUSED__, void *event); static void _cb_hook_post_fetch(void *data __UNUSED__, void *data2); @@ -9,8 +11,10 @@ static void _cb_hook_layout(void *data __UNUSED__, void *data2); static Eina_List *hooks = NULL; static Eina_List *handlers = NULL; -static Eina_Bool kbd_on = EINA_FALSE; -static Eina_Bool kbd_override = EINA_FALSE; +static Eina_Bool kbd_on = EINA_FALSE; +static Eina_Bool kbd_override = EINA_FALSE; +static Eina_List *borders = NULL; +static E_Border *bd_active = NULL; #define LADD(l, f) l = eina_list_append(l, f) @@ -23,6 +27,10 @@ e_policy_init(void) _cb_hook_post_assign, NULL)); LADD(hooks, e_border_hook_add(E_BORDER_HOOK_CONTAINER_LAYOUT, _cb_hook_layout, NULL)); + LADD(handlers, ecore_event_handler_add(E_EVENT_BORDER_ADD, + _cb_event_add, NULL)); + LADD(handlers, ecore_event_handler_add(E_EVENT_BORDER_REMOVE, + _cb_event_del, NULL)); LADD(handlers, ecore_event_handler_add(E_EVENT_BORDER_FOCUS_IN, _cb_event_focus_in, NULL)); LADD(handlers, ecore_event_handler_add(E_EVENT_BORDER_FOCUS_OUT, @@ -63,19 +71,57 @@ e_policy_kbd_override_set(Eina_Bool override) } } +const Eina_List * +e_policy_borders_get(void) +{ + return borders; +} + +const E_Border * +e_polict_border_active_get(void) +{ + return bd_active; +} + +static Eina_Bool +_cb_event_add(void *data __UNUSED__, int type __UNUSED__, void *event) +{ + E_Event_Border_Add *ev = event; + E_Border *bd = ev->border; + + if (bd_active) borders = eina_list_append_relative(borders, bd, bd_active); + else borders = eina_list_prepend(borders, bd); + return ECORE_CALLBACK_PASS_ON; +} + +static Eina_Bool +_cb_event_del(void *data __UNUSED__, int type __UNUSED__, void *event) +{ + E_Event_Border_Remove *ev = event; + E_Border *bd = ev->border; + + borders = eina_list_remove(borders, bd); + if (bd_active == bd) bd_active = NULL; + return ECORE_CALLBACK_PASS_ON; +} + static Eina_Bool _cb_event_focus_in(void *data __UNUSED__, int type __UNUSED__, void *event) { - E_Border *bd = event; + E_Event_Border_Focus_In *ev = event; + E_Border *bd = ev->border; + bd_active = bd; return ECORE_CALLBACK_PASS_ON; } static Eina_Bool _cb_event_focus_out(void *data __UNUSED__, int type __UNUSED__, void *event) { - E_Border *bd = event; + E_Event_Border_Focus_Out *ev = event; + E_Border *bd = ev->border; + if (bd_active == bd) bd_active = NULL; if (kbd_on) e_policy_kbd_override_set(EINA_FALSE); return ECORE_CALLBACK_PASS_ON; } diff --git a/src/modules/contact/e_policy.h b/src/modules/contact/e_policy.h index 44df36a5f..6c98fca2a 100644 --- a/src/modules/contact/e_policy.h +++ b/src/modules/contact/e_policy.h @@ -4,5 +4,7 @@ void e_policy_init(void); void e_policy_shutdown(void); void e_policy_kbd_override_set(Eina_Bool override); +const Eina_List *e_policy_borders_get(void); +const E_Border *e_polict_border_active_get(void); #endif