diff options
| author | Mikael Magnusson <mikachu@gmail.com> | 2014-10-06 19:52:14 +0200 |
|---|---|---|
| committer | Mikael Magnusson <mikachu@gmail.com> | 2014-10-06 22:05:26 +0200 |
| commit | 1b3afcff1fea0d1334b50dff378a6667e264b557 (patch) | |
| tree | 28cf965ff507f6fbaf853ddb26c35c757df40740 /openbox/screen.c | |
| parent | c5c5b7b455334ec2987b0f04e18d817f6d3767d0 (diff) | |
Move common gravity application to screen.c
Diffstat (limited to 'openbox/screen.c')
| -rw-r--r-- | openbox/screen.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/openbox/screen.c b/openbox/screen.c index 0198c36c..4b75b3e7 100644 --- a/openbox/screen.c +++ b/openbox/screen.c @@ -1928,3 +1928,30 @@ gboolean screen_compare_desktops(guint a, guint b) b = screen_desktop; return a == b; } + +void screen_apply_gravity_point(gint *x, gint *y, gint width, gint height, + GravityPoint *position, const Rect *area) +{ + if (position->x.center) + *x = area->width / 2 - width / 2; + else { + *x = position->x.pos; + if (position->x.denom) + *x = (*x * area->width) / position->x.denom; + if (position->x.opposite) + *x = area->width - width - *x; + } + + if (position->y.center) + *y = area->height / 2 - height / 2; + else { + *y = position->y.pos; + if (position->y.denom) + *y = (*y * area->height) / position->y.denom; + if (position->y.opposite) + *y = area->height - height - *y; + } + + *x += area->x; + *y += area->y; +} |
