summaryrefslogtreecommitdiff
path: root/openbox/config.c
diff options
context:
space:
mode:
authorMikael Magnusson <mikachu@gmail.com>2010-04-16 18:04:24 +0200
committerDana Jansens <danakj@orodu.net>2010-05-17 19:31:21 -0400
commit7a679dd1989ee0b5b36ab2d6b16af47be8a537ad (patch)
treef981d2a8fb64785371ca618b213299b083ef4421 /openbox/config.c
parent1c637efcbb26211f0274687beb8f462d5db36cd5 (diff)
Add support for using relative expressions in move and resize actions
Have MoveResizeTo use config_parse_gravity_coord instead of duplicating it locally Allow MoveResizeTo positions and sizes and per app positions to be relative to screen size Rename to config_parse_relative_number so it can be used for sizes too Add relative numbers to width/height in MoveResizeTo Add relative numbers to MoveRelative Add relative numbers to ResizeRelative, these are for the client size, not screen size
Diffstat (limited to 'openbox/config.c')
-rw-r--r--openbox/config.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/openbox/config.c b/openbox/config.c
index 573ce4c2..00309d8c 100644
--- a/openbox/config.c
+++ b/openbox/config.c
@@ -154,18 +154,29 @@ void config_app_settings_copy_non_defaults(const ObAppSettings *src,
}
}
-static void config_parse_gravity_coord(xmlNodePtr node, GravityCoord *c)
+void config_parse_relative_number(gchar *s, gint *num, gint *denom)
+{
+ *num = strtol(s, &s, 10);
+
+ if (*s == '%') {
+ *denom = 100;
+ } else if (*s == '/') {
+ *denom = atoi(s+1);
+ }
+}
+
+void config_parse_gravity_coord(xmlNodePtr node, GravityCoord *c)
{
gchar *s = obt_xml_node_string(node);
if (!g_ascii_strcasecmp(s, "center"))
c->center = TRUE;
else {
+ gchar *ps = s;
if (s[0] == '-')
c->opposite = TRUE;
if (s[0] == '-' || s[0] == '+')
- c->pos = atoi(s+1);
- else
- c->pos = atoi(s);
+ ps++;
+ config_parse_relative_number(ps, &c->pos, &c->denom);
}
g_free(s);
}