Merge lp:~smspillaz/compiz-core/compiz-core.width-height-for-border into lp:compiz-core

Proposed by Sam Spilsbury on 2012-04-04
Status: Rejected
Rejected by: Sam Spilsbury on 2012-04-05
Proposed branch: lp:~smspillaz/compiz-core/compiz-core.width-height-for-border
Merge into: lp:compiz-core
Prerequisite: lp:~smspillaz/compiz-core/compiz-core.work_923683
Diff against target: 383 lines (+81/-80)
9 files modified
plugins/decor/src/decor.cpp (+4/-6)
plugins/move/src/move.cpp (+2/-4)
plugins/place/src/constrain-to-workarea/src/constrain-to-workarea.cpp (+4/-6)
plugins/place/src/place.cpp (+19/-24)
src/screen.cpp (+2/-2)
src/window.cpp (+10/-10)
src/window/geometry/include/core/windowgeometry.h (+6/-0)
src/window/geometry/tests/window-geometry/src/test-window-geometry.cpp (+10/-0)
src/windowgeometry.cpp (+24/-28)
To merge this branch: bzr merge lp:~smspillaz/compiz-core/compiz-core.width-height-for-border
Reviewer Review Type Date Requested Status
Compiz Maintainers 2012-04-04 Pending
Review via email: mp+100728@code.launchpad.net

Description of the change

Adds widthIncBorders heightIncBorders etc to window::Geometry as suggested by alan at https://code.launchpad.net/~smspillaz/compiz-core/compiz-core.work_923683/+merge/100543/comments/216930

To post a comment you must log in.
Daniel van Vugt (vanvugt) wrote :

I think it would make sense to merge this branch into its prerequisite, perhaps.

Alan Griffiths (alan-griffiths) wrote :

> I think it would make sense to merge this branch into its prerequisite,
> perhaps.

+1

Unmerged revisions

2996. By Sam Spilsbury on 2012-04-04

Removed a lot of width () / height () + border () * 2 sillyness, replace with
more sturdy abstraction

2995. By Sam Spilsbury on 2012-04-03

Merge trunk

2994. By Sam Spilsbury on 2012-02-29

Use reference

2993. By Sam Spilsbury on 2012-02-28

Merge lp:compiz-core

2992. By Sam Spilsbury on 2012-02-28

Fix silly typo

2991. By Sam Spilsbury on 2012-02-28

Cleanup, fix removal of XSynchronize and detect error conditions

2990. By Sam Spilsbury on 2012-02-25

Also send moveNotify for override redirect windows

2989. By Sam Spilsbury on 2012-02-25

Added a note for a fixme

2988. By Sam Spilsbury on 2012-02-25

Also adjust the client position inside the frame whenever the frame value mask
indicates that it might have moved.

2987. By Sam Spilsbury on 2012-02-25

Update PrivateWindow::isInvisible

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/decor/src/decor.cpp'
2--- plugins/decor/src/decor.cpp 2012-04-04 05:26:23 +0000
3+++ plugins/decor/src/decor.cpp 2012-04-04 05:26:23 +0000
4@@ -1714,7 +1714,6 @@
5 XRectangle rects[4];
6 int x, y, width, height;
7 CompWindow::Geometry server = window->serverGeometry ();
8- int bw = server.border () * 2;
9 CompWindowExtents input;
10 CompWindowExtents border;
11 Window parent;
12@@ -1741,8 +1740,8 @@
13
14 x = window->border ().left - border.left;
15 y = window->border ().top - border.top;
16- width = server.width () + input.left + input.right + bw;
17- height = server.height ()+ input.top + input.bottom + bw;
18+ width = server.widthIncBorders () + input.left + input.right;
19+ height = server.heightIncBorders ()+ input.top + input.bottom ;
20
21 /* Non switcher windows are rooted relative to the frame window of the client
22 * and switchers need to be offset by the window geometry of the client */
23@@ -1881,7 +1880,6 @@
24 XRectangle rects[4];
25 int x, y, width, height;
26 CompWindow::Geometry server = window->serverGeometry ();
27- int bw = server.border () * 2;
28 CompWindowExtents input;
29
30 /* Determine frame extents */
31@@ -1892,8 +1890,8 @@
32
33 x = window->input ().left - input.left;
34 y = window->input ().top - input.top;
35- width = server.width () + input.left + input.right + bw;
36- height = server.height ()+ input.top + input.bottom + bw;
37+ width = server.widthIncBorders () + input.left + input.right;
38+ height = server.heightIncBorders ()+ input.top + input.bottom;
39
40 if (window->shaded ())
41 height = input.top + input.bottom;
42
43=== modified file 'plugins/move/src/move.cpp'
44--- plugins/move/src/move.cpp 2012-04-04 05:26:23 +0000
45+++ plugins/move/src/move.cpp 2012-04-04 05:26:23 +0000
46@@ -316,10 +316,8 @@
47
48 wX = w->serverGeometry ().x ();
49 wY = w->serverGeometry ().y ();
50- wWidth = w->serverGeometry ().width () +
51- w->serverGeometry ().border () * 2;
52- wHeight = w->serverGeometry ().height () +
53- w->serverGeometry ().border () * 2;
54+ wWidth = w->serverGeometry ().widthIncBorders ();
55+ wHeight = w->serverGeometry ().heightIncBorders ();
56
57 ms->x += xRoot - lastPointerX;
58 ms->y += yRoot - lastPointerY;
59
60=== modified file 'plugins/place/src/constrain-to-workarea/src/constrain-to-workarea.cpp'
61--- plugins/place/src/constrain-to-workarea/src/constrain-to-workarea.cpp 2012-01-20 06:13:07 +0000
62+++ plugins/place/src/constrain-to-workarea/src/constrain-to-workarea.cpp 2012-04-04 05:26:23 +0000
63@@ -61,13 +61,11 @@
64 }
65
66 left = x - border.left;
67- right = left + g.width () + (border.left +
68- border.right +
69- 2 * g.border ());
70+ right = left + g.widthIncBorders () + (border.left +
71+ border.right);
72 top = y - border.top;
73- bottom = top + g.height () + (border.top +
74- border.bottom +
75- 2 * g.border ());
76+ bottom = top + g.heightIncBorders () + (border.top +
77+ border.bottom);
78
79 if ((right - left) > workArea.width ())
80 {
81
82=== modified file 'plugins/place/src/place.cpp'
83--- plugins/place/src/place.cpp 2012-02-02 17:01:15 +0000
84+++ plugins/place/src/place.cpp 2012-04-04 05:26:23 +0000
85@@ -343,37 +343,36 @@
86 CompWindow::Geometry geom;
87 int output;
88
89+ geom.set (xwc->x, xwc->y, xwc->width, xwc->height,
90+ window->serverGeometry ().border ());
91+
92 if (clampToViewport)
93 {
94 /* left, right, top, bottom target coordinates, clamed to viewport
95 * sizes as we don't need to validate movements to other viewports;
96 * we are only interested in inner-viewport movements */
97
98- x = xwc->x % screen->width ();
99- if ((x + xwc->width) < 0)
100+ x = geom.x () % screen->width ();
101+ if ((geom.x2 ()) < 0)
102 x += screen->width ();
103
104- y = xwc->y % screen->height ();
105- if ((y + xwc->height) < 0)
106+ y = geom.y () % screen->height ();
107+ if ((geom.y2 ()) < 0)
108 y += screen->height ();
109 }
110 else
111 {
112- x = xwc->x;
113- y = xwc->y;
114+ x = geom.x ();
115+ y = geom.y ();
116 }
117
118 left = x - window->border ().left;
119- right = left + xwc->width + (window->border ().left +
120- window->border ().right +
121- 2 * window->serverGeometry ().border ());
122+ right = left + geom.widthIncBorders () + (window->border ().left +
123+ window->border ().right);
124 top = y - window->border ().top;
125- bottom = top + xwc->height + (window->border ().top +
126- window->border ().bottom +
127- 2 * window->serverGeometry ().border ());
128+ bottom = top + geom.heightIncBorders () + (window->border ().top +
129+ window->border ().bottom);
130
131- geom.set (xwc->x, xwc->y, xwc->width, xwc->height,
132- window->serverGeometry ().border ());
133 output = screen->outputDeviceForGeometry (geom);
134 workArea = screen->getWorkareaForOutput (output);
135
136@@ -746,10 +745,8 @@
137 {
138 if (PlaceScreen::get (screen)->getPointerPosition (pos))
139 {
140- unsigned int dx = (window->serverGeometry ().width () / 2) -
141- window->serverGeometry ().border ();
142- unsigned int dy = (window->serverGeometry ().height () / 2) -
143- window->serverGeometry ().border ();
144+ unsigned int dx = (window->serverGeometry ().widthIncBorders () / 2);
145+ unsigned int dy = (window->serverGeometry ().heightIncBorders () / 2);
146 pos -= CompPoint (dx, dy);
147 }
148 else
149@@ -1200,14 +1197,12 @@
150
151 extents.left = pos.x () - window->border ().left;
152 extents.top = pos.y () - window->border ().top;
153- extents.right = extents.left + window->serverWidth () +
154+ extents.right = extents.left + window->serverGeometry ().heightIncBorders () +
155 (window->border ().left +
156- window->border ().right +
157- 2 * window->serverGeometry ().border ());
158- extents.bottom = extents.top + window->serverHeight () +
159+ window->border ().right);
160+ extents.bottom = extents.top + window->serverGeometry ().widthIncBorders () +
161 (window->border ().top +
162- window->border ().bottom +
163- 2 * window->serverGeometry ().border ());
164+ window->border ().bottom);
165
166 delta = workArea.right () - extents.right;
167 if (delta < 0)
168
169=== modified file 'src/screen.cpp'
170--- src/screen.cpp 2012-04-04 05:26:23 +0000
171+++ src/screen.cpp 2012-04-04 05:26:23 +0000
172@@ -4060,8 +4060,8 @@
173 CompRect rect (gm);
174 int offset;
175
176- rect.setWidth (rect.width () + (gm.border () * 2));
177- rect.setHeight (rect.height () + (gm.border () * 2));
178+ rect.setWidth (gm.widthIncBorders ());
179+ rect.setHeight (gm.heightIncBorders ());
180
181 offset = rect.centerX () < 0 ? -1 : 0;
182 viewport.setX (priv->vp.x () + ((rect.centerX () / width ()) + offset) %
183
184=== modified file 'src/window.cpp'
185--- src/window.cpp 2012-04-04 05:26:23 +0000
186+++ src/window.cpp 2012-04-04 05:26:23 +0000
187@@ -918,8 +918,8 @@
188
189 r.x = -priv->serverGeometry.border ();
190 r.y = -priv->serverGeometry.border ();
191- r.width = priv->serverGeometry.width () + priv->serverGeometry.border ();
192- r.height = priv->serverGeometry.height () + priv->serverGeometry.border ();
193+ r.width = priv->serverGeometry.widthIncBorders ();
194+ r.height = priv->serverGeometry.heightIncBorders ();
195
196 if (nBounding < 1)
197 {
198@@ -1854,9 +1854,9 @@
199 * windows since we didn't resize them
200 * on configureXWindow */
201 if (priv->shaded)
202- height = priv->serverGeometry.height () - priv->serverGeometry.border () * 2 - priv->serverInput.top - priv->serverInput.bottom;
203+ height = priv->serverGeometry.heightIncBorders () - priv->serverInput.top - priv->serverInput.bottom;
204 else
205- height = ce->height - priv->serverGeometry.border () * 2 - priv->serverInput.top - priv->serverInput.bottom;
206+ height = ce->height + priv->serverGeometry.border () * 2 - priv->serverInput.top - priv->serverInput.bottom;
207
208 /* set the frame geometry */
209 priv->frameGeometry.set (ce->x, ce->y, ce->width, ce->height, ce->border_width);
210@@ -4308,8 +4308,8 @@
211 PrivateWindow::ensureWindowVisibility ()
212 {
213 int x1, y1, x2, y2;
214- int width = serverGeometry.width () + serverGeometry.border () * 2;
215- int height = serverGeometry.height () + serverGeometry.border () * 2;
216+ int width = serverGeometry.widthIncBorders ();
217+ int height = serverGeometry.heightIncBorders ();
218 int dx = 0;
219 int dy = 0;
220
221@@ -6819,10 +6819,10 @@
222 /* Wait for the reparent to finish */
223 XSync (dpy, false);
224
225- xwc.x = serverGeometry.x () - serverGeometry.border ();
226- xwc.y = serverGeometry.y () - serverGeometry.border ();
227- xwc.width = serverGeometry.width () + serverGeometry.border () * 2;
228- xwc.height = serverGeometry.height () + serverGeometry.border () * 2;
229+ xwc.x = serverGeometry.xMinusBorder ();
230+ xwc.y = serverGeometry.yMinusBorder ();
231+ xwc.width = serverGeometry.widthIncBorders ();
232+ xwc.height = serverGeometry.heightIncBorders ();
233
234 XConfigureWindow (dpy, serverFrame, CWX | CWY | CWWidth | CWHeight, &xwc);
235
236
237=== modified file 'src/window/geometry/include/core/windowgeometry.h'
238--- src/window/geometry/include/core/windowgeometry.h 2012-01-19 20:08:32 +0000
239+++ src/window/geometry/include/core/windowgeometry.h 2012-04-04 05:26:23 +0000
240@@ -64,6 +64,12 @@
241 compiz::window::Geometry change (const compiz::window::Geometry &g, unsigned int mask) const;
242 void applyChange (const compiz::window::Geometry &g, unsigned int mask);
243
244+ int xMinusBorder () const { return x () - mBorder; }
245+ int yMinusBorder () const { return y () - mBorder; }
246+
247+ unsigned int widthIncBorders () const { return width () + mBorder * 2; }
248+ unsigned int heightIncBorders () const { return height () + mBorder * 2; }
249+
250 private:
251 int mBorder;
252 };
253
254=== modified file 'src/window/geometry/tests/window-geometry/src/test-window-geometry.cpp'
255--- src/window/geometry/tests/window-geometry/src/test-window-geometry.cpp 2012-03-30 16:30:13 +0000
256+++ src/window/geometry/tests/window-geometry/src/test-window-geometry.cpp 2012-04-04 05:26:23 +0000
257@@ -87,3 +87,13 @@
258 EXPECT_EQ (rg, compiz::window::Geometry (49, 99, 199, 299, 5));
259 EXPECT_EQ (mask, CHANGE_X | CHANGE_Y | CHANGE_WIDTH | CHANGE_HEIGHT);
260 }
261+
262+TEST_F(CompWindowGeometryTestGeometry, TestBorders)
263+{
264+ compiz::window::Geometry g (1, 1, 1, 1, 1);
265+
266+ EXPECT_EQ (g.xMinusBorder (), 0);
267+ EXPECT_EQ (g.yMinusBorder (), 0);
268+ EXPECT_EQ (g.widthIncBorders (), 3);
269+ EXPECT_EQ (g.heightIncBorders (), 3);
270+}
271
272=== modified file 'src/windowgeometry.cpp'
273--- src/windowgeometry.cpp 2012-04-04 05:26:23 +0000
274+++ src/windowgeometry.cpp 2012-04-04 05:26:23 +0000
275@@ -102,42 +102,38 @@
276 int
277 CompWindow::serverWidth () const
278 {
279- return priv->serverGeometry.width () +
280- 2 * priv->serverGeometry.border ();
281+ return priv->serverGeometry.widthIncBorders ();
282 }
283
284 int
285 CompWindow::serverHeight () const
286 {
287- return priv->serverGeometry.height () +
288- 2 * priv->serverGeometry.border ();
289+ return priv->serverGeometry.heightIncBorders ();
290 }
291
292 const CompSize
293 CompWindow::serverSize () const
294 {
295- return CompSize (priv->serverGeometry.width () +
296- 2 * priv->serverGeometry.border (),
297- priv->serverGeometry.height () +
298- 2 * priv->serverGeometry.border ());
299+ return CompSize (priv->serverGeometry.widthIncBorders (),
300+ priv->serverGeometry.heightIncBorders ());
301 }
302
303 CompRect
304 CompWindow::borderRect () const
305 {
306- return CompRect (priv->geometry.x () - priv->geometry.border () - priv->border.left,
307- priv->geometry.y () - priv->geometry.border () - priv->border.top,
308- priv->geometry.width () + priv->geometry.border () * 2 +
309+ return CompRect (priv->geometry.xMinusBorder () - priv->border.left,
310+ priv->geometry.yMinusBorder () - priv->border.top,
311+ priv->geometry.widthIncBorders () +
312 priv->border.left + priv->border.right,
313- priv->geometry.height () + priv->geometry.border () * 2 +
314+ priv->geometry.heightIncBorders () +
315 priv->border.top + priv->border.bottom);
316 }
317
318 CompRect
319 CompWindow::serverBorderRect () const
320 {
321- return CompRect (priv->serverGeometry.x () - priv->geometry.border () - priv->border.left,
322- priv->serverGeometry.y () - priv->geometry.border () - priv->border.top,
323+ return CompRect (priv->serverGeometry.xMinusBorder () - priv->border.left,
324+ priv->serverGeometry.yMinusBorder () - priv->border.top,
325 priv->serverGeometry.width () + priv->geometry.border () * 2 +
326 priv->border.left + priv->border.right,
327 priv->serverGeometry.height () + priv->geometry.border () * 2 +
328@@ -147,8 +143,8 @@
329 CompRect
330 CompWindow::inputRect () const
331 {
332- return CompRect (priv->geometry.x () - priv->geometry.border () - priv->serverInput.left,
333- priv->geometry.y () - priv->geometry.border () - priv->serverInput.top,
334+ return CompRect (priv->geometry.xMinusBorder () - priv->serverInput.left,
335+ priv->geometry.yMinusBorder () - priv->serverInput.top,
336 priv->geometry.width () + priv->geometry.border () * 2 +
337 priv->serverInput.left + priv->serverInput.right,
338 priv->geometry.height () +priv->geometry.border () * 2 +
339@@ -158,32 +154,32 @@
340 CompRect
341 CompWindow::serverInputRect () const
342 {
343- return CompRect (priv->serverGeometry.x () - priv->serverGeometry.border () - priv->serverInput.left,
344- priv->serverGeometry.y () - priv->serverGeometry.border () - priv->serverInput.top,
345- priv->serverGeometry.width () + priv->serverGeometry.border () * 2 +
346+ return CompRect (priv->serverGeometry.xMinusBorder () - priv->serverInput.left,
347+ priv->serverGeometry.yMinusBorder () - priv->serverInput.top,
348+ priv->serverGeometry.widthIncBorders () +
349 priv->serverInput.left + priv->serverInput.right,
350- priv->serverGeometry.height () + priv->serverGeometry.border () * 2 +
351+ priv->serverGeometry.heightIncBorders () +
352 priv->serverInput.top + priv->serverInput.bottom);
353 }
354
355 CompRect
356 CompWindow::outputRect () const
357 {
358- return CompRect (priv->geometry.x () - priv->serverGeometry.border ()- priv->output.left,
359- priv->geometry.y () - priv->serverGeometry.border () - priv->output.top,
360- priv->geometry.width () + priv->serverGeometry.border () * 2 +
361+ return CompRect (priv->geometry.xMinusBorder ()- priv->output.left,
362+ priv->geometry.yMinusBorder () - priv->output.top,
363+ priv->geometry.widthIncBorders () +
364 priv->output.left + priv->output.right,
365- priv->geometry.height () + priv->serverGeometry.border () * 2 +
366+ priv->geometry.heightIncBorders () +
367 priv->output.top + priv->output.bottom);
368 }
369
370 CompRect
371 CompWindow::serverOutputRect () const
372 {
373- return CompRect (priv->serverGeometry.x () - priv->serverGeometry.border () - priv->output.left,
374- priv->serverGeometry.y () - priv->serverGeometry.border () - priv->output.top,
375- priv->serverGeometry.width () + priv->serverGeometry.border () * 2 +
376+ return CompRect (priv->serverGeometry.xMinusBorder () - priv->output.left,
377+ priv->serverGeometry.yMinusBorder () - priv->output.top,
378+ priv->serverGeometry.widthIncBorders () +
379 priv->output.left + priv->output.right,
380- priv->serverGeometry.height () + priv->serverGeometry.border () * 2 +
381+ priv->serverGeometry.heightIncBorders () +
382 priv->output.top + priv->output.bottom);
383 }

Subscribers

People subscribed via source and target branches