Re: [PATCH spice-gtk 2/5] gtk: Avoid deprecated gdk_window_get_pointer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Frediano,

On Mon, 2016-12-19 at 04:25 -0500, Frediano Ziglio wrote:
> > 
> > ---
> >  src/spice-widget.c | 46 ++++++++++++++++++++++++++++++++++++-----
> > -----
> >  1 file changed, 36 insertions(+), 10 deletions(-)
> > 
> > diff --git a/src/spice-widget.c b/src/spice-widget.c
> > index a27f5a2..a3d6526 100644
> > --- a/src/spice-widget.c
> > +++ b/src/spice-widget.c
> > @@ -2355,11 +2355,44 @@ static void
> > spice_display_class_init(SpiceDisplayClass *klass)
> >  #define SPICE_GDK_BUTTONS_MASK \
> >      (GDK_BUTTON1_MASK|GDK_BUTTON2_MASK|GDK_BUTTON3_MASK|GDK_BUTTO
> > N4_MASK|GDK_BUTTON5_MASK)
> >  
> > +#if GTK_CHECK_VERSION(3, 20, 0)
> > +static GdkSeat *spice_display_get_default_seat(SpiceDisplay
> > *display)
> > +{
> > +    GdkWindow *window =
> > gtk_widget_get_window(GTK_WIDGET(display));
> > +    GdkDisplay *gdk_display = gdk_window_get_display(window);
> > +    G_GNUC_BEGIN_IGNORE_DEPRECATIONS
> > +    return gdk_display_get_default_seat(gdk_display);
> > +    G_GNUC_END_IGNORE_DEPRECATIONS
> > +}
> > +#endif
> > +
> > +static GdkModifierType
> > spice_display_get_modifiers_state(SpiceDisplay
> > *display)
> > +{
> > +    GdkModifierType modifiers;
> > +    GdkWindow *window =
> > gtk_widget_get_window(GTK_WIDGET(display));
> > +
> > +    if (window == NULL) {
> > +        return 0;
> > +    }
> > +
> > +#if GTK_CHECK_VERSION(3, 20, 0)
> > +    G_GNUC_BEGIN_IGNORE_DEPRECATIONS
> > +    gdk_window_get_device_position(window,
> > +
> > gdk_seat_get_pointer(spice_display_get_default_seat(display)),
> > +                                   NULL,
> > +                                   NULL,
> > +                                   &modifiers);
> > +    G_GNUC_END_IGNORE_DEPRECATIONS
> > +#else
> > +    gdk_window_get_pointer(window, NULL, NULL, &modifiers);
> > +#endif
> 
> Why we need to call gdk_seat_get_pointer at all?
> We don't support 2.x anymore and gdk_seat_get_pointer was deprecated
from 3.0 so we should just move to gdk_window_get_device_position.
> Is it not possible to get the device from display/window ?
If we consider deprecated functions than it is possible to get the
device only from the seat

> Also this code compiled with Gdk < 3.20 will trigger a deprecated
> warning calling gdk_window_get_pointer witch is the opposite of
> the rationale.
It is not my rationale. I am more worried with the code not compiling
using gtk master.
Deprecation warnings are not considered as error since the commit
f8e0516ba7f6dcc8b27e02e80fd6f3d23a03e816

> I think part of the issue is that you started using
> gdk_display_get_default_seat to avoid gdk_display_get_device_manager

I don't like the idea of introducing the usage of deprecated functions
to the current code.

> deprecation warning but the rationale then is misleading, you should
> start using gdk_window_get_device_position always with an helper
> to get the device supporting both Gdk < 3.20 and Gdk >= 3.20.
okay

Pavel
> 
> > +    return modifiers;
> > +}
> > +
> >  static void update_mouse_mode(SpiceChannel *channel, gpointer
> > data)
> >  {
> >      SpiceDisplay *display = data;
> >      SpiceDisplayPrivate *d = display->priv;
> > -    GdkWindow *window =
> > gtk_widget_get_window(GTK_WIDGET(display));
> >  
> >      g_object_get(channel, "mouse-mode", &d->mouse_mode, NULL);
> >      SPICE_DEBUG("mouse mode %u", d->mouse_mode);
> > @@ -2372,15 +2405,8 @@ static void update_mouse_mode(SpiceChannel
> > *channel,
> > gpointer data)
> >          d->mouse_guest_x = -1;
> >          d->mouse_guest_y = -1;
> >  
> > -        if (window != NULL) {
> > -            GdkModifierType modifiers;
> > -            /* FIXME: gdk_window_get_pointer() is deprecated */
> > -            G_GNUC_BEGIN_IGNORE_DEPRECATIONS
> > -            gdk_window_get_pointer(window, NULL, NULL,
> > &modifiers);
> > -            G_GNUC_END_IGNORE_DEPRECATIONS
> > -
> > -            if (modifiers & SPICE_GDK_BUTTONS_MASK)
> > -                try_mouse_grab(display);
> > +        if (spice_display_get_modifiers_state(display) &
> > SPICE_GDK_BUTTONS_MASK) {
> > +            try_mouse_grab(display);
> >          }
> >          break;
> >      default:
> 
> Frediano
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]