From 0c3b477cc6ff94420caeec216fc7c5f272cf203d Mon Sep 17 00:00:00 2001 From: sebastid Date: Sun, 9 Oct 2005 18:02:17 +0000 Subject: [PATCH] pointer stack work. SVN revision: 17352 --- src/bin/Makefile.am | 4 +- src/bin/e_actions.c | 32 ++-- src/bin/e_bindings.c | 4 +- src/bin/e_includes.h | 1 + src/bin/e_int_menus.c | 15 ++ src/bin/e_pointer.c | 372 +++++++++++++++++++++++++----------------- src/bin/e_pointer.h | 4 +- 7 files changed, 267 insertions(+), 165 deletions(-) diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am index 7bab8c6df..694588981 100644 --- a/src/bin/Makefile.am +++ b/src/bin/Makefile.am @@ -80,7 +80,8 @@ e_about.h \ e_theme_about.h \ e_apps_cache.h \ e_entry.h \ -e_scrollbar.h +e_scrollbar.h \ +e_fileman.h enlightenment_src = \ e_user.c \ @@ -143,6 +144,7 @@ e_theme_about.c \ e_apps_cache.c \ e_entry.c \ e_scrollbar.c \ +e_fileman.c \ $(ENLIGHTENMENTHEADERS) enlightenment_SOURCES = \ diff --git a/src/bin/e_actions.c b/src/bin/e_actions.c index fbb34fe0a..c0bc9998f 100644 --- a/src/bin/e_actions.c +++ b/src/bin/e_actions.c @@ -1213,27 +1213,38 @@ ACT_FN_GO(restart) ecore_main_loop_quit(); } -ACT_FN_GO(pointer) +ACT_FN_GO(pointer_push) { - /* TODO: Check for valid pointer types? */ E_Manager *man = NULL; - if (!obj) obj = E_OBJECT(e_manager_current_get()); if (!obj) return; if (obj->type == E_BORDER_TYPE) { E_Border *bd; bd = (E_Border *)obj; if (bd->zone) - obj = bd->zone->container->manager; + man = bd->zone->container->manager; } - if (obj->type != E_MANAGER_TYPE) + if (!man) man = e_manager_current_get(); + if (!man) return; + e_pointer_type_push(man->pointer, obj, params); +} + +ACT_FN_GO(pointer_pop) +{ + E_Manager *man = NULL; + + if (!obj) return; + if (obj->type == E_BORDER_TYPE) { - obj = E_OBJECT(e_manager_current_get()); - if (!obj) return; + E_Border *bd; + bd = (E_Border *)obj; + if (bd->zone) + man = (E_Manager *)bd->zone->container->manager; } - man = (E_Manager *)obj; - e_pointer_type_set(man->pointer, params); + if (!man) man = e_manager_current_get(); + if (!man) return; + e_pointer_type_pop(man->pointer, obj, params); } /* local subsystem globals */ @@ -1326,7 +1337,8 @@ e_actions_init(void) ACT_GO(restart); ACT_GO(exit); - ACT_GO(pointer); + ACT_GO(pointer_push); + ACT_GO(pointer_pop); return 1; } diff --git a/src/bin/e_bindings.c b/src/bin/e_bindings.c index c98d2946b..150c604f3 100644 --- a/src/bin/e_bindings.c +++ b/src/bin/e_bindings.c @@ -62,9 +62,9 @@ e_bindings_init(void) } e_bindings_signal_add(E_BINDING_CONTEXT_BORDER, "mouse,in", "resize_br", - E_BINDING_MODIFIER_NONE, 1, "pointer", "resize_br"); + E_BINDING_MODIFIER_NONE, 1, "pointer_push", "resize_br"); e_bindings_signal_add(E_BINDING_CONTEXT_BORDER, "mouse,out", "resize_br", - E_BINDING_MODIFIER_NONE, 1, "pointer", "default"); + E_BINDING_MODIFIER_NONE, 1, "pointer_pop", "resize_br"); return 1; } diff --git a/src/bin/e_includes.h b/src/bin/e_includes.h index 0927fb30c..b1954b9f7 100644 --- a/src/bin/e_includes.h +++ b/src/bin/e_includes.h @@ -62,3 +62,4 @@ #include "e_theme_about.h" #include "e_apps_cache.h" #include "e_scrollbar.h" +#include "e_fileman.h" diff --git a/src/bin/e_int_menus.c b/src/bin/e_int_menus.c index 8a22b44c2..b7a687077 100644 --- a/src/bin/e_int_menus.c +++ b/src/bin/e_int_menus.c @@ -32,6 +32,7 @@ static void _e_int_menus_apps_start (void *data, E_Menu *m); static void _e_int_menus_apps_del_hook (void *obj); static void _e_int_menus_apps_free_hook (void *obj); static void _e_int_menus_apps_run (void *data, E_Menu *m, E_Menu_Item *mi); +static void _e_int_menus_main_fm (void *data, E_Menu *m, E_Menu_Item *mi); static void _e_int_menus_config_pre_cb (void *data, E_Menu *m); static void _e_int_menus_config_free_hook (void *obj); static void _e_int_menus_config_item_cb (void *data, E_Menu *m, E_Menu_Item *mi); @@ -143,6 +144,11 @@ e_int_menus_main_new(void) e_menu_item_callback_set(mi, _e_int_menus_main_run, NULL); } + mi = e_menu_item_new(m); + e_menu_item_label_set(mi, _("File Manager")); + e_util_menu_item_edje_icon_set(mi, "enlightenment/fileman"); + e_menu_item_callback_set(mi, _e_int_menus_main_fm, NULL); + subm = e_int_menus_config_new(); dat->config = subm; mi = e_menu_item_new(m); @@ -377,6 +383,15 @@ _e_int_menus_main_run(void *data, E_Menu *m, E_Menu_Item *mi) if (exe) ecore_exe_free(exe); } +static void +_e_int_menus_main_fm(void *data, E_Menu *m, E_Menu_Item *mi) +{ + E_Fileman_Canvas *canvas; + + canvas = e_fileman_new(m->zone->container); + e_fileman_show(canvas); +} + static void _e_int_menus_main_restart(void *data, E_Menu *m, E_Menu_Item *mi) { diff --git a/src/bin/e_pointer.c b/src/bin/e_pointer.c index 06a4df8cd..84c6c8c59 100644 --- a/src/bin/e_pointer.c +++ b/src/bin/e_pointer.c @@ -6,12 +6,23 @@ /* * TODO * - Make fallback user controlable. + * - Define the allowed signals? */ +typedef struct _E_Pointer_Stack E_Pointer_Stack; + +struct _E_Pointer_Stack +{ + void *obj; + char *type; + unsigned char e_cursor : 1; +}; + static Evas_List *_e_pointers = NULL; static void _e_pointer_cb_move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info); static void _e_pointer_free(E_Pointer *p); +static int _e_pointer_type_set(E_Pointer *p); /* externally accessible functions */ E_Pointer * @@ -31,14 +42,6 @@ e_pointer_window_new(Ecore_X_Window win) p = E_OBJECT_ALLOC(E_Pointer, E_POINTER_TYPE, _e_pointer_free); if (!p) return NULL; p->e_cursor = 1; - - p->type = strdup("default"); - if (!p->type) - { - e_object_del(E_OBJECT(p)); - return NULL; - } - p->win = win; p->w = e_config->cursor_size; @@ -85,44 +88,6 @@ e_pointer_window_new(Ecore_X_Window win) return NULL; } p->pointer_object = o; - if (ecore_x_cursor_color_supported_get()) - { - if (!e_theme_edje_object_set(o, - "base/theme/pointer", - "pointer/enlightenment/default/color")) - { - /* fallback on x cursor */ - p->e_cursor = 0; - free(p->type); - p->type = strdup(""); - free(p->evas); - p->evas = NULL; - free(p->pixels); - p->evas = NULL; - e_pointer_type_set(p, "default"); - return p; - } - p->color = 1; - } - else - { - if (!e_theme_edje_object_set(o, - "base/theme/pointer", - "pointer/enlightenment/default/mono")) - { - /* fallback on x cursor */ - p->e_cursor = 0; - free(p->type); - p->type = strdup(""); - free(p->evas); - p->evas = NULL; - free(p->pixels); - p->evas = NULL; - e_pointer_type_set(p, "default"); - return p; - } - p->color = 0; - } /* Create the hotspot object */ o = evas_object_rectangle_add(p->evas); @@ -135,13 +100,24 @@ e_pointer_window_new(Ecore_X_Window win) evas_object_event_callback_add(o, EVAS_CALLBACK_MOVE, _e_pointer_cb_move, p); - edje_object_part_swallow(p->pointer_object, "hotspot", o); + + /* Init the cursor object */ + if (ecore_x_cursor_color_supported_get()) + { + p->color = 1; + } + else + { + p->color = 0; + } /* init edje */ evas_object_move(p->pointer_object, 0, 0); evas_object_resize(p->pointer_object, p->w, p->h); evas_object_show(p->pointer_object); + e_pointer_type_push(p, p, "default"); + _e_pointers = evas_list_append(_e_pointers, p); } else @@ -149,18 +125,9 @@ e_pointer_window_new(Ecore_X_Window win) p = E_OBJECT_ALLOC(E_Pointer, E_POINTER_TYPE, _e_pointer_free); if (!p) return NULL; p->e_cursor = 0; - - p->type = strdup("default"); - if (!p->type) - { - e_object_del(E_OBJECT(p)); - return NULL; - } - p->win = win; - ecore_x_window_cursor_set(win, - ecore_x_cursor_shape_get(ECORE_X_CURSOR_LEFT_PTR)); + e_pointer_type_push(p, p, "default"); _e_pointers = evas_list_append(_e_pointers, p); } @@ -200,103 +167,89 @@ e_pointers_size_set(int size) } void -e_pointer_type_set(E_Pointer *p, const char *type) +e_pointer_type_push(E_Pointer *p, void *obj, const char *type) { - if (!strcmp(p->type, type)) return; - - if (p->e_cursor) - { - Evas_Object *o; - char cursor[1024]; - - o = p->pointer_object; - if (p->color) - { - snprintf(cursor, sizeof(cursor), "pointer/enlightenment/%s/color", type); - if (!e_theme_edje_object_set(o, - "base/theme/pointer", - cursor)) - { - /* fallback on x cursor */ - p->e_cursor = 0; - e_pointer_type_set(p, type); - return; - } - } - else - { - snprintf(cursor, sizeof(cursor), "pointer/enlightenment/%s/mono", type); - if (!e_theme_edje_object_set(o, - "base/theme/pointer", - cursor)) - { - /* fallback on x cursor */ - p->e_cursor = 0; - e_pointer_type_set(p, type); - return; - } - } - edje_object_part_swallow(p->pointer_object, "hotspot", p->hot_object); - p->hot.update = 1; - } - else - { - if (!strcmp(type, "move")) - { - ecore_x_window_cursor_set(p->win, - ecore_x_cursor_shape_get(ECORE_X_CURSOR_FLEUR)); - } - else if (!strcmp(type, "resize_tl")) - { - ecore_x_window_cursor_set(p->win, - ecore_x_cursor_shape_get(ECORE_X_CURSOR_TOP_LEFT_CORNER)); - } - else if (!strcmp(type, "resize_t")) - { - ecore_x_window_cursor_set(p->win, - ecore_x_cursor_shape_get(ECORE_X_CURSOR_TOP_SIDE)); - } - else if (!strcmp(type, "resize_tr")) - { - ecore_x_window_cursor_set(p->win, - ecore_x_cursor_shape_get(ECORE_X_CURSOR_TOP_RIGHT_CORNER)); - } - else if (!strcmp(type, "resize_r")) - { - ecore_x_window_cursor_set(p->win, - ecore_x_cursor_shape_get(ECORE_X_CURSOR_RIGHT_SIDE)); - } - else if (!strcmp(type, "resize_br")) - { - ecore_x_window_cursor_set(p->win, - ecore_x_cursor_shape_get(ECORE_X_CURSOR_BOTTOM_RIGHT_CORNER)); - } - else if (!strcmp(type, "resize_b")) - { - ecore_x_window_cursor_set(p->win, - ecore_x_cursor_shape_get(ECORE_X_CURSOR_BOTTOM_SIDE)); - } - else if (!strcmp(type, "resize_bl")) - { - ecore_x_window_cursor_set(p->win, - ecore_x_cursor_shape_get(ECORE_X_CURSOR_BOTTOM_LEFT_CORNER)); - } - else if (!strcmp(type, "resize_l")) - { - ecore_x_window_cursor_set(p->win, - ecore_x_cursor_shape_get(ECORE_X_CURSOR_LEFT_SIDE)); - } - else - { - ecore_x_window_cursor_set(p->win, - ecore_x_cursor_shape_get(ECORE_X_CURSOR_LEFT_PTR)); - } - } - /* try the default cursor next time */ - p->e_cursor = e_config->use_e_cursor; + E_Pointer_Stack *stack; if (p->type) free(p->type); p->type = strdup(type); + p->obj = obj; + + if (!_e_pointer_type_set(p)) + { + p->e_cursor = !p->e_cursor; + if (!_e_pointer_type_set(p)) + { + printf("BUG: Can't set cursor!\n"); + return; + } + } + + stack = E_NEW(E_Pointer_Stack, 1); + if (stack) + { + stack->obj = p->obj; + stack->type = strdup(p->type); + stack->e_cursor = p->e_cursor; + p->stack = evas_list_prepend(p->stack, stack); + } + + /* try the default cursor next time */ + p->e_cursor = e_config->use_e_cursor; +} + +void +e_pointer_type_pop(E_Pointer *p, void *obj, const char *type) +{ + Evas_List *l; + E_Pointer_Stack *stack; + + for (l = p->stack; l;) + { + Evas_List *l2; + + stack = l->data; + l2 = l; + l = l->next; + + if ((stack->obj == obj) && + ((!type) || (!strcmp(stack->type, type)))) + { + p->stack = evas_list_remove_list(p->stack, l2); + } + } + + if (!p->stack) + { + printf("BUG: No pointer on the stack!\n"); + return; + } + + stack = p->stack->data; + if ((stack->obj == p->obj) && + (!strcmp(stack->type, p->type))) + { + /* We already use the top pointer */ + return; + } + + if (p->type) free(p->type); + p->type = strdup(stack->type); + p->obj = stack->obj; + + p->e_cursor = stack->e_cursor; + if (!_e_pointer_type_set(p)) + { + p->e_cursor = !p->e_cursor; + if (!_e_pointer_type_set(p)) + { + printf("BUG: Can't set cursor!\n"); + return; + } + } + + /* try the default cursor next time */ + p->e_cursor = e_config->use_e_cursor; } void @@ -357,10 +310,127 @@ _e_pointer_free(E_Pointer *p) while (p->stack) { - free(p->stack->data); + E_Pointer_Stack *stack; + + stack = p->stack->data; + free(stack->type); + free(stack); + p->stack = evas_list_remove_list(p->stack, p->stack); } if (p->type) free(p->type); free(p); } + +static int +_e_pointer_type_set(E_Pointer *p) +{ + if (p->e_cursor) + { + Evas_Object *o; + char cursor[1024]; + + o = p->pointer_object; + if (p->color) + { + snprintf(cursor, sizeof(cursor), "pointer/enlightenment/%s/color", p->type); + if (!e_theme_edje_object_set(o, + "base/theme/pointer", + cursor)) + { + return 0; + } + } + else + { + snprintf(cursor, sizeof(cursor), "pointer/enlightenment/%s/mono", p->type); + if (!e_theme_edje_object_set(o, + "base/theme/pointer", + cursor)) + { + return 0; + } + } + edje_object_part_swallow(p->pointer_object, "hotspot", p->hot_object); + p->hot.update = 1; + } + else + { + Ecore_X_Cursor cursor; + if (!strcmp(p->type, "move")) + { + cursor = ecore_x_cursor_shape_get(ECORE_X_CURSOR_FLEUR); + if (!cursor) printf("X Cursor for %s is missing\n", p->type); + ecore_x_window_cursor_set(p->win, cursor); + } + else if (!strcmp(p->type, "resize")) + { + cursor = ecore_x_cursor_shape_get(ECORE_X_CURSOR_SIZING); + if (!cursor) printf("X Cursor for %s is missing\n", p->type); + ecore_x_window_cursor_set(p->win, cursor); + } + else if (!strcmp(p->type, "resize_tl")) + { + cursor = ecore_x_cursor_shape_get(ECORE_X_CURSOR_TOP_LEFT_CORNER); + if (!cursor) printf("X Cursor for %s is missing\n", p->type); + ecore_x_window_cursor_set(p->win, cursor); + } + else if (!strcmp(p->type, "resize_t")) + { + cursor = ecore_x_cursor_shape_get(ECORE_X_CURSOR_TOP_SIDE); + if (!cursor) printf("X Cursor for %s is missing\n", p->type); + ecore_x_window_cursor_set(p->win, cursor); + } + else if (!strcmp(p->type, "resize_tr")) + { + cursor = ecore_x_cursor_shape_get(ECORE_X_CURSOR_TOP_RIGHT_CORNER); + if (!cursor) printf("X Cursor for %s is missing\n", p->type); + ecore_x_window_cursor_set(p->win, cursor); + } + else if (!strcmp(p->type, "resize_r")) + { + cursor = ecore_x_cursor_shape_get(ECORE_X_CURSOR_RIGHT_SIDE); + if (!cursor) printf("X Cursor for %s is missing\n", p->type); + ecore_x_window_cursor_set(p->win, cursor); + } + else if (!strcmp(p->type, "resize_br")) + { + cursor = ecore_x_cursor_shape_get(ECORE_X_CURSOR_BOTTOM_RIGHT_CORNER); + if (!cursor) printf("X Cursor for %s is missing\n", p->type); + ecore_x_window_cursor_set(p->win, cursor); + } + else if (!strcmp(p->type, "resize_b")) + { + cursor = ecore_x_cursor_shape_get(ECORE_X_CURSOR_BOTTOM_SIDE); + if (!cursor) printf("X Cursor for %s is missing\n", p->type); + ecore_x_window_cursor_set(p->win, cursor); + } + else if (!strcmp(p->type, "resize_bl")) + { + cursor = ecore_x_cursor_shape_get(ECORE_X_CURSOR_BOTTOM_LEFT_CORNER); + if (!cursor) printf("X Cursor for %s is missing\n", p->type); + ecore_x_window_cursor_set(p->win, cursor); + } + else if (!strcmp(p->type, "resize_l")) + { + cursor = ecore_x_cursor_shape_get(ECORE_X_CURSOR_LEFT_SIDE); + if (!cursor) printf("X Cursor for %s is missing\n", p->type); + ecore_x_window_cursor_set(p->win, cursor); + } + else if (!strcmp(p->type, "default")) + { + cursor = ecore_x_cursor_shape_get(ECORE_X_CURSOR_LEFT_PTR); + if (!cursor) printf("X Cursor for %s is missing\n", p->type); + ecore_x_window_cursor_set(p->win, cursor); + } + else + { + printf("Unknown pointer p->type: %s\n", p->type); + cursor = ecore_x_cursor_shape_get(ECORE_X_CURSOR_LEFT_PTR); + if (!cursor) printf("X Cursor for default is missing\n"); + ecore_x_window_cursor_set(p->win, cursor); + } + } + return 1; +} diff --git a/src/bin/e_pointer.h b/src/bin/e_pointer.h index 68153ab18..e1610a4df 100644 --- a/src/bin/e_pointer.h +++ b/src/bin/e_pointer.h @@ -26,6 +26,7 @@ struct _E_Pointer int w, h; char *type; + void *obj; Evas_List *stack; struct { @@ -35,7 +36,8 @@ struct _E_Pointer }; EAPI E_Pointer *e_pointer_window_new(Ecore_X_Window win); -EAPI void e_pointer_type_set(E_Pointer *p, const char *type); +EAPI void e_pointer_type_push(E_Pointer *p, void *obj, const char *type); +EAPI void e_pointer_type_pop(E_Pointer *p, void *obj, const char *type); EAPI void e_pointers_size_set(int size); EAPI void e_pointer_idler_before(void);