[spice-gtk v2 4/4] gtk-deprecated: Avoid gdk_screen_get_width/height()

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

 



From: Victor Toso <me@xxxxxxxxxxxxxx>

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@xxxxxxxxxx>
---
 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..aebe0f6 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 = gtk_widget_get_window(GTK_WIDGET(display));
+    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;
     }
-- 
2.17.1

_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/spice-devel




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