merge 7697 from trunk
authorDana Jansens <danakj@orodu.net>
Wed, 11 Jul 2007 15:36:44 +0000 (15:36 +0000)
committerDana Jansens <danakj@orodu.net>
Wed, 11 Jul 2007 15:36:44 +0000 (15:36 +0000)
data/rc.xml
data/rc.xsd
openbox/config.c
openbox/config.h
openbox/screen.c

index 3ad7994..1630de4 100644 (file)
   <!-- 'Center' or 'Top' -->
 </resize>
 
+<!-- You can reserve a portion of your screen where windows will not cover when
+     they are maximized, or when they are initially placed.
+     Many programs reserve space automatically, but you can use this in other
+     cases. -->
+<margins>
+  <top>0</top>
+  <bottom>0</bottom>
+  <left>0</left>
+  <right>0</right>
+</margins>
+
 <dock>
   <position>TopLeft</position>
   <!-- (Top|Bottom)(Left|Right|)|Top|Bottom|Left|Right|Floating -->
index e802cf3..f37b6b1 100644 (file)
         <xsd:element name="policy" type="ob:placementpolicy"/>
         <xsd:element name="center" type="ob:bool"/>
     </xsd:complexType>
+    <xsd:complexType name="margins">
+        <xsd:annotation>
+            <xsd:documentation>defines desktop margins</xsd:documentation>
+        </xsd:annotation>
+        <xsd:element minOccurs="0" name="top" type="xsd:integer"/>
+        <xsd:element minOccurs="0" name="left" type="xsd:integer"/>
+        <xsd:element minOccurs="0" name="right" type="xsd:integer"/>
+        <xsd:element minOccurs="0" name="bottom" type="xsd:integer"/>
+    </xsd:complexType>              
     <xsd:complexType name="theme">
         <xsd:element minOccurs="0" name="name" type="xsd:string"/>
         <xsd:element minOccurs="0" name="titleLayout" type="xsd:string"/>
index bc3aba9..5082f57 100644 (file)
@@ -38,6 +38,8 @@ gboolean config_focus_under_mouse;
 ObPlacePolicy config_place_policy;
 gboolean      config_place_center;
 
+StrutPartial config_margins;
+
 gchar   *config_theme;
 gboolean config_theme_keepborder;
 
@@ -503,6 +505,23 @@ static void parse_placement(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
         config_place_center = parse_bool(doc, n);
 }
 
+static void parse_margins(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
+                          gpointer d)
+{
+    xmlNodePtr n;
+
+    node = node->children;
+    
+    if ((n = parse_find_node("top", node)))
+        config_margins.top = MAX(0, parse_int(doc, n));
+    if ((n = parse_find_node("left", node)))
+        config_margins.left = MAX(0, parse_int(doc, n));
+    if ((n = parse_find_node("right", node)))
+        config_margins.right = MAX(0, parse_int(doc, n));
+    if ((n = parse_find_node("bottom", node)))
+        config_margins.bottom = MAX(0, parse_int(doc, n));
+}
+
 static void parse_theme(ObParseInst *i, xmlDocPtr doc, xmlNodePtr node,
                         gpointer d)
 {
@@ -879,6 +898,10 @@ void config_startup(ObParseInst *i)
 
     parse_register(i, "placement", parse_placement, NULL);
 
+    STRUT_PARTIAL_SET(config_margins, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
+
+    parse_register(i, "margins", parse_margins, NULL);
+
     config_theme = NULL;
 
     config_animate_iconify = TRUE;
index 8a365f8..42bf353 100644 (file)
@@ -79,6 +79,9 @@ extern ObPlacePolicy config_place_policy;
 /*! Place windows in the center of the free area */
 extern gboolean config_place_center;
 
+/*! User-specified margins around the edge of the screen(s) */
+extern StrutPartial config_margins;
+
 /*! When true windows' contents are refreshed while they are resized; otherwise
   they are not updated until the resize is complete */
 extern gboolean config_resize_redraw;
index e619509..707d0b6 100644 (file)
@@ -1195,6 +1195,15 @@ typedef struct {
     sl = g_slist_prepend(sl, ss); \
 }
 
+#define VALIDATE_STRUTS(sl, side, max) \
+{ \
+    GSList *it; \
+    for (it = sl; it; it = g_slist_next(it)) { \
+      ObScreenStrut *ss = it->data; \
+      ss->strut->side = MIN(max, ss->strut->side); \
+    } \
+}
+
 void screen_update_areas()
 {
     guint i, j;
@@ -1202,11 +1211,19 @@ void screen_update_areas()
     GList *it;
     GSList *sit;
 
-    ob_debug("updating screen areas\n");
-
     g_free(monitor_area);
     extensions_xinerama_screens(&monitor_area, &screen_num_monitors);
 
+    /* set up the user-specified margins */
+    config_margins.top_start = RECT_LEFT(monitor_area[screen_num_monitors]);
+    config_margins.top_end = RECT_RIGHT(monitor_area[screen_num_monitors]);
+    config_margins.bottom_start = RECT_LEFT(monitor_area[screen_num_monitors]);
+    config_margins.bottom_end = RECT_RIGHT(monitor_area[screen_num_monitors]);
+    config_margins.left_start = RECT_TOP(monitor_area[screen_num_monitors]);
+    config_margins.left_end = RECT_BOTTOM(monitor_area[screen_num_monitors]);
+    config_margins.right_start = RECT_TOP(monitor_area[screen_num_monitors]);
+    config_margins.right_end = RECT_BOTTOM(monitor_area[screen_num_monitors]);
+
     dims = g_new(gulong, 4 * screen_num_desktops * screen_num_monitors);
 
     RESET_STRUT_LIST(struts_left);
@@ -1235,6 +1252,24 @@ void screen_update_areas()
     if (dock_strut.bottom)
         ADD_STRUT_TO_LIST(struts_bottom, DESKTOP_ALL, &dock_strut);
 
+    if (config_margins.left)
+        ADD_STRUT_TO_LIST(struts_left, DESKTOP_ALL, &config_margins);
+    if (config_margins.top)
+        ADD_STRUT_TO_LIST(struts_top, DESKTOP_ALL, &config_margins);
+    if (config_margins.right)
+        ADD_STRUT_TO_LIST(struts_right, DESKTOP_ALL, &config_margins);
+    if (config_margins.bottom)
+        ADD_STRUT_TO_LIST(struts_bottom, DESKTOP_ALL, &config_margins);
+
+    VALIDATE_STRUTS(struts_left, left,
+                    monitor_area[screen_num_monitors].width / 2);
+    VALIDATE_STRUTS(struts_right, right,
+                    monitor_area[screen_num_monitors].width / 2);
+    VALIDATE_STRUTS(struts_top, top,
+                    monitor_area[screen_num_monitors].height / 2);
+    VALIDATE_STRUTS(struts_bottom, bottom,
+                    monitor_area[screen_num_monitors].height / 2);
+
     /* set up the work areas to be full screen */
     for (i = 0; i < screen_num_monitors; ++i)
         for (j = 0; j < screen_num_desktops; ++j) {