From 00616d3fec468afb344f177cd534b93104eaa0a2 Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Thu, 22 Sep 2005 12:47:45 +0000 Subject: [PATCH] wheel bindings! WERD! hard-coded ones for now, need to make these config values that can be set/changed/deleted via ipc and are saved/loaded :) SVN revision: 16847 --- TODO | 4 +- src/bin/e_actions.c | 100 +++++----- src/bin/e_actions.h | 1 + src/bin/e_bindings.c | 351 +++++++++++++++++++++++++++++++-- src/bin/e_bindings.h | 27 ++- src/bin/e_border.c | 47 +++-- src/bin/e_container.c | 6 +- src/bin/e_focus.c | 4 + src/bin/e_popup.c | 85 ++++++++ src/bin/e_winlist.c | 2 + src/modules/pager/e_mod_main.c | 4 + 11 files changed, 535 insertions(+), 96 deletions(-) diff --git a/TODO b/TODO index ca950ca83..dfc7a71a2 100644 --- a/TODO +++ b/TODO @@ -8,7 +8,9 @@ Some of the things (in very short form) that need to be done to E17... BUGS / FIXES ------------------------------------------------------------------------------- -* BUG: dnd from knoqueror on zone 0 to another knoq on zone 1 with xinerama (2 +* BUG: race condition on winlist activate via keypress and the key grab thus + missing the alt key raise sometimes. +* BUG: dnd from konqueror on zone 0 to another konq on zone 1 with xinerama (2 zones) causes segv * BUG: e often forgets what window is focused so ctrl+alt+x for example doesnt close the current focused window... hmmmm diff --git a/src/bin/e_actions.c b/src/bin/e_actions.c index 1147c5ec6..84f511c41 100644 --- a/src/bin/e_actions.c +++ b/src/bin/e_actions.c @@ -18,6 +18,13 @@ } #define ACT_FN_GO_MOUSE(act) \ static void _e_actions_act_##act##_go_mouse(E_Object *obj, char *params, Ecore_X_Event_Mouse_Button_Down *ev) +#define ACT_GO_WHEEL(name) \ + { \ + act = e_action_add(#name); \ + if (act) act->func.go_wheel = _e_actions_act_##name##_go_wheel; \ + } +#define ACT_FN_GO_WHEEL(act) \ + static void _e_actions_act_##act##_go_wheel(E_Object *obj, char *params, Ecore_X_Event_Mouse_Wheel *ev) #define ACT_GO_KEY(name) \ { \ act = e_action_add(#name); \ @@ -395,13 +402,28 @@ ACT_FN_GO(resize) } /***************************************************************************/ +static E_Zone * +_e_actions_zone_get(E_Object *obj) +{ + if (obj) + { + if (obj->type == E_MANAGER_TYPE) + return e_util_zone_current_get((E_Manager *)obj); + else if (obj->type == E_CONTAINER_TYPE) + return e_util_zone_current_get(((E_Container *)obj)->manager); + else if (obj->type == E_ZONE_TYPE) + return e_util_zone_current_get(((E_Zone *)obj)->container->manager); + else + return e_util_zone_current_get(e_manager_current_get()); + } + return e_util_zone_current_get(e_manager_current_get()); +} + ACT_FN_GO(desk_flip_by) { E_Zone *zone; - - if (!obj) return; - if (obj->type != E_MANAGER_TYPE) return; - zone = e_util_zone_current_get((E_Manager *)obj); + + zone = _e_actions_zone_get(obj); if (zone) { if (params) @@ -418,10 +440,8 @@ ACT_FN_GO(desk_flip_by) ACT_FN_GO(desk_flip_to) { E_Zone *zone; - - if (!obj) return; - if (obj->type != E_MANAGER_TYPE) return; - zone = e_util_zone_current_get((E_Manager *)obj); + + zone = _e_actions_zone_get(obj); if (zone) { if (params) @@ -438,10 +458,8 @@ ACT_FN_GO(desk_flip_to) ACT_FN_GO(desk_linear_flip_by) { E_Zone *zone; - - if (!obj) return; - if (obj->type != E_MANAGER_TYPE) return; - zone = e_util_zone_current_get((E_Manager *)obj); + + zone = _e_actions_zone_get(obj); if (zone) { if (params) @@ -458,10 +476,8 @@ ACT_FN_GO(desk_linear_flip_by) ACT_FN_GO(desk_linear_flip_to) { E_Zone *zone; - - if (!obj) return; - if (obj->type != E_MANAGER_TYPE) return; - zone = e_util_zone_current_get((E_Manager *)obj); + + zone = _e_actions_zone_get(obj); if (zone) { if (params) @@ -589,15 +605,11 @@ _e_actions_menu_find(char *name) } ACT_FN_GO(menu_show) { - E_Zone *zone = NULL; + E_Zone *zone; /* menu is active - abort */ if (e_menu_grab_window_get()) return; - if (!obj) return; - if (obj->type == E_MANAGER_TYPE) - zone = e_util_zone_current_get((E_Manager *)obj); - else if (obj->type == E_ZONE_TYPE) - zone = (E_Zone *)obj; + zone = _e_actions_zone_get(obj); if (zone) { if (params) @@ -622,15 +634,11 @@ ACT_FN_GO(menu_show) } ACT_FN_GO_MOUSE(menu_show) { - E_Zone *zone = NULL; + E_Zone *zone; /* menu is active - abort */ if (e_menu_grab_window_get()) return; - if (!obj) return; - if (obj->type == E_MANAGER_TYPE) - zone = e_util_zone_current_get((E_Manager *)obj); - else if (obj->type == E_ZONE_TYPE) - zone = (E_Zone *)obj; + zone = _e_actions_zone_get(obj); if (zone) { if (params) @@ -658,15 +666,11 @@ ACT_FN_GO_MOUSE(menu_show) } ACT_FN_GO_KEY(menu_show) { - E_Zone *zone = NULL; + E_Zone *zone; /* menu is active - abort */ if (e_menu_grab_window_get()) return; - if (!obj) return; - if (obj->type == E_MANAGER_TYPE) - zone = e_util_zone_current_get((E_Manager *)obj); - else if (obj->type == E_ZONE_TYPE) - zone = (E_Zone *)obj; + zone = _e_actions_zone_get(obj); if (zone) { if (params) @@ -706,9 +710,7 @@ ACT_FN_GO(app) { E_Zone *zone; - if (!obj) return; - if (obj->type != E_MANAGER_TYPE) return; - zone = e_util_zone_current_get((E_Manager *)obj); + zone = _e_actions_zone_get(obj); if (zone) { if (params) @@ -743,13 +745,9 @@ ACT_FN_GO(app) /***************************************************************************/ ACT_FN_GO(winlist) { - E_Zone *zone = NULL; + E_Zone *zone; - if (!obj) return; - if (obj->type == E_MANAGER_TYPE) - zone = e_util_zone_current_get((E_Manager *)obj); - else if (obj->type == E_ZONE_TYPE) - zone = (E_Zone *)obj; + zone = _e_actions_zone_get(obj); if (zone) { if (params) @@ -774,13 +772,9 @@ ACT_FN_GO(winlist) } ACT_FN_GO_MOUSE(winlist) { - E_Zone *zone = NULL; + E_Zone *zone; - if (!obj) return; - if (obj->type == E_MANAGER_TYPE) - zone = e_util_zone_current_get((E_Manager *)obj); - else if (obj->type == E_ZONE_TYPE) - zone = (E_Zone *)obj; + zone = _e_actions_zone_get(obj); if (zone) { if (params) @@ -811,13 +805,9 @@ ACT_FN_GO_MOUSE(winlist) } ACT_FN_GO_KEY(winlist) { - E_Zone *zone = NULL; + E_Zone *zone; - if (!obj) return; - if (obj->type == E_MANAGER_TYPE) - zone = e_util_zone_current_get((E_Manager *)obj); - else if (obj->type == E_ZONE_TYPE) - zone = (E_Zone *)obj; + zone = _e_actions_zone_get(obj); if (zone) { if (params) diff --git a/src/bin/e_actions.h b/src/bin/e_actions.h index cb71f994a..cdf353b89 100644 --- a/src/bin/e_actions.h +++ b/src/bin/e_actions.h @@ -19,6 +19,7 @@ struct _E_Action struct { void (*go) (E_Object *obj, char *params); void (*go_mouse) (E_Object *obj, char *params, Ecore_X_Event_Mouse_Button_Down *ev); + void (*go_wheel) (E_Object *obj, char *params, Ecore_X_Event_Mouse_Wheel *ev); void (*go_key) (E_Object *obj, char *params, Ecore_X_Event_Key_Down *ev); void (*end) (E_Object *obj, char *params); void (*end_mouse) (E_Object *obj, char *params, Ecore_X_Event_Mouse_Button_Up *ev); diff --git a/src/bin/e_bindings.c b/src/bin/e_bindings.c index ddb3cd851..8bff82203 100644 --- a/src/bin/e_bindings.c +++ b/src/bin/e_bindings.c @@ -7,6 +7,8 @@ static void _e_bindings_mouse_free(E_Binding_Mouse *bind); static void _e_bindings_key_free(E_Binding_Key *bind); +static void _e_bindings_signal_free(E_Binding_Signal *bind); +static void _e_bindings_wheel_free(E_Binding_Wheel *bind); static int _e_bindings_context_match(E_Binding_Context bctxt, E_Binding_Context ctxt); /* local subsystem globals */ @@ -14,6 +16,7 @@ static int _e_bindings_context_match(E_Binding_Context bctxt, E_Binding_Context static Evas_List *mouse_bindings = NULL; static Evas_List *key_bindings = NULL; static Evas_List *signal_bindings = NULL; +static Evas_List *wheel_bindings = NULL; /* externally accessible functions */ @@ -39,34 +42,85 @@ e_bindings_init(void) e_bindings_key_add(eb->context, eb->key, eb->modifiers, eb->any_mod, eb->action, eb->params); } + + /* FIXME: these need to be come normal e_config bindings that you can + * modify via ipc and are saved/loaded to/from the user's config + */ + e_bindings_wheel_add(E_BINDING_CONTEXT_CONTAINER, + 0, -1, E_BINDING_MODIFIER_NONE, 1, + "desk_linear_flip_by", "-1"); + e_bindings_wheel_add(E_BINDING_CONTEXT_CONTAINER, + 1, -1, E_BINDING_MODIFIER_NONE, 1, + "desk_linear_flip_by", "-1"); + e_bindings_wheel_add(E_BINDING_CONTEXT_CONTAINER, + 0, 1, E_BINDING_MODIFIER_NONE, 1, + "desk_linear_flip_by", "1"); + e_bindings_wheel_add(E_BINDING_CONTEXT_CONTAINER, + 1, 1, E_BINDING_MODIFIER_NONE, 1, + "desk_linear_flip_by", "1"); + e_bindings_wheel_add(E_BINDING_CONTEXT_POPUP, + 0, -1, E_BINDING_MODIFIER_NONE, 1, + "desk_linear_flip_by", "-1"); + e_bindings_wheel_add(E_BINDING_CONTEXT_POPUP, + 1, -1, E_BINDING_MODIFIER_NONE, 1, + "desk_linear_flip_by", "-1"); + e_bindings_wheel_add(E_BINDING_CONTEXT_POPUP, + 0, 1, E_BINDING_MODIFIER_NONE, 1, + "desk_linear_flip_by", "1"); + e_bindings_wheel_add(E_BINDING_CONTEXT_POPUP, + 1, 1, E_BINDING_MODIFIER_NONE, 1, + "desk_linear_flip_by", "1"); + e_bindings_wheel_add(E_BINDING_CONTEXT_BORDER, + 0, -1, E_BINDING_MODIFIER_ALT, 0, + "desk_linear_flip_by", "-1"); + e_bindings_wheel_add(E_BINDING_CONTEXT_BORDER, + 1, -1, E_BINDING_MODIFIER_ALT, 0, + "desk_linear_flip_by", "-1"); + e_bindings_wheel_add(E_BINDING_CONTEXT_BORDER, + 0, 1, E_BINDING_MODIFIER_ALT, 0, + "desk_linear_flip_by", "1"); + e_bindings_wheel_add(E_BINDING_CONTEXT_BORDER, + 1, 1, E_BINDING_MODIFIER_ALT, 0, + "desk_linear_flip_by", "1"); + return 1; } int e_bindings_shutdown(void) { - Evas_List *l; - - for (l = mouse_bindings; l; l = l->next) + while (mouse_bindings) { E_Binding_Mouse *bind; - bind = l->data; + bind = mouse_bindings->data; + mouse_bindings = evas_list_remove_list(mouse_bindings, mouse_bindings); _e_bindings_mouse_free(bind); } - evas_list_free(mouse_bindings); - mouse_bindings = NULL; - - for (l = key_bindings; l; l = l->next) + while (key_bindings) { E_Binding_Key *bind; - bind = l->data; + bind = key_bindings->data; + key_bindings = evas_list_remove_list(key_bindings, key_bindings); _e_bindings_key_free(bind); } - evas_list_free(key_bindings); - key_bindings = NULL; - + while (signal_bindings) + { + E_Binding_Signal *bind; + + bind = signal_bindings->data; + signal_bindings = evas_list_remove_list(signal_bindings, signal_bindings); + _e_bindings_signal_free(bind); + } + while (wheel_bindings) + { + E_Binding_Wheel *bind; + + bind = wheel_bindings->data; + wheel_bindings = evas_list_remove_list(wheel_bindings, wheel_bindings); + _e_bindings_wheel_free(bind); + } return 1; } @@ -426,10 +480,261 @@ e_bindings_key_up_event_handle(E_Binding_Context ctxt, E_Object *obj, Ecore_X_Ev } /* FIXME: finish off signal bindings */ -int +void +e_bindings_signal_add(E_Binding_Context ctxt, char *sig, char *src, E_Binding_Modifier mod, int any_mod, char *action, char *params) +{ + E_Binding_Signal *bind; + + bind = calloc(1, sizeof(E_Binding_Signal)); + bind->ctxt = ctxt; + bind->sig = strdup(sig); + bind->src = strdup(src); + bind->mod = mod; + bind->any_mod = any_mod; + bind->action = strdup(action); + bind->params = strdup(params); + signal_bindings = evas_list_append(signal_bindings, bind); +} + +void +e_bindings_signal_del(E_Binding_Context ctxt, char *sig, char *src, E_Binding_Modifier mod, int any_mod, char *action, char *params) +{ + Evas_List *l; + + for (l = signal_bindings; l; l = l->next) + { + E_Binding_Signal *bind; + + bind = l->data; + if ((bind->ctxt == ctxt) && + (!strcmp(bind->sig, sig)) && + (!strcmp(bind->src, src)) && + (bind->mod == mod) && + (bind->any_mod == any_mod) && + (!strcmp(bind->action, action)) && + (!strcmp(bind->params, params))) + { + _e_bindings_signal_free(bind); + signal_bindings = evas_list_remove_list(signal_bindings, l); + break; + } + } +} + +E_Action * +e_bindings_signal_find(E_Binding_Context ctxt, E_Object *obj, char *sig, char *src, E_Binding_Signal **bind_ret) +{ + E_Binding_Modifier mod = 0; + Evas_List *l; + + if (strstr(sig, "MOD:Shift")) mod |= E_BINDING_MODIFIER_SHIFT; + if (strstr(sig, "MOD:Control")) mod |= E_BINDING_MODIFIER_CTRL; + if (strstr(sig, "MOD:Alt")) mod |= E_BINDING_MODIFIER_ALT; + if (strstr(sig, "MOD:Super")) mod |= E_BINDING_MODIFIER_WIN; + for (l = signal_bindings; l; l = l->next) + { + E_Binding_Signal *bind; + + bind = l->data; + if ((e_util_glob_match(sig, bind->sig)) && + (e_util_glob_match(src, bind->src)) && + ((bind->any_mod) || (bind->mod == mod))) + { + if (_e_bindings_context_match(bind->ctxt, ctxt)) + { + E_Action *act; + + act = e_action_find(bind->action); + if (bind_ret) *bind_ret = bind; + return act; + } + } + } + return NULL; +} + +E_Action * e_bindings_signal_handle(E_Binding_Context ctxt, E_Object *obj, char *sig, char *src) { - return 0; + E_Action *act; + E_Binding_Signal *bind; + + act = e_bindings_signal_find(ctxt, obj, sig, src, &bind); + if (act) + { + if (act->func.go) + act->func.go(obj, bind->params); + return act; + } + return act; +} + +/* FIXME: finish off wheel bindings */ +void +e_bindings_wheel_add(E_Binding_Context ctxt, int direction, int z, E_Binding_Modifier mod, int any_mod, char *action, char *params) +{ + E_Binding_Wheel *bind; + + bind = calloc(1, sizeof(E_Binding_Wheel)); + bind->ctxt = ctxt; + bind->direction = direction; + bind->z = z; + bind->mod = mod; + bind->any_mod = any_mod; + bind->action = strdup(action); + bind->params = strdup(params); + wheel_bindings = evas_list_append(wheel_bindings, bind); +} + +void +e_bindings_wheel_del(E_Binding_Context ctxt, int direction, int z, E_Binding_Modifier mod, int any_mod, char *action, char *params) +{ + Evas_List *l; + + for (l = wheel_bindings; l; l = l->next) + { + E_Binding_Wheel *bind; + + bind = l->data; + if ((bind->ctxt == ctxt) && + (bind->direction == direction) && + (bind->z == z) && + (bind->mod == mod) && + (bind->any_mod == any_mod) && + (!strcmp(bind->action, action)) && + (!strcmp(bind->params, params))) + { + _e_bindings_wheel_free(bind); + wheel_bindings = evas_list_remove_list(wheel_bindings, l); + break; + } + } +} + +void +e_bindings_wheel_grab(E_Binding_Context ctxt, Ecore_X_Window win) +{ + Evas_List *l; + + for (l = wheel_bindings; l; l = l->next) + { + E_Binding_Wheel *bind; + + bind = l->data; + if (_e_bindings_context_match(bind->ctxt, ctxt)) + { + int mod; + int button = 0; + + mod = 0; + if (bind->mod & E_BINDING_MODIFIER_SHIFT) mod |= ECORE_X_MODIFIER_SHIFT; + if (bind->mod & E_BINDING_MODIFIER_CTRL) mod |= ECORE_X_MODIFIER_CTRL; + if (bind->mod & E_BINDING_MODIFIER_ALT) mod |= ECORE_X_MODIFIER_ALT; + if (bind->mod & E_BINDING_MODIFIER_WIN) mod |= ECORE_X_MODIFIER_WIN; + + if (bind->direction == 0) + { + if (bind->z < 0) button = 4; + else if (bind->z > 0) button = 5; + } + else if (bind->direction == 1) + { + if (bind->z < 0) button = 6; + else if (bind->z > 0) button = 7; + } + if (button != 0) + ecore_x_window_button_grab(win, button, + ECORE_X_EVENT_MASK_MOUSE_DOWN, + mod, bind->any_mod); + } + } +} + +void +e_bindings_wheel_ungrab(E_Binding_Context ctxt, Ecore_X_Window win) +{ + Evas_List *l; + + for (l = wheel_bindings; l; l = l->next) + { + E_Binding_Wheel *bind; + + bind = l->data; + if (_e_bindings_context_match(bind->ctxt, ctxt)) + { + int mod; + int button = 0; + + mod = 0; + if (bind->mod & E_BINDING_MODIFIER_SHIFT) mod |= ECORE_X_MODIFIER_SHIFT; + if (bind->mod & E_BINDING_MODIFIER_CTRL) mod |= ECORE_X_MODIFIER_CTRL; + if (bind->mod & E_BINDING_MODIFIER_ALT) mod |= ECORE_X_MODIFIER_ALT; + if (bind->mod & E_BINDING_MODIFIER_WIN) mod |= ECORE_X_MODIFIER_WIN; + if (bind->direction == 0) + { + if (bind->z < 0) button = 4; + else if (bind->z > 0) button = 5; + } + else if (bind->direction == 1) + { + if (bind->z < 0) button = 6; + else if (bind->z > 0) button = 7; + } + if (button != 0) + ecore_x_window_button_ungrab(win, button, + mod, bind->any_mod); + } + } +} + +E_Action * +e_bindings_wheel_find(E_Binding_Context ctxt, E_Object *obj, Ecore_X_Event_Mouse_Wheel *ev, E_Binding_Wheel **bind_ret) +{ + E_Binding_Modifier mod = 0; + Evas_List *l; + + if (ev->modifiers & ECORE_X_MODIFIER_SHIFT) mod |= E_BINDING_MODIFIER_SHIFT; + if (ev->modifiers & ECORE_X_MODIFIER_CTRL) mod |= E_BINDING_MODIFIER_CTRL; + if (ev->modifiers & ECORE_X_MODIFIER_ALT) mod |= E_BINDING_MODIFIER_ALT; + if (ev->modifiers & ECORE_X_MODIFIER_WIN) mod |= E_BINDING_MODIFIER_WIN; + for (l = wheel_bindings; l; l = l->next) + { + E_Binding_Wheel *bind; + + bind = l->data; + if ((bind->direction == ev->direction) && + (((bind->z < 0) && (ev->z < 0)) || ((bind->z > 0) && (ev->z > 0))) && + ((bind->any_mod) || (bind->mod == mod))) + { + if (_e_bindings_context_match(bind->ctxt, ctxt)) + { + E_Action *act; + + act = e_action_find(bind->action); + if (bind_ret) *bind_ret = bind; + return act; + } + } + } + return NULL; +} + +E_Action * +e_bindings_wheel_event_handle(E_Binding_Context ctxt, E_Object *obj, Ecore_X_Event_Mouse_Wheel *ev) +{ + E_Action *act; + E_Binding_Wheel *bind; + + act = e_bindings_wheel_find(ctxt, obj, ev, &bind); + if (act) + { + if (act->func.go_wheel) + act->func.go_wheel(obj, bind->params, ev); + else if (act->func.go) + act->func.go(obj, bind->params); + return act; + } + return act; } /* local subsystem functions */ @@ -451,6 +756,24 @@ _e_bindings_key_free(E_Binding_Key *bind) free(bind); } +static void +_e_bindings_signal_free(E_Binding_Signal *bind) +{ + E_FREE(bind->sig); + E_FREE(bind->src); + E_FREE(bind->action); + E_FREE(bind->params); + free(bind); +} + +static void +_e_bindings_wheel_free(E_Binding_Wheel *bind) +{ + E_FREE(bind->action); + E_FREE(bind->params); + free(bind); +} + static int _e_bindings_context_match(E_Binding_Context bctxt, E_Binding_Context ctxt) { diff --git a/src/bin/e_bindings.h b/src/bin/e_bindings.h index 4be30cb88..d8ed9440d 100644 --- a/src/bin/e_bindings.h +++ b/src/bin/e_bindings.h @@ -13,6 +13,7 @@ typedef enum _E_Binding_Context E_BINDING_CONTEXT_MANAGER, E_BINDING_CONTEXT_MENU, E_BINDING_CONTEXT_WINLIST, + E_BINDING_CONTEXT_POPUP, E_BINDING_CONTEXT_ANY } E_Binding_Context; @@ -32,6 +33,7 @@ typedef enum _E_Binding_Modifier typedef struct _E_Binding_Mouse E_Binding_Mouse; typedef struct _E_Binding_Key E_Binding_Key; typedef struct _E_Binding_Signal E_Binding_Signal; +typedef struct _E_Binding_Wheel E_Binding_Wheel; #else #ifndef E_BINDINGS_H @@ -62,6 +64,19 @@ struct _E_Binding_Signal E_Binding_Context ctxt; char *sig; char *src; + E_Binding_Modifier mod; + unsigned char any_mod : 1; + char *action; + char *params; +}; + +struct _E_Binding_Wheel +{ + E_Binding_Context ctxt; + int direction; + int z; + E_Binding_Modifier mod; + unsigned char any_mod : 1; char *action; char *params; }; @@ -85,7 +100,17 @@ EAPI void e_bindings_key_ungrab(E_Binding_Context ctxt, Ecore_X_Window wi EAPI E_Action *e_bindings_key_down_event_handle(E_Binding_Context ctxt, E_Object *obj, Ecore_X_Event_Key_Down *ev); EAPI E_Action *e_bindings_key_up_event_handle(E_Binding_Context ctxt, E_Object *obj, Ecore_X_Event_Key_Up *ev); -EAPI int e_bindings_signal_handle(E_Binding_Context ctxt, E_Object *obj, char *sig, char *src); +EAPI void e_bindings_signal_add(E_Binding_Context ctxt, char *sig, char *src, E_Binding_Modifier mod, int any_mod, char *action, char *params); +EAPI void e_bindings_signal_del(E_Binding_Context ctxt, char *sig, char *src, E_Binding_Modifier mod, int any_mod, char *action, char *params); +EAPI E_Action *e_bindings_signal_find(E_Binding_Context ctxt, E_Object *obj, char *sig, char *src, E_Binding_Signal **bind_ret); +EAPI E_Action *e_bindings_signal_handle(E_Binding_Context ctxt, E_Object *obj, char *sig, char *src); +EAPI void e_bindings_wheel_add(E_Binding_Context ctxt, int direction, int z, E_Binding_Modifier mod, int any_mod, char *action, char *params); +EAPI void e_bindings_wheel_del(E_Binding_Context ctxt, int direction, int z, E_Binding_Modifier mod, int any_mod, char *action, char *params); +EAPI void e_bindings_wheel_grab(E_Binding_Context ctxt, Ecore_X_Window win); +EAPI void e_bindings_wheel_ungrab(E_Binding_Context ctxt, Ecore_X_Window win); +EAPI E_Action *e_bindings_wheel_find(E_Binding_Context ctxt, E_Object *obj, Ecore_X_Event_Mouse_Wheel *ev, E_Binding_Wheel **bind_ret); +EAPI E_Action *e_bindings_wheel_event_handle(E_Binding_Context ctxt, E_Object *obj, Ecore_X_Event_Mouse_Wheel *ev); + #endif #endif diff --git a/src/bin/e_border.c b/src/bin/e_border.c index f19b5ce7c..3e666f9ea 100644 --- a/src/bin/e_border.c +++ b/src/bin/e_border.c @@ -63,10 +63,10 @@ static void _e_border_cb_signal_action(void *data, Evas_Object *obj, const char static void _e_border_cb_signal_drag(void *data, Evas_Object *obj, const char *emission, const char *source); static int _e_border_cb_mouse_in(void *data, int type, void *event); static int _e_border_cb_mouse_out(void *data, int type, void *event); +static int _e_border_cb_mouse_wheel(void *data, int type, void *event); static int _e_border_cb_mouse_down(void *data, int type, void *event); static int _e_border_cb_mouse_up(void *data, int type, void *event); static int _e_border_cb_mouse_move(void *data, int type, void *event); -static int _e_border_cb_mouse_wheel(void *data, int type, void *event); static int _e_border_cb_grab_replay(void *data, int type, void *event); static void _e_border_eval(E_Border *bd); @@ -234,6 +234,7 @@ e_border_new(E_Container *con, Ecore_X_Window win, int first_map) bd->win = ecore_x_window_override_new(con->win, 0, 0, bd->w, bd->h); ecore_x_window_shape_events_select(bd->win, 1); e_bindings_mouse_grab(E_BINDING_CONTEXT_BORDER, bd->win); + e_bindings_wheel_grab(E_BINDING_CONTEXT_BORDER, bd->win); e_focus_setup(bd); if (e_canvas_engine_decide(e_config->evas_engine_borders) == E_EVAS_ENGINE_GL_X11) @@ -271,6 +272,7 @@ e_border_new(E_Container *con, Ecore_X_Window win, int first_map) ecore_evas_free(bd->bg_ecore_evas); ecore_x_window_del(bd->client.shell_win); e_bindings_mouse_ungrab(E_BINDING_CONTEXT_BORDER, bd->win); + e_bindings_wheel_ungrab(E_BINDING_CONTEXT_BORDER, bd->win); ecore_x_window_del(bd->win); free(bd); return NULL; @@ -2122,6 +2124,7 @@ e_border_button_bindings_ungrab_all(void) bd = l->data; e_focus_setdown(bd); e_bindings_mouse_ungrab(E_BINDING_CONTEXT_BORDER, bd->win); + e_bindings_wheel_ungrab(E_BINDING_CONTEXT_BORDER, bd->win); } } @@ -2136,6 +2139,7 @@ e_border_button_bindings_grab_all(void) bd = l->data; e_bindings_mouse_grab(E_BINDING_CONTEXT_BORDER, bd->win); + e_bindings_wheel_grab(E_BINDING_CONTEXT_BORDER, bd->win); e_focus_setup(bd); } } @@ -2405,6 +2409,7 @@ _e_border_free(E_Border *bd) ecore_x_window_del(bd->client.shell_win); e_focus_setdown(bd); e_bindings_mouse_ungrab(E_BINDING_CONTEXT_BORDER, bd->win); + e_bindings_wheel_ungrab(E_BINDING_CONTEXT_BORDER, bd->win); ecore_x_window_del(bd->win); e_container_border_remove(bd); @@ -3809,7 +3814,6 @@ _e_border_cb_mouse_in(void *data, int type, void *event) #endif bd->mouse.current.mx = ev->root.x; bd->mouse.current.my = ev->root.y; - evas_event_feed_mouse_move(bd->bg_evas, ev->x, ev->y, ev->time, NULL); evas_event_feed_mouse_in(bd->bg_evas, ev->time, NULL); return 1; } @@ -3881,11 +3885,30 @@ _e_border_cb_mouse_out(void *data, int type, void *event) #endif bd->mouse.current.mx = ev->root.x; bd->mouse.current.my = ev->root.y; - evas_event_feed_mouse_move(bd->bg_evas, ev->x, ev->y, ev->time, NULL); evas_event_feed_mouse_out(bd->bg_evas, ev->time, NULL); return 1; } +static int +_e_border_cb_mouse_wheel(void *data, int type, void *event) +{ + Ecore_X_Event_Mouse_Wheel *ev; + E_Border *bd; + + ev = event; + bd = data; + if (ev->event_win == bd->win) + { + bd->mouse.current.mx = ev->root.x; + bd->mouse.current.my = ev->root.y; + if (!bd->cur_mouse_action) + e_bindings_wheel_event_handle(E_BINDING_CONTEXT_BORDER, + E_OBJECT(bd), ev); + } + evas_event_feed_mouse_wheel(bd->bg_evas, ev->direction, ev->z, ev->time, NULL); + return 1; +} + static int _e_border_cb_mouse_down(void *data, int type, void *event) { @@ -3973,7 +3996,6 @@ _e_border_cb_mouse_down(void *data, int type, void *event) if (ev->double_click) flags |= EVAS_BUTTON_DOUBLE_CLICK; if (ev->triple_click) flags |= EVAS_BUTTON_TRIPLE_CLICK; - evas_event_feed_mouse_move(bd->bg_evas, ev->x, ev->y, ev->time, NULL); evas_event_feed_mouse_down(bd->bg_evas, ev->button, flags, ev->time, NULL); } return 1; @@ -4030,7 +4052,6 @@ _e_border_cb_mouse_up(void *data, int type, void *event) bd->drag.start = 0; - evas_event_feed_mouse_move(bd->bg_evas, ev->x, ev->y, ev->time, NULL); evas_event_feed_mouse_up(bd->bg_evas, ev->button, EVAS_BUTTON_NONE, ev->time, NULL); return 1; } @@ -4156,22 +4177,6 @@ _e_border_cb_mouse_move(void *data, int type, void *event) return 1; } -static int -_e_border_cb_mouse_wheel(void *data, int type, void *event) -{ - Ecore_X_Event_Mouse_Wheel *ev; - E_Border *bd; - - ev = event; - bd = data; - if (ev->win != bd->event_win) return 1; - bd->mouse.current.mx = ev->root.x; - bd->mouse.current.my = ev->root.y; - evas_event_feed_mouse_move(bd->bg_evas, ev->x, ev->y, ev->time, NULL); - evas_event_feed_mouse_wheel(bd->bg_evas, ev->direction, ev->z, ev->time, NULL); - return 1; -} - static int _e_border_cb_grab_replay(void *data, int type, void *event) { diff --git a/src/bin/e_container.c b/src/bin/e_container.c index 186061860..40d700fbd 100644 --- a/src/bin/e_container.c +++ b/src/bin/e_container.c @@ -1017,7 +1017,6 @@ _e_container_cb_mouse_in(void *data, int type, void *event) { bd = e_border_focused_get(); if (bd) e_focus_event_mouse_out(bd); - evas_event_feed_mouse_move(con->bg_evas, ev->x, ev->y, ev->time, NULL); evas_event_feed_mouse_in(con->bg_evas, ev->time, NULL); } return 1; @@ -1033,7 +1032,6 @@ _e_container_cb_mouse_out(void *data, int type, void *event) con = _e_container_find_by_event_window(ev->event_win); if (con) { - evas_event_feed_mouse_move(con->bg_evas, ev->x, ev->y, ev->time, NULL); evas_event_feed_mouse_out(con->bg_evas, ev->time, NULL); } return 1; @@ -1055,7 +1053,6 @@ _e_container_cb_mouse_down(void *data, int type, void *event) E_OBJECT(con), ev); if (ev->double_click) flags |= EVAS_BUTTON_DOUBLE_CLICK; if (ev->triple_click) flags |= EVAS_BUTTON_TRIPLE_CLICK; - evas_event_feed_mouse_move(con->bg_evas, ev->x, ev->y, ev->time, NULL); evas_event_feed_mouse_down(con->bg_evas, ev->button, flags, ev->time, NULL); } return 1; @@ -1071,7 +1068,6 @@ _e_container_cb_mouse_up(void *data, int type, void *event) con = _e_container_find_by_event_window(ev->event_win); if (con) { - evas_event_feed_mouse_move(con->bg_evas, ev->x, ev->y, ev->time, NULL); evas_event_feed_mouse_up(con->bg_evas, ev->button, EVAS_BUTTON_NONE, ev->time, NULL); e_bindings_mouse_up_event_handle(E_BINDING_CONTEXT_CONTAINER, E_OBJECT(con), ev); @@ -1104,6 +1100,8 @@ _e_container_cb_mouse_wheel(void *data, int type, void *event) con = _e_container_find_by_event_window(ev->event_win); if (con) { + e_bindings_wheel_event_handle(E_BINDING_CONTEXT_CONTAINER, + E_OBJECT(con), ev); evas_event_feed_mouse_wheel(con->bg_evas, ev->direction, ev->z, ev->time, NULL); } return 1; diff --git a/src/bin/e_focus.c b/src/bin/e_focus.c index 17d698e8f..d495628f1 100644 --- a/src/bin/e_focus.c +++ b/src/bin/e_focus.c @@ -94,10 +94,12 @@ e_focus_event_focus_in(E_Border *bd) { if (!bd->button_grabbed) return; e_bindings_mouse_ungrab(E_BINDING_CONTEXT_BORDER, bd->win); + e_bindings_wheel_ungrab(E_BINDING_CONTEXT_BORDER, bd->win); ecore_x_window_button_ungrab(bd->win, 1, 0, 1); ecore_x_window_button_ungrab(bd->win, 2, 0, 1); ecore_x_window_button_ungrab(bd->win, 3, 0, 1); e_bindings_mouse_grab(E_BINDING_CONTEXT_BORDER, bd->win); + e_bindings_wheel_grab(E_BINDING_CONTEXT_BORDER, bd->win); bd->button_grabbed = 0; } } @@ -153,10 +155,12 @@ e_focus_setdown(E_Border *bd) { if (!bd->button_grabbed) return; e_bindings_mouse_ungrab(E_BINDING_CONTEXT_BORDER, bd->win); + e_bindings_wheel_ungrab(E_BINDING_CONTEXT_BORDER, bd->win); ecore_x_window_button_ungrab(bd->win, 1, 0, 1); ecore_x_window_button_ungrab(bd->win, 2, 0, 1); ecore_x_window_button_ungrab(bd->win, 3, 0, 1); e_bindings_mouse_grab(E_BINDING_CONTEXT_BORDER, bd->win); + e_bindings_wheel_grab(E_BINDING_CONTEXT_BORDER, bd->win); bd->button_grabbed = 0; } diff --git a/src/bin/e_popup.c b/src/bin/e_popup.c index ec75a21a8..0cb21ade8 100644 --- a/src/bin/e_popup.c +++ b/src/bin/e_popup.c @@ -6,9 +6,16 @@ /* local subsystem functions */ static void _e_popup_free(E_Popup *pop); static int _e_popup_cb_window_shape(void *data, int ev_type, void *ev); +static E_Popup *_e_popup_find_by_window(Ecore_X_Window win); +static int _e_popup_cb_mouse_down(void *data, int type, void *event); +static int _e_popup_cb_mouse_up(void *data, int type, void *event); +static int _e_popup_cb_mouse_wheel(void *data, int type, void *event); /* local subsystem globals */ static Ecore_Event_Handler *_e_popup_window_shape_handler = NULL; +static Ecore_Event_Handler *_e_popup_mouse_down_handler = NULL; +static Ecore_Event_Handler *_e_popup_mouse_up_handler = NULL; +static Ecore_Event_Handler *_e_popup_mouse_wheel_handler = NULL; static Evas_List *_e_popup_list = NULL; /* externally accessible functions */ @@ -18,6 +25,12 @@ e_popup_init(void) { _e_popup_window_shape_handler = ecore_event_handler_add(ECORE_X_EVENT_WINDOW_SHAPE, _e_popup_cb_window_shape, NULL); + _e_popup_mouse_down_handler = ecore_event_handler_add(ECORE_X_EVENT_MOUSE_BUTTON_DOWN, + _e_popup_cb_mouse_down, NULL); + _e_popup_mouse_up_handler = ecore_event_handler_add(ECORE_X_EVENT_MOUSE_BUTTON_UP, + _e_popup_cb_mouse_up, NULL); + _e_popup_mouse_wheel_handler = ecore_event_handler_add(ECORE_X_EVENT_MOUSE_WHEEL, + _e_popup_cb_mouse_wheel, NULL); return 1; } @@ -25,6 +38,9 @@ int e_popup_shutdown(void) { E_FN_DEL(ecore_event_handler_del, _e_popup_window_shape_handler); + E_FN_DEL(ecore_event_handler_del, _e_popup_mouse_down_handler); + E_FN_DEL(ecore_event_handler_del, _e_popup_mouse_up_handler); + E_FN_DEL(ecore_event_handler_del, _e_popup_mouse_wheel_handler); return 1; } @@ -272,3 +288,72 @@ _e_popup_cb_window_shape(void *data, int ev_type, void *ev) } return 1; } + +static E_Popup * +_e_popup_find_by_window(Ecore_X_Window win) +{ + E_Popup *pop; + Evas_List *l; + + for (l = _e_popup_list; l; l = l->next) + { + pop = l->data; + if (pop->evas_win == win) return pop; + } + return NULL; +} + +static int +_e_popup_cb_mouse_down(void *data, int type, void *event) +{ + Ecore_X_Event_Mouse_Button_Down *ev; + E_Popup *pop; + + ev = event; + pop = _e_popup_find_by_window(ev->event_win); + if (pop) + { + Evas_Button_Flags flags = EVAS_BUTTON_NONE; + + e_bindings_mouse_down_event_handle(E_BINDING_CONTEXT_POPUP, + E_OBJECT(pop), ev); + if (ev->double_click) flags |= EVAS_BUTTON_DOUBLE_CLICK; + if (ev->triple_click) flags |= EVAS_BUTTON_TRIPLE_CLICK; + evas_event_feed_mouse_down(pop->evas, ev->button, flags, ev->time, NULL); + } + return 1; +} + +static int +_e_popup_cb_mouse_up(void *data, int type, void *event) +{ + Ecore_X_Event_Mouse_Button_Up *ev; + E_Popup *pop; + + ev = event; + pop = _e_popup_find_by_window(ev->event_win); + if (pop) + { + evas_event_feed_mouse_up(pop->evas, ev->button, EVAS_BUTTON_NONE, ev->time, NULL); + e_bindings_mouse_up_event_handle(E_BINDING_CONTEXT_POPUP, + E_OBJECT(pop), ev); + } + return 1; +} + +static int +_e_popup_cb_mouse_wheel(void *data, int type, void *event) +{ + Ecore_X_Event_Mouse_Wheel *ev; + E_Popup *pop; + + ev = event; + pop = _e_popup_find_by_window(ev->event_win); + if (pop) + { + e_bindings_wheel_event_handle(E_BINDING_CONTEXT_POPUP, + E_OBJECT(pop), ev); + evas_event_feed_mouse_wheel(pop->evas, ev->direction, ev->z, ev->time, NULL); + } + return 1; +} diff --git a/src/bin/e_winlist.c b/src/bin/e_winlist.c index 6b066c80d..da1442d29 100644 --- a/src/bin/e_winlist.c +++ b/src/bin/e_winlist.c @@ -769,6 +769,8 @@ _e_winlist_cb_mouse_wheel(void *data, int type, void *event) ev = event; if (ev->win != input_window) return 1; + e_bindings_wheel_event_handle(E_BINDING_CONTEXT_WINLIST, + E_OBJECT(winlist->zone), ev); if (ev->z < 0) /* up */ { int i; diff --git a/src/modules/pager/e_mod_main.c b/src/modules/pager/e_mod_main.c index e33b9fe50..71adba635 100644 --- a/src/modules/pager/e_mod_main.c +++ b/src/modules/pager/e_mod_main.c @@ -1007,6 +1007,8 @@ _pager_popup_free(Pager_Popup *pp) pp->face->pager->faces = evas_list_remove(pp->face->pager->faces, pp->face); evas_object_del(pp->bg_object); _pager_face_free(pp->face); + e_bindings_mouse_ungrab(E_BINDING_CONTEXT_POPUP, pp->popup->evas_win); + e_bindings_wheel_ungrab(E_BINDING_CONTEXT_POPUP, pp->popup->evas_win); e_object_del(E_OBJECT(pp->popup)); free(pp); } @@ -1668,6 +1670,8 @@ _pager_cb_event_desk_show(void *data, int type, void *event) pp->popup->zone->x + ((pp->popup->zone->w - w) / 2), pp->popup->zone->y + ((pp->popup->zone->h - h) / 2), w, h); + e_bindings_mouse_grab(E_BINDING_CONTEXT_POPUP, pp->popup->evas_win); + e_bindings_wheel_grab(E_BINDING_CONTEXT_POPUP, pp->popup->evas_win); e_popup_show(pp->popup); pp->timer = ecore_timer_add(face->pager->conf->popup_speed,