diff options
| author | Mikael Magnusson <mikachu@gmail.com> | 2010-04-16 18:04:24 +0200 |
|---|---|---|
| committer | Dana Jansens <danakj@orodu.net> | 2010-05-17 19:31:21 -0400 |
| commit | 7a679dd1989ee0b5b36ab2d6b16af47be8a537ad (patch) | |
| tree | f981d2a8fb64785371ca618b213299b083ef4421 /openbox/actions/moverelative.c | |
| parent | 1c637efcbb26211f0274687beb8f462d5db36cd5 (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/actions/moverelative.c')
| -rw-r--r-- | openbox/actions/moverelative.c | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/openbox/actions/moverelative.c b/openbox/actions/moverelative.c index 189b4dd0..fc4a615d 100644 --- a/openbox/actions/moverelative.c +++ b/openbox/actions/moverelative.c @@ -2,11 +2,14 @@ #include "openbox/client.h" #include "openbox/screen.h" #include "openbox/frame.h" +#include "openbox/config.h" #include <stdlib.h> /* for atoi */ typedef struct { gint x; + gint x_denom; gint y; + gint y_denom; } Options; static gpointer setup_func(xmlNodePtr node); @@ -22,13 +25,20 @@ static gpointer setup_func(xmlNodePtr node) { xmlNodePtr n; Options *o; + gchar *s; o = g_slice_new0(Options); - if ((n = obt_xml_find_node(node, "x"))) - o->x = obt_xml_node_int(n); - if ((n = obt_xml_find_node(node, "y"))) - o->y = obt_xml_node_int(n); + if ((n = obt_xml_find_node(node, "x"))) { + s = obt_xml_node_string(n); + config_parse_relative_number(s, &o->x, &o->x_denom); + g_free(s); + } + if ((n = obt_xml_find_node(node, "y"))) { + s = obt_xml_node_string(n); + config_parse_relative_number(s, &o->y, &o->y_denom); + g_free(s); + } return o; } @@ -48,8 +58,19 @@ static gboolean run_func(ObActionsData *data, gpointer options) gint x, y, lw, lh, w, h; c = data->client; - x = c->area.x + o->x; - y = c->area.y + o->y; + x = o->x; + y = o->y; + if (o->x_denom || o->y_denom) { + const Rect *carea; + + carea = screen_area(c->desktop, client_monitor(c), NULL); + if (o->x_denom) + x = (x * carea->width) / o->x_denom; + if (o->y_denom) + y = (y * carea->height) / o->y_denom; + } + x = c->area.x + x; + y = c->area.y + y; w = c->area.width; h = c->area.height; client_try_configure(c, &x, &y, &w, &h, &lw, &lh, TRUE); |
