7
* Copyright (c) 2006 Robert Carr <racarr@beryl-project.org>
10
* Robert Carr <racarr@beryl-project.org>
11
* Dennis Kasprzyk <onestone@opencompositing.org>
13
* This program is free software; you can redistribute it and/or
14
* modify it under the terms of the GNU General Public License
15
* as published by the Free Software Foundation; either version 2
16
* of the License, or (at your option) any later version.
18
* This program is distributed in the hope that it will be useful,
19
* but WITHOUT ANY WARRANTY; without even the implied warranty of
20
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
* GNU General Public License for more details.
25
#include "offset-movement.h"
28
compiz::wall::movementWindowOnScreen (const CompRect &serverBorderRect,
29
const CompRegion &screenRegion)
31
CompRegion sbrRegion (static_cast <const CompRect &> (serverBorderRect));
33
/* If the window would be partially offscreen
34
* after it was moved then we should move it back
35
* so that it is completely onscreen, since we moved
36
* from mostly offscreen on B to mostly onscreen on A,
37
* the user should be able to see their selected window */
38
CompRegion inter = sbrRegion.intersected (screenRegion);
39
CompRegion rem = sbrRegion - screenRegion;
44
for (std::vector <CompRect>::const_iterator it = rem.rects ().begin ();
45
it != rem.rects ().end ();
48
const CompRect &r = *it;
50
if (r.x1 () >= inter.boundingRect ().x2 ())
52
else if (r.x2 () <= inter.boundingRect ().x1 ())
55
if (r.y1 () >= inter.boundingRect ().y2 ())
57
else if (r.y2 () <= inter.boundingRect ().y1 ())
61
return CompPoint (dx, dy);