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

Proposed by Marco Trevisan (Treviño) on 2014-03-10
Status: Merged
Approved by: Christopher Townsend on 2014-03-10
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 continuous-integration Approve on 2014-03-10
Christopher Townsend 2014-03-10 Approve on 2014-03-10
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.
Christopher Townsend (townsend) wrote :

Very nice!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/window.cpp'
2--- src/window.cpp 2014-02-20 01:03:41 +0000
3+++ src/window.cpp 2014-03-10 13:06:12 +0000
4@@ -6185,6 +6185,8 @@
5
6 if (!priv->destroyed)
7 {
8+ CompWindowExtents empty;
9+ setWindowFrameExtents (&empty, &empty);
10 StackDebugger *dbg = StackDebugger::Default ();
11
12 screen->unhookWindow (this);
13@@ -6589,12 +6591,9 @@
14 CompSize sizeDelta;
15
16 /* We don't want to change the size of the window in general, but this is
17- * needed in case that a normal windows has just been decorated or if
18- * the window was maximized or fullscreen, so that it will extend
19- * to use the whole available space. */
20-
21- if (((priv->type & CompWindowTypeNormalMask) && !priv->alreadyDecorated) ||
22- (priv->state & MAXIMIZE_STATE) == MAXIMIZE_STATE ||
23+ * needed in case the window was maximized or fullscreen, so that it
24+ * will be extended to use the whole available space. */
25+ if ((priv->state & MAXIMIZE_STATE) == MAXIMIZE_STATE ||
26 (priv->state & CompWindowStateFullscreenMask) ||
27 (priv->type & CompWindowTypeFullscreenMask))
28 {
29@@ -6602,12 +6601,8 @@
30 (priv->border.left + priv->border.right)));
31 sizeDelta.setHeight (-((b->top + b->bottom) -
32 (priv->border.top + priv->border.bottom)));
33- priv->alreadyDecorated = true;
34 }
35
36- priv->serverInput = *i;
37- priv->border = *b;
38-
39 /* Offset client for any new decoration size */
40 XWindowChanges xwc;
41
42@@ -6616,6 +6611,44 @@
43 xwc.width = sizeDelta.width () + priv->serverGeometry.width ();
44 xwc.height = sizeDelta.height () + priv->serverGeometry.height ();
45
46+ if (!priv->alreadyDecorated)
47+ {
48+ /* Make sure we don't move the window outside the workarea */
49+ CompRect const& workarea = screen->getWorkareaForOutput (outputDevice ());
50+ CompPoint boffset((b->left + b->right) - (priv->border.left + priv->border.right),
51+ (b->top + b->bottom) - (priv->border.top + priv->border.bottom));
52+
53+ if (xwc.x + xwc.width > workarea.x2 ())
54+ {
55+ xwc.x -= boffset.x ();
56+
57+ if (xwc.x < workarea.x ())
58+ xwc.x = workarea.x () + movement.x ();
59+ }
60+
61+ if (xwc.y + xwc.height > workarea.y2 ())
62+ {
63+ xwc.y -= boffset.y ();
64+
65+ if (xwc.y < workarea.y ())
66+ xwc.y = workarea.y () + movement.y ();
67+ }
68+
69+ if (priv->actions & CompWindowActionResizeMask)
70+ {
71+ if (xwc.width + boffset.x () > workarea.width ())
72+ xwc.width = workarea.width () - boffset.x ();
73+
74+ if (xwc.height + boffset.y () > workarea.height ())
75+ xwc.height = workarea.height () - boffset.y ();
76+ }
77+
78+ priv->alreadyDecorated = true;
79+ }
80+
81+ priv->serverInput = *i;
82+ priv->border = *b;
83+
84 configureXWindow (CWX | CWY | CWWidth | CWHeight, &xwc);
85
86 windowNotify (CompWindowNotifyFrameUpdate);
87
88=== modified file 'src/window/extents/src/windowextents.cpp'
89--- src/window/extents/src/windowextents.cpp 2013-06-26 21:59:35 +0000
90+++ src/window/extents/src/windowextents.cpp 2014-03-10 13:06:12 +0000
91@@ -75,15 +75,19 @@
92 return rv;
93 }
94
95-compiz::window::extents::Extents::Extents () {}
96+compiz::window::extents::Extents::Extents () :
97+ left (0),
98+ right (0),
99+ top (0),
100+ bottom (0)
101+{}
102
103 compiz::window::extents::Extents::Extents (int left, int right, int top, int bottom) :
104 left (left),
105 right (right),
106 top (top),
107 bottom (bottom)
108-{
109-}
110+{}
111
112 /* Just here to keep ABI compatability */
113 bool

Subscribers

People subscribed via source and target branches