Merge lp:~3v1n0/compiz/extents-clamp-workarea into lp:compiz/0.9.11

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Christopher Townsend
Approved revision: 3841
Merged at revision: 3839
Proposed branch: lp:~3v1n0/compiz/extents-clamp-workarea
Merge into: lp:compiz/0.9.11
Diff against target: 113 lines (+50/-13)
2 files modified
src/window.cpp (+43/-10)
src/window/extents/src/windowextents.cpp (+7/-3)
To merge this branch: bzr merge lp:~3v1n0/compiz/extents-clamp-workarea
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Approve
Christopher Townsend Approve
Review via email: mp+210202@code.launchpad.net

Commit message

CompWindow: make sure we don't move a window outside its workarea when setting the extents

Description of the change

When setting the extents, if the window has not been decorated before, we make sure that we don't reposition it outside the workarea.

To post a comment you must log in.
Revision history for this message
Christopher Townsend (townsend) wrote :

Very nice!

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/window.cpp'
--- src/window.cpp 2014-02-20 01:03:41 +0000
+++ src/window.cpp 2014-03-10 13:06:12 +0000
@@ -6185,6 +6185,8 @@
61856185
6186 if (!priv->destroyed)6186 if (!priv->destroyed)
6187 {6187 {
6188 CompWindowExtents empty;
6189 setWindowFrameExtents (&empty, &empty);
6188 StackDebugger *dbg = StackDebugger::Default ();6190 StackDebugger *dbg = StackDebugger::Default ();
61896191
6190 screen->unhookWindow (this);6192 screen->unhookWindow (this);
@@ -6589,12 +6591,9 @@
6589 CompSize sizeDelta;6591 CompSize sizeDelta;
65906592
6591 /* We don't want to change the size of the window in general, but this is6593 /* We don't want to change the size of the window in general, but this is
6592 * needed in case that a normal windows has just been decorated or if6594 * needed in case the window was maximized or fullscreen, so that it
6593 * the window was maximized or fullscreen, so that it will extend6595 * will be extended to use the whole available space. */
6594 * to use the whole available space. */6596 if ((priv->state & MAXIMIZE_STATE) == MAXIMIZE_STATE ||
6595
6596 if (((priv->type & CompWindowTypeNormalMask) && !priv->alreadyDecorated) ||
6597 (priv->state & MAXIMIZE_STATE) == MAXIMIZE_STATE ||
6598 (priv->state & CompWindowStateFullscreenMask) ||6597 (priv->state & CompWindowStateFullscreenMask) ||
6599 (priv->type & CompWindowTypeFullscreenMask))6598 (priv->type & CompWindowTypeFullscreenMask))
6600 {6599 {
@@ -6602,12 +6601,8 @@
6602 (priv->border.left + priv->border.right)));6601 (priv->border.left + priv->border.right)));
6603 sizeDelta.setHeight (-((b->top + b->bottom) -6602 sizeDelta.setHeight (-((b->top + b->bottom) -
6604 (priv->border.top + priv->border.bottom)));6603 (priv->border.top + priv->border.bottom)));
6605 priv->alreadyDecorated = true;
6606 }6604 }
66076605
6608 priv->serverInput = *i;
6609 priv->border = *b;
6610
6611 /* Offset client for any new decoration size */6606 /* Offset client for any new decoration size */
6612 XWindowChanges xwc;6607 XWindowChanges xwc;
66136608
@@ -6616,6 +6611,44 @@
6616 xwc.width = sizeDelta.width () + priv->serverGeometry.width ();6611 xwc.width = sizeDelta.width () + priv->serverGeometry.width ();
6617 xwc.height = sizeDelta.height () + priv->serverGeometry.height ();6612 xwc.height = sizeDelta.height () + priv->serverGeometry.height ();
66186613
6614 if (!priv->alreadyDecorated)
6615 {
6616 /* Make sure we don't move the window outside the workarea */
6617 CompRect const& workarea = screen->getWorkareaForOutput (outputDevice ());
6618 CompPoint boffset((b->left + b->right) - (priv->border.left + priv->border.right),
6619 (b->top + b->bottom) - (priv->border.top + priv->border.bottom));
6620
6621 if (xwc.x + xwc.width > workarea.x2 ())
6622 {
6623 xwc.x -= boffset.x ();
6624
6625 if (xwc.x < workarea.x ())
6626 xwc.x = workarea.x () + movement.x ();
6627 }
6628
6629 if (xwc.y + xwc.height > workarea.y2 ())
6630 {
6631 xwc.y -= boffset.y ();
6632
6633 if (xwc.y < workarea.y ())
6634 xwc.y = workarea.y () + movement.y ();
6635 }
6636
6637 if (priv->actions & CompWindowActionResizeMask)
6638 {
6639 if (xwc.width + boffset.x () > workarea.width ())
6640 xwc.width = workarea.width () - boffset.x ();
6641
6642 if (xwc.height + boffset.y () > workarea.height ())
6643 xwc.height = workarea.height () - boffset.y ();
6644 }
6645
6646 priv->alreadyDecorated = true;
6647 }
6648
6649 priv->serverInput = *i;
6650 priv->border = *b;
6651
6619 configureXWindow (CWX | CWY | CWWidth | CWHeight, &xwc);6652 configureXWindow (CWX | CWY | CWWidth | CWHeight, &xwc);
66206653
6621 windowNotify (CompWindowNotifyFrameUpdate);6654 windowNotify (CompWindowNotifyFrameUpdate);
66226655
=== modified file 'src/window/extents/src/windowextents.cpp'
--- src/window/extents/src/windowextents.cpp 2013-06-26 21:59:35 +0000
+++ src/window/extents/src/windowextents.cpp 2014-03-10 13:06:12 +0000
@@ -75,15 +75,19 @@
75 return rv;75 return rv;
76}76}
7777
78compiz::window::extents::Extents::Extents () {}78compiz::window::extents::Extents::Extents () :
79 left (0),
80 right (0),
81 top (0),
82 bottom (0)
83{}
7984
80compiz::window::extents::Extents::Extents (int left, int right, int top, int bottom) :85compiz::window::extents::Extents::Extents (int left, int right, int top, int bottom) :
81 left (left),86 left (left),
82 right (right),87 right (right),
83 top (top),88 top (top),
84 bottom (bottom)89 bottom (bottom)
85{90{}
86}
8791
88/* Just here to keep ABI compatability */92/* Just here to keep ABI compatability */
89bool93bool

Subscribers

People subscribed via source and target branches