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

Proposed by Sam Spilsbury
Status: Superseded
Proposed branch: lp:~smspillaz/compiz-core/fix_896586_rotate_plugin
Merge into: lp:compiz-core/0.9.5
Prerequisite: lp:~smspillaz/compiz-core/fix_891591
Diff against target: 2634 lines (+1267/-681)
28 files modified
include/core/CMakeLists.txt (+0/-2)
include/core/rect.h (+0/-236)
include/core/screen.h (+6/-3)
include/core/window.h (+15/-2)
plugins/CMakeLists.txt (+1/-0)
plugins/decor/src/decor.cpp (+4/-13)
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 (+246/-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 (+91/-44)
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/fix_896586_rotate_plugin
Reviewer Review Type Date Requested Status
Alan Griffiths Needs Fixing
Tim Penhey (community) Needs Fixing
Thomi Richards (community) Approve
Review via email: mp+84061@code.launchpad.net

This proposal has been superseded by a proposal from 2012-01-13.

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.
2907. By Sam Spilsbury

Merged compiz-core.fix_891591

2908. By Sam Spilsbury

Fix typo

2909. By Sam Spilsbury

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

2910. By Sam Spilsbury

Merged compiz-core.fix_891591

2911. By Sam Spilsbury

Include point.cpp in the build files

2912. By Sam Spilsbury

Added missing files

2913. By Sam Spilsbury

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

2914. By Sam Spilsbury

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

2915. By Sam Spilsbury

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

2916. By Sam Spilsbury

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

2917. By Sam Spilsbury

Merged fix_891591

2918. By Sam Spilsbury

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

2919. By Sam Spilsbury

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

2920. By Sam Spilsbury

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

2921. By Sam Spilsbury

Cleanup, fix hardcoded debugging value

Revision history for this message
Thomi Richards (thomir-deactivatedaccount) wrote :

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
2922. By Sam Spilsbury

Merge

2923. By Sam Spilsbury

Merge

2924. By Sam Spilsbury

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

2925. By Sam Spilsbury

Merge

Revision history for this message
Tim Penhey (thumper) wrote :

> 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 :

> > 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

2926. By Sam Spilsbury

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

2927. By Sam Spilsbury

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

2928. By Sam Spilsbury

Don't read compiz pkg config file and cleanup

2929. By Sam Spilsbury

Merge

2930. By Sam Spilsbury

Merge

2931. By Sam Spilsbury

Merge

2932. By Sam Spilsbury

Added CompRect to testing and moved the wraparound point test to Google Test

2933. By Sam Spilsbury

Fix tests to make sure that width and height are relative and that the
intersection test reflects intersection and not union

2934. By Sam Spilsbury

Added a few FIXME notes

2935. By Sam Spilsbury

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

2936. By Sam Spilsbury

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

2937. By Sam Spilsbury

Expose rect in the plugins lists

2938. By Sam Spilsbury

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

2939. By Sam Spilsbury

Merge

2940. By Sam Spilsbury

Fix typo

2941. By Sam Spilsbury

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

2942. By Sam Spilsbury

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

2943. By Sam Spilsbury

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

2944. By Sam Spilsbury

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

2945. By Sam Spilsbury

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

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

> > 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
2946. By Sam Spilsbury

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

2947. By Sam Spilsbury

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

2948. By Sam Spilsbury

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

2949. By Sam Spilsbury

Don't translate the 2D texture matrix or regions

2950. By Sam Spilsbury

Merge

2951. By Sam Spilsbury

Remove files no longer installed in this point

2952. By Sam Spilsbury

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

Unmerged revisions

2952. By Sam Spilsbury

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

2951. By Sam Spilsbury

Remove files no longer installed in this point

2950. By Sam Spilsbury

Merge

2949. By Sam Spilsbury

Don't translate the 2D texture matrix or regions

2948. By Sam Spilsbury

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

2947. By Sam Spilsbury

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

2946. By Sam Spilsbury

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

2945. By Sam Spilsbury

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

2944. By Sam Spilsbury

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

2943. By Sam Spilsbury

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

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

Subscribers

People subscribed via source and target branches