diff -u kernel/action.c kernel/action.c --- kernel/action.c 2003/08/22 11:47:42 +++ kernel/action.c 2003/08/22 21:42:08 @@ -1280,9 +1280,10 @@ if (!data->diraction.c) return; - if ((nf = client_find_directional(data->diraction.c, - data->diraction.direction))) - client_activate(nf, FALSE); + nf = client_find_directional(data->diraction.c, + data->diraction.direction, + data->cycle.final, + data->cycle.cancel); } void action_movetoedge(union ActionData *data) diff -u kernel/client.c kernel/client.c --- kernel/client.c 2003/08/22 11:47:46 +++ kernel/client.c 2003/08/22 21:42:13 @@ -20,6 +20,7 @@ #include "menu.h" #include "keyboard.h" #include "mouse.h" +#include "popup.h" #include "render/render.h" #include @@ -36,6 +37,11 @@ ObClient *client_timeout_client; ObTimer *client_focus_timer; +ObClient *client_client; + +static ObClient *client_cycle_target; + +extern Popup *focus_cycle_popup; extern ObDock *dock; static void client_get_all(ObClient *self); @@ -2603,7 +2609,7 @@ } /* this be mostly ripped from fvwm */ -ObClient *client_find_directional(ObClient *c, ObDirection dir) +ObClient *client_find_directional(ObClient *c, ObDirection dir, gboolean done, gboolean cancel) { int my_cx, my_cy, his_cx, his_cy; int offset = 0; @@ -2615,9 +2621,24 @@ if(!client_list) return NULL; + if (cancel) { + if (client_cycle_target) + frame_adjust_focus(client_cycle_target->frame, FALSE); + if (client_client) + frame_adjust_focus(client_client->frame, TRUE); + goto done_cycle; + } else if (done) { + if (client_cycle_target) + client_activate(client_cycle_target, FALSE); + goto done_cycle; + } + + if (!client_client) client_client = c; + if (!client_cycle_target) client_cycle_target = c; + /* first, find the centre coords of the currently focused window */ - my_cx = c->frame->area.x + c->frame->area.width / 2; - my_cy = c->frame->area.y + c->frame->area.height / 2; + my_cx = client_cycle_target->frame->area.x + client_cycle_target->frame->area.width / 2; + my_cy = client_cycle_target->frame->area.y + client_cycle_target->frame->area.height / 2; best_score = -1; best_client = NULL; @@ -2626,11 +2647,11 @@ cur = it->data; /* the currently selected window isn't interesting */ - if(cur == c) + if(cur == client_cycle_target) continue; if (!client_normal(cur)) continue; - if(c->desktop != cur->desktop && cur->desktop != DESKTOP_ALL) + if(client_cycle_target->desktop != cur->desktop && cur->desktop != DESKTOP_ALL) continue; if(cur->iconic) continue; @@ -2696,8 +2717,28 @@ best_client = cur, best_score = score; } - + if (best_client) { + if (client_cycle_target) + frame_adjust_focus(client_cycle_target->frame, FALSE); + client_cycle_target = best_client; + frame_adjust_focus(client_cycle_target->frame, TRUE); + if (config_focus_warppointer) + XWarpPointer(ob_display, 0, RootWindow(ob_display, ob_screen), + 0, 0, 0, 0, + client_cycle_target->frame->area.x + + client_cycle_target->frame->area.width/2, + client_cycle_target->frame->area.y + + client_cycle_target->frame->area.height/2); + } + if (client_cycle_target) + popup_cycle(client_cycle_target, config_focus_popup, focus_cycle_popup); return best_client; + +done_cycle: + client_cycle_target = NULL; + client_client = NULL; + popup_cycle(NULL, FALSE, focus_cycle_popup); + return NULL; } void client_set_layer(ObClient *self, int layer) diff -u kernel/client.h kernel/client.h --- kernel/client.h 2003/08/22 11:47:46 +++ kernel/client.h 2003/08/22 21:42:14 @@ -464,7 +464,8 @@ ObClient *client_search_transient(ObClient *self, ObClient *search); /*! Return the "closest" client in the given direction */ -ObClient *client_find_directional(ObClient *c, ObDirection dir); +ObClient *client_find_directional(ObClient *c, ObDirection dir, gboolean done, + gboolean cancel); /*! Return the closest edge in the given direction */ int client_directional_edge_search(ObClient *c, ObDirection dir); --- kernel/focus.c 2003/08/14 08:21:33 1.83 +++ kernel/focus.c 2003/08/22 21:42:19 @@ -23,7 +23,7 @@ sets the number of desktops */ static ObClient *focus_cycle_target; -static Popup *focus_cycle_popup; +Popup *focus_cycle_popup; void focus_startup() { @@ -222,17 +222,17 @@ /* nothing to focus, and already set it to none above */ } -static void popup_cycle(ObClient *c, gboolean show) +void popup_cycle(ObClient *c, gboolean show, Popup *popup) { if (!show) { - popup_hide(focus_cycle_popup); + popup_hide(popup); } else { Rect *a; ObClient *p = c; char *title; a = screen_physical_area_monitor(0); - popup_position(focus_cycle_popup, CenterGravity, + popup_position(popup, CenterGravity, a->x + a->width / 2, a->y + a->height / 2); /* popup_size(focus_cycle_popup, a->height/2, a->height/16); popup_show(focus_cycle_popup, c->title, @@ -240,7 +240,7 @@ */ /* XXX the size and the font extents need to be related on some level */ - popup_size(focus_cycle_popup, POPUP_WIDTH, POPUP_HEIGHT); + popup_size(popup, POPUP_WIDTH, POPUP_HEIGHT); /* use the transient's parent's title/icon */ while (p->transient_for && p->transient_for != OB_TRAN_GROUP) @@ -254,7 +254,7 @@ (p->iconic ? p->icon_title : p->title), NULL); - popup_show(focus_cycle_popup, + popup_show(popup, (title ? title : (c->iconic ? c->icon_title : c->title)), client_icon(p, 48, 48)); g_free(title); @@ -316,8 +316,15 @@ frame_adjust_focus(focus_cycle_target->frame, FALSE); focus_cycle_target = ft; frame_adjust_focus(focus_cycle_target->frame, TRUE); + if (config_focus_warppointer) + XWarpPointer(ob_display, 0, RootWindow(ob_display, ob_screen), + 0, 0, 0, 0, + focus_cycle_target->frame->area.x + + focus_cycle_target->frame->area.width/2, + focus_cycle_target->frame->area.y + + focus_cycle_target->frame->area.height/2); } - popup_cycle(ft, config_focus_popup); + popup_cycle(ft, config_focus_popup, focus_cycle_popup); return ft; } } while (it != start); @@ -329,7 +336,7 @@ g_list_free(order); order = NULL; - popup_cycle(ft, FALSE); + popup_cycle(ft, FALSE, focus_cycle_popup); return NULL; } only in patch2: unchanged: --- kernel/keyboard.c 2003/08/20 23:25:59 1.9 +++ kernel/keyboard.c 2003/08/22 21:42:22 @@ -146,7 +146,8 @@ if (e->xkey.keycode == ob_keycode(OB_KEY_RETURN)) done = TRUE; else if (e->xkey.keycode == ob_keycode(OB_KEY_ESCAPE)) { - if (grabbed_action->func == action_cycle_windows) { + if (grabbed_action->func == action_cycle_windows || + grabbed_action->func == action_directional_focus) { grabbed_action->data.cycle.cancel = TRUE; } if (grabbed_action->func == action_desktop_dir) { @@ -160,7 +161,8 @@ } } if (done) { - if (grabbed_action->func == action_cycle_windows) { + if (grabbed_action->func == action_cycle_windows || + grabbed_action->func == action_directional_focus) { grabbed_action->data.cycle.final = TRUE; } if (grabbed_action->func == action_desktop_dir) { @@ -218,7 +220,8 @@ if (act->func != NULL) { act->data.any.c = client; - if (act->func == action_cycle_windows) + if (act->func == action_cycle_windows || + act->func == action_directional_focus) { act->data.cycle.final = FALSE; act->data.cycle.cancel = FALSE; @@ -242,6 +245,7 @@ if ((act->func == action_cycle_windows || act->func == action_desktop_dir || + act->func == action_directional_focus || act->func == action_send_to_desktop_dir)) { keyboard_interactive_grab(e->xkey.state, client,