Merge lp:~smspillaz/compiz-wall-plugin/compiz-wall-plugin.fix_939228 into lp:compiz-wall-plugin
- compiz-wall-plugin.fix_939228
- Merge into 0.9.5
Status: | Merged |
---|---|
Merged at revision: | 133 |
Proposed branch: | lp:~smspillaz/compiz-wall-plugin/compiz-wall-plugin.fix_939228 |
Merge into: | lp:compiz-wall-plugin |
Diff against target: |
452 lines (+343/-44) 8 files modified
CMakeLists.txt (+4/-1) src/offset_movement/CMakeLists.txt (+57/-0) src/offset_movement/include/offset-movement.h (+41/-0) src/offset_movement/src/offset-movement.cpp (+62/-0) src/offset_movement/tests/CMakeLists.txt (+58/-0) src/offset_movement/tests/test-wall-offset-movement.cpp (+97/-0) src/wall.cpp (+22/-43) src/wall.h (+2/-0) |
To merge this branch: | bzr merge lp:~smspillaz/compiz-wall-plugin/compiz-wall-plugin.fix_939228 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Daniel van Vugt | Approve | ||
Review via email: mp+104005@code.launchpad.net |
This proposal supersedes a proposal from 2012-04-24.
Commit message
Description of the change
== Problem ==
Another arm of bug 939228 : if a window spanned two monitors it would shift around on viewport changes
== Solution ==
Take all workareas into account when calculating window shift
== test ==
included.
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal | # |
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal | # |
Linking CXX executable compiz_
/usr/bin/ld: cannot find -lcompiz_core
collect2: ld returned 1 exit status
make[2]: *** [src/offset_
make[1]: *** [src/offset_
make: *** [all] Error 2
Sam Spilsbury (smspillaz) wrote : | # |
Curious. It compiles fine here and
pkg_check_modules (
GLIBMM
REQUIRED
glibmm-2.4 glib-2.0 compiz
)
INCLUDE_DIRECTORIES (
${CMAKE_
${CMAKE_
${CMAKE_
${Boost_
${GLIBMM_
)
LINK_DIRECTORIES (${GLIBMM_
^ should take care of finding the right directory for libcompiz_core . I suspect your install is broken. What is the output of make when CMAKE_VERBOSE_
Daniel van Vugt (vanvugt) wrote : | # |
Looks OK and seems to work.
Preview Diff
1 | === modified file 'CMakeLists.txt' |
2 | --- CMakeLists.txt 2012-04-24 08:39:54 +0000 |
3 | +++ CMakeLists.txt 2012-04-28 19:08:18 +0000 |
4 | @@ -2,4 +2,7 @@ |
5 | |
6 | include (CompizPlugin) |
7 | |
8 | -compiz_plugin (wall PLUGINDEPS composite opengl mousepoll PKGDEPS cairo cairo-xlib-xrender LIBRARIES dl) |
9 | +add_subdirectory (src/offset_movement) |
10 | +include_directories (src/offset_movement/include) |
11 | + |
12 | +compiz_plugin (wall PLUGINDEPS composite opengl mousepoll PKGDEPS cairo cairo-xlib-xrender LIBRARIES compiz_wall_offset_movement dl) |
13 | |
14 | === added directory 'src/offset_movement' |
15 | === added file 'src/offset_movement/CMakeLists.txt' |
16 | --- src/offset_movement/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
17 | +++ src/offset_movement/CMakeLists.txt 2012-04-28 19:08:18 +0000 |
18 | @@ -0,0 +1,57 @@ |
19 | +pkg_check_modules ( |
20 | + GLIBMM |
21 | + REQUIRED |
22 | + glibmm-2.4 glib-2.0 compiz |
23 | +) |
24 | + |
25 | +INCLUDE_DIRECTORIES ( |
26 | + ${CMAKE_CURRENT_SOURCE_DIR}/include |
27 | + ${CMAKE_CURRENT_SOURCE_DIR}/src |
28 | + |
29 | + ${CMAKE_SOURCE_DIR}/include |
30 | + |
31 | + ${Boost_INCLUDE_DIRS} |
32 | + |
33 | + ${GLIBMM_INCLUDE_DIRS} |
34 | +) |
35 | + |
36 | +LINK_DIRECTORIES (${GLIBMM_LIBRARY_DIRS}) |
37 | + |
38 | +SET ( |
39 | + PUBLIC_HEADERS |
40 | +) |
41 | + |
42 | +SET ( |
43 | + PRIVATE_HEADERS |
44 | + ${CMAKE_CURRENT_SOURCE_DIR}/include/offset-movement.h |
45 | +) |
46 | + |
47 | +SET( |
48 | + SRCS |
49 | + ${CMAKE_CURRENT_SOURCE_DIR}/src/offset-movement.cpp |
50 | +) |
51 | + |
52 | +ADD_LIBRARY( |
53 | + compiz_wall_offset_movement STATIC |
54 | + |
55 | + ${SRCS} |
56 | + |
57 | + ${PUBLIC_HEADERS} |
58 | + ${PRIVATE_HEADERS} |
59 | +) |
60 | + |
61 | +if (COMPIZ_BUILD_TESTING) |
62 | +ADD_SUBDIRECTORY( ${CMAKE_CURRENT_SOURCE_DIR}/tests ) |
63 | +endif (COMPIZ_BUILD_TESTING) |
64 | + |
65 | +SET_TARGET_PROPERTIES( |
66 | + compiz_wall_offset_movement PROPERTIES |
67 | + PUBLIC_HEADER "${PUBLIC_HEADERS}" |
68 | +) |
69 | + |
70 | +TARGET_LINK_LIBRARIES( |
71 | + compiz_wall_offset_movement |
72 | + |
73 | + compiz_core |
74 | + ${GLIBMM_LIBRARIES} |
75 | +) |
76 | |
77 | === added directory 'src/offset_movement/include' |
78 | === added file 'src/offset_movement/include/offset-movement.h' |
79 | --- src/offset_movement/include/offset-movement.h 1970-01-01 00:00:00 +0000 |
80 | +++ src/offset_movement/include/offset-movement.h 2012-04-28 19:08:18 +0000 |
81 | @@ -0,0 +1,41 @@ |
82 | +/** |
83 | + * |
84 | + * Compiz wall plugin |
85 | + * |
86 | + * offset-movement.h |
87 | + * |
88 | + * Copyright (c) 2006 Robert Carr <racarr@beryl-project.org> |
89 | + * |
90 | + * Authors: |
91 | + * Robert Carr <racarr@beryl-project.org> |
92 | + * Dennis Kasprzyk <onestone@opencompositing.org> |
93 | + * |
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. |
98 | + * |
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. |
103 | + * |
104 | + **/ |
105 | + |
106 | +#ifndef _COMPIZ_WALL_OFFSET_MOVEMENT_H |
107 | +#define _COMPIZ_WALL_OFFSET_MOVEMENT_H |
108 | + |
109 | +#include <core/region.h> |
110 | +#include <core/rect.h> |
111 | +#include <core/point.h> |
112 | + |
113 | +namespace compiz |
114 | +{ |
115 | + namespace wall |
116 | + { |
117 | + CompPoint movementWindowOnScreen (const CompRect &serverBorderRect, |
118 | + const CompRegion &screenRegion); |
119 | + } |
120 | +} |
121 | + |
122 | +#endif |
123 | |
124 | === added directory 'src/offset_movement/src' |
125 | === added file 'src/offset_movement/src/offset-movement.cpp' |
126 | --- src/offset_movement/src/offset-movement.cpp 1970-01-01 00:00:00 +0000 |
127 | +++ src/offset_movement/src/offset-movement.cpp 2012-04-28 19:08:18 +0000 |
128 | @@ -0,0 +1,62 @@ |
129 | +/** |
130 | + * |
131 | + * Compiz wall plugin |
132 | + * |
133 | + * offset-movement.c |
134 | + * |
135 | + * Copyright (c) 2006 Robert Carr <racarr@beryl-project.org> |
136 | + * |
137 | + * Authors: |
138 | + * Robert Carr <racarr@beryl-project.org> |
139 | + * Dennis Kasprzyk <onestone@opencompositing.org> |
140 | + * |
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. |
145 | + * |
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. |
150 | + * |
151 | + **/ |
152 | + |
153 | +#include "offset-movement.h" |
154 | + |
155 | +CompPoint |
156 | +compiz::wall::movementWindowOnScreen (const CompRect &serverBorderRect, |
157 | + const CompRegion &screenRegion) |
158 | +{ |
159 | + CompRegion sbrRegion (static_cast <const CompRect &> (serverBorderRect)); |
160 | + |
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; |
168 | + |
169 | + int dx = 0; |
170 | + int dy = 0; |
171 | + |
172 | + for (std::vector <CompRect>::const_iterator it = rem.rects ().begin (); |
173 | + it != rem.rects ().end (); |
174 | + it++) |
175 | + { |
176 | + const CompRect &r = *it; |
177 | + |
178 | + if (r.x1 () >= inter.boundingRect ().x2 ()) |
179 | + dx -= r.width (); |
180 | + else if (r.x2 () <= inter.boundingRect ().x1 ()) |
181 | + dx += r.width (); |
182 | + |
183 | + if (r.y1 () >= inter.boundingRect ().y2 ()) |
184 | + dy -= r.height (); |
185 | + else if (r.y2 () <= inter.boundingRect ().y1 ()) |
186 | + dy += r.height (); |
187 | + } |
188 | + |
189 | + return CompPoint (dx, dy); |
190 | +} |
191 | |
192 | === added directory 'src/offset_movement/tests' |
193 | === added file 'src/offset_movement/tests/CMakeLists.txt' |
194 | --- src/offset_movement/tests/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
195 | +++ src/offset_movement/tests/CMakeLists.txt 2012-04-28 19:08:18 +0000 |
196 | @@ -0,0 +1,58 @@ |
197 | +# Build Google Test and make its headers known |
198 | +find_package (GTest) |
199 | + |
200 | +if (NOT GTEST_FOUND) |
201 | + |
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 |
205 | + CACHE |
206 | + PATH |
207 | + "Path to Google test srcs" |
208 | + ) |
209 | + |
210 | + find_path (GTEST_INCLUDE_DIR gtest/gtest.h) |
211 | + |
212 | + if (GTEST_INCLUDE_DIR) |
213 | + #FIXME - hardcoded is bad! |
214 | + add_subdirectory (${GTEST_ROOT_DIR} |
215 | + gtest) |
216 | + endif(GTEST_INCLUDE_DIR) |
217 | + |
218 | + set (GTEST_BOTH_LIBRARIES gtest gtest_main) |
219 | + set (GTEST_FOUND TRUE) |
220 | + |
221 | +endif (NOT GTEST_FOUND) |
222 | + |
223 | +pkg_check_modules ( |
224 | + COMPIZ |
225 | + REQUIRED |
226 | + glibmm-2.4 glib-2.0 compiz |
227 | +) |
228 | + |
229 | +find_library (GMOCK_LIBRARY gmock) |
230 | +find_library (GMOCK_MAIN_LIBRARY gmock_main) |
231 | + |
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) |
236 | + |
237 | +include_directories (${GTEST_INCLUDE_DIRS}) |
238 | +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) |
239 | +include_directories (${COMPIZ_INCLUDE_DIRS}) |
240 | + |
241 | +link_directories (${COMPIZ_LIBRARY_DIRS}) |
242 | + |
243 | +add_executable (compiz_test_wall_offset_movement |
244 | + ${CMAKE_CURRENT_SOURCE_DIR}/test-wall-offset-movement.cpp) |
245 | + |
246 | +target_link_libraries (compiz_test_wall_offset_movement |
247 | + compiz_wall_offset_movement |
248 | + ${GTEST_BOTH_LIBRARIES} |
249 | + ${GMOCK_LIBRARY} |
250 | + ${GMOCK_MAIN_LIBRARY} |
251 | + ${CMAKE_THREAD_LIBS_INIT} # Link in pthread. |
252 | + ) |
253 | + |
254 | +gtest_add_tests (compiz_test_wall_offset_movement "" ${CMAKE_CURRENT_SOURCE_DIR}/test-wall-offset-movement.cpp) |
255 | |
256 | === added file 'src/offset_movement/tests/test-wall-offset-movement.cpp' |
257 | --- src/offset_movement/tests/test-wall-offset-movement.cpp 1970-01-01 00:00:00 +0000 |
258 | +++ src/offset_movement/tests/test-wall-offset-movement.cpp 2012-04-28 19:08:18 +0000 |
259 | @@ -0,0 +1,97 @@ |
260 | +#include <gtest/gtest.h> |
261 | +#include <gmock/gmock.h> |
262 | + |
263 | +#include "offset-movement.h" |
264 | + |
265 | +class WallOffsetMovementTest : |
266 | + public ::testing::Test |
267 | +{ |
268 | +}; |
269 | + |
270 | +TEST(WallOffsetMovementTest, TestOffsetRight) |
271 | +{ |
272 | + CompRect sbr (750, 0, 500, 500); |
273 | + CompRegion sr (0, 0, 1000, 1000); |
274 | + |
275 | + CompPoint offset = compiz::wall::movementWindowOnScreen (sbr, sr); |
276 | + |
277 | + EXPECT_EQ (offset, CompPoint (-250, 0)); |
278 | +} |
279 | + |
280 | +TEST(WallOffsetMovementTest, TestOffsetLeft) |
281 | +{ |
282 | + CompRect sbr (-250, 0, 500, 500); |
283 | + CompRegion sr (0, 0, 1000, 1000); |
284 | + |
285 | + CompPoint offset = compiz::wall::movementWindowOnScreen (sbr, sr); |
286 | + |
287 | + EXPECT_EQ (offset, CompPoint (250, 0)); |
288 | +} |
289 | + |
290 | +TEST(WallOffsetMovementTest, TestOffsetTop) |
291 | +{ |
292 | + CompRect sbr (0, -250, 500, 500); |
293 | + CompRegion sr (0, 0, 1000, 1000); |
294 | + |
295 | + CompPoint offset = compiz::wall::movementWindowOnScreen (sbr, sr); |
296 | + |
297 | + EXPECT_EQ (offset, CompPoint (0, 250)); |
298 | +} |
299 | + |
300 | +TEST(WallOffsetMovementTest, TestOffsetBottom) |
301 | +{ |
302 | + CompRect sbr (0, 750, 500, 500); |
303 | + CompRegion sr (0, 0, 1000, 1000); |
304 | + |
305 | + CompPoint offset = compiz::wall::movementWindowOnScreen (sbr, sr); |
306 | + |
307 | + EXPECT_EQ (offset, CompPoint (0, -250)); |
308 | +} |
309 | + |
310 | +TEST(WallOffsetMovementTest, TestOffsetRightMMSlice) |
311 | +{ |
312 | + CompRect sbr (750, 0, 500, 500); |
313 | + CompRegion sr (0, 0, 1000, 1000); |
314 | + |
315 | + sr -= CompRegion (400, 0, 200, 0); |
316 | + |
317 | + CompPoint offset = compiz::wall::movementWindowOnScreen (sbr, sr); |
318 | + |
319 | + EXPECT_EQ (offset, CompPoint (-250, 0)); |
320 | +} |
321 | + |
322 | +TEST(WallOffsetMovementTest, TestOffsetLeftMMSlice) |
323 | +{ |
324 | + CompRect sbr (-250, 0, 500, 500); |
325 | + CompRegion sr (0, 0, 1000, 1000); |
326 | + |
327 | + sr -= CompRegion (400, 0, 200, 0); |
328 | + |
329 | + CompPoint offset = compiz::wall::movementWindowOnScreen (sbr, sr); |
330 | + |
331 | + EXPECT_EQ (offset, CompPoint (250, 0)); |
332 | +} |
333 | + |
334 | +TEST(WallOffsetMovementTest, TestOffsetTopMMSlice) |
335 | +{ |
336 | + CompRect sbr (0, -250, 500, 500); |
337 | + CompRegion sr (0, 0, 1000, 1000); |
338 | + |
339 | + sr -= CompRegion (400, 0, 200, 0); |
340 | + |
341 | + CompPoint offset = compiz::wall::movementWindowOnScreen (sbr, sr); |
342 | + |
343 | + EXPECT_EQ (offset, CompPoint (0, 250)); |
344 | +} |
345 | + |
346 | +TEST(WallOffsetMovementTest, TestOffsetBottomMMSlice) |
347 | +{ |
348 | + CompRect sbr (0, 750, 500, 500); |
349 | + CompRegion sr (0, 0, 1000, 1000); |
350 | + |
351 | + sr -= CompRegion (400, 0, 200, 0); |
352 | + |
353 | + CompPoint offset = compiz::wall::movementWindowOnScreen (sbr, sr); |
354 | + |
355 | + EXPECT_EQ (offset, CompPoint (0, -250)); |
356 | +} |
357 | |
358 | === modified file 'src/wall.cpp' |
359 | --- src/wall.cpp 2011-10-11 13:28:07 +0000 |
360 | +++ src/wall.cpp 2012-04-28 19:08:18 +0000 |
361 | @@ -620,50 +620,29 @@ |
362 | XWindowChanges xwc; |
363 | unsigned int mask = 0; |
364 | |
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)) |
369 | + { |
370 | + window->activate (); |
371 | + return; |
372 | + } |
373 | + |
374 | ws->focusDefault = false; |
375 | |
376 | - CompWindow::Geometry sbr (window->serverBorderRect ().x (), |
377 | - window->serverBorderRect ().y (), |
378 | - window->serverBorderRect ().width (), |
379 | - window->serverBorderRect ().height (), |
380 | - 0); |
381 | - CompRegion sbrRegion (sbr); |
382 | - int output = screen->outputDeviceForGeometry (sbr); |
383 | - CompRegion outputRegion (screen->outputDevs ()[output].workArea ()); |
384 | - |
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; |
392 | - |
393 | - foreach (const CompRect &r, rem.rects ()) |
394 | - { |
395 | - if (r.x1 () >= inter.boundingRect ().x2 ()) |
396 | - { |
397 | - xwc.x = window->serverGeometry ().x () - r.width (); |
398 | - mask |= CWX; |
399 | - } |
400 | - else if (r.x2 () <= inter.boundingRect ().x1 ()) |
401 | - { |
402 | - xwc.x = window->serverGeometry ().x () + r.width (); |
403 | - mask |= CWX; |
404 | - } |
405 | - |
406 | - if (r.y1 () >= inter.boundingRect ().y2 ()) |
407 | - { |
408 | - xwc.y = window->serverGeometry ().y () - r.height (); |
409 | - mask |= CWY; |
410 | - } |
411 | - else if (r.y2 () <= inter.boundingRect ().y1 ()) |
412 | - { |
413 | - xwc.y = window->serverGeometry ().y () + r.height (); |
414 | - mask |= CWY; |
415 | - } |
416 | - } |
417 | + CompRegion screenRegion; |
418 | + |
419 | + foreach (const CompOutput &o, screen->outputDevs ()) |
420 | + screenRegion += o.workArea (); |
421 | + |
422 | + CompPoint d = compiz::wall::movementWindowOnScreen (window->serverBorderRect (), |
423 | + screenRegion); |
424 | + |
425 | + mask |= d.x () !=0 ? CWX : 0; |
426 | + mask |= d.y () !=0 ? CWY : 0; |
427 | + |
428 | + xwc.x = window->serverGeometry ().x () + dx; |
429 | + xwc.y = window->serverGeometry ().y () + dy; |
430 | |
431 | window->configureXWindow (mask, &xwc); |
432 | } |
433 | @@ -1515,7 +1494,7 @@ |
434 | |
435 | if (!moving && !showPreview && grabIndex) |
436 | { |
437 | - screen->removeGrab (grabIndex, NULL); |
438 | + screen->removeGrab (static_cast <CompScreen::GrabHandle> (grabIndex), NULL); |
439 | grabIndex = 0; |
440 | } |
441 | |
442 | |
443 | === modified file 'src/wall.h' |
444 | --- src/wall.h 2012-04-24 09:17:57 +0000 |
445 | +++ src/wall.h 2012-04-28 19:08:18 +0000 |
446 | @@ -31,6 +31,8 @@ |
447 | #include <cairo-xlib-xrender.h> |
448 | #include <cairo.h> |
449 | |
450 | +#include "offset-movement.h" |
451 | + |
452 | #include "wall_options.h" |
453 | |
454 |
Deduplicated bugs. This is now bug 755842.