diff options
author | David Reveman <davidr@novell.com> | 2009-01-06 18:09:27 -0500 |
---|---|---|
committer | Danny Baumann <dannybaumann@web.de> | 2009-02-04 08:47:52 +0100 |
commit | 836ed157388b0d5fbcb36e5fecadb9a5b13ea52c (patch) | |
tree | 735ebcaba6aca68057724996e964b77c21fb5e11 | |
parent | aa0fb3f1a98fbd86ebfa6447837d9545b9333a36 (diff) |
Fix placement of windows that can't fit in workspace.
-rw-r--r-- | plugins/place.c | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/plugins/place.c b/plugins/place.c index bbacfb21..5840a552 100644 --- a/plugins/place.c +++ b/plugins/place.c @@ -1089,35 +1089,31 @@ placeConstrainToWorkarea (CompWindow *w, int *y) { CompWindowExtents extents; - int width, height; + int delta; extents.left = *x - w->input.left; extents.top = *y - w->input.top; extents.right = *x + w->serverWidth + w->input.right; extents.bottom = *y + w->serverHeight + w->input.bottom; - width = extents.right - extents.left; - height = extents.bottom - extents.top; + delta = workArea->x + workArea->width - extents.right; + if (delta < 0) + extents.left += delta; - if (extents.left < workArea->x) - { - *x += workArea->x - extents.left; - } - else if (width <= workArea->width && - extents.right > workArea->x + workArea->width) - { - *x += workArea->x + workArea->width - extents.right; - } + delta = workArea->x - extents.left; + if (delta > 0) + extents.left += delta; - if (extents.top < workArea->y) - { - *y += workArea->y - extents.top; - } - else if (height <= workArea->height && - extents.bottom > workArea->y + workArea->height) - { - *y += workArea->y + workArea->height - extents.bottom; - } + delta = workArea->y + workArea->height - extents.bottom; + if (delta < 0) + extents.top += delta; + + delta = workArea->y - extents.top; + if (delta > 0) + extents.top += delta; + + *x = extents.left + w->input.left; + *y = extents.top + w->input.top; } static Bool |