Merge lp:~smspillaz/compiz-core/compiz-core.fix_896586_rotate_plugin into lp:compiz-core/0.9.5

Proposed by Sam Spilsbury
Status: Rejected
Rejected by: Sam Spilsbury
Proposed branch: lp:~smspillaz/compiz-core/compiz-core.fix_896586_rotate_plugin
Merge into: lp:compiz-core/0.9.5
Prerequisite: lp:~smspillaz/compiz-core/compiz-core.fix_891591
Diff against target: 2666 lines (+1271/-684)
29 files modified
include/core/CMakeLists.txt (+0/-2)
include/core/rect.h (+0/-233)
include/core/screen.h (+6/-3)
include/core/window.h (+15/-2)
plugins/CMakeLists.txt (+1/-0)
plugins/composite/src/window.cpp (+0/-2)
plugins/decor/src/decor.cpp (+5/-16)
plugins/move/src/move.cpp (+79/-20)
plugins/move/src/move.h (+16/-3)
plugins/opengl/include/opengl/opengl.h (+9/-2)
plugins/opengl/src/paint.cpp (+27/-22)
plugins/opengl/src/window.cpp (+4/-4)
plugins/rotate/src/rotate.cpp (+20/-5)
plugins/wobbly/src/wobbly.cpp (+42/-3)
plugins/wobbly/src/wobbly.h (+2/-0)
src/CMakeLists.txt (+5/-0)
src/rect.cpp (+0/-286)
src/rect/CMakeLists.txt (+66/-0)
src/rect/include/core/rect.h (+248/-0)
src/rect/src/rect.cpp (+306/-0)
src/rect/tests/CMakeLists.txt (+31/-0)
src/rect/tests/rect/src/test-rect.cpp (+106/-0)
src/rect/tests/test-rect.cpp (+34/-0)
src/rect/tests/test-rect.h (+44/-0)
src/rect/tests/wraparound_point/src/test-rect-wraparound-point.cpp (+78/-0)
src/screen.cpp (+32/-35)
src/window.cpp (+92/-45)
src/window/geometry-saver/CMakeLists.txt (+1/-0)
src/window/geometry/CMakeLists.txt (+2/-1)
To merge this branch: bzr merge lp:~smspillaz/compiz-core/compiz-core.fix_896586_rotate_plugin
Reviewer Review Type Date Requested Status
Alan Griffiths Needs Fixing
Thomi Richards Pending
Tim Penhey Pending
Review via email: mp+88493@code.launchpad.net

This proposal supersedes a proposal from 2011-12-01.

Description of the change

Made the cube and rotate plugins work with paint offsets.

In order to implement this properly, we had to move from immediately updating the 2D display matrix of the window on position offset change to applying a 4x4 transformation matrix to the window before it is painted, like how global paint offsets work, which means that a lot of code was consolidated.

In terms of other plugins, the wobbly plugin needed to be updated to move its model entirely by the paint offset, since that is going to be the global display model for the window.

Added a test for points outside of rectangles to wrap-around a rectangle within it.

Moved some of the utility functions related to viewports into their own namespace.

Made CompScreen::moveViewport wrapable so that plugins can know when a viewport was just changed (eg, causing window movement to happen) rather than guessing.

Next pipe: lp:~smspillaz/compiz-core/fix_896762

To post a comment you must log in.
Revision history for this message
Thomi Richards (thomir-deactivatedaccount) wrote : Posted in a previous version of this proposal

ln 1204: Why the static cast? It looks to me like you're being given a CompRectTest* already...

Otherwise, looks good to me.

review: Approve
Revision history for this message
Tim Penhey (thumper) wrote : Posted in a previous version of this proposal

> CompPoint remainingVp = CompPoint (screen->vpSize ().width () - wvp.x (),
> screen->vpSize ().height () - wvp.y ());

This is an inefficient way to write:

CompPoint remainingVp (screen->vpSize ().width () - wvp.x (),
                       screen->vpSize ().height () - wvp.y ());

The first way calls the constructor, then the copy constructor, then the destructor just to initialize remainingVp.

Please just use a constructor call. Please fix declarations in compiz::viewports::wraparoundOffsetForPoint.

review: Needs Fixing
Revision history for this message
Sam Spilsbury (smspillaz) wrote : Posted in a previous version of this proposal

> > CompPoint remainingVp = CompPoint (screen->vpSize ().width () - wvp.x (),
> > screen->vpSize ().height () - wvp.y ());
>
> This is an inefficient way to write:
>
>
> CompPoint remainingVp (screen->vpSize ().width () - wvp.x (),
> screen->vpSize ().height () - wvp.y ());
>
> The first way calls the constructor, then the copy constructor, then the
> destructor just to initialize remainingVp.

I'm suprised the compiler doesn't optimize that out.

>
> Please just use a constructor call. Please fix declarations in
> compiz::viewports::wraparoundOffsetForPoint.

ack

Revision history for this message
Alan Griffiths (alan-griffiths) wrote : Posted in a previous version of this proposal

> > This is an inefficient way to write:
> >
> > CompPoint remainingVp (screen->vpSize ().width () - wvp.x (),
> > screen->vpSize ().height () - wvp.y ());
> >
> > The first way calls the constructor, then the copy constructor, then the
> > destructor just to initialize remainingVp.
>
> I'm suprised the compiler doesn't optimize that out.

It is allowed to, but not required to - so the intent is explicit with the suggested syntax. (What actually happens varies with compiler/version and context.)

The same construct exists elsewhere. Vis:

357 + CompPoint gp = CompPoint (g.pos ().x () % (screen->vpSize ().width () * screen->width ()),
358 + g.pos ().y () % (screen->vpSize ().height () * screen->height ()));
359 + CompPoint dp = gp - window->serverGeometry ().pos ();
360 CompSize dsize = CompSize (g.width () - window->serverGeometry ().width (),
361 g.height () - window->serverGeometry ().height ());
...
2242 + compiz::window::Geometry ng = w->serverGeometry ();
...
2398 + CompPoint remainingVp = CompPoint (screen->vpSize ().width () - wvp.x (),
2399 + screen->vpSize ().height () - wvp.y ());
2400 + CompPoint maxOffset = CompPoint ((remainingVp.x () * screen->width ()) -
2401 + wp.x (),
2402 + (remainingVp.y () * screen->height ()) -
2403 + wp.y ());
2404 + CompPoint minOffset = CompPoint (-((screen->vpSize ().width () * screen->width ()) - maxOffset.x ()),
2405 + -((screen->vpSize ().height () * screen->height ()) - maxOffset.y ()));
2406 + CompRect constrain = CompRect (minOffset.x (), minOffset.y (),
2407 + maxOffset.x () - minOffset.x (),
2408 + maxOffset.y () - minOffset.y ());

> > Please just use a constructor call.

+1

review: Needs Fixing
Revision history for this message
Alan Griffiths (alan-griffiths) wrote :

There still a lot on unnecessary copy-initialization

review: Needs Fixing
2958. By Sam Spilsbury

Merged compiz-core.fix_891591 into compiz-core.fix_896586_rotate_plugin.

2959. By Sam Spilsbury

Merged compiz-core.fix_891591 into compiz-core.fix_896586_rotate_plugin.

2960. By Sam Spilsbury

Merged compiz-core.fix_891591 into compiz-core.fix_896586_rotate_plugin.

2961. By Sam Spilsbury

Merged compiz-core.fix_891591 into compiz-core.fix_896586_rotate_plugin.

2962. By Sam Spilsbury

Merged compiz-core.fix_891591 into compiz-core.fix_896586_rotate_plugin.

2963. By Sam Spilsbury

Merged compiz-core.fix_891591 into compiz-core.fix_896586_rotate_plugin.

2964. By Sam Spilsbury

Merged compiz-core.fix_891591 into compiz-core.fix_896586_rotate_plugin.

2965. By Sam Spilsbury

Merge and fix warnings

2966. By Sam Spilsbury

Merged compiz-core.fix_891591 into compiz-core.fix_896586_rotate_plugin.

Unmerged revisions

2966. By Sam Spilsbury

Merged compiz-core.fix_891591 into compiz-core.fix_896586_rotate_plugin.

2965. By Sam Spilsbury

Merge and fix warnings

2964. By Sam Spilsbury

Merged compiz-core.fix_891591 into compiz-core.fix_896586_rotate_plugin.

2963. By Sam Spilsbury

Merged compiz-core.fix_891591 into compiz-core.fix_896586_rotate_plugin.

2962. By Sam Spilsbury

Merged compiz-core.fix_891591 into compiz-core.fix_896586_rotate_plugin.

2961. By Sam Spilsbury

Merged compiz-core.fix_891591 into compiz-core.fix_896586_rotate_plugin.

2960. By Sam Spilsbury

Merged compiz-core.fix_891591 into compiz-core.fix_896586_rotate_plugin.

2959. By Sam Spilsbury

Merged compiz-core.fix_891591 into compiz-core.fix_896586_rotate_plugin.

2958. By Sam Spilsbury

Merged compiz-core.fix_891591 into compiz-core.fix_896586_rotate_plugin.

2957. By Sam Spilsbury

Cleanup

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'include/core/CMakeLists.txt'
2--- include/core/CMakeLists.txt 2012-01-19 06:08:11 +0000
3+++ include/core/CMakeLists.txt 2012-01-19 18:22:37 +0000
4@@ -10,10 +10,8 @@
5 option.h
6 output.h
7 plugin.h
8- point.h
9 propertywriter.h
10 privateunion.h
11- rect.h
12 region.h
13 screen.h
14 serialization.h
15
16=== removed file 'include/core/rect.h'
17--- include/core/rect.h 2012-01-18 16:26:45 +0000
18+++ include/core/rect.h 1970-01-01 00:00:00 +0000
19@@ -1,233 +0,0 @@
20-/*
21- * Copyright © 2008 Dennis Kasprzyk
22- *
23- * Permission to use, copy, modify, distribute, and sell this software
24- * and its documentation for any purpose is hereby granted without
25- * fee, provided that the above copyright notice appear in all copies
26- * and that both that copyright notice and this permission notice
27- * appear in supporting documentation, and that the name of
28- * Dennis Kasprzyk not be used in advertising or publicity pertaining to
29- * distribution of the software without specific, written prior permission.
30- * Dennis Kasprzyk makes no representations about the suitability of this
31- * software for any purpose. It is provided "as is" without express or
32- * implied warranty.
33- *
34- * DENNIS KASPRZYK DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
35- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
36- * NO EVENT SHALL DENNIS KASPRZYK BE LIABLE FOR ANY SPECIAL, INDIRECT OR
37- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
38- * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
39- * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
40- * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
41- *
42- * Authors: Dennis Kasprzyk <onestone@compiz-fusion.org>
43- */
44-
45-#ifndef _COMPRECT_H
46-#define _COMPRECT_H
47-
48-#include "core/point.h"
49-#include "core/size.h"
50-
51-#include <X11/Xutil.h>
52-#include <X11/Xregion.h>
53-
54-/**
55- * A 2D rectangle, which is likely in screen space. It's data is
56- * isolated and can only be mutated with set() methods.
57- */
58-class CompRect {
59-
60- public:
61- CompRect ();
62- CompRect (int x, int y, int width, int height);
63- CompRect (const CompRect&);
64- CompRect (const XRectangle);
65-
66- int x () const;
67- int y () const;
68- CompPoint pos () const;
69-
70- int width () const;
71- int height () const;
72-
73- int x1 () const;
74- int y1 () const;
75- int x2 () const;
76- int y2 () const;
77-
78- int left () const;
79- int right () const;
80- int top () const;
81- int bottom () const;
82-
83- int centerX () const;
84- int centerY () const;
85- CompPoint center () const;
86-
87- int area () const;
88-
89- /**
90- * Returns an X region handle for the CompRect
91- */
92- Region region () const;
93-
94- void setGeometry (int x, int y,
95- int width, int height);
96-
97- void setX (int);
98- void setY (int);
99- void setWidth (int);
100- void setHeight (int);
101-
102- void setPos (const CompPoint&);
103- void setSize (const CompSize&);
104-
105- /**
106- * Sets the left edge position
107- *
108- * Setting an edge past it's opposite edge will result in both edges
109- * being set to the new value
110- */
111- void setLeft (int);
112- /**
113- * Sets the top edge position
114- *
115- * Setting an edge past it's opposite edge will result in both edges
116- * being set to the new value
117- */
118- void setTop (int);
119- /**
120- * Sets the right edge position
121- *
122- * Setting an edge past it's opposite edge will result in both edges
123- * being set to the new value
124- */
125- void setRight (int);
126- /**
127- * Sets the bottom edge position
128- *
129- * Setting an edge past it's opposite edge will result in both edges
130- * being set to the new value
131- */
132- void setBottom (int);
133-
134- bool contains (const CompPoint &) const;
135- bool contains (const CompRect &) const;
136- bool intersects (const CompRect &) const;
137- bool isEmpty () const;
138-
139- bool operator== (const CompRect &) const;
140- bool operator!= (const CompRect &) const;
141-
142- CompRect operator& (const CompRect &) const;
143- CompRect& operator&= (const CompRect &);
144- CompRect& operator= (const CompRect &);
145-
146- typedef std::vector<CompRect> vector;
147- typedef std::vector<CompRect *> ptrVector;
148- typedef std::list<CompRect *> ptrList;
149-
150- private:
151- REGION mRegion;
152-};
153-
154-
155-inline int
156-CompRect::x () const
157-{
158- return mRegion.extents.x1;
159-}
160-
161-inline int
162-CompRect::y () const
163-{
164- return mRegion.extents.y1;
165-}
166-
167-inline CompPoint
168-CompRect::pos () const
169-{
170- return CompPoint (x (), y ());
171-}
172-
173-inline int
174-CompRect::width () const
175-{
176- return mRegion.extents.x2 - mRegion.extents.x1;
177-}
178-
179-inline int
180-CompRect::height () const
181-{
182- return mRegion.extents.y2 - mRegion.extents.y1;
183-}
184-
185-inline int
186-CompRect::x1 () const
187-{
188- return mRegion.extents.x1;
189-}
190-
191-inline int
192-CompRect::y1 () const
193-{
194- return mRegion.extents.y1;
195-}
196-
197-inline int
198-CompRect::x2 () const
199-{
200- return mRegion.extents.x2;
201-}
202-
203-inline int
204-CompRect::y2 () const
205-{
206- return mRegion.extents.y2;
207-}
208-
209-inline int
210-CompRect::left () const
211-{
212- return mRegion.extents.x1;
213-}
214-
215-inline int
216-CompRect::right () const
217-{
218- return mRegion.extents.x2;
219-}
220-
221-inline int
222-CompRect::top () const
223-{
224- return mRegion.extents.y1;
225-}
226-
227-
228-inline int
229-CompRect::bottom () const
230-{
231- return mRegion.extents.y2;
232-}
233-
234-inline int
235-CompRect::centerX () const
236-{
237- return x () + width () / 2;
238-}
239-
240-inline int
241-CompRect::centerY () const
242-{
243- return y () + height () / 2;
244-}
245-
246-inline CompPoint
247-CompRect::center () const
248-{
249- return CompPoint (centerX (), centerY ());
250-}
251-
252-#endif
253
254=== modified file 'include/core/screen.h'
255--- include/core/screen.h 2012-01-19 18:22:37 +0000
256+++ include/core/screen.h 2012-01-19 18:22:37 +0000
257@@ -135,6 +135,8 @@
258 virtual void enterShowDesktopMode ();
259 virtual void leaveShowDesktopMode (CompWindow *window);
260
261+ virtual void moveViewport (int tx, int ty);
262+
263 virtual void outputChangeNotify ();
264 virtual void addSupportedAtoms (std::vector<Atom>& atoms);
265 };
266@@ -145,7 +147,7 @@
267 */
268 class CompScreen :
269 public CompSize,
270- public WrapableHandler<ScreenInterface, 18>,
271+ public WrapableHandler<ScreenInterface, 19>,
272 public PluginClassStorage,
273 public CompOption::Class
274 {
275@@ -314,8 +316,6 @@
276
277 void runCommand (CompString command);
278
279- void moveViewport (int tx, int ty, bool sync);
280-
281 void sendWindowActivationRequest (Window id);
282
283 int outputDeviceForPoint (int x, int y);
284@@ -405,6 +405,9 @@
285 WRAPABLE_HND (17, ScreenInterface, void, addSupportedAtoms,
286 std::vector<Atom>& atoms);
287
288+ WRAPABLE_HND (18, ScreenInterface, void, moveViewport, int tx,
289+ int ty);
290+
291 friend class CompTimer;
292 friend class CompWindow;
293 friend class PrivateWindow;
294
295=== modified file 'include/core/window.h'
296--- include/core/window.h 2012-01-19 18:22:37 +0000
297+++ include/core/window.h 2012-01-19 18:22:37 +0000
298@@ -284,6 +284,21 @@
299 virtual bool focused ();
300 };
301
302+namespace compiz
303+{
304+ namespace viewports
305+ {
306+ CompRect borderRectForViewportPosition (const CompRect &,
307+ const CompPoint &,
308+ unsigned int,
309+ unsigned int);
310+
311+ CompPoint wraparoundOffsetForPoint (const CompPoint &,
312+ const CompPoint &,
313+ const CompPoint &);
314+ }
315+}
316+
317 /**
318 * An Window object that wraps an X window. This handles snychronization of
319 * window state, geometry, etc. between Compiz and the X server.
320@@ -389,8 +404,6 @@
321
322 XWindowChanges & saveWc ();
323
324- void moveToViewportPosition (int x, int y, bool sync);
325-
326 char * startupId ();
327
328 unsigned int desktop ();
329
330=== modified file 'plugins/CMakeLists.txt'
331--- plugins/CMakeLists.txt 2012-01-19 18:22:37 +0000
332+++ plugins/CMakeLists.txt 2012-01-19 18:22:37 +0000
333@@ -19,6 +19,7 @@
334 ${CMAKE_CURRENT_SOURCE_DIR}/../src/window/geometry-saver/include
335 ${CMAKE_CURRENT_SOURCE_DIR}/../src/window/extents/include
336 ${CMAKE_CURRENT_SOURCE_DIR}/../src/point/include
337+ ${CMAKE_CURRENT_SOURCE_DIR}/../src/rect/include
338 )
339
340 compiz_add_plugins_in_folder (${CMAKE_CURRENT_SOURCE_DIR})
341
342=== modified file 'plugins/composite/src/window.cpp'
343--- plugins/composite/src/window.cpp 2012-01-19 18:22:37 +0000
344+++ plugins/composite/src/window.cpp 2012-01-19 18:22:37 +0000
345@@ -634,8 +634,6 @@
346 /* Translate by position offset */
347 oldGeom.setPos (oldGeom.pos () + cWindow->paintOffset ());
348
349- compiz::window::Geometry newGeom = oldGeom;
350-
351 /* Since the geometry has already been updated
352 * at resizeNotify time, we must compute the old
353 * geometry */
354
355=== modified file 'plugins/decor/src/decor.cpp'
356--- plugins/decor/src/decor.cpp 2012-01-19 18:22:37 +0000
357+++ plugins/decor/src/decor.cpp 2012-01-19 18:22:37 +0000
358@@ -1056,9 +1056,6 @@
359 /* Translate by x and y points of this window */
360 pos = window->serverGeometry ().pos ();
361
362- if (cWindow)
363- pos += cWindow->paintOffset ();
364-
365 wd->quad[i].box.x1 = x1 + pos.x ();
366 wd->quad[i].box.y1 = y1 + pos.y ();
367 wd->quad[i].box.x2 = x2 + pos.x ();
368@@ -1354,7 +1351,6 @@
369 Decoration *old, *decoration = NULL;
370 bool decorate = false;
371 bool shadowOnly = true;
372- int moveDx, moveDy;
373 CompPoint oldShift;
374
375 old = (wd) ? wd->decor : NULL;
376@@ -1536,8 +1532,7 @@
377 }
378
379 /* Need to actually move the window */
380- if (window->placed () && !window->overrideRedirect () &&
381- (moveDx || moveDy))
382+ if (window->placed () && !window->overrideRedirect ())
383 {
384 /* Grab the geometry last sent to server at position ()
385 * time and not here since serverGeometry may be updated by
386@@ -2097,7 +2092,7 @@
387 DecorWindow::updateWindowRegions ()
388 {
389 CompRect input (window->serverInputRect ());
390- input.setPos (input.pos () + cWindow->paintOffset ());
391+ input.setPos (input.pos ());
392
393 if (regions.size () != gWindow->textures ().size ())
394 regions.resize (gWindow->textures ().size ());
395@@ -2670,7 +2665,9 @@
396 unsigned int source,
397 unsigned int constrainment)
398 {
399- CompPoint dp = g.pos () - window->serverGeometry ().pos ();
400+ CompPoint gp = CompPoint (g.pos ().x () % (screen->vpSize ().width () * screen->width ()),
401+ g.pos ().y () % (screen->vpSize ().height () * screen->height ()));
402+ CompPoint dp = gp - window->serverGeometry ().pos ();
403 CompSize dsize = CompSize (g.width () - window->serverGeometry ().width (),
404 g.height () - window->serverGeometry ().height ());
405
406@@ -2707,14 +2704,6 @@
407 void
408 DecorWindow::applyOffset (const CompPoint &dOff)
409 {
410- if (wd)
411- {
412- wd->translate (dOff);
413- setDecorationMatrices ();
414- }
415-
416- updateReg = true;
417-
418 cWindow->applyOffset (dOff);
419
420 if (dScreen->cmActive)
421
422=== modified file 'plugins/move/src/move.cpp'
423--- plugins/move/src/move.cpp 2012-01-19 18:22:37 +0000
424+++ plugins/move/src/move.cpp 2012-01-19 18:22:37 +0000
425@@ -146,18 +146,19 @@
426 s->warpPointer (xRoot - pointerX, yRoot - pointerY);
427 }
428
429- if (ms->moveOpacity != OPAQUE)
430- {
431- if (mw->cWindow)
432- mw->cWindow->addDamage ();
433- if (mw->gWindow)
434- mw->gWindow->glPaintSetEnabled (mw, true);
435- }
436-
437 if (ms->hasCompositing && mw->cWindow)
438 {
439 mw->cWindow->addDamage ();
440- }
441+ mw->cWindow->applyOffsetSetEnabled (mw ,true);
442+ }
443+
444+ if (ms->moveOpacity != OPAQUE && mw->gWindow)
445+ {
446+ mw->gWindow->glPaintSetEnabled (mw, true);
447+ }
448+
449+ ms->w->positionSetEnabled (mw, true);
450+ screen->moveViewportSetEnabled (ms, true);
451 }
452 }
453
454@@ -183,11 +184,15 @@
455
456 if (state & CompAction::StateCancel)
457 ng.setPos (CompPoint (ms->savedX, ms->savedY));
458- else
459+ else if (mw->cWindow)
460 ng.setPos (ng.pos () + mw->cWindow->paintOffset ());
461
462- ms->w->position (ng);
463- mw->cWindow->addDamage ();
464+ ms->w->positionSetEnabled (mw, false);
465+ ms->w->position (ng, 0, 0);
466+ ms->w->positionSetEnabled (mw, true);
467+
468+ if (mw->cWindow)
469+ mw->cWindow->addDamage ();
470
471 /* update window attributes as window constraints may have
472 changed - needed e.g. if a maximized window was moved
473@@ -200,13 +205,19 @@
474 ms->grab = NULL;
475 }
476
477- if (ms->moveOpacity != OPAQUE)
478- {
479- if (mw->cWindow)
480- mw->cWindow->addDamage ();
481- if (mw->gWindow)
482- mw->gWindow->glPaintSetEnabled (mw, false);
483- }
484+ if (ms->hasCompositing && mw->cWindow)
485+ {
486+ mw->cWindow->addDamage ();
487+ mw->cWindow->applyOffsetSetEnabled (mw, false);
488+ }
489+
490+ if (ms->moveOpacity != OPAQUE && mw->gWindow)
491+ {
492+ mw->gWindow->glPaintSetEnabled (mw, false);
493+ }
494+
495+ ms->w->positionSetEnabled (mw, false);
496+ screen->moveViewportSetEnabled (ms, false);
497
498 ms->w = 0;
499 ms->releaseButton = 0;
500@@ -496,7 +507,9 @@
501
502 ng.setPos (ng.pos () + d);
503
504+ ms->w->positionSetEnabled (mw, false);
505 ms->w->position (ng);
506+ ms->w->positionSetEnabled (mw, true);
507 }
508
509 ms->x -= dx;
510@@ -644,6 +657,50 @@
511 }
512
513 bool
514+MoveWindow::position (compiz::window::Geometry &g,
515+ unsigned int source,
516+ unsigned int constrainment)
517+{
518+ /* Normally on position updates during window movement
519+ * we should warp the pointer by the difference in
520+ * geometry (eg, -(CompWindow::serverGeometry +
521+ * CompositeWindow::poisitionOffset)) so that it will
522+ * start moving again from that position, but in
523+ * the case of a viewport switch while a window
524+ * is still grabbed we need to keep the paint offset
525+ * and cursor position where they are */
526+ if (!MoveScreen::get (screen)->mSwitchVp)
527+ {
528+ CompPoint dp = window->serverGeometry ().pos () -
529+ g.pos ();
530+
531+ dp -= cWindow->paintOffset ();
532+
533+ screen->warpPointer (dp.x (), dp.y ());
534+ }
535+
536+ return window->position (g, source, constrainment);
537+}
538+
539+void
540+MoveWindow::applyOffset (const CompPoint &dOffset)
541+{
542+ /* See above */
543+ if (MoveScreen::get (screen)->mSwitchVp)
544+ cWindow->applyOffset (CompPoint (0, 0));
545+ else
546+ cWindow->applyOffset (dOffset);
547+}
548+
549+void
550+MoveScreen::moveViewport (int tx, int ty)
551+{
552+ mSwitchVp = true;
553+ screen->moveViewport (tx, ty);
554+ mSwitchVp = false;
555+}
556+
557+bool
558 MoveWindow::glPaint (const GLWindowPaintAttrib &attrib,
559 const GLMatrix &transform,
560 const CompRegion &region,
561@@ -697,7 +754,8 @@
562 releaseButton (0),
563 grab (NULL),
564 hasCompositing (false),
565- yConstrained (false)
566+ yConstrained (false),
567+ mSwitchVp (false)
568 {
569 updateOpacity ();
570
571@@ -722,6 +780,7 @@
572 optionSetInitiateKeyTerminate (moveTerminate);
573
574 ScreenInterface::setHandler (screen);
575+ screen->moveViewportSetEnabled (this, false);
576 }
577
578 MoveScreen::~MoveScreen ()
579
580=== modified file 'plugins/move/src/move.h'
581--- plugins/move/src/move.h 2012-01-19 18:22:37 +0000
582+++ plugins/move/src/move.h 2012-01-19 18:22:37 +0000
583@@ -66,6 +66,8 @@
584
585 void handleEvent (XEvent *);
586
587+ void moveViewport (int tx, int ty);
588+
589 bool registerPaintHandler (compiz::composite::PaintHandler *pHnd);
590 void unregisterPaintHandler ();
591
592@@ -94,11 +96,14 @@
593 bool hasCompositing;
594
595 bool yConstrained;
596+
597+ bool mSwitchVp;
598 };
599
600 class MoveWindow :
601+ public WindowInterface,
602+ public CompositeWindowInterface,
603 public GLWindowInterface,
604- public CompositeWindowInterface,
605 public PluginClassHandler<MoveWindow,CompWindow>
606 {
607 public:
608@@ -108,13 +113,21 @@
609 gWindow (GLWindow::get (window)),
610 cWindow (CompositeWindow::get (window))
611 {
612+ if (cWindow)
613+ CompositeWindowInterface::setHandler (cWindow, true);
614+
615 if (gWindow)
616 GLWindowInterface::setHandler (gWindow, false);
617
618- if (cWindow)
619- CompositeWindowInterface::setHandler (cWindow);
620+ WindowInterface::setHandler (window, false);
621 };
622
623+ bool position (compiz::window::Geometry &g,
624+ unsigned int source,
625+ unsigned int constrainment);
626+
627+ void applyOffset (const CompPoint &dOffset);
628+
629 bool glPaint (const GLWindowPaintAttrib &, const GLMatrix &,
630 const CompRegion &, unsigned int);
631
632
633=== modified file 'plugins/opengl/include/opengl/opengl.h'
634--- plugins/opengl/include/opengl/opengl.h 2012-01-12 06:48:58 +0000
635+++ plugins/opengl/include/opengl/opengl.h 2012-01-19 18:22:37 +0000
636@@ -35,7 +35,7 @@
637 #include <opengl/texture.h>
638 #include <opengl/fragment.h>
639
640-#define COMPIZ_OPENGL_ABI 4
641+#define COMPIZ_OPENGL_ABI 5
642
643 #include <core/pluginclasshandler.h>
644
645@@ -479,10 +479,16 @@
646 virtual void glDrawTexture (GLTexture *texture, GLFragment::Attrib &,
647 unsigned int);
648 virtual void glDrawGeometry ();
649+
650+ /**
651+ * Specify an absolute paint offset for this window, the default
652+ * is to use the value from the composite plugin
653+ */
654+ virtual CompPoint glPaintOffset ();
655 };
656
657 class GLWindow :
658- public WrapableHandler<GLWindowInterface, 5>,
659+ public WrapableHandler<GLWindowInterface, 6>,
660 public PluginClassHandler<GLWindow, CompWindow, COMPIZ_OPENGL_ABI>
661 {
662 public:
663@@ -581,6 +587,7 @@
664 WRAPABLE_HND (3, GLWindowInterface, void, glDrawTexture,
665 GLTexture *texture, GLFragment::Attrib &, unsigned int);
666 WRAPABLE_HND (4, GLWindowInterface, void, glDrawGeometry);
667+ WRAPABLE_HND (5, GLWindowInterface, CompPoint, glPaintOffset);
668
669 friend class GLScreen;
670 friend class PrivateGLScreen;
671
672=== modified file 'plugins/opengl/src/paint.cpp'
673--- plugins/opengl/src/paint.cpp 2012-01-19 18:22:37 +0000
674+++ plugins/opengl/src/paint.cpp 2012-01-19 18:22:37 +0000
675@@ -209,7 +209,7 @@
676 bool status, unredirectFS;
677 bool withOffset = false;
678 GLMatrix vTransform;
679- CompPoint offXY;
680+ CompPoint offXY, offset;
681
682 CompWindowList pl;
683 CompWindowList::reverse_iterator rit;
684@@ -241,6 +241,13 @@
685 if (w->destroyed ())
686 continue;
687
688+ odMask = PAINT_WINDOW_OCCLUSION_DETECTION_MASK;
689+
690+ offset = w->onAllViewports () ? CompPoint () : cScreen->windowPaintOffset ();
691+ offset += gw->glPaintOffset ();
692+
693+ offXY = w->getMovementForOffset (offset);
694+
695 if (!w->shaded ())
696 {
697 /* Non-damaged windows don't have valid pixmap
698@@ -249,6 +256,7 @@
699 if (!gw->priv->cWindow->damaged ())
700 {
701 gw->priv->clip = region;
702+ gw->priv->clip.translate (offset);
703 continue;
704 }
705 if (!w->isViewable ())
706@@ -258,19 +266,11 @@
707 /* copy region */
708 gw->priv->clip = tmpRegion;
709
710- odMask = PAINT_WINDOW_OCCLUSION_DETECTION_MASK;
711-
712- const CompPoint &offset =
713- cScreen->windowPaintOffset ();
714-
715 if ((offset.x () != 0 ||
716- offset.y () != 0) &&
717- !w->onAllViewports ())
718+ offset.y () != 0))
719 {
720 withOffset = true;
721
722- offXY = w->getMovementForOffset (offset);
723-
724 vTransform = transform;
725 vTransform.translate (offXY.x (), offXY.y (), 0);
726
727@@ -294,8 +294,6 @@
728 if (withOffset)
729 pr.translate (offXY);
730
731- pr.translate (gw->priv->cWindow->paintOffset ());
732-
733 tmpRegion -= pr;
734
735 /* unredirect top most fullscreen windows. */
736@@ -328,6 +326,8 @@
737 /* paint all windows from bottom to top */
738 foreach (w, pl)
739 {
740+ gw = GLWindow::get (w);
741+
742 if (w->destroyed ())
743 continue;
744
745@@ -340,23 +340,21 @@
746 continue;
747 }
748
749- gw = GLWindow::get (w);
750+ offset = w->onAllViewports () ? CompPoint () : cScreen->windowPaintOffset ();
751+ offset += gw->glPaintOffset ();
752+
753+ offXY = w->getMovementForOffset (offset);
754
755 const CompRegion &clip =
756 (!(mask & PAINT_SCREEN_NO_OCCLUSION_DETECTION_MASK)) ?
757- gw->clip () : region.translated (gw->priv->cWindow->paintOffset ());
758-
759- CompPoint offset =
760- cScreen->windowPaintOffset ();
761+ gw->clip () : region.translated (offXY);
762
763 if ((offset.x () != 0 ||
764- offset.y () != 0) &&
765- !w->onAllViewports ())
766+ offset.y () != 0))
767 {
768- offXY = w->getMovementForOffset (offset);
769-
770 vTransform = transform;
771 vTransform.translate (offXY.x (), offXY.y (), 0);
772+
773 gw->glPaint (gw->paintAttrib (), vTransform, clip,
774 windowMask | PAINT_WINDOW_WITH_OFFSET_MASK);
775 }
776@@ -641,6 +639,14 @@
777 }
778 }
779
780+CompPoint
781+GLWindow::glPaintOffset ()
782+{
783+ WRAPABLE_HND_FUNC_RETURN (5, CompPoint, glPaintOffset);
784+
785+ return priv->cWindow->paintOffset ();
786+}
787+
788 static inline void
789 addSingleQuad (GLfloat *&d,
790 const GLTexture::MatrixList &matrix,
791@@ -1213,7 +1219,6 @@
792 * too */
793
794 CompRegion pr = priv->window->region ();
795- pr.translate (priv->cWindow->paintOffset ());
796
797 ml[0] = priv->matrices[0];
798 priv->geometry.reset ();
799
800=== modified file 'plugins/opengl/src/window.cpp'
801--- plugins/opengl/src/window.cpp 2012-01-19 18:22:37 +0000
802+++ plugins/opengl/src/window.cpp 2012-01-19 18:22:37 +0000
803@@ -78,8 +78,6 @@
804 {
805 CompRect input (window->serverInputRect ());
806
807- input.setPos (input.pos () + cWindow->paintOffset ());
808-
809 if (textures.size () != matrices.size ())
810 matrices.resize (textures.size ());
811
812@@ -159,6 +157,10 @@
813 GLWindowInterface::glDrawGeometry ()
814 WRAPABLE_DEF (glDrawGeometry)
815
816+CompPoint
817+GLWindowInterface::glPaintOffset ()
818+ WRAPABLE_DEF (glPaintOffset)
819+
820 const CompRegion &
821 GLWindow::clip () const
822 {
823@@ -385,8 +387,6 @@
824 {
825 CompRect input (window->serverInputRect ());
826
827- input.setPos (input.pos () + cWindow->paintOffset ());
828-
829 if (regions.size () != textures.size ())
830 regions.resize (textures.size ());
831 for (unsigned int i = 0; i < textures.size (); i++)
832
833=== modified file 'plugins/rotate/src/rotate.cpp'
834--- plugins/rotate/src/rotate.cpp 2012-01-19 18:22:37 +0000
835+++ plugins/rotate/src/rotate.cpp 2012-01-19 18:22:37 +0000
836@@ -112,6 +112,16 @@
837 void
838 RotateScreen::releaseMoveWindow ()
839 {
840+ CompWindow *w = screen->findWindow (mMoveWindow);
841+
842+ if (w)
843+ {
844+ compiz::window::Geometry g = w->serverGeometry ();
845+ g.setPos (g.pos () + CompositeWindow::get (w)->paintOffset ());
846+
847+ w->position (g, 0, 0);
848+ }
849+
850 mMoveWindow = None;
851 }
852
853@@ -203,7 +213,7 @@
854 /* flag end of rotation */
855 cubeScreen->rotationState (CubeScreen::RotationNone);
856
857- screen->moveViewport (tx, 0, true);
858+ screen->moveViewport (tx, 0);
859
860 mXrot = 0.0f;
861 mYrot = 0.0f;
862@@ -227,7 +237,8 @@
863
864 ng.setX (mMoveWindowX);
865
866- w->position (ng);
867+ /* Don't care about constrainments */
868+ w->position (ng, 0, 0);
869 }
870 }
871 /* only focus default window if switcher isn't active */
872@@ -249,9 +260,13 @@
873 w = screen->findWindow (mMoveWindow);
874 if (w)
875 {
876+ CompositeWindow *cw = CompositeWindow::get (w);
877+
878 float xrot = (screen->vpSize ().width () * (mBaseXrot + mXrot)) / 360.0f;
879- w->moveToViewportPosition (mMoveWindowX - xrot * screen->width (),
880- w->y (), false);
881+ CompPoint lastOffset = cw->paintOffset ();
882+ CompPoint offset = CompPoint (-xrot * screen->width (), 0);
883+
884+ cw->applyOffset (offset - lastOffset);
885 }
886 }
887 }
888@@ -374,7 +389,7 @@
889
890 mask &= ~PAINT_SCREEN_REGION_MASK;
891 mask |= PAINT_SCREEN_TRANSFORMED_MASK;
892-
893+
894 return gScreen->glPaintOutput (sAttrib, sTransform, region, output, mask);
895 }
896
897
898=== modified file 'plugins/wobbly/src/wobbly.cpp'
899--- plugins/wobbly/src/wobbly.cpp 2012-01-19 18:22:37 +0000
900+++ plugins/wobbly/src/wobbly.cpp 2012-01-19 18:22:37 +0000
901@@ -1478,7 +1478,7 @@
902 w->output ().top));
903
904 w->positionSetEnabled (ww, false);
905- w->position (ng);
906+ w->position (ng, 0, 0);
907 w->positionSetEnabled (ww, true);
908 }
909
910@@ -1509,8 +1509,8 @@
911
912 const CompPoint &offset = ww->cWindow->paintOffset ();
913
914- int wx = w->geometry ().x () + offset.x ();
915- int wy = w->geometry ().y () + offset.y ();
916+ int wx = w->serverGeometry ().x () + offset.x ();
917+ int wy = w->serverGeometry ().y () + offset.y ();
918 int borderWidth = w->geometry ().border ();
919
920 // Damage a box that's 1-pixel larger on each side
921@@ -1607,6 +1607,14 @@
922 }
923 }
924
925+CompPoint
926+WobblyWindow::glPaintOffset ()
927+{
928+ /* Offsets are already done by
929+ * the model here */
930+ return CompPoint ();
931+}
932+
933 void
934 WobblyWindow::glAddGeometry (const GLTexture::MatrixList &matrix,
935 const CompRegion &region,
936@@ -1865,6 +1873,36 @@
937 window->windowNotify (n);
938 }
939
940+/* Ignore movement due to viewport changes */
941+void
942+WobblyScreen::moveViewport (int tx, int ty)
943+{
944+ foreach (CompWindow *w, screen->windows ())
945+ {
946+ WobblyWindow *ww = WobblyWindow::get (w);
947+
948+ ww->cWindow->applyOffsetSetEnabled (ww, false);
949+ ww->window->positionSetEnabled (ww, false);
950+ }
951+
952+ screen->moveViewport (tx, ty);
953+
954+ foreach (CompWindow *w, screen->windows ())
955+ {
956+ WobblyWindow *ww = WobblyWindow::get (w);
957+
958+ ww->cWindow->applyOffsetSetEnabled (ww, true);
959+ ww->window->positionSetEnabled (ww, true);
960+
961+ /* Move all models back by viewport switch amount */
962+ if (ww->model && ww->grabbed)
963+ {
964+ ww->model->move ((static_cast <float> (tx)) * screen->width (),
965+ (static_cast <float> (ty)) * screen->height ());
966+ }
967+ }
968+}
969+
970 void
971 WobblyScreen::handleEvent (XEvent *event)
972 {
973@@ -1986,6 +2024,7 @@
974 WobblyWindow::enableWobbling (bool enabling)
975 {
976 gWindow->glPaintSetEnabled (this, enabling);
977+ gWindow->glPaintOffsetSetEnabled (this, enabling);
978 gWindow->glAddGeometrySetEnabled (this, enabling);
979 gWindow->glDrawGeometrySetEnabled (this, enabling);
980 cWindow->damageRectSetEnabled (this, enabling);
981
982=== modified file 'plugins/wobbly/src/wobbly.h'
983--- plugins/wobbly/src/wobbly.h 2012-01-19 18:22:37 +0000
984+++ plugins/wobbly/src/wobbly.h 2012-01-19 18:22:37 +0000
985@@ -247,6 +247,7 @@
986
987 // ScreenInterface methods
988 void handleEvent (XEvent *event);
989+ void moveViewport (int tx, int ty);
990
991 // CompositeScreenInterface methods
992 void preparePaint (int);
993@@ -328,6 +329,7 @@
994 const CompRegion &, const CompRegion &,
995 unsigned int = MAXSHORT, unsigned int = MAXSHORT);
996 void glDrawGeometry ();
997+ CompPoint glPaintOffset ();
998
999 WobblyScreen *wScreen;
1000 CompWindow *window;
1001
1002=== modified file 'src/CMakeLists.txt'
1003--- src/CMakeLists.txt 2012-01-19 18:22:37 +0000
1004+++ src/CMakeLists.txt 2012-01-19 18:22:37 +0000
1005@@ -7,6 +7,7 @@
1006 add_subdirectory( pluginclasshandler )
1007 add_subdirectory( window )
1008 add_subdirectory( point )
1009+add_subdirectory( rect )
1010 add_subdirectory( wrapsystem/tests )
1011
1012 compiz_add_bcop_targets (
1013@@ -43,6 +44,9 @@
1014 ${CMAKE_CURRENT_SOURCE_DIR}/point/include
1015 ${CMAKE_CURRENT_SOURCE_DIR}/point/src
1016
1017+ ${CMAKE_CURRENT_SOURCE_DIR}/rect/include
1018+ ${CMAKE_CURRENT_SOURCE_DIR}/rect/src
1019+
1020 ${CMAKE_CURRENT_SOURCE_DIR}/pluginclasshandler/include
1021 ${CMAKE_CURRENT_SOURCE_DIR}/pluginclasshandler/src
1022
1023@@ -118,6 +122,7 @@
1024 compiz_string
1025 compiz_timer
1026 compiz_point
1027+ compiz_rect
1028 compiz_logmessage
1029 compiz_pluginclasshandler
1030 compiz_window_geometry
1031
1032=== added directory 'src/rect'
1033=== removed file 'src/rect.cpp'
1034--- src/rect.cpp 2012-01-19 18:22:37 +0000
1035+++ src/rect.cpp 1970-01-01 00:00:00 +0000
1036@@ -1,286 +0,0 @@
1037-/*
1038- * Copyright © 2008 Dennis Kasprzyk
1039- *
1040- * Permission to use, copy, modify, distribute, and sell this software
1041- * and its documentation for any purpose is hereby granted without
1042- * fee, provided that the above copyright notice appear in all copies
1043- * and that both that copyright notice and this permission notice
1044- * appear in supporting documentation, and that the name of
1045- * Dennis Kasprzyk not be used in advertising or publicity pertaining to
1046- * distribution of the software without specific, written prior permission.
1047- * Dennis Kasprzyk makes no representations about the suitability of this
1048- * software for any purpose. It is provided "as is" without express or
1049- * implied warranty.
1050- *
1051- * DENNIS KASPRZYK DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
1052- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
1053- * NO EVENT SHALL DENNIS KASPRZYK BE LIABLE FOR ANY SPECIAL, INDIRECT OR
1054- * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
1055- * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
1056- * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
1057- * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1058- *
1059- * Authors: Dennis Kasprzyk <onestone@compiz-fusion.org>
1060- */
1061-
1062-#include <X11/Xlib.h>
1063-#include <X11/Xregion.h>
1064-#include <core/rect.h>
1065-
1066-CompRect::CompRect ()
1067-{
1068- mRegion.rects = &mRegion.extents;
1069- mRegion.numRects = 1;
1070- mRegion.extents.x1 = 0;
1071- mRegion.extents.x2 = 0;
1072- mRegion.extents.y1 = 0;
1073- mRegion.extents.y2 = 0;
1074-}
1075-
1076-CompRect::CompRect (int x, int y, int width, int height)
1077-{
1078- mRegion.rects = &mRegion.extents;
1079- mRegion.numRects = 1;
1080- mRegion.extents.x1 = x;
1081- mRegion.extents.y1 = y;
1082- mRegion.extents.x2 = x + width;
1083- mRegion.extents.y2 = y + height;
1084-}
1085-
1086-CompRect::CompRect (const CompRect& r)
1087-{
1088- mRegion = r.mRegion;
1089- mRegion.rects = &mRegion.extents;
1090-}
1091-
1092-CompRect::CompRect (const XRectangle xr)
1093-{
1094- mRegion.rects = &mRegion.extents;
1095- mRegion.numRects = 1;
1096- mRegion.extents.x1 = xr.x;
1097- mRegion.extents.y1 = xr.y;
1098- mRegion.extents.x2 = xr.x + xr.width;
1099- mRegion.extents.y2 = xr.y + xr.height;
1100-}
1101-
1102-Region
1103-CompRect::region () const
1104-{
1105- return const_cast<const Region> (&mRegion);
1106-}
1107-
1108-void
1109-CompRect::setGeometry (int x,
1110- int y,
1111- int width,
1112- int height)
1113-{
1114- mRegion.extents.x1 = x;
1115- mRegion.extents.y1 = y;
1116- mRegion.extents.x2 = x + width;
1117- mRegion.extents.y2 = y + height;
1118-}
1119-
1120-void
1121-CompRect::setX (int x)
1122-{
1123- int width = mRegion.extents.x2 - mRegion.extents.x1;
1124-
1125- mRegion.extents.x1 = x;
1126- mRegion.extents.x2 = x + width;
1127-}
1128-
1129-void
1130-CompRect::setY (int y)
1131-{
1132- int height = mRegion.extents.y2 - mRegion.extents.y1;
1133-
1134- mRegion.extents.y1 = y;
1135- mRegion.extents.y2 = y + height;
1136-}
1137-
1138-void
1139-CompRect::setPos (const CompPoint& pos)
1140-{
1141- setX (pos.x ());
1142- setY (pos.y ());
1143-}
1144-
1145-void
1146-CompRect::setWidth (int width)
1147-{
1148- mRegion.extents.x2 = mRegion.extents.x1 + width;
1149-}
1150-
1151-void
1152-CompRect::setHeight (int height)
1153-{
1154- mRegion.extents.y2 = mRegion.extents.y1 + height;
1155-}
1156-
1157-void
1158-CompRect::setSize (const CompSize& size)
1159-{
1160- mRegion.extents.x2 = mRegion.extents.x1 + size.width ();
1161- mRegion.extents.y2 = mRegion.extents.y1 + size.height ();
1162-}
1163-
1164-void
1165-CompRect::setLeft (int x1)
1166-{
1167- mRegion.extents.x1 = x1;
1168- if (mRegion.extents.x2 < x1)
1169- mRegion.extents.x2 = x1;
1170-}
1171-
1172-void
1173-CompRect::setTop (int y1)
1174-{
1175- mRegion.extents.y1 = y1;
1176- if (mRegion.extents.y2 < y1)
1177- mRegion.extents.y2 = y1;
1178-}
1179-
1180-void
1181-CompRect::setRight (int x2)
1182-{
1183- mRegion.extents.x2 = x2;
1184- if (mRegion.extents.x1 > x2)
1185- mRegion.extents.x1 = x2;
1186-}
1187-
1188-void
1189-CompRect::setBottom (int y2)
1190-{
1191- mRegion.extents.y2 = y2;
1192- if (mRegion.extents.y1 > y2)
1193- mRegion.extents.y1 = y2;
1194-}
1195-
1196-bool
1197-CompRect::contains (const CompPoint& point) const
1198-{
1199- if (point.x () < x1 ())
1200- return false;
1201- if (point.x () > x2 ())
1202- return false;
1203- if (point.y () < y1 ())
1204- return false;
1205- if (point.y () > y2 ())
1206- return false;
1207-
1208- return true;
1209-}
1210-
1211-bool
1212-CompRect::contains (const CompRect& rect) const
1213-{
1214- if (rect.x1 () < x1 ())
1215- return false;
1216- if (rect.x2 () > x2 ())
1217- return false;
1218- if (rect.y1 () < y1 ())
1219- return false;
1220- if (rect.y2 () > y2 ())
1221- return false;
1222-
1223- return true;
1224-}
1225-
1226-bool
1227-CompRect::intersects (const CompRect& rect) const
1228-{
1229- int l, r, t, b;
1230-
1231- /* extents of overlapping rectangle */
1232- l = MAX (left (), rect.left ());
1233- r = MIN (right (), rect.right ());
1234- t = MAX (top (), rect.top ());
1235- b = MIN (bottom (), rect.bottom ());
1236-
1237- return (l < r) && (t < b);
1238-}
1239-
1240-bool
1241-CompRect::isEmpty () const
1242-{
1243- if (mRegion.extents.x1 != mRegion.extents.x2)
1244- return false;
1245- if (mRegion.extents.y1 != mRegion.extents.y2)
1246- return false;
1247-
1248- return true;
1249-}
1250-
1251-int
1252-CompRect::area () const
1253-{
1254- if (mRegion.extents.x2 < mRegion.extents.x1)
1255- return 0;
1256- if (mRegion.extents.y2 < mRegion.extents.y1)
1257- return 0;
1258-
1259- return (mRegion.extents.x2 - mRegion.extents.x1) *
1260- (mRegion.extents.y2 - mRegion.extents.y1);
1261-}
1262-
1263-bool
1264-CompRect::operator== (const CompRect &rect) const
1265-{
1266- if (mRegion.extents.x1 != rect.mRegion.extents.x1)
1267- return false;
1268- if (mRegion.extents.y1 != rect.mRegion.extents.y1)
1269- return false;
1270- if (mRegion.extents.x2 != rect.mRegion.extents.x2)
1271- return false;
1272- if (mRegion.extents.y2 != rect.mRegion.extents.y2)
1273- return false;
1274-
1275- return true;
1276-}
1277-
1278-bool
1279-CompRect::operator!= (const CompRect &rect) const
1280-{
1281- return !(*this == rect);
1282-}
1283-
1284-CompRect
1285-CompRect::operator& (const CompRect &rect) const
1286-{
1287- CompRect result (*this);
1288-
1289- result &= rect;
1290- return result;
1291-}
1292-
1293-CompRect&
1294-CompRect::operator&= (const CompRect &rect)
1295-{
1296- int l, r, t, b;
1297-
1298- /* extents of overlapping rectangle */
1299- l = MAX (left (), rect.left ());
1300- r = MIN (right (), rect.right ());
1301- t = MAX (top (), rect.top ());
1302- b = MIN (bottom (), rect.bottom ());
1303-
1304- mRegion.extents.x1 = l;
1305- mRegion.extents.x2 = r;
1306- mRegion.extents.y1 = t;
1307- mRegion.extents.y2 = b;
1308-
1309- return *this;
1310-}
1311-
1312-CompRect &
1313-CompRect::operator= (const CompRect &rect)
1314-{
1315- mRegion.extents.x1 = rect.mRegion.extents.x1;
1316- mRegion.extents.y1 = rect.mRegion.extents.y1;
1317- mRegion.extents.x2 = rect.mRegion.extents.x2;
1318- mRegion.extents.y2 = rect.mRegion.extents.y2;
1319-
1320- return *this;
1321-}
1322-
1323
1324=== added file 'src/rect/CMakeLists.txt'
1325--- src/rect/CMakeLists.txt 1970-01-01 00:00:00 +0000
1326+++ src/rect/CMakeLists.txt 2012-01-19 18:22:37 +0000
1327@@ -0,0 +1,66 @@
1328+pkg_check_modules (
1329+ GLIBMM
1330+ REQUIRED
1331+ glibmm-2.4 glib-2.0
1332+)
1333+
1334+INCLUDE_DIRECTORIES (
1335+ ${CMAKE_CURRENT_SOURCE_DIR}/include
1336+ ${CMAKE_CURRENT_SOURCE_DIR}/src
1337+
1338+ ${compiz_SOURCE_DIR}/src/point/include
1339+ ${compiz_SOURCE_DIR}/include
1340+
1341+ ${Boost_INCLUDE_DIRS}
1342+
1343+ ${GLIBMM_INCLUDE_DIRS}
1344+)
1345+
1346+LINK_DIRECTORIES (${GLIBMM_LIBRARY_DIRS})
1347+
1348+SET (
1349+ PUBLIC_HEADERS
1350+ ${CMAKE_CURRENT_SOURCE_DIR}/include/core/rect.h
1351+)
1352+
1353+SET (
1354+ PRIVATE_HEADERS
1355+)
1356+
1357+SET(
1358+ SRCS
1359+ ${CMAKE_CURRENT_SOURCE_DIR}/src/rect.cpp
1360+)
1361+
1362+ADD_LIBRARY(
1363+ compiz_rect STATIC
1364+
1365+ ${SRCS}
1366+
1367+ ${PUBLIC_HEADERS}
1368+ ${PRIVATE_HEADERS}
1369+)
1370+
1371+ADD_SUBDIRECTORY( ${CMAKE_CURRENT_SOURCE_DIR}/tests )
1372+
1373+SET_TARGET_PROPERTIES(
1374+ compiz_rect PROPERTIES
1375+ PUBLIC_HEADER "${PUBLIC_HEADERS}"
1376+)
1377+
1378+INSTALL(
1379+ TARGETS compiz_rect
1380+ RUNTIME DESTINATION bin
1381+ LIBRARY DESTINATION lib
1382+ ARCHIVE DESTINATION lib
1383+ PUBLIC_HEADER DESTINATION include/compiz
1384+)
1385+
1386+
1387+
1388+TARGET_LINK_LIBRARIES(
1389+ compiz_rect
1390+ compiz_point
1391+
1392+ ${GLIBMM_LIBRARIES}
1393+)
1394
1395=== added directory 'src/rect/include'
1396=== added directory 'src/rect/include/core'
1397=== added file 'src/rect/include/core/rect.h'
1398--- src/rect/include/core/rect.h 1970-01-01 00:00:00 +0000
1399+++ src/rect/include/core/rect.h 2012-01-19 18:22:37 +0000
1400@@ -0,0 +1,248 @@
1401+/*
1402+ * Copyright © 2008 Dennis Kasprzyk
1403+ *
1404+ * Permission to use, copy, modify, distribute, and sell this software
1405+ * and its documentation for any purpose is hereby granted without
1406+ * fee, provided that the above copyright notice appear in all copies
1407+ * and that both that copyright notice and this permission notice
1408+ * appear in supporting documentation, and that the name of
1409+ * Dennis Kasprzyk not be used in advertising or publicity pertaining to
1410+ * distribution of the software without specific, written prior permission.
1411+ * Dennis Kasprzyk makes no representations about the suitability of this
1412+ * software for any purpose. It is provided "as is" without express or
1413+ * implied warranty.
1414+ *
1415+ * DENNIS KASPRZYK DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
1416+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
1417+ * NO EVENT SHALL DENNIS KASPRZYK BE LIABLE FOR ANY SPECIAL, INDIRECT OR
1418+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
1419+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
1420+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
1421+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1422+ *
1423+ * Authors: Dennis Kasprzyk <onestone@compiz-fusion.org>
1424+ */
1425+
1426+#ifndef _COMPRECT_H
1427+#define _COMPRECT_H
1428+
1429+#include <core/point.h>
1430+#include <core/size.h>
1431+#include <vector>
1432+#include <list>
1433+#include <X11/Xlib.h>
1434+#include <X11/Xutil.h>
1435+#include <X11/Xregion.h>
1436+#include "core/point.h"
1437+
1438+
1439+/**
1440+ * A 2D rectangle, which is likely in screen space. It's data is
1441+ * isolated and can only be mutated with set() methods.
1442+ */
1443+class CompRect {
1444+
1445+ public:
1446+ CompRect ();
1447+ CompRect (int x, int y, int width, int height);
1448+ CompRect (const CompRect&);
1449+ CompRect (const XRectangle);
1450+
1451+ int x () const;
1452+ int y () const;
1453+ CompPoint pos () const;
1454+
1455+ int width () const;
1456+ int height () const;
1457+
1458+ int x1 () const;
1459+ int y1 () const;
1460+ int x2 () const;
1461+ int y2 () const;
1462+
1463+ int left () const;
1464+ int right () const;
1465+ int top () const;
1466+ int bottom () const;
1467+
1468+ int centerX () const;
1469+ int centerY () const;
1470+ CompPoint center () const;
1471+
1472+ int area () const;
1473+
1474+ /**
1475+ * Returns an X region handle for the CompRect
1476+ */
1477+ Region region () const;
1478+
1479+ void setGeometry (int x, int y,
1480+ int width, int height);
1481+
1482+ void setX (int);
1483+ void setY (int);
1484+ void setWidth (int);
1485+ void setHeight (int);
1486+
1487+ void setPos (const CompPoint&);
1488+ void setSize (const CompSize&);
1489+
1490+ /**
1491+ * Sets the left edge position
1492+ *
1493+ * Setting an edge past it's opposite edge will result in both edges
1494+ * being set to the new value
1495+ */
1496+ void setLeft (int);
1497+ /**
1498+ * Sets the top edge position
1499+ *
1500+ * Setting an edge past it's opposite edge will result in both edges
1501+ * being set to the new value
1502+ */
1503+ void setTop (int);
1504+ /**
1505+ * Sets the right edge position
1506+ *
1507+ * Setting an edge past it's opposite edge will result in both edges
1508+ * being set to the new value
1509+ */
1510+ void setRight (int);
1511+ /**
1512+ * Sets the bottom edge position
1513+ *
1514+ * Setting an edge past it's opposite edge will result in both edges
1515+ * being set to the new value
1516+ */
1517+ void setBottom (int);
1518+
1519+ bool contains (const CompPoint &) const;
1520+ bool contains (const CompRect &) const;
1521+ bool intersects (const CompRect &) const;
1522+ bool isEmpty () const;
1523+
1524+ bool operator== (const CompRect &) const;
1525+ bool operator!= (const CompRect &) const;
1526+
1527+ /* FIXME: Implement operator|= */
1528+
1529+ CompRect operator& (const CompRect &) const;
1530+ CompRect& operator&= (const CompRect &);
1531+ CompRect& operator= (const CompRect &);
1532+
1533+ typedef std::vector<CompRect> vector;
1534+ typedef std::vector<CompRect *> ptrVector;
1535+ typedef std::list<CompRect *> ptrList;
1536+
1537+ private:
1538+ REGION mRegion;
1539+};
1540+
1541+namespace compiz
1542+{
1543+ namespace rect
1544+ {
1545+ CompPoint wraparoundPoint (const CompRect &bounds,
1546+ const CompPoint &p);
1547+ }
1548+}
1549+
1550+
1551+inline int
1552+CompRect::x () const
1553+{
1554+ return mRegion.extents.x1;
1555+}
1556+
1557+inline int
1558+CompRect::y () const
1559+{
1560+ return mRegion.extents.y1;
1561+}
1562+
1563+inline CompPoint
1564+CompRect::pos () const
1565+{
1566+ return CompPoint (x (), y ());
1567+}
1568+
1569+inline int
1570+CompRect::width () const
1571+{
1572+ return mRegion.extents.x2 - mRegion.extents.x1;
1573+}
1574+
1575+inline int
1576+CompRect::height () const
1577+{
1578+ return mRegion.extents.y2 - mRegion.extents.y1;
1579+}
1580+
1581+inline int
1582+CompRect::x1 () const
1583+{
1584+ return mRegion.extents.x1;
1585+}
1586+
1587+inline int
1588+CompRect::y1 () const
1589+{
1590+ return mRegion.extents.y1;
1591+}
1592+
1593+inline int
1594+CompRect::x2 () const
1595+{
1596+ return mRegion.extents.x2;
1597+}
1598+
1599+inline int
1600+CompRect::y2 () const
1601+{
1602+ return mRegion.extents.y2;
1603+}
1604+
1605+inline int
1606+CompRect::left () const
1607+{
1608+ return mRegion.extents.x1;
1609+}
1610+
1611+inline int
1612+CompRect::right () const
1613+{
1614+ return mRegion.extents.x2;
1615+}
1616+
1617+inline int
1618+CompRect::top () const
1619+{
1620+ return mRegion.extents.y1;
1621+}
1622+
1623+
1624+inline int
1625+CompRect::bottom () const
1626+{
1627+ return mRegion.extents.y2;
1628+}
1629+
1630+inline int
1631+CompRect::centerX () const
1632+{
1633+ return x () + width () / 2;
1634+}
1635+
1636+inline int
1637+CompRect::centerY () const
1638+{
1639+ return y () + height () / 2;
1640+}
1641+
1642+inline CompPoint
1643+CompRect::center () const
1644+{
1645+ return CompPoint (centerX (), centerY ());
1646+}
1647+
1648+#endif
1649
1650=== added directory 'src/rect/src'
1651=== added file 'src/rect/src/rect.cpp'
1652--- src/rect/src/rect.cpp 1970-01-01 00:00:00 +0000
1653+++ src/rect/src/rect.cpp 2012-01-19 18:22:37 +0000
1654@@ -0,0 +1,306 @@
1655+/*
1656+ * Copyright © 2008 Dennis Kasprzyk
1657+ *
1658+ * Permission to use, copy, modify, distribute, and sell this software
1659+ * and its documentation for any purpose is hereby granted without
1660+ * fee, provided that the above copyright notice appear in all copies
1661+ * and that both that copyright notice and this permission notice
1662+ * appear in supporting documentation, and that the name of
1663+ * Dennis Kasprzyk not be used in advertising or publicity pertaining to
1664+ * distribution of the software without specific, written prior permission.
1665+ * Dennis Kasprzyk makes no representations about the suitability of this
1666+ * software for any purpose. It is provided "as is" without express or
1667+ * implied warranty.
1668+ *
1669+ * DENNIS KASPRZYK DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
1670+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
1671+ * NO EVENT SHALL DENNIS KASPRZYK BE LIABLE FOR ANY SPECIAL, INDIRECT OR
1672+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
1673+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
1674+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
1675+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1676+ *
1677+ * Authors: Dennis Kasprzyk <onestone@compiz-fusion.org>
1678+ */
1679+
1680+#include <X11/Xlib.h>
1681+#include <X11/Xregion.h>
1682+#include <core/rect.h>
1683+#include <math.h>
1684+#include <stdlib.h>
1685+
1686+
1687+CompRect::CompRect ()
1688+{
1689+ mRegion.rects = &mRegion.extents;
1690+ mRegion.numRects = 1;
1691+ mRegion.extents.x1 = 0;
1692+ mRegion.extents.x2 = 0;
1693+ mRegion.extents.y1 = 0;
1694+ mRegion.extents.y2 = 0;
1695+}
1696+
1697+CompRect::CompRect (int x, int y, int width, int height)
1698+{
1699+ mRegion.rects = &mRegion.extents;
1700+ mRegion.numRects = 1;
1701+ mRegion.extents.x1 = x;
1702+ mRegion.extents.y1 = y;
1703+ mRegion.extents.x2 = x + width;
1704+ mRegion.extents.y2 = y + height;
1705+}
1706+
1707+CompRect::CompRect (const CompRect& r)
1708+{
1709+ mRegion = r.mRegion;
1710+ mRegion.rects = &mRegion.extents;
1711+}
1712+
1713+CompRect::CompRect (const XRectangle xr)
1714+{
1715+ mRegion.rects = &mRegion.extents;
1716+ mRegion.numRects = 1;
1717+ mRegion.extents.x1 = xr.x;
1718+ mRegion.extents.y1 = xr.y;
1719+ mRegion.extents.x2 = xr.x + xr.width;
1720+ mRegion.extents.y2 = xr.y + xr.height;
1721+}
1722+
1723+CompPoint
1724+compiz::rect::wraparoundPoint (const CompRect &bounds, const CompPoint &p)
1725+{
1726+ CompPoint r (p);
1727+
1728+ if (p.x () > bounds.x2 ())
1729+ r.setX ((p.x () % bounds.width ()) + bounds.x1 ());
1730+ else if (p.x () < bounds.x1 ())
1731+ r.setX (bounds.width () - (abs (p.x ()) % bounds.width ()));
1732+
1733+ if (p.y () > bounds.y2 ())
1734+ r.setY ((p.y () % bounds.height ()) + bounds.y1 ());
1735+ else if (p.y () < bounds.y1 ())
1736+ r.setY (bounds.height () - (abs (p.y ()) % bounds.height ()));
1737+
1738+ return r;
1739+}
1740+
1741+Region
1742+CompRect::region () const
1743+{
1744+ return const_cast<const Region> (&mRegion);
1745+}
1746+
1747+void
1748+CompRect::setGeometry (int x,
1749+ int y,
1750+ int width,
1751+ int height)
1752+{
1753+ mRegion.extents.x1 = x;
1754+ mRegion.extents.y1 = y;
1755+ mRegion.extents.x2 = x + width;
1756+ mRegion.extents.y2 = y + height;
1757+}
1758+
1759+void
1760+CompRect::setX (int x)
1761+{
1762+ int width = mRegion.extents.x2 - mRegion.extents.x1;
1763+
1764+ mRegion.extents.x1 = x;
1765+ mRegion.extents.x2 = x + width;
1766+}
1767+
1768+void
1769+CompRect::setY (int y)
1770+{
1771+ int height = mRegion.extents.y2 - mRegion.extents.y1;
1772+
1773+ mRegion.extents.y1 = y;
1774+ mRegion.extents.y2 = y + height;
1775+}
1776+
1777+void
1778+CompRect::setPos (const CompPoint& pos)
1779+{
1780+ setX (pos.x ());
1781+ setY (pos.y ());
1782+}
1783+
1784+void
1785+CompRect::setWidth (int width)
1786+{
1787+ mRegion.extents.x2 = mRegion.extents.x1 + width;
1788+}
1789+
1790+void
1791+CompRect::setHeight (int height)
1792+{
1793+ mRegion.extents.y2 = mRegion.extents.y1 + height;
1794+}
1795+
1796+void
1797+CompRect::setSize (const CompSize& size)
1798+{
1799+ mRegion.extents.x2 = mRegion.extents.x1 + size.width ();
1800+ mRegion.extents.y2 = mRegion.extents.y1 + size.height ();
1801+}
1802+
1803+void
1804+CompRect::setLeft (int x1)
1805+{
1806+ mRegion.extents.x1 = x1;
1807+ if (mRegion.extents.x2 < x1)
1808+ mRegion.extents.x2 = x1;
1809+}
1810+
1811+void
1812+CompRect::setTop (int y1)
1813+{
1814+ mRegion.extents.y1 = y1;
1815+ if (mRegion.extents.y2 < y1)
1816+ mRegion.extents.y2 = y1;
1817+}
1818+
1819+void
1820+CompRect::setRight (int x2)
1821+{
1822+ mRegion.extents.x2 = x2;
1823+ if (mRegion.extents.x1 > x2)
1824+ mRegion.extents.x1 = x2;
1825+}
1826+
1827+void
1828+CompRect::setBottom (int y2)
1829+{
1830+ mRegion.extents.y2 = y2;
1831+ if (mRegion.extents.y1 > y2)
1832+ mRegion.extents.y1 = y2;
1833+}
1834+
1835+bool
1836+CompRect::contains (const CompPoint& point) const
1837+{
1838+ if (point.x () < x1 ())
1839+ return false;
1840+ if (point.x () > x2 ())
1841+ return false;
1842+ if (point.y () < y1 ())
1843+ return false;
1844+ if (point.y () > y2 ())
1845+ return false;
1846+
1847+ return true;
1848+}
1849+
1850+bool
1851+CompRect::contains (const CompRect& rect) const
1852+{
1853+ if (rect.x1 () < x1 ())
1854+ return false;
1855+ if (rect.x2 () > x2 ())
1856+ return false;
1857+ if (rect.y1 () < y1 ())
1858+ return false;
1859+ if (rect.y2 () > y2 ())
1860+ return false;
1861+
1862+ return true;
1863+}
1864+
1865+bool
1866+CompRect::intersects (const CompRect& rect) const
1867+{
1868+ int l, r, t, b;
1869+
1870+ /* extents of overlapping rectangle */
1871+ l = MAX (left (), rect.left ());
1872+ r = MIN (right (), rect.right ());
1873+ t = MAX (top (), rect.top ());
1874+ b = MIN (bottom (), rect.bottom ());
1875+
1876+ return (l < r) && (t < b);
1877+}
1878+
1879+bool
1880+CompRect::isEmpty () const
1881+{
1882+ return mRegion.extents.x1 == mRegion.extents.x2 ||
1883+ mRegion.extents.y1 == mRegion.extents.y2;
1884+}
1885+
1886+int
1887+CompRect::area () const
1888+{
1889+ if (mRegion.extents.x2 < mRegion.extents.x1)
1890+ return 0;
1891+ if (mRegion.extents.y2 < mRegion.extents.y1)
1892+ return 0;
1893+
1894+ return (mRegion.extents.x2 - mRegion.extents.x1) *
1895+ (mRegion.extents.y2 - mRegion.extents.y1);
1896+}
1897+
1898+bool
1899+CompRect::operator== (const CompRect &rect) const
1900+{
1901+ if (mRegion.extents.x1 != rect.mRegion.extents.x1)
1902+ return false;
1903+ if (mRegion.extents.y1 != rect.mRegion.extents.y1)
1904+ return false;
1905+ if (mRegion.extents.x2 != rect.mRegion.extents.x2)
1906+ return false;
1907+ if (mRegion.extents.y2 != rect.mRegion.extents.y2)
1908+ return false;
1909+
1910+ return true;
1911+}
1912+
1913+bool
1914+CompRect::operator!= (const CompRect &rect) const
1915+{
1916+ return !(*this == rect);
1917+}
1918+
1919+CompRect
1920+CompRect::operator& (const CompRect &rect) const
1921+{
1922+ CompRect result (*this);
1923+
1924+ result &= rect;
1925+ return result;
1926+}
1927+
1928+CompRect&
1929+CompRect::operator&= (const CompRect &rect)
1930+{
1931+ int l, r, t, b;
1932+
1933+ /* extents of overlapping rectangle */
1934+ l = MAX (left (), rect.left ());
1935+ r = MIN (right (), rect.right ());
1936+ t = MAX (top (), rect.top ());
1937+ b = MIN (bottom (), rect.bottom ());
1938+
1939+ mRegion.extents.x1 = l;
1940+ mRegion.extents.x2 = r;
1941+ mRegion.extents.y1 = t;
1942+ mRegion.extents.y2 = b;
1943+
1944+ /* FIXME: This can result in negative widths
1945+ * and heights, which makes no sense */
1946+
1947+ return *this;
1948+}
1949+
1950+CompRect &
1951+CompRect::operator= (const CompRect &rect)
1952+{
1953+ mRegion.extents.x1 = rect.mRegion.extents.x1;
1954+ mRegion.extents.y1 = rect.mRegion.extents.y1;
1955+ mRegion.extents.x2 = rect.mRegion.extents.x2;
1956+ mRegion.extents.y2 = rect.mRegion.extents.y2;
1957+
1958+ return *this;
1959+}
1960+
1961
1962=== added directory 'src/rect/tests'
1963=== added file 'src/rect/tests/CMakeLists.txt'
1964--- src/rect/tests/CMakeLists.txt 1970-01-01 00:00:00 +0000
1965+++ src/rect/tests/CMakeLists.txt 2012-01-19 18:22:37 +0000
1966@@ -0,0 +1,31 @@
1967+include_directories(${CMAKE_CURRENT_SOURCE_DIR})
1968+
1969+add_library (compiz_rect_test
1970+ ${CMAKE_CURRENT_SOURCE_DIR}/test-rect.cpp)
1971+
1972+add_executable (compiz_test_rect
1973+ ${CMAKE_CURRENT_SOURCE_DIR}/rect/src/test-rect.cpp)
1974+
1975+add_executable (compiz_test_rect_wraparound_point
1976+ ${CMAKE_CURRENT_SOURCE_DIR}/wraparound_point/src/test-rect-wraparound-point.cpp)
1977+
1978+target_link_libraries (compiz_test_rect
1979+ compiz_rect_test
1980+ compiz_rect
1981+ ${GTEST_BOTH_LIBRARIES}
1982+ ${GMOCK_LIBRARY}
1983+ ${GMOCK_MAIN_LIBRARY}
1984+ ${CMAKE_THREAD_LIBS_INIT} # Link in pthread.
1985+ )
1986+
1987+target_link_libraries (compiz_test_rect_wraparound_point
1988+ compiz_rect_test
1989+ compiz_rect
1990+ ${GTEST_BOTH_LIBRARIES}
1991+ ${GMOCK_LIBRARY}
1992+ ${GMOCK_MAIN_LIBRARY}
1993+ ${CMAKE_THREAD_LIBS_INIT} # Link in pthread.
1994+ )
1995+
1996+add_test (compiz_rect compiz_test_rect)
1997+add_test (compiz_rect_wraparound_point compiz_test_rect_wraparound_point)
1998
1999=== added directory 'src/rect/tests/rect'
2000=== added directory 'src/rect/tests/rect/src'
2001=== added file 'src/rect/tests/rect/src/test-rect.cpp'
2002--- src/rect/tests/rect/src/test-rect.cpp 1970-01-01 00:00:00 +0000
2003+++ src/rect/tests/rect/src/test-rect.cpp 2012-01-19 18:22:37 +0000
2004@@ -0,0 +1,106 @@
2005+/*
2006+ * Copyright © 2011 Canonical Ltd.
2007+ *
2008+ * Permission to use, copy, modify, distribute, and sell this software
2009+ * and its documentation for any purpose is hereby granted without
2010+ * fee, provided that the above copyright notice appear in all copies
2011+ * and that both that copyright notice and this permission notice
2012+ * appear in supporting documentation, and that the name of
2013+ * Canonical Ltd. not be used in advertising or publicity pertaining to
2014+ * distribution of the software without specific, written prior permission.
2015+ * Canonical Ltd. makes no representations about the suitability of this
2016+ * software for any purpose. It is provided "as is" without express or
2017+ * implied warranty.
2018+ *
2019+ * CANONICAL, LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
2020+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
2021+ * NO EVENT SHALL CANONICAL, LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
2022+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
2023+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
2024+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
2025+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
2026+ *
2027+ * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com>
2028+ */
2029+
2030+#include <test-rect.h>
2031+#include <iostream>
2032+#include <stdlib.h>
2033+
2034+class CompRectTestRect :
2035+ public CompRectTest
2036+{
2037+public:
2038+
2039+ CompRectTestRect ();
2040+ ~CompRectTestRect ();
2041+};
2042+
2043+
2044+CompRectTestRect::CompRectTestRect ()
2045+{
2046+}
2047+
2048+CompRectTestRect::~CompRectTestRect ()
2049+{
2050+}
2051+
2052+TEST_F (CompRectTestRect, TestRect)
2053+{
2054+ ASSERT_EQ (mRect, CompRect (0, 0, 0, 0));
2055+
2056+ mRect = CompRect (100, 100, 400, 300);
2057+
2058+ EXPECT_EQ (mRect.x (), 100);
2059+ EXPECT_EQ (mRect.y (), 100);
2060+ EXPECT_EQ (mRect.width (), 400);
2061+ EXPECT_EQ (mRect.height (), 300);
2062+ EXPECT_EQ (mRect.x2 (), 500);
2063+ EXPECT_EQ (mRect.y2 (), 400);
2064+ EXPECT_EQ (mRect.left (), 100);
2065+ EXPECT_EQ (mRect.right (), 500);
2066+ EXPECT_EQ (mRect.top (), 100);
2067+ EXPECT_EQ (mRect.bottom (), 400);
2068+
2069+ EXPECT_EQ (mRect.centerX (), 300);
2070+ EXPECT_EQ (mRect.centerY (), 250);
2071+
2072+ EXPECT_EQ (mRect.center (), CompPoint (300, 250));
2073+ EXPECT_EQ (mRect.pos (), CompPoint (100, 100));
2074+
2075+ EXPECT_EQ (mRect.area (), 120000);
2076+
2077+ mRect.setWidth (-1);
2078+ mRect.setHeight (-1);
2079+
2080+ EXPECT_EQ (mRect.area (), 0);
2081+
2082+ mRect = CompRect (0, 0, 0, 0);
2083+
2084+ EXPECT_TRUE (mRect.isEmpty ());
2085+
2086+ mRect.setRight (500);
2087+ mRect.setLeft (100);
2088+ mRect.setTop (50);
2089+ mRect.setBottom (450);
2090+
2091+ EXPECT_EQ (mRect, CompRect (100, 50, 400, 400));
2092+
2093+ mRect.setLeft (600);
2094+
2095+ EXPECT_TRUE (mRect.isEmpty ());
2096+ EXPECT_EQ (mRect.right (), 600);
2097+
2098+ mRect.setRight (1000);
2099+
2100+ EXPECT_TRUE (mRect.contains (CompPoint (601, 100)));
2101+ EXPECT_TRUE (mRect.contains (CompRect (601, 51, 300, 350)));
2102+ EXPECT_FALSE (mRect.contains (CompRect (601, 41, 900, 500)));
2103+ EXPECT_TRUE (mRect.intersects (CompRect (601, 41, 300, 400)));
2104+
2105+ /* Intersection */
2106+ mRect &= CompRect (700, 100, 400, 100);
2107+
2108+ EXPECT_EQ (mRect, CompRect (700, 100, 300, 100));
2109+}
2110+
2111
2112=== added file 'src/rect/tests/test-rect.cpp'
2113--- src/rect/tests/test-rect.cpp 1970-01-01 00:00:00 +0000
2114+++ src/rect/tests/test-rect.cpp 2012-01-19 18:22:37 +0000
2115@@ -0,0 +1,34 @@
2116+/*
2117+ * Copyright © 2011 Canonical Ltd.
2118+ *
2119+ * Permission to use, copy, modify, distribute, and sell this software
2120+ * and its documentation for any purpose is hereby granted without
2121+ * fee, provided that the above copyright notice appear in all copies
2122+ * and that both that copyright notice and this permission notice
2123+ * appear in supporting documentation, and that the name of
2124+ * Canonical Ltd. not be used in advertising or publicity pertaining to
2125+ * distribution of the software without specific, written prior permission.
2126+ * Canonical Ltd. makes no representations about the suitability of this
2127+ * software for any purpose. It is provided "as is" without express or
2128+ * implied warranty.
2129+ *
2130+ * CANONICAL, LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
2131+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
2132+ * NO EVENT SHALL CANONICAL, LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
2133+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
2134+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
2135+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
2136+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
2137+ *
2138+ * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com>
2139+ */
2140+
2141+#include "test-rect.h"
2142+
2143+CompRectTest::CompRectTest ()
2144+{
2145+}
2146+
2147+CompRectTest::~CompRectTest ()
2148+{
2149+}
2150
2151=== added file 'src/rect/tests/test-rect.h'
2152--- src/rect/tests/test-rect.h 1970-01-01 00:00:00 +0000
2153+++ src/rect/tests/test-rect.h 2012-01-19 18:22:37 +0000
2154@@ -0,0 +1,44 @@
2155+/*
2156+ * Copyright © 2011 Canonical Ltd.
2157+ *
2158+ * Permission to use, copy, modify, distribute, and sell this software
2159+ * and its documentation for any purpose is hereby granted without
2160+ * fee, provided that the above copyright notice appear in all copies
2161+ * and that both that copyright notice and this permission notice
2162+ * appear in supporting documentation, and that the name of
2163+ * Canonical Ltd. not be used in advertising or publicity pertaining to
2164+ * distribution of the software without specific, written prior permission.
2165+ * Canonical Ltd. makes no representations about the suitability of this
2166+ * software for any purpose. It is provided "as is" without express or
2167+ * implied warranty.
2168+ *
2169+ * CANONICAL, LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
2170+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
2171+ * NO EVENT SHALL CANONICAL, LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
2172+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
2173+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
2174+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
2175+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
2176+ *
2177+ * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com>
2178+ */
2179+
2180+#ifndef _COMPIZ_TEST_TIMER_H
2181+#define _COMPIZ_TEST_TIMER_H
2182+
2183+#include <gtest/gtest.h>
2184+#include <core/rect.h>
2185+
2186+class CompRectTest : public ::testing::Test
2187+{
2188+public:
2189+
2190+ CompRectTest ();
2191+ virtual ~CompRectTest ();
2192+
2193+protected:
2194+
2195+ CompRect mRect;
2196+};
2197+
2198+#endif
2199
2200=== added directory 'src/rect/tests/wraparound_point'
2201=== added directory 'src/rect/tests/wraparound_point/src'
2202=== added file 'src/rect/tests/wraparound_point/src/test-rect-wraparound-point.cpp'
2203--- src/rect/tests/wraparound_point/src/test-rect-wraparound-point.cpp 1970-01-01 00:00:00 +0000
2204+++ src/rect/tests/wraparound_point/src/test-rect-wraparound-point.cpp 2012-01-19 18:22:37 +0000
2205@@ -0,0 +1,78 @@
2206+/*
2207+ * Copyright © 2011 Canonical Ltd.
2208+ *
2209+ * Permission to use, copy, modify, distribute, and sell this software
2210+ * and its documentation for any purpose is hereby granted without
2211+ * fee, provided that the above copyright notice appear in all copies
2212+ * and that both that copyright notice and this permission notice
2213+ * appear in supporting documentation, and that the name of
2214+ * Canonical Ltd. not be used in advertising or publicity pertaining to
2215+ * distribution of the software without specific, written prior permission.
2216+ * Canonical Ltd. makes no representations about the suitability of this
2217+ * software for any purpose. It is provided "as is" without express or
2218+ * implied warranty.
2219+ *
2220+ * CANONICAL, LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
2221+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
2222+ * NO EVENT SHALL CANONICAL, LTD. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
2223+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
2224+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
2225+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
2226+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
2227+ *
2228+ * Authored by: Sam Spilsbury <sam.spilsbury@canonical.com>
2229+ */
2230+
2231+#include <test-rect.h>
2232+#include <iostream>
2233+#include <stdlib.h>
2234+
2235+class CompRectTestWraparound :
2236+ public CompRectTest
2237+{
2238+public:
2239+
2240+ CompRectTestWraparound ();
2241+ ~CompRectTestWraparound ();
2242+};
2243+
2244+
2245+CompRectTestWraparound::CompRectTestWraparound ()
2246+{
2247+ /* x1: -500
2248+ * x2: 750
2249+ * y1: -400
2250+ * y2: 800
2251+ */
2252+ mRect = CompRect (-500, -400, 1250, 1200);
2253+}
2254+
2255+CompRectTestWraparound::~CompRectTestWraparound ()
2256+{
2257+}
2258+
2259+TEST_F (CompRectTestWraparound, TestWraparound)
2260+{
2261+ CompPoint outsider = CompPoint (2501, 2401);
2262+ CompPoint inside = CompPoint ();
2263+
2264+ inside = compiz::rect::wraparoundPoint (mRect, outsider);
2265+
2266+ RecordProperty ("Outside point x: ", outsider.x ());
2267+ RecordProperty ("Outside point y: ", outsider.y ());
2268+ RecordProperty ("Inside point x: ", inside.x ());
2269+ RecordProperty ("Inside point y: ", inside.y ());
2270+
2271+ EXPECT_EQ (inside, CompPoint (-499, -399));
2272+
2273+ outsider = CompPoint (-1751, -1601);
2274+
2275+ inside = compiz::rect::wraparoundPoint (mRect, outsider);
2276+
2277+ RecordProperty ("Outside point x: ", outsider.x ());
2278+ RecordProperty ("Outside point y: ", outsider.y ());
2279+ RecordProperty ("Inside point x: ", inside.x ());
2280+ RecordProperty ("Inside point y: ", inside.y ());
2281+
2282+ EXPECT_EQ (inside, CompPoint (749, 799));
2283+}
2284
2285=== modified file 'src/screen.cpp'
2286--- src/screen.cpp 2012-01-19 18:22:37 +0000
2287+++ src/screen.cpp 2012-01-19 18:22:37 +0000
2288@@ -1710,7 +1710,7 @@
2289 ty = screen->vp ().y () - (newv - 1);
2290
2291 if (tx != 0 || ty != 0)
2292- screen->moveViewport (tx, ty, TRUE);
2293+ screen->moveViewport (tx, ty);
2294
2295 /* Move windows that were in one of the deleted viewports into the
2296 closest viewport */
2297@@ -3498,8 +3498,10 @@
2298 }
2299
2300 void
2301-CompScreen::moveViewport (int tx, int ty, bool sync)
2302+CompScreen::moveViewport (int tx, int ty)
2303 {
2304+ WRAPABLE_HND_FUNCTN (moveViewport, tx, ty);
2305+ CompWindow *w;
2306 CompPoint pnt;
2307
2308 tx = priv->vp.x () - tx;
2309@@ -3521,9 +3523,8 @@
2310
2311 foreach (CompWindow *w, priv->windows)
2312 {
2313- unsigned int valueMask = CWX | CWY;
2314- XWindowChanges xwc;
2315 compiz::window::Geometry saved;
2316+ compiz::window::Geometry ng = w->serverGeometry ();
2317
2318 if (w->onAllViewports ())
2319 continue;
2320@@ -3534,35 +3535,27 @@
2321 CHANGE_Y);
2322
2323 saved.setPos (saved.pos () + pnt);
2324+ ng.setPos (ng.pos () + pnt);
2325
2326 w->priv->geometrySaver.update (saved, saveMask);
2327-
2328- xwc.x = w->serverGeometry ().x () + pnt.x ();
2329- xwc.y = w->serverGeometry ().y () + pnt.y ();
2330-
2331- w->priv->configureXWindow (valueMask, &xwc);
2332+ w->position (ng, 0, 0);
2333 }
2334
2335- if (sync)
2336+ priv->setDesktopHints ();
2337+
2338+ priv->setCurrentActiveWindowHistory (priv->vp.x (), priv->vp.y ());
2339+
2340+ w = findWindow (priv->activeWindow);
2341+ if (w)
2342 {
2343- CompWindow *w;
2344-
2345- priv->setDesktopHints ();
2346-
2347- priv->setCurrentActiveWindowHistory (priv->vp.x (), priv->vp.y ());
2348-
2349- w = findWindow (priv->activeWindow);
2350- if (w)
2351- {
2352- CompPoint dvp;
2353-
2354- dvp = w->defaultViewport ();
2355-
2356- /* add window to current history if it's default viewport is
2357- still the current one. */
2358- if (priv->vp.x () == dvp.x () && priv->vp.y () == dvp.y ())
2359- priv->addToCurrentActiveWindowHistory (w->id ());
2360- }
2361+ CompPoint dvp;
2362+
2363+ dvp = w->defaultViewport ();
2364+
2365+ /* add window to current history if it's default viewport is
2366+ still the current one. */
2367+ if (priv->vp.x () == dvp.x () && priv->vp.y () == dvp.y ())
2368+ priv->addToCurrentActiveWindowHistory (w->id ());
2369 }
2370 }
2371
2372@@ -4007,6 +4000,10 @@
2373 WRAPABLE_DEF (leaveShowDesktopMode, window)
2374
2375 void
2376+ScreenInterface::moveViewport (int tx, int ty)
2377+ WRAPABLE_DEF (moveViewport, tx, ty)
2378+
2379+void
2380 ScreenInterface::outputChangeNotify ()
2381 WRAPABLE_DEF (outputChangeNotify)
2382
2383@@ -4659,6 +4656,13 @@
2384 XUngrabServer (dpy);
2385 XSync (dpy, FALSE);
2386
2387+ /* Need to set a default here so that the value isn't uninitialized
2388+ * when loading plugins FIXME: Should find a way to initialize options
2389+ * first and then set this value, or better yet, tie this value directly
2390+ * to the option */
2391+ priv->vpSize.setWidth (priv->optionGetHsize ());
2392+ priv->vpSize.setHeight (priv->optionGetVsize ());
2393+
2394 /* Start initializing windows here */
2395 priv->initialized = true;
2396
2397@@ -4718,13 +4722,6 @@
2398 focusDefaultWindow ();
2399 }
2400
2401- /* Need to set a default here so that the value isn't uninitialized
2402- * when loading plugins FIXME: Should find a way to initialize options
2403- * first and then set this value, or better yet, tie this value directly
2404- * to the option */
2405- priv->vpSize.setWidth (priv->optionGetHsize ());
2406- priv->vpSize.setHeight (priv->optionGetVsize ());
2407-
2408 /* TODO: Bailout properly when screenInitPlugins fails
2409 * TODO: It would be nicer if this line could mean
2410 * "init all the screens", but unfortunately it only inits
2411
2412=== modified file 'src/window.cpp'
2413--- src/window.cpp 2012-01-19 18:22:37 +0000
2414+++ src/window.cpp 2012-01-19 18:22:37 +0000
2415@@ -2487,6 +2487,9 @@
2416 {
2417 WRAPABLE_HND_FUNCTN_RETURN (bool, position, g, source, constrainment)
2418
2419+ /* Enforce wrap-around viewports */
2420+ g.setPos (CompPoint (g.pos ().x () % (screen->vpSize ().width () * screen->width ()),
2421+ g.pos ().y () % (screen->vpSize ().height () * screen->height ())));
2422 unsigned int changeMask = priv->serverGeometry.changeMask (g);
2423
2424 if (!(priv->type & (CompWindowTypeDockMask |
2425@@ -2553,7 +2556,10 @@
2426 if (changeMask)
2427 {
2428 XWindowChanges xwc;
2429- CompPoint dp = g.pos () - priv->serverGeometry.pos ();
2430+ CompPoint dp (g.pos () - priv->serverGeometry.pos ());
2431+
2432+ /* Check viewport position */
2433+ CompPoint lastVp (defaultViewport ());
2434
2435 memset (&xwc, 0, sizeof (XWindowChanges));
2436
2437@@ -2575,6 +2581,21 @@
2438 if (!priv->frameRegion.isEmpty ())
2439 priv->frameRegion.translate (dp);
2440
2441+ if (defaultViewport () != lastVp)
2442+ {
2443+ compiz::window::Geometry update;
2444+ unsigned int saveMask = (priv->geometrySaver.get (update) &
2445+ (CHANGE_X |
2446+ CHANGE_Y));
2447+ /* Not perfect, but the cases where we are changing
2448+ * viewports with a window with saved geometry are
2449+ * going to be cases where the window moves
2450+ * but CompScreen::width or CompScreen::height */
2451+ update.setPos (update.pos () + dp);
2452+
2453+ priv->geometrySaver.update (update, saveMask);
2454+ }
2455+
2456 return true;
2457 }
2458
2459@@ -6158,14 +6179,37 @@
2460 return priv->struts;
2461 }
2462
2463-void
2464-CompWindow::moveToViewportPosition (int x,
2465- int y,
2466- bool sync)
2467-{
2468- int tx, ty;
2469+CompPoint
2470+compiz::viewports::wraparoundOffsetForPoint (const CompPoint &p,
2471+ const CompPoint &wp,
2472+ const CompPoint &wvp)
2473+{
2474+ CompPoint remainingVp (screen->vpSize ().width () - wvp.x (),
2475+ screen->vpSize ().height () - wvp.y ());
2476+ CompPoint maxOffset ((remainingVp.x () * screen->width ()) -
2477+ wp.x (),
2478+ (remainingVp.y () * screen->height ()) -
2479+ wp.y ());
2480+ CompPoint minOffset (-((screen->vpSize ().width () * screen->width ()) - maxOffset.x ()),
2481+ -((screen->vpSize ().height () * screen->height ()) - maxOffset.y ()));
2482+ CompRect constrain (minOffset.x (), minOffset.y (),
2483+ maxOffset.x () - minOffset.x (),
2484+ maxOffset.y () - minOffset.y ());
2485+
2486+ return compiz::rect::wraparoundPoint (constrain, p);
2487+}
2488+
2489+CompRect
2490+compiz::viewports::borderRectForViewportPosition (const CompRect &borderRect,
2491+ const CompPoint &vp,
2492+ unsigned int type,
2493+ unsigned int state)
2494+{
2495+ int x = vp.x () * screen->width () + borderRect.x ();
2496+ int y = vp.y () * screen->height () + borderRect.y ();
2497 int vWidth = screen->width () * screen->vpSize ().width ();
2498 int vHeight = screen->height () * screen->vpSize ().height ();
2499+ int tx, ty;
2500
2501 if (screen->vpSize ().width () != 1)
2502 {
2503@@ -6181,61 +6225,51 @@
2504 y -= screen->vp ().y () * screen->height ();
2505 }
2506
2507- tx = x - priv->geometry.x ();
2508- ty = y - priv->geometry.y ();
2509+ tx = x - borderRect.x ();
2510+ ty = y - borderRect.y ();
2511
2512 if (tx || ty)
2513 {
2514- unsigned int valueMask = CWX | CWY;
2515- XWindowChanges xwc;
2516 int m, wx, wy;
2517
2518- if (!priv->managed)
2519- return;
2520-
2521- if (priv->type & (CompWindowTypeDesktopMask | CompWindowTypeDockMask))
2522- return;
2523-
2524- if (priv->state & CompWindowStateStickyMask)
2525- return;
2526+ if (type & (CompWindowTypeDesktopMask | CompWindowTypeDockMask))
2527+ return borderRect;
2528+
2529+ if (state & CompWindowStateStickyMask)
2530+ return borderRect;
2531
2532 wx = tx;
2533 wy = ty;
2534
2535 if (screen->vpSize ().width ()!= 1)
2536 {
2537- m = priv->geometry.x () + tx;
2538+ m = borderRect.x () + tx;
2539
2540- if (m - priv->output.left < (int) screen->width () - vWidth)
2541+ if (m < (int) screen->width () - vWidth)
2542 wx = tx + vWidth;
2543- else if (m + priv->width + priv->output.right > vWidth)
2544+ else if (m + borderRect.width () > vWidth)
2545 wx = tx - vWidth;
2546 }
2547
2548 if (screen->vpSize ().height () != 1)
2549 {
2550- m = priv->geometry.y () + ty;
2551+ m = borderRect.y () + ty;
2552
2553- if (m - priv->output.top < (int) screen->height () - vHeight)
2554+ if (m < (int) screen->height () - vHeight)
2555 wy = ty + vHeight;
2556- else if (m + priv->height + priv->output.bottom > vHeight)
2557+ else if (m + borderRect.height () > vHeight)
2558 wy = ty - vHeight;
2559 }
2560
2561- compiz::window::Geometry update;
2562- unsigned int saveMask = (priv->geometrySaver.get (update) & (CHANGE_X |
2563- CHANGE_Y));
2564-
2565- update.setPos (CompPoint (update.x () + wx,
2566- update.y () + wy));
2567-
2568- priv->geometrySaver.update (update, saveMask);
2569-
2570- xwc.x = serverGeometry ().x () + wx;
2571- xwc.y = serverGeometry ().y () + wy;
2572-
2573- priv->configureXWindow (valueMask, &xwc);
2574+ CompPoint np (wx, wy);
2575+ CompRect nbr (borderRect);
2576+
2577+ nbr.setPos (nbr.pos () + np);
2578+
2579+ return nbr;
2580 }
2581+
2582+ return borderRect;
2583 }
2584
2585 char *
2586@@ -6359,8 +6393,6 @@
2587 {
2588 Time timestamp = 0;
2589 CompPoint vp, svp;
2590- CompSize size;
2591- int x, y;
2592
2593 initialTimestampSet = false;
2594 screen->priv->applyStartupProperties (window);
2595@@ -6374,11 +6406,26 @@
2596
2597 vp = window->defaultViewport ();
2598 svp = screen->vp ();
2599- size = *screen;
2600-
2601- x = window->geometry ().x () + (svp.x () - vp.x ()) * size.width ();
2602- y = window->geometry ().y () + (svp.y () - vp.y ()) * size.height ();
2603- window->moveToViewportPosition (x, y, true);
2604+
2605+ CompRect br = compiz::viewports::borderRectForViewportPosition (window->serverBorderRect (),
2606+ svp - vp,
2607+ window->state (),
2608+ window->actions ());
2609+ br.setPos (br.pos () + CompPoint (window->border ().left,
2610+ window->border ().top));
2611+ br.setWidth (br.width () - window->border ().left - window->border ().right);
2612+ br.setHeight (br.height () - window->border ().bottom - window->border ().top);
2613+
2614+ compiz::window::Geometry g = window->serverGeometry ();
2615+
2616+ g.applyChange (compiz::window::Geometry (br.x (),
2617+ br.y (),
2618+ br.width (),
2619+ br.height (), 0), CHANGE_X |
2620+ CHANGE_Y |
2621+ CHANGE_WIDTH |
2622+ CHANGE_HEIGHT);
2623+ window->position (g, 0, 0);
2624
2625 if (allowWindowFocus (0, timestamp))
2626 window->activate ();
2627
2628=== modified file 'src/window/geometry-saver/CMakeLists.txt'
2629--- src/window/geometry-saver/CMakeLists.txt 2012-01-19 18:22:37 +0000
2630+++ src/window/geometry-saver/CMakeLists.txt 2012-01-19 18:22:37 +0000
2631@@ -16,6 +16,7 @@
2632
2633 ${compiz_SOURCE_DIR}/src/window/geometry/include
2634 ${compiz_SOURCE_DIR}/src/point/include
2635+ ${compiz_SOURCE_DIR}/src/rect/include
2636 )
2637
2638 LINK_DIRECTORIES (${GLIBMM_LIBRARY_DIRS})
2639
2640=== modified file 'src/window/geometry/CMakeLists.txt'
2641--- src/window/geometry/CMakeLists.txt 2012-01-19 18:22:37 +0000
2642+++ src/window/geometry/CMakeLists.txt 2012-01-19 18:22:37 +0000
2643@@ -10,6 +10,7 @@
2644
2645 ${compiz_SOURCE_DIR}/include
2646 ${compiz_SOURCE_DIR}/src/point/include
2647+ ${compiz_SOURCE_DIR}/src/rect/include
2648
2649 ${Boost_INCLUDE_DIRS}
2650
2651@@ -30,7 +31,6 @@
2652 SET(
2653 SRCS
2654 ${CMAKE_CURRENT_SOURCE_DIR}/src/windowgeometry.cpp
2655- ${compiz_SOURCE_DIR}/src/rect.cpp
2656 )
2657
2658 ADD_LIBRARY(
2659@@ -62,6 +62,7 @@
2660 TARGET_LINK_LIBRARIES(
2661 compiz_window_geometry
2662 compiz_point
2663+ compiz_rect
2664
2665 ${GLIBMM_LIBRARIES}
2666 )

Subscribers

People subscribed via source and target branches