[PATCH 05/12] xf86Events: add Enable/DisableInputDeviceForVTSwitch functions

Peter Hutterer peter.hutterer at who-t.net
Mon Jan 27 22:35:20 PST 2014


On Wed, Jan 15, 2014 at 03:32:19PM +0100, Hans de Goede wrote:
> Factor this code out into functions so that it can be re-used for the
> systemd-logind device pause/resume paths.
> 
> Signed-off-by: Hans de Goede <hdegoede at redhat.com>

I'd probably rename these to xf86VTDisableDevice to have a slightly less
clunky name but either way

Reviewed-by: Peter Hutterer <peter.hutterer at who-t.net>

Cheers,
   Peter

PS: I reviewed this series on your for-keith branch
(646b5d885f15e4ca884a4c4da2d296e14d9fe972), just in case there are any
differences.

> ---
>  hw/xfree86/common/xf86.h       |  4 ++++
>  hw/xfree86/common/xf86Events.c | 52 +++++++++++++++++++++++-------------------
>  2 files changed, 32 insertions(+), 24 deletions(-)
> 
> diff --git a/hw/xfree86/common/xf86.h b/hw/xfree86/common/xf86.h
> index 537d1d1..cec3135 100644
> --- a/hw/xfree86/common/xf86.h
> +++ b/hw/xfree86/common/xf86.h
> @@ -215,6 +215,8 @@ extern _X_EXPORT xf86SetDGAModeProc xf86SetDGAMode;
>  
>  /* xf86Events.c */
>  
> +typedef struct _InputInfoRec *InputInfoPtr;
> +
>  extern _X_EXPORT void SetTimeSinceLastInputEvent(void);
>  extern _X_EXPORT void *xf86AddInputHandler(int fd, InputHandlerProc proc,
>                                               void *data);
> @@ -236,6 +238,8 @@ extern _X_EXPORT void xf86PrintBacktrace(void);
>  extern _X_EXPORT Bool xf86VTOwner(void);
>  extern _X_EXPORT void xf86VTLeave(void);
>  extern _X_EXPORT void xf86VTEnter(void);
> +extern _X_EXPORT void xf86EnableInputDeviceForVTSwitch(InputInfoPtr pInfo);
> +extern _X_EXPORT void xf86DisableInputDeviceForVTSwitch(InputInfoPtr pInfo);
>  
>  /* xf86Helper.c */
>  
> diff --git a/hw/xfree86/common/xf86Events.c b/hw/xfree86/common/xf86Events.c
> index e0ec768..7b53949 100644
> --- a/hw/xfree86/common/xf86Events.c
> +++ b/hw/xfree86/common/xf86Events.c
> @@ -408,6 +408,28 @@ xf86ReleaseKeys(DeviceIntPtr pDev)
>  }
>  
>  void
> +xf86DisableInputDeviceForVTSwitch(InputInfoPtr pInfo)
> +{
> +    if (!pInfo->dev)
> +        return;
> +
> +    if (!pInfo->dev->enabled)
> +        pInfo->flags |= XI86_DEVICE_DISABLED;
> +
> +    xf86ReleaseKeys(pInfo->dev);
> +    ProcessInputEvents();
> +    DisableDevice(pInfo->dev, TRUE);
> +}
> +
> +void
> +xf86EnableInputDeviceForVTSwitch(InputInfoPtr pInfo)
> +{
> +    if (pInfo->dev && (pInfo->flags & XI86_DEVICE_DISABLED) == 0)
> +        EnableDevice(pInfo->dev, TRUE);
> +    pInfo->flags &= ~XI86_DEVICE_DISABLED;
> +}
> +
> +void
>  xf86VTLeave(void)
>  {
>      int i;
> @@ -436,15 +458,8 @@ xf86VTLeave(void)
>          else
>              xf86DisableGeneralHandler(ih);
>      }
> -    for (pInfo = xf86InputDevs; pInfo; pInfo = pInfo->next) {
> -        if (pInfo->dev) {
> -            if (!pInfo->dev->enabled)
> -                pInfo->flags |= XI86_DEVICE_DISABLED;
> -            xf86ReleaseKeys(pInfo->dev);
> -            ProcessInputEvents();
> -            DisableDevice(pInfo->dev, TRUE);
> -        }
> -    }
> +    for (pInfo = xf86InputDevs; pInfo; pInfo = pInfo->next)
> +        xf86DisableInputDeviceForVTSwitch(pInfo);
>  
>      OsBlockSIGIO();
>      for (i = 0; i < xf86NumScreens; i++)
> @@ -494,13 +509,8 @@ switch_failed:
>      }
>      dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset);
>  
> -    pInfo = xf86InputDevs;
> -    while (pInfo) {
> -        if (pInfo->dev && (pInfo->flags & XI86_DEVICE_DISABLED) == 0)
> -            EnableDevice(pInfo->dev, TRUE);
> -        pInfo->flags &= ~XI86_DEVICE_DISABLED;
> -        pInfo = pInfo->next;
> -    }
> +    for (pInfo = xf86InputDevs; pInfo; pInfo = pInfo->next)
> +        xf86EnableInputDeviceForVTSwitch(pInfo);
>      for (ih = InputHandlers; ih; ih = ih->next) {
>          if (ih->is_input)
>              xf86EnableInputHandler(ih);
> @@ -546,14 +556,8 @@ xf86VTEnter(void)
>      /* Turn screen saver off when switching back */
>      dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset);
>  
> -    pInfo = xf86InputDevs;
> -    while (pInfo) {
> -        if (pInfo->dev && (pInfo->flags & XI86_DEVICE_DISABLED) == 0)
> -            EnableDevice(pInfo->dev, TRUE);
> -        pInfo->flags &= ~XI86_DEVICE_DISABLED;
> -        pInfo = pInfo->next;
> -    }
> -
> +    for (pInfo = xf86InputDevs; pInfo; pInfo = pInfo->next)
> +        xf86EnableInputDeviceForVTSwitch(pInfo);
>      for (ih = InputHandlers; ih; ih = ih->next) {
>          if (ih->is_input)
>              xf86EnableInputHandler(ih);
> -- 
> 1.8.4.2
> 
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel
> 


More information about the xorg-devel mailing list