[compiz] Edge + Mouse button draft patches

David Reveman davidr at novell.com
Mon Oct 16 12:53:58 PDT 2006


This seems very useful. I suggest that you add a

unsigned int edgeButton;

field to the CompAction struct and if it's set to 0, the action is
triggered on enter events as usual and if it's set to something else
it's only triggered when a matching button is pressed. This allows you
to set up both a normal button binding and a edge-button binding at the
same time.

(AnyButton is 0, which it might make sense to support, in which case we
can just make edgeButton signed and a negative value will give the usual
behavior.)

-David

On Mon, 2006-10-16 at 11:55 +0100, Mike Dransfield wrote:
> Attached are my draft patches to add edge + mouse button to the
> actions
> 
> It is useful because the edge bindings are too easily triggered, an edge +
> mouse button is good because it confirms the action.  An additional side
> benefit is that the mouse wheel can be used for rotating the cube and for
> the switcher (it is an excellent alternative to alt-tab).
> 
> I wanted to share the patches before cleaning them up because I wanted
> to check if there were any problems that I have missed.
> 
> The only problem that I can see is that if you want to have the default
> edge-only action then you have to set the button to Button0 (does
> anyone have a Button0?), this is because of the way compiz deals
> with the button bindings.  I do not mind this limitation too much
> but I would like to hear if I am doing something wrong.
> plain text document attachment (edgebutton-compiz.h.diff)
> diff --git a/include/compiz.h b/include/compiz.h
> index 61a9de5..f3c6e6c 100644
> --- a/include/compiz.h
> +++ b/include/compiz.h
> @@ -751,6 +751,8 @@ struct _CompDisplay {
>  
>      HandleEventProc handleEvent;
>  
> +    unsigned int mouseOnEdge;
> +
>      CompPrivate *privates;
>  };
>  
> plain text document attachment (edgebutton-event.c.diff)
> diff --git a/src/event.c b/src/event.c
> index 2d182be..b228dde 100644
> --- a/src/event.c
> +++ b/src/event.c
> @@ -266,12 +266,18 @@ triggerButtonPressBindings (CompDisplay 
>  	{
>  	    if (action->button.button == event->xbutton.button)
>  	    {
> -		bindMods = virtualToRealModMask (d, action->button.modifiers);
> +		/* if it has an edge mask set then make sure the mouse 
> +		   is on that corner as well */
> +		if (!option->value.action.edgeMask ||
> +		    (option->value.action.edgeMask & d->mouseOnEdge))
> +		{
> +		    bindMods = virtualToRealModMask (d, action->button.modifiers);
>  
> -		if ((bindMods & modMask) == (event->xbutton.state & modMask))
> -		    if ((*action->initiate) (d, action, state,
> -					     argument, nArgument))
> -			return TRUE;
> +		    if ((bindMods & modMask) == (event->xbutton.state & modMask))
> +		        if ((*action->initiate) (d, action, state,
> +			  		         argument, nArgument))
> +			    return TRUE;
> +		}
>  	    }
>  	}
>  
> @@ -556,6 +562,9 @@ isEdgeEnterAction (CompOption      *opti
>      if (!option->value.action.initiate)
>  	return FALSE;
>  
> +    if (option->value.action.button.button)
> +	return FALSE;
> +
>      *action = &option->value.action;
>  
>      return TRUE;
> @@ -802,6 +811,8 @@ handleActionEvent (CompDisplay *d,
>  		    }
>  		}
>  
> +                d->mouseOnEdge = 0;
> +
>  		edgeWindow = None;
>  
>  		o[0].value.i = event->xcrossing.window;
> @@ -844,6 +855,8 @@ handleActionEvent (CompDisplay *d,
>  
>  	    if (edge)
>  	    {
> +                d->mouseOnEdge = edge;
> +
>  		state = CompActionStateInitEdge;
>  
>  		edgeWindow = event->xcrossing.window;
> plain text document attachment (edgebutton-rotate.c.diff)
> diff --git a/plugins/rotate.c b/plugins/rotate.c
> index 152e1d6..6952722 100644
> --- a/plugins/rotate.c
> +++ b/plugins/rotate.c
> @@ -1774,6 +1774,7 @@ rotateDisplayInitOptions (RotateDisplay 
>      o->value.action.state	 |= CompActionStateInitKey;
>      o->value.action.state	 |= CompActionStateInitButton;
>      o->value.action.type	  = CompBindingTypeKey;
> +    o->value.action.button.button = 0;
>      o->value.action.key.modifiers = ROTATE_RIGHT_MODIFIERS_DEFAULT;
>      o->value.action.key.keycode   =
>  	XKeysymToKeycode (display,
> @@ -1902,6 +1903,7 @@ #define ROTATE_TO_OPTION(n)						 \
>      o->value.action.initiate	  = rotateEdgeFlipLeft;
>      o->value.action.terminate	  = rotateFlipTerminate;
>      o->value.action.bell	  = FALSE;
> +    o->value.action.button.button = 0;
>      o->value.action.edgeMask	  = 1 << SCREEN_EDGE_LEFT;
>      o->value.action.state	  = CompActionStateInitEdge;
>      o->value.action.state	 |= CompActionStateInitEdgeDnd;
> @@ -1918,6 +1920,7 @@ #define ROTATE_TO_OPTION(n)						 \
>      o->value.action.initiate	  = rotateEdgeFlipRight;
>      o->value.action.terminate	  = rotateFlipTerminate;
>      o->value.action.bell	  = FALSE;
> +    o->value.action.button.button = 0;
>      o->value.action.edgeMask	  = 1 << SCREEN_EDGE_RIGHT;
>      o->value.action.state	  = CompActionStateInitEdge;
>      o->value.action.state	 |= CompActionStateInitEdgeDnd;
> plain text document attachment (edgebutton-scale.c.diff)
> diff --git a/plugins/scale.c b/plugins/scale.c
> index 7095c2d..94e4258 100644
> --- a/plugins/scale.c
> +++ b/plugins/scale.c
> @@ -1075,11 +1075,14 @@ scaleInitiate (CompDisplay     *d,
>  		damageScreen (s);
>  	    }
>  
> -	    if (state & CompActionStateInitButton)
> -		action->state |= CompActionStateTermButton;
> +	    if (!(action->edgeMask & d->mouseOnEdge))
> +	    {
> +	        if (state & CompActionStateInitButton)
> +		    action->state |= CompActionStateTermButton;
>  
> -	    if (state & CompActionStateInitKey)
> -		action->state |= CompActionStateTermKey;
> +	        if (state & CompActionStateInitKey)
> +		    action->state |= CompActionStateTermKey;
> +	    }
>  	}
>      }
>  
> @@ -1372,9 +1375,11 @@ scaleDisplayInitOptions (ScaleDisplay *s
>      o->value.action.terminate	  = scaleTerminate;
>      o->value.action.bell	  = FALSE;
>      o->value.action.edgeMask	  = (1 << SCREEN_EDGE_TOPRIGHT);
> -    o->value.action.state	  = CompActionStateInitEdge;
>      o->value.action.type	  = CompBindingTypeKey;
> +    o->value.action.state	  = CompActionStateInitEdge;
>      o->value.action.state	 |= CompActionStateInitKey;
> +    o->value.action.state	 |= CompActionStateInitButton;
> +    o->value.action.button.button = 3;
>      o->value.action.key.modifiers = SCALE_INITIATE_MODIFIERS_DEFAULT;
>      o->value.action.key.keycode   =
>  	XKeysymToKeycode (display,
> plain text document attachment (edgebutton-switcher.c.diff)
> diff --git a/plugins/switcher.c b/plugins/switcher.c
> index f5808ee..e451325 100644
> --- a/plugins/switcher.c
> +++ b/plugins/switcher.c
> @@ -931,11 +931,14 @@ switchNext (CompDisplay     *d,
>  	{
>  	    switchInitiate (s, FALSE);
>  
> -	    if (state & CompActionStateInitKey)
> -		action->state |= CompActionStateTermKey;
> +	    if (!(action->edgeMask & d->mouseOnEdge))
> +	    {
> +	        if (state & CompActionStateInitKey)
> +		    action->state |= CompActionStateTermKey;
>  
> -	    if (state & CompActionStateInitButton)
> -		action->state |= CompActionStateTermButton;
> +	        if (state & CompActionStateInitButton)
> +		    action->state |= CompActionStateTermButton;
> +	    }
>  	}
>  
>  	switchToWindow (s, TRUE);
> @@ -965,11 +968,14 @@ switchPrev (CompDisplay     *d,
>  	{
>  	    switchInitiate (s, FALSE);
>  
> -	    if (state & CompActionStateInitKey)
> -		action->state |= CompActionStateTermKey;
> +	    if (!(action->edgeMask & d->mouseOnEdge))
> +	    {
> +	        if (state & CompActionStateInitKey)
> +		    action->state |= CompActionStateTermKey;
>  
> -	    if (state & CompActionStateInitButton)
> -		action->state |= CompActionStateTermButton;
> +	        if (state & CompActionStateInitButton)
> +		    action->state |= CompActionStateTermButton;
> +	    }
>  	}
>  
>  	switchToWindow (s, FALSE);
> @@ -1871,12 +1877,15 @@ switchDisplayInitOptions (SwitchDisplay 
>      o->value.action.initiate	  = switchNext;
>      o->value.action.terminate	  = switchTerminate;
>      o->value.action.bell	  = FALSE;
> -    o->value.action.edgeMask	  = 0;
> +    o->value.action.edgeMask	  = (1 << SCREEN_EDGE_TOP);
>      o->value.action.state	  = CompActionStateInitKey;
>      o->value.action.state	 |= CompActionStateInitButton;
> +    o->value.action.state	 |= CompActionStateInitEdge;
> +    o->value.action.state	 |= CompActionStateTermEdge;
>      o->value.action.type	  = CompBindingTypeKey;
> +    o->value.action.button.button = 5;
>      o->value.action.key.modifiers = SWITCH_NEXT_MODIFIERS_DEFAULT;
> -    o->value.action.key.keycode   =
> +    o->value.action.key.keycode   = 
>  	XKeysymToKeycode (display,
>  			  XStringToKeysym (SWITCH_NEXT_KEY_DEFAULT));
>  
> @@ -1889,10 +1898,13 @@ switchDisplayInitOptions (SwitchDisplay 
>      o->value.action.initiate	  = switchPrev;
>      o->value.action.terminate	  = switchTerminate;
>      o->value.action.bell	  = FALSE;
> -    o->value.action.edgeMask	  = 0;
> +    o->value.action.edgeMask	  = (1 << SCREEN_EDGE_TOP);
>      o->value.action.state	  = CompActionStateInitKey;
>      o->value.action.state	 |= CompActionStateInitButton;
> +    o->value.action.state	 |= CompActionStateInitEdge;
> +    o->value.action.state	 |= CompActionStateTermEdge;
>      o->value.action.type	  = CompBindingTypeKey;
> +    o->value.action.button.button = 4;
>      o->value.action.key.modifiers = SWITCH_PREV_MODIFIERS_DEFAULT;
>      o->value.action.key.keycode   =
>  	XKeysymToKeycode (display,
> _______________________________________________
> compiz mailing list
> compiz at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/compiz




More information about the compiz mailing list