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. Regards Mike
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
David Reveman wrote:> 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. > >Here is a patch for the cases that I am aware of There maybe others but not in actions commonly initiated by the mouse. Does the same apply in reverse? ie. Should I also change the terminate functions to return false to swallow the button up event? -------------- next part -------------->From 5e094651e6d12695c0a9c3eb2825a1526d66c24c Mon Sep 17 00:00:00 2001From: mike@blueroot.co.uk <mike@localhost.(none)> Date: Sun, 7 Jan 2007 01:29:49 +0000 Subject: [PATCH] Swallow clicks for initiate functions in screenshot, rotate and annotate --- plugins/annotate.c | 2 +- plugins/rotate.c | 2 +- plugins/screenshot.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/annotate.c b/plugins/annotate.c index 42ef705..1bb530b 100644 --- a/plugins/annotate.c +++ b/plugins/annotate.c @@ -500,7 +500,7 @@ annoInitiate (CompDisplay *d, as->eraseMode = FALSE; } - return FALSE; + return TRUE; } static Bool diff --git a/plugins/rotate.c b/plugins/rotate.c index 3e89e9f..e68d0ed 100644 --- a/plugins/rotate.c +++ b/plugins/rotate.c @@ -653,7 +653,7 @@ rotateInitiate (CompDisplay *d, } } - return FALSE; + return TRUE; } static Bool diff --git a/plugins/screenshot.c b/plugins/screenshot.c index ad27772..ddb9b52 100644 --- a/plugins/screenshot.c +++ b/plugins/screenshot.c @@ -104,7 +104,7 @@ shotInitiate (CompDisplay *d, ss->grab = TRUE; } - return FALSE; + return TRUE; } static Bool -- 1.4.4.3