[Spice-devel] [spice-gtk 4/4] gtk-deprecated: Avoid gdk_screen_get_width/height()
Frediano Ziglio
fziglio at redhat.com
Fri Jul 20 17:26:24 UTC 2018
>
> From: Victor Toso <me at victortoso.com>
>
> As those were deprecated in favor of fetching for information directly
> with GdkMonitor.
>
> Warnings fixed:
> | spice-widget.c: In function ‘mouse_wrap’:
> | spice-widget.c:1136:5: warning: ‘gdk_screen_get_width’ is deprecated
> |
> | xr = gdk_screen_get_width(screen) / 2;
> | ^~
> |
> | spice-widget.c:1137:5: warning: ‘gdk_screen_get_height’ is deprecated
> |
> | yr = gdk_screen_get_height(screen) / 2;
> | ^~
>
> Signed-off-by: Victor Toso <victortoso at redhat.com>
> ---
> src/spice-widget.c | 18 ++++++++++++------
> 1 file changed, 12 insertions(+), 6 deletions(-)
>
> diff --git a/src/spice-widget.c b/src/spice-widget.c
> index dc8ee40..f823b41 100644
> --- a/src/spice-widget.c
> +++ b/src/spice-widget.c
> @@ -1132,16 +1132,22 @@ static void mouse_wrap(SpiceDisplay *display,
> GdkEventMotion *motion)
> d->mouse_last_x = -1;
> d->mouse_last_y = -1;
> #else
> - GdkScreen *screen = gtk_widget_get_screen(GTK_WIDGET(display));
> - xr = gdk_screen_get_width(screen) / 2;
> - yr = gdk_screen_get_height(screen) / 2;
> + GdkRectangle geom;
> + GdkWindow *gdk_window =
> GDK_WINDOW(gtk_widget_get_window(GTK_WIDGET(display)));
No reasons to convert a GdkWindow* in a GdkWindow*.
> + GdkDisplay *gdk_display = gdk_window_get_display(gdk_window);
> + GdkMonitor *monitor = gdk_display_get_primary_monitor(gdk_display);
> + gdk_monitor_get_geometry(monitor, &geom);
> +
> + xr = geom.width / 2;
> + yr = geom.height / 2;
>
> if (xr != (gint)motion->x_root || yr != (gint)motion->y_root) {
> - GdkWindow *window = gtk_widget_get_window(GTK_WIDGET(display));
> /* FIXME: we try our best to ignore that next pointer move event..
> */
> - gdk_display_sync(gdk_screen_get_display(screen));
> + gdk_display_sync(gdk_display);
>
> - gdk_device_warp(spice_gdk_window_get_pointing_device(window),
> screen, xr, yr);
> + gdk_device_warp(spice_gdk_window_get_pointing_device(gdk_window),
> + gdk_window_get_screen(gdk_window),
> + xr, yr);
> d->mouse_last_x = -1;
> d->mouse_last_y = -1;
> }
Frediano
More information about the Spice-devel
mailing list