Directional switching
authorIan Zimmerman <itz@buug.org>
Wed, 8 Jul 2015 23:02:00 +0000 (16:02 -0700)
committerMikael Magnusson <mikachu@gmail.com>
Mon, 7 Sep 2015 08:13:44 +0000 (10:13 +0200)
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.

data/rc.xsd
openbox/config.c
openbox/config.h
openbox/focus_cycle.c

index c8f5638bc95b6be6b08f818336a6ec4079a07b0f..dcca6bcbec91f733fd37d97378f98f19b35c92be 100644 (file)
@@ -62,6 +62,8 @@
             <xsd:element minOccurs="0" name="focusDelay" type="xsd:integer"/>
             <xsd:element minOccurs="0" name="raiseOnFocus" type="ob:bool"/>
             <xsd:element minOccurs="0" name="unfocusOnLeave" type="ob:bool"/>
+            <xsd:element minOccurs="0" name="directionalDistanceWeight" type="xsd:integer"/>
+            <xsd:element minOccurs="0" name="directionalAngleWeight" type="xsd:integer"/>
         </xsd:all>
     </xsd:complexType>
     <xsd:complexType name="placement">
index dad5d1bf95d36ee63a5b5fd4c91c13a3143f20af..83c2bf8c9e368a355639be2ac4c8711597613c8f 100644 (file)
@@ -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)
index 96a66cf1ec3ba95323f2f66ba405842ce659ad2f..51944b374ea3d5be05c8ad9b696d025f8595767b 100644 (file)
@@ -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;
index de176501e562de9844b8327e86a44a93e8bea11b..24c0d2a154f1df73f7ed3447de9fdb17f1e04e37 100644 (file)
@@ -25,6 +25,7 @@
 #include "screen.h"
 #include "openbox.h"
 #include "debug.h"
+#include "config.h"
 
 #include <X11/Xlib.h>
 #include <glib.h>
@@ -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