]> Dogcows Code - chaz/openbox/blobdiff - openbox/config.c
Allow application rules to control window size (Fix bug 4661)
[chaz/openbox] / openbox / config.c
index d5ff8c45c9b7e12608cc7d825ed3322b5fb14b31..e0c984934e95f03536023bb9e754618125e76a9d 100644 (file)
@@ -37,7 +37,6 @@ 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,6 +153,14 @@ void config_app_settings_copy_non_defaults(const ObAppSettings *src,
         dst->position = src->position;
         /* 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;
+    }
 }
 
 void config_parse_relative_number(gchar *s, gint *num, gint *denom)
@@ -220,9 +227,10 @@ static void parse_per_app_settings(xmlNodePtr node, gpointer d)
         group_name_set, group_class_set;
     ObClientType type;
     gboolean x_pos_given;
+    gboolean width_given;
 
     while (app) {
-        x_pos_given = FALSE;
+        x_pos_given = width_given = FALSE;
 
         class_set = obt_xml_attr_string(app, "class", &class);
         name_set = obt_xml_attr_string(app, "name", &name);
@@ -323,6 +331,40 @@ static void parse_per_app_settings(xmlNodePtr node, gpointer d)
                 obt_xml_attr_bool(n, "force", &settings->pos_force);
             }
 
+            if ((n = obt_xml_find_node(app->children, "size"))) {
+                if ((c = obt_xml_find_node(n->children, "width"))) {
+                    if (!obt_xml_node_contains(c, "default")) {
+                        gchar *s = obt_xml_node_string(c);
+                        config_parse_relative_number(
+                            s,
+                            &settings->width_num,
+                            &settings->width_denom);
+                        if (settings->width_num > 0 &&
+                            settings->width_denom >= 0)
+                        {
+                            width_given = TRUE;
+                        }
+                        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 ((n = obt_xml_find_node(app->children, "focus")))
                 if (!obt_xml_node_contains(n, "default"))
                     settings->focus = obt_xml_node_bool(n);
@@ -598,8 +640,6 @@ static void parse_placement(xmlNodePtr node, gpointer d)
     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;
@@ -1027,7 +1067,6 @@ 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;
This page took 0.022241 seconds and 4 git commands to generate.