Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 459ec44

Browse files
committedOct 2, 2012
Allow non-interactive focus cycling.
Adds an <interactive>bool</interactive> option to the NextWindow and PreviousWindow actions. When it is false, the action is not interactive and will immediately switch focus to whatever the next focus target is. Removing the "interactive" flag from the focus_cycle() method, as it was unused previously, and the new code does not make use of it either. In order to be non-interactive it simply starts a focus_cycle then immediately ends it when the action ends. The "interactive" flag in focus_cycle() forced a linear cycling order which may not be what you want, so the new method is preferrable anyhow.
1 parent 276f125 commit 459ec44

File tree

3 files changed

+41
-49
lines changed

3 files changed

+41
-49
lines changed
 

‎openbox/actions/cyclewindows.c

+20-13
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ typedef struct {
1616
gboolean forward;
1717
gboolean bar;
1818
gboolean raise;
19+
gboolean interactive;
1920
ObFocusCyclePopupMode dialog_mode;
2021
GSList *actions;
2122

@@ -80,6 +81,8 @@ static gpointer setup_func(xmlNodePtr node,
8081
else if (obt_xml_node_contains(n, "icons"))
8182
o->dialog_mode = OB_FOCUS_CYCLE_POPUP_MODE_ICONS;
8283
}
84+
if ((n = obt_xml_find_node(node, "interactive")))
85+
o->interactive = obt_xml_node_bool(n);
8386
if ((n = obt_xml_find_node(node, "bar")))
8487
o->bar = obt_xml_node_bool(n);
8588
if ((n = obt_xml_find_node(node, "raise")))
@@ -157,21 +160,24 @@ static gboolean run_func(ObActionsData *data, gpointer options)
157160
Options *o = options;
158161
struct _ObClient *ft;
159162

160-
ft = focus_cycle(o->forward,
161-
o->all_desktops,
162-
!o->only_hilite_windows,
163-
o->dock_windows,
164-
o->desktop_windows,
165-
o->linear,
166-
TRUE,
167-
o->bar,
168-
o->dialog_mode,
169-
FALSE, FALSE);
163+
gboolean done = FALSE;
164+
gboolean cancel = FALSE;
165+
166+
ft = focus_cycle(
167+
o->forward,
168+
o->all_desktops,
169+
!o->only_hilite_windows,
170+
o->dock_windows,
171+
o->desktop_windows,
172+
o->linear,
173+
(o->interactive ? o->bar : FALSE),
174+
(o->interactive ? o->dialog_mode : OB_FOCUS_CYCLE_POPUP_MODE_NONE),
175+
done, cancel);
170176

171177
stacking_restore();
172178
if (o->raise && ft) stacking_temp_raise(CLIENT_AS_WINDOW(ft));
173179

174-
return TRUE;
180+
return o->interactive;
175181
}
176182

177183
static gboolean i_input_func(guint initial_state,
@@ -231,16 +237,17 @@ static void i_post_func(gpointer options)
231237
Options *o = options;
232238
struct _ObClient *ft;
233239

240+
gboolean done = TRUE;
241+
234242
ft = focus_cycle(o->forward,
235243
o->all_desktops,
236244
!o->only_hilite_windows,
237245
o->dock_windows,
238246
o->desktop_windows,
239247
o->linear,
240-
TRUE,
241248
o->bar,
242249
o->dialog_mode,
243-
TRUE, o->cancel);
250+
done, o->cancel);
244251

245252
if (ft)
246253
actions_run_acts(o->actions, OB_USER_ACTION_KEYBOARD_KEY,

‎openbox/focus_cycle.c

+19-34
Original file line numberDiff line numberDiff line change
@@ -93,40 +93,34 @@ void focus_cycle_reorder()
9393
focus_cycle_update_indicator(focus_cycle_target);
9494
if (!focus_cycle_target)
9595
focus_cycle(TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,
96-
TRUE, TRUE, OB_FOCUS_CYCLE_POPUP_MODE_NONE,
96+
TRUE, OB_FOCUS_CYCLE_POPUP_MODE_NONE,
9797
TRUE, TRUE);
9898
}
9999
}
100100

101101
ObClient* focus_cycle(gboolean forward, gboolean all_desktops,
102102
gboolean nonhilite_windows,
103103
gboolean dock_windows, gboolean desktop_windows,
104-
gboolean linear, gboolean interactive,
105-
gboolean showbar, ObFocusCyclePopupMode mode,
104+
gboolean linear, gboolean showbar,
105+
ObFocusCyclePopupMode mode,
106106
gboolean done, gboolean cancel)
107107
{
108108
static GList *order = NULL;
109109
GList *it, *start, *list;
110110
ObClient *ft = NULL;
111111
ObClient *ret = NULL;
112112

113-
if (interactive) {
114-
if (cancel) {
115-
focus_cycle_target = NULL;
116-
goto done_cycle;
117-
} else if (done)
118-
goto done_cycle;
113+
if (cancel) {
114+
focus_cycle_target = NULL;
115+
goto done_cycle;
116+
} else if (done)
117+
goto done_cycle;
119118

120-
if (!focus_order)
121-
goto done_cycle;
119+
if (!focus_order)
120+
goto done_cycle;
122121

123-
if (linear) list = client_list;
124-
else list = focus_order;
125-
} else {
126-
if (!focus_order)
127-
goto done_cycle;
128-
list = client_list;
129-
}
122+
if (linear) list = client_list;
123+
else list = focus_order;
130124

131125
if (focus_cycle_target == NULL) {
132126
focus_cycle_linear = linear;
@@ -153,21 +147,14 @@ ObClient* focus_cycle(gboolean forward, gboolean all_desktops,
153147
}
154148
ft = it->data;
155149
if (focus_cycle_valid(ft)) {
156-
if (interactive) {
157-
if (ft != focus_cycle_target) { /* prevents flicker */
158-
focus_cycle_target = ft;
159-
focus_cycle_type = OB_CYCLE_NORMAL;
160-
focus_cycle_draw_indicator(showbar ? ft : NULL);
161-
}
162-
/* same arguments as focus_target_valid */
163-
focus_cycle_popup_show(ft, mode, focus_cycle_linear);
164-
return focus_cycle_target;
165-
} else if (ft != focus_cycle_target) {
150+
if (ft != focus_cycle_target) { /* prevents flicker */
166151
focus_cycle_target = ft;
167152
focus_cycle_type = OB_CYCLE_NORMAL;
168-
done = TRUE;
169-
break;
153+
focus_cycle_draw_indicator(showbar ? ft : NULL);
170154
}
155+
/* same arguments as focus_target_valid */
156+
focus_cycle_popup_show(ft, mode, focus_cycle_linear);
157+
return focus_cycle_target;
171158
}
172159
} while (it != start);
173160

@@ -179,10 +166,8 @@ ObClient* focus_cycle(gboolean forward, gboolean all_desktops,
179166
g_list_free(order);
180167
order = NULL;
181168

182-
if (interactive) {
183-
focus_cycle_draw_indicator(NULL);
184-
focus_cycle_popup_hide();
185-
}
169+
focus_cycle_draw_indicator(NULL);
170+
focus_cycle_popup_hide();
186171

187172
return ret;
188173
}

‎openbox/focus_cycle.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ void focus_cycle_shutdown(gboolean reconfig);
3838
struct _ObClient* focus_cycle(gboolean forward, gboolean all_desktops,
3939
gboolean nonhilite_windows,
4040
gboolean dock_windows, gboolean desktop_windows,
41-
gboolean linear, gboolean interactive,
42-
gboolean showbar, ObFocusCyclePopupMode mode,
41+
gboolean linear, gboolean showbar,
42+
ObFocusCyclePopupMode mode,
4343
gboolean done, gboolean cancel);
4444
struct _ObClient* focus_directional_cycle(ObDirection dir,
4545
gboolean dock_windows,

0 commit comments

Comments
 (0)
Please sign in to comment.