diff options
| author | Dana Jansens <danakj@orodu.net> | 2012-10-01 21:43:56 -0400 |
|---|---|---|
| committer | Dana Jansens <danakj@orodu.net> | 2012-10-06 23:04:57 -0400 |
| commit | 10a833b2cba11349a57071a7538cae9a560b8cc9 (patch) | |
| tree | 661456c5b74cafa939eaa97287ff6b823ce205bf /openbox/config.c | |
| parent | 5e282dae08be3b900e0337efa0fae8f3ffa92cd7 (diff) | |
Allow application rules to control window size (Fix bug 4661)
Use the following in your per-app rules:
<size>
<width>A</width>
<height>B</height>
</size>
A and B can be integer values to specify a size in pixels. They can also be
percentages or fractions to be relative to the size of the monitor the window
is placed on.
Diffstat (limited to 'openbox/config.c')
| -rw-r--r-- | openbox/config.c | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/openbox/config.c b/openbox/config.c index f7cbc3b9..e0c98493 100644 --- a/openbox/config.c +++ b/openbox/config.c @@ -153,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) @@ -219,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); @@ -322,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); |
