summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Spilsbury <sam.spilsbury@canonical.com>2010-12-07 20:19:28 +0800
committerSam Spilsbury <sam.spilsbury@canonical.com>2010-12-07 20:19:40 +0800
commit8a6f8a3bc865fb02c4905677ff35d8fd3ad9b8ae (patch)
tree4b4e7a6a501acf84ee025249d2e6868c69866049
parent2e84ad1ea59965ba9dde5dd8eac139925e920633 (diff)
downloadcompiz-with-glib-mainloop-8a6f8a3bc865fb02c4905677ff35d8fd3ad9b8ae.tar.gz
compiz-with-glib-mainloop-8a6f8a3bc865fb02c4905677ff35d8fd3ad9b8ae.tar.bz2
Constrain resizes to screen edges and fix constraining.
Forward port 6c12e5a60297143a72c4e4bb104b0c35102ff3f4 to master
-rw-r--r--plugins/resize/src/resize.cpp44
1 files changed, 39 insertions, 5 deletions
diff --git a/plugins/resize/src/resize.cpp b/plugins/resize/src/resize.cpp
index 261766f..771dea4 100644
--- a/plugins/resize/src/resize.cpp
+++ b/plugins/resize/src/resize.cpp
@@ -729,18 +729,52 @@ ResizeScreen::handleMotionEvent (int xRoot, int yRoot)
damageRectangle (&box);
}
- if (mask & ResizeUpMask && yConstrained)
+ if (mask & ResizeUpMask)
{
int decorTop = savedGeometry.y + savedGeometry.height -
- (he + w->input ().top);
+ (che + w->input ().top);
- if (grabWindowWorkArea->y () > decorTop)
+ if (yConstrained)
+ {
+ if (grabWindowWorkArea->y () > decorTop)
+ {
+ /* constrain to workarea */
+ che -= grabWindowWorkArea->y () - decorTop;
+ }
+ }
+ else if (decorTop < 0)
{
- /* constrain to workarea */
- he -= grabWindowWorkArea->y () - decorTop;
+ /* constrain to screen */
+ che += decorTop;
}
}
+ /* constrain to screen */
+ if (mask & ResizeDownMask)
+ {
+ int decorBottom = savedGeometry.y + che + w->input ().bottom;
+
+ if (decorBottom > screen->height ())
+ che -= decorBottom = screen->height ();
+ }
+
+ if (mask & ResizeLeftMask)
+ {
+ int decorLeft = savedGeometry.x + savedGeometry.width -
+ (cwi + w->input ().left);
+
+ if (decorLeft < 0)
+ cwi += decorLeft;
+ }
+
+ if (mask & ResizeRightMask)
+ {
+ int decorRight = savedGeometry.x + cwi + w->input ().right;
+
+ if (decorRight > screen->width ())
+ w -= decorRight - screen->width ();
+ }
+
wi = cwi;
he = che;