[compiz] Return value from an action function

David Reveman davidr at novell.com
Wed Jan 3 10:57:00 PST 2007


On Wed, 2007-01-03 at 02:40 +0000, Mike Dransfield wrote:
> I had always assumed that an action option
> should return true if it handles the action,
> but it seems like most button bindings actually
> return false which causes a few problems.
> 
> 1. The clicks pass through to windows which
> is not good for rotate, screenshot or annotate.
> 
> 2. I am trying to add a generic action notification
> which plugins can wrap to see when other actions
> are initiated and terminated.  Some plugins like 3D
> 'react' to the cube being rotated manually but not
> when keyboard initiated.
> 
> I came to the conclusion that the best place for
> it to go would be in the handleEvent function.
> 
> If the trigger*Binding function returns true
> then it should send the notification, but this
> does not return true even if the action initiated
> because they are returning false.
> 
> Is there is reason for this?  If so can you explain
> exactly what returning true/false means.

A non zero return value indicates that the event should be stolen and
that no more processing of the event should be done. There might be a
few places where initiate functions return FALSE but should instead be
returning TRUE. We should fix those cases.

The only way to determine if an action was triggered is by looking at
the state field in the CompAction struct. However, that's not completely
reliable as it doesn't have to add a Fini flag to the state just because
it was triggered.

The result of an initiate call is currently not defined to be true or
false. This is by design. An initiate call might in some cases initiate
some functionality that can be terminated but in other cases initiate
something else that can't be terminated but the result would still not
be considered unsuccessful. This can be changed of course but I'm not
sure we want to do that.

I think what you want to do is expose the state field in each action
struct. However, that shouldn't be done as a reply to an activate method
call but instead as a signal because it can be changed at any time and
it might be just as important to know about this change when you're not
the one that triggered it.

-David



More information about the compiz mailing list