diff --git a/src/actions.c b/src/actions.c index 1344cb108..732d86e2e 100644 --- a/src/actions.c +++ b/src/actions.c @@ -221,10 +221,11 @@ e_action_free(E_Action *a) FREE(a); } -void +int e_action_start(char *action, E_Action_Type act, int button, char *key, Ecore_Event_Key_Modifiers mods, void *o, void *data, int x, int y, int rx, int ry) { Evas_List l; + int started_long_action = 0; e_action_find(action, act, button, key, mods, o); again: @@ -236,7 +237,10 @@ e_action_start(char *action, E_Action_Type act, int button, char *key, Ecore_Eve if (!a->started) { if (a->action_impl->func_stop) - a->started = 1; + { + a->started = 1; + started_long_action = 1; + } if (a->action_impl->func_start) { E_Object *obj; @@ -257,6 +261,7 @@ e_action_start(char *action, E_Action_Type act, int button, char *key, Ecore_Eve goto again; } } + return started_long_action; } void diff --git a/src/actions.h b/src/actions.h index d98d68256..24d255d72 100644 --- a/src/actions.h +++ b/src/actions.h @@ -56,7 +56,7 @@ struct _E_Action_Impl }; -void e_action_start(char *action, E_Action_Type act, int button, char *key, +int e_action_start(char *action, E_Action_Type act, int button, char *key, Ecore_Event_Key_Modifiers mods, void *o, void *data, int x, int y, int rx, int ry); void e_action_stop(char *action, E_Action_Type act, int button, char *key, diff --git a/src/border.c b/src/border.c index 3cb3acc88..2a458ca19 100644 --- a/src/border.c +++ b/src/border.c @@ -67,6 +67,24 @@ static void e_cb_border_visibility(E_Border *b); static void e_border_poll(int val, void *data); +static int e_border_replay_query(Ecore_Event_Mouse_Down *ev) +{ + E_Border *b; + + b = e_border_find_by_window(ev->win); + if (b) + { + int focus_mode; + E_CFG_INT(cfg_focus_mode, "settings", "/focus/mode", 0); + + E_CONFIG_INT_GET(cfg_focus_mode, focus_mode); + if ((focus_mode == 2) && (ev->mods == ECORE_EVENT_KEY_MODIFIER_NONE)) + /* FIXME: also if pass click always set */ + return 1; + } + return 0; +} + /* what to dowhen we're idle */ void @@ -345,11 +363,11 @@ e_reparent(Ecore_Event * ev) current_ev = ev; e = ev->event; -#if 0 { E_Border *b; b = e_border_find_by_window(e->win); +#if 0 if ((b) && (e->parent_from == b->win.container)) { if (b) @@ -366,8 +384,8 @@ e_reparent(Ecore_Event * ev) } } } +#endif } -#endif current_ev = NULL; } @@ -413,6 +431,29 @@ ecore_focus_in(Ecore_Event * ev) b->current.selected = 1; b->changed = 1; OBS_NOTIFY(b, ECORE_EVENT_WINDOW_FOCUS_IN); + { + Evas_List l; + + again: + for (l = b->grabs; l; l = l->next) + { + E_Grab *g; + + g = l->data; + /* find a grab that triggered this */ + if (b->click_grab == g) + { + printf("ungrab %s\n", b->client.title); +/* ecore_pointer_ungrab(e->time);*/ + ecore_button_ungrab(b->win.main, g->button, g->mods, g->any_mod); +/* ecore_window_button_grab_auto_replay_set(b->win.main, 0);*/ + free(g); + b->grabs = evas_list_remove(b->grabs, g); + b->click_grab = NULL; + break; + } + } + } } } current_ev = NULL; @@ -441,7 +482,7 @@ ecore_focus_out(Ecore_Event * ev) b->current.selected = 0; if (e->key_grab) b->current.select_lost_from_grab = 1; /* settings - click to focus would affect grabs */ - if (focus_mode == 2) /* click to focus */ + if ((!b->client.internal) && (focus_mode == 2)) /* click to focus */ { E_Grab *g; @@ -449,13 +490,13 @@ ecore_focus_out(Ecore_Event * ev) ZERO(g, E_Grab, 1); g->button = 0; g->mods = ECORE_EVENT_KEY_MODIFIER_NONE; - g->any_mod = 1; + g->any_mod = 0; g->remove_after = 1; b->grabs = evas_list_append(b->grabs, g); - printf("grab me baaaybe %s\n", b->client.title); - ecore_button_grab(b->win.main, 0, - XEV_BUTTON_PRESS, ECORE_EVENT_KEY_MODIFIER_NONE, 1); - ecore_window_button_grab_auto_replay_set(b->win.main, 1); + printf("grab me baaaybe %8x | %s\n", b->win.client, b->client.title); + ecore_button_grab(b->win.main, 0, XEV_BUTTON_PRESS | XEV_BUTTON_RELEASE, ECORE_EVENT_KEY_MODIFIER_NONE, 0); + ecore_window_button_grab_auto_replay_set(b->win.main, e_border_replay_query); + b->click_grab = g; } b->changed = 1; } @@ -488,7 +529,8 @@ static void e_mouse_down(Ecore_Event * ev) { Ecore_Event_Mouse_Down *e; - + + printf("doooown\n"); current_ev = ev; e = ev->event; { @@ -500,8 +542,15 @@ e_mouse_down(Ecore_Event * ev) mouse_y = e->ry; mouse_buttons |= (1 << e->button); b = e_border_find_by_window(e->win); + printf("%p (%x)\n", b, e->win); if (b) { + int focus_mode; + E_CFG_INT(cfg_focus_mode, "settings", "/focus/mode", 0); + + E_CONFIG_INT_GET(cfg_focus_mode, focus_mode); + if (focus_mode == 2) + ecore_focus_to_window(b->win.client); if (e->win == b->win.main) e_cb_border_mouse_down(b, ev); else { @@ -911,7 +960,7 @@ e_cb_border_mouse_in(E_Border *b, Ecore_Event *e) int focus_mode; E_CFG_INT(cfg_focus_mode, "settings", "/focus/mode", 0); - if (border_mouse_buttons) return; +/* if (border_mouse_buttons) return;*/ E_CONFIG_INT_GET(cfg_focus_mode, focus_mode); /* pointer focus stuff */ if (focus_mode == 0) @@ -921,7 +970,7 @@ e_cb_border_mouse_in(E_Border *b, Ecore_Event *e) border_mouse_x = mouse_x; border_mouse_y = mouse_y; - border_mouse_buttons = mouse_buttons; +/* border_mouse_buttons = mouse_buttons;*/ if (!current_ev) return; x = ((Ecore_Event_Window_Enter *)(e->event))->x; @@ -939,7 +988,7 @@ e_cb_border_mouse_out(E_Border *b, Ecore_Event *e) int x, y; char *class = "Window_Grab"; - if (border_mouse_buttons) return; +/* if (border_mouse_buttons) return; */ /* pointer focus stuff */ /* ecore_focus_to_window(0);*/ @@ -947,7 +996,7 @@ e_cb_border_mouse_out(E_Border *b, Ecore_Event *e) y = mouse_y; border_mouse_x = mouse_x; border_mouse_y = mouse_y; - border_mouse_buttons = mouse_buttons; +/* border_mouse_buttons = mouse_buttons; */ if (!current_ev) return; e_action_stop(class, ACT_MOUSE_OUT, 0, NULL, ECORE_EVENT_KEY_MODIFIER_NONE, @@ -970,8 +1019,10 @@ e_cb_border_mouse_down(E_Border *b, Ecore_Event *e) ecore_pointer_grab(b->win.main, CurrentTime); border_mouse_x = mouse_x; border_mouse_y = mouse_y; - if (border_mouse_buttons) return; - border_mouse_buttons = mouse_buttons; + printf("%i\n", border_mouse_buttons); +/* if (border_mouse_buttons) return; */ +/* border_mouse_buttons = mouse_buttons; */ + printf("%p\n", current_ev); if (!current_ev) return; x = ((Ecore_Event_Mouse_Down *)(e->event))->x; y = ((Ecore_Event_Mouse_Down *)(e->event))->y; @@ -991,13 +1042,12 @@ e_cb_border_mouse_down(E_Border *b, Ecore_Event *e) ((g->any_mod) || (((Ecore_Event_Mouse_Down *)(e->event))->mods == g->mods))) { + if (b->click_grab == g) b->click_grab = NULL; if (g->remove_after) { - if (focus_mode == 2) - ecore_focus_to_window(b->win.client); - printf("ungrab %s\n", b->client.title); + printf("pfft ungrab %s\n", b->client.title); ecore_button_ungrab(b->win.main, g->button, g->mods, g->any_mod); - ecore_window_button_grab_auto_replay_set(b->win.main, 0); + ecore_window_button_grab_auto_replay_set(b->win.main, NULL); ecore_pointer_ungrab(((Ecore_Event_Mouse_Up *)(e->event))->time); free(g); b->grabs = evas_list_remove(b->grabs, g); @@ -1006,6 +1056,7 @@ e_cb_border_mouse_down(E_Border *b, Ecore_Event *e) } } } + printf("(...e_cb_border_mouse_down...)\n"); { E_Action_Type act; Ecore_Event_Key_Modifiers mods; @@ -1020,13 +1071,17 @@ e_cb_border_mouse_down(E_Border *b, Ecore_Event *e) e_action_stop(class, act, bt, NULL, mods, b, NULL, x, y, border_mouse_x, border_mouse_y); - e_action_start(class, act, bt, NULL, mods, b, NULL, - x, y, border_mouse_x, border_mouse_y); + if (!e_action_start(class, act, bt, NULL, mods, b, NULL, + x, y, border_mouse_x, border_mouse_y)) + { + ecore_pointer_ungrab(((Ecore_Event_Mouse_Down *)(e->event))->time); + } + else + { + ecore_pointer_grab(((Ecore_Event_Mouse_Down *)(e->event))->win, + ((Ecore_Event_Mouse_Down *)(e->event))->time); + } } -/* - * ecore_pointer_ungrab(((Ecore_Event_Mouse_Up *)(e->event))->time); - * ecore_pointer_replay(((Ecore_Event_Mouse_Up *)(e->event))->time); - */ } static void @@ -1038,7 +1093,7 @@ e_cb_border_mouse_up(E_Border *b, Ecore_Event *e) ecore_pointer_ungrab(CurrentTime); border_mouse_x = mouse_x; border_mouse_y = mouse_y; - border_mouse_buttons = mouse_buttons; +/* border_mouse_buttons = mouse_buttons; */ if (!current_ev) return; x = ((Ecore_Event_Mouse_Up *)(e->event))->x; y = ((Ecore_Event_Mouse_Up *)(e->event))->y; @@ -1610,6 +1665,22 @@ e_border_remove_mouse_grabs(E_Border *b) } } +void +e_border_remove_click_grab(E_Border *b) +{ + if (b->click_grab) + { + E_Grab *g; + + g = b->click_grab; + b->grabs = evas_list_remove(b->grabs, b->click_grab); + ecore_button_ungrab(b->win.main, g->button, g->mods, g->any_mod); + ecore_window_button_grab_auto_replay_set(b->win.main, NULL); + b->click_grab = NULL; + FREE(g); + } +} + void e_border_attach_mouse_grabs(E_Border *b) { @@ -1633,12 +1704,13 @@ e_border_attach_mouse_grabs(E_Border *b) ZERO(g, E_Grab, 1); g->button = 0; g->mods = ECORE_EVENT_KEY_MODIFIER_NONE; - g->any_mod = 1; + g->any_mod = 0; g->remove_after = 1; b->grabs = evas_list_append(b->grabs, g); - printf("grab me baaaybe %s\n", b->client.title); - ecore_button_grab(b->win.main, 0, XEV_BUTTON_PRESS, ECORE_EVENT_KEY_MODIFIER_NONE, 1); - ecore_window_button_grab_auto_replay_set(b->win.main, 1); + printf("attach... grab me baaaybe %8x | %s\n", b->win.client, b->client.title); + ecore_button_grab(b->win.main, 0, XEV_BUTTON_PRESS | XEV_BUTTON_RELEASE, ECORE_EVENT_KEY_MODIFIER_NONE, 0); + ecore_window_button_grab_auto_replay_set(b->win.main, e_border_replay_query); + b->click_grab = g; } } diff --git a/src/border.h b/src/border.h index 16aaf2e41..d88f3bc40 100644 --- a/src/border.h +++ b/src/border.h @@ -103,6 +103,7 @@ struct _E_Border struct { int x, y; } area; + int internal; } client; struct { @@ -119,6 +120,7 @@ struct _E_Border int placed; Evas_List grabs; + E_Grab *click_grab; E_Desktop *desk; char *border_style; @@ -139,6 +141,7 @@ E_Border *e_border_adopt(Window win, int use_client_pos); E_Border *e_border_new(void); void e_border_free(E_Border *b); void e_border_remove_mouse_grabs(E_Border *b); +void e_border_remove_click_grab(E_Border *b); void e_border_attach_mouse_grabs(E_Border *b); void e_border_remove_all_mouse_grabs(void); void e_border_attach_all_mouse_grabs(void); diff --git a/src/desktops.c b/src/desktops.c index a2c2c2edd..79e7f952e 100644 --- a/src/desktops.c +++ b/src/desktops.c @@ -204,6 +204,8 @@ e_desktops_init_file_display(E_Desktop *desk) ecore_window_set_min_size(v->win.base, desk->real.w, desk->real.h); ecore_window_set_max_size(v->win.base, desk->real.w, desk->real.h); b = e_border_adopt(v->win.base, 1); + b->client.internal = 1; + e_border_remove_click_grab(b); b->client.sticky = 1; b->client.fixed = 1; b->client.is_desktop = 1; diff --git a/src/e.h b/src/e.h index 500474953..0205ee04f 100644 --- a/src/e.h +++ b/src/e.h @@ -27,7 +27,7 @@ #include #ifndef PATH_MAX -#define PATH_MAX 4095 +#define PATH_MAX 4096 #endif #if 0 diff --git a/src/util.c b/src/util.c index c1d60be85..c4bf9f634 100644 --- a/src/util.c +++ b/src/util.c @@ -62,7 +62,7 @@ int e_file_cp(char *src, char *dst) { FILE *f1, *f2; - char buf[PATH_MAX]; + char buf[16384]; size_t num; f1 = fopen(src, "rb"); @@ -73,7 +73,7 @@ e_file_cp(char *src, char *dst) fclose(f1); return 0; } - while ((num = fread(buf, 1, PATH_MAX, f1)) > 0) fwrite(buf, 1, num, f2); + while ((num = fread(buf, 1, 16384, f1)) > 0) fwrite(buf, 1, num, f2); fclose(f1); fclose(f2); return 1; @@ -91,7 +91,7 @@ e_file_real(char *file) } char * -e_filecore_get_file(char *file) +e_file_get_file(char *file) { char *p; char *f; @@ -107,7 +107,7 @@ e_filecore_get_file(char *file) } char * -e_filecore_get_dir(char *file) +e_file_get_dir(char *file) { char *p; char *f; diff --git a/src/view.c b/src/view.c index 4f1801e84..33682e99a 100644 --- a/src/view.c +++ b/src/view.c @@ -1478,6 +1478,12 @@ e_mouse_down(Ecore_Event * ev) v = l->data; if (e->win == v->win.main) { + int focus_mode; + E_CFG_INT(cfg_focus_mode, "settings", "/focus/mode", 0); + + E_CONFIG_INT_GET(cfg_focus_mode, focus_mode); + if (focus_mode == 2) + ecore_focus_to_window(v->win.base); evas_event_button_down(v->evas, e->x, e->y, e->button); current_ev = NULL; return; @@ -2738,6 +2744,8 @@ e_view_handle_fs(EfsdEvent *ev) e_background_set_size(v->bg, v->size.w, v->size.h); if (v->options.back_pixmap) e_view_update(v); b = e_border_adopt(v->win.base, 1); + b->client.internal = 1; + e_border_remove_click_grab(b); } return; } diff --git a/tools/e_setup.c b/tools/e_setup.c index 9c785a838..58d0d553e 100644 --- a/tools/e_setup.c +++ b/tools/e_setup.c @@ -7,8 +7,17 @@ #include #include #include +#include +#include +#include +#include +#include #include "../config.h" +#ifndef PATH_MAX +#define PATH_MAX 4096 +#endif + /* stuff we want from e */ #define OBJ_PROPERTIES \ int references; \ @@ -364,6 +373,226 @@ e_background_set_color_class(E_Background *bg, char *cc, int r, int g, int b, in /* */ /* */ +int +e_file_exists(char *file) +{ + struct stat st; + + if (stat(file, &st) < 0) return 0; + return 1; +} + +int +e_file_is_dir(char *file) +{ + struct stat st; + + if (stat(file, &st) < 0) return 0; + if (S_ISDIR(st.st_mode)) return 1; + return 0; +} + +char * +e_file_home(void) +{ + static char *home = NULL; + + if (home) return home; + home = getenv("HOME"); + if (!home) home = getenv("TMPDIR"); + if (!home) home = "/tmp"; + return home; +} + +static mode_t default_mode = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH; + +int +e_file_mkdir(char *dir) +{ + if (mkdir(dir, default_mode) < 0) return 0; + return 1; +} + +void +e_file_mkdirs(char *s) +{ + char ss[PATH_MAX]; + int i, ii; + + i = 0; + ii = 0; + while (s[i]) + { + ss[ii++] = s[i]; + ss[ii] = 0; + if (s[i] == '/') + { + if (!e_file_exists(ss)) + e_file_mkdir(ss); + else if (!e_file_is_dir(ss)) + return; + } + i++; + } +} + +int +e_file_cp(char *src, char *dst) +{ + FILE *f1, *f2; + char buf[16384]; + size_t num; + + f1 = fopen(src, "rb"); + if (!f1) return 0; + f2 = fopen(dst, "wb"); + if (!f2) + { + fclose(f1); + return 0; + } + while ((num = fread(buf, 1, 16384, f1)) > 0) fwrite(buf, 1, num, f2); + fclose(f1); + fclose(f2); + return 1; +} + +void +e_file_delete(char *s) +{ + unlink(s); +} + +void +e_file_rename(char *s, char *ss) +{ + rename(s, ss); +} + +int +e_glob_matches(char *str, char *glob) +{ + if (!fnmatch(glob, str, 0)) return 1; + return 0; +} + +char * +e_file_get_file(char *file) +{ + char *p; + char *f; + + p = strrchr(file, '/'); + if (!p) + { + e_strdup(f, file); + return f; + } + e_strdup(f, &(p[1])); + return f; +} + +char * +e_file_get_dir(char *file) +{ + char *p; + char *f; + char buf[PATH_MAX]; + + strcpy(buf, file); + p = strrchr(buf, '/'); + if (!p) + { + e_strdup(f, file); + return f; + } + *p = 0; + e_strdup(f, buf); + return f; +} + +int +e_file_can_exec(struct stat *st) +{ + static int have_uid = 0; + static uid_t uid = -1; + static gid_t gid = -1; + int ok; + + if (!st) return 0; + ok = 0; + if (!have_uid) uid = getuid(); + if (!have_uid) gid = getgid(); + have_uid = 1; + if (st->st_uid == uid) + { + if (st->st_mode & S_IXUSR) ok = 1; + } + else if (st->st_gid == gid) + { + if (st->st_mode & S_IXGRP) ok = 1; + } + else + { + if (st->st_mode & S_IXOTH) ok = 1; + } + return ok; +} + +char * +e_file_link(char *link) +{ + char buf[PATH_MAX]; + char *f; + int count; + + if ((count = readlink(link, buf, sizeof(buf))) < 0) return NULL; + buf[count] = 0; + e_strdup(f, buf); + return f; +} + +Evas_List +e_file_list_dir(char *dir) +{ + DIR *dirp; + struct dirent *dp; + Evas_List list; + + dirp = opendir(dir); + if (!dirp) return NULL; + list = NULL; + while ((dp = readdir(dirp))) + { + if ((strcmp(dp->d_name, ".")) && + (strcmp(dp->d_name, ".."))) + { + Evas_List l; + char *f; + + /* insertion sort */ + for (l = list; l; l = l->next) + { + if (strcmp(l->data, dp->d_name) > 0) + { + e_strdup(f, dp->d_name); + list = evas_list_prepend_relative(list, f, l->data); + break; + } + } + /* nowhwre to go? just append it */ + e_strdup(f, dp->d_name); + if (!l) list = evas_list_append(list, f); + } + } + closedir(dirp); + return list; +} + + +/* */ +/* */ +/* */ typedef struct _text_zone Text_Zone;