From da2d394f1224830ffa0bd541e87b262d4f69dd5d Mon Sep 17 00:00:00 2001 From: Mikael Magnusson Date: Sun, 11 Aug 2013 14:33:46 +0200 Subject: [PATCH] Allow specifying only one of width and height in per-app settings size --- openbox/config.c | 23 +++++++++++++---------- openbox/place.c | 29 ++++++++++++++--------------- 2 files changed, 27 insertions(+), 25 deletions(-) diff --git a/openbox/config.c b/openbox/config.c index 889bbcb..a1b9f96 100644 --- a/openbox/config.c +++ b/openbox/config.c @@ -213,7 +213,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")) @@ -265,19 +264,23 @@ static void parse_single_per_app_settings(xmlNodePtr app, &settings->width_num, &settings->width_denom); if (settings->width_num > 0 && settings->width_denom >= 0) - width_given = TRUE; + settings->size_given = TRUE; g_free(s); - } + } else + settings->size_given = TRUE; } - 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) + 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->size_given = TRUE; + g_free(s); + } else settings->size_given = TRUE; - g_free(s); } } diff --git a/openbox/place.c b/openbox/place.c index d2d66e0..cbbc002 100644 --- a/openbox/place.c +++ b/openbox/place.c @@ -327,23 +327,22 @@ static void place_per_app_setting_size(ObClient *client, Rect *screen, ob_debug("sizing by per-app settings"); - g_assert(settings->width_num > 0); - g_assert(settings->width_denom >= 0); - g_assert(settings->height_num > 0); - g_assert(settings->height_denom >= 0); - - if (!settings->width_denom) - *w = settings->width_num; - else { - *w = screen->width * settings->width_num / settings->width_denom; - *w = MIN(*w, screen->width); + if (settings->width_num) { + if (!settings->width_denom) + *w = settings->width_num; + else { + *w = screen->width * settings->width_num / settings->width_denom; + *w = MIN(*w, screen->width); + } } - if (!settings->height_denom) - *h = settings->height_num; - else { - *h = screen->height * settings->height_num / settings->height_denom; - *h = MIN(*h, screen->height); + if (settings->height_num) { + if (!settings->height_denom) + *h = settings->height_num; + else { + *h = screen->height * settings->height_num / settings->height_denom; + *h = MIN(*h, screen->height); + } } } -- 1.9.1