From: Ian Zimmerman Date: Wed, 8 Jul 2015 23:02:00 +0000 (-0700) Subject: Directional switching X-Git-Url: http://git.openbox.org/?a=commitdiff_plain;h=025822e7b5609943d3635434b91d43b4de8a2a81;p=mikachu%2Fopenbox.git Directional switching On 2015-07-07 13:17 -0700, Ian Zimmerman wrote: > The 2 and 5 could/should be rc.xml parameters. With defaults 1 and 1 > you'd have the current behavior. Is there interest in me pursuing that > path and providing a more complete patch? Not much interest, but here it is anyway. I want to be on record as using this feature to its full extent, and if necessary maintaining it. -- Please *no* private copies of mailing list or newsgroup messages. Rule 420: All persons more than eight miles high to leave the court. --- diff --git a/data/rc.xsd b/data/rc.xsd index c8f5638b..dcca6bcb 100644 --- a/data/rc.xsd +++ b/data/rc.xsd @@ -62,6 +62,8 @@ + + diff --git a/openbox/config.c b/openbox/config.c index dad5d1bf..83c2bf8c 100644 --- a/openbox/config.c +++ b/openbox/config.c @@ -35,6 +35,8 @@ gboolean config_focus_raise; gboolean config_focus_last; gboolean config_focus_under_mouse; gboolean config_unfocus_leave; +guint config_directional_distance_weight; +guint config_directional_angle_weight; ObPlacePolicy config_place_policy; gboolean config_place_center; @@ -635,6 +637,14 @@ static void parse_focus(xmlNodePtr node, gpointer d) config_focus_under_mouse = obt_xml_node_bool(n); if ((n = obt_xml_find_node(node, "unfocusOnLeave"))) config_unfocus_leave = obt_xml_node_bool(n); + if ((n = obt_xml_find_node(node, "directionalDistanceWeight"))) + config_directional_distance_weight = obt_xml_node_int(n); + else + config_directional_distance_weight = 1U; + if ((n = obt_xml_find_node(node, "directionalAngleWeight"))) + config_directional_angle_weight = obt_xml_node_int(n); + else + config_directional_angle_weight = 1U; } static void parse_placement(xmlNodePtr node, gpointer d) diff --git a/openbox/config.h b/openbox/config.h index 96a66cf1..51944b37 100644 --- a/openbox/config.h +++ b/openbox/config.h @@ -85,6 +85,10 @@ extern gboolean config_focus_under_mouse; /*! Remove focus from windows when the mouse leaves them */ extern gboolean config_unfocus_leave; +/*! Weight of distance part of score for directional switching */ +extern guint config_directional_distance_weight; +/*! Weight of angle part of score for directional switching */ +extern guint config_directional_angle_weight; /*! The algorithm to use for placing new windows */ extern ObPlacePolicy config_place_policy; diff --git a/openbox/focus_cycle.c b/openbox/focus_cycle.c index de176501..24c0d2a1 100644 --- a/openbox/focus_cycle.c +++ b/openbox/focus_cycle.c @@ -25,6 +25,7 @@ #include "screen.h" #include "openbox.h" #include "debug.h" +#include "config.h" #include #include @@ -250,7 +251,8 @@ static ObClient *focus_find_directional(ObClient *c, ObDirection dir, continue; /* Calculate score for this window. The smaller the better. */ - score = distance + offset; + score = (distance * config_directional_distance_weight + + offset * config_directional_angle_weight); /* windows more than 45 degrees off the direction are * heavily penalized and will only be chosen if nothing