[Spice-commits] src/spice-widget.c
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Fri Feb 22 15:43:19 UTC 2019
src/spice-widget.c | 5 +++++
1 file changed, 5 insertions(+)
New commits:
commit 994435ce843798451fcd1af40d094dd9ce045829
Author: Victor Toso <me at victortoso.com>
Date: Tue Feb 12 15:56:51 2019 +0000
widget: mouse: Fix getting coordinates
Documentation for gdk_display_get_primary_monitor() says that it
returns "the primary monitor, or NULL if no primary monitor is
configured by the user".
If monitor end up being NULL, we end up using uninitialized
GdkRectangle geom later on as gdk_monitor_get_geometry() will fail
with:
| gdk_monitor_get_geometry: assertion 'GDK_IS_MONITOR (monitor)' failed
This patch tries gdk_display_get_monitor_at_point() and will fail if
no GdkMonitor is set.
Signed-off-by: Victor Toso <victortoso at redhat.com>
Acked-by: Frediano Ziglio <fziglio at redhat.com>
diff --git a/src/spice-widget.c b/src/spice-widget.c
index d924731..1f2a154 100644
--- a/src/spice-widget.c
+++ b/src/spice-widget.c
@@ -1166,6 +1166,11 @@ static void mouse_wrap(SpiceDisplay *display, GdkEventMotion *motion)
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);
+ if (monitor == NULL) {
+ /* No primary monitor set, using last mouse coordinates */
+ monitor = gdk_display_get_monitor_at_point(gdk_display, d->mouse_last_x, d->mouse_last_y);
+ }
+ g_return_if_fail(monitor != NULL);
gdk_monitor_get_geometry(monitor, &geom);
xr = geom.width / 2;
More information about the Spice-commits
mailing list