[Spice-devel] [PATCH spice-gtk v2 1/2] widget: Extend mouse mode debug
Frediano Ziglio
fziglio at redhat.com
Thu Mar 23 17:37:56 UTC 2017
>
> ---
> I always forget the enum value and have to check the spice-protocol
> ---
> src/spice-widget.c | 15 ++++++++++++++-
> 1 file changed, 14 insertions(+), 1 deletion(-)
>
> diff --git a/src/spice-widget.c b/src/spice-widget.c
> index f548b0d..ef320eb 100644
> --- a/src/spice-widget.c
> +++ b/src/spice-widget.c
> @@ -2444,13 +2444,26 @@ static GdkModifierType
> spice_display_get_modifiers_state(SpiceDisplay *display)
> return modifiers;
> }
>
> +static const gchar* mouse_mode_to_str(guint mode)
> +{
> + const gchar *mouse_mode_str[] = {
I would say
static const gchar *const mouse_mode_str[] = {
> + [SPICE_MOUSE_MODE_CLIENT] = "client",
> + [SPICE_MOUSE_MODE_SERVER] = "server",
> + };
> +
> + if (mode < G_N_ELEMENTS(mouse_mode_str) && mouse_mode_str[mode] != NULL)
> {
> + return mouse_mode_str[mode];
> + }
> + return "unknown";
> +}
> +
> static void update_mouse_mode(SpiceChannel *channel, gpointer data)
> {
> SpiceDisplay *display = data;
> SpiceDisplayPrivate *d = display->priv;
>
> g_object_get(channel, "mouse-mode", &d->mouse_mode, NULL);
> - SPICE_DEBUG("mouse mode %u", d->mouse_mode);
> + SPICE_DEBUG("mouse mode %u (%s)", d->mouse_mode,
> mouse_mode_to_str(d->mouse_mode));
>
> switch (d->mouse_mode) {
> case SPICE_MOUSE_MODE_CLIENT:
Beside that looks fine.
Frediano
More information about the Spice-devel
mailing list