[Spice-devel] [PATCH v2] Remove global "allowed" variable

Jonathon Jongsma jjongsma at redhat.com
Thu Jun 2 15:52:16 UTC 2016


On Thu, 2016-06-02 at 10:50 -0500, Jonathon Jongsma wrote:
> This variable was always the same value as
> dispatcher_allows_client_mouse.
> ---
> Alternate proposal.
> 
> Within reds_update_client_mouse_allowed(), it's not obvious how
> reds->dispatcher_allows_client is relevant, so move the check inside
> reds_set_client_mouse_allowed() instead.

By the way, since this is the only place that reds_set_client_mouse_allowed() is
called, I debated simply removing this static function altogether and moving the
code to the calling location. Preference?

> 
>  server/reds.c | 9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
> 
> diff --git a/server/reds.c b/server/reds.c
> index 827ba2a..5e25d21 100644
> --- a/server/reds.c
> +++ b/server/reds.c
> @@ -1858,6 +1858,9 @@ static void reds_handle_main_link(RedsState *reds,
> RedLinkInfo *link)
>  
>  static void reds_set_client_mouse_allowed(RedsState *reds, int
> is_client_mouse_allowed, int x_res, int y_res)
>  {
> +    if (!(is_client_mouse_allowed || is_client_mouse_allowed != reds-
> >dispatcher_allows_client_mouse))
> +        return;
> +
>      reds->monitor_mode.x_res = x_res;
>      reds->monitor_mode.y_res = y_res;
>      reds->dispatcher_allows_client_mouse = is_client_mouse_allowed;
> @@ -4193,7 +4196,6 @@ void reds_core_timer_remove(RedsState *reds,
>  
>  void reds_update_client_mouse_allowed(RedsState *reds)
>  {
> -    static int allowed = FALSE;
>      int allow_now = FALSE;
>      int x_res = 0;
>      int y_res = 0;
> @@ -4211,10 +4213,7 @@ void reds_update_client_mouse_allowed(RedsState *reds)
>          }
>      }
>  
> -    if (allow_now || allow_now != allowed) {
> -        allowed = allow_now;
> -        reds_set_client_mouse_allowed(reds, allowed, x_res, y_res);
> -    }
> +    reds_set_client_mouse_allowed(reds, allow_now, x_res, y_res);
>  }
>  
>  static gboolean reds_use_client_monitors_config(RedsState *reds)


More information about the Spice-devel mailing list