[Spice-devel] [PATCH spice-server 05/22] reds: use bool for RedsState::dispatcher_allows_client_mouse
Christophe Fergeau
cfergeau at redhat.com
Fri Jun 16 14:11:08 UTC 2017
On Fri, Jun 16, 2017 at 09:56:55AM -0400, Frediano Ziglio wrote:
> >
> > On Fri, Jun 16, 2017 at 10:13:17AM +0100, Frediano Ziglio wrote:
> > > Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> > > ---
> > > server/reds-private.h | 2 +-
> > > server/reds.c | 6 +++---
> > > 2 files changed, 4 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/server/reds-private.h b/server/reds-private.h
> > > index 227827d..5aebd5c 100644
> > > --- a/server/reds-private.h
> > > +++ b/server/reds-private.h
> > > @@ -103,7 +103,7 @@ struct RedsState {
> > > GList *channels;
> > > int mouse_mode;
> > > int is_client_mouse_allowed;
> > > - int dispatcher_allows_client_mouse;
> > > + bool dispatcher_allows_client_mouse;
> > > MonitorMode monitor_mode;
> > > SpiceTimer *mig_timer;
> > >
> > > diff --git a/server/reds.c b/server/reds.c
> > > index 5b6bb1a..e1bac2d 100644
> > > --- a/server/reds.c
> > > +++ b/server/reds.c
> > > @@ -4318,7 +4318,7 @@ void reds_core_timer_remove(RedsState *reds,
> > >
> > > void reds_update_client_mouse_allowed(RedsState *reds)
> > > {
> > > - int allow_now = FALSE;
> > > + bool allow_now = false;
> > > int x_res = 0;
> > > int y_res = 0;
> > > int num_active_workers = g_list_length(reds->qxl_instances);
> > > @@ -4327,10 +4327,10 @@ void reds_update_client_mouse_allowed(RedsState
> > > *reds)
> > > GListIter it;
> > > QXLInstance *qxl;
> > >
> > > - allow_now = TRUE;
> > > + allow_now = true;
> > > FOREACH_QXL_INSTANCE(reds, it, qxl) {
> > > if (red_qxl_get_primary_active(qxl)) {
> > > - allow_now = red_qxl_get_allow_client_mouse(qxl, &x_res,
> > > &y_res);
> > > + allow_now = !!red_qxl_get_allow_client_mouse(qxl, &x_res,
> > > &y_res);
> >
> > red_qxl_get_allow_client_mouse returns a gboolean for now, I think it
> > should be up to it to do the return !!foo; if needed, not to its caller.
> >
> > Christophe
> >
>
> I can do it although I prefer the !! as a gboolean -> bool (although gboolean
> should be 0/1 in any case too).
gboolean should already be TRUE or FALSE (ie 0 or 1), I would use !!
when converting from 'something' to gboolean to make sure we get 0/1.
If I see !! in a gboolean -> bool conversion, I would assume that the
gboolean might be > 1, so something would be wrong somewhere.
>
> A bit OT but not much, in red-qxl.c we have
>
> qxl_state->use_hardware_cursor = surface->mouse_mode;
>
> but use_hardware_cursor is always used as a flag. Being mouse_mode a flag
> (see spice-common/spice.proto) basically use_hardware_cursor is always true
> if there's a surface.
Hmm, sounds odd indeed :-/
Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20170616/c11a23fd/attachment.sig>
More information about the Spice-devel
mailing list