Add the old <center> option for the placement policy. (Bug 5946)
[dana/openbox.git] / openbox / config.c
index 49fc29b..76f4856 100644 (file)
@@ -37,6 +37,7 @@ gboolean config_focus_under_mouse;
 gboolean config_unfocus_leave;
 
 ObPlacePolicy  config_place_policy;
+gboolean       config_place_center;
 ObPlaceMonitor config_place_monitor;
 
 guint          config_primary_monitor_index;
@@ -154,13 +155,10 @@ void config_app_settings_copy_non_defaults(const ObAppSettings *src,
         /* monitor is copied above */
     }
 
-    if (src->size_given) {
-        dst->size_given = TRUE;
-        dst->width_num = src->width_num;
-        dst->width_denom = src->width_denom;
-        dst->height_num = src->height_num;
-        dst->height_denom = src->height_denom;
-    }
+    dst->width_num = src->width_num;
+    dst->width_denom = src->width_denom;
+    dst->height_num = src->height_num;
+    dst->height_denom = src->height_denom;
 }
 
 void config_parse_relative_number(gchar *s, gint *num, gint *denom)
@@ -212,7 +210,6 @@ static void parse_single_per_app_settings(xmlNodePtr app,
 {
     xmlNodePtr n, c;
     gboolean x_pos_given = FALSE;
-    gboolean width_given = FALSE;
 
     if ((n = obt_xml_find_node(app->children, "decor")))
         if (!obt_xml_node_contains(n, "default"))
@@ -263,20 +260,22 @@ static void parse_single_per_app_settings(xmlNodePtr app,
                 config_parse_relative_number(s,
                                              &settings->width_num,
                                              &settings->width_denom);
-                if (settings->width_num > 0 && settings->width_denom >= 0)
-                    width_given = TRUE;
+                if (settings->width_num <= 0 || settings->width_denom < 0)
+                    settings->width_num = settings->width_denom = 0;
                 g_free(s);
             }
         }
 
-        if (width_given && (c = obt_xml_find_node(n->children, "height"))) {
-            gchar *s = obt_xml_node_string(c);
-            config_parse_relative_number(s,
-                                         &settings->height_num,
-                                         &settings->height_denom);
-            if (settings->height_num > 0 && settings->height_denom >= 0)
-                settings->size_given = TRUE;
-            g_free(s);
+        if ((c = obt_xml_find_node(n->children, "height"))) {
+            if (!obt_xml_node_contains(c, "default")) {
+                gchar *s = obt_xml_node_string(c);
+                config_parse_relative_number(s,
+                                             &settings->height_num,
+                                             &settings->height_denom);
+                if (settings->height_num <= 0 || settings->height_denom < 0)
+                    settings->height_num = settings->height_denom = 0;
+                g_free(s);
+            }
         }
     }
 
@@ -627,9 +626,13 @@ static void parse_placement(xmlNodePtr node, gpointer d)
 
     node = node->children;
 
-    if ((n = obt_xml_find_node(node, "policy")))
+    if ((n = obt_xml_find_node(node, "policy"))) {
         if (obt_xml_node_contains(n, "UnderMouse"))
             config_place_policy = OB_PLACE_POLICY_MOUSE;
+    }
+    if ((n = obt_xml_find_node(node, "center"))) {
+        config_place_center = obt_xml_node_bool(n);
+    }
     if ((n = obt_xml_find_node(node, "monitor"))) {
         if (obt_xml_node_contains(n, "active"))
             config_place_monitor = OB_PLACE_MONITOR_ACTIVE;
@@ -1057,6 +1060,7 @@ void config_startup(ObtXmlInst *i)
     obt_xml_register(i, "focus", parse_focus, NULL);
 
     config_place_policy = OB_PLACE_POLICY_SMART;
+    config_place_center = TRUE;
     config_place_monitor = OB_PLACE_MONITOR_PRIMARY;
 
     config_primary_monitor_index = 1;