[PATCH xserver] XKB: Redirect actions defunct with Gtk3 (XInput?)

Peter Hutterer peter.hutterer at who-t.net
Sun Feb 19 23:12:38 PST 2012


On Sun, Feb 19, 2012 at 11:18:19AM +0100, Andreas Wettstein wrote:
> When redirect actions are used with Gtk3, Gtk3 complains about
> events not holding a GdkDevice.  This is caused by device IDs not
> being set for redirect actions. The patch below sets them, but I
> am not quite sure that the values are correct.  Anyway, the
> warnings from Gtk3 warnings are gone.
> 
> More seriously, Gtk3 does not receive state changes redirect
> actions might specify.  This is because event_set_state in
> dix/inpututils.c accesses the prev_state field, but the changes
> for the redirect action are only put into the state field.
> 
> Signed-off-by: Andreas Wettstein <wettstein509 at solnet.ch>
> ---
>  xkb/xkbActions.c |   18 ++++++++++++++----
>  1 files changed, 14 insertions(+), 4 deletions(-)
> 
> diff --git a/xkb/xkbActions.c b/xkb/xkbActions.c
> index da0bdea..da874f0 100644
> --- a/xkb/xkbActions.c
> +++ b/xkb/xkbActions.c
> @@ -795,7 +795,7 @@ _XkbFilterRedirectKey(	XkbSrvInfoPtr	xkbi,
>  {
>  DeviceEvent	ev;
>  int		x,y;
> -XkbStateRec	old;
> +XkbStateRec	old, old_prev;
>  unsigned	mods,mask;
>  xkbDeviceInfoPtr xkbPrivPtr = XKBDEVICEINFO(xkbi->device);
>  ProcessInputProc backupproc;
> @@ -803,6 +803,7 @@ ProcessInputProc backupproc;
>      /* never actually used uninitialised, but gcc isn't smart enough
>       * to work that out. */
>      memset(&old, 0, sizeof(old));
> +    memset(&old_prev, 0, sizeof(old_prev));
>      memset(&ev, 0, sizeof(ev));
>  
>      if ((filter->keycode!=0)&&(filter->keycode!=keycode))
> @@ -814,6 +815,7 @@ ProcessInputProc backupproc;
>      ev.time = GetTimeInMillis();
>      ev.root_x = x;
>      ev.root_y = y;
> +    ev.deviceid = ev.sourceid = xkbi->device->id;

not sure about this one. the actual device and source ID is in the caller
and you need to pass this down. they aren't always the same.
I think the rest is ok though.

Cheers,
  Peter
>  
>      if (filter->keycode==0) {		/* initial press */
>  	if ((pAction->redirect.new_key<xkbi->desc->min_key_code)||
> @@ -839,6 +841,7 @@ ProcessInputProc backupproc;
>  
>  	if ( mask || mods ) {
>  	    old= xkbi->state;
> +	    old_prev= xkbi->prev_state;
>  	    xkbi->state.base_mods&= ~mask;
>  	    xkbi->state.base_mods|= (mods&mask);
>  	    xkbi->state.latched_mods&= ~mask;
> @@ -846,15 +849,18 @@ ProcessInputProc backupproc;
>  	    xkbi->state.locked_mods&= ~mask;
>  	    xkbi->state.locked_mods|= (mods&mask);
>  	    XkbComputeDerivedState(xkbi);
> +	    xkbi->prev_state= xkbi->state;
>  	}
>  
>  	UNWRAP_PROCESS_INPUT_PROC(xkbi->device,xkbPrivPtr, backupproc);
>  	xkbi->device->public.processInputProc((InternalEvent*)&ev, xkbi->device);
>  	COND_WRAP_PROCESS_INPUT_PROC(xkbi->device, xkbPrivPtr,
>  				     backupproc,xkbUnwrapProc);
> -	
> -	if ( mask || mods )
> +
> +	if ( mask || mods ) {
>  	    xkbi->state= old;
> +	    xkbi->prev_state= old_prev;
> +	}
>      }
>      else if (filter->keycode==keycode) {
>  
> @@ -870,6 +876,7 @@ ProcessInputProc backupproc;
>  
>  	if ( mask || mods ) {
>  	    old= xkbi->state;
> +	    old_prev= xkbi->prev_state;
>  	    xkbi->state.base_mods&= ~mask;
>  	    xkbi->state.base_mods|= (mods&mask);
>  	    xkbi->state.latched_mods&= ~mask;
> @@ -877,6 +884,7 @@ ProcessInputProc backupproc;
>  	    xkbi->state.locked_mods&= ~mask;
>  	    xkbi->state.locked_mods|= (mods&mask);
>  	    XkbComputeDerivedState(xkbi);
> +	    xkbi->prev_state= xkbi->state;
>  	}
>  
>  	UNWRAP_PROCESS_INPUT_PROC(xkbi->device,xkbPrivPtr, backupproc);
> @@ -884,8 +892,10 @@ ProcessInputProc backupproc;
>  	COND_WRAP_PROCESS_INPUT_PROC(xkbi->device, xkbPrivPtr,
>  				     backupproc,xkbUnwrapProc);
>  
> -	if ( mask || mods )
> +	if ( mask || mods ) {
>  	    xkbi->state= old;
> +	    xkbi->prev_state= old_prev;
> +	}
>  
>  	filter->keycode= 0;
>  	filter->active= 0;
> -- 
> 1.7.6


More information about the xorg-devel mailing list