Merge lp:~smspillaz/compiz-wall-plugin/compiz-wall-plugin.fix_939228 into lp:compiz-wall-plugin

Proposed by Sam Spilsbury
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
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.

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.

To post a comment you must log in.
Revision history for this message
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Deduplicated bugs. This is now bug 755842.

Revision history for this message
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

Linking CXX executable compiz_test_wall_offset_movement
/usr/bin/ld: cannot find -lcompiz_core
collect2: ld returned 1 exit status
make[2]: *** [src/offset_movement/tests/compiz_test_wall_offset_movement] Error 1
make[1]: *** [src/offset_movement/tests/CMakeFiles/compiz_test_wall_offset_movement.dir/all] Error 2
make: *** [all] Error 2

review: Needs Fixing
Revision history for this message
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_CURRENT_SOURCE_DIR}/include
  ${CMAKE_CURRENT_SOURCE_DIR}/src

  ${CMAKE_SOURCE_DIR}/include

  ${Boost_INCLUDE_DIRS}

  ${GLIBMM_INCLUDE_DIRS}
)

LINK_DIRECTORIES (${GLIBMM_LIBRARY_DIRS})

^ 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_MAKEFILE is turned on ?

Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Looks OK and seems to work.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2012-04-24 08:39:54 +0000
+++ CMakeLists.txt 2012-04-28 19:08:18 +0000
@@ -2,4 +2,7 @@
22
3include (CompizPlugin)3include (CompizPlugin)
44
5compiz_plugin (wall PLUGINDEPS composite opengl mousepoll PKGDEPS cairo cairo-xlib-xrender LIBRARIES dl)5add_subdirectory (src/offset_movement)
6include_directories (src/offset_movement/include)
7
8compiz_plugin (wall PLUGINDEPS composite opengl mousepoll PKGDEPS cairo cairo-xlib-xrender LIBRARIES compiz_wall_offset_movement dl)
69
=== added directory 'src/offset_movement'
=== added file 'src/offset_movement/CMakeLists.txt'
--- src/offset_movement/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ src/offset_movement/CMakeLists.txt 2012-04-28 19:08:18 +0000
@@ -0,0 +1,57 @@
1pkg_check_modules (
2 GLIBMM
3 REQUIRED
4 glibmm-2.4 glib-2.0 compiz
5)
6
7INCLUDE_DIRECTORIES (
8 ${CMAKE_CURRENT_SOURCE_DIR}/include
9 ${CMAKE_CURRENT_SOURCE_DIR}/src
10
11 ${CMAKE_SOURCE_DIR}/include
12
13 ${Boost_INCLUDE_DIRS}
14
15 ${GLIBMM_INCLUDE_DIRS}
16)
17
18LINK_DIRECTORIES (${GLIBMM_LIBRARY_DIRS})
19
20SET (
21 PUBLIC_HEADERS
22)
23
24SET (
25 PRIVATE_HEADERS
26 ${CMAKE_CURRENT_SOURCE_DIR}/include/offset-movement.h
27)
28
29SET(
30 SRCS
31 ${CMAKE_CURRENT_SOURCE_DIR}/src/offset-movement.cpp
32)
33
34ADD_LIBRARY(
35 compiz_wall_offset_movement STATIC
36
37 ${SRCS}
38
39 ${PUBLIC_HEADERS}
40 ${PRIVATE_HEADERS}
41)
42
43if (COMPIZ_BUILD_TESTING)
44ADD_SUBDIRECTORY( ${CMAKE_CURRENT_SOURCE_DIR}/tests )
45endif (COMPIZ_BUILD_TESTING)
46
47SET_TARGET_PROPERTIES(
48 compiz_wall_offset_movement PROPERTIES
49 PUBLIC_HEADER "${PUBLIC_HEADERS}"
50)
51
52TARGET_LINK_LIBRARIES(
53 compiz_wall_offset_movement
54
55 compiz_core
56 ${GLIBMM_LIBRARIES}
57)
058
=== added directory 'src/offset_movement/include'
=== added file 'src/offset_movement/include/offset-movement.h'
--- src/offset_movement/include/offset-movement.h 1970-01-01 00:00:00 +0000
+++ src/offset_movement/include/offset-movement.h 2012-04-28 19:08:18 +0000
@@ -0,0 +1,41 @@
1/**
2 *
3 * Compiz wall plugin
4 *
5 * offset-movement.h
6 *
7 * Copyright (c) 2006 Robert Carr <racarr@beryl-project.org>
8 *
9 * Authors:
10 * Robert Carr <racarr@beryl-project.org>
11 * Dennis Kasprzyk <onestone@opencompositing.org>
12 *
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.
17 *
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.
22 *
23 **/
24
25#ifndef _COMPIZ_WALL_OFFSET_MOVEMENT_H
26#define _COMPIZ_WALL_OFFSET_MOVEMENT_H
27
28#include <core/region.h>
29#include <core/rect.h>
30#include <core/point.h>
31
32namespace compiz
33{
34 namespace wall
35 {
36 CompPoint movementWindowOnScreen (const CompRect &serverBorderRect,
37 const CompRegion &screenRegion);
38 }
39}
40
41#endif
042
=== added directory 'src/offset_movement/src'
=== added file 'src/offset_movement/src/offset-movement.cpp'
--- src/offset_movement/src/offset-movement.cpp 1970-01-01 00:00:00 +0000
+++ src/offset_movement/src/offset-movement.cpp 2012-04-28 19:08:18 +0000
@@ -0,0 +1,62 @@
1/**
2 *
3 * Compiz wall plugin
4 *
5 * offset-movement.c
6 *
7 * Copyright (c) 2006 Robert Carr <racarr@beryl-project.org>
8 *
9 * Authors:
10 * Robert Carr <racarr@beryl-project.org>
11 * Dennis Kasprzyk <onestone@opencompositing.org>
12 *
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.
17 *
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.
22 *
23 **/
24
25#include "offset-movement.h"
26
27CompPoint
28compiz::wall::movementWindowOnScreen (const CompRect &serverBorderRect,
29 const CompRegion &screenRegion)
30{
31 CompRegion sbrRegion (static_cast <const CompRect &> (serverBorderRect));
32
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;
40
41 int dx = 0;
42 int dy = 0;
43
44 for (std::vector <CompRect>::const_iterator it = rem.rects ().begin ();
45 it != rem.rects ().end ();
46 it++)
47 {
48 const CompRect &r = *it;
49
50 if (r.x1 () >= inter.boundingRect ().x2 ())
51 dx -= r.width ();
52 else if (r.x2 () <= inter.boundingRect ().x1 ())
53 dx += r.width ();
54
55 if (r.y1 () >= inter.boundingRect ().y2 ())
56 dy -= r.height ();
57 else if (r.y2 () <= inter.boundingRect ().y1 ())
58 dy += r.height ();
59 }
60
61 return CompPoint (dx, dy);
62}
063
=== added directory 'src/offset_movement/tests'
=== added file 'src/offset_movement/tests/CMakeLists.txt'
--- src/offset_movement/tests/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ src/offset_movement/tests/CMakeLists.txt 2012-04-28 19:08:18 +0000
@@ -0,0 +1,58 @@
1# Build Google Test and make its headers known
2find_package (GTest)
3
4if (NOT GTEST_FOUND)
5
6 # Check for google test and build it locally
7 set (GTEST_ROOT_DIR
8 "/usr/src/gtest" # Default value, adjustable by user with e.g., ccmake
9 CACHE
10 PATH
11 "Path to Google test srcs"
12 )
13
14 find_path (GTEST_INCLUDE_DIR gtest/gtest.h)
15
16 if (GTEST_INCLUDE_DIR)
17 #FIXME - hardcoded is bad!
18 add_subdirectory (${GTEST_ROOT_DIR}
19 gtest)
20 endif(GTEST_INCLUDE_DIR)
21
22 set (GTEST_BOTH_LIBRARIES gtest gtest_main)
23 set (GTEST_FOUND TRUE)
24
25endif (NOT GTEST_FOUND)
26
27pkg_check_modules (
28 COMPIZ
29 REQUIRED
30 glibmm-2.4 glib-2.0 compiz
31)
32
33find_library (GMOCK_LIBRARY gmock)
34find_library (GMOCK_MAIN_LIBRARY gmock_main)
35
36if (NOT GMOCK_LIBRARY OR NOT GMOCK_MAIN_LIBRARY OR NOT GTEST_FOUND)
37 message ("Google Mock and Google Test not found - cannot build tests!")
38 set (COMPIZ_BUILD_TESTING OFF)
39endif (NOT GMOCK_LIBRARY OR NOT GMOCK_MAIN_LIBRARY OR NOT GTEST_FOUND)
40
41include_directories (${GTEST_INCLUDE_DIRS})
42include_directories(${CMAKE_CURRENT_SOURCE_DIR})
43include_directories (${COMPIZ_INCLUDE_DIRS})
44
45link_directories (${COMPIZ_LIBRARY_DIRS})
46
47add_executable (compiz_test_wall_offset_movement
48 ${CMAKE_CURRENT_SOURCE_DIR}/test-wall-offset-movement.cpp)
49
50target_link_libraries (compiz_test_wall_offset_movement
51 compiz_wall_offset_movement
52 ${GTEST_BOTH_LIBRARIES}
53 ${GMOCK_LIBRARY}
54 ${GMOCK_MAIN_LIBRARY}
55 ${CMAKE_THREAD_LIBS_INIT} # Link in pthread.
56 )
57
58gtest_add_tests (compiz_test_wall_offset_movement "" ${CMAKE_CURRENT_SOURCE_DIR}/test-wall-offset-movement.cpp)
059
=== added file 'src/offset_movement/tests/test-wall-offset-movement.cpp'
--- src/offset_movement/tests/test-wall-offset-movement.cpp 1970-01-01 00:00:00 +0000
+++ src/offset_movement/tests/test-wall-offset-movement.cpp 2012-04-28 19:08:18 +0000
@@ -0,0 +1,97 @@
1#include <gtest/gtest.h>
2#include <gmock/gmock.h>
3
4#include "offset-movement.h"
5
6class WallOffsetMovementTest :
7 public ::testing::Test
8{
9};
10
11TEST(WallOffsetMovementTest, TestOffsetRight)
12{
13 CompRect sbr (750, 0, 500, 500);
14 CompRegion sr (0, 0, 1000, 1000);
15
16 CompPoint offset = compiz::wall::movementWindowOnScreen (sbr, sr);
17
18 EXPECT_EQ (offset, CompPoint (-250, 0));
19}
20
21TEST(WallOffsetMovementTest, TestOffsetLeft)
22{
23 CompRect sbr (-250, 0, 500, 500);
24 CompRegion sr (0, 0, 1000, 1000);
25
26 CompPoint offset = compiz::wall::movementWindowOnScreen (sbr, sr);
27
28 EXPECT_EQ (offset, CompPoint (250, 0));
29}
30
31TEST(WallOffsetMovementTest, TestOffsetTop)
32{
33 CompRect sbr (0, -250, 500, 500);
34 CompRegion sr (0, 0, 1000, 1000);
35
36 CompPoint offset = compiz::wall::movementWindowOnScreen (sbr, sr);
37
38 EXPECT_EQ (offset, CompPoint (0, 250));
39}
40
41TEST(WallOffsetMovementTest, TestOffsetBottom)
42{
43 CompRect sbr (0, 750, 500, 500);
44 CompRegion sr (0, 0, 1000, 1000);
45
46 CompPoint offset = compiz::wall::movementWindowOnScreen (sbr, sr);
47
48 EXPECT_EQ (offset, CompPoint (0, -250));
49}
50
51TEST(WallOffsetMovementTest, TestOffsetRightMMSlice)
52{
53 CompRect sbr (750, 0, 500, 500);
54 CompRegion sr (0, 0, 1000, 1000);
55
56 sr -= CompRegion (400, 0, 200, 0);
57
58 CompPoint offset = compiz::wall::movementWindowOnScreen (sbr, sr);
59
60 EXPECT_EQ (offset, CompPoint (-250, 0));
61}
62
63TEST(WallOffsetMovementTest, TestOffsetLeftMMSlice)
64{
65 CompRect sbr (-250, 0, 500, 500);
66 CompRegion sr (0, 0, 1000, 1000);
67
68 sr -= CompRegion (400, 0, 200, 0);
69
70 CompPoint offset = compiz::wall::movementWindowOnScreen (sbr, sr);
71
72 EXPECT_EQ (offset, CompPoint (250, 0));
73}
74
75TEST(WallOffsetMovementTest, TestOffsetTopMMSlice)
76{
77 CompRect sbr (0, -250, 500, 500);
78 CompRegion sr (0, 0, 1000, 1000);
79
80 sr -= CompRegion (400, 0, 200, 0);
81
82 CompPoint offset = compiz::wall::movementWindowOnScreen (sbr, sr);
83
84 EXPECT_EQ (offset, CompPoint (0, 250));
85}
86
87TEST(WallOffsetMovementTest, TestOffsetBottomMMSlice)
88{
89 CompRect sbr (0, 750, 500, 500);
90 CompRegion sr (0, 0, 1000, 1000);
91
92 sr -= CompRegion (400, 0, 200, 0);
93
94 CompPoint offset = compiz::wall::movementWindowOnScreen (sbr, sr);
95
96 EXPECT_EQ (offset, CompPoint (0, -250));
97}
098
=== modified file 'src/wall.cpp'
--- src/wall.cpp 2011-10-11 13:28:07 +0000
+++ src/wall.cpp 2012-04-28 19:08:18 +0000
@@ -620,50 +620,29 @@
620 XWindowChanges xwc;620 XWindowChanges xwc;
621 unsigned int mask = 0;621 unsigned int mask = 0;
622622
623 ws->moveViewport (-dx, -dy, false);623 /* If changing viewports fails we should not
624 * move the client window */
625 if (!ws->moveViewport (-dx, -dy, false))
626 {
627 window->activate ();
628 return;
629 }
630
624 ws->focusDefault = false;631 ws->focusDefault = false;
625632
626 CompWindow::Geometry sbr (window->serverBorderRect ().x (),633 CompRegion screenRegion;
627 window->serverBorderRect ().y (),634
628 window->serverBorderRect ().width (),635 foreach (const CompOutput &o, screen->outputDevs ())
629 window->serverBorderRect ().height (),636 screenRegion += o.workArea ();
630 0);637
631 CompRegion sbrRegion (sbr);638 CompPoint d = compiz::wall::movementWindowOnScreen (window->serverBorderRect (),
632 int output = screen->outputDeviceForGeometry (sbr);639 screenRegion);
633 CompRegion outputRegion (screen->outputDevs ()[output].workArea ());640
634641 mask |= d.x () !=0 ? CWX : 0;
635 /* If the window would be partially offscreen642 mask |= d.y () !=0 ? CWY : 0;
636 * after it was moved then we should move it back643
637 * so that it is completely onscreen, since we moved644 xwc.x = window->serverGeometry ().x () + dx;
638 * from mostly offscreen on B to mostly onscreen on A,645 xwc.y = window->serverGeometry ().y () + dy;
639 * the user should be able to see their selected window */
640 CompRegion inter = sbrRegion.intersected (outputRegion);
641 CompRegion rem = sbrRegion - outputRegion;
642
643 foreach (const CompRect &r, rem.rects ())
644 {
645 if (r.x1 () >= inter.boundingRect ().x2 ())
646 {
647 xwc.x = window->serverGeometry ().x () - r.width ();
648 mask |= CWX;
649 }
650 else if (r.x2 () <= inter.boundingRect ().x1 ())
651 {
652 xwc.x = window->serverGeometry ().x () + r.width ();
653 mask |= CWX;
654 }
655
656 if (r.y1 () >= inter.boundingRect ().y2 ())
657 {
658 xwc.y = window->serverGeometry ().y () - r.height ();
659 mask |= CWY;
660 }
661 else if (r.y2 () <= inter.boundingRect ().y1 ())
662 {
663 xwc.y = window->serverGeometry ().y () + r.height ();
664 mask |= CWY;
665 }
666 }
667646
668 window->configureXWindow (mask, &xwc);647 window->configureXWindow (mask, &xwc);
669 }648 }
@@ -1515,7 +1494,7 @@
15151494
1516 if (!moving && !showPreview && grabIndex)1495 if (!moving && !showPreview && grabIndex)
1517 {1496 {
1518 screen->removeGrab (grabIndex, NULL);1497 screen->removeGrab (static_cast <CompScreen::GrabHandle> (grabIndex), NULL);
1519 grabIndex = 0;1498 grabIndex = 0;
1520 }1499 }
15211500
15221501
=== modified file 'src/wall.h'
--- src/wall.h 2012-04-24 09:17:57 +0000
+++ src/wall.h 2012-04-28 19:08:18 +0000
@@ -31,6 +31,8 @@
31#include <cairo-xlib-xrender.h>31#include <cairo-xlib-xrender.h>
32#include <cairo.h>32#include <cairo.h>
3333
34#include "offset-movement.h"
35
34#include "wall_options.h"36#include "wall_options.h"
3537
3638

Subscribers

People subscribed via source and target branches