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

Proposed by Sam Spilsbury
Status: Superseded
Proposed branch: lp:~compiz-team/compiz/compiz.fix_1053280
Merge into: lp:compiz/0.9.9
Diff against target: 1140 lines (+850/-75)
11 files modified
include/core/abiversion.h (+1/-1)
include/core/action.h (+14/-1)
include/core/option.h (+4/-3)
src/action.cpp (+15/-0)
src/event.cpp (+149/-62)
src/eventmanagement.h (+80/-0)
src/option.cpp (+16/-4)
src/option/tests/option.cpp (+31/-0)
src/privateaction.h (+23/-1)
src/privatescreen/tests/test-privatescreen.cpp (+514/-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
jenkins (community) continuous-integration Needs Fixing
Daniel van Vugt Needs Fixing
Sam Spilsbury Pending
Review via email: mp+126873@code.launchpad.net

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

This proposal has been superseded by a proposal from 2012-10-11.

Commit message

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.

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 : Posted in a previous version of this proposal

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 : Posted in a previous version of this proposal
review: Approve (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote : Posted in a previous version of this proposal

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

review: Needs Resubmitting
Revision history for this message
jenkins (martin-mrazik+qa) wrote :
review: Needs Fixing (continuous-integration)
3394. By Sam Spilsbury

Merge lp:compiz and handle some BCI stuff

3395. By Sam Spilsbury

Constify the API a bit

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

No obvious problems in testing. Just a few things:

1. These should be dropped now:
    Type type (); // BCI: drop this in 0.9.9
If you need to constify functions as part of this proposal then no problem. Otherwise constification and other general clean-ups should be done as separate proposals.

2. BCI, PV? Are those acronyms explained in the source files they're mentioned?

3. I would much prefer that the namespace depth did not affect the indentation of declarations. I would accept:
    namespace a { namespace b {
or
    namespace a {
    namespace b {
Because namespaces should be changeable without affecting the surrounding code. So if the depth changed then you shouldn't ever need to re-indent your code.

4. Two functions:
    PrivateAction::makeActive()
    PrivateAction::makeInactive()
should be one:
    PrivateAction::setActive(bool active)
Which will not only shrink the interface but is much more flexible for callers who want to change the setting based on a bool, like ca::setActionActiveState.

5. End-users of identifiers in namespaces like src/screen.cpp should use:
    using namespace compiz::actions;
    foo
    bar
instead of:
    namespace ca = compiz::actions;
    ca::foo
    ca::bar
It's cleaner to read, and again more flexible should namespaces ever change.

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

> No obvious problems in testing. Just a few things:
>
> 1. These should be dropped now:
> Type type (); // BCI: drop this in 0.9.9
> If you need to constify functions as part of this proposal then no problem.
> Otherwise constification and other general clean-ups should be done as
> separate proposals.

Done. Constification was necessary.

>
> 2. BCI, PV? Are those acronyms explained in the source files they're
> mentioned?

BCI == Binary Compat
PV == Pure Virtual

>
> 3. I would much prefer that the namespace depth did not affect the indentation
> of declarations. I would accept:
> namespace a { namespace b {
> or
> namespace a {
> namespace b {
> Because namespaces should be changeable without affecting the surrounding
> code. So if the depth changed then you shouldn't ever need to re-indent your
> code.

Debatable but okay.

>
> 4. Two functions:
> PrivateAction::makeActive()
> PrivateAction::makeInactive()
> should be one:
> PrivateAction::setActive(bool active)
> Which will not only shrink the interface but is much more flexible for callers
> who want to change the setting based on a bool, like ca::setActionActiveState.
>

Okay

> 5. End-users of identifiers in namespaces like src/screen.cpp should use:
> using namespace compiz::actions;
> foo
> bar
> instead of:
> namespace ca = compiz::actions;
> ca::foo
> ca::bar
> It's cleaner to read, and again more flexible should namespaces ever change.

using is bad because it just imports namespace conflicts and defeats the purpose of namespaces. namespace aliases are designed to fix that problem. Also considering that we have implementation and interface namespaces the conflicts are a very real problem.

3396. By Sam Spilsbury

Cleanup.

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

Revision history for this message
jenkins (martin-mrazik+qa) wrote :
review: Needs Fixing (continuous-integration)
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

Preview Diff

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

Subscribers

People subscribed via source and target branches