diff -Napur openbox-3.4.11.2.orig/openbox/actions/cyclewindows.c openbox-3.4.11.2/openbox/actions/cyclewindows.c --- openbox-3.4.11.2.orig/openbox/actions/cyclewindows.c 2010-05-14 17:59:05.000000000 +0400 +++ openbox-3.4.11.2/openbox/actions/cyclewindows.c 2010-12-20 20:52:13.000000000 +0300 @@ -16,6 +16,7 @@ typedef struct { gboolean forward; gboolean bar; gboolean raise; + gboolean focus; GSList *actions; } Options; @@ -61,6 +62,8 @@ static gpointer setup_func(ObParseInst * o->bar = parse_bool(doc, n); if ((n = parse_find_node("raise", node))) o->raise = parse_bool(doc, n); + if ((n = parse_find_node("focus", node))) + o->focus = parse_bool(doc, n); if ((n = parse_find_node("panels", node))) o->dock_windows = parse_bool(doc, n); if ((n = parse_find_node("desktop", node))) @@ -134,6 +137,9 @@ static gboolean run_func(ObActionsData * FALSE, FALSE); cycling = TRUE; + focus_restore(); + if (o->focus && ft) focus_temp_set_client(ft); + stacking_restore(); if (o->raise && ft) stacking_temp_raise(CLIENT_AS_WINDOW(ft)); @@ -194,6 +200,10 @@ static void end_cycle(gboolean cancel, g TRUE, cancel); cycling = FALSE; + /* if being called after actions_run_acts(), focus_restore() will reset + the visible focus to the same state as before run_func() was called */ + focus_restore(); + if (ft) actions_run_acts(o->actions, OB_USER_ACTION_KEYBOARD_KEY, state, -1, -1, 0, OB_FRAME_CONTEXT_NONE, ft); diff -Napur openbox-3.4.11.2.orig/openbox/focus.c openbox-3.4.11.2/openbox/focus.c --- openbox-3.4.11.2.orig/openbox/focus.c 2010-05-14 17:59:05.000000000 +0400 +++ openbox-3.4.11.2/openbox/focus.c 2010-12-20 20:39:50.000000000 +0300 @@ -39,6 +39,8 @@ ObClient *focus_client = NULL; GList *focus_order = NULL; +static ObClient *focus_temp_client = NULL; + void focus_startup(gboolean reconfig) { if (reconfig) return; @@ -69,10 +71,42 @@ static void push_to_top(ObClient *client focus_order = g_list_prepend(focus_order, client); } +static void move_visual_focus (ObClient *from, ObClient *to) +{ + Window active; + + client_focus(to); + + screen_install_colormap(from, FALSE); + screen_install_colormap(to, TRUE); + client_hilite(to, FALSE); + + active = to ? to->window : None; + PROP_SET32(RootWindow(ob_display, ob_screen), + net_active_window, window, active); +} + +void focus_restore() +{ + if (focus_temp_client) { + move_visual_focus(focus_temp_client, focus_client); + focus_temp_client = NULL; + } +} + +void focus_temp_set_client(ObClient *client) +{ + focus_temp_client = client; + move_visual_focus(focus_client, focus_temp_client); +} + + void focus_set_client(ObClient *client) { Window active; + if (focus_temp_client) return; + ob_debug_type(OB_DEBUG_FOCUS, "focus_set_client 0x%lx\n", client ? client->window : 0);