After four years of development finally the release of the new GTK 4.0 branch was announced, which is being developed as part of a new development process that attempts to provide application developers with a stable and compatible API for several years, which can be used without fear of having to redo applications every six months due to API changes in the next GTK branch.
The GTK 4 branch has been declared stable and will be used in the next GNOME 4.0 release. At the same time, it was announced that support for the GTK 2 branch was discontinued, in a few days for which the latest release is planned to be released, while support for the GTK 3 branch will continue for the foreseeable future.
Main new features of GTK 4.0
Of the changes that stand out in this new branch, we can find that a restricted design method was implemented, in which the location and size of child elements are determined based on the distance to the edges and the size of other elements.
Besides that added a rendering module based on the Vulkan graphics API, which implements shaders for many resource-intensive CSS elements used in GTK widgets and GSK has been integrated (GTK Scene Kit) with scene graphics rendering capabilities via OpenGL and Vulkan.
The organization of the representation has been revised: instead of sending it to the buffer, now a model based on rendering nodes is used, in which the output is organized in the form of a high-level operations tree, processed efficiently by the GPU using OpenGL and Vulkan.
We can also see that in GTK 4.0 a modernized event delivery model is proposed, which makes it possible to bypass a subwindow when routing input events. The need to implement a new model is associated with a more active use of animation effects, which must be rendered without changing the layout of the visible elements and, consequently, without a subwindow.
GDK API reformulated to take advantage of the Wayland protocol and related concepts. The X11 and Wayland related functions have been moved to separate backends and a large API cleanup has been done, including the removal of the GtkMenu, GtkMenuBar and GtkToolbar classes, instead of which the GMenu and popover options are suggested.
While for widget development, a new GtkLayoutManager object is presented with the implementation of the control system for the arrangement of elements based on the size of the visible area and that GtkLayoutManager has replaced the child properties in GTK containers such as GtkBox and GtkGrid.
Of the other changes that stand out:
- A new GtkNative class has been added for widgets that have their own display surface and can work separately on the first level, without being linked to the main widgets.
- New widgets have been added including GtkPicture, GtkText, GtkPasswordEntry, GtkListView, GtkGridView, GtkColumnView, as well as a widget to display Emoji.
- A new abstraction layer, GdkPaintable, has been added that renders objects that can be drawn anywhere and at any size, without having to sort the design layers.
- Broadway backend rewritten to allow rendering of GTK library output in a web browser window.
- The API related to drag and drop operations has been redesigned, including the proposed separate GdkDrag and GdkDrop objects.
- The previous implementation of the Accessibility API for people with disabilities has been removed and a new version based on the ARIA specification and the GtkAccessible widget has been proposed.
- Added support for editable labels
- The GtkTreeView widget implements the ability to edit cells.
- Added support for incremental scrolling and filtering to GtkFilterListModel and GtkSortListModel.
- Added a new GDK backend for macOS.
GtkTextView and other input widgets have a built-in undo stack.
- For Windows, a new ANGLE-based GDK rendering backend is offered, an intermediate layer for translating calls from OpenGL ES to OpenGL, Direct3D 9/11, Desktop GL, and Vulkan.