From: Mikael Magnusson Date: Sat, 26 Jan 2008 08:09:47 +0000 (+0100) Subject: Add a dontStop option in to make alt-tab not stop when a new window opens. X-Git-Tag: mikabox-3.4.7.2~58^2~3 X-Git-Url: http://git.openbox.org/?a=commitdiff_plain;h=c6be0873be364e30237cd69d3da8cb79a0cfbf4a;p=mikachu%2Fopenbox.git Add a dontStop option in to make alt-tab not stop when a new window opens. Currently focus gets a bit messed up when a window closes because I don't feel like tracking it down right now. Also causes crashes when windows close and whatnot. Although i think this was fixed recently by dana. --- diff --git a/openbox/client.c b/openbox/client.c index 55402cc6..da456bc1 100644 --- a/openbox/client.c +++ b/openbox/client.c @@ -31,6 +31,7 @@ #include "grab.h" #include "prompt.h" #include "focus.h" +#include "focus_cycle.h" #include "stacking.h" #include "openbox.h" #include "hooks.h" @@ -281,7 +282,8 @@ void client_manage(Window window, ObPrompt *prompt) client_search_focus_tree_full(self)) && /* this checks for focus=false for the window */ (!settings || settings->focus != 0) && - focus_valid_target(self, FALSE, FALSE, TRUE, FALSE, FALSE)) + focus_valid_target(self, FALSE, FALSE, TRUE, FALSE, FALSE) && + (!focus_cycle_target || !config_focus_dontstop)) { activate = TRUE; } diff --git a/openbox/config.c b/openbox/config.c index cc86ce7c..91b2c613 100644 --- a/openbox/config.c +++ b/openbox/config.c @@ -35,6 +35,7 @@ guint config_focus_delay; gboolean config_focus_raise; gboolean config_focus_last; gboolean config_focus_under_mouse; +gboolean config_focus_dontstop; ObPlacePolicy config_place_policy; gboolean config_place_center; @@ -536,6 +537,8 @@ static void parse_focus(xmlNodePtr node, gpointer d) config_focus_last = obt_parse_node_bool(n); if ((n = obt_parse_find_node(node, "underMouse"))) config_focus_under_mouse = obt_parse_node_bool(n); + if ((n = obt_parse_find_node(node, "dontStop"))) + config_focus_dontstop = obt_parse_node_bool(n); } static void parse_placement(xmlNodePtr node, gpointer d) @@ -944,6 +947,7 @@ void config_startup(ObtParseInst *i) config_focus_raise = FALSE; config_focus_last = TRUE; config_focus_under_mouse = FALSE; + config_focus_dontstop = FALSE; obt_parse_register(i, "focus", parse_focus, NULL); diff --git a/openbox/config.h b/openbox/config.h index cc5fa89a..ca312735 100644 --- a/openbox/config.h +++ b/openbox/config.h @@ -73,6 +73,8 @@ extern gboolean config_focus_last; /*! Try keep focus on the window under the mouse when the mouse is not moving */ extern gboolean config_focus_under_mouse; +/*! Rather than cancelling alt-tab when a client (dis)appears, don't focus anything */ +extern gboolean config_focus_dontstop; /*! The algorithm to use for placing new windows */ extern ObPlacePolicy config_place_policy; diff --git a/openbox/event.c b/openbox/event.c index e6a5719c..e604e7cb 100644 --- a/openbox/event.c +++ b/openbox/event.c @@ -591,10 +591,12 @@ static void event_process(const XEvent *ec, gpointer data) } else if (client != focus_client) { focus_left_screen = FALSE; - frame_adjust_focus(client->frame, TRUE); - focus_set_client(client); - client_calc_layer(client); - client_bring_helper_windows(client); + if (!focus_cycle_target || !config_focus_dontstop) { + frame_adjust_focus(client->frame, TRUE); + focus_set_client(client); + client_calc_layer(client); + client_bring_helper_windows(client); + } } } else if (e->type == FocusOut) { XEvent ce; diff --git a/openbox/focus.c b/openbox/focus.c index baf88e81..413886d0 100644 --- a/openbox/focus.c +++ b/openbox/focus.c @@ -40,6 +40,18 @@ ObClient *focus_client = NULL; GList *focus_order = NULL; +static gboolean stop_or_cancel_cycle(ObClient *c) +{ + /* in the middle of cycling..? kill it. + * or stop focusing */ + if (config_focus_dontstop) + return focus_interruptable(c); + else { + focus_cycle_stop(c); + return FALSE; + } +} + void focus_startup(gboolean reconfig) { if (reconfig) return; @@ -81,13 +93,17 @@ void focus_set_client(ObClient *client) if (focus_client == client) return; + /* in the middle of cycling..? kill it. */ + if (stop_or_cancel_cycle(focus_client) || + stop_or_cancel_cycle(client)) + { + return; + } + /* uninstall the old colormap, and install the new one */ screen_install_colormap(focus_client, FALSE); screen_install_colormap(client, TRUE); - /* in the middle of cycling..? kill it. */ - focus_cycle_stop(focus_client); - focus_cycle_stop(client); old = focus_client; focus_client = client; @@ -223,16 +239,14 @@ void focus_order_add_new(ObClient *c) focus_order = g_list_insert(focus_order, c, 1); } - /* in the middle of cycling..? kill it. */ - focus_cycle_stop(c); + stop_or_cancel_cycle(c); } void focus_order_remove(ObClient *c) { focus_order = g_list_remove(focus_order, c); - /* in the middle of cycling..? kill it. */ - focus_cycle_stop(c); + stop_or_cancel_cycle(c); } void focus_order_to_top(ObClient *c) diff --git a/openbox/focus_cycle.c b/openbox/focus_cycle.c index 063de644..14c65374 100644 --- a/openbox/focus_cycle.c +++ b/openbox/focus_cycle.c @@ -50,17 +50,21 @@ void focus_cycle_shutdown(gboolean reconfig) if (reconfig) return; } -void focus_cycle_stop(ObClient *ifclient) +gboolean focus_interruptable(ObClient *ifclient) { /* stop focus cycling if the given client is a valid focus target, and so the cycling is being disrupted */ - if (focus_cycle_target && ifclient && - focus_valid_target(ifclient, TRUE, - focus_cycle_iconic_windows, - focus_cycle_all_desktops, - focus_cycle_dock_windows, - focus_cycle_desktop_windows)) - { + return focus_cycle_target && ifclient && + focus_valid_target(ifclient, TRUE, + focus_cycle_iconic_windows, + focus_cycle_all_desktops, + focus_cycle_dock_windows, + focus_cycle_desktop_windows); +} + +void focus_cycle_stop(ObClient *ifclient) +{ + if (focus_interruptable(ifclient)) { focus_cycle(TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE,TRUE); focus_directional_cycle(0, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE, TRUE); } diff --git a/openbox/focus_cycle.h b/openbox/focus_cycle.h index c31abc81..e1906038 100644 --- a/openbox/focus_cycle.h +++ b/openbox/focus_cycle.h @@ -48,6 +48,7 @@ struct _ObClient* focus_directional_cycle(ObDirection dir, gboolean dialog, gboolean done, gboolean cancel); +gboolean focus_interruptable(struct _ObClient *ifclient); void focus_cycle_stop(struct _ObClient *ifclient); #endif