Hi guys, I am trying to learn GTK and example 3 uses a deprecated function called gdk_surface_create_similar_surface. However, I don't know what to use instead of this.
This is the relevant example
https://docs.gtk.org/gtk4/getting_started.html#drawing-in-response-to-input
compiled with
gcc $(pkg-config --cflags gtk4) -o example example-3 example-3.c $(pkg-config -- libs gtk4)
This is the error I get,
example-3.c: In function ‘resize_cb’:
example-3.c:30:9: warning: ‘gdk_surface_create_similar_surface’ is deprecated [-Wdeprecated-declarations]
30 | surface = gdk_surface_create_similar_surface (gtk_native_get_surface (gtk_widget_get_native (widget)), | ^~~~~~~
In file included from /usr/include/gtk-4.0/gdk/gdkseat.h:27,
from /usr/include/gtk-4.0/gdk/gdkdisplay.h:30,
from /usr/include/gtk-4.0/gdk/gdk.h:43,
from /usr/include/gtk-4.0/gtk/gtk.h:30,
from example-3.c:1:
/usr/include/gtk-4.0/gdk/gdksurface.h:111:15: note: declared here
111 | gdk_surface_create_similar_surface (GdkSurface *surface,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: cannot find example-3: No such file or directory
collect2: error: ld returned 1 exit status
Gtk documentation
https://docs.gtk.org/gdk4/method.Surface.create_similar_surface.html