From 0993012776e159a5b94a34034289f2274ad6c7bf Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Wed, 23 Jun 2004 13:50:26 +0000 Subject: [PATCH] try to fix focus switching with mouse actions up a bit --- openbox/action.c | 3 ++- openbox/focus.c | 55 +++++++++++++++++++++++++++++++----------------- openbox/focus.h | 4 ++-- 3 files changed, 40 insertions(+), 22 deletions(-) diff --git a/openbox/action.c b/openbox/action.c index fbfb0960..0ab6120d 100644 --- a/openbox/action.c +++ b/openbox/action.c @@ -1411,7 +1411,7 @@ void action_cycle_windows(union ActionData *data) on us */ event_halt_focus_delay(); - focus_cycle(data->cycle.forward, data->cycle.linear, + focus_cycle(data->cycle.forward, data->cycle.linear, data->any.interactive, data->cycle.dialog, data->cycle.inter.final, data->cycle.inter.cancel); } @@ -1423,6 +1423,7 @@ void action_directional_focus(union ActionData *data) event_halt_focus_delay(); focus_directional_cycle(data->interdiraction.direction, + data->any.interactive, data->interdiraction.dialog, data->interdiraction.inter.final, data->interdiraction.inter.cancel); diff --git a/openbox/focus.c b/openbox/focus.c index 09d642c2..9d16387b 100644 --- a/openbox/focus.c +++ b/openbox/focus.c @@ -538,7 +538,7 @@ static gboolean valid_focus_target(ObClient *ft) return FALSE; } -void focus_cycle(gboolean forward, gboolean linear, +void focus_cycle(gboolean forward, gboolean linear, gboolean interactive, gboolean dialog, gboolean done, gboolean cancel) { static ObClient *first = NULL; @@ -547,20 +547,26 @@ void focus_cycle(gboolean forward, gboolean linear, GList *it, *start, *list; ObClient *ft = NULL; - if (cancel) { - focus_cycle_target = NULL; - goto done_cycle; - } else if (done) - goto done_cycle; + if (interactive) { + if (cancel) { + focus_cycle_target = NULL; + goto done_cycle; + } else if (done) + goto done_cycle; - if (!focus_order[screen_desktop]) - goto done_cycle; + if (!focus_order[screen_desktop]) + goto done_cycle; - if (!first) first = focus_client; - if (!focus_cycle_target) focus_cycle_target = focus_client; + if (!first) first = focus_client; - if (linear) list = client_list; - else list = focus_order[screen_desktop]; + if (linear) list = client_list; + else list = focus_order[screen_desktop]; + } else { + if (!focus_order[screen_desktop]) + goto done_cycle; + list = client_list; + } + if (!focus_cycle_target) focus_cycle_target = focus_client; start = it = g_list_find(list, focus_cycle_target); if (!start) /* switched desktops or something? */ @@ -577,12 +583,18 @@ void focus_cycle(gboolean forward, gboolean linear, } ft = it->data; if (valid_focus_target(ft)) { - if (ft != focus_cycle_target) { /* prevents flicker */ + if (interactive) { + if (ft != focus_cycle_target) { /* prevents flicker */ + focus_cycle_target = ft; + focus_cycle_draw_indicator(); + } + popup_cycle(ft, dialog); + return; + } else if (ft != focus_cycle_target) { focus_cycle_target = ft; - focus_cycle_draw_indicator(); + done = TRUE; + break; } - popup_cycle(ft, dialog); - return; } } while (it != start); @@ -596,18 +608,23 @@ done_cycle: g_list_free(order); order = NULL; - focus_cycle_draw_indicator(); - popup_cycle(ft, FALSE); + if (interactive) { + focus_cycle_draw_indicator(); + popup_cycle(ft, FALSE); + } return; } -void focus_directional_cycle(ObDirection dir, +void focus_directional_cycle(ObDirection dir, gboolean interactive, gboolean dialog, gboolean done, gboolean cancel) { static ObClient *first = NULL; ObClient *ft = NULL; + if (!interactive) + return; + if (cancel) { focus_cycle_target = NULL; goto done_cycle; diff --git a/openbox/focus.h b/openbox/focus.h index 4a3f0b1a..345685c0 100644 --- a/openbox/focus.h +++ b/openbox/focus.h @@ -57,9 +57,9 @@ struct _ObClient* focus_fallback_target(ObFocusFallbackType type); void focus_fallback(ObFocusFallbackType type); /*! Cycle focus amongst windows. */ -void focus_cycle(gboolean forward, gboolean linear, +void focus_cycle(gboolean forward, gboolean linear, gboolean interactive, gboolean dialog, gboolean done, gboolean cancel); -void focus_directional_cycle(ObDirection dir, +void focus_directional_cycle(ObDirection dir, gboolean interactive, gboolean dialog, gboolean done, gboolean cancel); void focus_cycle_draw_indicator(); -- 2.45.2