1
=== modified file 'wall/CMakeLists.txt'
2
--- a/wall/CMakeLists.txt 2012-04-24 10:17:49 +0000
3
+++ b/wall/CMakeLists.txt 2012-05-09 01:57:02 +0000
8
-compiz_plugin (wall PLUGINDEPS composite opengl mousepoll PKGDEPS cairo cairo-xlib-xrender)
9
+add_subdirectory (src/offset_movement)
10
+include_directories (src/offset_movement/include)
12
+compiz_plugin (wall PLUGINDEPS composite opengl mousepoll PKGDEPS cairo cairo-xlib-xrender LIBRARIES compiz_wall_offset_movement dl)
14
=== added directory 'wall/src/offset_movement'
15
=== added file 'wall/src/offset_movement/CMakeLists.txt'
16
--- a/wall/src/offset_movement/CMakeLists.txt 1970-01-01 00:00:00 +0000
17
+++ b/wall/src/offset_movement/CMakeLists.txt 2012-05-09 01:57:02 +0000
22
+ glibmm-2.4 glib-2.0 compiz
25
+INCLUDE_DIRECTORIES (
26
+ ${CMAKE_CURRENT_SOURCE_DIR}/include
27
+ ${CMAKE_CURRENT_SOURCE_DIR}/src
29
+ ${CMAKE_SOURCE_DIR}/include
31
+ ${Boost_INCLUDE_DIRS}
33
+ ${GLIBMM_INCLUDE_DIRS}
36
+LINK_DIRECTORIES (${GLIBMM_LIBRARY_DIRS})
44
+ ${CMAKE_CURRENT_SOURCE_DIR}/include/offset-movement.h
49
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/offset-movement.cpp
53
+ compiz_wall_offset_movement STATIC
61
+if (COMPIZ_BUILD_TESTING)
62
+ADD_SUBDIRECTORY( ${CMAKE_CURRENT_SOURCE_DIR}/tests )
63
+endif (COMPIZ_BUILD_TESTING)
65
+SET_TARGET_PROPERTIES(
66
+ compiz_wall_offset_movement PROPERTIES
67
+ PUBLIC_HEADER "${PUBLIC_HEADERS}"
70
+TARGET_LINK_LIBRARIES(
71
+ compiz_wall_offset_movement
77
=== added directory 'wall/src/offset_movement/include'
78
=== added file 'wall/src/offset_movement/include/offset-movement.h'
79
--- a/wall/src/offset_movement/include/offset-movement.h 1970-01-01 00:00:00 +0000
80
+++ b/wall/src/offset_movement/include/offset-movement.h 2012-05-09 01:57:02 +0000
84
+ * Compiz wall plugin
88
+ * Copyright (c) 2006 Robert Carr <racarr@beryl-project.org>
91
+ * Robert Carr <racarr@beryl-project.org>
92
+ * Dennis Kasprzyk <onestone@opencompositing.org>
94
+ * This program is free software; you can redistribute it and/or
95
+ * modify it under the terms of the GNU General Public License
96
+ * as published by the Free Software Foundation; either version 2
97
+ * of the License, or (at your option) any later version.
99
+ * This program is distributed in the hope that it will be useful,
100
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
101
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
102
+ * GNU General Public License for more details.
106
+#ifndef _COMPIZ_WALL_OFFSET_MOVEMENT_H
107
+#define _COMPIZ_WALL_OFFSET_MOVEMENT_H
109
+#include <core/region.h>
110
+#include <core/rect.h>
111
+#include <core/point.h>
117
+ CompPoint movementWindowOnScreen (const CompRect &serverBorderRect,
118
+ const CompRegion &screenRegion);
124
=== added directory 'wall/src/offset_movement/src'
125
=== added file 'wall/src/offset_movement/src/offset-movement.cpp'
126
--- a/wall/src/offset_movement/src/offset-movement.cpp 1970-01-01 00:00:00 +0000
127
+++ b/wall/src/offset_movement/src/offset-movement.cpp 2012-05-09 01:57:02 +0000
131
+ * Compiz wall plugin
133
+ * offset-movement.c
135
+ * Copyright (c) 2006 Robert Carr <racarr@beryl-project.org>
138
+ * Robert Carr <racarr@beryl-project.org>
139
+ * Dennis Kasprzyk <onestone@opencompositing.org>
141
+ * This program is free software; you can redistribute it and/or
142
+ * modify it under the terms of the GNU General Public License
143
+ * as published by the Free Software Foundation; either version 2
144
+ * of the License, or (at your option) any later version.
146
+ * This program is distributed in the hope that it will be useful,
147
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
148
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
149
+ * GNU General Public License for more details.
153
+#include "offset-movement.h"
156
+compiz::wall::movementWindowOnScreen (const CompRect &serverBorderRect,
157
+ const CompRegion &screenRegion)
159
+ CompRegion sbrRegion (static_cast <const CompRect &> (serverBorderRect));
161
+ /* If the window would be partially offscreen
162
+ * after it was moved then we should move it back
163
+ * so that it is completely onscreen, since we moved
164
+ * from mostly offscreen on B to mostly onscreen on A,
165
+ * the user should be able to see their selected window */
166
+ CompRegion inter = sbrRegion.intersected (screenRegion);
167
+ CompRegion rem = sbrRegion - screenRegion;
172
+ for (std::vector <CompRect>::const_iterator it = rem.rects ().begin ();
173
+ it != rem.rects ().end ();
176
+ const CompRect &r = *it;
178
+ if (r.x1 () >= inter.boundingRect ().x2 ())
180
+ else if (r.x2 () <= inter.boundingRect ().x1 ())
183
+ if (r.y1 () >= inter.boundingRect ().y2 ())
185
+ else if (r.y2 () <= inter.boundingRect ().y1 ())
189
+ return CompPoint (dx, dy);
192
=== added directory 'wall/src/offset_movement/tests'
193
=== added file 'wall/src/offset_movement/tests/CMakeLists.txt'
194
--- a/wall/src/offset_movement/tests/CMakeLists.txt 1970-01-01 00:00:00 +0000
195
+++ b/wall/src/offset_movement/tests/CMakeLists.txt 2012-05-09 01:57:02 +0000
197
+# Build Google Test and make its headers known
198
+find_package (GTest)
200
+if (NOT GTEST_FOUND)
202
+ # Check for google test and build it locally
203
+ set (GTEST_ROOT_DIR
204
+ "/usr/src/gtest" # Default value, adjustable by user with e.g., ccmake
207
+ "Path to Google test srcs"
210
+ find_path (GTEST_INCLUDE_DIR gtest/gtest.h)
212
+ if (GTEST_INCLUDE_DIR)
213
+ #FIXME - hardcoded is bad!
214
+ add_subdirectory (${GTEST_ROOT_DIR}
216
+ endif(GTEST_INCLUDE_DIR)
218
+ set (GTEST_BOTH_LIBRARIES gtest gtest_main)
219
+ set (GTEST_FOUND TRUE)
221
+endif (NOT GTEST_FOUND)
226
+ glibmm-2.4 glib-2.0 compiz
229
+find_library (GMOCK_LIBRARY gmock)
230
+find_library (GMOCK_MAIN_LIBRARY gmock_main)
232
+if (NOT GMOCK_LIBRARY OR NOT GMOCK_MAIN_LIBRARY OR NOT GTEST_FOUND)
233
+ message ("Google Mock and Google Test not found - cannot build tests!")
234
+ set (COMPIZ_BUILD_TESTING OFF)
235
+endif (NOT GMOCK_LIBRARY OR NOT GMOCK_MAIN_LIBRARY OR NOT GTEST_FOUND)
237
+include_directories (${GTEST_INCLUDE_DIRS})
238
+include_directories(${CMAKE_CURRENT_SOURCE_DIR})
239
+include_directories (${COMPIZ_INCLUDE_DIRS})
241
+link_directories (${COMPIZ_LIBRARY_DIRS})
243
+add_executable (compiz_test_wall_offset_movement
244
+ ${CMAKE_CURRENT_SOURCE_DIR}/test-wall-offset-movement.cpp)
246
+target_link_libraries (compiz_test_wall_offset_movement
247
+ compiz_wall_offset_movement
248
+ ${GTEST_BOTH_LIBRARIES}
250
+ ${GMOCK_MAIN_LIBRARY}
251
+ ${CMAKE_THREAD_LIBS_INIT} # Link in pthread.
254
+gtest_add_tests (compiz_test_wall_offset_movement "" ${CMAKE_CURRENT_SOURCE_DIR}/test-wall-offset-movement.cpp)
256
=== added file 'wall/src/offset_movement/tests/test-wall-offset-movement.cpp'
257
--- a/wall/src/offset_movement/tests/test-wall-offset-movement.cpp 1970-01-01 00:00:00 +0000
258
+++ b/wall/src/offset_movement/tests/test-wall-offset-movement.cpp 2012-05-09 01:57:02 +0000
260
+#include <gtest/gtest.h>
261
+#include <gmock/gmock.h>
263
+#include "offset-movement.h"
265
+class WallOffsetMovementTest :
266
+ public ::testing::Test
270
+TEST(WallOffsetMovementTest, TestOffsetRight)
272
+ CompRect sbr (750, 0, 500, 500);
273
+ CompRegion sr (0, 0, 1000, 1000);
275
+ CompPoint offset = compiz::wall::movementWindowOnScreen (sbr, sr);
277
+ EXPECT_EQ (offset, CompPoint (-250, 0));
280
+TEST(WallOffsetMovementTest, TestOffsetLeft)
282
+ CompRect sbr (-250, 0, 500, 500);
283
+ CompRegion sr (0, 0, 1000, 1000);
285
+ CompPoint offset = compiz::wall::movementWindowOnScreen (sbr, sr);
287
+ EXPECT_EQ (offset, CompPoint (250, 0));
290
+TEST(WallOffsetMovementTest, TestOffsetTop)
292
+ CompRect sbr (0, -250, 500, 500);
293
+ CompRegion sr (0, 0, 1000, 1000);
295
+ CompPoint offset = compiz::wall::movementWindowOnScreen (sbr, sr);
297
+ EXPECT_EQ (offset, CompPoint (0, 250));
300
+TEST(WallOffsetMovementTest, TestOffsetBottom)
302
+ CompRect sbr (0, 750, 500, 500);
303
+ CompRegion sr (0, 0, 1000, 1000);
305
+ CompPoint offset = compiz::wall::movementWindowOnScreen (sbr, sr);
307
+ EXPECT_EQ (offset, CompPoint (0, -250));
310
+TEST(WallOffsetMovementTest, TestOffsetRightMMSlice)
312
+ CompRect sbr (750, 0, 500, 500);
313
+ CompRegion sr (0, 0, 1000, 1000);
315
+ sr -= CompRegion (400, 0, 200, 0);
317
+ CompPoint offset = compiz::wall::movementWindowOnScreen (sbr, sr);
319
+ EXPECT_EQ (offset, CompPoint (-250, 0));
322
+TEST(WallOffsetMovementTest, TestOffsetLeftMMSlice)
324
+ CompRect sbr (-250, 0, 500, 500);
325
+ CompRegion sr (0, 0, 1000, 1000);
327
+ sr -= CompRegion (400, 0, 200, 0);
329
+ CompPoint offset = compiz::wall::movementWindowOnScreen (sbr, sr);
331
+ EXPECT_EQ (offset, CompPoint (250, 0));
334
+TEST(WallOffsetMovementTest, TestOffsetTopMMSlice)
336
+ CompRect sbr (0, -250, 500, 500);
337
+ CompRegion sr (0, 0, 1000, 1000);
339
+ sr -= CompRegion (400, 0, 200, 0);
341
+ CompPoint offset = compiz::wall::movementWindowOnScreen (sbr, sr);
343
+ EXPECT_EQ (offset, CompPoint (0, 250));
346
+TEST(WallOffsetMovementTest, TestOffsetBottomMMSlice)
348
+ CompRect sbr (0, 750, 500, 500);
349
+ CompRegion sr (0, 0, 1000, 1000);
351
+ sr -= CompRegion (400, 0, 200, 0);
353
+ CompPoint offset = compiz::wall::movementWindowOnScreen (sbr, sr);
355
+ EXPECT_EQ (offset, CompPoint (0, -250));
358
=== modified file 'wall/src/wall.cpp'
359
--- a/wall/src/wall.cpp 2012-01-23 10:29:36 +0000
360
+++ b/wall/src/wall.cpp 2012-05-09 01:57:02 +0000
361
@@ -620,50 +620,29 @@
363
unsigned int mask = 0;
365
- ws->moveViewport (-dx, -dy, false);
366
+ /* If changing viewports fails we should not
367
+ * move the client window */
368
+ if (!ws->moveViewport (-dx, -dy, false))
370
+ window->activate ();
374
ws->focusDefault = false;
376
- CompWindow::Geometry sbr (window->serverBorderRect ().x (),
377
- window->serverBorderRect ().y (),
378
- window->serverBorderRect ().width (),
379
- window->serverBorderRect ().height (),
381
- CompRegion sbrRegion (sbr);
382
- int output = screen->outputDeviceForGeometry (sbr);
383
- CompRegion outputRegion (screen->outputDevs ()[output].workArea ());
385
- /* If the window would be partially offscreen
386
- * after it was moved then we should move it back
387
- * so that it is completely onscreen, since we moved
388
- * from mostly offscreen on B to mostly onscreen on A,
389
- * the user should be able to see their selected window */
390
- CompRegion inter = sbrRegion.intersected (outputRegion);
391
- CompRegion rem = sbrRegion - outputRegion;
393
- foreach (const CompRect &r, rem.rects ())
395
- if (r.x1 () >= inter.boundingRect ().x2 ())
397
- xwc.x = window->serverGeometry ().x () - r.width ();
400
- else if (r.x2 () <= inter.boundingRect ().x1 ())
402
- xwc.x = window->serverGeometry ().x () + r.width ();
406
- if (r.y1 () >= inter.boundingRect ().y2 ())
408
- xwc.y = window->serverGeometry ().y () - r.height ();
411
- else if (r.y2 () <= inter.boundingRect ().y1 ())
413
- xwc.y = window->serverGeometry ().y () + r.height ();
417
+ CompRegion screenRegion;
419
+ foreach (const CompOutput &o, screen->outputDevs ())
420
+ screenRegion += o.workArea ();
422
+ CompPoint d = compiz::wall::movementWindowOnScreen (window->serverBorderRect (),
425
+ mask |= d.x () !=0 ? CWX : 0;
426
+ mask |= d.y () !=0 ? CWY : 0;
428
+ xwc.x = window->serverGeometry ().x () + dx;
429
+ xwc.y = window->serverGeometry ().y () + dy;
431
window->configureXWindow (mask, &xwc);
433
@@ -1515,7 +1494,7 @@
435
if (!moving && !showPreview && grabIndex)
437
- screen->removeGrab (grabIndex, NULL);
438
+ screen->removeGrab (static_cast <CompScreen::GrabHandle> (grabIndex), NULL);
443
=== modified file 'wall/src/wall.h'
444
--- a/wall/src/wall.h 2012-03-09 10:11:24 +0000
445
+++ b/wall/src/wall.h 2012-05-09 01:57:02 +0000
447
#include <cairo-xlib-xrender.h>
450
+#include "offset-movement.h"
452
#include "wall_options.h"