Merge lp:~3v1n0/compiz-grid-plugin/oneiric.fix_891886 into lp:~compiz-team/compiz-grid-plugin/oneiric

Proposed by Marco Trevisan (Treviño)
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: 94
Merged at revision: 96
Proposed branch: lp:~3v1n0/compiz-grid-plugin/oneiric.fix_891886
Merge into: lp:~compiz-team/compiz-grid-plugin/oneiric
Diff against target: 207 lines (+142/-4)
6 files modified
CMakeLists.txt (+2/-0)
src/grabhandler.cpp (+47/-0)
src/grabhandler.h (+31/-0)
src/grid.cpp (+6/-4)
tests/grabhandler/CMakeLists.txt (+9/-0)
tests/grabhandler/test-grid-grab-handler.cpp (+47/-0)
To merge this branch: bzr merge lp:~3v1n0/compiz-grid-plugin/oneiric.fix_891886
Reviewer Review Type Date Requested Status
Sam Spilsbury Approve
Review via email: mp+82794@code.launchpad.net

Description of the change

This branch fixes the issue causing the grid plugin to be fired on window resize introduced by the branch lp:~smspillaz/compiz-grid-plugin/oneiric.fix_750316 .

I've added an extra check to see if we're not resizing, however just using the check

   if (mask & CompWindowGrabMoveMask)

seems to do the trick as well, but I'm not totally sure that this won't interfere with the multitouch issue related to bug #750316, also if using the three-fingers move in my notebook seems to work fine.

So, if anyone can re-test both the fixes...

To post a comment you must log in.
Revision history for this message
Sam Spilsbury (smspillaz) wrote :

Hi Marco,

Can you confirm that the testcase here would be that resizing a window to the corner *wont* show the grid overlay ?

Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Yes, I confirm. The same should happen when resizing a window grabbing the top edge near to the panel.

94. By Marco Trevisan (Treviño)

Merged Sam's branch, which includes a test

Revision history for this message
Sam Spilsbury (smspillaz) wrote :

Approved, works with tests, works with multitouch

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2011-09-29 11:18:56 +0000
3+++ CMakeLists.txt 2011-11-22 00:00:28 +0000
4@@ -5,3 +5,5 @@
5 set (CMAKE_CXX_FLAGS -std=c++0x)
6
7 compiz_plugin(grid PLUGINDEPS composite opengl)
8+
9+add_subdirectory (tests/grabhandler)
10
11=== added file 'src/grabhandler.cpp'
12--- src/grabhandler.cpp 1970-01-01 00:00:00 +0000
13+++ src/grabhandler.cpp 2011-11-22 00:00:28 +0000
14@@ -0,0 +1,47 @@
15+/*
16+ * Compiz Fusion Grid plugin
17+ *
18+ * Copyright (c) 2008 Stephen Kennedy <suasol@gmail.com>
19+ * Copyright (c) 2010 Scott Moreau <oreaus@gmail.com>
20+ *
21+ * This program is free software; you can redistribute it and/or
22+ * modify it under the terms of the GNU General Public License
23+ * as published by the Free Software Foundation; either version 2
24+ * of the License, or (at your option) any later version.
25+ *
26+ * This program is distributed in the hope that it will be useful,
27+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
28+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29+ * GNU General Public License for more details.
30+ *
31+ * Description:
32+ *
33+ * Plugin to act like winsplit revolution (http://www.winsplit-revolution.com/)
34+ * use <Control><Alt>NUMPAD_KEY to move and tile your windows.
35+ *
36+ * Press the tiling keys several times to cycle through some tiling options.
37+ */
38+
39+#include "grabhandler.h"
40+
41+compiz::grid::window::GrabWindowHandler::GrabWindowHandler (unsigned int mask) :
42+ mMask (mask)
43+{
44+}
45+
46+compiz::grid::window::GrabWindowHandler::~GrabWindowHandler ()
47+{
48+}
49+
50+bool
51+compiz::grid::window::GrabWindowHandler::track ()
52+{
53+ return ((mMask & (CompWindowGrabMoveMask | CompWindowGrabButtonMask)) &&
54+ !(mMask & CompWindowGrabResizeMask));
55+}
56+
57+bool
58+compiz::grid::window::GrabWindowHandler::resetResize ()
59+{
60+ return (mMask & CompWindowGrabResizeMask);
61+}
62
63=== added file 'src/grabhandler.h'
64--- src/grabhandler.h 1970-01-01 00:00:00 +0000
65+++ src/grabhandler.h 2011-11-22 00:00:28 +0000
66@@ -0,0 +1,31 @@
67+#define CompWindowGrabKeyMask (1 << 0)
68+#define CompWindowGrabButtonMask (1 << 1)
69+#define CompWindowGrabMoveMask (1 << 2)
70+#define CompWindowGrabResizeMask (1 << 3)
71+#define CompWindowGrabExternalAppMask (1 << 4)
72+
73+namespace compiz
74+{
75+namespace grid
76+{
77+namespace window
78+{
79+
80+class GrabWindowHandler
81+{
82+ public:
83+
84+ GrabWindowHandler (unsigned int mask);
85+ ~GrabWindowHandler ();
86+
87+ bool track ();
88+ bool resetResize ();
89+
90+ private:
91+
92+ unsigned int mMask;
93+
94+};
95+}
96+}
97+}
98
99=== modified file 'src/grid.cpp'
100--- src/grid.cpp 2011-10-05 17:41:22 +0000
101+++ src/grid.cpp 2011-11-22 00:00:28 +0000
102@@ -23,6 +23,7 @@
103 */
104
105 #include "grid.h"
106+#include "grabhandler.h"
107
108 using namespace GridWindowType;
109
110@@ -766,7 +767,9 @@
111 unsigned int state,
112 unsigned int mask)
113 {
114- if (mask & (CompWindowGrabMoveMask | CompWindowGrabButtonMask))
115+ compiz::grid::window::GrabWindowHandler gwHandler (mask);
116+
117+ if (gwHandler.track ())
118 {
119 gScreen->o[0].value ().set ((int) window->id ());
120
121@@ -780,8 +783,7 @@
122 originalSize = gScreen->slotToRect(window,
123 window->serverBorderRect ());
124 }
125-
126- if (mask & CompWindowGrabResizeMask)
127+ else if (gwHandler.resetResize ())
128 {
129 isGridResized = false;
130 resizeCount = 0;
131@@ -1018,7 +1020,7 @@
132 gridProps[GridRight] = GridProps {1,0, 2,1};
133 gridProps[GridTopLeft] = GridProps{0,0, 2,2};
134 gridProps[GridTop] = GridProps {0,0, 1,2};
135- gridProps[GridTopRight] = GridProps {0,0, 1,2};
136+ gridProps[GridTopRight] = GridProps {1,0, 2,2};
137 gridProps[GridMaximize] = GridProps {0,0, 1,1};
138
139 animations.clear ();
140
141=== added directory 'tests'
142=== added directory 'tests/grabhandler'
143=== added file 'tests/grabhandler/CMakeLists.txt'
144--- tests/grabhandler/CMakeLists.txt 1970-01-01 00:00:00 +0000
145+++ tests/grabhandler/CMakeLists.txt 2011-11-22 00:00:28 +0000
146@@ -0,0 +1,9 @@
147+include_directories (${compiz_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/src)
148+
149+add_executable (test-grid-grab-handler
150+ test-grid-grab-handler.cpp
151+ ../../src/grabhandler.cpp)
152+
153+target_link_libraries (test-grid-grab-handler pthread dl)
154+
155+add_test (test-grid-grab-handler-test test-grid-grab-handler)
156
157=== added file 'tests/grabhandler/test-grid-grab-handler.cpp'
158--- tests/grabhandler/test-grid-grab-handler.cpp 1970-01-01 00:00:00 +0000
159+++ tests/grabhandler/test-grid-grab-handler.cpp 2011-11-22 00:00:28 +0000
160@@ -0,0 +1,47 @@
161+#include <stdlib.h>
162+#include <iostream>
163+#include <string>
164+#include <grabhandler.h>
165+
166+/* FIXME: Not entirely portable, but we can't
167+ * include window.h without pulling in bunch of
168+ * static initalizers */
169+
170+#define CompWindowGrabKeyMask (1 << 0)
171+#define CompWindowGrabButtonMask (1 << 1)
172+#define CompWindowGrabMoveMask (1 << 2)
173+#define CompWindowGrabResizeMask (1 << 3)
174+#define CompWindowGrabExternalAppMask (1 << 4)
175+
176+void pass (const std::string &message)
177+{
178+ std::cout << "PASS: " << message << std::endl;
179+}
180+
181+void fail (const std::string &message)
182+{
183+ std::cout << "FAIL: " << message << std::endl;
184+ exit (1);
185+}
186+
187+int main (void)
188+{
189+ compiz::grid::window::GrabWindowHandler moveHandler (CompWindowGrabMoveMask |
190+ CompWindowGrabButtonMask);
191+ compiz::grid::window::GrabWindowHandler resizeHandler (CompWindowGrabButtonMask |
192+ CompWindowGrabResizeMask);
193+
194+ std::cout << "TEST: compiz::grid::window::GrabHandler" << std::endl;
195+
196+ if (moveHandler.track () && !moveHandler.resetResize ())
197+ pass ("compiz::grid::window::GrabHandler CompWindowGrabMoveMask | CompWindowGrabButtonMask");
198+ else
199+ fail ("compiz::grid::window::GrabHandler CompWindowGrabMoveMask | CompWindowGrabButtonMask");
200+
201+ if (!resizeHandler.track () && resizeHandler.resetResize ())
202+ pass ("compiz::grid::window::GrabHandler CompWindowGrabResizeMask | CompWindowGrabButtonMask");
203+ else
204+ fail ("compiz::grid::window::GrabHandler CompWindowGrabResizeMask | CompWindowGrabButtonMask");
205+
206+ return 0;
207+}

Subscribers

People subscribed via source and target branches