* [Qemu-devel] [PATCH] gtk: fix compilation warning with gtk 3.22.2
@ 2016-10-26 15:21 Alberto Garcia
2016-10-26 15:35 ` Alberto Garcia
0 siblings, 1 reply; 3+ messages in thread
From: Alberto Garcia @ 2016-10-26 15:21 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann, Alberto Garcia
gdk_screen_get_width() is deprecated since gtk 3.22.2, use
gdk_monitor_get_geometry() instead if it's available.
Signed-off-by: Alberto Garcia <berto@igalia.com>
---
ui/gtk.c | 23 +++++++++++++++++++++--
1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/ui/gtk.c b/ui/gtk.c
index 25e6d99..dd13982 100644
--- a/ui/gtk.c
+++ b/ui/gtk.c
@@ -912,9 +912,28 @@ static gboolean gd_motion_event(GtkWidget *widget, GdkEventMotion *motion,
if (!qemu_input_is_absolute() && s->ptr_owner == vc) {
GdkScreen *screen = gtk_widget_get_screen(vc->gfx.drawing_area);
+ int screen_width, screen_height;
+
int x = (int)motion->x_root;
int y = (int)motion->y_root;
+#if GTK_CHECK_VERSION(3, 22, 0)
+ {
+ GdkDisplay *dpy = gtk_widget_get_display(widget);
+ GdkWindow *win = gtk_widget_get_window(widget);
+ GdkMonitor *monitor = gdk_display_get_monitor_at_window(dpy, win);
+ GdkRectangle geometry;
+ gdk_monitor_get_geometry(monitor, &geometry);
+ screen_width = geometry.width;
+ screen_height = geometry.height;
+ }
+#else
+ {
+ screen_width = gdk_screen_get_width(screen);
+ screen_height = gdk_screen_get_height(screen);
+ }
+#endif
+
/* In relative mode check to see if client pointer hit
* one of the screen edges, and if so move it back by
* 200 pixels. This is important because the pointer
@@ -928,10 +947,10 @@ static gboolean gd_motion_event(GtkWidget *widget, GdkEventMotion *motion,
if (y == 0) {
y += 200;
}
- if (x == (gdk_screen_get_width(screen) - 1)) {
+ if (x == (screen_width - 1)) {
x -= 200;
}
- if (y == (gdk_screen_get_height(screen) - 1)) {
+ if (y == (screen_height - 1)) {
y -= 200;
}
--
2.9.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] gtk: fix compilation warning with gtk 3.22.2
2016-10-26 15:21 [Qemu-devel] [PATCH] gtk: fix compilation warning with gtk 3.22.2 Alberto Garcia
@ 2016-10-26 15:35 ` Alberto Garcia
2016-10-27 11:50 ` Gerd Hoffmann
0 siblings, 1 reply; 3+ messages in thread
From: Alberto Garcia @ 2016-10-26 15:35 UTC (permalink / raw)
To: qemu-devel; +Cc: Gerd Hoffmann
On Wed 26 Oct 2016 05:21:08 PM CEST, Alberto Garcia wrote:
> +#else
> + {
> + screen_width = gdk_screen_get_width(screen);
> + screen_height = gdk_screen_get_height(screen);
> + }
> +#endif
I forgot to remove these braces, they are actually not necessary, so
whoever applies the patch can remove them if they want. I don't mind if
we keep them for clarity, though, I'm fine either way.
Berto
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] gtk: fix compilation warning with gtk 3.22.2
2016-10-26 15:35 ` Alberto Garcia
@ 2016-10-27 11:50 ` Gerd Hoffmann
0 siblings, 0 replies; 3+ messages in thread
From: Gerd Hoffmann @ 2016-10-27 11:50 UTC (permalink / raw)
To: Alberto Garcia; +Cc: qemu-devel
On Mi, 2016-10-26 at 17:35 +0200, Alberto Garcia wrote:
> On Wed 26 Oct 2016 05:21:08 PM CEST, Alberto Garcia wrote:
> > +#else
> > + {
> > + screen_width = gdk_screen_get_width(screen);
> > + screen_height = gdk_screen_get_height(screen);
> > + }
> > +#endif
>
> I forgot to remove these braces, they are actually not necessary, so
> whoever applies the patch can remove them if they want. I don't mind if
> we keep them for clarity, though, I'm fine either way.
Taking patch as-is, I find it more readable with the braces.
thanks,
Gerd
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-10-27 12:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-26 15:21 [Qemu-devel] [PATCH] gtk: fix compilation warning with gtk 3.22.2 Alberto Garcia
2016-10-26 15:35 ` Alberto Garcia
2016-10-27 11:50 ` Gerd Hoffmann
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.