Merge lp:~compiz-team/compiz/compiz.fix_1053280 into lp:compiz/0.9.8

Proposed by Sam Spilsbury
Status: Superseded
Proposed branch: lp:~compiz-team/compiz/compiz.fix_1053280
Merge into: lp:compiz/0.9.8
Diff against target: 1115 lines (+859/-69)
10 files modified
include/core/action.h (+12/-1)
include/core/option.h (+4/-2)
src/action.cpp (+24/-0)
src/event.cpp (+149/-62)
src/eventmanagement.h (+80/-0)
src/option.cpp (+18/-0)
src/option/tests/option.cpp (+31/-0)
src/privateaction.h (+25/-1)
src/privatescreen/tests/test-privatescreen.cpp (+513/-1)
src/screen.cpp (+3/-2)
To merge this branch: bzr merge lp:~compiz-team/compiz/compiz.fix_1053280
Reviewer Review Type Date Requested Status
Daniel van Vugt Needs Resubmitting
jenkins (community) continuous-integration Approve
Sam Spilsbury Needs Resubmitting
Review via email: mp+125984@code.launchpad.net

This proposal supersedes a proposal from 2012-09-22.

This proposal has been superseded by a proposal from 2012-09-28.

Description of the change

Don't trigger actions unless they are actually marked active. It is possible that we may have a passive button grab for other reasons than actions being bound, so actions which haven't been added should be ignored.

Tests added for refactored code:

 Start 107: privatescreen_ButtonPressEdgeEventManagementTest.IgnoreWhenEventAndRootWindowMismatch
107/548 Test #107: privatescreen_ButtonPressEdgeEventManagementTest.IgnoreWhenEventAndRootWindowMismatch ....................................................................... Passed 0.01 sec
        Start 108: privatescreen_ButtonPressEdgeEventManagementTest.IgnoreWhenEventMismatchAndNoGrabs
108/548 Test #108: privatescreen_ButtonPressEdgeEventManagementTest.IgnoreWhenEventMismatchAndNoGrabs .......................................................................... Passed 0.01 sec
        Start 109: privatescreen_ButtonPressEdgeEventManagementTest.AllowWhenEventButNotRootWindowMismatchWhileGrabbed
109/548 Test #109: privatescreen_ButtonPressEdgeEventManagementTest.AllowWhenEventButNotRootWindowMismatchWhileGrabbed ......................................................... Passed 0.01 sec
        Start 110: privatescreen_ButtonPressEdgeEventManagementTest.NoTriggerOnInvalidEdge
110/548 Test #110: privatescreen_ButtonPressEdgeEventManagementTest.NoTriggerOnInvalidEdge ..................................................................................... Passed 0.01 sec
        Start 111: privatescreen_ButtonPressEdgeEventManagementTest.NoTriggerOnUnboundAction
111/548 Test #111: privatescreen_ButtonPressEdgeEventManagementTest.NoTriggerOnUnboundAction ................................................................................... Passed 0.01 sec
        Start 112: privatescreen_ButtonPressEdgeEventManagementTest.NoTriggerOnMismatchedEdgeMask
112/548 Test #112: privatescreen_ButtonPressEdgeEventManagementTest.NoTriggerOnMismatchedEdgeMask .............................................................................. Passed 0.01 sec
        Start 113: privatescreen_ButtonPressEdgeEventManagementTest.NoTriggerOnMismatchedButtonNumber
113/548 Test #113: privatescreen_ButtonPressEdgeEventManagementTest.NoTriggerOnMismatchedButtonNumber .......................................................................... Passed 0.01 sec
        Start 114: privatescreen_ButtonPressEdgeEventManagementTest.NoTriggerOnMismatchedButtonState
114/548 Test #114: privatescreen_ButtonPressEdgeEventManagementTest.NoTriggerOnMismatchedButtonState ........................................................................... Passed 0.01 sec
        Start 115: privatescreen_ButtonPressEdgeEventManagementTest.TriggerWhenStateButtonAndEdgeMaskMatch
115/548 Test #115: privatescreen_ButtonPressEdgeEventManagementTest.TriggerWhenStateButtonAndEdgeMaskMatch ..................................................................... Passed 0.01 sec
        Start 116: privatescreen_ButtonPressEventManagementTest.SetEventWindowArgument
116/548 Test #116: privatescreen_ButtonPressEventManagementTest.SetEventWindowArgument ......................................................................................... Passed 0.01 sec
        Start 117: privatescreen_ButtonPressEventManagementTest.NoTriggerOnUnboundAction
117/548 Test #117: privatescreen_ButtonPressEventManagementTest.NoTriggerOnUnboundAction ....................................................................................... Passed 0.01 sec
        Start 118: privatescreen_ButtonPressEventManagementTest.NoTriggerOnUnboundInactiveAction
118/548 Test #118: privatescreen_ButtonPressEventManagementTest.NoTriggerOnUnboundInactiveAction ............................................................................... Passed 0.01 sec
        Start 119: privatescreen_ButtonPressEventManagementTest.NoTriggerOnMismatchedButtonNumber
119/548 Test #119: privatescreen_ButtonPressEventManagementTest.NoTriggerOnMismatchedButtonNumber .............................................................................. Passed 0.01 sec
        Start 120: privatescreen_ButtonPressEventManagementTest.NoTriggerOnMismatchedButtonState
120/548 Test #120: privatescreen_ButtonPressEventManagementTest.NoTriggerOnMismatchedButtonState ............................................................................... Passed 0.01 sec
        Start 121: privatescreen_ButtonPressEventManagementTest.TriggerWhenStateAndButtonMatch
121/548 Test #121: privatescreen_ButtonPressEventManagementTest.TriggerWhenStateAndButtonMatch ................................................................................. Passed 0.01 sec

To post a comment you must log in.
Revision history for this message
jenkins (martin-mrazik+qa) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Martin Mrazik (mrazik) wrote : Posted in a previous version of this proposal

This is the jenkins error:
[ 14%] Building CXX object src/CMakeFiles/compiz_core.dir/event.cpp.o
cd /tmp/buildd/compiz-0.9.8.2+bzr3377/obj-x86_64-linux-gnu/src && /usr/lib/ccache/c++ -Dcompiz_core_EXPORTS -DHAVE_SCANDIR_POSIX -DHAVE_SCANDIR_POSIX -DHAVE_SCANDIR_POSIX -DHAVE_CONFIG_H -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -fPIC -Wall -Wl,-zdefs -Wno-deprecated-declarations -Werror -fPIC -Wall -Wl,-zdefs -Wno-deprecated-declarations -Werror -fPIC -Wall -Wl,-zdefs -Wno-deprecated-declarations -Werror -O2 -g -fPIC -I/tmp/buildd/compiz-0.9.8.2+bzr3377/include -I/tmp/buildd/compiz-0.9.8.2+bzr3377/obj-x86_64-linux-gnu -I/tmp/buildd/compiz-0.9.8.2+bzr3377/obj-x86_64-linux-gnu/generated -I/usr/include/libxml2 -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/glibmm-2.4 -I/usr/lib/x86_64-linux-gnu/glibmm-2.4/include -I/usr/include/sigc++-2.0 -I/usr/lib/x86_64-linux-gnu/sigc++-2.0/include -I/usr/include/startup-notification-1.0 -I/include -I/tmp/buildd/compiz-0.9.8.2+bzr3377/src -I/tmp/buildd/compiz-0.9.8.2+bzr3377/src/string/include -I/tmp/buildd/compiz-0.9.8.2+bzr3377/src/string/src -I/tmp/buildd/compiz-0.9.8.2+bzr3377/src/logmessage/include -I/tmp/buildd/compiz-0.9.8.2+bzr3377/src/logmessage/src -I/tmp/buildd/compiz-0.9.8.2+bzr3377/src/timer/include -I/tmp/buildd/compiz-0.9.8.2+bzr3377/src/timer/src -I/tmp/buildd/compiz-0.9.8.2+bzr3377/src/pluginclasshandler/include -I/tmp/buildd/compiz-0.9.8.2+bzr3377/src/pluginclasshandler/src -I/tmp/buildd/compiz-0.9.8.2+bzr3377/src/point/include -I/tmp/buildd/compiz-0.9.8.2+bzr3377/src/point/src -I/tmp/buildd/compiz-0.9.8.2+bzr3377/src/rect/include -I/tmp/buildd/compiz-0.9.8.2+bzr3377/src/rect/src -I/tmp/buildd/compiz-0.9.8.2+bzr3377/src/servergrab/include -I/tmp/buildd/compiz-0.9.8.2+bzr3377/src/servergrab/src -I/tmp/buildd/compiz-0.9.8.2+bzr3377/src/region/include -I/tmp/buildd/compiz-0.9.8.2+bzr3377/src/region/src -I/tmp/buildd/compiz-0.9.8.2+bzr3377/src/window/geometry/include -I/tmp/buildd/compiz-0.9.8.2+bzr3377/src/window/geometry/src -I/tmp/buildd/compiz-0.9.8.2+bzr3377/src/window/geometry-saver/include -I/tmp/buildd/compiz-0.9.8.2+bzr3377/src/window/geometry-saver/src -I/tmp/buildd/compiz-0.9.8.2+bzr3377/src/window/extents/include -I/tmp/buildd/compiz-0.9.8.2+bzr3377/src/window/extents/src -I/tmp/buildd/compiz-0.9.8.2+bzr3377/src/window/constrainment/include -I/tmp/buildd/compiz-0.9.8.2+bzr3377/src/window/constrainment/src -DPLUGINDIR=\"/usr/lib/compiz\" -DSHAREDIR=\"/usr/share/compiz/\" -DMETADATADIR=\"/usr/share/compiz\" -o CMakeFiles/compiz_core.dir/event.cpp.o -c /tmp/buildd/compiz-0.9.8.2+bzr3377/src/event.cpp
/tmp/buildd/compiz-0.9.8.2+bzr3377/src/event.cpp:44:29: fatal error: eventmanagement.h: No such file or directory
compilation terminated.
make[3]: *** [src/CMakeFiles/compiz_core.dir/event.cpp.o] Error 1
make[3]: Leaving directory `/tmp/buildd/compiz-0.9.8.2+bzr3377/obj-x86_64-linux-gnu'

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

What's the real bug ID? I don't think it's bug 1053820.

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

And after that, please set to Resubmit. I think this is too large and dangerous to squeeze in 0.9.8.

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

Resubmit per the prereq branch.

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

Sorry, that comment doesn't belong here. Please fix as requested above.

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

Confirmed the same build failure as jenkins:
/home/dan/bzr/compiz/tmp.142/src/event.cpp:44:29: fatal error: eventmanagement.h: No such file or directory

Please also correct the bug links and branch name. Then leave it in progress or Resubmit state.

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

Resubmitted with typo fixed and file added (sorry about that). Marking resubmit for now as requested, as this bug is no longer high priority.

review: Needs Resubmitting
Revision history for this message
jenkins (martin-mrazik+qa) wrote :
review: Approve (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

Resubmit... just so I don't keep forgetting and looking at this again.

review: Needs Resubmitting
3394. By Sam Spilsbury

Merge lp:compiz and handle some BCI stuff

3395. By Sam Spilsbury

Constify the API a bit

3396. By Sam Spilsbury

Cleanup.

Unindent namespaces, simplify interface, add namespace alias where
appropriate.

3397. By Sam Spilsbury

Forward declare correctly

3398. By Sam Spilsbury

Merge lp:compiz

3399. By Daniel van Vugt

Fix build error/warning: Remove unused function.

Unmerged revisions

3399. By Daniel van Vugt

Fix build error/warning: Remove unused function.

3398. By Sam Spilsbury

Merge lp:compiz

3397. By Sam Spilsbury

Forward declare correctly

3396. By Sam Spilsbury

Cleanup.

Unindent namespaces, simplify interface, add namespace alias where
appropriate.

3395. By Sam Spilsbury

Constify the API a bit

3394. By Sam Spilsbury

Merge lp:compiz and handle some BCI stuff

3393. By Sam Spilsbury

Move check to the right place

3392. By Sam Spilsbury

Merge lp:compiz

3391. By Sam Spilsbury

Add missing file

3390. By Sam Spilsbury

Don't trigger actions unless they're actually added

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'include/core/action.h'
2--- include/core/action.h 2012-09-07 22:37:20 +0000
3+++ include/core/action.h 2012-09-24 11:41:41 +0000
4@@ -34,6 +34,14 @@
5
6 #include <X11/Xlib-xcb.h>
7
8+namespace compiz
9+{
10+ namespace actions
11+ {
12+ void setActionActiveState (const CompAction &action,
13+ bool active);
14+ }
15+}
16
17 class PrivateAction;
18
19@@ -171,7 +179,10 @@
20
21 bool active ();
22
23- friend class CompScreenImpl;
24+ /* BCI: Not optimal, CompAction should implement
25+ * BoundAction instead or be a PV class */
26+ friend void compiz::actions::setActionActiveState (const CompAction &action,
27+ bool active);
28
29 private:
30 PrivateAction *priv;
31
32=== modified file 'include/core/option.h'
33--- include/core/option.h 2012-05-30 09:24:15 +0000
34+++ include/core/option.h 2012-09-24 11:41:41 +0000
35@@ -244,8 +244,10 @@
36
37 CompString name ();
38
39- Type type ();
40- Value & value ();
41+ Type type () const;
42+ Type type (); // BCI: drop this in 0.9.9
43+ Value & value () const;
44+ Value & value (); // BCI: drop this in 0.9.9
45 Restriction & rest ();
46
47 bool set (Value &val);
48
49=== modified file 'src/action.cpp'
50--- src/action.cpp 2012-05-10 12:58:01 +0000
51+++ src/action.cpp 2012-09-24 11:41:41 +0000
52@@ -33,6 +33,8 @@
53 #include <core/screen.h>
54 #include "privateaction.h"
55
56+namespace ca = compiz::actions;
57+
58 struct _Modifier {
59 const char *name;
60 int modifier;
61@@ -626,6 +628,28 @@
62 return priv->active;
63 }
64
65+void
66+PrivateAction::makeActive ()
67+{
68+ active = true;
69+}
70+
71+void
72+PrivateAction::makeInactive ()
73+{
74+ active = false;
75+}
76+
77+void
78+ca::setActionActiveState (const CompAction &action,
79+ bool active)
80+{
81+ if (active)
82+ action.priv->makeActive ();
83+ else
84+ action.priv->makeInactive ();
85+}
86+
87 PrivateAction::PrivateAction () :
88 initiate (),
89 terminate (),
90
91=== modified file 'src/event.cpp'
92--- src/event.cpp 2012-09-05 16:42:03 +0000
93+++ src/event.cpp 2012-09-24 11:41:41 +0000
94@@ -41,8 +41,10 @@
95 #include "privatescreen.h"
96 #include "privatewindow.h"
97 #include "privatestackdebugger.h"
98+#include "eventmanagement.h"
99
100 namespace cps = compiz::private_screen;
101+namespace ce = compiz::events;
102
103 namespace
104 {
105@@ -109,6 +111,9 @@
106 if (!(option.value ().action ().state () & state))
107 return false;
108
109+ if (!option.value ().action ().active ())
110+ return false;
111+
112 return true;
113 }
114
115@@ -189,78 +194,160 @@
116 return false;
117 }
118
119+int
120+ce::processButtonPressOnEdgeWindow (Window edgeWindow,
121+ Window root,
122+ Window eventWindow,
123+ Window eventRoot,
124+ cps::GrabList &grabList,
125+ const CompScreenEdge *screenEdge)
126+{
127+ int edge = -1;
128+
129+ if (eventRoot != root)
130+ return edge;
131+
132+ if (eventWindow != edgeWindow)
133+ {
134+ if (grabList.grabsEmpty () ||
135+ eventRoot != root)
136+ return edge;
137+ }
138+
139+ for (unsigned int i = 0; i < SCREEN_EDGE_NUM; i++)
140+ {
141+ if (edgeWindow == screenEdge[i].id)
142+ {
143+ edge = 1 << i;
144+ break;
145+ }
146+ }
147+
148+ return edge;
149+}
150+
151+void
152+ce::setEventWindowInButtonPressArguments (ce::EventArguments &arguments,
153+ Window eventWindow)
154+{
155+ arguments[1].value ().set ((int) eventWindow);
156+}
157+
158+namespace
159+{
160+ bool buttonActionModifiersMatchEventState (unsigned int actionModifiers,
161+ unsigned int eventState)
162+ {
163+ const unsigned int ignored = modHandler->ignoredModMask ();
164+ const unsigned int modMask = REAL_MOD_MASK & ~ignored;
165+ const unsigned int bindMods = modHandler->virtualToRealModMask (actionModifiers);
166+
167+ return (bindMods & modMask) == (eventState & modMask);
168+ }
169+}
170+
171+bool
172+ce::activateButtonPressOnWindowBindingOption (CompOption &option,
173+ unsigned int eventButton,
174+ unsigned int eventState,
175+ cps::EventManager &eventManager,
176+ const ActionModsMatchesEventStateFunc &matchEventState,
177+ ce::EventArguments &arguments)
178+{
179+ CompAction *action;
180+ const CompAction::State state = CompAction::StateInitButton;
181+
182+ if (isBound (option, CompAction::BindingTypeButton, state, &action))
183+ {
184+ if (action->button ().button () == (int) eventButton)
185+ {
186+ if (matchEventState (action->button ().modifiers (),
187+ eventState))
188+ {
189+ if (eventManager.triggerPress (action, state, arguments))
190+ return true;
191+ }
192+ }
193+ }
194+
195+ return false;
196+}
197+
198+bool
199+ce::activateButtonPressOnEdgeBindingOption (CompOption &option,
200+ unsigned int eventButton,
201+ unsigned int eventState,
202+ int edge,
203+ cps::EventManager &eventManager,
204+ const ActionModsMatchesEventStateFunc &matchEventState,
205+ ce::EventArguments &arguments)
206+{
207+ CompAction *action;
208+ const CompAction::State state = CompAction::StateInitButton |
209+ CompAction::StateInitEdge;
210+
211+ if (edge != -1)
212+ {
213+ if (isInitiateBinding (option, CompAction::BindingTypeEdgeButton,
214+ state, &action))
215+ {
216+ if ((action->button ().button () == (int) eventButton) &&
217+ (action->edgeMask () & edge))
218+ {
219+ if (matchEventState (action->button ().modifiers (),
220+ eventState))
221+ if (action->initiate () (action, state,
222+ arguments))
223+ return true;
224+ }
225+ }
226+ }
227+
228+ return false;
229+}
230+
231 bool
232 PrivateScreen::triggerButtonPressBindings (CompOption::Vector &options,
233 XButtonEvent *event,
234 CompOption::Vector &arguments)
235 {
236- CompAction::State state = CompAction::StateInitButton;
237- CompAction *action;
238- unsigned int ignored = modHandler->ignoredModMask ();
239- unsigned int modMask = REAL_MOD_MASK & ~ignored;
240- unsigned int bindMods;
241- unsigned int edge = 0;
242+ int edge = -1;
243+
244+ static const ce::ActionModsMatchesEventStateFunc matchEventState (
245+ boost::bind (buttonActionModifiersMatchEventState,
246+ _1, _2));
247
248 if (edgeWindow)
249- {
250- unsigned int i;
251-
252- if (event->root != screen->root())
253- return false;
254-
255- if (event->window != edgeWindow)
256- {
257- if (eventManager.grabsEmpty () || event->window != screen->root())
258- return false;
259- }
260-
261- for (i = 0; i < SCREEN_EDGE_NUM; i++)
262- {
263- if (edgeWindow == screenEdge[i].id)
264- {
265- edge = 1 << i;
266- arguments[1].value ().set ((int) orphanData.activeWindow);
267- break;
268- }
269- }
270- }
271+ edge = ce::processButtonPressOnEdgeWindow (edgeWindow,
272+ screen->root (),
273+ event->window,
274+ event->root,
275+ eventManager,
276+ screenEdge);
277+
278+ if (edge != -1)
279+ ce::setEventWindowInButtonPressArguments (arguments,
280+ orphanData.activeWindow);
281
282 foreach (CompOption &option, options)
283 {
284- if (isBound (option, CompAction::BindingTypeButton, state, &action))
285- {
286- if (action->button ().button () == (int) event->button)
287- {
288- bindMods = modHandler->virtualToRealModMask (
289- action->button ().modifiers ());
290-
291- if ((bindMods & modMask) == (event->state & modMask))
292- {
293- if (eventManager.triggerPress (action, state, arguments))
294- return true;
295- }
296- }
297- }
298-
299- if (edge)
300- {
301- if (isInitiateBinding (option, CompAction::BindingTypeEdgeButton,
302- state | CompAction::StateInitEdge, &action))
303- {
304- if ((action->button ().button () == (int) event->button) &&
305- (action->edgeMask () & edge))
306- {
307- bindMods = modHandler->virtualToRealModMask (
308- action->button ().modifiers ());
309-
310- if ((bindMods & modMask) == (event->state & modMask))
311- if (action->initiate () (action, state |
312- CompAction::StateInitEdge,
313- arguments))
314- return true;
315- }
316- }
317- }
318+ if (ce::activateButtonPressOnWindowBindingOption (option,
319+ event->button,
320+ event->state,
321+ eventManager,
322+ matchEventState,
323+ arguments))
324+ return true;
325+
326+ if (ce::activateButtonPressOnEdgeBindingOption (option,
327+ event->button,
328+ event->state,
329+ edge,
330+ eventManager,
331+ matchEventState,
332+ arguments))
333+ return true;
334+
335 }
336
337 return false;
338
339=== added file 'src/eventmanagement.h'
340--- src/eventmanagement.h 1970-01-01 00:00:00 +0000
341+++ src/eventmanagement.h 2012-09-24 11:41:41 +0000
342@@ -0,0 +1,80 @@
343+/*
344+ * Copyright © 2012 Canonical, Ltd.
345+ *
346+ * Permission to use, copy, modify, distribute, and sell this software
347+ * and its documentation for any purpose is hereby granted without
348+ * fee, provided that the above copyright notice appear in all copies
349+ * and that both that copyright notice and this permission notice
350+ * appear in supporting documentation, and that the name of
351+ * Canonical, Ltd. not be used in advertising or publicity pertaining to
352+ * distribution of the software without specific, written prior permission.
353+ * Canonical, Ltd. makes no representations about the suitability of this
354+ * software for any purpose. It is provided "as is" without express or
355+ * implied warranty.
356+ *
357+ * CANONICAL LTD. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
358+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
359+ * NO EVENT SHALL Canonical, Ltd. BE LIABLE FOR ANY SPECIAL, INDIRECT OR
360+ * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
361+ * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
362+ * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
363+ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
364+ *
365+ * Author: Sam Spilsbury <sam.spilsbury@canonical.com>
366+ */
367+#ifndef _COMPIZ_EVENT_MANAGEMENT_H
368+#define _COMPIZ_EVENT_MANAGEMENT_H
369+
370+#include <boost/function.hpp>
371+
372+class CompScreenEdge;
373+class CompOption;
374+
375+namespace compiz
376+{
377+ namespace private_screen
378+ {
379+ struct GrabList;
380+ class EventManager;
381+ }
382+
383+ namespace events
384+ {
385+ namespace cps = compiz::private_screen;
386+ typedef std::vector <CompOption> EventArguments;
387+ typedef boost::function <bool (unsigned int, unsigned int)> ActionModsMatchesEventStateFunc;
388+
389+ int
390+ processButtonPressOnEdgeWindow (Window edgeWindow,
391+ Window root,
392+ Window eventWindow,
393+ Window eventRoot,
394+ cps::GrabList &grabList,
395+ const CompScreenEdge *screenEdge);
396+
397+ void
398+ setEventWindowInButtonPressArguments (EventArguments &arguments,
399+ Window eventWindow);
400+
401+ bool
402+ activateButtonPressOnWindowBindingOption (CompOption &option,
403+ unsigned int eventButton,
404+ unsigned int eventState,
405+ cps::EventManager &eventManager,
406+ const ActionModsMatchesEventStateFunc &matchEventState,
407+ EventArguments &arguments);
408+
409+ bool
410+ activateButtonPressOnEdgeBindingOption (CompOption &option,
411+ unsigned int eventButton,
412+ unsigned int eventState,
413+ int edge,
414+ cps::EventManager &eventManager,
415+ const ActionModsMatchesEventStateFunc &matchEventState,
416+ EventArguments &arguments);
417+ }
418+}
419+
420+
421+
422+#endif
423
424=== modified file 'src/option.cpp'
425--- src/option.cpp 2012-06-24 09:00:27 +0000
426+++ src/option.cpp 2012-09-24 11:41:41 +0000
427@@ -462,12 +462,24 @@
428 return priv->type;
429 }
430
431+CompOption::Type
432+CompOption::type () const
433+{
434+ return priv->type;
435+}
436+
437 CompOption::Value &
438 CompOption::value ()
439 {
440 return priv->value;
441 }
442
443+CompOption::Value &
444+CompOption::value () const
445+{
446+ return priv->value;
447+}
448+
449 CompOption::Restriction &
450 CompOption::rest ()
451 {
452@@ -477,6 +489,12 @@
453 bool
454 CompOption::set (CompOption::Value &val)
455 {
456+ /* XXX: It is uncertain as to why this is done. The only
457+ * logical reason would be that actions are stateful and
458+ * we don't want to care about the old state from the
459+ * action that we're setting this value to, so we're just
460+ * clearing that state and starting over, however copyState
461+ * does a lot more than that */
462 if (isAction () && priv->type != CompOption::TypeAction)
463 val.action ().copyState (priv->value.action ());
464
465
466=== modified file 'src/option/tests/option.cpp'
467--- src/option/tests/option.cpp 2012-05-27 03:27:57 +0000
468+++ src/option/tests/option.cpp 2012-09-24 11:41:41 +0000
469@@ -206,3 +206,34 @@
470 ASSERT_EQ(expectTwo, as_const.f());
471 }
472 }
473+
474+TEST (CompOption, AssignDefaultActionValueToUnsetTypeClearsOldStateKeepsInfo)
475+{
476+ /* Value is unset at this point */
477+ CompOption option ("testing", CompOption::TypeKey);
478+ CompAction action;
479+
480+ /* We need to set up the state here as
481+ * the CompOption::Value constructor makes
482+ * a copy of the action */
483+ action.setState (CompAction::StateInitKey);
484+ action.setButton (CompAction::ButtonBinding (1,
485+ 1 << 1));
486+
487+ CompOption::Value value (action);
488+
489+ ASSERT_EQ (value.action ().state (), CompAction::StateInitKey);
490+
491+ /* Actually set the action value, this will
492+ * overwrite the internal value */
493+ option.set (value);
494+
495+ /* We don't care about the old action's state, so get
496+ * rid of it */
497+ ASSERT_EQ (option.value ().action ().state (), 0);
498+
499+ /* We do want to keep the non-stateful data which is
500+ * pure info */
501+ ASSERT_EQ (option.value ().action ().button ().button (), 1);
502+ ASSERT_EQ (option.value ().action ().button ().modifiers (), 1 << 1);
503+}
504
505=== modified file 'src/privateaction.h'
506--- src/privateaction.h 2012-02-14 11:39:59 +0000
507+++ src/privateaction.h 2012-09-24 11:41:41 +0000
508@@ -28,11 +28,35 @@
509 #ifndef _PRIVATEACTION_H
510 #define _PRIVATEACTION_H
511
512-class PrivateAction {
513+namespace compiz
514+{
515+ namespace actions
516+ {
517+ class BoundAction
518+ {
519+ public:
520+
521+ virtual ~BoundAction () {}
522+
523+ virtual void makeActive () = 0;
524+ virtual void makeInactive () = 0;
525+ };
526+
527+ void setActionActiveState (const CompAction &action,
528+ bool active);
529+ }
530+}
531+
532+class PrivateAction :
533+ public compiz::actions::BoundAction
534+{
535 public:
536 PrivateAction ();
537 PrivateAction (const PrivateAction&);
538
539+ void makeActive ();
540+ void makeInactive ();
541+
542 CompAction::CallBack initiate;
543 CompAction::CallBack terminate;
544
545
546=== modified file 'src/privatescreen/tests/test-privatescreen.cpp'
547--- src/privatescreen/tests/test-privatescreen.cpp 2012-06-24 09:00:27 +0000
548+++ src/privatescreen/tests/test-privatescreen.cpp 2012-09-24 11:41:41 +0000
549@@ -1,5 +1,6 @@
550 #include "privatescreen.h"
551-
552+#include "privateaction.h"
553+#include "eventmanagement.h"
554
555 // Get rid of stupid macro from X.h
556 // Why, oh why, are we including X.h?
557@@ -16,6 +17,8 @@
558
559 namespace {
560
561+const unsigned long None = 0;
562+
563 class MockCompScreen : public CompScreen
564 {
565 public:
566@@ -355,6 +358,7 @@
567 } // (abstract) namespace
568
569 namespace cps = compiz::private_screen;
570+namespace ce = compiz::events;
571
572 TEST(privatescreen_PluginManagerTest, create_and_destroy)
573 {
574@@ -909,3 +913,511 @@
575
576 EXPECT_EQ (vp, CompPoint (0, 1));
577 }
578+
579+namespace
580+{
581+ const Window topLeftScreenEdge = 1;
582+ const Window topScreenEdge = 2;
583+ const Window topRightScreenEdge = 3;
584+ const Window rightScreenEdge = 4;
585+ const Window bottomRightScreenEdge = 5;
586+ const Window bottomScreenEdge = 6;
587+ const Window bottomLeftScreenEdge = 7;
588+ const Window leftScreenEdge = 8;
589+
590+ const CompScreenEdge screenEdges[SCREEN_EDGE_NUM] =
591+ {
592+ { leftScreenEdge, SCREEN_EDGE_LEFT },
593+ { rightScreenEdge, SCREEN_EDGE_RIGHT },
594+ { topScreenEdge, SCREEN_EDGE_TOP },
595+ { bottomScreenEdge , SCREEN_EDGE_BOTTOM },
596+ { topLeftScreenEdge, SCREEN_EDGE_TOPLEFT },
597+ { topRightScreenEdge, SCREEN_EDGE_TOPRIGHT },
598+ { bottomLeftScreenEdge, SCREEN_EDGE_BOTTOMLEFT },
599+ { bottomRightScreenEdge, SCREEN_EDGE_BOTTOMRIGHT}
600+ };
601+}
602+
603+TEST (privatescreen_ButtonPressEdgeEventManagementTest, IgnoreWhenEventAndRootWindowMismatch)
604+{
605+ const Window rootWindow = 1;
606+ const Window edgeWindow = topScreenEdge;
607+
608+ cps::OrphanData orphanData;
609+ cps::GrabList grabList;
610+
611+ EXPECT_EQ (ce::processButtonPressOnEdgeWindow (edgeWindow,
612+ rootWindow,
613+ 0,
614+ 0,
615+ grabList,
616+ screenEdges), -1);
617+}
618+
619+TEST (privatescreen_ButtonPressEdgeEventManagementTest, IgnoreWhenEventMismatchAndNoGrabs)
620+{
621+ const Window rootWindow = 1;
622+ const Window edgeWindow = topScreenEdge;
623+
624+ cps::OrphanData orphanData;
625+ cps::GrabList grabList;
626+
627+ EXPECT_EQ (ce::processButtonPressOnEdgeWindow (edgeWindow,
628+ rootWindow,
629+ 0,
630+ rootWindow,
631+ grabList,
632+ screenEdges), -1);
633+}
634+
635+TEST (privatescreen_ButtonPressEdgeEventManagementTest, AllowWhenEventButNotRootWindowMismatchWhileGrabbed)
636+{
637+ const Window rootWindow = 1;
638+ const Window edgeWindow = topScreenEdge;
639+ unsigned int topEdgeMask = 1 << SCREEN_EDGE_TOP;
640+
641+ cps::OrphanData orphanData;
642+ cps::GrabList grabList;
643+
644+ grabList.grabsPush (new cps::Grab (None, "Nil"));
645+
646+ EXPECT_EQ (ce::processButtonPressOnEdgeWindow (edgeWindow,
647+ rootWindow,
648+ 0,
649+ rootWindow,
650+ grabList,
651+ screenEdges), topEdgeMask);
652+
653+ grabList.grabsRemove (grabList.grabsBack ());
654+}
655+
656+TEST (privatescreen_ButtonPressEventManagementTest, SetEventWindowArgument)
657+{
658+ const Window activeWindow = 1;
659+
660+ ce::EventArguments arguments (2);
661+ ce::setEventWindowInButtonPressArguments (arguments, activeWindow);
662+ EXPECT_EQ (arguments[1].value ().i (), activeWindow);
663+}
664+
665+namespace
666+{
667+ class MockTriggerableAction
668+ {
669+ public:
670+
671+ MOCK_METHOD2 (matchEventState, bool (unsigned int,
672+ unsigned int));
673+ MOCK_METHOD3 (initiate, bool (CompAction *,
674+ CompAction::State ,
675+ CompOption::Vector &));
676+ MOCK_METHOD3 (terminate, bool (CompAction *,
677+ CompAction::State ,
678+ CompOption::Vector &));
679+ };
680+
681+ const unsigned int testingButtonNumber = 1;
682+ const unsigned int testingButtonState = (1 << 1);
683+
684+ ce::ActionModsMatchesEventStateFunc
685+ GetMatchEventStateFuncForMock (MockTriggerableAction &triggerableAction)
686+ {
687+ return boost::bind (&MockTriggerableAction::matchEventState,
688+ &triggerableAction,
689+ _1, _2);
690+ }
691+
692+ CompAction::CallBack
693+ GetInitiateForMock (MockTriggerableAction &triggerableAction)
694+ {
695+ return boost::bind (&MockTriggerableAction::initiate,
696+ &triggerableAction,
697+ _1, _2, _3);
698+ }
699+
700+ CompAction::CallBack
701+ GetTerminateForMock (MockTriggerableAction &triggerableAction)
702+ {
703+ return boost::bind (&MockTriggerableAction::terminate,
704+ &triggerableAction,
705+ _1, _2, _3);
706+ }
707+}
708+
709+bool operator== (const CompOption &lhs,
710+ const CompOption &rhs)
711+{
712+ if (lhs.type () != rhs.type ())
713+ return false;
714+
715+ return lhs.value () == rhs.value ();
716+}
717+
718+TEST (privatescreen_ButtonPressEventManagementTest, NoTriggerOnUnboundAction)
719+{
720+ CompAction action;
721+ CompOption option ("button", CompOption::TypeButton);
722+ CompOption::Value value (action);
723+ cps::EventManager eventManager;
724+ MockTriggerableAction triggerableAction;
725+ ce::EventArguments arguments;
726+
727+ option.set (value);
728+
729+ const ce::ActionModsMatchesEventStateFunc &matchEventState =
730+ GetMatchEventStateFuncForMock (triggerableAction);
731+
732+ EXPECT_FALSE (ce::activateButtonPressOnWindowBindingOption (option,
733+ testingButtonNumber,
734+ testingButtonState,
735+ eventManager,
736+ matchEventState,
737+ arguments));
738+}
739+
740+TEST (privatescreen_ButtonPressEventManagementTest, NoTriggerOnUnboundInactiveAction)
741+{
742+ CompAction action;
743+ MockTriggerableAction triggerableAction;
744+ int edgeMask = 1 << SCREEN_EDGE_TOP;
745+
746+ const ce::ActionModsMatchesEventStateFunc &matchEventState =
747+ GetMatchEventStateFuncForMock (triggerableAction);
748+ const CompAction::CallBack &initiate =
749+ GetInitiateForMock (triggerableAction);
750+
751+ action.setButton (CompAction::ButtonBinding (testingButtonNumber,
752+ testingButtonState));
753+ action.setEdgeMask (edgeMask);
754+
755+
756+ CompOption option ("button", CompOption::TypeButton);
757+ CompOption::Value value (action);
758+ cps::EventManager eventManager;
759+ ce::EventArguments arguments;
760+
761+ option.set (value);
762+ option.value ().action ().setInitiate (initiate);
763+ option.value ().action ().setState (CompAction::StateInitButton);
764+ compiz::actions::setActionActiveState (option.value ().action (), false);
765+
766+ EXPECT_FALSE (ce::activateButtonPressOnEdgeBindingOption (option,
767+ testingButtonNumber,
768+ testingButtonState,
769+ edgeMask,
770+ eventManager,
771+ matchEventState,
772+ arguments));
773+}
774+
775+TEST (privatescreen_ButtonPressEventManagementTest, NoTriggerOnMismatchedButtonNumber)
776+{
777+ CompAction action;
778+ MockTriggerableAction triggerableAction;
779+
780+ const ce::ActionModsMatchesEventStateFunc &matchEventState =
781+ GetMatchEventStateFuncForMock (triggerableAction);
782+ const CompAction::CallBack &initiate =
783+ GetInitiateForMock (triggerableAction);
784+
785+ action.setButton (CompAction::ButtonBinding (testingButtonNumber,
786+ testingButtonState));
787+
788+ CompOption option ("button", CompOption::TypeButton);
789+ CompOption::Value value (action);
790+ cps::EventManager eventManager;
791+ ce::EventArguments arguments;
792+
793+ option.set (value);
794+ option.value ().action ().setInitiate (initiate);
795+ option.value ().action ().setState (CompAction::StateInitButton);
796+ compiz::actions::setActionActiveState (option.value ().action (), true);
797+
798+ EXPECT_CALL (triggerableAction, initiate (_, _, _)).Times (0);
799+ EXPECT_FALSE (ce::activateButtonPressOnWindowBindingOption (option,
800+ 0,
801+ testingButtonState,
802+ eventManager,
803+ matchEventState,
804+ arguments));
805+}
806+
807+TEST (privatescreen_ButtonPressEventManagementTest, NoTriggerOnMismatchedButtonState)
808+{
809+ CompAction action;
810+ MockTriggerableAction triggerableAction;
811+
812+ const ce::ActionModsMatchesEventStateFunc &matchEventState =
813+ GetMatchEventStateFuncForMock (triggerableAction);
814+ const CompAction::CallBack &initiate =
815+ GetInitiateForMock (triggerableAction);
816+
817+ action.setButton (CompAction::ButtonBinding (testingButtonNumber,
818+ testingButtonState));
819+
820+ CompOption option ("button", CompOption::TypeButton);
821+ CompOption::Value value (action);
822+ cps::EventManager eventManager;
823+ ce::EventArguments arguments;
824+
825+ option.set (value);
826+ option.value ().action ().setInitiate (initiate);
827+ option.value ().action ().setState (CompAction::StateInitButton);
828+ compiz::actions::setActionActiveState (option.value ().action (), true);
829+
830+ EXPECT_CALL (triggerableAction, matchEventState (testingButtonState, 0))
831+ .WillOnce (Return (false));
832+ EXPECT_CALL (triggerableAction, initiate (_, _, _)).Times (0);
833+ EXPECT_FALSE (ce::activateButtonPressOnWindowBindingOption (option,
834+ testingButtonNumber,
835+ 0,
836+ eventManager,
837+ matchEventState,
838+ arguments));
839+}
840+
841+TEST (privatescreen_ButtonPressEventManagementTest, TriggerWhenStateAndButtonMatch)
842+{
843+ CompAction action;
844+ MockTriggerableAction triggerableAction;
845+
846+ const ce::ActionModsMatchesEventStateFunc &matchEventState =
847+ GetMatchEventStateFuncForMock (triggerableAction);
848+ const CompAction::CallBack &initiate =
849+ GetInitiateForMock (triggerableAction);
850+
851+ action.setButton (CompAction::ButtonBinding (testingButtonNumber,
852+ testingButtonState));
853+
854+ CompOption option ("button", CompOption::TypeButton);
855+ CompOption::Value value (action);
856+ cps::EventManager eventManager;
857+ ce::EventArguments arguments;
858+
859+ option.set (value);
860+ option.value ().action ().setInitiate (initiate);
861+ option.value ().action ().setState (CompAction::StateInitButton);
862+ compiz::actions::setActionActiveState (option.value ().action (), true);
863+
864+ EXPECT_CALL (triggerableAction, matchEventState (testingButtonState, testingButtonState))
865+ .WillOnce (Return (true));
866+ EXPECT_CALL (triggerableAction, initiate (&option.value ().action (),
867+ CompAction::StateInitButton,
868+ arguments)).WillOnce (Return (true));
869+ EXPECT_TRUE (ce::activateButtonPressOnWindowBindingOption (option,
870+ testingButtonNumber,
871+ testingButtonState,
872+ eventManager,
873+ matchEventState,
874+ arguments));
875+}
876+
877+TEST (privatescreen_ButtonPressEdgeEventManagementTest, NoTriggerOnInvalidEdge)
878+{
879+ CompAction action;
880+ CompOption option ("button", CompOption::TypeButton);
881+ CompOption::Value value (action);
882+ cps::EventManager eventManager;
883+ MockTriggerableAction triggerableAction;
884+ ce::EventArguments arguments;
885+ int edgeMask = -1;
886+
887+ option.set (value);
888+
889+ const ce::ActionModsMatchesEventStateFunc &matchEventState =
890+ GetMatchEventStateFuncForMock (triggerableAction);
891+
892+ EXPECT_FALSE (ce::activateButtonPressOnEdgeBindingOption (option,
893+ testingButtonNumber,
894+ testingButtonState,
895+ edgeMask,
896+ eventManager,
897+ matchEventState,
898+ arguments));
899+}
900+
901+TEST (privatescreen_ButtonPressEdgeEventManagementTest, NoTriggerOnUnboundAction)
902+{
903+ CompAction action;
904+ CompOption option ("button", CompOption::TypeButton);
905+ CompOption::Value value (action);
906+ cps::EventManager eventManager;
907+ MockTriggerableAction triggerableAction;
908+ ce::EventArguments arguments;
909+ int edgeMask = 1 << SCREEN_EDGE_TOP;
910+
911+ option.set (value);
912+
913+ const ce::ActionModsMatchesEventStateFunc &matchEventState =
914+ GetMatchEventStateFuncForMock (triggerableAction);
915+
916+ EXPECT_FALSE (ce::activateButtonPressOnEdgeBindingOption (option,
917+ testingButtonNumber,
918+ testingButtonState,
919+ edgeMask,
920+ eventManager,
921+ matchEventState,
922+ arguments));
923+}
924+
925+TEST (privatescreen_ButtonPressEdgeEventManagementTest, NoTriggerOnMismatchedEdgeMask)
926+{
927+ CompAction action;
928+ MockTriggerableAction triggerableAction;
929+ int edgeMask = 1 << SCREEN_EDGE_TOP;
930+
931+ const ce::ActionModsMatchesEventStateFunc &matchEventState =
932+ GetMatchEventStateFuncForMock (triggerableAction);
933+ const CompAction::CallBack &initiate =
934+ GetInitiateForMock (triggerableAction);
935+
936+ action.setButton (CompAction::ButtonBinding (testingButtonNumber,
937+ testingButtonState));
938+ action.setEdgeMask (edgeMask);
939+
940+ CompOption option ("button", CompOption::TypeButton);
941+ CompOption::Value value (action);
942+ cps::EventManager eventManager;
943+ ce::EventArguments arguments;
944+
945+
946+ option.set (value);
947+ option.value ().action ().setInitiate (initiate);
948+ option.value ().action ().setState (CompAction::StateInitButton);
949+ compiz::actions::setActionActiveState (option.value ().action (), true);
950+
951+ EXPECT_CALL (triggerableAction, initiate (_, _, _)).Times (0);
952+ EXPECT_FALSE (ce::activateButtonPressOnEdgeBindingOption (option,
953+ testingButtonNumber,
954+ testingButtonState,
955+ 0,
956+ eventManager,
957+ matchEventState,
958+ arguments));
959+}
960+
961+TEST (privatescreen_ButtonPressEdgeEventManagementTest, NoTriggerOnMismatchedButtonNumber)
962+{
963+ CompAction action;
964+ MockTriggerableAction triggerableAction;
965+ int edgeMask = 1 << SCREEN_EDGE_TOP;
966+
967+ const ce::ActionModsMatchesEventStateFunc &matchEventState =
968+ GetMatchEventStateFuncForMock (triggerableAction);
969+ const CompAction::CallBack &initiate =
970+ GetInitiateForMock (triggerableAction);
971+
972+ action.setButton (CompAction::ButtonBinding (testingButtonNumber,
973+ testingButtonState));
974+ action.setEdgeMask (edgeMask);
975+
976+ CompOption option ("button", CompOption::TypeButton);
977+ CompOption::Value value (action);
978+ cps::EventManager eventManager;
979+ ce::EventArguments arguments;
980+
981+
982+ option.set (value);
983+ option.value ().action ().setInitiate (initiate);
984+ option.value ().action ().setState (CompAction::StateInitButton);
985+ compiz::actions::setActionActiveState (option.value ().action (), true);
986+
987+ EXPECT_CALL (triggerableAction, initiate (_, _, _)).Times (0);
988+ EXPECT_FALSE (ce::activateButtonPressOnEdgeBindingOption (option,
989+ 0,
990+ testingButtonState,
991+ edgeMask,
992+ eventManager,
993+ matchEventState,
994+ arguments));
995+}
996+
997+TEST (privatescreen_ButtonPressEdgeEventManagementTest, NoTriggerOnMismatchedButtonState)
998+{
999+ CompAction action;
1000+ MockTriggerableAction triggerableAction;
1001+ int edgeMask = 1 << SCREEN_EDGE_TOP;
1002+
1003+ const ce::ActionModsMatchesEventStateFunc &matchEventState =
1004+ GetMatchEventStateFuncForMock (triggerableAction);
1005+ const CompAction::CallBack &initiate =
1006+ GetInitiateForMock (triggerableAction);
1007+
1008+ action.setButton (CompAction::ButtonBinding (testingButtonNumber,
1009+ testingButtonState));
1010+ action.setEdgeMask (edgeMask);
1011+
1012+
1013+ CompOption option ("button", CompOption::TypeButton);
1014+ CompOption::Value value (action);
1015+ cps::EventManager eventManager;
1016+ ce::EventArguments arguments;
1017+
1018+ option.set (value);
1019+ option.value ().action ().setInitiate (initiate);
1020+ option.value ().action ().setState (CompAction::StateInitButton);
1021+ compiz::actions::setActionActiveState (option.value ().action (), true);
1022+
1023+ EXPECT_CALL (triggerableAction, matchEventState (testingButtonState, 0))
1024+ .WillOnce (Return (false));
1025+ EXPECT_CALL (triggerableAction, initiate (_, _, _)).Times (0);
1026+ EXPECT_FALSE (ce::activateButtonPressOnEdgeBindingOption (option,
1027+ testingButtonNumber,
1028+ 0,
1029+ edgeMask,
1030+ eventManager,
1031+ matchEventState,
1032+ arguments));
1033+}
1034+
1035+TEST (privatescreen_ButtonPressEdgeEventManagementTest, TriggerWhenStateButtonAndEdgeMaskMatch)
1036+{
1037+ CompAction action;
1038+ MockTriggerableAction triggerableAction;
1039+ int edgeMask = 1 << SCREEN_EDGE_TOP;
1040+
1041+ const ce::ActionModsMatchesEventStateFunc &matchEventState =
1042+ GetMatchEventStateFuncForMock (triggerableAction);
1043+ const CompAction::CallBack &initiate =
1044+ GetInitiateForMock (triggerableAction);
1045+
1046+ action.setButton (CompAction::ButtonBinding (testingButtonNumber,
1047+ testingButtonState));
1048+ action.setEdgeMask (edgeMask);
1049+
1050+ CompOption option ("button", CompOption::TypeButton);
1051+ CompOption::Value value (action);
1052+ cps::EventManager eventManager;
1053+ ce::EventArguments arguments;
1054+
1055+ option.set (value);
1056+ option.value ().action ().setInitiate (initiate);
1057+ option.value ().action ().setState (CompAction::StateInitButton |
1058+ CompAction::StateInitEdge);
1059+ compiz::actions::setActionActiveState (option.value ().action (), true);
1060+
1061+ EXPECT_CALL (triggerableAction, matchEventState (testingButtonState, testingButtonState))
1062+ .WillOnce (Return (true));
1063+ EXPECT_CALL (triggerableAction, initiate (&option.value ().action (),
1064+ CompAction::StateInitButton |
1065+ CompAction::StateInitEdge,
1066+ arguments)).WillOnce (Return (true));
1067+ EXPECT_TRUE (ce::activateButtonPressOnEdgeBindingOption (option,
1068+ testingButtonNumber,
1069+ testingButtonState,
1070+ edgeMask,
1071+ eventManager,
1072+ matchEventState,
1073+ arguments));
1074+}
1075+
1076+TEST (privatescreen_ActionActiveTest, TestMakeActionActive)
1077+{
1078+ CompAction action;
1079+
1080+ ASSERT_EQ (action.active (), false);
1081+ compiz::actions::setActionActiveState (action, true);
1082+ ASSERT_EQ (action.active (), true);
1083+ compiz::actions::setActionActiveState (action, false);
1084+ ASSERT_EQ (action.active (), false);
1085+}
1086
1087=== modified file 'src/screen.cpp'
1088--- src/screen.cpp 2012-09-18 01:44:23 +0000
1089+++ src/screen.cpp 2012-09-24 11:41:41 +0000
1090@@ -89,6 +89,7 @@
1091 } MwmHints;
1092
1093 namespace cps = compiz::private_screen;
1094+namespace ca = compiz::actions;
1095
1096
1097
1098@@ -3565,7 +3566,7 @@
1099 privateScreen.enableEdge (i);
1100 }
1101
1102- action->priv->active = true;
1103+ ca::setActionActiveState (*action, true);
1104
1105 return true;
1106 }
1107@@ -3594,7 +3595,7 @@
1108 privateScreen.disableEdge (i);
1109 }
1110
1111- action->priv->active = false;
1112+ ca::setActionActiveState (*action, false);
1113 }
1114
1115 CompRect

Subscribers

People subscribed via source and target branches