Re: Directional switching

Ian Zimmerman <[email protected]>
Newsgroups gmane.comp.window-managers.openbox
Message-ID <[email protected]>
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.

_______________________________________________
openbox mailing list
[email protected]
http://icculus.org/mailman/listinfo/openbox
openbox-directional.patch (text/x-diff, 3.1 KB)
diff --git a/data/rc.xsd b/data/rc.xsd
index 2f90b6e..bad1492 100644
--- a/data/rc.xsd
+++ b/data/rc.xsd
@@ -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">
diff --git a/openbox/config.c b/openbox/config.c
index 26d3ea0..e7fcb88 100644
--- a/openbox/config.c
+++ b/openbox/config.c
@@ -36,6 +36,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;
@@ -636,6 +638,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 96a66cf..51944b3 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 de17650..24c0d2a 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 <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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.