Skip to contentSkip to conversation

gtk: Replace gdk_cursor_new()

PATCH In review Max Reitz 2 participants 2 messages May 20, 2015

lore
Share & tools
lore

Max Reitz

author
#0 lore raw

PATCH 1/1 gtk: Replace gdk_cursor_new()

gdk_cursor_new() has been deprecated in GTK 3.16, it is recommended to use gdk_cursor_new_for_display() instead, so do that.

---
 ui/gtk.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
ui/gtk.c +4 -1
index c58028f..b9abee1 100644
@@ -1875,6 +1875,7 @@ void gtk_display_init(DisplayState *ds, bool full_screen, bool grab_on_hover)
 {
     GtkDisplayState *s = g_malloc0(sizeof(*s));
     char *filename;
+    GdkDisplay *window_display;
 
     gtk_init(NULL, NULL);
 
@@ -1893,7 +1894,9 @@ void gtk_display_init(DisplayState *ds, bool full_screen, bool grab_on_hover)
     bindtextdomain("qemu", CONFIG_QEMU_LOCALEDIR);
     textdomain("qemu");
 
-    s->null_cursor = gdk_cursor_new(GDK_BLANK_CURSOR);
+    window_display = gtk_widget_get_display(s->window);
+    s->null_cursor = gdk_cursor_new_for_display(window_display,
+                                                GDK_BLANK_CURSOR);
 
     s->mouse_mode_notifier.notify = gd_mouse_mode_change;
     qemu_add_mouse_mode_change_notifier(&s->mouse_mode_notifier);
Signature · 1 line
2.4.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 22 lines · Max Reitz

gdk_cursor_new() has been deprecated in GTK 3.16, it is recommended to use gdk_cursor_new_for_display() instead, so do that.

---
 ui/gtk.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
ui/gtk.c +1 -0
index c58028f..b9abee1 100644
@@ -1875,6 +1875,7 @@ void gtk_display_init(DisplayState *ds, bool full_screen, bool grab_on_hover)
 {
     GtkDisplayState *s = g_malloc0(sizeof(*s));
     char *filename;
+    GdkDisplay *window_display;
 
     gtk_init(NULL, NULL);
 

ui/gtk.c void gtk_display_init(DisplayState *ds, bool full_screen, bool grab_on_hover) · line 1902

Quoted 10 lines
ui/gtk.c +3 -1
@@ -1893,7 +1894,9 @@ void gtk_display_init(DisplayState *ds, bool full_screen, bool grab_on_hover)
     bindtextdomain("qemu", CONFIG_QEMU_LOCALEDIR);
     textdomain("qemu");
 
-    s->null_cursor = gdk_cursor_new(GDK_BLANK_CURSOR);
+    window_display = gtk_widget_get_display(s->window);
+    s->null_cursor = gdk_cursor_new_for_display(window_display,
+                                                GDK_BLANK_CURSOR);
 
     s->mouse_mode_notifier.notify = gd_mouse_mode_change;
     qemu_add_mouse_mode_change_notifier(&s->mouse_mode_notifier);

Docs say gdk_cursor_new_for_display is around since gtk 2.2, so looks fine to use unconditionally

- Cole