From b30f189e6fbaea5ef542a570bc835f79a03809ea Mon Sep 17 00:00:00 2001 From: Carsten Haitzler Date: Fri, 3 Feb 2006 06:16:25 +0000 Subject: [PATCH] illogicit patches for: >e_int_config_focus_missing_options.patch: adds refocus last focused window on desktop switch and revert focus when hiding or closing a window options. >e_menu_various.patch: (up-to-date) adds several things... - support KeyPad equivalent for keybindings (numbers as well as directions). - add [home] [end] support : will go to the first/last menu item - 0 will go to the last menu item instead of going to the 10th one. - corrected the bug when the first menu item was activated *twice* when creating a POP_DIRECTION_DOWN menu with keyboard <- passed a long time on this trying to figure why it was happening - do not activate an already active menu item >e_int_border_menu_consistency.patch: do not show items that will ne be taken into account anyway. SVN revision: 20223 --- src/bin/e_int_border_menu.c | 9 +-- src/bin/e_int_config_focus.c | 16 +++++ src/bin/e_menu.c | 144 +++++++++++++++++++++++++++++++++++-------- 3 files changed, 140 insertions(+), 29 deletions(-) diff --git a/src/bin/e_int_border_menu.c b/src/bin/e_int_border_menu.c index cf5dcc1..f1b0eea 100644 --- a/src/bin/e_int_border_menu.c +++ b/src/bin/e_int_border_menu.c @@ -78,7 +78,7 @@ e_int_border_menu_show(E_Border *bd, Evas_Coord x, Evas_Coord y, int key, Ecore_ e_menu_category_data_set("border/maximize",bd); bd->border_maximize_menu = m; /* Only allow to change layer for windows in "normal" layers */ - if ((!bd->lock_user_maximize) && + if ((!bd->lock_user_maximize) && (!bd->shaded) && ((bd->layer == 50) || (bd->layer == 100) || (bd->layer == 150))) { int __fullmaximization = 0; @@ -187,7 +187,8 @@ e_int_border_menu_show(E_Border *bd, Evas_Coord x, Evas_Coord y, int key, Ecore_ "widgets/border/default/maximize"); } - if ((!bd->lock_user_shade) && (!(!strcmp("borderless", bd->client.border.name)))) + if ((!bd->lock_user_shade) && (!bd->fullscreen) && (!bd->maximized) && + (!(!strcmp("borderless", bd->client.border.name)))) { mi = e_menu_item_new(m); e_menu_item_label_set(mi, _("Shaded")); @@ -265,7 +266,7 @@ e_int_border_menu_show(E_Border *bd, Evas_Coord x, Evas_Coord y, int key, Ecore_ "widgets/border/default/borderless"); } - if (!bd->lock_user_fullscreen) + if ((!bd->lock_user_fullscreen) && (!bd->shaded)) { mi = e_menu_item_new(m); e_menu_item_label_set(mi, _("Fullscreen")); @@ -325,7 +326,7 @@ e_int_border_menu_show(E_Border *bd, Evas_Coord x, Evas_Coord y, int key, Ecore_ e_menu_item_separator_set(mi, 1); } - if (!bd->lock_user_iconify) + if ((!bd->lock_user_iconify) && (!bd->fullscreen)) { mi = e_menu_item_new(m); e_menu_item_label_set(mi, _("Iconify")); diff --git a/src/bin/e_int_config_focus.c b/src/bin/e_int_config_focus.c index 849db06..1191d98 100644 --- a/src/bin/e_int_config_focus.c +++ b/src/bin/e_int_config_focus.c @@ -23,6 +23,8 @@ struct _E_Config_Dialog_Data int pass_click_on; int always_click_to_raise; int always_click_to_focus; + int focus_last_focused_per_desktop; + int focus_revert_on_hide_or_close; }; /* a nice easy setup function that does the dirty work */ @@ -55,6 +57,8 @@ _fill_data(E_Config_Dialog_Data *cfdata) cfdata->pass_click_on = e_config->pass_click_on; cfdata->always_click_to_raise = e_config->always_click_to_raise; cfdata->always_click_to_focus = e_config->always_click_to_focus; + cfdata->focus_last_focused_per_desktop = e_config->focus_last_focused_per_desktop; + cfdata->focus_revert_on_hide_or_close = e_config->focus_revert_on_hide_or_close; cfdata->mode = cfdata->focus_policy; } @@ -93,6 +97,8 @@ _basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata) e_config->pass_click_on = 1; e_config->always_click_to_raise = 0; e_config->always_click_to_focus = 0; + e_config->focus_last_focused_per_desktop = 0; + e_config->focus_revert_on_hide_or_close = 1; } else if (cfdata->mode == E_FOCUS_MOUSE) { @@ -101,6 +107,8 @@ _basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata) e_config->pass_click_on = 1; e_config->always_click_to_raise = 0; e_config->always_click_to_focus = 0; + e_config->focus_last_focused_per_desktop = 0; + e_config->focus_revert_on_hide_or_close = 0; } else { @@ -109,6 +117,8 @@ _basic_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata) e_config->pass_click_on = 1; e_config->always_click_to_raise = 0; e_config->always_click_to_focus = 0; + e_config->focus_last_focused_per_desktop = 1; + e_config->focus_revert_on_hide_or_close = 1; } e_border_button_bindings_grab_all(); e_config_save_queue(); @@ -125,6 +135,8 @@ _advanced_apply_data(E_Config_Dialog *cfd, E_Config_Dialog_Data *cfdata) e_config->pass_click_on = cfdata->pass_click_on; e_config->always_click_to_raise = cfdata->always_click_to_raise; e_config->always_click_to_focus = cfdata->always_click_to_focus; + e_config->focus_last_focused_per_desktop = cfdata->focus_last_focused_per_desktop; + e_config->focus_revert_on_hide_or_close = cfdata->focus_revert_on_hide_or_close; e_border_button_bindings_grab_all(); e_config_save_queue(); return 1; /* Apply was OK */ @@ -191,6 +203,10 @@ _advanced_create_widgets(E_Config_Dialog *cfd, Evas *evas, E_Config_Dialog_Data e_widget_framelist_object_append(of, ob); ob = e_widget_check_add(evas, _("A click in a window always focuses it"), &(cfdata->always_click_to_focus)); e_widget_framelist_object_append(of, ob); + ob = e_widget_check_add(evas, _("Refocus last focused window on desktop switch"), &(cfdata->focus_last_focused_per_desktop)); + e_widget_framelist_object_append(of, ob); + ob = e_widget_check_add(evas, _("Revert focus when hiding or closing a window"), &(cfdata->focus_revert_on_hide_or_close)); + e_widget_framelist_object_append(of, ob); e_widget_list_object_append(o, of, 1, 1, 0.5); return o; diff --git a/src/bin/e_menu.c b/src/bin/e_menu.c index e165558..29980bf 100644 --- a/src/bin/e_menu.c +++ b/src/bin/e_menu.c @@ -49,6 +49,9 @@ static void _e_menu_reposition (E_Menu *m); static int _e_menu_active_call (void); static void _e_menu_item_activate_next (void); static void _e_menu_item_activate_previous (void); +static void _e_menu_item_activate_first (void); +static void _e_menu_item_activate_last (void); +static void _e_menu_item_activate_nth (int n); static void _e_menu_activate_next (void); static void _e_menu_activate_previous (void); static void _e_menu_activate_first (void); @@ -194,6 +197,7 @@ e_menu_activate_key(E_Menu *m, E_Zone *zone, int x, int y, int w, int h, int dir _e_menu_activate_last(); break; case E_MENU_POP_DIRECTION_DOWN: + _e_menu_realize(m); m->cur.x = x + w; m->cur.y = y + h; _e_menu_activate_first(); @@ -726,6 +730,7 @@ e_menu_item_active_set(E_Menu_Item *mi, int active) E_Menu_Item *pmi; pmi = _e_menu_item_active_get(); + if (mi == pmi) return; if (pmi) e_menu_item_active_set(pmi, 0); mi->active = 1; if (mi->bg_object) @@ -1928,6 +1933,84 @@ _e_menu_item_activate_previous(void) } static void +_e_menu_item_activate_first(void) +{ + E_Menu *m; + Evas_List *ll; + E_Menu_Item *mi; + + /* FIXME: inefficient. should track current menu and active item */ + m = _e_menu_active_get(); + if (m) + { + ll = m->items; + mi = ll->data; + while ((mi->separator) && (ll->next)) + { + ll = ll->next; + mi = ll->data; + } + if (mi->separator) return; + e_menu_item_active_set(mi, 1); + _e_menu_item_ensure_onscreen(mi); + return; + } + _e_menu_activate_first(); +} + +static void +_e_menu_item_activate_last(void) +{ + E_Menu *m; + Evas_List *ll; + E_Menu_Item *mi; + + /* FIXME: inefficient. should track current menu and active item */ + m = _e_menu_active_get(); + if (m) + { + ll = evas_list_last(m->items); + mi = ll->data; + while ((mi->separator) && (ll->prev)) + { + ll = ll->prev; + mi = ll->data; + } + if (mi->separator) return; + e_menu_item_active_set(mi, 1); + _e_menu_item_ensure_onscreen(mi); + return; + } + _e_menu_activate_first(); +} + +static void +_e_menu_item_activate_nth(int n) +{ + E_Menu *m; + E_Menu_Item *mi; + Evas_List *ll; + int i; + + mi = _e_menu_item_active_get(); + if (!mi) + { + _e_menu_activate_first(); + mi = _e_menu_item_active_get(); + if (!mi) return; + } + m = mi->menu; + for (i = -1, ll = m->items; ll; ll = ll->next) + { + mi = ll->data; + if (!mi->separator) i++; + if (i == n) break; + } + e_menu_item_active_set(mi, 1); + _e_menu_item_ensure_onscreen(mi); +} + +static void _e_menu_activate_next(void) { E_Menu_Item *mi; @@ -2346,45 +2429,56 @@ _e_menu_cb_key_down(void *data, int type, void *event) ev = event; if (ev->win != _e_menu_win) return 1; - if (!strcmp(ev->keysymbol, "Up")) + if ((!strcmp(ev->keysymbol, "Up")) || + (!strcmp(ev->keysymbol, "KP_Up"))) _e_menu_item_activate_previous(); - else if (!strcmp(ev->keysymbol, "Down")) + else if ((!strcmp(ev->keysymbol, "Down")) || + (!strcmp(ev->keysymbol, "KP_Down"))) _e_menu_item_activate_next(); - else if (!strcmp(ev->keysymbol, "Left")) + else if ((!strcmp(ev->keysymbol, "Left")) || + (!strcmp(ev->keysymbol, "KP_Left"))) _e_menu_activate_previous(); - else if (!strcmp(ev->keysymbol, "Right")) + else if ((!strcmp(ev->keysymbol, "Right")) || + (!strcmp(ev->keysymbol, "KP_Right"))) _e_menu_activate_next(); + else if ((!strcmp(ev->keysymbol, "Home")) || + (!strcmp(ev->keysymbol, "KP_Home"))) + _e_menu_item_activate_first(); + else if ((!strcmp(ev->keysymbol, "End")) || + (!strcmp(ev->keysymbol, "KP_End"))) + _e_menu_item_activate_last(); else if (!strcmp(ev->keysymbol, "space")) { _e_menu_active_call(); } - else if (!strcmp(ev->keysymbol, "Return")) + else if ((!strcmp(ev->keysymbol, "Return")) || + (!strcmp(ev->keysymbol, "KP_Enter"))) { _e_menu_active_call(); _e_menu_deactivate_all(); } else if (!strcmp(ev->keysymbol, "Escape")) _e_menu_deactivate_all(); - else if (!strcmp(ev->keysymbol, "1")) - _e_menu_activate_nth(0); - else if (!strcmp(ev->keysymbol, "2")) - _e_menu_activate_nth(1); - else if (!strcmp(ev->keysymbol, "3")) - _e_menu_activate_nth(2); - else if (!strcmp(ev->keysymbol, "4")) - _e_menu_activate_nth(3); - else if (!strcmp(ev->keysymbol, "5")) - _e_menu_activate_nth(4); - else if (!strcmp(ev->keysymbol, "6")) - _e_menu_activate_nth(5); - else if (!strcmp(ev->keysymbol, "7")) - _e_menu_activate_nth(6); - else if (!strcmp(ev->keysymbol, "8")) - _e_menu_activate_nth(7); - else if (!strcmp(ev->keysymbol, "9")) - _e_menu_activate_nth(8); - else if (!strcmp(ev->keysymbol, "0")) - _e_menu_activate_nth(9); + else if ((!strcmp(ev->keysymbol, "1")) || (!strcmp(ev->keysymbol, "KP_1"))) + _e_menu_item_activate_first(); + else if ((!strcmp(ev->keysymbol, "2")) || (!strcmp(ev->keysymbol, "KP_2"))) + _e_menu_item_activate_nth(1); + else if ((!strcmp(ev->keysymbol, "3")) || (!strcmp(ev->keysymbol, "KP_3"))) + _e_menu_item_activate_nth(2); + else if ((!strcmp(ev->keysymbol, "4")) || (!strcmp(ev->keysymbol, "KP_4"))) + _e_menu_item_activate_nth(3); + else if ((!strcmp(ev->keysymbol, "5")) || (!strcmp(ev->keysymbol, "KP_5"))) + _e_menu_item_activate_nth(4); + else if ((!strcmp(ev->keysymbol, "6")) || (!strcmp(ev->keysymbol, "KP_6"))) + _e_menu_item_activate_nth(5); + else if ((!strcmp(ev->keysymbol, "7")) || (!strcmp(ev->keysymbol, "KP_7"))) + _e_menu_item_activate_nth(6); + else if ((!strcmp(ev->keysymbol, "8")) || (!strcmp(ev->keysymbol, "KP_8"))) + _e_menu_item_activate_nth(7); + else if ((!strcmp(ev->keysymbol, "9")) || (!strcmp(ev->keysymbol, "KP_9"))) + _e_menu_item_activate_nth(8); + else if ((!strcmp(ev->keysymbol, "0")) || (!strcmp(ev->keysymbol, "KP_0"))) + _e_menu_item_activate_last(); return 1; } -- 2.7.4