Added <windowMargin> config item and made the margin thing respect it!
authorDave Foster <daf@minuslab.net>
Sat, 23 Aug 2008 04:20:37 +0000 (00:20 -0400)
committerDave Foster <daf@minuslab.net>
Sat, 23 Aug 2008 04:20:37 +0000 (00:20 -0400)
data/rc.xml
data/rc.xsd
openbox/client.c
openbox/config.c
openbox/config.h
openbox/resist.c

index 2b65b25fd1cd3a2fafe57ff264f01a90e9e668f2..7090a26803f100d48e77d30b21e5779bebea2f01 100644 (file)
   <screen_edge_strength>20</screen_edge_strength>
 </resistance>
 
+<!-- amount of space around windows to respect in terms of 
+     moving/resizing/growing/shrinking -->
+<windowMargin>0</windowMargin>
+
 <focus>
   <focusNew>yes</focusNew>
   <!-- always try to focus new windows when they appear. other rules do
index c51135b4ff61e7a93f2e78a82b2bed9fc540db93..7e96b3b8c90e8b1f64e0593c9d98d76bd90a085f 100644 (file)
@@ -65,6 +65,7 @@
         <xsd:element minOccurs="0" name="right" type="xsd:integer"/>
         <xsd:element minOccurs="0" name="bottom" type="xsd:integer"/>
     </xsd:complexType>              
+    <xsd:element name="windowMargin" type="xsd:integer"/>
     <xsd:complexType name="theme">
         <xsd:element minOccurs="0" name="name" type="xsd:string"/>
         <xsd:element minOccurs="0" name="titleLayout" type="xsd:string"/>
index ae157fb426ab9d2e8bd56a953b2f2d9824f317b3..749527ddb589da05c59a948a7136003d48cc1132 100644 (file)
@@ -55,7 +55,7 @@
 #include <glib.h>
 #include <X11/Xutil.h>
 
-extern StrutPartial config_margins;
+extern guint config_window_margin;
 
 /*! The event mask to grab on client windows */
 #define CLIENT_EVENTMASK (PropertyChangeMask | StructureNotifyMask | \
@@ -4254,10 +4254,10 @@ void client_find_edge_directional(ObClient *self, ObDirection dir,
 
         ob_debug("trying window %s\n", cur->title);
 
-        RECT_SET(expand, cur->frame->area.x - config_margins.left
-                         cur->frame->area.y - config_margins.top
-                         cur->frame->area.width + config_margins.left + config_margins.right
-                         cur->frame->area.height + config_margins.top + config_margins.bottom);
+        RECT_SET(expand, cur->frame->area.x - config_window_margin
+                         cur->frame->area.y - config_window_margin
+                         cur->frame->area.width + config_window_margin * 2
+                         cur->frame->area.height + config_window_margin * 2);
         detect_edge(expand, dir, my_head, my_size, my_edge_start,
                     my_edge_size, dest, near_edge);
     }
index b623931a6429e386ea9bb40055f3d67af6d2f550..bd91432126fd9f79ae74bae6b4319d084fff4b6f 100644 (file)
@@ -96,6 +96,8 @@ GSList *config_menu_files;
 gint     config_resist_win;
 gint     config_resist_edge;
 
+guint    config_window_margin;
+
 GSList *config_per_app_settings;
 
 ObAppSettings* config_create_app_settings(void)
@@ -822,6 +824,12 @@ static void parse_resistance(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
         config_resist_edge = parse_int(doc, n);
 }
 
+static void parse_window_margin(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
+                                gpointer data)
+{
+    config_window_margin = parse_int(doc, node);
+}
+
 typedef struct
 {
     const gchar *key;
@@ -994,6 +1002,10 @@ void config_startup(ObParseInst *i)
 
     parse_register(i, "resistance", parse_resistance, NULL);
 
+    config_window_margin = 0;
+
+    parse_register(i, "windowMargin", parse_window_margin, NULL);
+
     config_menu_hide_delay = 250;
     config_menu_middle = FALSE;
     config_submenu_show_delay = 0;
index 109d822153482216cc632042a162d7ea9203befc..93f12ce1605af7b7c663acd408dd62c1d527b5b6 100644 (file)
@@ -173,6 +173,9 @@ extern gint config_resist_win;
 /*! Number of pixels to resist while crossing a screen's edge */
 extern gint config_resist_edge;
 
+/*! Number of pixels surrounding windows, affects move/resize/grow/shrink */
+extern guint config_window_margin;
+
 /*! Delay for hiding menu when opening in milliseconds */
 extern guint    config_menu_hide_delay;
 /*! Center menus vertically about the parent entry */
index 11e3b92fedaf6fadfb16d61ca703be4247e9b2bf..f6823d3c289a25747cceaf2117018261cb96dd58 100644 (file)
@@ -28,7 +28,7 @@
 
 #include <glib.h>
 
-extern StrutPartial config_margins;
+extern guint config_window_margin;
 
 static gboolean resist_move_window(Rect window,
                                    Rect target, gint resist,
@@ -133,10 +133,13 @@ void resist_move_windows(ObClient *c, gint resist, gint *x, gint *y)
             break;
 
         /* now check window with the expanded margin area */
-        RECT_SET(expand, target->frame->area.x - config_margins.left, 
-                         target->frame->area.y - config_margins.top, 
-                         target->frame->area.width + config_margins.left + config_margins.right, 
-                         target->frame->area.height + config_margins.top + config_margins.bottom);
+        if (config_window_margin == 0)
+            continue;
+
+        RECT_SET(expand, target->frame->area.x - config_window_margin, 
+                         target->frame->area.y - config_window_margin, 
+                         target->frame->area.width + config_window_margin * 2, 
+                         target->frame->area.height + config_window_margin * 2);
 
         if (resist_move_window(c->frame->area, expand,
                                resist, x, y))
@@ -333,11 +336,13 @@ void resist_size_windows(ObClient *c, gint resist, gint *w, gint *h,
             break;
 
         /* now check window with the expanded margin area */
-        RECT_SET(expand, target->frame->area.x - config_margins.left, 
-                         target->frame->area.y - config_margins.top, 
-                         target->frame->area.width + config_margins.left + config_margins.right, 
-                         target->frame->area.height + config_margins.top + config_margins.bottom);
+        if (config_window_margin == 0)
+            continue;
 
+        RECT_SET(expand, target->frame->area.x - config_window_margin, 
+                         target->frame->area.y - config_window_margin, 
+                         target->frame->area.width + config_window_margin * 2, 
+                         target->frame->area.height + config_window_margin * 2);
 
         if (resist_size_window(c->frame->area, expand,
                                resist, w, h, dir))